From 60c84b38b5d8146a0df1ece0e9fbd9a66a986da0 Mon Sep 17 00:00:00 2001 From: Jacob Keeler Date: Tue, 1 Nov 2016 15:12:20 -0400 Subject: Inclusion of PLAY_PAUSE as a subscribable button --- src/appMain/hmi_capabilities.json | 6 ++++++ .../src/commands/mobile/subscribe_button_request.cc | 3 ++- src/components/application_manager/src/hmi_capabilities_impl.cc | 2 ++ src/components/application_manager/test/hmi_capabilities.json | 6 ++++++ src/components/interfaces/HMI_API.xml | 1 + src/components/interfaces/Json_HMI_message_specification.txt | 7 +++++++ src/components/interfaces/MOBILE_API.xml | 1 + src/components/interfaces/QT_HMI_API.xml | 1 + src/components/utils/test/test_generator/MOBILE_API.xml | 1 + tools/intergen/test/test_hmi_interface.xml | 1 + 10 files changed, 28 insertions(+), 1 deletion(-) diff --git a/src/appMain/hmi_capabilities.json b/src/appMain/hmi_capabilities.json index 41cf1d3bee..11ac7ccccf 100755 --- a/src/appMain/hmi_capabilities.json +++ b/src/appMain/hmi_capabilities.json @@ -421,6 +421,12 @@ "longPressAvailable" :true, "upDownAvailable" :true }, + { + "name":"PLAY_PAUSE", + "shortPressAvailable":true, + "longPressAvailable" :true, + "upDownAvailable" :true + }, { "name":"SEEKLEFT", "shortPressAvailable":true, diff --git a/src/components/application_manager/src/commands/mobile/subscribe_button_request.cc b/src/components/application_manager/src/commands/mobile/subscribe_button_request.cc index eb6bbf545e..83121a91bd 100644 --- a/src/components/application_manager/src/commands/mobile/subscribe_button_request.cc +++ b/src/components/application_manager/src/commands/mobile/subscribe_button_request.cc @@ -95,7 +95,8 @@ void SubscribeButtonRequest::Run() { bool SubscribeButtonRequest::IsSubscriptionAllowed( ApplicationSharedPtr app, mobile_apis::ButtonName::eType btn_id) { if (!app->is_media_application() && - ((mobile_apis::ButtonName::SEEKLEFT == btn_id) || + ((mobile_apis::ButtonName::PLAY_PAUSE == btn_id) || + (mobile_apis::ButtonName::SEEKLEFT == btn_id) || (mobile_apis::ButtonName::SEEKRIGHT == btn_id) || (mobile_apis::ButtonName::TUNEUP == btn_id) || (mobile_apis::ButtonName::TUNEDOWN == btn_id))) { diff --git a/src/components/application_manager/src/hmi_capabilities_impl.cc b/src/components/application_manager/src/hmi_capabilities_impl.cc index c6fa321401..d7ffa10178 100644 --- a/src/components/application_manager/src/hmi_capabilities_impl.cc +++ b/src/components/application_manager/src/hmi_capabilities_impl.cc @@ -73,6 +73,8 @@ void InitCapabilities() { button_enum_name.insert( std::make_pair(std::string("OK"), hmi_apis::Common_ButtonName::OK)); + button_enum_name.insert(std::make_pair( + std::string("PLAY_PAUSE"), hmi_apis::Common_ButtonName::PLAY_PAUSE)); button_enum_name.insert(std::make_pair( std::string("SEEKLEFT"), hmi_apis::Common_ButtonName::SEEKLEFT)); button_enum_name.insert(std::make_pair( diff --git a/src/components/application_manager/test/hmi_capabilities.json b/src/components/application_manager/test/hmi_capabilities.json index c174dfcba4..89524971fe 100644 --- a/src/components/application_manager/test/hmi_capabilities.json +++ b/src/components/application_manager/test/hmi_capabilities.json @@ -421,6 +421,12 @@ "longPressAvailable" :true, "upDownAvailable" :true }, + { + "name":"PLAY_PAUSE", + "shortPressAvailable":true, + "longPressAvailable" :true, + "upDownAvailable" :true + }, { "name":"SEEKLEFT", "shortPressAvailable":true, diff --git a/src/components/interfaces/HMI_API.xml b/src/components/interfaces/HMI_API.xml index 022053f96a..be0b0ad874 100644 --- a/src/components/interfaces/HMI_API.xml +++ b/src/components/interfaces/HMI_API.xml @@ -76,6 +76,7 @@ Defines the hard (physical) and soft (touchscreen) buttons available from SYNC + diff --git a/src/components/interfaces/Json_HMI_message_specification.txt b/src/components/interfaces/Json_HMI_message_specification.txt index 9f5b20a3c4..f464f42351 100644 --- a/src/components/interfaces/Json_HMI_message_specification.txt +++ b/src/components/interfaces/Json_HMI_message_specification.txt @@ -265,6 +265,13 @@ Notifications: "upDownAvailable" : true }, + { + "longPressAvailable" : true, + "name" : "PLAY_PAUSE", + "shortPressAvailable" : true, + "upDownAvailable" : true + }, + { "longPressAvailable" : true, "name" : "SEEKLEFT", diff --git a/src/components/interfaces/MOBILE_API.xml b/src/components/interfaces/MOBILE_API.xml index d0326ce647..1fd13d489c 100644 --- a/src/components/interfaces/MOBILE_API.xml +++ b/src/components/interfaces/MOBILE_API.xml @@ -489,6 +489,7 @@ Defines the hard (physical) and soft (touchscreen) buttons available from SYNC + diff --git a/src/components/interfaces/QT_HMI_API.xml b/src/components/interfaces/QT_HMI_API.xml index 85a4d4143f..cc4bd62015 100644 --- a/src/components/interfaces/QT_HMI_API.xml +++ b/src/components/interfaces/QT_HMI_API.xml @@ -70,6 +70,7 @@ Defines the hard (physical) and soft (touchscreen) buttons available from SYNC + diff --git a/src/components/utils/test/test_generator/MOBILE_API.xml b/src/components/utils/test/test_generator/MOBILE_API.xml index f5d1c691b7..9642db692e 100644 --- a/src/components/utils/test/test_generator/MOBILE_API.xml +++ b/src/components/utils/test/test_generator/MOBILE_API.xml @@ -493,6 +493,7 @@ Defines the hard (physical) and soft (touchscreen) buttons available from SYNC + diff --git a/tools/intergen/test/test_hmi_interface.xml b/tools/intergen/test/test_hmi_interface.xml index e091909833..e85060abbb 100644 --- a/tools/intergen/test/test_hmi_interface.xml +++ b/tools/intergen/test/test_hmi_interface.xml @@ -66,6 +66,7 @@ Defines the hard (physical) and soft (touchscreen) buttons available from SYNC + -- cgit v1.2.1 From 203aedc01958fe8e0825f70599f8cda0f621ae5c Mon Sep 17 00:00:00 2001 From: Jacob Keeler Date: Tue, 1 Nov 2016 17:01:02 -0400 Subject: Fix HMI capabilities test failure --- src/components/application_manager/test/hmi_capabilities_test.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/application_manager/test/hmi_capabilities_test.cc b/src/components/application_manager/test/hmi_capabilities_test.cc index 738797b122..945578f586 100644 --- a/src/components/application_manager/test/hmi_capabilities_test.cc +++ b/src/components/application_manager/test/hmi_capabilities_test.cc @@ -236,7 +236,7 @@ TEST_F(HMICapabilitiesTest, LoadCapabilitiesFromFile) { // Count of buttons in json file const uint32_t btn_length = buttons_capabilities_so.length(); - EXPECT_EQ(15u, btn_length); + EXPECT_EQ(16u, btn_length); for (uint32_t i = 0; i < btn_length; ++i) { EXPECT_TRUE((buttons_capabilities_so[i]).keyExists(strings::name)); EXPECT_TRUE((buttons_capabilities_so[i]).keyExists("shortPressAvailable")); -- cgit v1.2.1 From aaa9e66237066a135b92607413638be4ec829f35 Mon Sep 17 00:00:00 2001 From: Jacob Keeler Date: Thu, 1 Mar 2018 16:26:05 -0500 Subject: Check result of TransportManager Init function --- src/appMain/life_cycle.cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/appMain/life_cycle.cc b/src/appMain/life_cycle.cc index 3bf0e62f87..a03ea3a8ee 100644 --- a/src/appMain/life_cycle.cc +++ b/src/appMain/life_cycle.cc @@ -180,7 +180,10 @@ bool LifeCycle::StartComponents() { // [TM -> CH -> AM], otherwise some events from TM could arrive at nowhere app_manager_->set_protocol_handler(protocol_handler_); - transport_manager_->Init(*last_state_); + if (!transport_manager_->Init(*last_state_)) { + LOG4CXX_ERROR(logger_, "Transport manager init failed."); + return false; + } // start transport manager transport_manager_->Visibility(true); -- cgit v1.2.1 From da112964563b41641f89dc9d67d6f76a20319b56 Mon Sep 17 00:00:00 2001 From: jacobkeeler Date: Fri, 2 Mar 2018 16:43:15 -0500 Subject: Delete unused `SetIcon` RPC message files --- src/components/application_manager/CMakeLists.txt | 1 - .../commands/hmi/ui_set_icon_request.h | 73 ----------- .../commands/hmi/ui_set_icon_response.h | 72 ----------- .../commands/mobile/set_icon_request.h | 87 ------------- .../commands/mobile/set_icon_response.h | 74 ----------- .../src/commands/hmi/ui_set_icon_request.cc | 53 -------- .../src/commands/mobile/set_icon_request.cc | 140 --------------------- .../src/commands/mobile/set_icon_response.cc | 55 -------- .../test/commands/hmi/dummy_hmi_commands_test.cc | 1 - .../commands/hmi/simple_requests_to_hmi_test.cc | 1 - 10 files changed, 557 deletions(-) delete mode 100644 src/components/application_manager/include/application_manager/commands/hmi/ui_set_icon_request.h delete mode 100644 src/components/application_manager/include/application_manager/commands/hmi/ui_set_icon_response.h delete mode 100644 src/components/application_manager/include/application_manager/commands/mobile/set_icon_request.h delete mode 100644 src/components/application_manager/include/application_manager/commands/mobile/set_icon_response.h delete mode 100644 src/components/application_manager/src/commands/hmi/ui_set_icon_request.cc delete mode 100644 src/components/application_manager/src/commands/mobile/set_icon_request.cc delete mode 100644 src/components/application_manager/src/commands/mobile/set_icon_response.cc diff --git a/src/components/application_manager/CMakeLists.txt b/src/components/application_manager/CMakeLists.txt index e9f2f8ec7b..0f3371e5bb 100644 --- a/src/components/application_manager/CMakeLists.txt +++ b/src/components/application_manager/CMakeLists.txt @@ -338,7 +338,6 @@ set (HMI_COMMANDS_SOURCES ${COMMANDS_SOURCE_DIR}/hmi/on_event_changed_notification.cc ${COMMANDS_SOURCE_DIR}/hmi/decrypt_certificate_request.cc ${COMMANDS_SOURCE_DIR}/hmi/decrypt_certificate_response.cc - ${COMMANDS_SOURCE_DIR}/hmi/ui_set_icon_request.cc ${COMMANDS_SOURCE_DIR}/hmi/rc_is_ready_request.cc ${COMMANDS_SOURCE_DIR}/hmi/rc_is_ready_response.cc ${COMMANDS_SOURCE_DIR}/hmi/rc_get_capabilities_request.cc diff --git a/src/components/application_manager/include/application_manager/commands/hmi/ui_set_icon_request.h b/src/components/application_manager/include/application_manager/commands/hmi/ui_set_icon_request.h deleted file mode 100644 index b7d759916e..0000000000 --- a/src/components/application_manager/include/application_manager/commands/hmi/ui_set_icon_request.h +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright (c) 2016, 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_COMMANDS_HMI_UI_SET_ICON_REQUEST_H_ -#define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_COMMANDS_HMI_UI_SET_ICON_REQUEST_H_ - -#include "application_manager/commands/hmi/request_to_hmi.h" - -namespace application_manager { - -namespace commands { - -/** - * @brief UISetIconRequest command class - **/ -class UISetIconRequest : public RequestToHMI { - public: - /** - * @brief UISetIconRequest class constructor - * - * @param message Incoming SmartObject message - **/ - UISetIconRequest(const MessageSharedPtr& message, - ApplicationManager& application_manager); - - /** - * @brief UISetIconRequest class destructor - **/ - virtual ~UISetIconRequest(); - - /** - * @brief Execute command - **/ - virtual void Run(); - - private: - DISALLOW_COPY_AND_ASSIGN(UISetIconRequest); -}; - -} // namespace commands - -} // namespace application_manager - -#endif // SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_COMMANDS_HMI_UI_SET_ICON_REQUEST_H_ diff --git a/src/components/application_manager/include/application_manager/commands/hmi/ui_set_icon_response.h b/src/components/application_manager/include/application_manager/commands/hmi/ui_set_icon_response.h deleted file mode 100644 index a9739bc802..0000000000 --- a/src/components/application_manager/include/application_manager/commands/hmi/ui_set_icon_response.h +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright (c) 2016, 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_COMMANDS_HMI_UI_SET_ICON_RESPONSE_H_ -#define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_COMMANDS_HMI_UI_SET_ICON_RESPONSE_H_ - -#include "application_manager/commands/hmi/response_from_hmi.h" - -namespace application_manager { - -namespace commands { - -/** - * @brief UISetIconResponse command class - **/ -class UISetIconResponse : public ResponseFromHMI { - public: - /** - * @brief UISetIconResponse class constructor - * - * @param message Incoming SmartObject message - **/ - UISetIconResponse(const MessageSharedPtr& message); - - /** - * @brief UISetIconResponse class destructor - **/ - virtual ~UISetIconResponse(); - - /** - * @brief Execute command - **/ - virtual void Run(); - - private: - DISALLOW_COPY_AND_ASSIGN(UISetIconResponse); -}; - -} // namespace commands - -} // namespace application_manager - -#endif // SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_COMMANDS_HMI_UI_SET_ICON_RESPONSE_H_ diff --git a/src/components/application_manager/include/application_manager/commands/mobile/set_icon_request.h b/src/components/application_manager/include/application_manager/commands/mobile/set_icon_request.h deleted file mode 100644 index 96d4ac6f1e..0000000000 --- a/src/components/application_manager/include/application_manager/commands/mobile/set_icon_request.h +++ /dev/null @@ -1,87 +0,0 @@ -/* - - Copyright (c) 2013, 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_COMMANDS_MOBILE_SET_ICON_REQUEST_H_ -#define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_COMMANDS_MOBILE_SET_ICON_REQUEST_H_ - -#include "application_manager/commands/command_request_impl.h" -#include "application_manager/application_manager.h" -#include "utils/macro.h" - -namespace application_manager { - -namespace commands { - -/** - * @brief SetIconRequest command class - **/ -class SetIconRequest : public CommandRequestImpl { - public: - /** - * @brief Contains information about the type of image - */ - typedef enum { STATIC = 0, DYNAMIC } ImageType; - - /** - * @brief SetIconRequest class constructor - * - * @param message Incoming SmartObject message - **/ - SetIconRequest(const MessageSharedPtr& message, - ApplicationManager& application_manager); - - /** - * @brief SetIconRequest class destructor - **/ - virtual ~SetIconRequest(); - - /** - * @brief Interface method that is called whenever new event received - * - * @param event The received event - */ - void on_event(const event_engine::Event& event); - - /** - * @brief Execute command - **/ - virtual void Run(); - - private: - DISALLOW_COPY_AND_ASSIGN(SetIconRequest); -}; - -} // namespace commands -} // namespace application_manager - -#endif // SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_COMMANDS_MOBILE_SET_ICON_REQUEST_H_ diff --git a/src/components/application_manager/include/application_manager/commands/mobile/set_icon_response.h b/src/components/application_manager/include/application_manager/commands/mobile/set_icon_response.h deleted file mode 100644 index 83be0d4a4b..0000000000 --- a/src/components/application_manager/include/application_manager/commands/mobile/set_icon_response.h +++ /dev/null @@ -1,74 +0,0 @@ -/* - - Copyright (c) 2013, 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_COMMANDS_MOBILE_SET_ICON_RESPONSE_H_ -#define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_COMMANDS_MOBILE_SET_ICON_RESPONSE_H_ - -#include "application_manager/commands/command_response_impl.h" -#include "application_manager/application_manager.h" -#include "utils/macro.h" - -namespace application_manager { - -namespace commands { - -/** - * @brief SetIconResponse command class - **/ -class SetIconResponse : public CommandResponseImpl { - public: - /** - * @brief SetIconResponse class constructor - * - * @param message Incoming SmartObject message - **/ - SetIconResponse(const MessageSharedPtr& message, ApplicationManager& app_man); - - /** - * @brief SetIconResponse class destructor - **/ - virtual ~SetIconResponse(); - - /** - * @brief Execute command - **/ - virtual void Run(); - - private: - DISALLOW_COPY_AND_ASSIGN(SetIconResponse); -}; - -} // namespace commands -} // namespace application_manager - -#endif // SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_COMMANDS_MOBILE_SET_ICON_RESPONSE_H_ diff --git a/src/components/application_manager/src/commands/hmi/ui_set_icon_request.cc b/src/components/application_manager/src/commands/hmi/ui_set_icon_request.cc deleted file mode 100644 index 1653ec0744..0000000000 --- a/src/components/application_manager/src/commands/hmi/ui_set_icon_request.cc +++ /dev/null @@ -1,53 +0,0 @@ -/** - * Copyright (c) 2013, 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/commands/hmi/ui_set_icon_request.h" - -namespace application_manager { - -namespace commands { - -UISetIconRequest::UISetIconRequest(const MessageSharedPtr& message, - ApplicationManager& application_manager) - : RequestToHMI(message, application_manager) {} - -UISetIconRequest::~UISetIconRequest() {} - -void UISetIconRequest::Run() { - LOG4CXX_AUTO_TRACE(logger_); - - SendRequest(); -} - -} // namespace commands - -} // namespace application_manager diff --git a/src/components/application_manager/src/commands/mobile/set_icon_request.cc b/src/components/application_manager/src/commands/mobile/set_icon_request.cc deleted file mode 100644 index 037de54456..0000000000 --- a/src/components/application_manager/src/commands/mobile/set_icon_request.cc +++ /dev/null @@ -1,140 +0,0 @@ -/* - - Copyright (c) 2013, 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/commands/mobile/set_icon_request.h" -#include "application_manager/application_manager.h" -#include "application_manager/application_impl.h" -#include "config_profile/profile.h" -#include "interfaces/MOBILE_API.h" -#include "interfaces/HMI_API.h" -#include "utils/file_system.h" - -namespace application_manager { - -namespace commands { - -SetIconRequest::SetIconRequest(const MessageSharedPtr& message, - ApplicationManager& application_manager) - : CommandRequestImpl(message, application_manager) {} - -SetIconRequest::~SetIconRequest() {} - -void SetIconRequest::Run() { - LOG4CXX_AUTO_TRACE(logger_); - - ApplicationSharedPtr app = application_manager_.application(connection_key()); - - if (!app) { - LOG4CXX_ERROR(logger_, "Application is not registered"); - SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED); - return; - } - - const std::string& sync_file_name = - (*message_)[strings::msg_params][strings::sync_file_name].asString(); - - std::string full_file_path = - application_manager_.get_settings().app_storage_folder() + "/"; - full_file_path += app->folder_name(); - full_file_path += "/"; - full_file_path += sync_file_name; - - if (!file_system::FileExists(full_file_path)) { - LOG4CXX_ERROR(logger_, "No such file " << full_file_path); - SendResponse(false, mobile_apis::Result::INVALID_DATA); - return; - } - - smart_objects::SmartObject msg_params = - smart_objects::SmartObject(smart_objects::SmartType_Map); - - msg_params[strings::app_id] = app->app_id(); - msg_params[strings::sync_file_name] = - smart_objects::SmartObject(smart_objects::SmartType_Map); - - // Panasonic requres unchanged path value without encoded special characters - const std::string full_file_path_for_hmi = - file_system::ConvertPathForURL(full_file_path); - - msg_params[strings::sync_file_name][strings::value] = full_file_path_for_hmi; - - // TODO(VS): research why is image_type hardcoded - msg_params[strings::sync_file_name][strings::image_type] = - static_cast(SetIconRequest::ImageType::DYNAMIC); - - // for further use in on_event function - (*message_)[strings::msg_params][strings::sync_file_name] = - msg_params[strings::sync_file_name]; - StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_UI); - SendHMIRequest(hmi_apis::FunctionID::UI_SetAppIcon, &msg_params, true); -} - -void SetIconRequest::on_event(const event_engine::Event& event) { - LOG4CXX_AUTO_TRACE(logger_); - const smart_objects::SmartObject& message = event.smart_object(); - - switch (event.id()) { - case hmi_apis::FunctionID::UI_SetAppIcon: { - EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_UI); - mobile_apis::Result::eType result_code = - static_cast( - message[strings::params][hmi_response::code].asInt()); - - bool result = mobile_apis::Result::SUCCESS == result_code; - - if (result) { - ApplicationSharedPtr app = - application_manager_.application(connection_key()); - - const std::string path = - (*message_)[strings::msg_params][strings::sync_file_name] - [strings::value].asString(); - app->set_app_icon_path(path); - - LOG4CXX_INFO(logger_, - "Icon path was set to '" << app->app_icon_path() << "'"); - } - - 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/set_icon_response.cc b/src/components/application_manager/src/commands/mobile/set_icon_response.cc deleted file mode 100644 index c140d04f51..0000000000 --- a/src/components/application_manager/src/commands/mobile/set_icon_response.cc +++ /dev/null @@ -1,55 +0,0 @@ -/* - - Copyright (c) 2013, 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/commands/mobile/set_icon_response.h" -#include "application_manager/application_manager.h" - -namespace application_manager { - -namespace commands { - -SetIconResponse::SetIconResponse(const MessageSharedPtr& message, - ApplicationManager& app_man) - : CommandResponseImpl(message, app_man) {} - -SetIconResponse::~SetIconResponse() {} - -void SetIconResponse::Run() { - LOG4CXX_AUTO_TRACE(logger_); - - application_manager_.SendMessageToMobile(message_); -} - -} // namespace commands - -} // namespace application_manager diff --git a/src/components/application_manager/test/commands/hmi/dummy_hmi_commands_test.cc b/src/components/application_manager/test/commands/hmi/dummy_hmi_commands_test.cc index 7c95a4ca2f..316d2aa522 100644 --- a/src/components/application_manager/test/commands/hmi/dummy_hmi_commands_test.cc +++ b/src/components/application_manager/test/commands/hmi/dummy_hmi_commands_test.cc @@ -262,7 +262,6 @@ #include "application_manager/commands/hmi/on_vi_acc_pedal_position_notification.h" #include "application_manager/commands/hmi/on_vi_steering_wheel_angle_notification.h" #include "application_manager/commands/hmi/on_vi_my_key_notification.h" -#include "application_manager/commands/hmi/ui_set_icon_request.h" #include "application_manager/mock_application.h" #include "application_manager/mock_application_manager.h" diff --git a/src/components/application_manager/test/commands/hmi/simple_requests_to_hmi_test.cc b/src/components/application_manager/test/commands/hmi/simple_requests_to_hmi_test.cc index 3fa3aaef3a..5bbfb1f3bb 100644 --- a/src/components/application_manager/test/commands/hmi/simple_requests_to_hmi_test.cc +++ b/src/components/application_manager/test/commands/hmi/simple_requests_to_hmi_test.cc @@ -115,7 +115,6 @@ #include "application_manager/commands/hmi/navi_stop_stream_request.h" #include "application_manager/commands/hmi/navi_subscribe_way_points_request.h" #include "application_manager/commands/hmi/sdl_policy_update.h" -#include "application_manager/commands/hmi/ui_set_icon_request.h" #include "application_manager/commands/hmi/dial_number_request.h" #include "application_manager/commands/hmi/ui_send_haptic_data_request.h" -- cgit v1.2.1 From ccf9073578e5c43f99ca9c8db09a15382129e0bd Mon Sep 17 00:00:00 2001 From: Conlain Kelly Date: Mon, 18 Jun 2018 11:43:53 -0400 Subject: remove struct timeval and use boost time_duration instead also cleans up date_time namespacing but maintains helper functions --- src/3rd_party/CMakeLists.txt | 11 +- .../include/application_manager/application_impl.h | 2 +- .../application_manager/application_manager_impl.h | 2 +- .../include/application_manager/request_info.h | 28 +- .../include/application_manager/request_tracker.h | 2 +- .../application_manager/telemetry_observer.h | 4 +- .../src/app_launch/app_launch_data_json.cc | 4 +- .../application_manager/src/application_impl.cc | 19 +- .../src/application_manager_impl.cc | 18 +- .../src/policies/policy_handler.cc | 8 +- .../application_manager/src/request_controller.cc | 6 +- .../application_manager/src/request_info.cc | 18 +- .../application_manager/src/request_tracker.cc | 15 +- .../test/app_launch/app_launch_data_json_test.cc | 35 +-- .../application_manager/test/request_info_test.cc | 52 ++-- .../include/connection_handler/heartbeat_monitor.h | 2 +- .../connection_handler/src/heartbeat_monitor.cc | 8 +- .../include/protocol_handler/telemetry_observer.h | 6 +- .../protocol_handler/mock_telemetry_observer.h | 2 +- src/components/include/utils/date_time.h | 95 +++--- src/components/include/utils/messagemeter.h | 35 +-- .../policy/policy_external/src/cache_manager.cc | 10 +- .../policy_external/src/policy_manager_impl.cc | 2 +- .../policy_external/src/sql_pt_representation.cc | 4 +- .../src/usage_statistics/counter.cc | 2 +- .../test/policy_manager_impl_ptu_test.cc | 2 +- .../test/policy_manager_impl_user_consent_test.cc | 2 +- .../policy/policy_regular/src/cache_manager.cc | 2 +- .../policy_regular/src/policy_manager_impl.cc | 8 +- .../policy_regular/src/sql_pt_representation.cc | 4 +- .../policy_regular/src/usage_statistics/counter.cc | 2 +- .../test/policy_manager_impl_test.cc | 34 +-- .../include/protocol_handler/multiframe_builder.h | 2 +- .../protocol_handler/src/multiframe_builder.cc | 6 +- .../protocol_handler/src/protocol_handler_impl.cc | 4 +- .../protocol_handler/mock_telemetry_observer.h | 2 +- .../security_manager/src/crypto_manager_impl.cc | 2 +- .../telemetry_monitor/protocol_handler_observer.h | 4 +- .../telemetry_monitor/transport_manager_observer.h | 2 +- .../src/application_manager_metric_wrapper.cc | 4 +- .../src/protocol_handler_metric_wrapper.cc | 4 +- .../src/protocol_handler_observer.cc | 6 +- .../telemetry_monitor/src/telemetry_monitor.cc | 65 ++-- .../src/transport_manager_metric_wrapper.cc | 4 +- .../src/transport_manager_observer.cc | 6 +- .../test/application_manager_metric_test.cc | 29 +- .../test/protocol_handler_metric_test.cc | 30 +- .../test/protocol_handler_observer_test.cc | 10 +- .../test/transport_manager_metric_test.cc | 24 +- .../include/transport_manager/telemetry_observer.h | 4 +- src/components/utils/CMakeLists.txt | 7 +- src/components/utils/src/date_time.cc | 119 +++----- src/components/utils/test/date_time_test.cc | 335 ++++++++------------- src/components/utils/test/messagemeter_test.cc | 42 ++- 54 files changed, 491 insertions(+), 664 deletions(-) diff --git a/src/3rd_party/CMakeLists.txt b/src/3rd_party/CMakeLists.txt index b97c05f7f9..6752f30227 100644 --- a/src/3rd_party/CMakeLists.txt +++ b/src/3rd_party/CMakeLists.txt @@ -30,8 +30,8 @@ include("./set_3rd_party_paths.cmake") -set(3RD_PARTY_SOURCE_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) -set(3RD_PARTY_BINARY_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) +set(3RD_PARTY_SOURCE_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) +set(3RD_PARTY_BINARY_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) set (install-3rd_party_logger_var "") @@ -208,7 +208,7 @@ else() endif() if (HMIADAPTER STREQUAL "messagebroker") - find_package(Boost 1.66.0 COMPONENTS system) + find_package(Boost 1.66.0 COMPONENTS system) set(BOOST_LIB_SOURCE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/boost_src) set(BOOST_LIBS_DIRECTORY ${3RD_PARTY_INSTALL_PREFIX}/lib) SET_PROPERTY(GLOBAL PROPERTY GLOBAL_BOOST_LIBS ${BOOST_LIBS_DIRECTORY}) @@ -225,9 +225,9 @@ if (HMIADAPTER STREQUAL "messagebroker") URL https://dl.bintray.com/boostorg/release/1.66.0/source/boost_1_66_0.tar.gz DOWNLOAD_DIR ${BOOST_LIB_SOURCE_DIRECTORY} SOURCE_DIR ${BOOST_LIB_SOURCE_DIRECTORY} - CONFIGURE_COMMAND ./bootstrap.sh --with-libraries=system --prefix=${3RD_PARTY_INSTALL_PREFIX} + CONFIGURE_COMMAND ./bootstrap.sh --with-libraries=system,thread,date_time --prefix=${3RD_PARTY_INSTALL_PREFIX} BUILD_COMMAND ./b2 - INSTALL_COMMAND ${BOOST_INSTALL_COMMAND} --with-system --prefix=${3RD_PARTY_INSTALL_PREFIX} + INSTALL_COMMAND ${BOOST_INSTALL_COMMAND} --with-system --with-thread --with-date_time --prefix=${3RD_PARTY_INSTALL_PREFIX} INSTALL_DIR ${3RD_PARTY_INSTALL_PREFIX} BUILD_IN_SOURCE true ) @@ -243,4 +243,3 @@ add_custom_target(install-3rd_party DEPENDS Boost WORKING_DIRECTORY ${3RD_PARTY_BINARY_DIRECTORY} ) - diff --git a/src/components/application_manager/include/application_manager/application_impl.h b/src/components/application_manager/include/application_manager/application_impl.h index e033570435..42eba1a64e 100644 --- a/src/components/application_manager/include/application_manager/application_impl.h +++ b/src/components/application_manager/include/application_manager/application_impl.h @@ -503,7 +503,7 @@ class ApplicationImpl : public virtual Application, /** * @brief Defines number per time in seconds limits */ - typedef std::pair TimeToNumberLimit; + typedef std::pair TimeToNumberLimit; /** * @brief Defines specific command number per time in seconds limits 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 30816e0ffa..89a2de96f5 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 @@ -1576,7 +1576,7 @@ class ApplicationManagerImpl * @brief Map contains applications which * will send TTS global properties to HMI after timeout */ - std::map tts_global_properties_app_list_; + std::map tts_global_properties_app_list_; bool audio_pass_thru_active_; uint32_t audio_pass_thru_app_id_; 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 5ebcac71f8..e284e5f618 100644 --- a/src/components/application_manager/include/application_manager/request_info.h +++ b/src/components/application_manager/include/application_manager/request_info.h @@ -62,7 +62,7 @@ struct RequestInfo { , app_id_(0) , requst_type_(RequestNone) , correlation_id_(0) { - start_time_ = date_time::DateTime::getCurrentTime(); + start_time_ = date_time::getCurrentTime(); updateEndTime(); } virtual ~RequestInfo() {} @@ -71,14 +71,14 @@ struct RequestInfo { const RequestType requst_type, const uint64_t timeout_msec) : request_(request), timeout_msec_(timeout_msec), correlation_id_(0) { - start_time_ = date_time::DateTime::getCurrentTime(); + start_time_ = date_time::getCurrentTime(); updateEndTime(); requst_type_ = requst_type; } RequestInfo(RequestPtr request, const RequestType requst_type, - const TimevalStruct& start_time, + const date_time::TimeDuration& start_time, const uint64_t timeout_msec); void updateEndTime(); @@ -87,11 +87,11 @@ struct RequestInfo { bool isExpired(); - TimevalStruct start_time() { + date_time::TimeDuration start_time() { return start_time_; } - void update_start_time(TimevalStruct start_time) { + void update_start_time(date_time::TimeDuration start_time) { start_time_ = start_time; } @@ -103,7 +103,7 @@ struct RequestInfo { timeout_msec_ = timeout; } - TimevalStruct end_time() { + date_time::TimeDuration end_time() { return end_time_; } @@ -128,9 +128,9 @@ struct RequestInfo { protected: RequestPtr request_; - TimevalStruct start_time_; + date_time::TimeDuration start_time_; uint64_t timeout_msec_; - TimevalStruct end_time_; + date_time::TimeDuration end_time_; uint32_t app_id_; RequestType requst_type_; uint32_t correlation_id_; @@ -141,14 +141,14 @@ typedef utils::SharedPtr RequestInfoPtr; struct MobileRequestInfo : public RequestInfo { MobileRequestInfo(RequestPtr request, const uint64_t timeout_msec); MobileRequestInfo(RequestPtr request, - const TimevalStruct& start_time, + const date_time::TimeDuration& start_time, const uint64_t timeout_msec); }; struct HMIRequestInfo : public RequestInfo { HMIRequestInfo(RequestPtr request, const uint64_t timeout_msec); HMIRequestInfo(RequestPtr request, - const TimevalStruct& start_time, + const date_time::TimeDuration& start_time, const uint64_t timeout_msec); }; @@ -270,8 +270,8 @@ class RequestInfoSet { * during time scale */ struct TimeScale { - TimeScale(const TimevalStruct& start, - const TimevalStruct& end, + TimeScale(const date_time::TimeDuration& start, + const date_time::TimeDuration& end, const uint32_t& app_id) : start_(start), end_(end), app_id_(app_id) {} @@ -292,8 +292,8 @@ struct TimeScale { } private: - TimevalStruct start_; - TimevalStruct end_; + date_time::TimeDuration start_; + date_time::TimeDuration end_; uint32_t app_id_; }; diff --git a/src/components/application_manager/include/application_manager/request_tracker.h b/src/components/application_manager/include/application_manager/request_tracker.h index 36ab3eaefb..b351e716a7 100644 --- a/src/components/application_manager/include/application_manager/request_tracker.h +++ b/src/components/application_manager/include/application_manager/request_tracker.h @@ -85,7 +85,7 @@ class RequestTracker { const mobile_apis::HMILevel::eType level); private: - typedef std::vector RequestAddedAt; + typedef std::vector RequestAddedAt; typedef std::map ApplicationsRequestsTracker; /** diff --git a/src/components/application_manager/include/application_manager/telemetry_observer.h b/src/components/application_manager/include/application_manager/telemetry_observer.h index 20b3aaca5a..d8fab87c40 100644 --- a/src/components/application_manager/include/application_manager/telemetry_observer.h +++ b/src/components/application_manager/include/application_manager/telemetry_observer.h @@ -44,8 +44,8 @@ namespace application_manager { class AMTelemetryObserver { public: struct MessageMetric { - TimevalStruct begin; - TimevalStruct end; + date_time::TimeDuration begin; + date_time::TimeDuration end; utils::SharedPtr message; }; typedef utils::SharedPtr MessageMetricSharedPtr; diff --git a/src/components/application_manager/src/app_launch/app_launch_data_json.cc b/src/components/application_manager/src/app_launch/app_launch_data_json.cc index 7599dcccb3..cc01e4908f 100644 --- a/src/components/application_manager/src/app_launch/app_launch_data_json.cc +++ b/src/components/application_manager/src/app_launch/app_launch_data_json.cc @@ -133,7 +133,7 @@ bool AppLaunchDataJson::RefreshAppSessionTime(const ApplicationData& app_data) { if (index != NotFound) { if (json_data_list.empty() == false) { json_data_list[index][strings::app_launch_last_session] = - static_cast(DateTime::getCurrentTime().tv_sec); + static_cast(getSecs(getCurrentTime())); retVal = true; } } @@ -152,7 +152,7 @@ bool AppLaunchDataJson::AddNewAppData(const ApplicationData& app_data) { json_app_data[strings::app_id] = app_data.mobile_app_id_; json_app_data[strings::bundle_id] = app_data.bundle_id_; json_app_data[strings::app_launch_last_session] = - static_cast(DateTime::getCurrentTime().tv_sec); + static_cast(getSecs(getCurrentTime())); LOG4CXX_DEBUG(logger_, "New application data saved. Detatils device_id: " diff --git a/src/components/application_manager/src/application_impl.cc b/src/components/application_manager/src/application_impl.cc index 8fb88ad5ff..54121bae74 100644 --- a/src/components/application_manager/src/application_impl.cc +++ b/src/components/application_manager/src/application_impl.cc @@ -72,7 +72,7 @@ mobile_apis::FileType::eType StringToFileType(const char* str) { return mobile_apis::FileType::BINARY; } } -} +} // namespace CREATE_LOGGERPTR_GLOBAL(logger_, "ApplicationManager") @@ -141,9 +141,9 @@ ApplicationImpl::ApplicationImpl( this, &ApplicationImpl::OnAudioStreamSuspend)) , application_manager_(application_manager) { cmd_number_to_time_limits_[mobile_apis::FunctionID::ReadDIDID] = { - date_time::DateTime::getCurrentTime(), 0}; + date_time::getCurrentTime(), 0}; cmd_number_to_time_limits_[mobile_apis::FunctionID::GetVehicleDataID] = { - date_time::DateTime::getCurrentTime(), 0}; + date_time::getCurrentTime(), 0}; set_mobile_app_id(mobile_app_id); set_name(app_name); @@ -753,7 +753,7 @@ bool ApplicationImpl::SubscribeToIVI(uint32_t vehicle_info_type) { sync_primitives::AutoLock lock(vi_lock_); return subscribed_vehicle_info_ .insert( - static_cast(vehicle_info_type)) + static_cast(vehicle_info_type)) .second; } @@ -776,7 +776,7 @@ UsageStatistics& ApplicationImpl::usage_report() { bool ApplicationImpl::AreCommandLimitsExceeded( mobile_apis::FunctionID::eType cmd_id, TLimitSource source) { - TimevalStruct current = date_time::DateTime::getCurrentTime(); + date_time::TimeDuration current = date_time::getCurrentTime(); switch (source) { // In case of config file values there is COMMON limitations for number of // commands per certain time in seconds, i.e. 5 requests per 10 seconds with @@ -808,13 +808,14 @@ bool ApplicationImpl::AreCommandLimitsExceeded( LOG4CXX_INFO(logger_, "Time Info: " - << "\n Current: " << current.tv_sec << "\n Limit: (" - << limit.first.tv_sec << "," << limit.second + << "\n Current: " << date_time::getSecs(current) << "\n Limit: (" + << date_time::getSecs(limit.first) << "," << limit.second << ")" "\n frequency_restrictions: (" << frequency_restrictions.first << "," << frequency_restrictions.second << ")"); - if (current.tv_sec < limit.first.tv_sec + frequency_restrictions.second) { + if (date_time::getSecs(current) < + date_time::getSecs(limit.first) + frequency_restrictions.second) { if (limit.second < frequency_restrictions.first) { ++limit.second; return false; @@ -856,7 +857,7 @@ bool ApplicationImpl::AreCommandLimitsExceeded( TimeToNumberLimit& limit = it->second; // Checking even limitation for command - if (static_cast(current.tv_sec - limit.first.tv_sec) < + if (static_cast(date_time::getSecs(current) - date_time::getSecs(limit.first)) < minute / cmd_limit) { return true; } diff --git a/src/components/application_manager/src/application_manager_impl.cc b/src/components/application_manager/src/application_manager_impl.cc index 5edd485343..df350d13f0 100644 --- a/src/components/application_manager/src/application_manager_impl.cc +++ b/src/components/application_manager/src/application_manager_impl.cc @@ -2619,7 +2619,7 @@ void ApplicationManagerImpl::ProcessMessageFromMobile( #ifdef TELEMETRY_MONITOR AMTelemetryObserver::MessageMetricSharedPtr metric( new AMTelemetryObserver::MessageMetric()); - metric->begin = date_time::DateTime::getCurrentTime(); + metric->begin = date_time::getCurrentTime(); #endif // TELEMETRY_MONITOR smart_objects::SmartObjectSPtr so_from_mobile = utils::MakeShared(); @@ -2642,7 +2642,7 @@ void ApplicationManagerImpl::ProcessMessageFromMobile( LOG4CXX_ERROR(logger_, "Received command didn't run successfully"); } #ifdef TELEMETRY_MONITOR - metric->end = date_time::DateTime::getCurrentTime(); + metric->end = date_time::getCurrentTime(); if (metric_observer_) { metric_observer_->OnMessage(metric); } @@ -3991,14 +3991,14 @@ void ApplicationManagerImpl::OnTimerSendTTSGlobalProperties() { std::vector app_list; { sync_primitives::AutoLock lock(tts_global_properties_app_list_lock_); - std::map::iterator it = + std::map::iterator it = tts_global_properties_app_list_.begin(); - std::map::iterator it_end = + std::map::iterator it_end = tts_global_properties_app_list_.end(); date_time::TimeCompare time_comp; for (; it != it_end; ++it) { - time_comp = date_time::DateTime::compareTime( - date_time::DateTime::getCurrentTime(), it->second); + time_comp = date_time::compareTime( + date_time::getCurrentTime(), it->second); if (date_time::GREATER == time_comp || date_time::EQUAL == time_comp) { app_list.push_back(it->first); } @@ -4019,8 +4019,8 @@ void ApplicationManagerImpl::AddAppToTTSGlobalPropertiesList( const uint32_t app_id) { LOG4CXX_AUTO_TRACE(logger_); uint16_t timeout = get_settings().tts_global_properties_timeout(); - TimevalStruct current_time = date_time::DateTime::getCurrentTime(); - current_time.tv_sec += timeout; + date_time::TimeDuration current_time = date_time::getCurrentTime(); + current_time += date_time::seconds(timeout); // please avoid AutoLock usage to avoid deadlock tts_global_properties_app_list_lock_.Acquire(); if (tts_global_properties_app_list_.end() == @@ -4043,7 +4043,7 @@ void ApplicationManagerImpl::RemoveAppFromTTSGlobalPropertiesList( LOG4CXX_AUTO_TRACE(logger_); // please avoid AutoLock usage to avoid deadlock tts_global_properties_app_list_lock_.Acquire(); - std::map::iterator it = + std::map::iterator it = tts_global_properties_app_list_.find(app_id); if (tts_global_properties_app_list_.end() != it) { tts_global_properties_app_list_.erase(it); diff --git a/src/components/application_manager/src/policies/policy_handler.cc b/src/components/application_manager/src/policies/policy_handler.cc index 123606a11e..b0f52ba227 100644 --- a/src/components/application_manager/src/policies/policy_handler.cc +++ b/src/components/application_manager/src/policies/policy_handler.cc @@ -661,9 +661,9 @@ void PolicyHandler::OnAppPermissionConsentInternal( void policy::PolicyHandler::SetDaysAfterEpoch() { POLICY_LIB_CHECK_VOID(); - TimevalStruct current_time = date_time::DateTime::getCurrentTime(); + date_time::TimeDuration current_time = date_time::getCurrentTime(); const int kSecondsInDay = 60 * 60 * 24; - int days_after_epoch = current_time.tv_sec / kSecondsInDay; + int days_after_epoch = date_time::getSecs(current_time) / kSecondsInDay; PTUpdatedAt(Counters::DAYS_AFTER_EPOCH, days_after_epoch); } @@ -1467,7 +1467,7 @@ void PolicyHandler::OnSnapshotCreated( std::string policy_snapshot_full_path; if (SaveSnapshot(pt_string, policy_snapshot_full_path)) { const uint32_t timeout_exchange_s = - timeout_exchange_ms / date_time::DateTime::MILLISECONDS_IN_SECOND; + timeout_exchange_ms / date_time::MILLISECONDS_IN_SECOND; MessageHelper::SendPolicyUpdate(policy_snapshot_full_path, timeout_exchange_s, retry_delay_seconds, @@ -1589,7 +1589,7 @@ uint32_t PolicyHandler::NextRetryTimeout() { } uint32_t PolicyHandler::TimeoutExchangeSec() const { - return TimeoutExchangeMSec() / date_time::DateTime::MILLISECONDS_IN_SECOND; + return TimeoutExchangeMSec() / date_time::MILLISECONDS_IN_SECOND; } uint32_t PolicyHandler::TimeoutExchangeMSec() const { diff --git a/src/components/application_manager/src/request_controller.cc b/src/components/application_manager/src/request_controller.cc index f341967842..1620128f74 100644 --- a/src/components/application_manager/src/request_controller.cc +++ b/src/components/application_manager/src/request_controller.cc @@ -407,11 +407,11 @@ void RequestController::TimeoutThread() { << " request id: " << probably_expired->requestId() << " connection_key: " << probably_expired->app_id() << " NOT expired"); - const TimevalStruct current_time = date_time::DateTime::getCurrentTime(); - const TimevalStruct end_time = probably_expired->end_time(); + const date_time::TimeDuration current_time = date_time::getCurrentTime(); + const date_time::TimeDuration end_time = probably_expired->end_time(); if (current_time < end_time) { const uint32_t msecs = static_cast( - date_time::DateTime::getmSecs(end_time - current_time)); + date_time::getmSecs(end_time - current_time)); LOG4CXX_DEBUG(logger_, "Sleep for " << msecs << " millisecs"); timer_condition_.WaitFor(auto_lock, msecs); } diff --git a/src/components/application_manager/src/request_info.cc b/src/components/application_manager/src/request_info.cc index 9a5828d939..d26f69a39b 100644 --- a/src/components/application_manager/src/request_info.cc +++ b/src/components/application_manager/src/request_info.cc @@ -51,7 +51,7 @@ HMIRequestInfo::HMIRequestInfo(RequestPtr request, const uint64_t timeout_msec) } HMIRequestInfo::HMIRequestInfo(RequestPtr request, - const TimevalStruct& start_time, + const date_time::TimeDuration& start_time, const uint64_t timeout_msec) : RequestInfo(request, HMIRequest, start_time, timeout_msec) { correlation_id_ = request_->correlation_id(); @@ -66,7 +66,7 @@ MobileRequestInfo::MobileRequestInfo(RequestPtr request, } MobileRequestInfo::MobileRequestInfo(RequestPtr request, - const TimevalStruct& start_time, + const date_time::TimeDuration& start_time, const uint64_t timeout_msec) : RequestInfo(request, MobileRequest, start_time, timeout_msec) { correlation_id_ = request_.get()->correlation_id(); @@ -75,7 +75,7 @@ MobileRequestInfo::MobileRequestInfo(RequestPtr request, RequestInfo::RequestInfo(RequestPtr request, const RequestInfo::RequestType requst_type, - const TimevalStruct& start_time, + const date_time::TimeDuration& start_time, const uint64_t timeout_msec) : request_(request), start_time_(start_time), timeout_msec_(timeout_msec) { updateEndTime(); @@ -85,8 +85,8 @@ RequestInfo::RequestInfo(RequestPtr request, } void application_manager::request_controller::RequestInfo::updateEndTime() { - end_time_ = date_time::DateTime::getCurrentTime(); - date_time::DateTime::AddMilliseconds(end_time_, timeout_msec_); + end_time_ = date_time::getCurrentTime(); + date_time::AddMilliseconds(end_time_, timeout_msec_); } void RequestInfo::updateTimeOut(const uint64_t& timeout_msec) { @@ -95,9 +95,9 @@ void RequestInfo::updateTimeOut(const uint64_t& timeout_msec) { } bool RequestInfo::isExpired() { - TimevalStruct curr_time = date_time::DateTime::getCurrentTime(); - return date_time::DateTime::getmSecs(end_time_) <= - date_time::DateTime::getmSecs(curr_time); + date_time::TimeDuration curr_time = date_time::getCurrentTime(); + return date_time::getmSecs(end_time_) <= + date_time::getmSecs(curr_time); } uint64_t RequestInfo::hash() { @@ -283,7 +283,7 @@ bool RequestInfoSet::AppIdCompararator::operator()( bool RequestInfoTimeComparator::operator()(const RequestInfoPtr lhs, const RequestInfoPtr rhs) const { date_time::TimeCompare compare_result = - date_time::DateTime::compareTime(lhs->end_time(), rhs->end_time()); + date_time::compareTime(lhs->end_time(), rhs->end_time()); if (compare_result == date_time::LESS) { return true; } else if (compare_result == date_time::GREATER) { diff --git a/src/components/application_manager/src/request_tracker.cc b/src/components/application_manager/src/request_tracker.cc index 13b3d4d873..c047c82579 100644 --- a/src/components/application_manager/src/request_tracker.cc +++ b/src/components/application_manager/src/request_tracker.cc @@ -77,7 +77,7 @@ bool RequestTracker::Track(const ApplicationID& app_id, const uint32_t max_requests, ApplicationsRequestsTracker& tracker) { LOG4CXX_AUTO_TRACE(logger_); - using date_time::DateTime; + using namespace date_time; if (!time_scale || !max_requests) { LOG4CXX_INFO(logger_, "Time scale request tracking is disabled."); @@ -93,7 +93,7 @@ bool RequestTracker::Track(const ApplicationID& app_id, if (tracker.end() == it_app) { LOG4CXX_DEBUG(logger_, "Adding new application into tracking."); - tracker[app_id].push_back(DateTime::getCurrentTime()); + tracker[app_id].push_back(getCurrentTime()); return true; } @@ -102,25 +102,24 @@ bool RequestTracker::Track(const ApplicationID& app_id, if (it_app->second.size() < max_requests) { LOG4CXX_DEBUG(logger_, "Adding new request into tracking."); - tracker[app_id].push_back(DateTime::getCurrentTime()); + tracker[app_id].push_back(getCurrentTime()); return true; } LOG4CXX_DEBUG(logger_, "Oldest request is added at: " - << DateTime::getmSecs(it_app->second.front()) - << ". Current time is: " - << DateTime::getmSecs(DateTime::getCurrentTime()) + << getmSecs(it_app->second.front()) + << ". Current time is: " << getmSecs(getCurrentTime()) << ". Time scale is: " << time_scale); - if (DateTime::calculateTimeSpan(it_app->second.front()) > time_scale) { + if (calculateTimeSpan(it_app->second.front()) > time_scale) { LOG4CXX_DEBUG(logger_, "Dropping oldest request, adding new one."); ApplicationsRequestsTracker::mapped_type& times = tracker[app_id]; DCHECK_OR_RETURN(!times.empty(), false); times.erase(times.begin()); - times.push_back(DateTime::getCurrentTime()); + times.push_back(getCurrentTime()); return true; } diff --git a/src/components/application_manager/test/app_launch/app_launch_data_json_test.cc b/src/components/application_manager/test/app_launch/app_launch_data_json_test.cc index cc7d3f5814..cd1e53ba96 100644 --- a/src/components/application_manager/test/app_launch/app_launch_data_json_test.cc +++ b/src/components/application_manager/test/app_launch/app_launch_data_json_test.cc @@ -97,14 +97,15 @@ class AppLaunchDataJsonTest : public ::testing::Test { void AddApplicationDataWithIncreaseTable(const ApplicationData& data); void AddApplicationDataWithoutIncreaseTable(const ApplicationData& data); - TimevalStruct GetApplicationData_EXPECT_TRUE(const ApplicationData& in_data, - ApplicationData& out_data); + date_time::TimeDuration GetApplicationData_EXPECT_TRUE( + const ApplicationData& in_data, ApplicationData& out_data); void GetApplicationData_EXPECT_FALSE(const ApplicationData& in_data); std::string AddCounter(const std::string& inp, int32_t val); std::auto_ptr test_last_state_; std::auto_ptr res_json_; - void SetTimestamp(const ApplicationData& in_data, TimevalStruct& timestamp); + void SetTimestamp(const ApplicationData& in_data, + date_time::TimeDuration& timestamp); }; void AppLaunchDataJsonTest::AddApplicationDataWithIncreaseTable( @@ -129,7 +130,7 @@ void AppLaunchDataJsonTest::AddApplicationDataWithoutIncreaseTable( EXPECT_EQ(sizeBeforeAdding, sizeAfterAdding); } -TimevalStruct AppLaunchDataJsonTest::GetApplicationData_EXPECT_TRUE( +date_time::TimeDuration AppLaunchDataJsonTest::GetApplicationData_EXPECT_TRUE( const ApplicationData& in_data, ApplicationData& out_data) { uint32_t sizeBeforeGetting = res_json()->GetCurentNumberOfAppData(); @@ -148,9 +149,9 @@ TimevalStruct AppLaunchDataJsonTest::GetApplicationData_EXPECT_TRUE( out_data.bundle_id_ = json_data_list[index][am::strings::bundle_id].asString(); // time stamp - TimevalStruct tmVal = {0}; - tmVal.tv_sec = - json_data_list[index][am::strings::app_launch_last_session].asUInt64(); + date_time::TimeDuration tmVal = date_time::seconds( + json_data_list[index][am::strings::app_launch_last_session].asUInt64()); + return tmVal; } @@ -168,7 +169,7 @@ void AppLaunchDataJsonTest::GetApplicationData_EXPECT_FALSE( } void AppLaunchDataJsonTest::SetTimestamp(const ApplicationData& in_data, - TimevalStruct& timestamp) { + date_time::TimeDuration& timestamp) { uint32_t sizeBeforeGetting = res_json()->GetCurentNumberOfAppData(); int32_t index = NotFound; @@ -183,7 +184,7 @@ void AppLaunchDataJsonTest::SetTimestamp(const ApplicationData& in_data, EXPECT_EQ(sizeBeforeGetting, sizeAfterGetting); // time stamp json_data_list[index][am::strings::app_launch_last_session] = - static_cast(timestamp.tv_sec); + static_cast(date_time::getSecs(timestamp)); } std::string AppLaunchDataJsonTest::AddCounter(const std::string& inp, @@ -225,18 +226,18 @@ TEST_F(AppLaunchDataJsonTest, RefreshTimestamp) { ApplicationData data("mobile_app_id", "bundle_id", "device_mac"); AddApplicationDataWithIncreaseTable(data); ApplicationData recoveredData("", "", ""); - TimevalStruct timestamp1 = + date_time::TimeDuration timestamp1 = GetApplicationData_EXPECT_TRUE(data, recoveredData); - TimevalStruct tm = {0, 0}; + date_time::TimeDuration tm = date_time::TimeDurationZero(); SetTimestamp(data, tm); - TimevalStruct timestamp2 = + date_time::TimeDuration timestamp2 = GetApplicationData_EXPECT_TRUE(data, recoveredData); - EXPECT_NE(timestamp1.tv_sec, timestamp2.tv_sec); + EXPECT_NE(date_time::getSecs(timestamp1), date_time::getSecs(timestamp2)); AddApplicationDataWithoutIncreaseTable(data); // again insert the same - TimevalStruct timestamp3 = + date_time::TimeDuration timestamp3 = GetApplicationData_EXPECT_TRUE(data, recoveredData); EXPECT_TRUE(data == recoveredData); - EXPECT_NE(timestamp2.tv_sec, timestamp3.tv_sec); + EXPECT_NE(date_time::getSecs(timestamp2), date_time::getSecs(timestamp3)); } TEST_F(AppLaunchDataJsonTest, MaxCount) { @@ -250,7 +251,7 @@ TEST_F(AppLaunchDataJsonTest, MaxCount) { // insert new time stamp ApplicationData changedRecord("mobile_app_id_0", "bundle_id_0", "device_mac"); - TimevalStruct tm = {0, 0}; + date_time::TimeDuration tm = date_time::TimeDurationZero(); SetTimestamp(changedRecord, tm); uint32_t size_max = res_json()->GetCurentNumberOfAppData(); @@ -339,6 +340,6 @@ TEST_F(AppLaunchDataJsonTest, SelectMultipleData) { } } -} // namespace app_launch +} // namespace test_app_launch } // namespace components } // namespace test diff --git a/src/components/application_manager/test/request_info_test.cc b/src/components/application_manager/test/request_info_test.cc index 11b2d2f259..8cef39d162 100644 --- a/src/components/application_manager/test/request_info_test.cc +++ b/src/components/application_manager/test/request_info_test.cc @@ -49,10 +49,10 @@ class TestRequestInfo : public request_info::RequestInfo { public: TestRequestInfo(request_info::RequestPtr request, const RequestType requst_type, - const TimevalStruct& start_time, + const date_time::TimeDuration& start_time, const uint64_t timeout_msec) : RequestInfo(request, requst_type, start_time, timeout_msec) {} - void SetEndTime(const TimevalStruct& end_time) { + void SetEndTime(const date_time::TimeDuration& end_time) { end_time_ = end_time; } }; @@ -80,7 +80,7 @@ class RequestInfoTest : public ::testing::Test { uint32_t connection_key, uint32_t correlation_id, request_info::RequestInfo::RequestType requst_type, - const TimevalStruct& start_time, + const date_time::TimeDuration& start_time, uint64_t timeout_msec) { utils::SharedPtr mock_request = utils::MakeShared(connection_key, correlation_id); @@ -93,7 +93,7 @@ class RequestInfoTest : public ::testing::Test { TEST_F(RequestInfoTest, RequestInfoEqualEndTime) { std::vector > requests; - const TimevalStruct& time = date_time::DateTime::getCurrentTime(); + const date_time::TimeDuration& time = date_time::getCurrentTime(); for (uint32_t i = 0; i < count_of_requests_for_test_; ++i) { utils::SharedPtr request = CreateTestInfo( i, i, request_info::RequestInfo::MobileRequest, time, default_timeout_); @@ -109,7 +109,7 @@ TEST_F(RequestInfoTest, AddRemoveHMIRequests) { CreateTestInfo(hmi_connection_key_, i, request_info::RequestInfo::HMIRequest, - date_time::DateTime::getCurrentTime(), + date_time::getCurrentTime(), default_timeout_); EXPECT_TRUE(request_info_set_.Add(request)); EXPECT_TRUE(request_info_set_.RemoveRequest(request)); @@ -127,7 +127,7 @@ TEST_F(RequestInfoTest, AddHMIRequests_RemoveAllRequests) { CreateTestInfo(hmi_connection_key_, i, request_info::RequestInfo::HMIRequest, - date_time::DateTime::getCurrentTime(), + date_time::getCurrentTime(), default_timeout_); requests.push_back(request); EXPECT_TRUE(request_info_set_.Add(request)); @@ -159,14 +159,14 @@ TEST_F(RequestInfoTest, AddMobileRequests_RemoveMobileRequests) { CreateTestInfo(mobile_connection_key1_, 12345, request_info::RequestInfo::MobileRequest, - date_time::DateTime::getCurrentTime(), + date_time::getCurrentTime(), default_timeout_); EXPECT_TRUE(request_info_set_.Add(mobile_request1)); utils::SharedPtr mobile_request2 = CreateTestInfo(mobile_connection_key2_, 54321, request_info::RequestInfo::MobileRequest, - date_time::DateTime::getCurrentTime(), + date_time::getCurrentTime(), default_timeout_); EXPECT_TRUE(request_info_set_.Add(mobile_request2)); EXPECT_EQ(2u, request_info_set_.Size()); @@ -183,7 +183,7 @@ TEST_F(RequestInfoTest, AddMobileRequests_RemoveMobileRequestsByConnectionKey) { CreateTestInfo(mobile_connection_key1_, i, request_info::RequestInfo::MobileRequest, - date_time::DateTime::getCurrentTime(), + date_time::getCurrentTime(), default_timeout_); requests.push_back(mobile_request1); @@ -196,7 +196,7 @@ TEST_F(RequestInfoTest, AddMobileRequests_RemoveMobileRequestsByConnectionKey) { CreateTestInfo(mobile_connection_key2_, i, request_info::RequestInfo::MobileRequest, - date_time::DateTime::getCurrentTime(), + date_time::getCurrentTime(), default_timeout_); requests.push_back(mobile_request2); @@ -218,7 +218,7 @@ TEST_F(RequestInfoTest, RequestInfoSetFront) { CreateTestInfo(mobile_connection_key1_, i, request_info::RequestInfo::HMIRequest, - date_time::DateTime::getCurrentTime(), + date_time::getCurrentTime(), i); request_info_set_.Add(request); } @@ -252,7 +252,7 @@ TEST_F(RequestInfoTest, RequestInfoSetFind) { CreateTestInfo(req_it->first, req_it->second, request_info::RequestInfo::HMIRequest, - date_time::DateTime::getCurrentTime(), + date_time::getCurrentTime(), 10); EXPECT_TRUE(request_info_set_.Add(request)); } @@ -281,7 +281,7 @@ TEST_F(RequestInfoTest, RequestInfoSetEqualHash) { CreateTestInfo(connection_key, corr_id, request_info::RequestInfo::HMIRequest, - date_time::DateTime::getCurrentTime(), + date_time::getCurrentTime(), 10); EXPECT_TRUE(request_info_set.Add(request)); EXPECT_FALSE(request_info_set.Add(request)); @@ -305,13 +305,13 @@ TEST_F(RequestInfoTest, RequestInfoSetEqualHash) { } TEST_F(RequestInfoTest, EndTimeisExpired) { - TimevalStruct time = date_time::DateTime::getCurrentTime(); + date_time::TimeDuration time = date_time::getCurrentTime(); + // get just the seconds part of the current time + date_time::TimeDuration not_expired = date_time::seconds(date_time::getSecs(date_time::getCurrentTime())); + not_expired+= date_time::microseconds(std::numeric_limits::min()); - TimevalStruct not_expired = date_time::DateTime::getCurrentTime(); - not_expired.tv_usec = std::numeric_limits::min(); - - TimevalStruct expired = date_time::DateTime::getCurrentTime(); - expired.tv_usec = std::numeric_limits::max(); + date_time::TimeDuration expired = date_time::seconds(date_time::getSecs(date_time::getCurrentTime())); + expired += date_time::microseconds(std::numeric_limits::max()); utils::SharedPtr request = CreateTestInfo(mobile_connection_key1_, @@ -328,7 +328,7 @@ TEST_F(RequestInfoTest, EndTimeisExpired) { } TEST_F(RequestInfoTest, UpdateEndTime) { - TimevalStruct time = date_time::DateTime::getCurrentTime(); + date_time::TimeDuration time = date_time::getCurrentTime(); utils::SharedPtr request = CreateTestInfo(mobile_connection_key1_, mobile_correlation_id, @@ -337,12 +337,12 @@ TEST_F(RequestInfoTest, UpdateEndTime) { default_timeout_); request->SetEndTime(time); request->updateEndTime(); - TimevalStruct last_time = request->end_time(); - EXPECT_LE(time.tv_sec, last_time.tv_sec); + date_time::TimeDuration last_time = request->end_time(); + EXPECT_LE(date_time::getSecs(time), date_time::getSecs(last_time)); } TEST_F(RequestInfoTest, UpdateTimeOut) { - TimevalStruct time = date_time::DateTime::getCurrentTime(); + date_time::TimeDuration time = date_time::getCurrentTime(); utils::SharedPtr request = CreateTestInfo(mobile_connection_key1_, mobile_correlation_id, @@ -353,9 +353,9 @@ TEST_F(RequestInfoTest, UpdateTimeOut) { request->updateEndTime(); request->updateTimeOut(100); - time = date_time::DateTime::getCurrentTime(); - TimevalStruct last_time = request->end_time(); - EXPECT_NEAR(time.tv_sec + 100, last_time.tv_sec, 500); + time = date_time::getCurrentTime(); + date_time::TimeDuration last_time = request->end_time(); + EXPECT_NEAR(date_time::getSecs(time) + 100, date_time::getSecs(last_time), 500); } } // namespace application_manager_test diff --git a/src/components/connection_handler/include/connection_handler/heartbeat_monitor.h b/src/components/connection_handler/include/connection_handler/heartbeat_monitor.h index 4d1d07112c..65e27e39f2 100644 --- a/src/components/connection_handler/include/connection_handler/heartbeat_monitor.h +++ b/src/components/connection_handler/include/connection_handler/heartbeat_monitor.h @@ -102,7 +102,7 @@ class HeartBeatMonitor : public threads::ThreadDelegate { void RefreshExpiration(); uint32_t heartbeat_timeout_mseconds_; - TimevalStruct heartbeat_expiration_; + date_time::TimeDuration heartbeat_expiration_; bool is_heartbeat_sent_; }; diff --git a/src/components/connection_handler/src/heartbeat_monitor.cc b/src/components/connection_handler/src/heartbeat_monitor.cc index f3a2322810..2c174bbfbb 100644 --- a/src/components/connection_handler/src/heartbeat_monitor.cc +++ b/src/components/connection_handler/src/heartbeat_monitor.cc @@ -164,8 +164,8 @@ HeartBeatMonitor::SessionState::SessionState( void HeartBeatMonitor::SessionState::RefreshExpiration() { LOG4CXX_DEBUG(logger_, "Refresh expiration: " << heartbeat_timeout_mseconds_); using namespace date_time; - TimevalStruct time = DateTime::getCurrentTime(); - DateTime::AddMilliseconds(time, heartbeat_timeout_mseconds_); + date_time::TimeDuration time = getCurrentTime(); + AddMilliseconds(time, heartbeat_timeout_mseconds_); heartbeat_expiration_ = time; } @@ -194,8 +194,8 @@ void HeartBeatMonitor::SessionState::KeepAlive() { } bool HeartBeatMonitor::SessionState::HasTimeoutElapsed() { - TimevalStruct now = date_time::DateTime::getCurrentTime(); - return date_time::DateTime::Greater(now, heartbeat_expiration_); + date_time::TimeDuration now = date_time::getCurrentTime(); + return date_time::Greater(now, heartbeat_expiration_); } } // namespace connection_handler diff --git a/src/components/include/protocol_handler/telemetry_observer.h b/src/components/include/protocol_handler/telemetry_observer.h index a76fbce717..301496589c 100644 --- a/src/components/include/protocol_handler/telemetry_observer.h +++ b/src/components/include/protocol_handler/telemetry_observer.h @@ -45,11 +45,11 @@ class PHTelemetryObserver { RawMessagePtr raw_msg; uint32_t message_id; uint8_t connection_key; - TimevalStruct begin; - TimevalStruct end; + date_time::TimeDuration begin; + date_time::TimeDuration end; }; virtual void StartMessageProcess(uint32_t message_id, - const TimevalStruct& start_time) = 0; + const date_time::TimeDuration& start_time) = 0; virtual void EndMessageProcess(utils::SharedPtr m) = 0; virtual ~PHTelemetryObserver() {} }; diff --git a/src/components/include/test/protocol_handler/mock_telemetry_observer.h b/src/components/include/test/protocol_handler/mock_telemetry_observer.h index 1c87de4d5a..0a0eb261d3 100644 --- a/src/components/include/test/protocol_handler/mock_telemetry_observer.h +++ b/src/components/include/test/protocol_handler/mock_telemetry_observer.h @@ -44,7 +44,7 @@ namespace protocol_handler_test { class MockPHTelemetryObserver : public PHTelemetryObserver { public: MOCK_METHOD2(StartMessageProcess, - void(uint32_t message_id, const TimevalStruct& start_time)); + void(uint32_t message_id, const date_time::TimeDuration& start_time)); MOCK_METHOD1(EndMessageProcess, void(utils::SharedPtr m)); }; diff --git a/src/components/include/utils/date_time.h b/src/components/include/utils/date_time.h index f8f8e3d6ce..3e649cfc28 100644 --- a/src/components/include/utils/date_time.h +++ b/src/components/include/utils/date_time.h @@ -32,69 +32,70 @@ #ifndef SRC_COMPONENTS_INCLUDE_UTILS_DATE_TIME_H_ #define SRC_COMPONENTS_INCLUDE_UTILS_DATE_TIME_H_ -#if defined(OS_POSIX) -#include -typedef struct timeval TimevalStruct; -#endif #include +#include "boost/date_time.hpp" namespace date_time { +// skip boost namespacing for all this +// NOTE that it's called posix_time for its functionality, not for any +// platform-dependence +typedef boost::posix_time::time_duration TimeDuration; +// Capture from boost's namespaces +using boost::posix_time::microseconds; +using boost::posix_time::milliseconds; +using boost::posix_time::seconds; + enum TimeCompare { LESS, EQUAL, GREATER }; -class DateTime { - public: - static const int32_t MILLISECONDS_IN_SECOND = 1000; - static const int32_t MICROSECONDS_IN_MILLISECOND = 1000; - static const int32_t NANOSECONDS_IN_MICROSECOND = 1000; - static const int32_t SECONDS_IN_HOUR = 3600; - static const int32_t MICROSECONDS_IN_SECOND = - MILLISECONDS_IN_SECOND * MICROSECONDS_IN_MILLISECOND; - static const int32_t NANOSECONDS_IN_MILLISECOND = - MICROSECONDS_IN_MILLISECOND * NANOSECONDS_IN_MICROSECOND; +// public defines for external usage +const int32_t MILLISECONDS_IN_SECOND = 1000; +const int32_t MICROSECONDS_IN_MILLISECOND = 1000; +const int32_t NANOSECONDS_IN_MICROSECOND = 1000; +const int32_t SECONDS_IN_HOUR = 3600; +const int32_t MICROSECONDS_IN_SECOND = + MILLISECONDS_IN_SECOND * MICROSECONDS_IN_MILLISECOND; +const int32_t NANOSECONDS_IN_MILLISECOND = + MICROSECONDS_IN_MILLISECOND * NANOSECONDS_IN_MICROSECOND; + +TimeDuration getCurrentTime(); - static TimevalStruct getCurrentTime(); +// empty duration +TimeDuration TimeDurationZero(); - // return SECONDS count - static int64_t getSecs(const TimevalStruct& time); +// return SECONDS count +int64_t getSecs(const TimeDuration& t); - // return MILLISECONDS count - static int64_t getmSecs(const TimevalStruct& time); - // return MICROSECONDS count - static int64_t getuSecs(const TimevalStruct& time); +// return MILLISECONDS count +int64_t getmSecs(const TimeDuration& t); +// return MICROSECONDS count +int64_t getuSecs(const TimeDuration& t); - // return MILLISECONDS count between sinceTime value and current time - static int64_t calculateTimeSpan(const TimevalStruct& sinceTime); +// get just the MILLISECONDS count (< 1000) +int64_t get_just_mSecs(const TimeDuration& t); - // return MILLISECONDS count between time1 and time2 - static int64_t calculateTimeDiff(const TimevalStruct& time1, - const TimevalStruct& time2); +// get just the MICROSECONDS count (< 1000) +int64_t get_just_uSecs(const TimeDuration& t); - /** - * @brief Adds milliseconds to time struct - * @param time contains time struct - * @param milliseconds contains value which need to - * add to time struct - **/ - static void AddMilliseconds(TimevalStruct& time, uint32_t milliseconds); +// return MILLISECONDS count between sinceTime value and current time +int64_t calculateTimeSpan(const TimeDuration& sinceTime); - static TimevalStruct Sub(const TimevalStruct& time1, - const TimevalStruct& time2); +// return MILLISECONDS count between time1 and time2 +int64_t calculateTimeDiff(const TimeDuration& time1, const TimeDuration& time2); - static TimeCompare compareTime(const TimevalStruct& time1, - const TimevalStruct& time2); +/** + * @brief Adds milliseconds to time struct + * @param time contains time struct + * @param milliseconds contains value which need to + * add to time struct + **/ +void AddMilliseconds(TimeDuration& time, uint32_t milliseconds); - static bool Greater(const TimevalStruct& time1, const TimevalStruct& time2); - static bool Less(const TimevalStruct& time1, const TimevalStruct& time2); - static bool Equal(const TimevalStruct& time1, const TimevalStruct& time2); +TimeCompare compareTime(const TimeDuration& time1, const TimeDuration& time2); - private: - static TimevalStruct ConvertionUsecs(const TimevalStruct& time); -}; +bool Greater(const TimeDuration& time1, const TimeDuration& time2); +bool Less(const TimeDuration& time1, const TimeDuration& time2); +bool Equal(const TimeDuration& time1, const TimeDuration& time2); } // namespace date_time -bool operator<(const TimevalStruct& time1, const TimevalStruct& time2); -bool operator==(const TimevalStruct& time1, const TimevalStruct& time2); -const TimevalStruct operator-(const TimevalStruct& time1, - const TimevalStruct& time2); #endif // SRC_COMPONENTS_INCLUDE_UTILS_DATE_TIME_H_ diff --git a/src/components/include/utils/messagemeter.h b/src/components/include/utils/messagemeter.h index 42b658ad6b..1148a65b57 100644 --- a/src/components/include/utils/messagemeter.h +++ b/src/components/include/utils/messagemeter.h @@ -34,8 +34,8 @@ #define SRC_COMPONENTS_INCLUDE_UTILS_MESSAGEMETER_H_ #include -#include #include +#include #include "utils/date_time.h" namespace utils { @@ -82,20 +82,19 @@ class MessageMeter { void ClearIdentifiers(); void set_time_range(const size_t time_range_msecs); - void set_time_range(const TimevalStruct& time_range); - TimevalStruct time_range() const; + void set_time_range(const date_time::TimeDuration& time_range); + date_time::TimeDuration time_range() const; private: - TimevalStruct time_range_; - typedef std::multiset Timings; + date_time::TimeDuration time_range_; + typedef std::multiset Timings; typedef std::map TimingMap; TimingMap timing_map_; }; template -MessageMeter::MessageMeter() - : time_range_(TimevalStruct{0, 0}) { - time_range_.tv_sec = 1; +MessageMeter::MessageMeter() { + time_range_ = date_time::seconds(1); } template @@ -106,7 +105,7 @@ size_t MessageMeter::TrackMessage(const Id& id) { template size_t MessageMeter::TrackMessages(const Id& id, const size_t count) { Timings& timings = timing_map_[id]; - const TimevalStruct current_time = date_time::DateTime::getCurrentTime(); + const date_time::TimeDuration current_time = date_time::getCurrentTime(); for (size_t i = 0; i < count; ++i) { // Adding to the end is amortized constant timings.insert(timings.end(), current_time); @@ -124,8 +123,8 @@ size_t MessageMeter::Frequency(const Id& id) { if (timings.empty()) { return 0u; } - const TimevalStruct actual_begin_time = date_time::DateTime::Sub( - date_time::DateTime::getCurrentTime(), time_range_); + const date_time::TimeDuration actual_begin_time = + (date_time::getCurrentTime() - time_range_); timings.erase(timings.begin(), timings.upper_bound(actual_begin_time)); return timings.size(); } @@ -142,21 +141,15 @@ void MessageMeter::ClearIdentifiers() { template void MessageMeter::set_time_range(const size_t time_range_msecs) { - // TODO(EZamakhov): move to date_time::DateTime - const size_t secs = - time_range_msecs / date_time::DateTime::MILLISECONDS_IN_SECOND; - time_range_.tv_sec = secs; - const size_t mSecs = - time_range_msecs % date_time::DateTime::MILLISECONDS_IN_SECOND; - time_range_.tv_usec = - mSecs * date_time::DateTime::MICROSECONDS_IN_MILLISECOND; + time_range_ = date_time::milliseconds(time_range_msecs); } template -void MessageMeter::set_time_range(const TimevalStruct& time_range) { +void MessageMeter::set_time_range( + const date_time::TimeDuration& time_range) { time_range_ = time_range; } template -TimevalStruct MessageMeter::time_range() const { +date_time::TimeDuration MessageMeter::time_range() const { return time_range_; } } // namespace utils diff --git a/src/components/policy/policy_external/src/cache_manager.cc b/src/components/policy/policy_external/src/cache_manager.cc index 00bb1e4a1c..6e9465eea4 100644 --- a/src/components/policy/policy_external/src/cache_manager.cc +++ b/src/components/policy/policy_external/src/cache_manager.cc @@ -1119,8 +1119,8 @@ bool CacheManager::SetUserPermissionsForApp( it_group->second != is_allowed) { *out_app_permissions_changed = true; - const TimevalStruct tm = date_time::DateTime::getCurrentTime(); - int64_t current_time_msec = date_time::DateTime::getmSecs(tm); + const date_time::TimeDuration tm = date_time::getCurrentTime(); + int64_t current_time_msec = date_time::getmSecs(tm); ucr.consent_last_updated = current_time_msec; LOG4CXX_DEBUG(logger_, "Updating consents time " << current_time_msec); } @@ -1333,7 +1333,7 @@ int CacheManager::TimeoutResponse() { CACHE_MANAGER_CHECK(0); sync_primitives::AutoLock auto_lock(cache_lock_); return pt_->policy_table.module_config.timeout_after_x_seconds * - date_time::DateTime::MILLISECONDS_IN_SECOND; + date_time::MILLISECONDS_IN_SECOND; } bool CacheManager::SecondsBetweenRetries(std::vector& seconds) { @@ -2651,8 +2651,8 @@ void CacheManager::SetExternalConsentForApp( (*(*pt_->policy_table.device_data)[permissions.device_id] .user_consent_records)[permissions.policy_app_id]; - const TimevalStruct tm = date_time::DateTime::getCurrentTime(); - int64_t current_time_msec = date_time::DateTime::getmSecs(tm); + const date_time::TimeDuration tm = date_time::getCurrentTime(); + int64_t current_time_msec = date_time::getmSecs(tm); app_consent_records.ext_consent_last_updated = current_time_msec; LOG4CXX_DEBUG(logger_, "Updating consents time " << current_time_msec); diff --git a/src/components/policy/policy_external/src/policy_manager_impl.cc b/src/components/policy/policy_external/src/policy_manager_impl.cc index 56de26af64..07afb2fe22 100644 --- a/src/components/policy/policy_external/src/policy_manager_impl.cc +++ b/src/components/policy/policy_external/src/policy_manager_impl.cc @@ -1507,7 +1507,7 @@ void PolicyManagerImpl::CalculateGroupsConsentFromExternalConsent( bool PolicyManagerImpl::ExceededDays() { LOG4CXX_AUTO_TRACE(logger_); - TimevalStruct current_time = date_time::DateTime::getCurrentTime(); + date_time::TimeDuration current_time = date_time::getCurrentTime(); const int kSecondsInDay = 60 * 60 * 24; const int days = current_time.tv_sec / kSecondsInDay; diff --git a/src/components/policy/policy_external/src/sql_pt_representation.cc b/src/components/policy/policy_external/src/sql_pt_representation.cc index b05716dc3f..368dfa80f2 100644 --- a/src/components/policy/policy_external/src/sql_pt_representation.cc +++ b/src/components/policy/policy_external/src/sql_pt_representation.cc @@ -235,10 +235,10 @@ int SQLPTRepresentation::TimeoutResponse() { utils::dbms::SQLQuery query(db()); if (!query.Prepare(sql_pt::kSelectTimeoutResponse) || !query.Exec()) { LOG4CXX_INFO(logger_, "Can not select timeout response for retry sequence"); - const int defaultTimeout = 30 * date_time::DateTime::MILLISECONDS_IN_SECOND; + const int defaultTimeout = 30 * date_time::MILLISECONDS_IN_SECOND; return defaultTimeout; } - return query.GetInteger(0) * date_time::DateTime::MILLISECONDS_IN_SECOND; + return query.GetInteger(0) * date_time::MILLISECONDS_IN_SECOND; } bool SQLPTRepresentation::SecondsBetweenRetries(std::vector* seconds) { diff --git a/src/components/policy/policy_external/src/usage_statistics/counter.cc b/src/components/policy/policy_external/src/usage_statistics/counter.cc index 661ea29704..e2c4d59b0e 100644 --- a/src/components/policy/policy_external/src/usage_statistics/counter.cc +++ b/src/components/policy/policy_external/src/usage_statistics/counter.cc @@ -107,7 +107,7 @@ AppStopwatchImpl::~AppStopwatchImpl() {} void AppStopwatchImpl::Start(AppStopwatchId stopwatch_type) { stopwatch_type_ = stopwatch_type; - timer_.Start(time_out_ * date_time::DateTime::MILLISECONDS_IN_SECOND, + timer_.Start(time_out_ * date_time::MILLISECONDS_IN_SECOND, timer::kPeriodic); } diff --git a/src/components/policy/policy_external/test/policy_manager_impl_ptu_test.cc b/src/components/policy/policy_external/test/policy_manager_impl_ptu_test.cc index 947bb5d3ad..c1ff1c8487 100644 --- a/src/components/policy/policy_external/test/policy_manager_impl_ptu_test.cc +++ b/src/components/policy/policy_external/test/policy_manager_impl_ptu_test.cc @@ -924,7 +924,7 @@ TEST_F( } uint32_t GetCurrentDaysCount() { - TimevalStruct current_time = date_time::DateTime::getCurrentTime(); + date_time::TimeDuration current_time = date_time::getCurrentTime(); const uint32_t kSecondsInDay = 60 * 60 * 24; return current_time.tv_sec / kSecondsInDay; } diff --git a/src/components/policy/policy_external/test/policy_manager_impl_user_consent_test.cc b/src/components/policy/policy_external/test/policy_manager_impl_user_consent_test.cc index 2f2162494f..0532710deb 100644 --- a/src/components/policy/policy_external/test/policy_manager_impl_user_consent_test.cc +++ b/src/components/policy/policy_external/test/policy_manager_impl_user_consent_test.cc @@ -69,7 +69,7 @@ TEST_F( // To set UP_TO_DATE before registration GetPTU(kValidSdlPtUpdateJson); - const TimevalStruct current_time = date_time::DateTime::getCurrentTime(); + const date_time::TimeDuration current_time = date_time::getCurrentTime(); const int kSecondsInDay = 60 * 60 * 24; const int days_after_epoch = current_time.tv_sec / kSecondsInDay; diff --git a/src/components/policy/policy_regular/src/cache_manager.cc b/src/components/policy/policy_regular/src/cache_manager.cc index 1d51b81af4..99621269e2 100644 --- a/src/components/policy/policy_regular/src/cache_manager.cc +++ b/src/components/policy/policy_regular/src/cache_manager.cc @@ -646,7 +646,7 @@ int CacheManager::TimeoutResponse() { CACHE_MANAGER_CHECK(0); sync_primitives::AutoLock auto_lock(cache_lock_); return pt_->policy_table.module_config.timeout_after_x_seconds * - date_time::DateTime::MILLISECONDS_IN_SECOND; + date_time::MILLISECONDS_IN_SECOND; } bool CacheManager::SecondsBetweenRetries(std::vector& seconds) { diff --git a/src/components/policy/policy_regular/src/policy_manager_impl.cc b/src/components/policy/policy_regular/src/policy_manager_impl.cc index a48a9a1ba0..5bdfdaf3bb 100644 --- a/src/components/policy/policy_regular/src/policy_manager_impl.cc +++ b/src/components/policy/policy_regular/src/policy_manager_impl.cc @@ -65,7 +65,7 @@ void DeleteManager(policy::PolicyManager* pm) { namespace { const uint32_t kDefaultRetryTimeoutInMSec = - 60u * date_time::DateTime::MILLISECONDS_IN_SECOND; + 60u * date_time::MILLISECONDS_IN_SECOND; } // namespace namespace policy { @@ -832,9 +832,9 @@ const PolicySettings& PolicyManagerImpl::get_settings() const { bool PolicyManagerImpl::ExceededDays() { LOG4CXX_AUTO_TRACE(logger_); - TimevalStruct current_time = date_time::DateTime::getCurrentTime(); + date_time::TimeDuration current_time = date_time::getCurrentTime(); const int kSecondsInDay = 60 * 60 * 24; - const int days = current_time.tv_sec / kSecondsInDay; + const int days = date_time::getSecs(current_time) / kSecondsInDay; return 0 == cache_->DaysBeforeExchange(days); } @@ -885,7 +885,7 @@ uint32_t PolicyManagerImpl::NextRetryTimeout() { for (uint32_t i = 0u; i < retry_sequence_index_; ++i) { next += retry_sequence_seconds_[i] * - date_time::DateTime::MILLISECONDS_IN_SECOND; + date_time::MILLISECONDS_IN_SECOND; next += retry_sequence_timeout_; } ++retry_sequence_index_; diff --git a/src/components/policy/policy_regular/src/sql_pt_representation.cc b/src/components/policy/policy_regular/src/sql_pt_representation.cc index a57230aeb1..043a5e54d4 100644 --- a/src/components/policy/policy_regular/src/sql_pt_representation.cc +++ b/src/components/policy/policy_regular/src/sql_pt_representation.cc @@ -187,10 +187,10 @@ int SQLPTRepresentation::TimeoutResponse() { utils::dbms::SQLQuery query(db()); if (!query.Prepare(sql_pt::kSelectTimeoutResponse) || !query.Exec()) { LOG4CXX_INFO(logger_, "Can not select timeout response for retry sequence"); - const int defaultTimeout = 30 * date_time::DateTime::MILLISECONDS_IN_SECOND; + const int defaultTimeout = 30 * date_time::MILLISECONDS_IN_SECOND; return defaultTimeout; } - return query.GetInteger(0) * date_time::DateTime::MILLISECONDS_IN_SECOND; + return query.GetInteger(0) * date_time::MILLISECONDS_IN_SECOND; } bool SQLPTRepresentation::SecondsBetweenRetries(std::vector* seconds) { diff --git a/src/components/policy/policy_regular/src/usage_statistics/counter.cc b/src/components/policy/policy_regular/src/usage_statistics/counter.cc index 60e34a929d..83e12194e0 100644 --- a/src/components/policy/policy_regular/src/usage_statistics/counter.cc +++ b/src/components/policy/policy_regular/src/usage_statistics/counter.cc @@ -103,7 +103,7 @@ AppStopwatchImpl::AppStopwatchImpl( void AppStopwatchImpl::Start(AppStopwatchId stopwatch_type) { stopwatch_type_ = stopwatch_type; - timer_.Start(time_out_ * date_time::DateTime::MILLISECONDS_IN_SECOND, + timer_.Start(time_out_ * date_time::MILLISECONDS_IN_SECOND, timer::kPeriodic); } diff --git a/src/components/policy/policy_regular/test/policy_manager_impl_test.cc b/src/components/policy/policy_regular/test/policy_manager_impl_test.cc index 5fd0a48f7c..c105b304fe 100644 --- a/src/components/policy/policy_regular/test/policy_manager_impl_test.cc +++ b/src/components/policy/policy_regular/test/policy_manager_impl_test.cc @@ -840,9 +840,9 @@ TEST_F(PolicyManagerImplTest2, PTUpdatedAt_DaysNotExceedLimit_ExpectNoUpdateRequired) { // Arrange CreateLocalPT("sdl_preloaded_pt.json"); - TimevalStruct current_time = date_time::DateTime::getCurrentTime(); + date_time::TimeDuration current_time = date_time::getCurrentTime(); const int kSecondsInDay = 60 * 60 * 24; - int days = current_time.tv_sec / kSecondsInDay; + int days = date_time::getSecs(current_time) / kSecondsInDay; EXPECT_EQ("UP_TO_DATE", manager->GetPolicyTableStatus()); GetPTU("valid_sdl_pt_update.json"); @@ -900,24 +900,23 @@ TEST_F(PolicyManagerImplTest2, NextRetryTimeout_ExpectTimeoutsFromPT) { uint32_t timeout_after_x_seconds = root["policy_table"]["module_config"]["timeout_after_x_seconds"] .asInt() * - date_time::DateTime::MILLISECONDS_IN_SECOND; + date_time::MILLISECONDS_IN_SECOND; const uint32_t first_retry = timeout_after_x_seconds; EXPECT_EQ(first_retry, manager->NextRetryTimeout()); - uint32_t next_retry = first_retry + - seconds_between_retries[0].asInt() * - date_time::DateTime::MILLISECONDS_IN_SECOND; + uint32_t next_retry = first_retry + seconds_between_retries[0].asInt() * + date_time::MILLISECONDS_IN_SECOND; EXPECT_EQ(next_retry, manager->NextRetryTimeout()); - next_retry = first_retry + next_retry + - seconds_between_retries[1].asInt() * - date_time::DateTime::MILLISECONDS_IN_SECOND; + next_retry = + first_retry + next_retry + + seconds_between_retries[1].asInt() * date_time::MILLISECONDS_IN_SECOND; EXPECT_EQ(next_retry, manager->NextRetryTimeout()); - next_retry = first_retry + next_retry + - seconds_between_retries[2].asInt() * - date_time::DateTime::MILLISECONDS_IN_SECOND; + next_retry = + first_retry + next_retry + + seconds_between_retries[2].asInt() * date_time::MILLISECONDS_IN_SECOND; EXPECT_EQ(next_retry, manager->NextRetryTimeout()); - next_retry = first_retry + next_retry + - seconds_between_retries[3].asInt() * - date_time::DateTime::MILLISECONDS_IN_SECOND; + next_retry = + first_retry + next_retry + + seconds_between_retries[3].asInt() * date_time::MILLISECONDS_IN_SECOND; EXPECT_EQ(next_retry, manager->NextRetryTimeout()); } } @@ -948,9 +947,8 @@ TEST_F(PolicyManagerImplTest2, UpdatedPreloadedPT_ExpectLPT_IsUpdated) { Json::Value val2(Json::arrayValue); val2[0] = hmi_level[index]; val[new_data.new_field_value_]["hmi_levels"] = val2; - root["policy_table"]["functional_groupings"][new_data - .new_field_name_]["rpcs"] = - val; + root["policy_table"]["functional_groupings"][new_data.new_field_name_] + ["rpcs"] = val; root["policy_table"]["functional_groupings"][new_data.new_field_name_] ["user_consent_prompt"] = new_data.new_field_name_; } diff --git a/src/components/protocol_handler/include/protocol_handler/multiframe_builder.h b/src/components/protocol_handler/include/protocol_handler/multiframe_builder.h index bac37b508c..84ec3c9e30 100644 --- a/src/components/protocol_handler/include/protocol_handler/multiframe_builder.h +++ b/src/components/protocol_handler/include/protocol_handler/multiframe_builder.h @@ -60,7 +60,7 @@ typedef uint32_t MessageID; struct ProtocolFrameData { ProtocolFramePtr frame; - TimevalStruct append_time; + date_time::TimeDuration append_time; }; /** *\brief Map of frames with last frame data for messages received in multiple diff --git a/src/components/protocol_handler/src/multiframe_builder.cc b/src/components/protocol_handler/src/multiframe_builder.cc index 5a1fc6d205..d554c1843c 100644 --- a/src/components/protocol_handler/src/multiframe_builder.cc +++ b/src/components/protocol_handler/src/multiframe_builder.cc @@ -122,7 +122,7 @@ ProtocolFramePtrList MultiFrameBuilder::PopMultiframes() { if (consecutive_frame_wait_msecs_ != 0) { LOG4CXX_TRACE(logger_, "Expiration verification"); const int64_t time_left = - date_time::DateTime::calculateTimeSpan(frame_data.append_time); + date_time::calculateTimeSpan(frame_data.append_time); LOG4CXX_DEBUG(logger_, "mSecs left: " << time_left); if (time_left >= consecutive_frame_wait_msecs_) { LOG4CXX_WARN(logger_, "Expired frame: " << frame); @@ -198,7 +198,7 @@ RESULT_CODE MultiFrameBuilder::HandleFirstFrame(const ProtocolFramePtr packet) { << connection_id << ", session_id: " << static_cast(session_id) << ", message_id: " << message_id); - messageId_map[message_id] = {packet, date_time::DateTime::getCurrentTime()}; + messageId_map[message_id] = {packet, date_time::getCurrentTime()}; return RESULT_OK; } @@ -277,7 +277,7 @@ RESULT_CODE MultiFrameBuilder::HandleConsecutiveFrame( LOG4CXX_INFO(logger_, "Assembled frame with payload size: " << assembling_frame->payload_size()); - frame_data.append_time = date_time::DateTime::getCurrentTime(); + frame_data.append_time = date_time::getCurrentTime(); return RESULT_OK; } diff --git a/src/components/protocol_handler/src/protocol_handler_impl.cc b/src/components/protocol_handler/src/protocol_handler_impl.cc index 762b986782..16cc814f8a 100644 --- a/src/components/protocol_handler/src/protocol_handler_impl.cc +++ b/src/components/protocol_handler/src/protocol_handler_impl.cc @@ -574,7 +574,7 @@ void ProtocolHandlerImpl::SendHeartBeat(int32_t connection_id, void ProtocolHandlerImpl::SendMessageToMobileApp(const RawMessagePtr message, bool final_message) { #ifdef TELEMETRY_MONITOR - const TimevalStruct start_time = date_time::DateTime::getCurrentTime(); + const date_time::TimeDuration start_time = date_time::getCurrentTime(); #endif // TELEMETRY_MONITOR LOG4CXX_AUTO_TRACE(logger_); if (!message) { @@ -720,7 +720,7 @@ void ProtocolHandlerImpl::OnTMMessageReceived(const RawMessagePtr tm_message) { it != protocol_frames.end(); ++it) { #ifdef TELEMETRY_MONITOR - const TimevalStruct start_time = date_time::DateTime::getCurrentTime(); + const date_time::TimeDuration start_time = date_time::getCurrentTime(); #endif // TELEMETRY_MONITOR ProtocolFramePtr frame = *it; #ifdef ENABLE_SECURITY diff --git a/src/components/protocol_handler/test/include/protocol_handler/mock_telemetry_observer.h b/src/components/protocol_handler/test/include/protocol_handler/mock_telemetry_observer.h index a1c1f188d1..d46b8470a3 100644 --- a/src/components/protocol_handler/test/include/protocol_handler/mock_telemetry_observer.h +++ b/src/components/protocol_handler/test/include/protocol_handler/mock_telemetry_observer.h @@ -43,7 +43,7 @@ namespace protocol_handler_test { class MockPHTelemetryObserver : public ::protocol_handler::PHTelemetryObserver { public: - MOCK_METHOD2(StartMessageProcess, void(uint32_t, const TimevalStruct&)); + MOCK_METHOD2(StartMessageProcess, void(uint32_t, const date_time::TimeDuration&)); MOCK_METHOD2(EndMessageProcess, void(utils::SharedPtr)); }; diff --git a/src/components/security_manager/src/crypto_manager_impl.cc b/src/components/security_manager/src/crypto_manager_impl.cc index 2cc88c5966..f3dfa8bb1d 100644 --- a/src/components/security_manager/src/crypto_manager_impl.cc +++ b/src/components/security_manager/src/crypto_manager_impl.cc @@ -293,7 +293,7 @@ bool CryptoManagerImpl::IsCertificateUpdateRequired() const { } return seconds <= (get_settings().update_before_hours() * - date_time::DateTime::SECONDS_IN_HOUR); + date_time::SECONDS_IN_HOUR); } const CryptoManagerSettings& CryptoManagerImpl::get_settings() const { diff --git a/src/components/telemetry_monitor/include/telemetry_monitor/protocol_handler_observer.h b/src/components/telemetry_monitor/include/telemetry_monitor/protocol_handler_observer.h index 69e5658382..108757043f 100644 --- a/src/components/telemetry_monitor/include/telemetry_monitor/protocol_handler_observer.h +++ b/src/components/telemetry_monitor/include/telemetry_monitor/protocol_handler_observer.h @@ -45,13 +45,13 @@ class ProtocolHandlerObserver : public protocol_handler::PHTelemetryObserver { explicit ProtocolHandlerObserver(TelemetryMonitor* telemetry_monitor); virtual void StartMessageProcess(uint32_t message_id, - const TimevalStruct& start_time); + const date_time::TimeDuration& start_time); virtual void EndMessageProcess(utils::SharedPtr m); private: TelemetryMonitor* telemetry_monitor_; - std::map time_starts; + std::map time_starts; }; } // namespace telemetry_monitor #endif // SRC_COMPONENTS_TELEMETRY_MONITOR_INCLUDE_TELEMETRY_MONITOR_PROTOCOL_HANDLER_OBSERVER_H_ diff --git a/src/components/telemetry_monitor/include/telemetry_monitor/transport_manager_observer.h b/src/components/telemetry_monitor/include/telemetry_monitor/transport_manager_observer.h index bff5834586..d0f1b2b96a 100644 --- a/src/components/telemetry_monitor/include/telemetry_monitor/transport_manager_observer.h +++ b/src/components/telemetry_monitor/include/telemetry_monitor/transport_manager_observer.h @@ -49,7 +49,7 @@ class TransportManagerObserver : public transport_manager::TMTelemetryObserver { private: TelemetryMonitor* telemetry_monitor_; - std::map time_starts; + std::map time_starts; }; } // namespace telemetry_monitor #endif // SRC_COMPONENTS_TELEMETRY_MONITOR_INCLUDE_TELEMETRY_MONITOR_TRANSPORT_MANAGER_OBSERVER_H_ diff --git a/src/components/telemetry_monitor/src/application_manager_metric_wrapper.cc b/src/components/telemetry_monitor/src/application_manager_metric_wrapper.cc index b693d9df22..0b95792f0f 100644 --- a/src/components/telemetry_monitor/src/application_manager_metric_wrapper.cc +++ b/src/components/telemetry_monitor/src/application_manager_metric_wrapper.cc @@ -41,9 +41,9 @@ Json::Value ApplicationManagerMetricWrapper::GetJsonMetric() { Json::Value result = MetricWrapper::GetJsonMetric(); result[strings::logger] = "ApplicationManager"; result[strings::begin] = - Json::Int64(date_time::DateTime::getuSecs(message_metric->begin)); + Json::Int64(date_time::getuSecs(message_metric->begin)); result[strings::end] = - Json::Int64(date_time::DateTime::getuSecs(message_metric->end)); + Json::Int64(date_time::getuSecs(message_metric->end)); const NsSmartDeviceLink::NsSmartObjects::SmartObject& params = message_metric->message->getElement(application_manager::strings::params); result[strings::correlation_id] = utils::ConvertInt64ToLongLongInt( diff --git a/src/components/telemetry_monitor/src/protocol_handler_metric_wrapper.cc b/src/components/telemetry_monitor/src/protocol_handler_metric_wrapper.cc index 335f0dbb29..471b0dfdad 100644 --- a/src/components/telemetry_monitor/src/protocol_handler_metric_wrapper.cc +++ b/src/components/telemetry_monitor/src/protocol_handler_metric_wrapper.cc @@ -40,9 +40,9 @@ Json::Value ProtocolHandlerMecticWrapper::GetJsonMetric() { Json::Value result = MetricWrapper::GetJsonMetric(); result[strings::logger] = "ProtocolHandler"; result[strings::begin] = - Json::Int64(date_time::DateTime::getuSecs(message_metric->begin)); + Json::Int64(date_time::getuSecs(message_metric->begin)); result[strings::end] = - Json::Int64(date_time::DateTime::getuSecs(message_metric->end)); + Json::Int64(date_time::getuSecs(message_metric->end)); result[strings::message_id] = message_metric->message_id; result[strings::connection_key] = message_metric->connection_key; return result; diff --git a/src/components/telemetry_monitor/src/protocol_handler_observer.cc b/src/components/telemetry_monitor/src/protocol_handler_observer.cc index 2244cb2259..0045229ea7 100644 --- a/src/components/telemetry_monitor/src/protocol_handler_observer.cc +++ b/src/components/telemetry_monitor/src/protocol_handler_observer.cc @@ -44,7 +44,7 @@ ProtocolHandlerObserver::ProtocolHandlerObserver( : telemetry_monitor_(telemetry_monitor) {} void ProtocolHandlerObserver::StartMessageProcess( - uint32_t message_id, const TimevalStruct& start_time) { + uint32_t message_id, const date_time::TimeDuration& start_time) { if (message_id == 0) { return; } @@ -60,14 +60,14 @@ void ProtocolHandlerObserver::StartMessageProcess( void ProtocolHandlerObserver::EndMessageProcess( utils::SharedPtr m) { uint32_t message_id = m->message_id; - std::map::const_iterator it = + std::map::const_iterator it = time_starts.find(message_id); if (it == time_starts.end()) { LOG4CXX_WARN(logger_, "Cant find start time for message" << message_id); return; } m->begin = time_starts[message_id]; - m->end = date_time::DateTime::getCurrentTime(); + m->end = date_time::getCurrentTime(); ProtocolHandlerMecticWrapper* metric = new ProtocolHandlerMecticWrapper(); metric->message_metric = m; metric->grabResources(); diff --git a/src/components/telemetry_monitor/src/telemetry_monitor.cc b/src/components/telemetry_monitor/src/telemetry_monitor.cc index 53a5a2dc70..9b5c294051 100644 --- a/src/components/telemetry_monitor/src/telemetry_monitor.cc +++ b/src/components/telemetry_monitor/src/telemetry_monitor.cc @@ -1,34 +1,34 @@ /* -* Copyright (c) 2014, 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. -*/ + * Copyright (c) 2014, 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 "telemetry_monitor/telemetry_monitor.h" @@ -251,8 +251,9 @@ bool Streamer::IsReady() const { fd_set fds; FD_ZERO(&fds); FD_SET(client_socket_fd_, &fds); - TimevalStruct tv = {0, 0}; - tv.tv_sec = 5; // set a 5 second timeout + // need to construct a timeval for the duration, can't use duration + struct timeval tv; + tv.tv_sec = 5; tv.tv_usec = 0; const int retval = select(client_socket_fd_ + 1, 0, &fds, 0, &tv); diff --git a/src/components/telemetry_monitor/src/transport_manager_metric_wrapper.cc b/src/components/telemetry_monitor/src/transport_manager_metric_wrapper.cc index a891aa1118..47636ed499 100644 --- a/src/components/telemetry_monitor/src/transport_manager_metric_wrapper.cc +++ b/src/components/telemetry_monitor/src/transport_manager_metric_wrapper.cc @@ -41,9 +41,9 @@ Json::Value TransportManagerMecticWrapper::GetJsonMetric() { Json::Value result = MetricWrapper::GetJsonMetric(); result[strings::logger] = "TransportManager"; result[strings::begin] = - Json::Int64(date_time::DateTime::getuSecs(message_metric->begin)); + Json::Int64(date_time::getuSecs(message_metric->begin)); result[strings::end] = - Json::Int64(date_time::DateTime::getuSecs(message_metric->end)); + Json::Int64(date_time::getuSecs(message_metric->end)); result[strings::data_size] = static_cast(message_metric->data_size); return result; } diff --git a/src/components/telemetry_monitor/src/transport_manager_observer.cc b/src/components/telemetry_monitor/src/transport_manager_observer.cc index b3e57ac22a..c761b34210 100644 --- a/src/components/telemetry_monitor/src/transport_manager_observer.cc +++ b/src/components/telemetry_monitor/src/transport_manager_observer.cc @@ -44,12 +44,12 @@ TransportManagerObserver::TransportManagerObserver( void TransportManagerObserver::StartRawMsg( const protocol_handler::RawMessage* ptr) { - time_starts[ptr] = date_time::DateTime::getCurrentTime(); + time_starts[ptr] = date_time::getCurrentTime(); } void TransportManagerObserver::StopRawMsg( const protocol_handler::RawMessage* ptr) { - std::map::const_iterator + std::map::const_iterator it; it = time_starts.find(ptr); if (it != time_starts.end()) { @@ -57,7 +57,7 @@ void TransportManagerObserver::StopRawMsg( m->message_metric = new transport_manager::TMTelemetryObserver::MessageMetric(); m->message_metric->begin = it->second; - m->message_metric->end = date_time::DateTime::getCurrentTime(); + m->message_metric->end = date_time::getCurrentTime(); m->message_metric->data_size = ptr->data_size(); m->grabResources(); telemetry_monitor_->SendMetric(m); diff --git a/src/components/telemetry_monitor/test/application_manager_metric_test.cc b/src/components/telemetry_monitor/test/application_manager_metric_test.cc index 9029c41bc4..d370cab278 100644 --- a/src/components/telemetry_monitor/test/application_manager_metric_test.cc +++ b/src/components/telemetry_monitor/test/application_manager_metric_test.cc @@ -50,13 +50,10 @@ TEST(ApplicationManagerMetricWrapper, grabResources) { TEST(ApplicationManagerMetricWrapper, GetJsonMetric) { ApplicationManagerMetricWrapper metric_test; - TimevalStruct start_time; - start_time.tv_sec = 1; - start_time.tv_usec = 0; + date_time::TimeDuration start_time = date_time::seconds(1); + + date_time::TimeDuration end_time = date_time::seconds(10); - TimevalStruct end_time; - end_time.tv_sec = 10; - end_time.tv_usec = 0; metric_test.message_metric = new application_manager::AMTelemetryObserver::MessageMetric(); metric_test.message_metric->begin = start_time; @@ -75,9 +72,9 @@ TEST(ApplicationManagerMetricWrapper, GetJsonMetric) { EXPECT_EQ("null\n", jvalue[telemetry_monitor::strings::memory].toStyledString()); - EXPECT_EQ(date_time::DateTime::getuSecs(start_time), + EXPECT_EQ(date_time::getuSecs(start_time), jvalue[telemetry_monitor::strings::begin].asInt64()); - EXPECT_EQ(date_time::DateTime::getuSecs(end_time), + EXPECT_EQ(date_time::getuSecs(end_time), jvalue[telemetry_monitor::strings::end].asInt64()); EXPECT_EQ(obj["params"][application_manager::strings::correlation_id].asInt(), jvalue[telemetry_monitor::strings::correlation_id].asInt64()); @@ -90,13 +87,9 @@ TEST(ApplicationManagerMetricWrapper, GetJsonMetricWithGrabResources) { utils::ResourseUsage* resources = utils::Resources::getCurrentResourseUsage(); EXPECT_TRUE(metric_test.grabResources()); - TimevalStruct start_time; - start_time.tv_sec = 1; - start_time.tv_usec = 0; + date_time::TimeDuration start_time = date_time::seconds(1); - TimevalStruct end_time; - end_time.tv_sec = 10; - end_time.tv_usec = 0; + date_time::TimeDuration end_time = date_time::seconds(10); metric_test.message_metric = new application_manager::AMTelemetryObserver::MessageMetric(); @@ -109,18 +102,18 @@ TEST(ApplicationManagerMetricWrapper, GetJsonMetricWithGrabResources) { new NsSmartDeviceLink::NsSmartObjects::SmartObject(obj); Json::Value jvalue = metric_test.GetJsonMetric(); - EXPECT_EQ(date_time::DateTime::getuSecs(start_time), + EXPECT_EQ(date_time::getuSecs(start_time), jvalue[telemetry_monitor::strings::begin].asInt64()); - EXPECT_EQ(date_time::DateTime::getuSecs(end_time), + EXPECT_EQ(date_time::getuSecs(end_time), jvalue[telemetry_monitor::strings::end].asInt64()); EXPECT_EQ(obj["params"][application_manager::strings::correlation_id].asInt(), jvalue[telemetry_monitor::strings::correlation_id].asInt64()); EXPECT_EQ(obj["params"][application_manager::strings::connection_key].asInt(), jvalue[telemetry_monitor::strings::connection_key].asInt()); - EXPECT_EQ(date_time::DateTime::getuSecs(start_time), + EXPECT_EQ(date_time::getuSecs(start_time), jvalue[telemetry_monitor::strings::begin].asInt64()); - EXPECT_EQ(date_time::DateTime::getuSecs(end_time), + EXPECT_EQ(date_time::getuSecs(end_time), jvalue[telemetry_monitor::strings::end].asInt64()); EXPECT_NEAR( diff --git a/src/components/telemetry_monitor/test/protocol_handler_metric_test.cc b/src/components/telemetry_monitor/test/protocol_handler_metric_test.cc index 8253cf2553..3adccc7196 100644 --- a/src/components/telemetry_monitor/test/protocol_handler_metric_test.cc +++ b/src/components/telemetry_monitor/test/protocol_handler_metric_test.cc @@ -51,13 +51,10 @@ TEST(ProtocolHandlerMetricTest, grabResources) { TEST(ProtocolHandlerMetricTest, GetJsonMetric) { ProtocolHandlerMecticWrapper metric_test; - TimevalStruct start_time; - start_time.tv_sec = 1; - start_time.tv_usec = 0; + date_time::TimeDuration start_time = date_time::seconds(1); + + date_time::TimeDuration end_time = date_time::seconds(10); - TimevalStruct end_time; - end_time.tv_sec = 10; - end_time.tv_usec = 0; metric_test.message_metric = new protocol_handler::PHTelemetryObserver::MessageMetric(); metric_test.message_metric->begin = start_time; @@ -71,10 +68,8 @@ TEST(ProtocolHandlerMetricTest, GetJsonMetric) { EXPECT_EQ("null\n", jvalue[strings::utime].toStyledString()); EXPECT_EQ("null\n", jvalue[strings::memory].toStyledString()); - EXPECT_EQ(date_time::DateTime::getuSecs(start_time), - jvalue[strings::begin].asInt64()); - EXPECT_EQ(date_time::DateTime::getuSecs(end_time), - jvalue[strings::end].asInt64()); + EXPECT_EQ(date_time::getuSecs(start_time), jvalue[strings::begin].asInt64()); + EXPECT_EQ(date_time::getuSecs(end_time), jvalue[strings::end].asInt64()); EXPECT_EQ(5, jvalue[strings::message_id].asInt64()); EXPECT_EQ(2, jvalue[strings::connection_key].asInt()); } @@ -85,13 +80,10 @@ TEST(ProtocolHandlerMetricTest, GetJsonMetricWithGrabResources) { EXPECT_TRUE(resources != NULL); EXPECT_TRUE(metric_test.grabResources()); - TimevalStruct start_time; - start_time.tv_sec = 1; - start_time.tv_usec = 0; + date_time::TimeDuration start_time = date_time::seconds(1); + + date_time::TimeDuration end_time = date_time::seconds(10); - TimevalStruct end_time; - end_time.tv_sec = 10; - end_time.tv_usec = 0; metric_test.message_metric = new protocol_handler::PHTelemetryObserver::MessageMetric(); metric_test.message_metric->begin = start_time; @@ -107,10 +99,8 @@ TEST(ProtocolHandlerMetricTest, GetJsonMetricWithGrabResources) { EXPECT_NE("null/n", jvalue[strings::utime].toStyledString()); EXPECT_NE("null/n", jvalue[strings::memory].toStyledString()); - EXPECT_EQ(date_time::DateTime::getuSecs(start_time), - jvalue[strings::begin].asInt64()); - EXPECT_EQ(date_time::DateTime::getuSecs(end_time), - jvalue[strings::end].asInt64()); + EXPECT_EQ(date_time::getuSecs(start_time), jvalue[strings::begin].asInt64()); + EXPECT_EQ(date_time::getuSecs(end_time), jvalue[strings::end].asInt64()); EXPECT_EQ(5, jvalue[strings::message_id].asInt64()); EXPECT_EQ(2, jvalue[strings::connection_key].asInt()); diff --git a/src/components/telemetry_monitor/test/protocol_handler_observer_test.cc b/src/components/telemetry_monitor/test/protocol_handler_observer_test.cc index 784e809da6..3815b161b1 100644 --- a/src/components/telemetry_monitor/test/protocol_handler_observer_test.cc +++ b/src/components/telemetry_monitor/test/protocol_handler_observer_test.cc @@ -47,9 +47,8 @@ TEST(ProtocolHandlerObserverTest, MessageProcess) { ProtocolHandlerObserver pr_handler(&mock_telemetry_monitor); uint32_t message_id = 1; - TimevalStruct start_time; - start_time.tv_sec = 1; - start_time.tv_usec = 0; + date_time::TimeDuration start_time = date_time::seconds(1); + pr_handler.StartMessageProcess(message_id, start_time); typedef protocol_handler::PHTelemetryObserver::MessageMetric MetricType; @@ -64,9 +63,8 @@ TEST(ProtocolHandlerObserverTest, MessageProcessWithZeroMessageId) { ProtocolHandlerObserver pr_handler(&mock_telemetry_monitor); uint32_t message_id = 0; - TimevalStruct start_time; - start_time.tv_sec = 1; - start_time.tv_usec = 0; + date_time::TimeDuration start_time = date_time::seconds(1); + pr_handler.StartMessageProcess(message_id, start_time); typedef protocol_handler::PHTelemetryObserver::MessageMetric MetricType; diff --git a/src/components/telemetry_monitor/test/transport_manager_metric_test.cc b/src/components/telemetry_monitor/test/transport_manager_metric_test.cc index 6eb479387a..184a1ef9ec 100644 --- a/src/components/telemetry_monitor/test/transport_manager_metric_test.cc +++ b/src/components/telemetry_monitor/test/transport_manager_metric_test.cc @@ -51,13 +51,9 @@ TEST(TransportManagerMetricWrapper, grabResources) { TEST(TransportManagerMetricWrapper, GetJsonMetric) { TransportManagerMecticWrapper metric_test; - TimevalStruct start_time; - start_time.tv_sec = 1; - start_time.tv_usec = 0; + date_time::TimeDuration start_time = date_time::seconds(1); - TimevalStruct end_time; - end_time.tv_sec = 10; - end_time.tv_usec = 0; + date_time::TimeDuration end_time = date_time::seconds(10); metric_test.message_metric = new transport_manager::TMTelemetryObserver::MessageMetric(); metric_test.message_metric->begin = start_time; @@ -69,9 +65,9 @@ TEST(TransportManagerMetricWrapper, GetJsonMetric) { EXPECT_EQ("null\n", jvalue[strings::utime].toStyledString()); EXPECT_EQ("null\n", jvalue[strings::memory].toStyledString()); - EXPECT_EQ(date_time::DateTime::getuSecs(start_time), + EXPECT_EQ(date_time::getuSecs(start_time), jvalue[strings::begin].asInt64()); - EXPECT_EQ(date_time::DateTime::getuSecs(end_time), + EXPECT_EQ(date_time::getuSecs(end_time), jvalue[strings::end].asInt64()); EXPECT_EQ(1000, jvalue[strings::data_size].asInt()); } @@ -82,13 +78,9 @@ TEST(TransportManagerMetricWrapper, GetJsonMetricWithGrabResources) { EXPECT_TRUE(resources != NULL); EXPECT_TRUE(metric_test.grabResources()); - TimevalStruct start_time; - start_time.tv_sec = 1; - start_time.tv_usec = 0; + date_time::TimeDuration start_time = date_time::seconds(1); - TimevalStruct end_time; - end_time.tv_sec = 10; - end_time.tv_usec = 0; + date_time::TimeDuration end_time = date_time::seconds(10); metric_test.message_metric = new transport_manager::TMTelemetryObserver::MessageMetric(); metric_test.message_metric->begin = start_time; @@ -98,9 +90,9 @@ TEST(TransportManagerMetricWrapper, GetJsonMetricWithGrabResources) { Json::Value jvalue = metric_test.GetJsonMetric(); EXPECT_EQ("\"TransportManager\"\n", jvalue[strings::logger].toStyledString()); - EXPECT_EQ(date_time::DateTime::getuSecs(start_time), + EXPECT_EQ(date_time::getuSecs(start_time), jvalue[strings::begin].asInt64()); - EXPECT_EQ(date_time::DateTime::getuSecs(end_time), + EXPECT_EQ(date_time::getuSecs(end_time), jvalue[strings::end].asInt64()); EXPECT_EQ(1000, jvalue[strings::data_size].asInt()); diff --git a/src/components/transport_manager/include/transport_manager/telemetry_observer.h b/src/components/transport_manager/include/transport_manager/telemetry_observer.h index 5e42289a03..a38255966b 100644 --- a/src/components/transport_manager/include/transport_manager/telemetry_observer.h +++ b/src/components/transport_manager/include/transport_manager/telemetry_observer.h @@ -42,8 +42,8 @@ namespace transport_manager { class TMTelemetryObserver { public: struct MessageMetric { - TimevalStruct begin; - TimevalStruct end; + date_time::TimeDuration begin; + date_time::TimeDuration end; size_t data_size; }; virtual void StartRawMsg(const protocol_handler::RawMessage* ptr) = 0; diff --git a/src/components/utils/CMakeLists.txt b/src/components/utils/CMakeLists.txt index 51835c125a..98f3c74145 100644 --- a/src/components/utils/CMakeLists.txt +++ b/src/components/utils/CMakeLists.txt @@ -101,7 +101,7 @@ set(PATHS collect_sources(SOURCES "${PATHS}" "${EXCLUDE_PATHS}") if (CMAKE_SYSTEM_NAME STREQUAL "QNX") - # --- QDB Wrapper + # --- QDB Wrapper add_subdirectory(./src/qdb_wrapper) else () # --- SQLite Wrapper @@ -109,14 +109,15 @@ else () endif () if(${CMAKE_SYSTEM_NAME} MATCHES "Linux") - list(APPEND LIBRARIES dl pthread ${RTLIB}) + list(APPEND LIBRARIES dl pthread ${RTLIB}) endif() add_library("Utils" ${SOURCES}) +list(APPEND LIBRARIES -lboost_system -lboost_thread -lboost_date_time) target_link_libraries("Utils" ${LIBRARIES}) if(ENABLE_LOG) - add_dependencies("Utils" install-3rd_party_logger) + add_dependencies("Utils" install-3rd_party_logger Boost) endif() if(BUILD_TESTS) diff --git a/src/components/utils/src/date_time.cc b/src/components/utils/src/date_time.cc index fdf0926eb2..2802ed0f91 100644 --- a/src/components/utils/src/date_time.cc +++ b/src/components/utils/src/date_time.cc @@ -30,94 +30,69 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include #include +#include #include "utils/date_time.h" +namespace bpt = boost::posix_time; +using namespace boost::date_time; namespace date_time { -TimevalStruct DateTime::getCurrentTime() { - TimevalStruct currentTime; - timezone timeZone; - - gettimeofday(¤tTime, &timeZone); +/* Set of helper functions for the TimeDuration struct + */ - return currentTime; +TimeDuration getCurrentTime() { + return bpt::microsec_clock::local_time() - bpt::from_time_t(0); +} +TimeDuration TimeDurationZero() { + return TimeDuration(0, 0, 0, 0); +} +int64_t getSecs(const TimeDuration& t) { + return t.total_seconds(); } -int64_t date_time::DateTime::getSecs(const TimevalStruct& time) { - const TimevalStruct times = ConvertionUsecs(time); - return static_cast(times.tv_sec); +int64_t getmSecs(const TimeDuration& t) { + return t.total_milliseconds(); } -int64_t DateTime::getmSecs(const TimevalStruct& time) { - const TimevalStruct times = ConvertionUsecs(time); - return static_cast(times.tv_sec) * MILLISECONDS_IN_SECOND + - times.tv_usec / MICROSECONDS_IN_MILLISECOND; +int64_t getuSecs(const TimeDuration& t) { + return t.total_microseconds(); } -int64_t DateTime::getuSecs(const TimevalStruct& time) { - const TimevalStruct times = ConvertionUsecs(time); - return static_cast(times.tv_sec) * MILLISECONDS_IN_SECOND * - MICROSECONDS_IN_MILLISECOND + - times.tv_usec; +int64_t get_just_mSecs(const TimeDuration& t) { + return t.total_milliseconds() % MILLISECONDS_IN_SECOND; } -int64_t DateTime::calculateTimeSpan(const TimevalStruct& sinceTime) { - return calculateTimeDiff(getCurrentTime(), sinceTime); +int64_t get_just_uSecs(const TimeDuration& t) { + return t.total_microseconds() % MICROSECONDS_IN_SECOND; } -int64_t DateTime::calculateTimeDiff(const TimevalStruct& time1, - const TimevalStruct& time2) { - const TimevalStruct times1 = ConvertionUsecs(time1); - const TimevalStruct times2 = ConvertionUsecs(time2); - TimevalStruct ret; - if (Greater(times1, times2)) { - ret = Sub(times1, times2); - } else { - ret = Sub(times2, times1); - } - return getmSecs(ret); +int64_t calculateTimeSpan(const TimeDuration& sinceTime) { + return calculateTimeDiff(getCurrentTime(), sinceTime); } -void DateTime::AddMilliseconds(TimevalStruct& time, uint32_t milliseconds) { - const uint32_t sec = milliseconds / MILLISECONDS_IN_SECOND; - const uint32_t usec = - (milliseconds % MILLISECONDS_IN_SECOND) * MICROSECONDS_IN_MILLISECOND; - time.tv_sec += sec; - time.tv_usec += usec; - time = ConvertionUsecs(time); +int64_t calculateTimeDiff(const TimeDuration& time1, + const TimeDuration& time2) { + return std::abs((time1 + -time2).total_milliseconds()); } -TimevalStruct DateTime::Sub(const TimevalStruct& time1, - const TimevalStruct& time2) { - const TimevalStruct times1 = ConvertionUsecs(time1); - const TimevalStruct times2 = ConvertionUsecs(time2); - TimevalStruct ret; - timersub(×1, ×2, &ret); - return ret; +void AddMilliseconds(TimeDuration& t, uint32_t milliseconds) { + t += bpt::milliseconds(milliseconds); } -bool DateTime::Greater(const TimevalStruct& time1, const TimevalStruct& time2) { - const TimevalStruct times1 = ConvertionUsecs(time1); - const TimevalStruct times2 = ConvertionUsecs(time2); - return timercmp(×1, ×2, > ); +bool Greater(const TimeDuration& time1, const TimeDuration& time2) { + return time1 > time2; } -bool DateTime::Less(const TimevalStruct& time1, const TimevalStruct& time2) { - const TimevalStruct times1 = ConvertionUsecs(time1); - const TimevalStruct times2 = ConvertionUsecs(time2); - return timercmp(×1, ×2, < ); +bool Less(const TimeDuration& time1, const TimeDuration& time2) { + return time1 < time2; } -bool DateTime::Equal(const TimevalStruct& time1, const TimevalStruct& time2) { - const TimevalStruct times1 = ConvertionUsecs(time1); - const TimevalStruct times2 = ConvertionUsecs(time2); - return !timercmp(×1, ×2, != ); +bool Equal(const TimeDuration& time1, const TimeDuration& time2) { + return time1 == time2; } -TimeCompare date_time::DateTime::compareTime(const TimevalStruct& time1, - const TimevalStruct& time2) { +TimeCompare compareTime(const TimeDuration& time1, const TimeDuration& time2) { if (Greater(time1, time2)) return GREATER; if (Less(time1, time2)) @@ -125,28 +100,4 @@ TimeCompare date_time::DateTime::compareTime(const TimevalStruct& time1, return EQUAL; } -TimevalStruct date_time::DateTime::ConvertionUsecs(const TimevalStruct& time) { - if (time.tv_usec >= MICROSECONDS_IN_SECOND) { - TimevalStruct time1; - time1.tv_sec = static_cast(time.tv_sec) + - (time.tv_usec / MICROSECONDS_IN_SECOND); - time1.tv_usec = static_cast(time.tv_usec) % MICROSECONDS_IN_SECOND; - return time1; - } - return time; -} - } // namespace date_time - -bool operator<(const TimevalStruct& time1, const TimevalStruct& time2) { - return date_time::DateTime::Less(time1, time2); -} - -bool operator==(const TimevalStruct& time1, const TimevalStruct& time2) { - return date_time::DateTime::Equal(time1, time2); -} - -const TimevalStruct operator-(const TimevalStruct& time1, - const TimevalStruct& time2) { - return date_time::DateTime::Sub(time1, time2); -} diff --git a/src/components/utils/test/date_time_test.cc b/src/components/utils/test/date_time_test.cc index a209ab4d43..34d3b0f959 100644 --- a/src/components/utils/test/date_time_test.cc +++ b/src/components/utils/test/date_time_test.cc @@ -30,6 +30,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ +#include #include "gtest/gtest.h" #include "utils/date_time.h" @@ -38,364 +39,274 @@ namespace components { namespace utils_test { using namespace date_time; + +namespace bpt = boost::posix_time; TEST(DateTimeTest, GetCurrentTime) { // arrange - const TimevalStruct time1 = date_time::DateTime::getCurrentTime(); + const date_time::TimeDuration time1 = getCurrentTime(); // assert - ASSERT_NE(0, time1.tv_sec); - ASSERT_GE(time1.tv_usec, 0); + ASSERT_NE(0, time1.total_seconds()); + ASSERT_GE(get_just_uSecs(time1), 0); // act - const TimevalStruct time2 = date_time::DateTime::getCurrentTime(); + const date_time::TimeDuration time2 = getCurrentTime(); // assert - ASSERT_NE(0, time2.tv_sec); - ASSERT_GE(time2.tv_usec, 0); - ASSERT_GE(time2.tv_sec, time1.tv_sec); + ASSERT_NE(0, time2.total_seconds()); + ASSERT_GE(get_just_uSecs(time1), 0); + ASSERT_GE(time2.total_seconds(), time1.total_seconds()); } TEST(DateTimeTest, GetSecs) { // arrange - TimevalStruct time; - time.tv_sec = 1; - time.tv_usec = 2 * date_time::DateTime::MICROSECONDS_IN_MILLISECOND; + date_time::TimeDuration time1 = bpt::seconds(1) + bpt::milliseconds(2); // assert - ASSERT_EQ(1, date_time::DateTime::getSecs(time)); + ASSERT_EQ(1, getSecs(time1)); } TEST(DateTimeTest, GetmSecs) { // arrange - TimevalStruct time; - time.tv_sec = 1; - time.tv_usec = 2 * date_time::DateTime::MICROSECONDS_IN_MILLISECOND; + date_time::TimeDuration time1 = bpt::seconds(1) + bpt::milliseconds(2); + int expected = 1 * MILLISECONDS_IN_SECOND + 2; - int64_t expect_value = - time.tv_sec * date_time::DateTime::MILLISECONDS_IN_SECOND + - time.tv_usec / date_time::DateTime::MICROSECONDS_IN_MILLISECOND; // assert - ASSERT_EQ(expect_value, date_time::DateTime::getmSecs(time)); + ASSERT_EQ(expected, getmSecs(time1)); } TEST(DateTimeTest, GetuSecs) { // arrange - TimevalStruct time; - time.tv_sec = 3; - time.tv_usec = 4; - - int64_t expect_value = time.tv_sec * - date_time::DateTime::MILLISECONDS_IN_SECOND * - date_time::DateTime::MICROSECONDS_IN_MILLISECOND + - time.tv_usec; + date_time::TimeDuration time1 = bpt::seconds(3) + bpt::microseconds(4); + int expect_value = 3 * MILLISECONDS_IN_SECOND * + MICROSECONDS_IN_MILLISECOND + + 4; + // assert - ASSERT_EQ(expect_value, date_time::DateTime::getuSecs(time)); + ASSERT_EQ(expect_value, getuSecs(time1)); } TEST(DateTimeTest, GetuSecsmSecs) { // arrange - TimevalStruct time; - time.tv_sec = 5; - time.tv_usec = 6; + date_time::TimeDuration time1 = bpt::seconds(5) + bpt::microseconds(6); - int64_t expect_value = date_time::DateTime::getuSecs(time) / - date_time::DateTime::MICROSECONDS_IN_MILLISECOND; + int64_t expect_value = + getuSecs(time1) / MICROSECONDS_IN_MILLISECOND; // assert - ASSERT_EQ(expect_value, date_time::DateTime::getmSecs(time)); + ASSERT_EQ(expect_value, getmSecs(time1)); } TEST(DateTimeTest, CalculateTimeSpan) { // arrange - const TimevalStruct time = date_time::DateTime::getCurrentTime(); + const date_time::TimeDuration time1 = getCurrentTime(); const uint32_t sleep_time_mSec = 10; - usleep(sleep_time_mSec * date_time::DateTime::MICROSECONDS_IN_MILLISECOND); + // sleep current thread + boost::this_thread::sleep(boost::posix_time::milliseconds(sleep_time_mSec)); // assert - ASSERT_GE(date_time::DateTime::calculateTimeSpan(time), sleep_time_mSec); + ASSERT_GE(calculateTimeSpan(time1), sleep_time_mSec); } TEST(DateTimeTest, CalculateTimeDiff) { // arrange - TimevalStruct time1; - time1.tv_sec = 1; - time1.tv_usec = 2 * date_time::DateTime::MICROSECONDS_IN_MILLISECOND; - TimevalStruct time2; - time2.tv_sec = 3; - time2.tv_usec = 4 * date_time::DateTime::MICROSECONDS_IN_MILLISECOND; + date_time::TimeDuration time1 = bpt::seconds(2) + bpt::milliseconds(2); + date_time::TimeDuration time2 = bpt::seconds(3) + bpt::milliseconds(4); // time2 to time1 - TimevalStruct diff1; - diff1.tv_sec = time2.tv_sec - time1.tv_sec; - diff1.tv_usec = time2.tv_usec - time1.tv_usec; - - const int64_t mSecDiff = - static_cast(diff1.tv_sec) * 1000 + diff1.tv_usec / 1000; + date_time::TimeDuration diff1 = bpt::seconds(1) + bpt::milliseconds(2); // assert - ASSERT_EQ(mSecDiff, date_time::DateTime::calculateTimeDiff(time2, time1)); - - // time1 to time2 - TimevalStruct diff2; - diff2.tv_sec = time1.tv_sec - time2.tv_sec; - diff2.tv_usec = time1.tv_usec - time2.tv_usec; + ASSERT_EQ(diff1.total_milliseconds(), + calculateTimeDiff(time2, time1)); - const int64_t mSecDiff2 = - -(static_cast(diff2.tv_sec) * 1000 + diff2.tv_usec / 1000); + // time1 to time2, but calculateTimeDiff returns an absolute value + date_time::TimeDuration diff2 = -diff1.invert_sign(); // assert - ASSERT_EQ(mSecDiff2, date_time::DateTime::calculateTimeDiff(time1, time2)); + ASSERT_EQ(diff2.total_milliseconds(), + calculateTimeDiff(time1, time2)); } TEST(DateTimeTest, CalculateEqualTimeDiff) { - TimevalStruct time1; - time1.tv_sec = 1; - time1.tv_usec = 2 * date_time::DateTime::MICROSECONDS_IN_MILLISECOND; + date_time::TimeDuration time1 = bpt::seconds(1) + bpt::milliseconds(2); - TimevalStruct time2; - time2.tv_sec = 1; - time2.tv_usec = 2 * date_time::DateTime::MICROSECONDS_IN_MILLISECOND; + date_time::TimeDuration time2 = bpt::seconds(1) + bpt::milliseconds(2); - ASSERT_EQ(0, date_time::DateTime::calculateTimeDiff(time2, time1)); - ASSERT_EQ(0, date_time::DateTime::calculateTimeDiff(time1, time2)); + ASSERT_EQ(0, calculateTimeDiff(time2, time1)); + ASSERT_EQ(0, calculateTimeDiff(time1, time2)); } TEST(DateTimeTest, compareTime) { // arrange - TimevalStruct time1; - time1.tv_sec = 1; - time1.tv_usec = 2 * date_time::DateTime::MICROSECONDS_IN_MILLISECOND; + date_time::TimeDuration time1 = bpt::seconds(1) + bpt::milliseconds(2); - TimevalStruct time2; - time2.tv_sec = 2; - time2.tv_usec = 4 * date_time::DateTime::MICROSECONDS_IN_MILLISECOND; + date_time::TimeDuration time2 = bpt::seconds(2) + bpt::milliseconds(4); // assert - ASSERT_EQ(LESS, date_time::DateTime::compareTime(time1, time2)); - ASSERT_EQ(GREATER, date_time::DateTime::compareTime(time2, time1)); - ASSERT_NE(EQUAL, date_time::DateTime::compareTime(time2, time1)); + ASSERT_EQ(LESS, compareTime(time1, time2)); + ASSERT_EQ(GREATER, compareTime(time2, time1)); + ASSERT_NE(EQUAL, compareTime(time2, time1)); // act - TimevalStruct time3 = date_time::DateTime::Sub(time2, time1); + date_time::TimeDuration time3 = time2 - time1; // assert - ASSERT_EQ(EQUAL, date_time::DateTime::compareTime(time1, time3)); + ASSERT_EQ(EQUAL, compareTime(time1, time3)); } TEST(DateTimeTest, GetSecs_UsecConvertedInSec) { // arrange - TimevalStruct time1; - time1.tv_sec = 0; - time1.tv_usec = date_time::DateTime::MICROSECONDS_IN_SECOND; + date_time::TimeDuration time1 = bpt::microseconds(MICROSECONDS_IN_SECOND); // assert - ASSERT_EQ(1, date_time::DateTime::getSecs(time1)); + ASSERT_EQ(1, getSecs(time1)); } TEST(DateTimeTest, compareTime_UsecConvertedInSec) { // arrange - TimevalStruct time1; - time1.tv_sec = 1; - time1.tv_usec = 0; - - TimevalStruct time2; - time2.tv_sec = 0; - time2.tv_usec = date_time::DateTime::MICROSECONDS_IN_SECOND; - - // assert - ASSERT_EQ(1, date_time::DateTime::getSecs(time1)); - ASSERT_EQ(1, date_time::DateTime::getSecs(time2)); - ASSERT_EQ(EQUAL, date_time::DateTime::compareTime(time1, time2)); -} - -TEST(DateTimeTest, compareEqualTime_UsecConvertedInSec) { - // arrange - TimevalStruct time1; - time1.tv_sec = 1; - time1.tv_usec = 0; + date_time::TimeDuration time1 = bpt::seconds(1); - TimevalStruct time2; - time2.tv_sec = 0; - time2.tv_usec = date_time::DateTime::MICROSECONDS_IN_SECOND; + date_time::TimeDuration time2 = bpt::microseconds(MICROSECONDS_IN_SECOND); // assert - ASSERT_TRUE(date_time::DateTime::Equal(time1, time2)); + ASSERT_EQ(1, getSecs(time1)); + ASSERT_EQ(1, getSecs(time2)); + ASSERT_EQ(EQUAL, compareTime(time1, time2)); + ASSERT_TRUE(Equal(time1, time2)); } TEST(DateTimeTest, compareLessTime_UsecConvertedInSec) { // arrange - TimevalStruct time1; - time1.tv_sec = 1; - time1.tv_usec = 0; + date_time::TimeDuration time1 = bpt::seconds(1); - TimevalStruct time2; - time2.tv_sec = 0; - time2.tv_usec = 2 * date_time::DateTime::MICROSECONDS_IN_SECOND; + date_time::TimeDuration time2 = bpt::microseconds(2 * MICROSECONDS_IN_SECOND); // assert - ASSERT_TRUE(date_time::DateTime::Less(time1, time2)); + ASSERT_TRUE(Less(time1, time2)); } TEST(DateTimeTest, compareGreaterTime_UsecConvertedInSec) { // arrange - TimevalStruct time1; - time1.tv_sec = 1; - time1.tv_usec = 0; + date_time::TimeDuration time1 = bpt::seconds(1); - TimevalStruct time2; - time2.tv_sec = 0; - time2.tv_usec = 2 * date_time::DateTime::MICROSECONDS_IN_SECOND; + date_time::TimeDuration time2 = bpt::milliseconds(2 * MICROSECONDS_IN_SECOND); // assert - ASSERT_TRUE(date_time::DateTime::Greater(time2, time1)); + ASSERT_TRUE(Greater(time2, time1)); } TEST(DateTimeTest, CalculateTimeSub_UsecConvertedInSec) { // arrange - TimevalStruct time1; - time1.tv_sec = 1; - time1.tv_usec = 0; + date_time::TimeDuration time1 = bpt::seconds(1); - TimevalStruct time2; - time2.tv_sec = 0; - time2.tv_usec = 2 * date_time::DateTime::MICROSECONDS_IN_SECOND; + date_time::TimeDuration time2 = bpt::microseconds(2 * MICROSECONDS_IN_SECOND); - TimevalStruct time3 = date_time::DateTime::Sub(time2, time1); + date_time::TimeDuration time3 = time2 - time1; // assert - ASSERT_EQ(EQUAL, date_time::DateTime::compareTime(time1, time3)); + ASSERT_EQ(EQUAL, compareTime(time1, time3)); } TEST(DateTimeTest, CalculateTimeDiff_UsecConvertedInSec) { // arrange - TimevalStruct time1; - time1.tv_sec = 2; - time1.tv_usec = 5 * date_time::DateTime::MICROSECONDS_IN_SECOND; - TimevalStruct time2; - time2.tv_sec = 3; - time2.tv_usec = 1 * date_time::DateTime::MICROSECONDS_IN_SECOND; + date_time::TimeDuration time1 = + bpt::seconds(2) + bpt::microseconds(5 * MICROSECONDS_IN_SECOND); + date_time::TimeDuration time2 = + bpt::seconds(3) + bpt::microseconds(1 * MICROSECONDS_IN_SECOND); // assert - ASSERT_EQ(3000, date_time::DateTime::calculateTimeDiff(time2, time1)); - ASSERT_EQ(3000, date_time::DateTime::calculateTimeDiff(time1, time2)); + ASSERT_EQ(3000, calculateTimeDiff(time2, time1)); + ASSERT_EQ(3000, calculateTimeDiff(time1, time2)); } TEST(DateTimeTest, CalculateEqualTimeDiff_UsecConvertedInSec) { - // arrange - TimevalStruct time1; - time1.tv_sec = 2; - time1.tv_usec = 2 * date_time::DateTime::MICROSECONDS_IN_SECOND; - - TimevalStruct time2; - time2.tv_sec = 3; - time2.tv_usec = 1 * date_time::DateTime::MICROSECONDS_IN_SECOND; + date_time::TimeDuration time1 = + bpt::seconds(2) + bpt::microseconds(2 * MICROSECONDS_IN_SECOND); + date_time::TimeDuration time2 = + bpt::seconds(3) + bpt::microseconds(1 * MICROSECONDS_IN_SECOND); // assert - ASSERT_EQ(0, date_time::DateTime::calculateTimeDiff(time2, time1)); - ASSERT_EQ(0, date_time::DateTime::calculateTimeDiff(time1, time2)); -} + ASSERT_EQ(0, calculateTimeDiff(time2, time1)); + ASSERT_EQ(0, calculateTimeDiff(time1, time2)); -TEST(DateTimeTest, CalculateEqualTimeSub_UsecConvertedInSec) { - // arrange - TimevalStruct time1; - time1.tv_sec = 3; - time1.tv_usec = 0; - - TimevalStruct time2; - time2.tv_sec = 2; - time2.tv_usec = 1 * date_time::DateTime::MICROSECONDS_IN_SECOND; + date_time::TimeDuration time3 = time2 - time1; + date_time::TimeDuration time4 = time1 - time2; - TimevalStruct time3 = date_time::DateTime::Sub(time2, time1); - TimevalStruct time4 = date_time::DateTime::Sub(time1, time2); + date_time::TimeDuration time_expected(0, 0, 0, 0); - TimevalStruct time_expected; - time_expected.tv_sec = 0; - time_expected.tv_usec = 0; - // assert - ASSERT_EQ(EQUAL, date_time::DateTime::compareTime(time_expected, time3)); - ASSERT_EQ(EQUAL, date_time::DateTime::compareTime(time_expected, time4)); + ASSERT_EQ(EQUAL, compareTime(time_expected, time3)); + ASSERT_EQ(EQUAL, compareTime(time_expected, time4)); } TEST(DateTimeTest, AddMilliseconds_SetMillisecondMultiplesSecond_ExpectChangeTime) { - TimevalStruct time1; - time1.tv_sec = 3; - time1.tv_usec = 0; + date_time::TimeDuration time1 = bpt::seconds(3); uint32_t milliseconds = 7000; - date_time::DateTime::AddMilliseconds(time1, milliseconds); - ASSERT_EQ(10, time1.tv_sec); - ASSERT_EQ(0, time1.tv_usec); + AddMilliseconds(time1, milliseconds); + ASSERT_EQ(10, getSecs(time1)); + ASSERT_EQ(0, get_just_mSecs(time1)); } TEST(DateTimeTest, AddMilliseconds_SetMillisecondNotMultiplesSecond_ExpectChangeTime) { - TimevalStruct time1; + date_time::TimeDuration time1 = bpt::seconds(3); uint32_t milliseconds = 7500; - time1.tv_sec = 3; - time1.tv_usec = 0; - date_time::DateTime::AddMilliseconds(time1, milliseconds); - ASSERT_EQ(10, time1.tv_sec); - ASSERT_EQ(500000, time1.tv_usec); + + AddMilliseconds(time1, milliseconds); + ASSERT_EQ(10, time1.total_seconds()); + ASSERT_EQ(500000, get_just_uSecs(time1)); } TEST(DateTimeTest, AddMilliseconds_SetMilliSecondLessThenSeconds_ExpectChangeTime) { - TimevalStruct time1; + date_time::TimeDuration time1 = bpt::seconds(3); uint32_t milliseconds = 500; - time1.tv_sec = 3; - time1.tv_usec = 0; - date_time::DateTime::AddMilliseconds(time1, milliseconds); - ASSERT_EQ(3, time1.tv_sec); - ASSERT_EQ(500000, time1.tv_usec); + + AddMilliseconds(time1, milliseconds); + ASSERT_EQ(3, getSecs(time1)); + ASSERT_EQ(500000, get_just_uSecs(time1)); } TEST(DateTimeTest, AddMilliseconds_SetMillisecondEqualNull_ExpectNotChangeTime) { - TimevalStruct time1; + date_time::TimeDuration time1 = bpt::seconds(3); uint32_t milliseconds = 0; - time1.tv_sec = 3; - time1.tv_usec = 0; - date_time::DateTime::AddMilliseconds(time1, milliseconds); - ASSERT_EQ(3, time1.tv_sec); - ASSERT_EQ(0, time1.tv_usec); + + AddMilliseconds(time1, milliseconds); + ASSERT_EQ(3, getSecs(time1)); + ASSERT_EQ(0, get_just_mSecs(time1)); } TEST(DateTimeTest, AddMilliseconds_SetOverlowMicrosecond_ExpectChangeTime) { - TimevalStruct time1; + date_time::TimeDuration time1 = bpt::seconds(3); uint32_t milliseconds = 7600; - time1.tv_sec = 3; - time1.tv_usec = 500000; - date_time::DateTime::AddMilliseconds(time1, milliseconds); - ASSERT_EQ(11, time1.tv_sec); - ASSERT_EQ(100000, time1.tv_usec); + + AddMilliseconds(time1, milliseconds); + ASSERT_EQ(10, getSecs(time1)); + ASSERT_EQ(600000, get_just_uSecs(time1)); } -TEST(DateTimeTest, Operator_minus_TimevalStruct_positive) { - TimevalStruct time1; - TimevalStruct time2; - TimevalStruct time3; - time1.tv_sec = 3; - time1.tv_usec = 0; - time2.tv_sec = 3; - time2.tv_usec = 0; - time3.tv_sec = 2; - time3.tv_usec = 9000000; - ASSERT_EQ(0, date_time::DateTime::getSecs(time1 - time2)); - ASSERT_EQ(8000000, date_time::DateTime::getuSecs(time3 - time1)); +TEST(DateTimeTest, Operator_minus_TimeDuration_positive) { + date_time::TimeDuration time1 = bpt::seconds(3); + date_time::TimeDuration time2 = bpt::seconds(3); + date_time::TimeDuration time3 = + bpt::seconds(2) + bpt::microseconds(9 * MICROSECONDS_IN_SECOND); + date_time::TimeDuration diff1 = time1 - time2; + ASSERT_EQ(0, getSecs(diff1)); + ASSERT_EQ(8000000, getuSecs(time3 - time1)); } -TEST(DateTimeTest, Operator_minus_TimevalStruct_negative) { - TimevalStruct time1; - TimevalStruct time2; - time1.tv_sec = 3; - time1.tv_usec = 0; - time2.tv_sec = 2; - time2.tv_usec = 9000000; - ASSERT_NE(1, date_time::DateTime::getSecs(time1 - time2)); - ASSERT_NE(-8000000, date_time::DateTime::getSecs(time2 - time1)); +TEST(DateTimeTest, Operator_minus_TimeDuration_negative) { + date_time::TimeDuration time1 = bpt::seconds(3); + date_time::TimeDuration time2 = + bpt::seconds(2) + bpt::microseconds(9 * MICROSECONDS_IN_SECOND); + + ASSERT_NE(1, getSecs(time1 - time2)); + ASSERT_NE(-8000000, getSecs(time2 - time1)); } } // namespace utils_test diff --git a/src/components/utils/test/messagemeter_test.cc b/src/components/utils/test/messagemeter_test.cc index 4ec14ac1cc..d45e600034 100644 --- a/src/components/utils/test/messagemeter_test.cc +++ b/src/components/utils/test/messagemeter_test.cc @@ -57,25 +57,25 @@ const TimePair testing_time_pairs[] = {TimePair(0, 50), class MessageMeterTest : public ::testing::TestWithParam { protected: void SetUp() OVERRIDE { - usecs = date_time::DateTime::MICROSECONDS_IN_MILLISECOND; + usecs = date_time::MICROSECONDS_IN_MILLISECOND; id1 = 0x0; id2 = 0xABCDEF; id3 = 0xFEBCDA; const TimePair time_pair = GetParam(); EXPECT_GT(usecs, time_pair.second) << "Wrong time (msecs) value"; + time_range = date_time::seconds(time_pair.first) + + date_time::microseconds(time_pair.second * usecs); - time_range.tv_sec = time_pair.first; - time_range.tv_usec = time_pair.second * usecs; - EXPECT_LT(0, date_time::DateTime::getuSecs(time_range)) + EXPECT_LT(0, date_time::getuSecs(time_range)) << "Wrong test case with null range value"; meter.set_time_range(time_range); - time_range_msecs = date_time::DateTime::getmSecs(time_range); + time_range_msecs = date_time::getmSecs(time_range); } void TearDown() OVERRIDE {} ::utils::MessageMeter meter; - TimevalStruct time_range = {0, 0}; + date_time::TimeDuration time_range = date_time::TimeDurationZero(); int64_t time_range_msecs; int usecs; int id1, id2, id3; @@ -83,27 +83,25 @@ class MessageMeterTest : public ::testing::TestWithParam { TEST(MessageMeterTest, DefaultTimeRange) { const ::utils::MessageMeter default_meter; - const TimevalStruct time_second{1, 0}; + const date_time::TimeDuration time_second = date_time::seconds(1); EXPECT_EQ(time_second, default_meter.time_range()); } TEST(MessageMeterTest, TimeRangeSetter) { ::utils::MessageMeter meter; - TimevalStruct time_range{0, 0}; + date_time::TimeDuration time_range; const int test_count_secs = 1000; - // Skip 1000th msec value as wrong for TimevalStruct + // Skip 1000th msec value as wrong for date_time::TimeDuration const int test_count_msecs = 999; for (int sec = test_count_secs; sec >= 0; --sec) { for (int msec = test_count_msecs; msec >= 0; --msec) { - time_range.tv_sec = sec; - time_range.tv_usec = - msec * date_time::DateTime::MICROSECONDS_IN_MILLISECOND; - // Setter TimevalStruct + time_range = date_time::seconds(sec) + date_time::milliseconds(msec); + + // Setter date_time::TimeDuration meter.set_time_range(time_range); EXPECT_EQ(time_range, meter.time_range()) << sec << "." << msec << " sec"; // Setter mSecs - meter.set_time_range(sec * date_time::DateTime::MILLISECONDS_IN_SECOND + - msec); + meter.set_time_range(sec * date_time::MILLISECONDS_IN_SECOND + msec); EXPECT_EQ(time_range, meter.time_range()) << sec << "." << msec << " sec"; } } @@ -113,7 +111,7 @@ TEST(MessageMeterTest, AddingWithNullTimeRange) { ::utils::MessageMeter meter; const int id1 = 1; const int id2 = 2; - const TimevalStruct null_time_range{0, 0}; + const date_time::TimeDuration null_time_range = date_time::TimeDurationZero(); meter.set_time_range(null_time_range); for (int i = 0; i < 10000; ++i) { // 1st Connection @@ -129,10 +127,10 @@ TEST(MessageMeterTest, AddingWithNullTimeRange) { TEST_P(MessageMeterTest, DISABLED_TrackMessage_AddingOverPeriod_CorrectCountOfMessages) { size_t messages = 0; - const TimevalStruct start_time = date_time::DateTime::getCurrentTime(); + const date_time::TimeDuration start_time = date_time::getCurrentTime(); // Add messages for less range period int64_t time_span; - while ((time_span = date_time::DateTime::calculateTimeSpan(start_time)) < + while ((time_span = date_time::calculateTimeSpan(start_time)) < time_range_msecs) { ++messages; @@ -153,10 +151,10 @@ TEST_P(MessageMeterTest, TEST_P(MessageMeterTest, DISABLED_TrackMessage_AddingOverPeriodMultiIds_CorrectCountOfMessages) { size_t messages = 0; - const TimevalStruct start_time = date_time::DateTime::getCurrentTime(); + const date_time::TimeDuration start_time = date_time::getCurrentTime(); // Add messages for less range period int64_t time_span; - while ((time_span = date_time::DateTime::calculateTimeSpan(start_time)) < + while ((time_span = date_time::calculateTimeSpan(start_time)) < time_range_msecs) { ++messages; @@ -188,14 +186,14 @@ TEST_P(MessageMeterTest, TEST_P(MessageMeterTest, DISABLED_Frequency_CountingOverPeriod_CorrectCountOfMessages) { const size_t one_message = 1; - const TimevalStruct start_time = date_time::DateTime::getCurrentTime(); + const date_time::TimeDuration start_time = date_time::getCurrentTime(); EXPECT_EQ(one_message, meter.TrackMessage(id1)); EXPECT_EQ(one_message, meter.TrackMessage(id2)); EXPECT_EQ(one_message, meter.TrackMessage(id3)); // Check messages count over period int64_t time_span; - while ((time_span = date_time::DateTime::calculateTimeSpan(start_time)) < + while ((time_span = date_time::calculateTimeSpan(start_time)) < time_range_msecs) { usleep(time_range_msecs); -- cgit v1.2.1 From b4a758a70a86ad92ae8db21907be42bbe4d44809 Mon Sep 17 00:00:00 2001 From: Conlain Kelly Date: Mon, 25 Jun 2018 13:20:36 -0400 Subject: Style fix --- src/components/application_manager/src/application_impl.cc | 13 +++++++------ .../application_manager/src/application_manager_impl.cc | 4 ++-- .../application_manager/src/request_controller.cc | 4 ++-- src/components/application_manager/src/request_info.cc | 3 +-- .../application_manager/test/request_info_test.cc | 11 +++++++---- .../include/protocol_handler/telemetry_observer.h | 4 ++-- .../test/protocol_handler/mock_telemetry_observer.h | 3 ++- .../policy/policy_external/src/usage_statistics/counter.cc | 3 +-- .../policy/policy_regular/src/policy_manager_impl.cc | 3 +-- .../policy/policy_regular/src/usage_statistics/counter.cc | 3 +-- .../policy/policy_regular/test/policy_manager_impl_test.cc | 10 ++++++---- .../include/protocol_handler/mock_telemetry_observer.h | 3 ++- src/components/security_manager/src/crypto_manager_impl.cc | 4 ++-- .../include/telemetry_monitor/transport_manager_observer.h | 3 ++- .../src/application_manager_metric_wrapper.cc | 3 +-- .../src/protocol_handler_metric_wrapper.cc | 3 +-- .../src/transport_manager_metric_wrapper.cc | 3 +-- .../telemetry_monitor/src/transport_manager_observer.cc | 4 ++-- .../test/transport_manager_metric_test.cc | 12 ++++-------- src/components/utils/test/date_time_test.cc | 14 +++++--------- 20 files changed, 52 insertions(+), 58 deletions(-) diff --git a/src/components/application_manager/src/application_impl.cc b/src/components/application_manager/src/application_impl.cc index 54121bae74..6333228d95 100644 --- a/src/components/application_manager/src/application_impl.cc +++ b/src/components/application_manager/src/application_impl.cc @@ -753,7 +753,7 @@ bool ApplicationImpl::SubscribeToIVI(uint32_t vehicle_info_type) { sync_primitives::AutoLock lock(vi_lock_); return subscribed_vehicle_info_ .insert( - static_cast(vehicle_info_type)) + static_cast(vehicle_info_type)) .second; } @@ -808,10 +808,10 @@ bool ApplicationImpl::AreCommandLimitsExceeded( LOG4CXX_INFO(logger_, "Time Info: " - << "\n Current: " << date_time::getSecs(current) << "\n Limit: (" - << date_time::getSecs(limit.first) << "," << limit.second - << ")" - "\n frequency_restrictions: (" + << "\n Current: " << date_time::getSecs(current) + << "\n Limit: (" << date_time::getSecs(limit.first) + << "," << limit.second << ")" + "\n frequency_restrictions: (" << frequency_restrictions.first << "," << frequency_restrictions.second << ")"); if (date_time::getSecs(current) < @@ -857,7 +857,8 @@ bool ApplicationImpl::AreCommandLimitsExceeded( TimeToNumberLimit& limit = it->second; // Checking even limitation for command - if (static_cast(date_time::getSecs(current) - date_time::getSecs(limit.first)) < + if (static_cast(date_time::getSecs(current) - + date_time::getSecs(limit.first)) < minute / cmd_limit) { return true; } diff --git a/src/components/application_manager/src/application_manager_impl.cc b/src/components/application_manager/src/application_manager_impl.cc index 1d7f233b49..4f9a77f22f 100644 --- a/src/components/application_manager/src/application_manager_impl.cc +++ b/src/components/application_manager/src/application_manager_impl.cc @@ -4002,8 +4002,8 @@ void ApplicationManagerImpl::OnTimerSendTTSGlobalProperties() { tts_global_properties_app_list_.end(); date_time::TimeCompare time_comp; for (; it != it_end; ++it) { - time_comp = date_time::compareTime( - date_time::getCurrentTime(), it->second); + time_comp = + date_time::compareTime(date_time::getCurrentTime(), it->second); if (date_time::GREATER == time_comp || date_time::EQUAL == time_comp) { app_list.push_back(it->first); } diff --git a/src/components/application_manager/src/request_controller.cc b/src/components/application_manager/src/request_controller.cc index 1620128f74..4710433e0c 100644 --- a/src/components/application_manager/src/request_controller.cc +++ b/src/components/application_manager/src/request_controller.cc @@ -410,8 +410,8 @@ void RequestController::TimeoutThread() { const date_time::TimeDuration current_time = date_time::getCurrentTime(); const date_time::TimeDuration end_time = probably_expired->end_time(); if (current_time < end_time) { - const uint32_t msecs = static_cast( - date_time::getmSecs(end_time - current_time)); + const uint32_t msecs = + static_cast(date_time::getmSecs(end_time - current_time)); LOG4CXX_DEBUG(logger_, "Sleep for " << msecs << " millisecs"); timer_condition_.WaitFor(auto_lock, msecs); } diff --git a/src/components/application_manager/src/request_info.cc b/src/components/application_manager/src/request_info.cc index d26f69a39b..c59e2f2da2 100644 --- a/src/components/application_manager/src/request_info.cc +++ b/src/components/application_manager/src/request_info.cc @@ -96,8 +96,7 @@ void RequestInfo::updateTimeOut(const uint64_t& timeout_msec) { bool RequestInfo::isExpired() { date_time::TimeDuration curr_time = date_time::getCurrentTime(); - return date_time::getmSecs(end_time_) <= - date_time::getmSecs(curr_time); + return date_time::getmSecs(end_time_) <= date_time::getmSecs(curr_time); } uint64_t RequestInfo::hash() { diff --git a/src/components/application_manager/test/request_info_test.cc b/src/components/application_manager/test/request_info_test.cc index 8cef39d162..74145bdb08 100644 --- a/src/components/application_manager/test/request_info_test.cc +++ b/src/components/application_manager/test/request_info_test.cc @@ -307,10 +307,12 @@ TEST_F(RequestInfoTest, RequestInfoSetEqualHash) { TEST_F(RequestInfoTest, EndTimeisExpired) { date_time::TimeDuration time = date_time::getCurrentTime(); // get just the seconds part of the current time - date_time::TimeDuration not_expired = date_time::seconds(date_time::getSecs(date_time::getCurrentTime())); - not_expired+= date_time::microseconds(std::numeric_limits::min()); + date_time::TimeDuration not_expired = + date_time::seconds(date_time::getSecs(date_time::getCurrentTime())); + not_expired += date_time::microseconds(std::numeric_limits::min()); - date_time::TimeDuration expired = date_time::seconds(date_time::getSecs(date_time::getCurrentTime())); + date_time::TimeDuration expired = + date_time::seconds(date_time::getSecs(date_time::getCurrentTime())); expired += date_time::microseconds(std::numeric_limits::max()); utils::SharedPtr request = @@ -355,7 +357,8 @@ TEST_F(RequestInfoTest, UpdateTimeOut) { request->updateTimeOut(100); time = date_time::getCurrentTime(); date_time::TimeDuration last_time = request->end_time(); - EXPECT_NEAR(date_time::getSecs(time) + 100, date_time::getSecs(last_time), 500); + EXPECT_NEAR( + date_time::getSecs(time) + 100, date_time::getSecs(last_time), 500); } } // namespace application_manager_test diff --git a/src/components/include/protocol_handler/telemetry_observer.h b/src/components/include/protocol_handler/telemetry_observer.h index 301496589c..533ad51d62 100644 --- a/src/components/include/protocol_handler/telemetry_observer.h +++ b/src/components/include/protocol_handler/telemetry_observer.h @@ -48,8 +48,8 @@ class PHTelemetryObserver { date_time::TimeDuration begin; date_time::TimeDuration end; }; - virtual void StartMessageProcess(uint32_t message_id, - const date_time::TimeDuration& start_time) = 0; + virtual void StartMessageProcess( + uint32_t message_id, const date_time::TimeDuration& start_time) = 0; virtual void EndMessageProcess(utils::SharedPtr m) = 0; virtual ~PHTelemetryObserver() {} }; diff --git a/src/components/include/test/protocol_handler/mock_telemetry_observer.h b/src/components/include/test/protocol_handler/mock_telemetry_observer.h index 0a0eb261d3..6b24d5a919 100644 --- a/src/components/include/test/protocol_handler/mock_telemetry_observer.h +++ b/src/components/include/test/protocol_handler/mock_telemetry_observer.h @@ -44,7 +44,8 @@ namespace protocol_handler_test { class MockPHTelemetryObserver : public PHTelemetryObserver { public: MOCK_METHOD2(StartMessageProcess, - void(uint32_t message_id, const date_time::TimeDuration& start_time)); + void(uint32_t message_id, + const date_time::TimeDuration& start_time)); MOCK_METHOD1(EndMessageProcess, void(utils::SharedPtr m)); }; diff --git a/src/components/policy/policy_external/src/usage_statistics/counter.cc b/src/components/policy/policy_external/src/usage_statistics/counter.cc index e2c4d59b0e..6f3373c6a5 100644 --- a/src/components/policy/policy_external/src/usage_statistics/counter.cc +++ b/src/components/policy/policy_external/src/usage_statistics/counter.cc @@ -107,8 +107,7 @@ AppStopwatchImpl::~AppStopwatchImpl() {} void AppStopwatchImpl::Start(AppStopwatchId stopwatch_type) { stopwatch_type_ = stopwatch_type; - timer_.Start(time_out_ * date_time::MILLISECONDS_IN_SECOND, - timer::kPeriodic); + timer_.Start(time_out_ * date_time::MILLISECONDS_IN_SECOND, timer::kPeriodic); } void AppStopwatchImpl::Switch(AppStopwatchId stopwatch_type) { diff --git a/src/components/policy/policy_regular/src/policy_manager_impl.cc b/src/components/policy/policy_regular/src/policy_manager_impl.cc index ba850efde5..5462601c35 100644 --- a/src/components/policy/policy_regular/src/policy_manager_impl.cc +++ b/src/components/policy/policy_regular/src/policy_manager_impl.cc @@ -882,8 +882,7 @@ uint32_t PolicyManagerImpl::NextRetryTimeout() { } for (uint32_t i = 0u; i < retry_sequence_index_; ++i) { - next += retry_sequence_seconds_[i] * - date_time::MILLISECONDS_IN_SECOND; + next += retry_sequence_seconds_[i] * date_time::MILLISECONDS_IN_SECOND; next += retry_sequence_timeout_; } ++retry_sequence_index_; diff --git a/src/components/policy/policy_regular/src/usage_statistics/counter.cc b/src/components/policy/policy_regular/src/usage_statistics/counter.cc index 83e12194e0..a0b6b689d4 100644 --- a/src/components/policy/policy_regular/src/usage_statistics/counter.cc +++ b/src/components/policy/policy_regular/src/usage_statistics/counter.cc @@ -103,8 +103,7 @@ AppStopwatchImpl::AppStopwatchImpl( void AppStopwatchImpl::Start(AppStopwatchId stopwatch_type) { stopwatch_type_ = stopwatch_type; - timer_.Start(time_out_ * date_time::MILLISECONDS_IN_SECOND, - timer::kPeriodic); + timer_.Start(time_out_ * date_time::MILLISECONDS_IN_SECOND, timer::kPeriodic); } void AppStopwatchImpl::Switch(AppStopwatchId stopwatch_type) { diff --git a/src/components/policy/policy_regular/test/policy_manager_impl_test.cc b/src/components/policy/policy_regular/test/policy_manager_impl_test.cc index c105b304fe..08a939ecda 100644 --- a/src/components/policy/policy_regular/test/policy_manager_impl_test.cc +++ b/src/components/policy/policy_regular/test/policy_manager_impl_test.cc @@ -903,8 +903,9 @@ TEST_F(PolicyManagerImplTest2, NextRetryTimeout_ExpectTimeoutsFromPT) { date_time::MILLISECONDS_IN_SECOND; const uint32_t first_retry = timeout_after_x_seconds; EXPECT_EQ(first_retry, manager->NextRetryTimeout()); - uint32_t next_retry = first_retry + seconds_between_retries[0].asInt() * - date_time::MILLISECONDS_IN_SECOND; + uint32_t next_retry = + first_retry + + seconds_between_retries[0].asInt() * date_time::MILLISECONDS_IN_SECOND; EXPECT_EQ(next_retry, manager->NextRetryTimeout()); next_retry = first_retry + next_retry + @@ -947,8 +948,9 @@ TEST_F(PolicyManagerImplTest2, UpdatedPreloadedPT_ExpectLPT_IsUpdated) { Json::Value val2(Json::arrayValue); val2[0] = hmi_level[index]; val[new_data.new_field_value_]["hmi_levels"] = val2; - root["policy_table"]["functional_groupings"][new_data.new_field_name_] - ["rpcs"] = val; + root["policy_table"]["functional_groupings"][new_data + .new_field_name_]["rpcs"] = + val; root["policy_table"]["functional_groupings"][new_data.new_field_name_] ["user_consent_prompt"] = new_data.new_field_name_; } diff --git a/src/components/protocol_handler/test/include/protocol_handler/mock_telemetry_observer.h b/src/components/protocol_handler/test/include/protocol_handler/mock_telemetry_observer.h index d46b8470a3..3296d716fa 100644 --- a/src/components/protocol_handler/test/include/protocol_handler/mock_telemetry_observer.h +++ b/src/components/protocol_handler/test/include/protocol_handler/mock_telemetry_observer.h @@ -43,7 +43,8 @@ namespace protocol_handler_test { class MockPHTelemetryObserver : public ::protocol_handler::PHTelemetryObserver { public: - MOCK_METHOD2(StartMessageProcess, void(uint32_t, const date_time::TimeDuration&)); + MOCK_METHOD2(StartMessageProcess, + void(uint32_t, const date_time::TimeDuration&)); MOCK_METHOD2(EndMessageProcess, void(utils::SharedPtr)); }; diff --git a/src/components/security_manager/src/crypto_manager_impl.cc b/src/components/security_manager/src/crypto_manager_impl.cc index 1506382bce..84f7773e9b 100644 --- a/src/components/security_manager/src/crypto_manager_impl.cc +++ b/src/components/security_manager/src/crypto_manager_impl.cc @@ -354,8 +354,8 @@ bool CryptoManagerImpl::IsCertificateUpdateRequired( return true; } - return seconds <= (get_settings().update_before_hours() * - date_time::SECONDS_IN_HOUR); + return seconds <= + (get_settings().update_before_hours() * date_time::SECONDS_IN_HOUR); } const CryptoManagerSettings& CryptoManagerImpl::get_settings() const { diff --git a/src/components/telemetry_monitor/include/telemetry_monitor/transport_manager_observer.h b/src/components/telemetry_monitor/include/telemetry_monitor/transport_manager_observer.h index d0f1b2b96a..d0bf4ba5bb 100644 --- a/src/components/telemetry_monitor/include/telemetry_monitor/transport_manager_observer.h +++ b/src/components/telemetry_monitor/include/telemetry_monitor/transport_manager_observer.h @@ -49,7 +49,8 @@ class TransportManagerObserver : public transport_manager::TMTelemetryObserver { private: TelemetryMonitor* telemetry_monitor_; - std::map time_starts; + std::map + time_starts; }; } // namespace telemetry_monitor #endif // SRC_COMPONENTS_TELEMETRY_MONITOR_INCLUDE_TELEMETRY_MONITOR_TRANSPORT_MANAGER_OBSERVER_H_ diff --git a/src/components/telemetry_monitor/src/application_manager_metric_wrapper.cc b/src/components/telemetry_monitor/src/application_manager_metric_wrapper.cc index 0b95792f0f..2dabc210f7 100644 --- a/src/components/telemetry_monitor/src/application_manager_metric_wrapper.cc +++ b/src/components/telemetry_monitor/src/application_manager_metric_wrapper.cc @@ -42,8 +42,7 @@ Json::Value ApplicationManagerMetricWrapper::GetJsonMetric() { result[strings::logger] = "ApplicationManager"; result[strings::begin] = Json::Int64(date_time::getuSecs(message_metric->begin)); - result[strings::end] = - Json::Int64(date_time::getuSecs(message_metric->end)); + result[strings::end] = Json::Int64(date_time::getuSecs(message_metric->end)); const NsSmartDeviceLink::NsSmartObjects::SmartObject& params = message_metric->message->getElement(application_manager::strings::params); result[strings::correlation_id] = utils::ConvertInt64ToLongLongInt( diff --git a/src/components/telemetry_monitor/src/protocol_handler_metric_wrapper.cc b/src/components/telemetry_monitor/src/protocol_handler_metric_wrapper.cc index 471b0dfdad..1591e00af8 100644 --- a/src/components/telemetry_monitor/src/protocol_handler_metric_wrapper.cc +++ b/src/components/telemetry_monitor/src/protocol_handler_metric_wrapper.cc @@ -41,8 +41,7 @@ Json::Value ProtocolHandlerMecticWrapper::GetJsonMetric() { result[strings::logger] = "ProtocolHandler"; result[strings::begin] = Json::Int64(date_time::getuSecs(message_metric->begin)); - result[strings::end] = - Json::Int64(date_time::getuSecs(message_metric->end)); + result[strings::end] = Json::Int64(date_time::getuSecs(message_metric->end)); result[strings::message_id] = message_metric->message_id; result[strings::connection_key] = message_metric->connection_key; return result; diff --git a/src/components/telemetry_monitor/src/transport_manager_metric_wrapper.cc b/src/components/telemetry_monitor/src/transport_manager_metric_wrapper.cc index 47636ed499..789da92eaf 100644 --- a/src/components/telemetry_monitor/src/transport_manager_metric_wrapper.cc +++ b/src/components/telemetry_monitor/src/transport_manager_metric_wrapper.cc @@ -42,8 +42,7 @@ Json::Value TransportManagerMecticWrapper::GetJsonMetric() { result[strings::logger] = "TransportManager"; result[strings::begin] = Json::Int64(date_time::getuSecs(message_metric->begin)); - result[strings::end] = - Json::Int64(date_time::getuSecs(message_metric->end)); + result[strings::end] = Json::Int64(date_time::getuSecs(message_metric->end)); result[strings::data_size] = static_cast(message_metric->data_size); return result; } diff --git a/src/components/telemetry_monitor/src/transport_manager_observer.cc b/src/components/telemetry_monitor/src/transport_manager_observer.cc index c761b34210..b217ba5c53 100644 --- a/src/components/telemetry_monitor/src/transport_manager_observer.cc +++ b/src/components/telemetry_monitor/src/transport_manager_observer.cc @@ -49,8 +49,8 @@ void TransportManagerObserver::StartRawMsg( void TransportManagerObserver::StopRawMsg( const protocol_handler::RawMessage* ptr) { - std::map::const_iterator - it; + std::map::const_iterator it; it = time_starts.find(ptr); if (it != time_starts.end()) { TransportManagerMecticWrapper* m = new TransportManagerMecticWrapper(); diff --git a/src/components/telemetry_monitor/test/transport_manager_metric_test.cc b/src/components/telemetry_monitor/test/transport_manager_metric_test.cc index 184a1ef9ec..ca4bc2af6e 100644 --- a/src/components/telemetry_monitor/test/transport_manager_metric_test.cc +++ b/src/components/telemetry_monitor/test/transport_manager_metric_test.cc @@ -65,10 +65,8 @@ TEST(TransportManagerMetricWrapper, GetJsonMetric) { EXPECT_EQ("null\n", jvalue[strings::utime].toStyledString()); EXPECT_EQ("null\n", jvalue[strings::memory].toStyledString()); - EXPECT_EQ(date_time::getuSecs(start_time), - jvalue[strings::begin].asInt64()); - EXPECT_EQ(date_time::getuSecs(end_time), - jvalue[strings::end].asInt64()); + EXPECT_EQ(date_time::getuSecs(start_time), jvalue[strings::begin].asInt64()); + EXPECT_EQ(date_time::getuSecs(end_time), jvalue[strings::end].asInt64()); EXPECT_EQ(1000, jvalue[strings::data_size].asInt()); } @@ -90,10 +88,8 @@ TEST(TransportManagerMetricWrapper, GetJsonMetricWithGrabResources) { Json::Value jvalue = metric_test.GetJsonMetric(); EXPECT_EQ("\"TransportManager\"\n", jvalue[strings::logger].toStyledString()); - EXPECT_EQ(date_time::getuSecs(start_time), - jvalue[strings::begin].asInt64()); - EXPECT_EQ(date_time::getuSecs(end_time), - jvalue[strings::end].asInt64()); + EXPECT_EQ(date_time::getuSecs(start_time), jvalue[strings::begin].asInt64()); + EXPECT_EQ(date_time::getuSecs(end_time), jvalue[strings::end].asInt64()); EXPECT_EQ(1000, jvalue[strings::data_size].asInt()); EXPECT_NEAR(resources->stime, jvalue[strings::stime].asInt(), 1); diff --git a/src/components/utils/test/date_time_test.cc b/src/components/utils/test/date_time_test.cc index 34d3b0f959..00085813aa 100644 --- a/src/components/utils/test/date_time_test.cc +++ b/src/components/utils/test/date_time_test.cc @@ -78,9 +78,8 @@ TEST(DateTimeTest, GetmSecs) { TEST(DateTimeTest, GetuSecs) { // arrange date_time::TimeDuration time1 = bpt::seconds(3) + bpt::microseconds(4); - int expect_value = 3 * MILLISECONDS_IN_SECOND * - MICROSECONDS_IN_MILLISECOND + - 4; + int expect_value = + 3 * MILLISECONDS_IN_SECOND * MICROSECONDS_IN_MILLISECOND + 4; // assert ASSERT_EQ(expect_value, getuSecs(time1)); @@ -90,8 +89,7 @@ TEST(DateTimeTest, GetuSecsmSecs) { // arrange date_time::TimeDuration time1 = bpt::seconds(5) + bpt::microseconds(6); - int64_t expect_value = - getuSecs(time1) / MICROSECONDS_IN_MILLISECOND; + int64_t expect_value = getuSecs(time1) / MICROSECONDS_IN_MILLISECOND; // assert ASSERT_EQ(expect_value, getmSecs(time1)); @@ -119,15 +117,13 @@ TEST(DateTimeTest, CalculateTimeDiff) { date_time::TimeDuration diff1 = bpt::seconds(1) + bpt::milliseconds(2); // assert - ASSERT_EQ(diff1.total_milliseconds(), - calculateTimeDiff(time2, time1)); + ASSERT_EQ(diff1.total_milliseconds(), calculateTimeDiff(time2, time1)); // time1 to time2, but calculateTimeDiff returns an absolute value date_time::TimeDuration diff2 = -diff1.invert_sign(); // assert - ASSERT_EQ(diff2.total_milliseconds(), - calculateTimeDiff(time1, time2)); + ASSERT_EQ(diff2.total_milliseconds(), calculateTimeDiff(time1, time2)); } TEST(DateTimeTest, CalculateEqualTimeDiff) { -- cgit v1.2.1 From 5a9bd10daf8fd3c28d82a4fe473a3547a279c616 Mon Sep 17 00:00:00 2001 From: Takamitsu Yoshii Date: Thu, 28 Jun 2018 17:28:19 +0900 Subject: set unregister reason when stopping application manager --- src/components/application_manager/src/application_manager_impl.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/components/application_manager/src/application_manager_impl.cc b/src/components/application_manager/src/application_manager_impl.cc index d42d1aa76d..cb890e389d 100644 --- a/src/components/application_manager/src/application_manager_impl.cc +++ b/src/components/application_manager/src/application_manager_impl.cc @@ -2272,6 +2272,8 @@ bool ApplicationManagerImpl::Stop() { stopping_application_mng_lock_.Release(); application_list_update_timer_.Stop(); try { + SetUnregisterAllApplicationsReason( + mobile_api::AppInterfaceUnregisteredReason::IGNITION_OFF); UnregisterAllApplications(); } catch (...) { LOG4CXX_ERROR(logger_, -- cgit v1.2.1 From d9aa78b45b9c2456176d9023e0128944ac71b6cc Mon Sep 17 00:00:00 2001 From: Conlain Kelly Date: Thu, 28 Jun 2018 15:03:40 -0400 Subject: Add full app id parameter, need to use it still --- src/appMain/smartDeviceLink.ini | 2 ++ .../application_manager/application_manager_impl.h | 6 +++- .../application_manager/smart_object_keys.h | 1 + .../mobile/register_app_interface_request.cc | 40 ++++++++++++++++------ .../mobile/register_app_interface_request_test.cc | 4 +++ .../src/application_manager_impl.cc | 16 +++++++++ .../application_manager/src/smart_object_keys.cc | 1 + .../include/config_profile/profile.h | 7 ++++ src/components/config_profile/src/profile.cc | 15 ++++++++ .../application_manager/application_manager.h | 3 ++ .../application_manager_settings.h | 1 + .../application_manager/mock_application_manager.h | 4 +++ .../mock_application_manager_settings.h | 1 + src/components/interfaces/MOBILE_API.xml | 3 ++ 14 files changed, 92 insertions(+), 12 deletions(-) diff --git a/src/appMain/smartDeviceLink.ini b/src/appMain/smartDeviceLink.ini index aa15b7c5fe..5b9432ecc9 100644 --- a/src/appMain/smartDeviceLink.ini +++ b/src/appMain/smartDeviceLink.ini @@ -186,6 +186,8 @@ PathToSnapshot = sdl_snapshot.json AttemptsToOpenPolicyDB = 5 ; Timeout between attempts during opening DB in milliseconds OpenAttemptTimeoutMs = 500 +; Whether to use the fullAppID over the short-form appID in policy lookups +UseFullAppID = false [TransportManager] ; Listening port form incoming TCP mobile connection 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 7433a5560f..4901b625a0 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 @@ -1106,6 +1106,8 @@ class ApplicationManagerImpl StateController& state_controller() OVERRIDE; const ApplicationManagerSettings& get_settings() const OVERRIDE; + std::string GetCorrectMobileIDFromMessage( + const commands::MessageSharedPtr& message) const OVERRIDE; virtual event_engine::EventDispatcher& event_dispatcher() OVERRIDE; app_launch::AppLaunchCtrl& app_launch_ctrl() OVERRIDE; @@ -1412,7 +1414,9 @@ class ApplicationManagerImpl */ static std::vector ConvertRejectedParamList( const std::vector& input); - + + std::string GetCorrectMobileIDFromMessage( + const commands::MessageSharedPtr& message); private: const ApplicationManagerSettings& settings_; /** 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 50d70591c9..b5ef51c8b0 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 @@ -54,6 +54,7 @@ extern const char* msg_params; extern const char* method_name; extern const char* info; extern const char* app_id; +extern const char* full_app_id; extern const char* bundle_id; extern const char* app_info; extern const char* app_launch; diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/register_app_interface_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/register_app_interface_request.cc index ea353c8d90..f083195fa3 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/register_app_interface_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/register_app_interface_request.cc @@ -229,8 +229,6 @@ void RegisterAppInterfaceRequest::Run() { return; } - const std::string mobile_app_id = - (*message_)[strings::msg_params][strings::app_id].asString(); ApplicationSharedPtr application = application_manager_.application(connection_key()); @@ -239,17 +237,27 @@ void RegisterAppInterfaceRequest::Run() { SendResponse(false, mobile_apis::Result::APPLICATION_REGISTERED_ALREADY); return; } + const std::string policy_app_id = application_manager_.GetCorrectMobileIDFromMessage(message_); const smart_objects::SmartObject& msg_params = (*message_)[strings::msg_params]; - const std::string policy_app_id = msg_params[strings::app_id].asString(); - std::string new_policy_app_id = policy_app_id; - std::transform(policy_app_id.begin(), - policy_app_id.end(), - new_policy_app_id.begin(), + const std::string app_id_short = msg_params[strings::app_id].asString(); + const std::string app_id_full = msg_params[strings::full_app_id].asString(); + printf("policy_app_id is %s, use_full is %d, short is %s, long is %s\n", policy_app_id.c_str(), application_manager_.get_settings().use_full_app_id(), app_id_short.c_str(), app_id_full.c_str()); + // transform the given ids to lower case for later use I guess? + std::string new_app_id_short = app_id_short; + std::string new_app_id_full = app_id_full; + std::transform(app_id_short.begin(), + app_id_short.end(), + new_app_id_short.begin(), + ::tolower); + std::transform(app_id_full.begin(), + app_id_full.end(), + new_app_id_full.begin(), ::tolower); - (*message_)[strings::msg_params][strings::app_id] = new_policy_app_id; + (*message_)[strings::msg_params][strings::app_id] = new_app_id_short; + (*message_)[strings::msg_params][strings::full_app_id] = new_app_id_full; if (application_manager_.IsApplicationForbidden(connection_key(), policy_app_id)) { @@ -1041,7 +1049,7 @@ mobile_apis::Result::eType RegisterAppInterfaceRequest::CheckWithPolicyData() { policy::StringArray app_hmi_types; const std::string mobile_app_id = - message[strings::msg_params][strings::app_id].asString(); + application_manager_.GetCorrectMobileIDFromMessage(message_); const bool init_result = GetPolicyHandler().GetInitialAppData( mobile_app_id, &app_nicknames, &app_hmi_types); @@ -1145,8 +1153,8 @@ void RegisterAppInterfaceRequest::FillDeviceInfo( bool RegisterAppInterfaceRequest::IsApplicationWithSameAppIdRegistered() { LOG4CXX_AUTO_TRACE(logger_); - const custom_string::CustomString mobile_app_id = - (*message_)[strings::msg_params][strings::app_id].asCustomString(); + const custom_string::CustomString mobile_app_id( + application_manager_.GetCorrectMobileIDFromMessage(message_)); const ApplicationSet& applications = application_manager_.applications().GetData(); @@ -1287,6 +1295,16 @@ bool RegisterAppInterfaceRequest::IsWhiteSpaceExist() { return true; } } + + if (application_manager_.get_settings().use_full_app_id()) { + if ((*message_)[strings::msg_params].keyExists(strings::full_app_id)) { + str = (*message_)[strings::msg_params][strings::full_app_id].asCharArray(); + if (!CheckSyntax(str)) { + LOG4CXX_ERROR(logger_, "Invalid app_id syntax check failed"); + return true; + } + } + } return false; } 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 8b21ceff17..a5c739b5e0 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 @@ -82,6 +82,7 @@ const mobile_apis::Language::eType kMobileLanguage = mobile_apis::Language::EN_US; const std::string kMacAddress = "test_mac_address"; const std::string kAppId = "test_app_id"; +const std::string kFullAppId = "test_app_id_long"; const std::string kDummyString = "test_string"; const std::vector kDummyDiagModes; } // namespace @@ -112,6 +113,7 @@ class RegisterAppInterfaceRequestTest void InitBasicMessage() { (*msg_)[am::strings::params][am::strings::connection_key] = kConnectionKey; (*msg_)[am::strings::msg_params][am::strings::app_id] = kAppId; + (*msg_)[am::strings::msg_params][am::strings::full_app_id] = kFullAppId; (*msg_)[am::strings::msg_params][am::strings::app_name] = app_name_; (*msg_)[am::strings::msg_params][am::strings::language_desired] = kHmiLanguage; @@ -143,6 +145,8 @@ class RegisterAppInterfaceRequestTest } void InitGetters() { + ON_CALL(app_mngr_, GetCorrectMobileIDFromMessage(msg_)) + .WillByDefault(Return(kAppId)); ON_CALL(app_mngr_, IsHMICooperating()).WillByDefault(Return(true)); ON_CALL(app_mngr_, resume_controller()) .WillByDefault(ReturnRef(mock_resume_crt_)); diff --git a/src/components/application_manager/src/application_manager_impl.cc b/src/components/application_manager/src/application_manager_impl.cc index 35deddfc8d..662adffd6c 100644 --- a/src/components/application_manager/src/application_manager_impl.cc +++ b/src/components/application_manager/src/application_manager_impl.cc @@ -504,6 +504,7 @@ ApplicationSharedPtr ApplicationManagerImpl::RegisterApplication( LOG4CXX_DEBUG(logger_, "Device mac for id" << device_id << " is " << device_mac); } + printf("device id is %lu, app id is %u, policy_app_id is %s, \n", device_id, app_id, policy_app_id.c_str()); LOG4CXX_DEBUG(logger_, "Restarting application list update timer"); GetPolicyHandler().OnAppsSearchStarted(); @@ -962,6 +963,21 @@ const ApplicationManagerSettings& ApplicationManagerImpl::get_settings() const { return settings_; } +// Extract the app ID to use internally based on the UseFullAppID .ini setting +std::string ApplicationManagerImpl::GetCorrectMobileIDFromMessage( + const commands::MessageSharedPtr& message) const { + const std::string app_id_short = + (*message)[strings::msg_params][strings::app_id].asString(); + const std::string app_id_full = + (*message)[strings::msg_params][strings::full_app_id].asString(); + + printf("getting correct id, short is %s, long is %s\n",app_id_short.c_str(), app_id_full.c_str() ); + // Get the correct policy id + const std::string chosen_app_id = + get_settings().use_full_app_id() ? app_id_full : app_id_short; + return chosen_app_id; +} + void application_manager::ApplicationManagerImpl::MarkAppsGreyOut( const connection_handler::DeviceHandle handle, bool is_greyed_out) { sync_primitives::AutoLock lock(apps_to_register_list_lock_ptr_); diff --git a/src/components/application_manager/src/smart_object_keys.cc b/src/components/application_manager/src/smart_object_keys.cc index e4e89c6e1f..0aa20dd014 100644 --- a/src/components/application_manager/src/smart_object_keys.cc +++ b/src/components/application_manager/src/smart_object_keys.cc @@ -18,6 +18,7 @@ const char* msg_params = "msg_params"; const char* method_name = "methodName"; const char* info = "info"; const char* app_id = "appID"; +const char* full_app_id = "fullAppID"; const char* bundle_id = "appBundleID"; const char* app_info = "appInfo"; const char* app_launch = "app_launch"; diff --git a/src/components/config_profile/include/config_profile/profile.h b/src/components/config_profile/include/config_profile/profile.h index 61dddf55b0..282ff9ba91 100644 --- a/src/components/config_profile/include/config_profile/profile.h +++ b/src/components/config_profile/include/config_profile/profile.h @@ -367,6 +367,12 @@ class Profile : public protocol_handler::ProtocolHandlerSettings, * @return Flag */ bool enable_policy() const; + + /** + * @brief Should core use fullAppID internally instead of appID (Default true) + * @return Flag + */ + bool use_full_app_id() const; // TransportManageSettings interface @@ -854,6 +860,7 @@ class Profile : public protocol_handler::ProtocolHandlerSettings, std::string preloaded_pt_file_; std::string policy_snapshot_file_name_; bool enable_policy_; + bool use_full_app_id_; uint32_t transport_manager_disconnect_timeout_; bool use_last_state_; std::vector supported_diag_modes_; diff --git a/src/components/config_profile/src/profile.cc b/src/components/config_profile/src/profile.cc index 4137476d63..769b1d6d2c 100644 --- a/src/components/config_profile/src/profile.cc +++ b/src/components/config_profile/src/profile.cc @@ -176,6 +176,7 @@ const char* kTTSDelimiterKey = "TTSDelimiter"; const char* kRecordingFileNameKey = "RecordingFileName"; const char* kRecordingFileSourceKey = "RecordingFileSource"; const char* kEnablePolicy = "EnablePolicy"; +const char* kUseFullAppID = "UseFullAppID"; const char* kEventMQKey = "EventMQ"; const char* kAckMQKey = "AckMQ"; const char* kApplicationListUpdateTimeoutKey = "ApplicationListUpdateTimeout"; @@ -370,6 +371,7 @@ Profile::Profile() , max_supported_protocol_version_(kDefaultMaxSupportedProtocolVersion) , policy_snapshot_file_name_(kDefaultPoliciesSnapshotFileName) , enable_policy_(false) + , use_full_app_id_(true) , transport_manager_disconnect_timeout_( kDefaultTransportManagerDisconnectTimeout) , use_last_state_(false) @@ -659,6 +661,10 @@ bool Profile::enable_policy() const { return enable_policy_; } +bool Profile::use_full_app_id() const { + return use_full_app_id_; +} + uint32_t Profile::transport_manager_disconnect_timeout() const { return transport_manager_disconnect_timeout_; } @@ -1700,6 +1706,15 @@ void Profile::UpdateValues() { } else { enable_policy_ = false; } + + // Use full app ID internally? + std::string use_full_id_string; + if (ReadValue(&use_full_id_string, kPolicySection, kUseFullAppID) && + 0 == strcmp("true", use_full_id_string.c_str())) { + use_full_app_id_ = true; + } else { + use_full_app_id_ = false; + } // Max protocol version ReadUIntValue(&max_supported_protocol_version_, diff --git a/src/components/include/application_manager/application_manager.h b/src/components/include/application_manager/application_manager.h index 0888e1fc90..a883a35c8e 100644 --- a/src/components/include/application_manager/application_manager.h +++ b/src/components/include/application_manager/application_manager.h @@ -728,6 +728,9 @@ class ApplicationManager { std::vector& rejected_params) = 0; virtual const ApplicationManagerSettings& get_settings() const = 0; + // Extract the app ID to use internally based on the UseFullAppID .ini setting + virtual std::string GetCorrectMobileIDFromMessage( + const commands::MessageSharedPtr& message) const = 0; virtual event_engine::EventDispatcher& event_dispatcher() = 0; diff --git a/src/components/include/application_manager/application_manager_settings.h b/src/components/include/application_manager/application_manager_settings.h index e745a831c6..d4cc6a7447 100644 --- a/src/components/include/application_manager/application_manager_settings.h +++ b/src/components/include/application_manager/application_manager_settings.h @@ -80,6 +80,7 @@ class ApplicationManagerSettings : public RequestControlerSettings, virtual const std::string& video_stream_file() const = 0; virtual const std::string& audio_stream_file() const = 0; + virtual bool use_full_app_id() const = 0; virtual bool use_db_for_resumption() const = 0; virtual const uint32_t& app_resumption_save_persistent_data_timeout() const = 0; 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 09957dbde0..3f0cc028ed 100644 --- a/src/components/include/test/application_manager/mock_application_manager.h +++ b/src/components/include/test/application_manager/mock_application_manager.h @@ -267,6 +267,10 @@ class MockApplicationManager : public application_manager::ApplicationManager { MOCK_METHOD1(ForbidStreaming, void(uint32_t app_id)); MOCK_CONST_METHOD0(get_settings, const application_manager::ApplicationManagerSettings&()); + MOCK_CONST_METHOD1( + GetCorrectMobileIDFromMessage, + std::string( + const application_manager::commands::MessageSharedPtr& message)); MOCK_METHOD0(event_dispatcher, application_manager::event_engine::EventDispatcher&()); 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 25cf994566..bdf0feafa5 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 @@ -87,6 +87,7 @@ class MockApplicationManagerSettings MOCK_CONST_METHOD0(named_audio_pipe_path, const std::string&()); MOCK_CONST_METHOD0(video_stream_file, const std::string&()); MOCK_CONST_METHOD0(audio_stream_file, const std::string&()); + MOCK_CONST_METHOD0(use_full_app_id, bool()); MOCK_CONST_METHOD0(use_db_for_resumption, bool()); MOCK_CONST_METHOD0(app_resumption_save_persistent_data_timeout, const uint32_t&()); diff --git a/src/components/interfaces/MOBILE_API.xml b/src/components/interfaces/MOBILE_API.xml index 310bbc34f4..8b2a56b853 100644 --- a/src/components/interfaces/MOBILE_API.xml +++ b/src/components/interfaces/MOBILE_API.xml @@ -3089,6 +3089,9 @@ ID used to validate app with policy table entries + + ID used to validate app with policy table entries + See AppInfo. -- cgit v1.2.1 From 4ad94bd52327b2e6c0d5c21801a0c357b69ebc50 Mon Sep 17 00:00:00 2001 From: Conlain Kelly Date: Thu, 28 Jun 2018 17:26:02 -0400 Subject: A little cleanup, use correct app id throughout --- .../include/application_manager/application_manager_impl.h | 3 --- .../src/commands/mobile/register_app_interface_request.cc | 5 +---- .../application_manager/src/application_manager_impl.cc | 8 ++++---- 3 files changed, 5 insertions(+), 11 deletions(-) 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 4901b625a0..c4ec3ee5bc 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 @@ -1414,9 +1414,6 @@ class ApplicationManagerImpl */ static std::vector ConvertRejectedParamList( const std::vector& input); - - std::string GetCorrectMobileIDFromMessage( - const commands::MessageSharedPtr& message); private: const ApplicationManagerSettings& settings_; /** diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/register_app_interface_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/register_app_interface_request.cc index f083195fa3..eb9e68df35 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/register_app_interface_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/register_app_interface_request.cc @@ -244,7 +244,6 @@ void RegisterAppInterfaceRequest::Run() { const std::string app_id_short = msg_params[strings::app_id].asString(); const std::string app_id_full = msg_params[strings::full_app_id].asString(); - printf("policy_app_id is %s, use_full is %d, short is %s, long is %s\n", policy_app_id.c_str(), application_manager_.get_settings().use_full_app_id(), app_id_short.c_str(), app_id_full.c_str()); // transform the given ids to lower case for later use I guess? std::string new_app_id_short = app_id_short; std::string new_app_id_full = app_id_full; @@ -1338,10 +1337,8 @@ void RegisterAppInterfaceRequest::SendSubscribeCustomButtonNotification() { } bool RegisterAppInterfaceRequest::IsApplicationSwitched() { - const smart_objects::SmartObject& msg_params = - (*message_)[strings::msg_params]; - const std::string& policy_app_id = msg_params[strings::app_id].asString(); + const std::string& policy_app_id = application_manager_.GetCorrectMobileIDFromMessage(message_); LOG4CXX_DEBUG(logger_, "Looking for application id " << policy_app_id); diff --git a/src/components/application_manager/src/application_manager_impl.cc b/src/components/application_manager/src/application_manager_impl.cc index 662adffd6c..9bf912aa09 100644 --- a/src/components/application_manager/src/application_manager_impl.cc +++ b/src/components/application_manager/src/application_manager_impl.cc @@ -492,7 +492,7 @@ ApplicationSharedPtr ApplicationManagerImpl::RegisterApplication( } smart_objects::SmartObject& params = message[strings::msg_params]; - const std::string& policy_app_id = params[strings::app_id].asString(); + const std::string& policy_app_id = GetCorrectMobileIDFromMessage(request_for_registration); const custom_str::CustomString& app_name = message[strings::msg_params][strings::app_name].asCustomString(); std::string device_mac; @@ -966,14 +966,14 @@ const ApplicationManagerSettings& ApplicationManagerImpl::get_settings() const { // Extract the app ID to use internally based on the UseFullAppID .ini setting std::string ApplicationManagerImpl::GetCorrectMobileIDFromMessage( const commands::MessageSharedPtr& message) const { - const std::string app_id_short = + std::string app_id_short = (*message)[strings::msg_params][strings::app_id].asString(); - const std::string app_id_full = + std::string app_id_full = (*message)[strings::msg_params][strings::full_app_id].asString(); printf("getting correct id, short is %s, long is %s\n",app_id_short.c_str(), app_id_full.c_str() ); // Get the correct policy id - const std::string chosen_app_id = + std::string chosen_app_id = get_settings().use_full_app_id() ? app_id_full : app_id_short; return chosen_app_id; } -- cgit v1.2.1 From 17b5cfad35f6b579c3fbacbc7d32a202b06ff53c Mon Sep 17 00:00:00 2001 From: Conlain Kelly Date: Mon, 16 Jul 2018 14:50:03 -0400 Subject: Modify pt representation to pick up full app id support --- src/appMain/smartDeviceLink.ini | 2 +- .../src/application_manager_impl.cc | 19 +++++++++++++------ .../application_manager/test/sdl_preloaded_pt.json | 1 + .../include/policy/policy_table/types.h | 1 + .../include/policy/policy_table_interface_ext.xml | 1 + .../policy/policy_external/src/sql_pt_queries.cc | 5 +++-- ...with_invalid_default_reqestType_between_valid.json | 1 + .../preloadedPT_with_invalid_default_requestType.json | 1 + ...dPT_with_several_invalid_default_requestTypes.json | 1 + .../policy_external/test/json/sdl_preloaded_pt.json | 1 + .../include/policy/policy_table/types.h | 1 + .../policy_regular/policy_table_interface_ext.xml | 1 + .../policy/policy_regular/src/cache_manager.cc | 1 + .../policy/policy_regular/src/sql_pt_queries.cc | 5 +++-- src/components/policy/policy_regular/test/PTU.json | 1 + src/components/policy/policy_regular/test/PTU2.json | 1 + src/components/policy/policy_regular/test/PTU3.json | 1 + src/components/policy/policy_regular/test/PTU4.json | 1 + .../policy/policy_regular/test/sdl_preloaded_pt.json | 1 + src/components/utils/test/policy.sql | 5 +++-- 20 files changed, 38 insertions(+), 13 deletions(-) diff --git a/src/appMain/smartDeviceLink.ini b/src/appMain/smartDeviceLink.ini index b3c56ce04c..2eff499bf7 100644 --- a/src/appMain/smartDeviceLink.ini +++ b/src/appMain/smartDeviceLink.ini @@ -187,7 +187,7 @@ AttemptsToOpenPolicyDB = 5 ; Timeout between attempts during opening DB in milliseconds OpenAttemptTimeoutMs = 500 ; Whether to use the fullAppID over the short-form appID in policy lookups -UseFullAppID = false +UseFullAppID = true [TransportManager] ; Listening port form incoming TCP mobile connection diff --git a/src/components/application_manager/src/application_manager_impl.cc b/src/components/application_manager/src/application_manager_impl.cc index 064c58e36f..2d46b91179 100644 --- a/src/components/application_manager/src/application_manager_impl.cc +++ b/src/components/application_manager/src/application_manager_impl.cc @@ -499,7 +499,8 @@ ApplicationSharedPtr ApplicationManagerImpl::RegisterApplication( } smart_objects::SmartObject& params = message[strings::msg_params]; - const std::string& policy_app_id = GetCorrectMobileIDFromMessage(request_for_registration); + const std::string& policy_app_id = + GetCorrectMobileIDFromMessage(request_for_registration); const custom_str::CustomString& app_name = message[strings::msg_params][strings::app_name].asCustomString(); std::string device_mac; @@ -511,7 +512,10 @@ ApplicationSharedPtr ApplicationManagerImpl::RegisterApplication( LOG4CXX_DEBUG(logger_, "Device mac for id" << device_id << " is " << device_mac); } - printf("device id is %lu, app id is %u, policy_app_id is %s, \n", device_id, app_id, policy_app_id.c_str()); + printf("device id is %lu, app id is %u, policy_app_id is %s, \n", + device_id, + app_id, + policy_app_id.c_str()); LOG4CXX_DEBUG(logger_, "Restarting application list update timer"); GetPolicyHandler().OnAppsSearchStarted(); @@ -983,12 +987,15 @@ const ApplicationManagerSettings& ApplicationManagerImpl::get_settings() const { // Extract the app ID to use internally based on the UseFullAppID .ini setting std::string ApplicationManagerImpl::GetCorrectMobileIDFromMessage( const commands::MessageSharedPtr& message) const { - std::string app_id_short = + std::string app_id_short = (*message)[strings::msg_params][strings::app_id].asString(); - std::string app_id_full = + std::string app_id_full = (*message)[strings::msg_params][strings::full_app_id].asString(); - - printf("getting correct id, short is %s, long is %s\n",app_id_short.c_str(), app_id_full.c_str() ); + + printf("getting correct id, short is %s, long is %s, use full is %d\n", + app_id_short.c_str(), + app_id_full.c_str(), + get_settings().use_full_app_id()); // Get the correct policy id std::string chosen_app_id = get_settings().use_full_app_id() ? app_id_full : app_id_short; diff --git a/src/components/application_manager/test/sdl_preloaded_pt.json b/src/components/application_manager/test/sdl_preloaded_pt.json index 59e3f947c3..b45f71ce5c 100644 --- a/src/components/application_manager/test/sdl_preloaded_pt.json +++ b/src/components/application_manager/test/sdl_preloaded_pt.json @@ -2,6 +2,7 @@ "policy_table": { "module_config": { "preloaded_pt": true, + "full_app_id_supported": true, "preloaded_date": "2015-02-12", "exchange_after_x_ignition_cycles": 100, "exchange_after_x_kilometers": 1800, diff --git a/src/components/policy/policy_external/include/policy/policy_table/types.h b/src/components/policy/policy_external/include/policy/policy_table/types.h index b062fa0966..68e29a97ee 100644 --- a/src/components/policy/policy_external/include/policy/policy_table/types.h +++ b/src/components/policy/policy_external/include/policy/policy_table/types.h @@ -303,6 +303,7 @@ struct ModuleConfig : CompositeType { Optional > preloaded_date; Optional > certificate; Optional preloaded_pt; + Optional full_app_id_supported; public: ModuleConfig(); diff --git a/src/components/policy/policy_external/include/policy/policy_table_interface_ext.xml b/src/components/policy/policy_external/include/policy/policy_table_interface_ext.xml index 7979a0f2ba..7246bec800 100644 --- a/src/components/policy/policy_external/include/policy/policy_table_interface_ext.xml +++ b/src/components/policy/policy_external/include/policy/policy_table_interface_ext.xml @@ -140,6 +140,7 @@ + , 0, 255> > device_certificates; Optional preloaded_pt; + Optional full_app_id_supported; Integer exchange_after_x_ignition_cycles; Integer exchange_after_x_kilometers; Integer exchange_after_x_days; diff --git a/src/components/policy/policy_regular/policy_table_interface_ext.xml b/src/components/policy/policy_regular/policy_table_interface_ext.xml index 393a419139..a6a5b343c2 100644 --- a/src/components/policy/policy_regular/policy_table_interface_ext.xml +++ b/src/components/policy/policy_regular/policy_table_interface_ext.xml @@ -136,6 +136,7 @@ + CacheManager::GenerateSnapshot() { CACHE_MANAGER_CHECK(snapshot_); + printf("Generating snapshot!\n" ); snapshot_ = new policy_table::Table(); diff --git a/src/components/policy/policy_regular/src/sql_pt_queries.cc b/src/components/policy/policy_regular/src/sql_pt_queries.cc index 91a5573a04..2e2eacd511 100644 --- a/src/components/policy/policy_regular/src/sql_pt_queries.cc +++ b/src/components/policy/policy_regular/src/sql_pt_queries.cc @@ -63,6 +63,7 @@ const std::string kCreateSchema = "); " "CREATE TABLE IF NOT EXISTS `module_config`( " " `preloaded_pt` BOOL NOT NULL, " + " `full_app_id_supported` BOOL NOT NULL, " " `is_first_run` BOOL NOT NULL, " " `exchange_after_x_ignition_cycles` INTEGER NOT NULL, " " `exchange_after_x_kilometers` INTEGER NOT NULL, " @@ -377,10 +378,10 @@ const std::string kInsertInitData = "`ignition_cycles_since_last_exchange`," " `flag_update_required`) " " VALUES (0, 0, 0, 0); " - "INSERT OR IGNORE INTO `module_config` (`preloaded_pt`, `is_first_run`," + "INSERT OR IGNORE INTO `module_config` (`preloaded_pt`, `full_app_id_supported`, `is_first_run`," " `exchange_after_x_ignition_cycles`, `exchange_after_x_kilometers`, " " `exchange_after_x_days`, `timeout_after_x_seconds`) " - " VALUES(1, 0, 0, 0, 0, 0); " + " VALUES(1, 1, 0, 0, 0, 0, 0); " "INSERT OR IGNORE INTO `priority`(`value`) VALUES ('EMERGENCY'); " "INSERT OR IGNORE INTO `priority`(`value`) VALUES ('NAVIGATION'); " "INSERT OR IGNORE INTO `priority`(`value`) VALUES ('VOICECOMMUNICATION'); " diff --git a/src/components/policy/policy_regular/test/PTU.json b/src/components/policy/policy_regular/test/PTU.json index 2f4735dd66..83b96193ed 100644 --- a/src/components/policy/policy_regular/test/PTU.json +++ b/src/components/policy/policy_regular/test/PTU.json @@ -2,6 +2,7 @@ "policy_table": { "module_config": { "preloaded_pt": true, + "full_app_id_supported": true, "preloaded_date": "2015-12-08", "exchange_after_x_ignition_cycles": 100, "exchange_after_x_kilometers": 1800, diff --git a/src/components/policy/policy_regular/test/PTU2.json b/src/components/policy/policy_regular/test/PTU2.json index 806ab8bcc0..773b99f3fe 100644 --- a/src/components/policy/policy_regular/test/PTU2.json +++ b/src/components/policy/policy_regular/test/PTU2.json @@ -2,6 +2,7 @@ "policy_table": { "module_config": { "preloaded_pt": true, + "full_app_id_supported": true, "preloaded_date": "2015-12-08", "exchange_after_x_ignition_cycles": 100, "exchange_after_x_kilometers": 1800, diff --git a/src/components/policy/policy_regular/test/PTU3.json b/src/components/policy/policy_regular/test/PTU3.json index 28396be29a..bf54920db3 100644 --- a/src/components/policy/policy_regular/test/PTU3.json +++ b/src/components/policy/policy_regular/test/PTU3.json @@ -71,6 +71,7 @@ "policy_table": { "module_config": { "preloaded_pt": true, + "full_app_id_supported": true, "preloaded_date": "2015-12-08", "exchange_after_x_ignition_cycles": 100, "exchange_after_x_kilometers": 1800, diff --git a/src/components/policy/policy_regular/test/PTU4.json b/src/components/policy/policy_regular/test/PTU4.json index 4592e228df..c504c3da08 100644 --- a/src/components/policy/policy_regular/test/PTU4.json +++ b/src/components/policy/policy_regular/test/PTU4.json @@ -2,6 +2,7 @@ "policy_table": { "module_config": { "preloaded_pt": true, + "full_app_id_supported": true, "preloaded_date": "2015-12-08", "exchange_after_x_ignition_cycles": 100, "exchange_after_x_kilometers": 1800, diff --git a/src/components/policy/policy_regular/test/sdl_preloaded_pt.json b/src/components/policy/policy_regular/test/sdl_preloaded_pt.json index 59e3f947c3..b45f71ce5c 100644 --- a/src/components/policy/policy_regular/test/sdl_preloaded_pt.json +++ b/src/components/policy/policy_regular/test/sdl_preloaded_pt.json @@ -2,6 +2,7 @@ "policy_table": { "module_config": { "preloaded_pt": true, + "full_app_id_supported": true, "preloaded_date": "2015-02-12", "exchange_after_x_ignition_cycles": 100, "exchange_after_x_kilometers": 1800, diff --git a/src/components/utils/test/policy.sql b/src/components/utils/test/policy.sql index d588d695a6..acfd42644b 100644 --- a/src/components/utils/test/policy.sql +++ b/src/components/utils/test/policy.sql @@ -34,6 +34,7 @@ BEGIN TRANSACTION; VALUES (0, 0, 0, 0); CREATE TABLE IF NOT EXISTS `module_config`( `preloaded_pt` BOOL NOT NULL, + `full_app_id_supported` BOOL NOT NULL, `is_first_run` BOOL NOT NULL, `exchange_after_x_ignition_cycles` INTEGER NOT NULL, `exchange_after_x_kilometers` INTEGER NOT NULL, @@ -43,10 +44,10 @@ BEGIN TRANSACTION; `vehicle_model` VARCHAR(45), `vehicle_year` VARCHAR(4) ); - INSERT OR IGNORE INTO `module_config` (`preloaded_pt`, `is_first_run`, + INSERT OR IGNORE INTO `module_config` (`preloaded_pt`, `full_app_id_supported`, `is_first_run`, `exchange_after_x_ignition_cycles`, `exchange_after_x_kilometers`, `exchange_after_x_days`, `timeout_after_x_seconds`) - VALUES(1, 1, 0, 0, 0, 0); + VALUES(1, 1, 1, 0, 0, 0, 0); CREATE TABLE IF NOT EXISTS `functional_group`( `id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `user_consent_prompt` TEXT UNIQUE ON CONFLICT REPLACE, -- cgit v1.2.1 From 98be100535a76a5045dfeffef233a4eadb7b00ce Mon Sep 17 00:00:00 2001 From: Conlain Kelly Date: Mon, 16 Jul 2018 15:00:11 -0400 Subject: Implement correct behavior around full app id existence --- .../src/application_manager_impl.cc | 33 +++++++++++++--------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/src/components/application_manager/src/application_manager_impl.cc b/src/components/application_manager/src/application_manager_impl.cc index 2d46b91179..a5446704bb 100644 --- a/src/components/application_manager/src/application_manager_impl.cc +++ b/src/components/application_manager/src/application_manager_impl.cc @@ -987,19 +987,26 @@ const ApplicationManagerSettings& ApplicationManagerImpl::get_settings() const { // Extract the app ID to use internally based on the UseFullAppID .ini setting std::string ApplicationManagerImpl::GetCorrectMobileIDFromMessage( const commands::MessageSharedPtr& message) const { - std::string app_id_short = - (*message)[strings::msg_params][strings::app_id].asString(); - std::string app_id_full = - (*message)[strings::msg_params][strings::full_app_id].asString(); - - printf("getting correct id, short is %s, long is %s, use full is %d\n", - app_id_short.c_str(), - app_id_full.c_str(), - get_settings().use_full_app_id()); - // Get the correct policy id - std::string chosen_app_id = - get_settings().use_full_app_id() ? app_id_full : app_id_short; - return chosen_app_id; + // If we're expecting the full app id + if (get_settings().use_full_app_id()) { + // we got the full app id, use it + if ((*message)[strings::msg_params].keyExists(strings::full_app_id)) { + // temporary debug printing + std::string app_id_short = + (*message)[strings::msg_params][strings::app_id].asString(); + std::string app_id_full = + (*message)[strings::msg_params][strings::full_app_id].asString(); + + printf("getting full id, short is %s, long is %s, use full is %d\n", + app_id_short.c_str(), + app_id_full.c_str()); + return (*message)[strings::msg_params][strings::full_app_id].asString(); + } else { + LOG4CXX_DEBUG("UseFullAppID is on but only short ID given!"); + } + } + // if we're not using full or no full given, use regular appID + return (*message)[strings::msg_params][strings::app_id].asString(); } void application_manager::ApplicationManagerImpl::MarkAppsGreyOut( -- cgit v1.2.1 From 4b3c0c994d2501f70c5e1132ef6a2b262746b98e Mon Sep 17 00:00:00 2001 From: Conlain Kelly Date: Mon, 16 Jul 2018 17:28:55 -0400 Subject: Fix code errors --- src/components/application_manager/src/application_manager_impl.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/application_manager/src/application_manager_impl.cc b/src/components/application_manager/src/application_manager_impl.cc index a5446704bb..285e61885f 100644 --- a/src/components/application_manager/src/application_manager_impl.cc +++ b/src/components/application_manager/src/application_manager_impl.cc @@ -997,12 +997,12 @@ std::string ApplicationManagerImpl::GetCorrectMobileIDFromMessage( std::string app_id_full = (*message)[strings::msg_params][strings::full_app_id].asString(); - printf("getting full id, short is %s, long is %s, use full is %d\n", + printf("getting full id, short is %s, long is %s\n", app_id_short.c_str(), app_id_full.c_str()); return (*message)[strings::msg_params][strings::full_app_id].asString(); } else { - LOG4CXX_DEBUG("UseFullAppID is on but only short ID given!"); + LOG4CXX_DEBUG(logger_, "UseFullAppID is on but only short ID given!"); } } // if we're not using full or no full given, use regular appID -- cgit v1.2.1 From d1c9522bbcecd3dd117e6ca19ed95813301ff445 Mon Sep 17 00:00:00 2001 From: Conlain Kelly Date: Mon, 16 Jul 2018 17:35:27 -0400 Subject: Revert "Modify pt representation to pick up full app id support" This reverts commit 17b5cfad35f6b579c3fbacbc7d32a202b06ff53c. --- src/appMain/smartDeviceLink.ini | 2 +- src/components/application_manager/test/sdl_preloaded_pt.json | 1 - .../policy/policy_external/include/policy/policy_table/types.h | 1 - .../policy_external/include/policy/policy_table_interface_ext.xml | 1 - src/components/policy/policy_external/src/sql_pt_queries.cc | 5 ++--- .../preloadedPT_with_invalid_default_reqestType_between_valid.json | 1 - .../test/json/preloadedPT_with_invalid_default_requestType.json | 1 - .../json/preloadedPT_with_several_invalid_default_requestTypes.json | 1 - .../policy/policy_external/test/json/sdl_preloaded_pt.json | 1 - .../policy/policy_regular/include/policy/policy_table/types.h | 1 - src/components/policy/policy_regular/policy_table_interface_ext.xml | 1 - src/components/policy/policy_regular/src/cache_manager.cc | 1 - src/components/policy/policy_regular/src/sql_pt_queries.cc | 5 ++--- src/components/policy/policy_regular/test/PTU.json | 1 - src/components/policy/policy_regular/test/PTU2.json | 1 - src/components/policy/policy_regular/test/PTU3.json | 1 - src/components/policy/policy_regular/test/PTU4.json | 1 - src/components/policy/policy_regular/test/sdl_preloaded_pt.json | 1 - src/components/utils/test/policy.sql | 5 ++--- 19 files changed, 7 insertions(+), 25 deletions(-) diff --git a/src/appMain/smartDeviceLink.ini b/src/appMain/smartDeviceLink.ini index 2eff499bf7..b3c56ce04c 100644 --- a/src/appMain/smartDeviceLink.ini +++ b/src/appMain/smartDeviceLink.ini @@ -187,7 +187,7 @@ AttemptsToOpenPolicyDB = 5 ; Timeout between attempts during opening DB in milliseconds OpenAttemptTimeoutMs = 500 ; Whether to use the fullAppID over the short-form appID in policy lookups -UseFullAppID = true +UseFullAppID = false [TransportManager] ; Listening port form incoming TCP mobile connection diff --git a/src/components/application_manager/test/sdl_preloaded_pt.json b/src/components/application_manager/test/sdl_preloaded_pt.json index b45f71ce5c..59e3f947c3 100644 --- a/src/components/application_manager/test/sdl_preloaded_pt.json +++ b/src/components/application_manager/test/sdl_preloaded_pt.json @@ -2,7 +2,6 @@ "policy_table": { "module_config": { "preloaded_pt": true, - "full_app_id_supported": true, "preloaded_date": "2015-02-12", "exchange_after_x_ignition_cycles": 100, "exchange_after_x_kilometers": 1800, diff --git a/src/components/policy/policy_external/include/policy/policy_table/types.h b/src/components/policy/policy_external/include/policy/policy_table/types.h index 68e29a97ee..b062fa0966 100644 --- a/src/components/policy/policy_external/include/policy/policy_table/types.h +++ b/src/components/policy/policy_external/include/policy/policy_table/types.h @@ -303,7 +303,6 @@ struct ModuleConfig : CompositeType { Optional > preloaded_date; Optional > certificate; Optional preloaded_pt; - Optional full_app_id_supported; public: ModuleConfig(); diff --git a/src/components/policy/policy_external/include/policy/policy_table_interface_ext.xml b/src/components/policy/policy_external/include/policy/policy_table_interface_ext.xml index 7246bec800..7979a0f2ba 100644 --- a/src/components/policy/policy_external/include/policy/policy_table_interface_ext.xml +++ b/src/components/policy/policy_external/include/policy/policy_table_interface_ext.xml @@ -140,7 +140,6 @@ - , 0, 255> > device_certificates; Optional preloaded_pt; - Optional full_app_id_supported; Integer exchange_after_x_ignition_cycles; Integer exchange_after_x_kilometers; Integer exchange_after_x_days; diff --git a/src/components/policy/policy_regular/policy_table_interface_ext.xml b/src/components/policy/policy_regular/policy_table_interface_ext.xml index a6a5b343c2..393a419139 100644 --- a/src/components/policy/policy_regular/policy_table_interface_ext.xml +++ b/src/components/policy/policy_regular/policy_table_interface_ext.xml @@ -136,7 +136,6 @@ - CacheManager::GenerateSnapshot() { CACHE_MANAGER_CHECK(snapshot_); - printf("Generating snapshot!\n" ); snapshot_ = new policy_table::Table(); diff --git a/src/components/policy/policy_regular/src/sql_pt_queries.cc b/src/components/policy/policy_regular/src/sql_pt_queries.cc index 2e2eacd511..91a5573a04 100644 --- a/src/components/policy/policy_regular/src/sql_pt_queries.cc +++ b/src/components/policy/policy_regular/src/sql_pt_queries.cc @@ -63,7 +63,6 @@ const std::string kCreateSchema = "); " "CREATE TABLE IF NOT EXISTS `module_config`( " " `preloaded_pt` BOOL NOT NULL, " - " `full_app_id_supported` BOOL NOT NULL, " " `is_first_run` BOOL NOT NULL, " " `exchange_after_x_ignition_cycles` INTEGER NOT NULL, " " `exchange_after_x_kilometers` INTEGER NOT NULL, " @@ -378,10 +377,10 @@ const std::string kInsertInitData = "`ignition_cycles_since_last_exchange`," " `flag_update_required`) " " VALUES (0, 0, 0, 0); " - "INSERT OR IGNORE INTO `module_config` (`preloaded_pt`, `full_app_id_supported`, `is_first_run`," + "INSERT OR IGNORE INTO `module_config` (`preloaded_pt`, `is_first_run`," " `exchange_after_x_ignition_cycles`, `exchange_after_x_kilometers`, " " `exchange_after_x_days`, `timeout_after_x_seconds`) " - " VALUES(1, 1, 0, 0, 0, 0, 0); " + " VALUES(1, 0, 0, 0, 0, 0); " "INSERT OR IGNORE INTO `priority`(`value`) VALUES ('EMERGENCY'); " "INSERT OR IGNORE INTO `priority`(`value`) VALUES ('NAVIGATION'); " "INSERT OR IGNORE INTO `priority`(`value`) VALUES ('VOICECOMMUNICATION'); " diff --git a/src/components/policy/policy_regular/test/PTU.json b/src/components/policy/policy_regular/test/PTU.json index 83b96193ed..2f4735dd66 100644 --- a/src/components/policy/policy_regular/test/PTU.json +++ b/src/components/policy/policy_regular/test/PTU.json @@ -2,7 +2,6 @@ "policy_table": { "module_config": { "preloaded_pt": true, - "full_app_id_supported": true, "preloaded_date": "2015-12-08", "exchange_after_x_ignition_cycles": 100, "exchange_after_x_kilometers": 1800, diff --git a/src/components/policy/policy_regular/test/PTU2.json b/src/components/policy/policy_regular/test/PTU2.json index 773b99f3fe..806ab8bcc0 100644 --- a/src/components/policy/policy_regular/test/PTU2.json +++ b/src/components/policy/policy_regular/test/PTU2.json @@ -2,7 +2,6 @@ "policy_table": { "module_config": { "preloaded_pt": true, - "full_app_id_supported": true, "preloaded_date": "2015-12-08", "exchange_after_x_ignition_cycles": 100, "exchange_after_x_kilometers": 1800, diff --git a/src/components/policy/policy_regular/test/PTU3.json b/src/components/policy/policy_regular/test/PTU3.json index bf54920db3..28396be29a 100644 --- a/src/components/policy/policy_regular/test/PTU3.json +++ b/src/components/policy/policy_regular/test/PTU3.json @@ -71,7 +71,6 @@ "policy_table": { "module_config": { "preloaded_pt": true, - "full_app_id_supported": true, "preloaded_date": "2015-12-08", "exchange_after_x_ignition_cycles": 100, "exchange_after_x_kilometers": 1800, diff --git a/src/components/policy/policy_regular/test/PTU4.json b/src/components/policy/policy_regular/test/PTU4.json index c504c3da08..4592e228df 100644 --- a/src/components/policy/policy_regular/test/PTU4.json +++ b/src/components/policy/policy_regular/test/PTU4.json @@ -2,7 +2,6 @@ "policy_table": { "module_config": { "preloaded_pt": true, - "full_app_id_supported": true, "preloaded_date": "2015-12-08", "exchange_after_x_ignition_cycles": 100, "exchange_after_x_kilometers": 1800, diff --git a/src/components/policy/policy_regular/test/sdl_preloaded_pt.json b/src/components/policy/policy_regular/test/sdl_preloaded_pt.json index b45f71ce5c..59e3f947c3 100644 --- a/src/components/policy/policy_regular/test/sdl_preloaded_pt.json +++ b/src/components/policy/policy_regular/test/sdl_preloaded_pt.json @@ -2,7 +2,6 @@ "policy_table": { "module_config": { "preloaded_pt": true, - "full_app_id_supported": true, "preloaded_date": "2015-02-12", "exchange_after_x_ignition_cycles": 100, "exchange_after_x_kilometers": 1800, diff --git a/src/components/utils/test/policy.sql b/src/components/utils/test/policy.sql index acfd42644b..d588d695a6 100644 --- a/src/components/utils/test/policy.sql +++ b/src/components/utils/test/policy.sql @@ -34,7 +34,6 @@ BEGIN TRANSACTION; VALUES (0, 0, 0, 0); CREATE TABLE IF NOT EXISTS `module_config`( `preloaded_pt` BOOL NOT NULL, - `full_app_id_supported` BOOL NOT NULL, `is_first_run` BOOL NOT NULL, `exchange_after_x_ignition_cycles` INTEGER NOT NULL, `exchange_after_x_kilometers` INTEGER NOT NULL, @@ -44,10 +43,10 @@ BEGIN TRANSACTION; `vehicle_model` VARCHAR(45), `vehicle_year` VARCHAR(4) ); - INSERT OR IGNORE INTO `module_config` (`preloaded_pt`, `full_app_id_supported`, `is_first_run`, + INSERT OR IGNORE INTO `module_config` (`preloaded_pt`, `is_first_run`, `exchange_after_x_ignition_cycles`, `exchange_after_x_kilometers`, `exchange_after_x_days`, `timeout_after_x_seconds`) - VALUES(1, 1, 1, 0, 0, 0, 0); + VALUES(1, 1, 0, 0, 0, 0); CREATE TABLE IF NOT EXISTS `functional_group`( `id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `user_consent_prompt` TEXT UNIQUE ON CONFLICT REPLACE, -- cgit v1.2.1 From 33d6b97fae64339d3151b8f9d2d140545647689c Mon Sep 17 00:00:00 2001 From: Conlain Kelly Date: Tue, 17 Jul 2018 10:23:10 -0400 Subject: Add full_app_id_supported to onSystemRequest call in proprietary mode --- .../mobile/on_system_request_notification.h | 3 ++- .../mobile/on_system_request_notification.cc | 29 +++++++++++++++++++--- 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_system_request_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_system_request_notification.h index b369ad38f2..72d4dc8d80 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_system_request_notification.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_system_request_notification.h @@ -78,8 +78,9 @@ class OnSystemRequestNotification /** * @brief Adds HTTP header to message * @param message Message + * @param useFullAppID adds the full_app_id_supported field to the message if we support full app IDs */ - void AddHeader(BinaryMessage& message) const; + void AddHeader(BinaryMessage& message, bool useFullAppID) const; size_t ParsePTString(std::string& pt_string) const; #endif // PROPRIETARY_MODE diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_system_request_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_system_request_notification.cc index 419024f9b0..08dc7e24e4 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_system_request_notification.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_system_request_notification.cc @@ -118,7 +118,8 @@ void OnSystemRequestNotification::Run() { BinaryMessage binary_data; file_system::ReadBinaryFile(filename, binary_data); #if defined(PROPRIETARY_MODE) - AddHeader(binary_data); + AddHeader(binary_data, + application_manager_.get_settings().use_full_app_id()); #endif // PROPRIETARY_MODE #if defined(PROPRIETARY_MODE) || defined(EXTERNAL_PROPRIETARY_MODE) @@ -138,7 +139,9 @@ void OnSystemRequestNotification::Run() { } #ifdef PROPRIETARY_MODE -void OnSystemRequestNotification::AddHeader(BinaryMessage& message) const { +void OnSystemRequestNotification::AddHeader(BinaryMessage& message, + bool useFullAppID) const { + std::cout << "ADDING HEADER HEERE!\n"; LOG4CXX_AUTO_TRACE(logger_); const uint32_t timeout = policy_handler_.TimeoutExchangeSec(); @@ -156,6 +159,26 @@ void OnSystemRequestNotification::AddHeader(BinaryMessage& message) const { std::string policy_table_string = std::string(message.begin(), message.end()); + Json::Reader reader; + Json::Value policy_table_json; + if (!reader.parse(policy_table_string.c_str(), policy_table_json)) { + LOG4CXX_FATAL( + logger_, + "PT snapshot is corrupted: " << reader.getFormattedErrorMessages()); + } + + std::cout << "PT str is " << policy_table_string << std::endl; + + if (policy_table_json.isMember("policy_table")) { + if (policy_table_json["policy_table"].isMember("module_config")) { + std::cout << "mc is \n" << policy_table_json["policy_table"]["module_config"] << std::endl; + policy_table_json["policy_table"]["module_config"] + ["full_app_id_supported"] = useFullAppID; + std::cout << "new mc is \n" << policy_table_json["policy_table"]["module_config"] << std::endl; + + } + } + /* The Content-Length to be sent in the HTTP Request header should be calculated before additional escape characters are added to the policy table string. The mobile proxy will remove the escape @@ -226,4 +249,4 @@ size_t OnSystemRequestNotification::ParsePTString( } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin -- cgit v1.2.1 From 609d2f74e48d12a043b84cb1ebd431b842b33e02 Mon Sep 17 00:00:00 2001 From: Conlain Kelly Date: Tue, 17 Jul 2018 10:25:35 -0400 Subject: remove debug prints --- .../src/commands/mobile/on_system_request_notification.cc | 6 ------ .../application_manager/src/application_manager_impl.cc | 8 -------- 2 files changed, 14 deletions(-) diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_system_request_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_system_request_notification.cc index 08dc7e24e4..db4e258515 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_system_request_notification.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_system_request_notification.cc @@ -141,7 +141,6 @@ void OnSystemRequestNotification::Run() { #ifdef PROPRIETARY_MODE void OnSystemRequestNotification::AddHeader(BinaryMessage& message, bool useFullAppID) const { - std::cout << "ADDING HEADER HEERE!\n"; LOG4CXX_AUTO_TRACE(logger_); const uint32_t timeout = policy_handler_.TimeoutExchangeSec(); @@ -167,15 +166,10 @@ void OnSystemRequestNotification::AddHeader(BinaryMessage& message, "PT snapshot is corrupted: " << reader.getFormattedErrorMessages()); } - std::cout << "PT str is " << policy_table_string << std::endl; - if (policy_table_json.isMember("policy_table")) { if (policy_table_json["policy_table"].isMember("module_config")) { - std::cout << "mc is \n" << policy_table_json["policy_table"]["module_config"] << std::endl; policy_table_json["policy_table"]["module_config"] ["full_app_id_supported"] = useFullAppID; - std::cout << "new mc is \n" << policy_table_json["policy_table"]["module_config"] << std::endl; - } } diff --git a/src/components/application_manager/src/application_manager_impl.cc b/src/components/application_manager/src/application_manager_impl.cc index 285e61885f..39a6b59c71 100644 --- a/src/components/application_manager/src/application_manager_impl.cc +++ b/src/components/application_manager/src/application_manager_impl.cc @@ -512,10 +512,6 @@ ApplicationSharedPtr ApplicationManagerImpl::RegisterApplication( LOG4CXX_DEBUG(logger_, "Device mac for id" << device_id << " is " << device_mac); } - printf("device id is %lu, app id is %u, policy_app_id is %s, \n", - device_id, - app_id, - policy_app_id.c_str()); LOG4CXX_DEBUG(logger_, "Restarting application list update timer"); GetPolicyHandler().OnAppsSearchStarted(); @@ -996,10 +992,6 @@ std::string ApplicationManagerImpl::GetCorrectMobileIDFromMessage( (*message)[strings::msg_params][strings::app_id].asString(); std::string app_id_full = (*message)[strings::msg_params][strings::full_app_id].asString(); - - printf("getting full id, short is %s, long is %s\n", - app_id_short.c_str(), - app_id_full.c_str()); return (*message)[strings::msg_params][strings::full_app_id].asString(); } else { LOG4CXX_DEBUG(logger_, "UseFullAppID is on but only short ID given!"); -- cgit v1.2.1 From 0a4977faa3ffdf1709c2e61631b71495cf7eb373 Mon Sep 17 00:00:00 2001 From: Conlain Kelly Date: Tue, 17 Jul 2018 10:34:19 -0400 Subject: Style fix --- .../include/application_manager/application_manager_impl.h | 1 + .../commands/mobile/on_system_request_notification.h | 3 ++- .../src/commands/mobile/register_app_interface_request.cc | 13 +++++++------ .../config_profile/include/config_profile/profile.h | 2 +- src/components/config_profile/src/profile.cc | 2 +- 5 files changed, 12 insertions(+), 9 deletions(-) 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 24737a155f..30dd181858 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 @@ -1441,6 +1441,7 @@ class ApplicationManagerImpl */ static std::vector ConvertRejectedParamList( const std::vector& input); + private: const ApplicationManagerSettings& settings_; /** diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_system_request_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_system_request_notification.h index 72d4dc8d80..2d9720bb22 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_system_request_notification.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_system_request_notification.h @@ -78,7 +78,8 @@ class OnSystemRequestNotification /** * @brief Adds HTTP header to message * @param message Message - * @param useFullAppID adds the full_app_id_supported field to the message if we support full app IDs + * @param useFullAppID adds the full_app_id_supported field to the message if + * we support full app IDs */ void AddHeader(BinaryMessage& message, bool useFullAppID) const; size_t ParsePTString(std::string& pt_string) const; diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/register_app_interface_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/register_app_interface_request.cc index 53193577fb..5532eb4572 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/register_app_interface_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/register_app_interface_request.cc @@ -229,7 +229,6 @@ void RegisterAppInterfaceRequest::Run() { return; } - ApplicationSharedPtr application = application_manager_.application(connection_key()); @@ -237,7 +236,8 @@ void RegisterAppInterfaceRequest::Run() { SendResponse(false, mobile_apis::Result::APPLICATION_REGISTERED_ALREADY); return; } - const std::string policy_app_id = application_manager_.GetCorrectMobileIDFromMessage(message_); + const std::string policy_app_id = + application_manager_.GetCorrectMobileIDFromMessage(message_); const smart_objects::SmartObject& msg_params = (*message_)[strings::msg_params]; @@ -1291,10 +1291,11 @@ bool RegisterAppInterfaceRequest::IsWhiteSpaceExist() { return true; } } - + if (application_manager_.get_settings().use_full_app_id()) { if ((*message_)[strings::msg_params].keyExists(strings::full_app_id)) { - str = (*message_)[strings::msg_params][strings::full_app_id].asCharArray(); + str = + (*message_)[strings::msg_params][strings::full_app_id].asCharArray(); if (!CheckSyntax(str)) { LOG4CXX_ERROR(logger_, "Invalid app_id syntax check failed"); return true; @@ -1334,8 +1335,8 @@ void RegisterAppInterfaceRequest::SendSubscribeCustomButtonNotification() { } bool RegisterAppInterfaceRequest::IsApplicationSwitched() { - - const std::string& policy_app_id = application_manager_.GetCorrectMobileIDFromMessage(message_); + const std::string& policy_app_id = + application_manager_.GetCorrectMobileIDFromMessage(message_); LOG4CXX_DEBUG(logger_, "Looking for application id " << policy_app_id); diff --git a/src/components/config_profile/include/config_profile/profile.h b/src/components/config_profile/include/config_profile/profile.h index cada485174..4cc57e5b0a 100644 --- a/src/components/config_profile/include/config_profile/profile.h +++ b/src/components/config_profile/include/config_profile/profile.h @@ -368,7 +368,7 @@ class Profile : public protocol_handler::ProtocolHandlerSettings, * @return Flag */ bool enable_policy() const; - + /** * @brief Should core use fullAppID internally instead of appID (Default true) * @return Flag diff --git a/src/components/config_profile/src/profile.cc b/src/components/config_profile/src/profile.cc index 58dd80149e..7fa67fc34c 100644 --- a/src/components/config_profile/src/profile.cc +++ b/src/components/config_profile/src/profile.cc @@ -1834,7 +1834,7 @@ void Profile::UpdateValues() { } else { enable_policy_ = false; } - + // Use full app ID internally? std::string use_full_id_string; if (ReadValue(&use_full_id_string, kPolicySection, kUseFullAppID) && -- cgit v1.2.1 From fca52058f773e73a09ef7dc1272e609d445c5961 Mon Sep 17 00:00:00 2001 From: Conlain Kelly Date: Tue, 17 Jul 2018 11:50:01 -0400 Subject: Actually write back the correct pt snapshot --- src/appMain/smartDeviceLink.ini | 2 +- .../src/commands/mobile/on_system_request_notification.cc | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/appMain/smartDeviceLink.ini b/src/appMain/smartDeviceLink.ini index b3c56ce04c..2eff499bf7 100644 --- a/src/appMain/smartDeviceLink.ini +++ b/src/appMain/smartDeviceLink.ini @@ -187,7 +187,7 @@ AttemptsToOpenPolicyDB = 5 ; Timeout between attempts during opening DB in milliseconds OpenAttemptTimeoutMs = 500 ; Whether to use the fullAppID over the short-form appID in policy lookups -UseFullAppID = false +UseFullAppID = true [TransportManager] ; Listening port form incoming TCP mobile connection diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_system_request_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_system_request_notification.cc index db4e258515..dab05b2221 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_system_request_notification.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_system_request_notification.cc @@ -170,6 +170,11 @@ void OnSystemRequestNotification::AddHeader(BinaryMessage& message, if (policy_table_json["policy_table"].isMember("module_config")) { policy_table_json["policy_table"]["module_config"] ["full_app_id_supported"] = useFullAppID; + LOG4CXX_DEBUG(logger_, "Successfully annotated full_App_id_supported!\n"); + Json::FastWriter writer; + + // Write back modified snapshot + policy_table_string = writer.write(policy_table_json); } } -- cgit v1.2.1 From 325bf4094287e4ab3cf8bd0fee43aef3e585d218 Mon Sep 17 00:00:00 2001 From: Conlain Kelly Date: Thu, 19 Jul 2018 09:47:22 -0400 Subject: first run at making vrcommands optional --- .../include/application_manager/message_helper.h | 36 ++++++++++++++++ .../commands/mobile/perform_interaction_request.h | 14 +++++++ .../create_interaction_choice_set_request.cc | 15 +++++-- .../commands/mobile/perform_interaction_request.cc | 49 +++++++++++++++++++++- src/components/interfaces/MOBILE_API.xml | 2 +- 5 files changed, 111 insertions(+), 5 deletions(-) diff --git a/src/components/application_manager/include/application_manager/message_helper.h b/src/components/application_manager/include/application_manager/message_helper.h index 9559c2007e..3c90928d8a 100644 --- a/src/components/application_manager/include/application_manager/message_helper.h +++ b/src/components/application_manager/include/application_manager/message_helper.h @@ -50,6 +50,7 @@ #include "application_manager/policies/policy_handler_interface.h" #include "smart_objects/smart_object.h" #include "transport_manager/common.h" +#include namespace policy { class PolicyHandlerInterface; @@ -854,6 +855,41 @@ class MessageHelper { */ static smart_objects::SmartObjectSPtr CreateMessageForHMI( hmi_apis::messageType::eType message_type, const uint32_t correlation_id); + + + // Check whether each choice has the vrCommands field + // returns -1 for failure, 0 if all choice include vrCommands, and 1 if none do + // vrCommands is an all-or-none deal + static int CheckChoiceSet_VRCommands( + const smart_objects::SmartObject& choice_set) { + + // if this becomes true, someone doesn't have vrCommands + bool all_have = true; + // if this is true, no one has vrCommands + bool none_have = true; + smart_objects::SmartArray::const_iterator current_choice_set_it = choice_set.asArray()->begin(); + // Iterate through choices + for (; choice_set.asArray()->end() != current_choice_set_it; ++current_choice_set_it) { + // if the vrCommands is present + if (current_choice_set_it->keyExists(application_manager::strings::vr_commands)) { + // this one has the parameter + none_have = false; + } else { + // this one doesn't + all_have = false; + } + } + // everyone has it + if (all_have) { + return 0; + } + // No one has it + if (none_have) { + return 1; + } + // mix-and-match, this is an error + return -1; + } private: /** diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/perform_interaction_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/perform_interaction_request.h index 40e706b851..02ea6945f7 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/perform_interaction_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/perform_interaction_request.h @@ -211,6 +211,20 @@ class PerformInteractionRequest app_mngr::ApplicationSharedPtr app, const size_t choice_set_id_list_length, const smart_objects::SmartObject& choice_set_id_list) const; + + + /** + * @brief Checks each choice in each set for having a VRcommands parameter + * @param app contains pointer to application. + * @param choice_set_id_list_length contains amount + * of choice set ids. + * @param choice_set_id_list array of choice set ids + * @return returns false request has choice sets with no vrCommands + */ + bool CheckChoiceSetList_VRCommands( + app_mngr::ApplicationSharedPtr app, + const size_t choice_set_id_list_length, + const smart_objects::SmartObject& choice_set_id_list) const; /** * @brief Tells if there are sent requests without responses 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 7451ea7905..31f4deb50c 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 @@ -124,10 +124,19 @@ void CreateInteractionChoiceSetRequest::Run() { SendResponse(false, result); return; } - uint32_t grammar_id = application_manager_.GenerateGrammarID(); - (*message_)[strings::msg_params][strings::grammar_id] = grammar_id; + int vr_status = MessageHelper::CheckChoiceSet_VRCommands((*message_)[strings::msg_params][strings::choice_set]); + if (vr_status == -1) { + // this is an error + SendResponse(false, Result::INVALID_DATA, "Some choices don't contain VR commands."); + + } else if (vr_status == 0) { + // everyone had a vr command, setup the grammar + uint32_t grammar_id = application_manager_.GenerateGrammarID(); + (*message_)[strings::msg_params][strings::grammar_id] = grammar_id; + SendVRAddCommandRequests(app); + } + // continue on as usual app->AddChoiceSet(choice_set_id_, (*message_)[strings::msg_params]); - SendVRAddCommandRequests(app); } mobile_apis::Result::eType CreateInteractionChoiceSetRequest::CheckChoiceSet( 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 8710f3c3d6..bac700f89c 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 @@ -163,7 +163,18 @@ void PerformInteractionRequest::Run() { SendResponse(false, mobile_apis::Result::INVALID_ID); return; } - + if (!CheckChoiceSetList_VRCommands( + app, + choice_set_id_list_length, + msg_params[strings::interaction_choice_set_id_list])) { + LOG4CXX_ERROR(logger_, + "PerformInteraction has choice sets with " + "missing vrCommands"); + SendResponse(false, + mobile_apis::Result::INVALID_DATA, + "Some choices don't contain VR commands."); + return; + } if (msg_params.keyExists(strings::vr_help)) { if (mobile_apis::Result::SUCCESS != MessageHelper::VerifyImageVrHelpItems( @@ -942,6 +953,35 @@ bool PerformInteractionRequest::CheckChoiceIDFromResponse( return false; } + +bool PerformInteractionRequest::CheckChoiceSetList_VRCommands( + ApplicationSharedPtr app, + const size_t choice_set_id_list_length, + const smart_objects::SmartObject& choice_set_id_list) const { + LOG4CXX_AUTO_TRACE(logger_); + + smart_objects::SmartObject* choice_set = 0; + std::pair::iterator, bool> ins_res; + + for (size_t i = 0; i < choice_set_id_list_length; ++i) { + choice_set = app->FindChoiceSet(choice_set_id_list[i].asInt()); + if (!choice_set) { + LOG4CXX_ERROR( + logger_, + "Couldn't find choiceset_id = " << choice_set_id_list[i].asInt()); + return false; + } + + + int vr_status = MessageHelper::CheckChoiceSet_VRCommands(*choice_set); + // if not all choices have vr commands + if (vr_status != 0) { + return false; + } + } + return true; +} + bool PerformInteractionRequest::CheckChoiceIDFromRequest( ApplicationSharedPtr app, const size_t choice_set_id_list_length, @@ -961,6 +1001,13 @@ bool PerformInteractionRequest::CheckChoiceIDFromRequest( "Couldn't find choiset_id = " << choice_set_id_list[i].asInt()); return false; } + + + int vr_status = MessageHelper::CheckChoiceSet_VRCommands(*choice_set); + // if not all choices have vr commands + if (vr_status != 0) { + + } choice_list_length = (*choice_set)[strings::choice_set].length(); const smart_objects::SmartObject& choices_list = (*choice_set)[strings::choice_set]; diff --git a/src/components/interfaces/MOBILE_API.xml b/src/components/interfaces/MOBILE_API.xml index 2766bb48d0..de7513386d 100644 --- a/src/components/interfaces/MOBILE_API.xml +++ b/src/components/interfaces/MOBILE_API.xml @@ -950,7 +950,7 @@ A choice is an option given to the user, which can be selected either by menu, or through voice recognition system. - + Optional secondary text to display; e.g. address of POI in a search result entry -- cgit v1.2.1 From b1d49ad732781c8213b01a491074e9ab554ca126 Mon Sep 17 00:00:00 2001 From: Conlain Kelly Date: Thu, 19 Jul 2018 16:28:21 -0400 Subject: more development, needs testing and performinteraction checks --- .../create_interaction_choice_set_request.cc | 10 +++++- .../commands/mobile/perform_interaction_request.cc | 38 ++++++++++++---------- .../mobile/create_interaction_choice_set_test.cc | 6 ++-- 3 files changed, 33 insertions(+), 21 deletions(-) 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 31f4deb50c..9b365b3f13 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 @@ -124,16 +124,24 @@ void CreateInteractionChoiceSetRequest::Run() { SendResponse(false, result); return; } + std::cerr << "checking choice set\n"; int vr_status = MessageHelper::CheckChoiceSet_VRCommands((*message_)[strings::msg_params][strings::choice_set]); if (vr_status == -1) { + std::cerr << "choice set has invalid MIXED set of VR parameters" << '\n'; // this is an error SendResponse(false, Result::INVALID_DATA, "Some choices don't contain VR commands."); + return; // exit now, this is a bad set } else if (vr_status == 0) { + std::cerr << "choice set has valid FULL set of VR parameters" << '\n'; + // everyone had a vr command, setup the grammar uint32_t grammar_id = application_manager_.GenerateGrammarID(); (*message_)[strings::msg_params][strings::grammar_id] = grammar_id; SendVRAddCommandRequests(app); + } else { + std::cerr << "choice set has valid EMPTY set of VR parameters" << '\n'; + } // continue on as usual app->AddChoiceSet(choice_set_id_, (*message_)[strings::msg_params]); @@ -158,7 +166,7 @@ mobile_apis::Result::eType CreateInteractionChoiceSetRequest::CheckChoiceSet( (*current_choice_set_it)[strings::choice_id].asInt()); if (!ins_res.second) { LOG4CXX_ERROR(logger_, - "Choise with ID " + "Choice with ID " << (*current_choice_set_it)[strings::choice_id].asInt() << " already exists"); return mobile_apis::Result::INVALID_ID; 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 bac700f89c..7753c16acf 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 @@ -163,18 +163,18 @@ void PerformInteractionRequest::Run() { SendResponse(false, mobile_apis::Result::INVALID_ID); return; } - if (!CheckChoiceSetList_VRCommands( - app, - choice_set_id_list_length, - msg_params[strings::interaction_choice_set_id_list])) { - LOG4CXX_ERROR(logger_, - "PerformInteraction has choice sets with " - "missing vrCommands"); - SendResponse(false, - mobile_apis::Result::INVALID_DATA, - "Some choices don't contain VR commands."); - return; - } + // if (!CheckChoiceSetList_VRCommands( + // app, + // choice_set_id_list_length, + // msg_params[strings::interaction_choice_set_id_list])) { + // LOG4CXX_ERROR(logger_, + // "PerformInteraction has choice sets with " + // "missing vrCommands"); + // SendResponse(false, + // mobile_apis::Result::INVALID_DATA, + // "Some choices don't contain VR commands."); + // return; + // } if (msg_params.keyExists(strings::vr_help)) { if (mobile_apis::Result::SUCCESS != MessageHelper::VerifyImageVrHelpItems( @@ -965,17 +965,19 @@ bool PerformInteractionRequest::CheckChoiceSetList_VRCommands( for (size_t i = 0; i < choice_set_id_list_length; ++i) { choice_set = app->FindChoiceSet(choice_set_id_list[i].asInt()); - if (!choice_set) { - LOG4CXX_ERROR( - logger_, - "Couldn't find choiceset_id = " << choice_set_id_list[i].asInt()); - return false; - } + // this should never ever happen + // if (!choice_set) { + // LOG4CXX_ERROR( + // logger_, + // "Couldn't find choiceset_id = " << choice_set_id_list[i].asInt()); + // return false; + // } int vr_status = MessageHelper::CheckChoiceSet_VRCommands(*choice_set); // if not all choices have vr commands if (vr_status != 0) { + std::cerr << "choice set has member missing vr commands\n"; return false; } } 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 10ffbded09..d7edd303ef 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 @@ -200,8 +200,10 @@ TEST_F(CreateInteractionChoiceSetRequestTest, OnEvent_VR_UNSUPPORTED_RESOURCE) { MessageSharedPtr msg_vr = CreateFullParamsVRSO(); (*msg_vr)[strings::msg_params][strings::choice_set][0][strings::choice_id] = 10; - (*msg_vr)[strings::msg_params][strings::choice_set][0][strings::menu_name] = - "menu_name"; +(*msg_vr)[strings::msg_params][strings::choice_set][0][strings::menu_name] = + "menu_name"; +(*msg_vr)[strings::msg_params][strings::choice_set][0][strings::vr_commands][0] = + kVrCommands1; (*msg_vr)[strings::msg_params][strings::interaction_choice_set_id] = 11; utils::SharedPtr req_vr = CreateCommand(msg_vr); -- cgit v1.2.1 From d0ab2ab0bde5986051920c189085225fbff97779 Mon Sep 17 00:00:00 2001 From: AKalinich-Luxoft Date: Fri, 20 Jul 2018 17:46:11 +0300 Subject: Fixed RPC parameters permission calculation according to requirements There was a problem when application has several consented functional groups with the same RPC included. In case when some of functional groups have RPC with all parameters disallowed option, SDL ignores all allowed parameters for this RPC in other functional groups. According to AppLink Policies Manager specification SDL should perform a logical OR amongst all of the possible allowed permissions scenarios for the RPC defined by each of the functional groups. Current logic was updated to fit this requirement. --- .../policy_external/include/policy/policy_helper.h | 22 +++++++- .../policy/policy_external/src/policy_helper.cc | 66 +++++++++++++++------- 2 files changed, 65 insertions(+), 23 deletions(-) diff --git a/src/components/policy/policy_external/include/policy/policy_helper.h b/src/components/policy/policy_external/include/policy/policy_helper.h index e446c0b2e3..bdb9ba76b6 100644 --- a/src/components/policy/policy_external/include/policy/policy_helper.h +++ b/src/components/policy/policy_external/include/policy/policy_helper.h @@ -255,8 +255,26 @@ struct FillNotificationData { const std::set& target); void InitRpcKeys(const std::string& rpc_name); bool RpcParametersEmpty(RpcPermissions& rpc); - bool IsSectionEmpty(ParameterPermissions& permissions, - const std::string& section); + + /** + * @brief Checks if specific section in specified permissions is empty + * @param permissions reference to the permissions structure + * @param section reference to the section name + * @return true if specified section in permissions is empty otherwise returns + * false + */ + bool IsSectionEmpty(const ParameterPermissions& permissions, + const std::string& section) const; + + /** + * @brief Checks if at least one parameter is allowed for the specified + * permissions + * @param permissions reference to the permissions structure + * @return true if at least one parameter is allowed for the specified + * permissions otherwise returns false + */ + bool IsSomeParametersAllowed(const ParameterPermissions& permissions) const; + std::string current_key_; Permissions& data_; const bool does_require_user_consent_; diff --git a/src/components/policy/policy_external/src/policy_helper.cc b/src/components/policy/policy_external/src/policy_helper.cc index ed12cdde3a..e1a72c3f6a 100644 --- a/src/components/policy/policy_external/src/policy_helper.cc +++ b/src/components/policy/policy_external/src/policy_helper.cc @@ -620,26 +620,36 @@ void FillNotificationData::UpdateParameters( ParametersConstItr it_parameters = in_parameters.begin(); ParametersConstItr it_parameters_end = in_parameters.end(); - // Due to APPLINK-24201 SDL must consider cases when 'parameters' section is - // not present for RPC or present, but is empty. - - // If 'parameters' section is like: 'parameters' : [] - if (in_parameters.is_initialized() && in_parameters.empty()) { - if (!does_require_user_consent_) { - out_parameter.any_parameter_disallowed_by_policy = true; - } - if (does_require_user_consent_ && kAllowedKey == current_key_) { - out_parameter.any_parameter_disallowed_by_user = true; + // From AppLink Policies Manager specification: + // To determine consent for a particular RPC in a particular HMI level with + // particular parameters (if applicable), the system shall find all of the + // functional groups the RPC is included in. If user consent is needed as + // listed within the functional group in the policy table, the system shall + // use a logical AND: backend permissions AND User permissions. If the RPC is + // listed under more than one group, the system shall perform a logical OR + // amongst all of the possible allowed permissions scenarios for the RPC (and + // parameter/or HMI level) defined by each of the functional groups. + + if (!IsSomeParametersAllowed(out_parameter)) { + // Due to APPLINK-24201 SDL must consider cases when 'parameters' section is + // not present for RPC or present, but is empty. + + // If 'parameters' section is like: 'parameters' : [] + if (in_parameters.is_initialized() && in_parameters.empty()) { + if (!does_require_user_consent_) { + out_parameter.any_parameter_disallowed_by_policy = true; + } + if (does_require_user_consent_ && kAllowedKey == current_key_) { + out_parameter.any_parameter_disallowed_by_user = true; + } } - } - // If 'parameters' section is omitted - if (!in_parameters.is_initialized()) { - if (!does_require_user_consent_) { - out_parameter.any_parameter_allowed = true; - } - if (does_require_user_consent_ && kAllowedKey == current_key_) { - out_parameter.any_parameter_allowed = true; + // If 'parameters' section is omitted + if (!in_parameters.is_initialized()) { + if (!does_require_user_consent_ || + (does_require_user_consent_ && kAllowedKey == current_key_)) { + out_parameter.any_parameter_allowed = true; + } } } @@ -647,6 +657,13 @@ void FillNotificationData::UpdateParameters( out_parameter[current_key_].insert( policy_table::EnumToJsonString(*it_parameters)); } + + // We should reset ALL DISALLOWED flags if at least one parameter is allowed + // due to a logical OR permissions check + if (IsSomeParametersAllowed(out_parameter)) { + out_parameter.any_parameter_disallowed_by_policy = false; + out_parameter.any_parameter_disallowed_by_user = false; + } } void FillNotificationData::ExcludeSame(RpcPermissions& rpc) { @@ -769,16 +786,23 @@ bool FillNotificationData::RpcParametersEmpty(RpcPermissions& rpc) { no_user_disallowed_parameters; } -bool FillNotificationData::IsSectionEmpty(ParameterPermissions& permissions, - const std::string& section) { +bool FillNotificationData::IsSectionEmpty( + const ParameterPermissions& permissions, const std::string& section) const { ParameterPermissions::const_iterator it_section = permissions.find(section); ParameterPermissions::const_iterator end = permissions.end(); if (end != it_section) { - return permissions[section].empty(); + return it_section->second.empty(); } return true; } +bool FillNotificationData::IsSomeParametersAllowed( + const ParameterPermissions& permissions) const { + return permissions.any_parameter_allowed || + (kAllowedKey == current_key_ && + !IsSectionEmpty(permissions, kAllowedKey)); +} + ProcessFunctionalGroup::ProcessFunctionalGroup( const policy_table::FunctionalGroupings& fg, const std::vector& group_permissions, -- cgit v1.2.1 From 8d574d35259e34bdb698a5c26684f4e2c1515ae7 Mon Sep 17 00:00:00 2001 From: Conlain Kelly Date: Fri, 20 Jul 2018 10:47:38 -0400 Subject: Don't accidentally make a fullappid if none exists; make fullAppID mandatory --- .../mobile/register_app_interface_request.cc | 20 +++++++++++--------- src/components/interfaces/MOBILE_API.xml | 2 +- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/register_app_interface_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/register_app_interface_request.cc index 5532eb4572..a6a41ca9b6 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/register_app_interface_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/register_app_interface_request.cc @@ -242,22 +242,24 @@ void RegisterAppInterfaceRequest::Run() { const smart_objects::SmartObject& msg_params = (*message_)[strings::msg_params]; - const std::string app_id_short = msg_params[strings::app_id].asString(); - const std::string app_id_full = msg_params[strings::full_app_id].asString(); // transform the given ids to lower case for later use I guess? + const std::string app_id_short = msg_params[strings::app_id].asString(); std::string new_app_id_short = app_id_short; - std::string new_app_id_full = app_id_full; std::transform(app_id_short.begin(), app_id_short.end(), new_app_id_short.begin(), ::tolower); - std::transform(app_id_full.begin(), - app_id_full.end(), - new_app_id_full.begin(), - ::tolower); (*message_)[strings::msg_params][strings::app_id] = new_app_id_short; - (*message_)[strings::msg_params][strings::full_app_id] = new_app_id_full; - + // If full ID is present, shift that to lowercase too + if (msg_params.keyExists(strings::full_app_id)) { + const std::string app_id_full = msg_params[strings::full_app_id].asString(); + std::string new_app_id_full = app_id_full; + std::transform(app_id_full.begin(), + app_id_full.end(), + new_app_id_full.begin(), + ::tolower); + (*message_)[strings::msg_params][strings::full_app_id] = new_app_id_full; + } if (application_manager_.IsApplicationForbidden(connection_key(), policy_app_id)) { SendResponse(false, mobile_apis::Result::TOO_MANY_PENDING_REQUESTS); diff --git a/src/components/interfaces/MOBILE_API.xml b/src/components/interfaces/MOBILE_API.xml index 5662edc36b..209dda6084 100644 --- a/src/components/interfaces/MOBILE_API.xml +++ b/src/components/interfaces/MOBILE_API.xml @@ -3270,7 +3270,7 @@ ID used to validate app with policy table entries - + ID used to validate app with policy table entries -- cgit v1.2.1 From c71899ecf9d1be292646b80704a91fea97bb18d3 Mon Sep 17 00:00:00 2001 From: AKalinich-Luxoft Date: Fri, 20 Jul 2018 17:47:58 +0300 Subject: Fix affected unit tests in policy Updated expectations according to requirements --- .../test/policy_manager_impl_ptu_test.cc | 36 +++++++++++----------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/src/components/policy/policy_external/test/policy_manager_impl_ptu_test.cc b/src/components/policy/policy_external/test/policy_manager_impl_ptu_test.cc index 537e40e170..4ef6ed3e10 100644 --- a/src/components/policy/policy_external/test/policy_manager_impl_ptu_test.cc +++ b/src/components/policy/policy_external/test/policy_manager_impl_ptu_test.cc @@ -757,18 +757,18 @@ TEST_F(PolicyManagerImplTest2, policy_manager_->CheckPermissions( application_id_, kHmiLevelFull, "SendLocation", input_params, output); - EXPECT_EQ(::policy::kRpcDisallowed, output.hmi_level_permitted); - EXPECT_TRUE(output.list_of_allowed_params.empty()); - EXPECT_EQ(10u, output.list_of_undefined_params.size()); + EXPECT_EQ(::policy::kRpcAllowed, output.hmi_level_permitted); + EXPECT_TRUE(output.list_of_undefined_params.empty()); + EXPECT_EQ(10u, output.list_of_allowed_params.size()); ResetOutputList(output); // Rpc in LIMITED level policy_manager_->CheckPermissions( application_id_, kHmiLevelLimited, "SendLocation", input_params, output); - EXPECT_EQ(::policy::kRpcDisallowed, output.hmi_level_permitted); - EXPECT_TRUE(output.list_of_allowed_params.empty()); - EXPECT_EQ(10u, output.list_of_undefined_params.size()); + EXPECT_EQ(::policy::kRpcAllowed, output.hmi_level_permitted); + EXPECT_TRUE(output.list_of_undefined_params.empty()); + EXPECT_EQ(10u, output.list_of_allowed_params.size()); ResetOutputList(output); // Rpc in BACKGROUND level @@ -778,9 +778,9 @@ TEST_F(PolicyManagerImplTest2, input_params, output); - EXPECT_EQ(::policy::kRpcDisallowed, output.hmi_level_permitted); - EXPECT_TRUE(output.list_of_allowed_params.empty()); - EXPECT_EQ(10u, output.list_of_undefined_params.size()); + EXPECT_EQ(::policy::kRpcAllowed, output.hmi_level_permitted); + EXPECT_TRUE(output.list_of_undefined_params.empty()); + EXPECT_EQ(10u, output.list_of_allowed_params.size()); // Reset output ResetOutputList(output); @@ -845,17 +845,17 @@ TEST_F(PolicyManagerImplTest2, policy_manager_->CheckPermissions( application_id_, kHmiLevelFull, "SendLocation", input_params, output); - EXPECT_EQ(::policy::kRpcDisallowed, output.hmi_level_permitted); - EXPECT_TRUE(output.list_of_allowed_params.empty()); - EXPECT_EQ(10u, output.list_of_undefined_params.size()); + EXPECT_EQ(::policy::kRpcAllowed, output.hmi_level_permitted); + EXPECT_TRUE(output.list_of_undefined_params.empty()); + EXPECT_EQ(10u, output.list_of_allowed_params.size()); ResetOutputList(output); // Rpc in LIMITED level policy_manager_->CheckPermissions( application_id_, kHmiLevelLimited, "SendLocation", input_params, output); - EXPECT_EQ(::policy::kRpcDisallowed, output.hmi_level_permitted); - EXPECT_TRUE(output.list_of_allowed_params.empty()); - EXPECT_EQ(10u, output.list_of_undefined_params.size()); + EXPECT_EQ(::policy::kRpcAllowed, output.hmi_level_permitted); + EXPECT_TRUE(output.list_of_undefined_params.empty()); + EXPECT_EQ(10u, output.list_of_allowed_params.size()); ResetOutputList(output); // Rpc in BACKGROUND level @@ -864,9 +864,9 @@ TEST_F(PolicyManagerImplTest2, "SendLocation", input_params, output); - EXPECT_EQ(::policy::kRpcDisallowed, output.hmi_level_permitted); - EXPECT_TRUE(output.list_of_allowed_params.empty()); - EXPECT_EQ(10u, output.list_of_undefined_params.size()); + EXPECT_EQ(::policy::kRpcAllowed, output.hmi_level_permitted); + EXPECT_TRUE(output.list_of_undefined_params.empty()); + EXPECT_EQ(10u, output.list_of_allowed_params.size()); // Reset output ResetOutputList(output); -- cgit v1.2.1 From 3b5ddfdacb94f4e3f5752bb7165ca668f62f4a5d Mon Sep 17 00:00:00 2001 From: conlain-k Date: Fri, 20 Jul 2018 13:51:19 -0400 Subject: add new components to find_boost requirements --- src/3rd_party/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/3rd_party/CMakeLists.txt b/src/3rd_party/CMakeLists.txt index 54bfdb022b..4115fc3b8a 100644 --- a/src/3rd_party/CMakeLists.txt +++ b/src/3rd_party/CMakeLists.txt @@ -208,7 +208,7 @@ else() endif() if (HMIADAPTER STREQUAL "messagebroker") - find_package(Boost 1.66.0 COMPONENTS system) + find_package(Boost 1.66.0 COMPONENTS system thread date_time) set(BOOST_LIB_SOURCE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/boost_src) set(BOOST_LIBS_DIRECTORY ${3RD_PARTY_INSTALL_PREFIX}/lib) SET_PROPERTY(GLOBAL PROPERTY GLOBAL_BOOST_LIBS ${BOOST_LIBS_DIRECTORY}) -- cgit v1.2.1 From 750dad21868304cbe06b2039e5a8f0f561caa924 Mon Sep 17 00:00:00 2001 From: Conlain Kelly Date: Fri, 20 Jul 2018 15:51:03 -0400 Subject: Add multithread and move tests into main build --- .travis.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 73bbfbeb2a..f56f77902d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -24,8 +24,7 @@ script: - ./tools/infrastructure/check_style.sh - mkdir build && cd build - cmake ../ -DBUILD_TESTS=ON - - make install && sudo ldconfig -after_success: + - make install-3rd_party && make -j `nproc` install && sudo ldconfig - make test env: global: -- cgit v1.2.1 From 78e99ab9190fc62f34656e55ba29ff3ed7290877 Mon Sep 17 00:00:00 2001 From: Conlain Kelly Date: Mon, 23 Jul 2018 13:41:25 -0400 Subject: Create grammar only once --- .../mobile/create_interaction_choice_set_request.cc | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) 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 9b365b3f13..b20b657279 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 @@ -119,12 +119,7 @@ void CreateInteractionChoiceSetRequest::Run() { return; } - Result::eType result = CheckChoiceSet(app); - if (Result::SUCCESS != result) { - SendResponse(false, result); - return; - } - std::cerr << "checking choice set\n"; + int vr_status = MessageHelper::CheckChoiceSet_VRCommands((*message_)[strings::msg_params][strings::choice_set]); if (vr_status == -1) { std::cerr << "choice set has invalid MIXED set of VR parameters" << '\n'; @@ -134,14 +129,20 @@ void CreateInteractionChoiceSetRequest::Run() { } else if (vr_status == 0) { std::cerr << "choice set has valid FULL set of VR parameters" << '\n'; - + } else { + std::cerr << "choice set has valid EMPTY set of VR parameters" << '\n'; + } + + Result::eType result = CheckChoiceSet(app); + if (Result::SUCCESS != result) { + SendResponse(false, result); + return; + } + if (vr_status == 0) { // everyone had a vr command, setup the grammar uint32_t grammar_id = application_manager_.GenerateGrammarID(); (*message_)[strings::msg_params][strings::grammar_id] = grammar_id; SendVRAddCommandRequests(app); - } else { - std::cerr << "choice set has valid EMPTY set of VR parameters" << '\n'; - } // continue on as usual app->AddChoiceSet(choice_set_id_, (*message_)[strings::msg_params]); -- cgit v1.2.1 From 0849c2a539587ae1b020599c0baed5e6403ce3b0 Mon Sep 17 00:00:00 2001 From: conlain-k Date: Mon, 23 Jul 2018 17:13:50 -0400 Subject: Only run tests on successful build --- .travis.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index f56f77902d..7f7df359b4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -24,8 +24,7 @@ script: - ./tools/infrastructure/check_style.sh - mkdir build && cd build - cmake ../ -DBUILD_TESTS=ON - - make install-3rd_party && make -j `nproc` install && sudo ldconfig - - make test + - make install-3rd_party && make -j `nproc` install && sudo ldconfig && make test env: global: - LC_CTYPE=en_US.UTF-8 -- cgit v1.2.1 From 176b4391dc45a8fd6ffe4054ae66161d942cbfdb Mon Sep 17 00:00:00 2001 From: Sho Amano Date: Tue, 24 Jul 2018 09:34:47 +0900 Subject: Remove Xevo copyrights from multiple transport implementation --- .../application_manager/smart_object_keys.h | 5 +--- .../transport_adapter/transport_adapter.h | 5 +--- .../transport_adapter/transport_adapter_event.h | 5 +--- .../transport_manager/transport_manager_listener.h | 5 +--- .../transport_manager_listener_empty.h | 5 +--- src/components/interfaces/HMI_API.xml | 3 -- .../tcp/network_interface_listener.h | 32 ---------------------- .../tcp/network_interface_listener_impl.h | 32 ---------------------- ...form_specific_network_interface_listener_impl.h | 32 ---------------------- ...form_specific_network_interface_listener_impl.h | 32 ---------------------- .../transport_manager/tcp/tcp_client_listener.h | 5 +--- .../transport_manager/tcp/tcp_transport_adapter.h | 5 +--- .../transport_adapter_controller.h | 5 +--- .../transport_adapter/transport_adapter_impl.h | 5 +--- .../transport_adapter/transport_adapter_listener.h | 5 +--- .../transport_adapter_listener_impl.h | 5 +--- .../src/tcp/network_interface_listener_impl.cc | 32 ---------------------- ...platform_specific_network_interface_listener.cc | 32 ---------------------- ...platform_specific_network_interface_listener.cc | 31 --------------------- .../src/tcp/tcp_client_listener.cc | 5 +--- .../src/tcp/tcp_transport_adapter.cc | 5 +--- .../transport_adapter/transport_adapter_impl.cc | 5 +--- .../transport_adapter_listener_impl.cc | 5 +--- .../src/transport_manager_impl.cc | 5 +--- .../tcp/mock_tcp_client_listener.h | 32 ---------------------- .../test/network_interface_listener_test.cc | 32 ---------------------- .../linux/linux_network_interface_listener_test.cc | 32 ---------------------- .../test/tcp_client_listener_test.cc | 5 +--- 28 files changed, 17 insertions(+), 390 deletions(-) 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 d0a3c1ed96..b66f7973ec 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 @@ -2,9 +2,6 @@ Copyright (c) 2013, Ford Motor Company All rights reserved. - 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: @@ -16,7 +13,7 @@ disclaimer in the documentation and/or other materials provided with the distribution. - Neither the name of the copyright holders nor the names of their contributors + 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. diff --git a/src/components/include/transport_manager/transport_adapter/transport_adapter.h b/src/components/include/transport_manager/transport_adapter/transport_adapter.h index 8bba7ade8b..dfe150fb68 100644 --- a/src/components/include/transport_manager/transport_adapter/transport_adapter.h +++ b/src/components/include/transport_manager/transport_adapter/transport_adapter.h @@ -5,9 +5,6 @@ * Copyright (c) 2016, Ford Motor Company * All rights reserved. * - * Copyright (c) 2018 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: * @@ -19,7 +16,7 @@ * disclaimer in the documentation and/or other materials provided with the * distribution. * - * Neither the name of the copyright holders nor the names of its contributors + * 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. * diff --git a/src/components/include/transport_manager/transport_adapter/transport_adapter_event.h b/src/components/include/transport_manager/transport_adapter/transport_adapter_event.h index 5d55960943..23be8492ac 100644 --- a/src/components/include/transport_manager/transport_adapter/transport_adapter_event.h +++ b/src/components/include/transport_manager/transport_adapter/transport_adapter_event.h @@ -2,9 +2,6 @@ * Copyright (c) 2013, Ford Motor Company * All rights reserved. * - * Copyright (c) 2018 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: * @@ -16,7 +13,7 @@ * disclaimer in the documentation and/or other materials provided with the * distribution. * - * Neither the name of the copyright holders nor the names of its contributors + * 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. * diff --git a/src/components/include/transport_manager/transport_manager_listener.h b/src/components/include/transport_manager/transport_manager_listener.h index 0d02bfd8c7..6c3f6e2eaa 100644 --- a/src/components/include/transport_manager/transport_manager_listener.h +++ b/src/components/include/transport_manager/transport_manager_listener.h @@ -2,9 +2,6 @@ * Copyright (c) 2014, Ford Motor Company * All rights reserved. * - * Copyright (c) 2018 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: * @@ -16,7 +13,7 @@ * disclaimer in the documentation and/or other materials provided with the * distribution. * - * Neither the name of the copyright holders nor the names of its contributors + * 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. * diff --git a/src/components/include/transport_manager/transport_manager_listener_empty.h b/src/components/include/transport_manager/transport_manager_listener_empty.h index a255256290..08b2b77c30 100644 --- a/src/components/include/transport_manager/transport_manager_listener_empty.h +++ b/src/components/include/transport_manager/transport_manager_listener_empty.h @@ -2,9 +2,6 @@ * Copyright (c) 2014, Ford Motor Company * All rights reserved. * - * Copyright (c) 2018 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: * @@ -16,7 +13,7 @@ * disclaimer in the documentation and/or other materials provided with the * distribution. * - * Neither the name of the copyright holders nor the names of its contributors + * 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. * diff --git a/src/components/interfaces/HMI_API.xml b/src/components/interfaces/HMI_API.xml index 18966ff00a..1939defc1f 100644 --- a/src/components/interfaces/HMI_API.xml +++ b/src/components/interfaces/HMI_API.xml @@ -4,9 +4,6 @@ * Copyright (c) 2016, Ford Motor Company * All rights reserved. * - * 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: * diff --git a/src/components/transport_manager/include/transport_manager/tcp/network_interface_listener.h b/src/components/transport_manager/include/transport_manager/tcp/network_interface_listener.h index 91ddb3839c..8154503077 100644 --- a/src/components/transport_manager/include/transport_manager/tcp/network_interface_listener.h +++ b/src/components/transport_manager/include/transport_manager/tcp/network_interface_listener.h @@ -1,35 +1,3 @@ -/* - * Copyright (c) 2018 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 names of the copyright holders 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_TRANSPORT_MANAGER_INCLUDE_TRANSPORT_MANAGER_TCP_NETWORK_INTERFACE_LISTENER_H_ #define SRC_COMPONENTS_TRANSPORT_MANAGER_INCLUDE_TRANSPORT_MANAGER_TCP_NETWORK_INTERFACE_LISTENER_H_ diff --git a/src/components/transport_manager/include/transport_manager/tcp/network_interface_listener_impl.h b/src/components/transport_manager/include/transport_manager/tcp/network_interface_listener_impl.h index 11a9be05ed..159b5ff21d 100644 --- a/src/components/transport_manager/include/transport_manager/tcp/network_interface_listener_impl.h +++ b/src/components/transport_manager/include/transport_manager/tcp/network_interface_listener_impl.h @@ -1,35 +1,3 @@ -/* - * Copyright (c) 2018 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 names of the copyright holders 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_TRANSPORT_MANAGER_INCLUDE_TRANSPORT_MANAGER_TCP_NETWORK_INTERFACE_LISTENER_IMPL_H_ #define SRC_COMPONENTS_TRANSPORT_MANAGER_INCLUDE_TRANSPORT_MANAGER_TCP_NETWORK_INTERFACE_LISTENER_IMPL_H_ diff --git a/src/components/transport_manager/include/transport_manager/tcp/platform_specific/linux/platform_specific_network_interface_listener_impl.h b/src/components/transport_manager/include/transport_manager/tcp/platform_specific/linux/platform_specific_network_interface_listener_impl.h index 8a2279003a..a7338b94be 100644 --- a/src/components/transport_manager/include/transport_manager/tcp/platform_specific/linux/platform_specific_network_interface_listener_impl.h +++ b/src/components/transport_manager/include/transport_manager/tcp/platform_specific/linux/platform_specific_network_interface_listener_impl.h @@ -1,35 +1,3 @@ -/* - * Copyright (c) 2018 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 names of the copyright holders 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_TRANSPORT_MANAGER_INCLUDE_TRANSPORT_MANAGER_TCP_PLATFORM_SPECIFIC_LINUX_PLATFORM_SPECIFIC_NETWORK_INTERFACE_LISTENER_H_ #define SRC_COMPONENTS_TRANSPORT_MANAGER_INCLUDE_TRANSPORT_MANAGER_TCP_PLATFORM_SPECIFIC_LINUX_PLATFORM_SPECIFIC_NETWORK_INTERFACE_LISTENER_H_ diff --git a/src/components/transport_manager/include/transport_manager/tcp/platform_specific/qnx/platform_specific_network_interface_listener_impl.h b/src/components/transport_manager/include/transport_manager/tcp/platform_specific/qnx/platform_specific_network_interface_listener_impl.h index c5982853dc..2cb5eb47a7 100644 --- a/src/components/transport_manager/include/transport_manager/tcp/platform_specific/qnx/platform_specific_network_interface_listener_impl.h +++ b/src/components/transport_manager/include/transport_manager/tcp/platform_specific/qnx/platform_specific_network_interface_listener_impl.h @@ -1,35 +1,3 @@ -/* - * Copyright (c) 2018 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 names of the copyright holders 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_TRANSPORT_MANAGER_INCLUDE_TRANSPORT_MANAGER_TCP_PLATFORM_SPECIFIC_QNX_PLATFORM_SPECIFIC_NETWORK_INTERFACE_LISTENER_H_ #define SRC_COMPONENTS_TRANSPORT_MANAGER_INCLUDE_TRANSPORT_MANAGER_TCP_PLATFORM_SPECIFIC_QNX_PLATFORM_SPECIFIC_NETWORK_INTERFACE_LISTENER_H_ diff --git a/src/components/transport_manager/include/transport_manager/tcp/tcp_client_listener.h b/src/components/transport_manager/include/transport_manager/tcp/tcp_client_listener.h index dae66cd30e..0f9529d8d8 100644 --- a/src/components/transport_manager/include/transport_manager/tcp/tcp_client_listener.h +++ b/src/components/transport_manager/include/transport_manager/tcp/tcp_client_listener.h @@ -5,9 +5,6 @@ * Copyright (c) 2013, Ford Motor Company * All rights reserved. * - * Copyright (c) 2018 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: * @@ -19,7 +16,7 @@ * disclaimer in the documentation and/or other materials provided with the * distribution. * - * Neither the name of the copyright holders nor the names of its contributors + * 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. * diff --git a/src/components/transport_manager/include/transport_manager/tcp/tcp_transport_adapter.h b/src/components/transport_manager/include/transport_manager/tcp/tcp_transport_adapter.h index 647e14dbfa..37f5a7fe49 100644 --- a/src/components/transport_manager/include/transport_manager/tcp/tcp_transport_adapter.h +++ b/src/components/transport_manager/include/transport_manager/tcp/tcp_transport_adapter.h @@ -5,9 +5,6 @@ * Copyright (c) 2013, Ford Motor Company * All rights reserved. * - * Copyright (c) 2018 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: * @@ -19,7 +16,7 @@ * disclaimer in the documentation and/or other materials provided with the * distribution. * - * Neither the name of the copyright holders nor the names of its contributors + * 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. * diff --git a/src/components/transport_manager/include/transport_manager/transport_adapter/transport_adapter_controller.h b/src/components/transport_manager/include/transport_manager/transport_adapter/transport_adapter_controller.h index a5a5eb4bdf..69d76b4b2b 100644 --- a/src/components/transport_manager/include/transport_manager/transport_adapter/transport_adapter_controller.h +++ b/src/components/transport_manager/include/transport_manager/transport_adapter/transport_adapter_controller.h @@ -2,9 +2,6 @@ * Copyright (c) 2014, Ford Motor Company * All rights reserved. * - * Copyright (c) 2018 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: * @@ -16,7 +13,7 @@ * disclaimer in the documentation and/or other materials provided with the * distribution. * - * Neither the name of the copyright holders nor the names of its contributors + * 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. * diff --git a/src/components/transport_manager/include/transport_manager/transport_adapter/transport_adapter_impl.h b/src/components/transport_manager/include/transport_manager/transport_adapter/transport_adapter_impl.h index b503e609f1..078f93b32f 100644 --- a/src/components/transport_manager/include/transport_manager/transport_adapter/transport_adapter_impl.h +++ b/src/components/transport_manager/include/transport_manager/transport_adapter/transport_adapter_impl.h @@ -2,9 +2,6 @@ * Copyright (c) 2016, Ford Motor Company * All rights reserved. * - * Copyright (c) 2018 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: * @@ -16,7 +13,7 @@ * disclaimer in the documentation and/or other materials provided with the * distribution. * - * Neither the name of the copyright holders nor the names of its contributors + * 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. * diff --git a/src/components/transport_manager/include/transport_manager/transport_adapter/transport_adapter_listener.h b/src/components/transport_manager/include/transport_manager/transport_adapter/transport_adapter_listener.h index 07938224d6..4606bac2d4 100644 --- a/src/components/transport_manager/include/transport_manager/transport_adapter/transport_adapter_listener.h +++ b/src/components/transport_manager/include/transport_manager/transport_adapter/transport_adapter_listener.h @@ -2,9 +2,6 @@ * Copyright (c) 2014, Ford Motor Company * All rights reserved. * - * Copyright (c) 2018 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: * @@ -16,7 +13,7 @@ * disclaimer in the documentation and/or other materials provided with the * distribution. * - * Neither the name of the copyright holders nor the names of its contributors + * 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. * diff --git a/src/components/transport_manager/include/transport_manager/transport_adapter/transport_adapter_listener_impl.h b/src/components/transport_manager/include/transport_manager/transport_adapter/transport_adapter_listener_impl.h index f1576d1dc3..a744400279 100644 --- a/src/components/transport_manager/include/transport_manager/transport_adapter/transport_adapter_listener_impl.h +++ b/src/components/transport_manager/include/transport_manager/transport_adapter/transport_adapter_listener_impl.h @@ -2,9 +2,6 @@ * Copyright (c) 2014, Ford Motor Company * All rights reserved. * - * Copyright (c) 2018 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: * @@ -16,7 +13,7 @@ * disclaimer in the documentation and/or other materials provided with the * distribution. * - * Neither the name of the copyright holders nor the names of its contributors + * 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. * diff --git a/src/components/transport_manager/src/tcp/network_interface_listener_impl.cc b/src/components/transport_manager/src/tcp/network_interface_listener_impl.cc index e362ee8a73..85c479134d 100644 --- a/src/components/transport_manager/src/tcp/network_interface_listener_impl.cc +++ b/src/components/transport_manager/src/tcp/network_interface_listener_impl.cc @@ -1,35 +1,3 @@ -/* - * Copyright (c) 2018 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 names of the copyright holders 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 "transport_manager/tcp/network_interface_listener_impl.h" #include "platform_specific_network_interface_listener_impl.h" diff --git a/src/components/transport_manager/src/tcp/platform_specific/linux/platform_specific_network_interface_listener.cc b/src/components/transport_manager/src/tcp/platform_specific/linux/platform_specific_network_interface_listener.cc index 29e55b97dd..f6b26c5a39 100644 --- a/src/components/transport_manager/src/tcp/platform_specific/linux/platform_specific_network_interface_listener.cc +++ b/src/components/transport_manager/src/tcp/platform_specific/linux/platform_specific_network_interface_listener.cc @@ -1,35 +1,3 @@ -/* - * Copyright (c) 2018 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 names of the copyright holders 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 "transport_manager/tcp/platform_specific/linux/platform_specific_network_interface_listener_impl.h" #include diff --git a/src/components/transport_manager/src/tcp/platform_specific/qnx/platform_specific_network_interface_listener.cc b/src/components/transport_manager/src/tcp/platform_specific/qnx/platform_specific_network_interface_listener.cc index 9ca7890278..15b3814999 100644 --- a/src/components/transport_manager/src/tcp/platform_specific/qnx/platform_specific_network_interface_listener.cc +++ b/src/components/transport_manager/src/tcp/platform_specific/qnx/platform_specific_network_interface_listener.cc @@ -1,34 +1,3 @@ -/* - * Copyright (c) 2018 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 names of the copyright holders 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 "transport_manager/tcp/platform_specific/qnx/platform_specific_network_interface_listener_impl.h" namespace transport_manager { diff --git a/src/components/transport_manager/src/tcp/tcp_client_listener.cc b/src/components/transport_manager/src/tcp/tcp_client_listener.cc index abcca43509..82c30744e7 100644 --- a/src/components/transport_manager/src/tcp/tcp_client_listener.cc +++ b/src/components/transport_manager/src/tcp/tcp_client_listener.cc @@ -3,9 +3,6 @@ * Copyright (c) 2017, Ford Motor Company * All rights reserved. * - * Copyright (c) 2018 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: * @@ -17,7 +14,7 @@ * disclaimer in the documentation and/or other materials provided with the * distribution. * - * Neither the name of the copyright holders nor the names of its contributors + * 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. * diff --git a/src/components/transport_manager/src/tcp/tcp_transport_adapter.cc b/src/components/transport_manager/src/tcp/tcp_transport_adapter.cc index 27ff893df3..b3dbf49628 100644 --- a/src/components/transport_manager/src/tcp/tcp_transport_adapter.cc +++ b/src/components/transport_manager/src/tcp/tcp_transport_adapter.cc @@ -2,9 +2,6 @@ * Copyright (c) 2017, Ford Motor Company * All rights reserved. * - * Copyright (c) 2018 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: * @@ -16,7 +13,7 @@ * disclaimer in the documentation and/or other materials provided with the * distribution. * - * Neither the name of the copyright holders nor the names of its contributors + * 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. * diff --git a/src/components/transport_manager/src/transport_adapter/transport_adapter_impl.cc b/src/components/transport_manager/src/transport_adapter/transport_adapter_impl.cc index c50309d437..41971f9feb 100644 --- a/src/components/transport_manager/src/transport_adapter/transport_adapter_impl.cc +++ b/src/components/transport_manager/src/transport_adapter/transport_adapter_impl.cc @@ -2,9 +2,6 @@ * Copyright (c) 2017, Ford Motor Company * All rights reserved. * - * Copyright (c) 2018 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: * @@ -16,7 +13,7 @@ * disclaimer in the documentation and/or other materials provided with the * distribution. * - * Neither the name of the copyright holders nor the names of its contributors + * 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. * diff --git a/src/components/transport_manager/src/transport_adapter/transport_adapter_listener_impl.cc b/src/components/transport_manager/src/transport_adapter/transport_adapter_listener_impl.cc index 5bf9036a4e..544cdde999 100644 --- a/src/components/transport_manager/src/transport_adapter/transport_adapter_listener_impl.cc +++ b/src/components/transport_manager/src/transport_adapter/transport_adapter_listener_impl.cc @@ -2,9 +2,6 @@ * Copyright (c) 2014, Ford Motor Company * All rights reserved. * - * Copyright (c) 2018 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: * @@ -16,7 +13,7 @@ * disclaimer in the documentation and/or other materials provided with the * distribution. * - * Neither the name of the copyright holders nor the names of its contributors + * 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. * diff --git a/src/components/transport_manager/src/transport_manager_impl.cc b/src/components/transport_manager/src/transport_manager_impl.cc index abe4edd812..7cf5dee052 100644 --- a/src/components/transport_manager/src/transport_manager_impl.cc +++ b/src/components/transport_manager/src/transport_manager_impl.cc @@ -2,9 +2,6 @@ * Copyright (c) 2017, Ford Motor Company * All rights reserved. * - * Copyright (c) 2018 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: * @@ -16,7 +13,7 @@ * disclaimer in the documentation and/or other materials provided with the * distribution. * - * Neither the name of the copyright holders nor the names of its contributors + * 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. * diff --git a/src/components/transport_manager/test/include/transport_manager/tcp/mock_tcp_client_listener.h b/src/components/transport_manager/test/include/transport_manager/tcp/mock_tcp_client_listener.h index b7db7c7e64..d18500b02d 100644 --- a/src/components/transport_manager/test/include/transport_manager/tcp/mock_tcp_client_listener.h +++ b/src/components/transport_manager/test/include/transport_manager/tcp/mock_tcp_client_listener.h @@ -1,35 +1,3 @@ -/* - * Copyright (c) 2018 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 copyright holders 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_TRANSPORT_MANAGER_TEST_INCLUDE_TRANSPORT_MANAGER_TCP_MOCK_TCP_CLIENT_LISTENER_H_ #define SRC_COMPONENTS_TRANSPORT_MANAGER_TEST_INCLUDE_TRANSPORT_MANAGER_TCP_MOCK_TCP_CLIENT_LISTENER_H_ diff --git a/src/components/transport_manager/test/network_interface_listener_test.cc b/src/components/transport_manager/test/network_interface_listener_test.cc index 7a5b0315ab..55a35fb4ea 100644 --- a/src/components/transport_manager/test/network_interface_listener_test.cc +++ b/src/components/transport_manager/test/network_interface_listener_test.cc @@ -1,35 +1,3 @@ -/* - * Copyright (c) 2018 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 copyright holders 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 #include #include diff --git a/src/components/transport_manager/test/platform_specific/linux/linux_network_interface_listener_test.cc b/src/components/transport_manager/test/platform_specific/linux/linux_network_interface_listener_test.cc index 864cb9d657..da58466c29 100644 --- a/src/components/transport_manager/test/platform_specific/linux/linux_network_interface_listener_test.cc +++ b/src/components/transport_manager/test/platform_specific/linux/linux_network_interface_listener_test.cc @@ -1,35 +1,3 @@ -/* - * Copyright (c) 2018 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 copyright holders 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 #include #include diff --git a/src/components/transport_manager/test/tcp_client_listener_test.cc b/src/components/transport_manager/test/tcp_client_listener_test.cc index 496851c0ef..5205d6ae3c 100644 --- a/src/components/transport_manager/test/tcp_client_listener_test.cc +++ b/src/components/transport_manager/test/tcp_client_listener_test.cc @@ -2,9 +2,6 @@ * Copyright (c) 2015, Ford Motor Company * All rights reserved. * - * Copyright (c) 2018 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: * @@ -16,7 +13,7 @@ * disclaimer in the documentation and/or other materials provided with the * distribution. * - * Neither the name of the copyright holders nor the names of its contributors + * 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. * -- cgit v1.2.1 From b5043f977fc861c581e7b912923847b0d85aea7c Mon Sep 17 00:00:00 2001 From: Conlain Kelly Date: Tue, 24 Jul 2018 10:49:24 -0400 Subject: add perform interaction modifications --- .../commands/mobile/perform_interaction_request.cc | 50 +++++++++++----------- 1 file changed, 26 insertions(+), 24 deletions(-) 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 7753c16acf..5a614b73c4 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 @@ -163,18 +163,18 @@ void PerformInteractionRequest::Run() { SendResponse(false, mobile_apis::Result::INVALID_ID); return; } - // if (!CheckChoiceSetList_VRCommands( - // app, - // choice_set_id_list_length, - // msg_params[strings::interaction_choice_set_id_list])) { - // LOG4CXX_ERROR(logger_, - // "PerformInteraction has choice sets with " - // "missing vrCommands"); - // SendResponse(false, - // mobile_apis::Result::INVALID_DATA, - // "Some choices don't contain VR commands."); - // return; - // } + if (!CheckChoiceSetList_VRCommands( + app, + choice_set_id_list_length, + msg_params[strings::interaction_choice_set_id_list])) { + LOG4CXX_ERROR(logger_, + "PerformInteraction has choice sets with " + "missing vrCommands"); + SendResponse(false, + mobile_apis::Result::INVALID_DATA, + "Some choices don't contain VR commands."); + return; + } if (msg_params.keyExists(strings::vr_help)) { if (mobile_apis::Result::SUCCESS != MessageHelper::VerifyImageVrHelpItems( @@ -964,17 +964,24 @@ bool PerformInteractionRequest::CheckChoiceSetList_VRCommands( std::pair::iterator, bool> ins_res; for (size_t i = 0; i < choice_set_id_list_length; ++i) { + // std::cerr << "loop entered!\n"; choice_set = app->FindChoiceSet(choice_set_id_list[i].asInt()); + // std::cerr << "set found!!\n"; + // this should never ever happen - // if (!choice_set) { - // LOG4CXX_ERROR( - // logger_, - // "Couldn't find choiceset_id = " << choice_set_id_list[i].asInt()); - // return false; - // } + if (choice_set == nullptr) { + std::cerr << "bad choice set list!\n"; + return false; + } + // std::cerr<< "SMARTTYPE is " << choice_set->getType() << std::endl; + + // std::cerr << "checking status!!!\n"; + const smart_objects::SmartObject& choices_list = + (*choice_set)[strings::choice_set]; + int vr_status = MessageHelper::CheckChoiceSet_VRCommands(choices_list); + // std::cerr << "status checked!!!!\n"; - int vr_status = MessageHelper::CheckChoiceSet_VRCommands(*choice_set); // if not all choices have vr commands if (vr_status != 0) { std::cerr << "choice set has member missing vr commands\n"; @@ -1005,11 +1012,6 @@ bool PerformInteractionRequest::CheckChoiceIDFromRequest( } - int vr_status = MessageHelper::CheckChoiceSet_VRCommands(*choice_set); - // if not all choices have vr commands - if (vr_status != 0) { - - } choice_list_length = (*choice_set)[strings::choice_set].length(); const smart_objects::SmartObject& choices_list = (*choice_set)[strings::choice_set]; -- cgit v1.2.1 From 28246b04368088a1ebd11e3c1b6885cace6e643b Mon Sep 17 00:00:00 2001 From: Conlain Kelly Date: Tue, 24 Jul 2018 13:53:31 -0400 Subject: Fix segfault, add perform interaction checks --- .../commands/mobile/perform_interaction_request.h | 4 +- .../create_interaction_choice_set_request.cc | 28 +++++++---- .../commands/mobile/perform_interaction_request.cc | 54 ++++++++++++---------- 3 files changed, 50 insertions(+), 36 deletions(-) diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/perform_interaction_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/perform_interaction_request.h index 02ea6945f7..7684b3fd3f 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/perform_interaction_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/perform_interaction_request.h @@ -222,9 +222,7 @@ class PerformInteractionRequest * @return returns false request has choice sets with no vrCommands */ bool CheckChoiceSetList_VRCommands( - app_mngr::ApplicationSharedPtr app, - const size_t choice_set_id_list_length, - const smart_objects::SmartObject& choice_set_id_list) const; + app_mngr::ApplicationSharedPtr app); /** * @brief Tells if there are sent requests without responses 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 b20b657279..48f15aafda 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 @@ -124,7 +124,7 @@ void CreateInteractionChoiceSetRequest::Run() { if (vr_status == -1) { std::cerr << "choice set has invalid MIXED set of VR parameters" << '\n'; // this is an error - SendResponse(false, Result::INVALID_DATA, "Some choices don't contain VR commands."); + SendResponse(false, Result::INVALID_DATA, "Some choices don't contain VR commands. Either all or none must have voice commands."); return; // exit now, this is a bad set } else if (vr_status == 0) { @@ -139,13 +139,23 @@ void CreateInteractionChoiceSetRequest::Run() { return; } if (vr_status == 0) { + std::cerr << "creating grammar\n"; // everyone had a vr command, setup the grammar uint32_t grammar_id = application_manager_.GenerateGrammarID(); (*message_)[strings::msg_params][strings::grammar_id] = grammar_id; - SendVRAddCommandRequests(app); } // continue on as usual + std::cerr << "adding choice set\n"; app->AddChoiceSet(choice_set_id_, (*message_)[strings::msg_params]); + std::cerr << "added! choice set\n"; + + if (vr_status == 0) { + SendVRAddCommandRequests(app); + std::cerr << "requests sent!!!!\n"; + } else { + SendResponse(true, Result::SUCCESS); + + } } mobile_apis::Result::eType CreateInteractionChoiceSetRequest::CheckChoiceSet( @@ -191,12 +201,14 @@ mobile_apis::Result::eType CreateInteractionChoiceSetRequest::CheckChoiceSet( bool CreateInteractionChoiceSetRequest::compareSynonyms( const NsSmartDeviceLink::NsSmartObjects::SmartObject& choice1, const NsSmartDeviceLink::NsSmartObjects::SmartObject& choice2) { - smart_objects::SmartArray* vr_cmds_1 = - choice1[strings::vr_commands].asArray(); - DCHECK(vr_cmds_1 != NULL); - smart_objects::SmartArray* vr_cmds_2 = - choice2[strings::vr_commands].asArray(); - DCHECK(vr_cmds_2 != NULL); + // only compare if they both have vr commands + if (!(choice1.keyExists(strings::vr_commands) && + choice2.keyExists(strings::vr_commands))) { + std::cerr << "someone is empty!\n"; + return false; // clearly there isn't a duplicate if one of them is null + } + smart_objects::SmartArray* vr_cmds_1 = choice1[strings::vr_commands].asArray(); + smart_objects::SmartArray* vr_cmds_2 = choice2[strings::vr_commands].asArray(); smart_objects::SmartArray::iterator it; it = std::find_first_of(vr_cmds_1->begin(), 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 5a614b73c4..6a55936bcc 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 @@ -163,18 +163,6 @@ void PerformInteractionRequest::Run() { SendResponse(false, mobile_apis::Result::INVALID_ID); return; } - if (!CheckChoiceSetList_VRCommands( - app, - choice_set_id_list_length, - msg_params[strings::interaction_choice_set_id_list])) { - LOG4CXX_ERROR(logger_, - "PerformInteraction has choice sets with " - "missing vrCommands"); - SendResponse(false, - mobile_apis::Result::INVALID_DATA, - "Some choices don't contain VR commands."); - return; - } if (msg_params.keyExists(strings::vr_help)) { if (mobile_apis::Result::SUCCESS != MessageHelper::VerifyImageVrHelpItems( @@ -197,7 +185,7 @@ void PerformInteractionRequest::Run() { case mobile_apis::InteractionMode::BOTH: { LOG4CXX_DEBUG(logger_, "Interaction Mode: BOTH"); if (!CheckChoiceSetVRSynonyms(app) || !CheckChoiceSetMenuNames(app) || - !CheckVrHelpItemPositions(app)) { + !CheckVrHelpItemPositions(app) || !CheckChoiceSetList_VRCommands(app)) { return; } break; @@ -212,7 +200,8 @@ void PerformInteractionRequest::Run() { } case mobile_apis::InteractionMode::VR_ONLY: { LOG4CXX_DEBUG(logger_, "Interaction Mode: VR_ONLY"); - if (!CheckChoiceSetVRSynonyms(app) || !CheckVrHelpItemPositions(app)) { + if (!CheckChoiceSetVRSynonyms(app) || !CheckVrHelpItemPositions(app) || + !CheckChoiceSetList_VRCommands(app)) { return; } break; @@ -757,6 +746,15 @@ bool PerformInteractionRequest::CheckChoiceSetVRSynonyms( size_t jj = 0; for (; ii < (*i_choice_set)[strings::choice_set].length(); ++ii) { for (; jj < (*j_choice_set)[strings::choice_set].length(); ++jj) { + if (!((*i_choice_set)[strings::choice_set][ii].keyExists( + strings::vr_commands) && + (*j_choice_set)[strings::choice_set][jj].keyExists( + strings::vr_commands))) { + LOG4CXX_DEBUG( + logger_, + "One or both sets has missing vr commands, skipping synonym check"); + return true; + } // choice_set pointer contains SmartObject msg_params smart_objects::SmartObject& ii_vr_commands = (*i_choice_set)[strings::choice_set][ii][strings::vr_commands]; @@ -955,36 +953,42 @@ bool PerformInteractionRequest::CheckChoiceIDFromResponse( bool PerformInteractionRequest::CheckChoiceSetList_VRCommands( - ApplicationSharedPtr app, - const size_t choice_set_id_list_length, - const smart_objects::SmartObject& choice_set_id_list) const { + ApplicationSharedPtr app) { LOG4CXX_AUTO_TRACE(logger_); + + const smart_objects::SmartObject& choice_set_id_list = + (*message_)[strings::msg_params][strings::interaction_choice_set_id_list]; - smart_objects::SmartObject* choice_set = 0; - std::pair::iterator, bool> ins_res; + smart_objects::SmartObject* choice_set = nullptr; - for (size_t i = 0; i < choice_set_id_list_length; ++i) { - // std::cerr << "loop entered!\n"; + for (size_t i = 0; i < choice_set_id_list.length(); ++i) { + std::cerr << "loop entered!\n"; choice_set = app->FindChoiceSet(choice_set_id_list[i].asInt()); - // std::cerr << "set found!!\n"; + std::cerr << "set found!!\n"; // this should never ever happen if (choice_set == nullptr) { std::cerr << "bad choice set list!\n"; return false; } - // std::cerr<< "SMARTTYPE is " << choice_set->getType() << std::endl; + std::cerr<< "SMARTTYPE is " << choice_set->getType() << std::endl; - // std::cerr << "checking status!!!\n"; + std::cerr << "checking status!!!\n"; const smart_objects::SmartObject& choices_list = (*choice_set)[strings::choice_set]; int vr_status = MessageHelper::CheckChoiceSet_VRCommands(choices_list); - // std::cerr << "status checked!!!!\n"; + std::cerr << "status checked!!!!\n"; // if not all choices have vr commands if (vr_status != 0) { std::cerr << "choice set has member missing vr commands\n"; + LOG4CXX_ERROR(logger_, + "PerformInteraction has choice sets with " + "missing vrCommands, not in MANUAL_ONLY mode"); + SendResponse(false, + mobile_apis::Result::INVALID_DATA, + "Some choices don't contain VR commands."); return false; } } -- cgit v1.2.1 From 0ed004d9a7f961ccb964851dff1266949ebea1ee Mon Sep 17 00:00:00 2001 From: Conlain Kelly Date: Tue, 24 Jul 2018 15:00:02 -0400 Subject: Cleanup, remove some typos --- .../create_interaction_choice_set_request.cc | 24 ++++++---------------- .../commands/mobile/perform_interaction_request.cc | 24 +++++++++------------- 2 files changed, 16 insertions(+), 32 deletions(-) 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 48f15aafda..91ef7c3bbd 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 @@ -120,41 +120,30 @@ void CreateInteractionChoiceSetRequest::Run() { } + Result::eType result = CheckChoiceSet(app); + if (Result::SUCCESS != result) { + SendResponse(false, result); + return; + } int vr_status = MessageHelper::CheckChoiceSet_VRCommands((*message_)[strings::msg_params][strings::choice_set]); if (vr_status == -1) { - std::cerr << "choice set has invalid MIXED set of VR parameters" << '\n'; // this is an error SendResponse(false, Result::INVALID_DATA, "Some choices don't contain VR commands. Either all or none must have voice commands."); return; // exit now, this is a bad set } else if (vr_status == 0) { - std::cerr << "choice set has valid FULL set of VR parameters" << '\n'; - } else { - std::cerr << "choice set has valid EMPTY set of VR parameters" << '\n'; - } - - Result::eType result = CheckChoiceSet(app); - if (Result::SUCCESS != result) { - SendResponse(false, result); - return; - } - if (vr_status == 0) { - std::cerr << "creating grammar\n"; // everyone had a vr command, setup the grammar uint32_t grammar_id = application_manager_.GenerateGrammarID(); (*message_)[strings::msg_params][strings::grammar_id] = grammar_id; } // continue on as usual - std::cerr << "adding choice set\n"; app->AddChoiceSet(choice_set_id_, (*message_)[strings::msg_params]); - std::cerr << "added! choice set\n"; if (vr_status == 0) { + // we have VR commands SendVRAddCommandRequests(app); - std::cerr << "requests sent!!!!\n"; } else { SendResponse(true, Result::SUCCESS); - } } @@ -204,7 +193,6 @@ bool CreateInteractionChoiceSetRequest::compareSynonyms( // only compare if they both have vr commands if (!(choice1.keyExists(strings::vr_commands) && choice2.keyExists(strings::vr_commands))) { - std::cerr << "someone is empty!\n"; return false; // clearly there isn't a duplicate if one of them is null } smart_objects::SmartArray* vr_cmds_1 = choice1[strings::vr_commands].asArray(); 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 6a55936bcc..98b5d96bb5 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 @@ -354,15 +354,15 @@ bool PerformInteractionRequest::ProcessVRResponse( const SmartObject& hmi_msg_params = message[strings::msg_params]; if (hmi_msg_params.keyExists(strings::choice_id)) { - const int choise_id = hmi_msg_params[strings::choice_id].asInt(); - if (!CheckChoiceIDFromResponse(app, choise_id)) { + const int choice_id = hmi_msg_params[strings::choice_id].asInt(); + if (!CheckChoiceIDFromResponse(app, choice_id)) { LOG4CXX_ERROR(logger_, "Wrong choiceID was received from HMI"); TerminatePerformInteraction(); SendResponse( false, Result::GENERIC_ERROR, "Wrong choiceID was received from HMI"); return true; } - msg_params[strings::choice_id] = choise_id; + msg_params[strings::choice_id] = choice_id; } return false; } @@ -538,7 +538,7 @@ void PerformInteractionRequest::SendVRPerformInteractionRequest( smart_objects::SmartObject* choice_set = app->FindChoiceSet(choice_list[i].asInt()); if (!choice_set) { - LOG4CXX_WARN(logger_, "Couldn't found choiset"); + LOG4CXX_WARN(logger_, "Couldn't found choiceset"); continue; } msg_params[strings::grammar_id][grammar_id_index++] = @@ -962,27 +962,23 @@ bool PerformInteractionRequest::CheckChoiceSetList_VRCommands( smart_objects::SmartObject* choice_set = nullptr; for (size_t i = 0; i < choice_set_id_list.length(); ++i) { - std::cerr << "loop entered!\n"; choice_set = app->FindChoiceSet(choice_set_id_list[i].asInt()); - std::cerr << "set found!!\n"; - // this should never ever happen + // this should never ever happen since this was already checked if (choice_set == nullptr) { - std::cerr << "bad choice set list!\n"; + LOG4CXX_ERROR( + logger_, + "Couldn't find choiceset_id = " << choice_set_id_list[i].asInt()); return false; } - std::cerr<< "SMARTTYPE is " << choice_set->getType() << std::endl; - std::cerr << "checking status!!!\n"; const smart_objects::SmartObject& choices_list = (*choice_set)[strings::choice_set]; int vr_status = MessageHelper::CheckChoiceSet_VRCommands(choices_list); - std::cerr << "status checked!!!!\n"; // if not all choices have vr commands if (vr_status != 0) { - std::cerr << "choice set has member missing vr commands\n"; LOG4CXX_ERROR(logger_, "PerformInteraction has choice sets with " "missing vrCommands, not in MANUAL_ONLY mode"); @@ -1011,7 +1007,7 @@ bool PerformInteractionRequest::CheckChoiceIDFromRequest( if (!choice_set) { LOG4CXX_ERROR( logger_, - "Couldn't find choiset_id = " << choice_set_id_list[i].asInt()); + "Couldn't find choiceset_id = " << choice_set_id_list[i].asInt()); return false; } @@ -1024,7 +1020,7 @@ bool PerformInteractionRequest::CheckChoiceIDFromRequest( choice_id_set.insert(choices_list[k][strings::choice_id].asInt()); if (!ins_res.second) { LOG4CXX_ERROR(logger_, - "Choise with ID " + "choice with ID " << choices_list[k][strings::choice_id].asInt() << " already exists"); return false; -- cgit v1.2.1 From 1dc7bf3e56f927915c440ced3d102a2a53fb22db Mon Sep 17 00:00:00 2001 From: Conlain Kelly Date: Tue, 24 Jul 2018 17:19:08 -0400 Subject: style fix --- .../include/application_manager/message_helper.h | 16 +++++----- .../commands/mobile/perform_interaction_request.h | 6 ++-- .../create_interaction_choice_set_request.cc | 23 +++++++++------ .../commands/mobile/perform_interaction_request.cc | 34 ++++++++++------------ .../mobile/create_interaction_choice_set_test.cc | 8 ++--- 5 files changed, 45 insertions(+), 42 deletions(-) diff --git a/src/components/application_manager/include/application_manager/message_helper.h b/src/components/application_manager/include/application_manager/message_helper.h index 3c90928d8a..b15cf0c615 100644 --- a/src/components/application_manager/include/application_manager/message_helper.h +++ b/src/components/application_manager/include/application_manager/message_helper.h @@ -855,23 +855,25 @@ class MessageHelper { */ static smart_objects::SmartObjectSPtr CreateMessageForHMI( hmi_apis::messageType::eType message_type, const uint32_t correlation_id); - - + // Check whether each choice has the vrCommands field - // returns -1 for failure, 0 if all choice include vrCommands, and 1 if none do + // returns -1 for failure, 0 if all choice include vrCommands, and 1 if none + // do // vrCommands is an all-or-none deal static int CheckChoiceSet_VRCommands( const smart_objects::SmartObject& choice_set) { - // if this becomes true, someone doesn't have vrCommands bool all_have = true; // if this is true, no one has vrCommands bool none_have = true; - smart_objects::SmartArray::const_iterator current_choice_set_it = choice_set.asArray()->begin(); + smart_objects::SmartArray::const_iterator current_choice_set_it = + choice_set.asArray()->begin(); // Iterate through choices - for (; choice_set.asArray()->end() != current_choice_set_it; ++current_choice_set_it) { + for (; choice_set.asArray()->end() != current_choice_set_it; + ++current_choice_set_it) { // if the vrCommands is present - if (current_choice_set_it->keyExists(application_manager::strings::vr_commands)) { + if (current_choice_set_it->keyExists( + application_manager::strings::vr_commands)) { // this one has the parameter none_have = false; } else { diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/perform_interaction_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/perform_interaction_request.h index 7684b3fd3f..8c98a4ff30 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/perform_interaction_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/perform_interaction_request.h @@ -211,8 +211,7 @@ class PerformInteractionRequest app_mngr::ApplicationSharedPtr app, const size_t choice_set_id_list_length, const smart_objects::SmartObject& choice_set_id_list) const; - - + /** * @brief Checks each choice in each set for having a VRcommands parameter * @param app contains pointer to application. @@ -221,8 +220,7 @@ class PerformInteractionRequest * @param choice_set_id_list array of choice set ids * @return returns false request has choice sets with no vrCommands */ - bool CheckChoiceSetList_VRCommands( - app_mngr::ApplicationSharedPtr app); + bool CheckChoiceSetList_VRCommands(app_mngr::ApplicationSharedPtr app); /** * @brief Tells if there are sent requests without responses 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 87f270d48a..0d6114cc50 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 @@ -118,18 +118,21 @@ void CreateInteractionChoiceSetRequest::Run() { return; } - Result::eType result = CheckChoiceSet(app); if (Result::SUCCESS != result) { SendResponse(false, result); return; } - int vr_status = MessageHelper::CheckChoiceSet_VRCommands((*message_)[strings::msg_params][strings::choice_set]); + int vr_status = MessageHelper::CheckChoiceSet_VRCommands( + (*message_)[strings::msg_params][strings::choice_set]); if (vr_status == -1) { // this is an error - SendResponse(false, Result::INVALID_DATA, "Some choices don't contain VR commands. Either all or none must have voice commands."); - return; // exit now, this is a bad set - + SendResponse(false, + Result::INVALID_DATA, + "Some choices don't contain VR commands. Either all or none " + "must have voice commands."); + return; // exit now, this is a bad set + } else if (vr_status == 0) { // everyone had a vr command, setup the grammar uint32_t grammar_id = application_manager_.GenerateGrammarID(); @@ -137,7 +140,7 @@ void CreateInteractionChoiceSetRequest::Run() { } // continue on as usual app->AddChoiceSet(choice_set_id_, (*message_)[strings::msg_params]); - + if (vr_status == 0) { // we have VR commands SendVRAddCommandRequests(app); @@ -189,13 +192,15 @@ mobile_apis::Result::eType CreateInteractionChoiceSetRequest::CheckChoiceSet( bool CreateInteractionChoiceSetRequest::compareSynonyms( const NsSmartDeviceLink::NsSmartObjects::SmartObject& choice1, const NsSmartDeviceLink::NsSmartObjects::SmartObject& choice2) { - // only compare if they both have vr commands + // only compare if they both have vr commands if (!(choice1.keyExists(strings::vr_commands) && choice2.keyExists(strings::vr_commands))) { return false; // clearly there isn't a duplicate if one of them is null } - smart_objects::SmartArray* vr_cmds_1 = choice1[strings::vr_commands].asArray(); - smart_objects::SmartArray* vr_cmds_2 = choice2[strings::vr_commands].asArray(); + smart_objects::SmartArray* vr_cmds_1 = + choice1[strings::vr_commands].asArray(); + smart_objects::SmartArray* vr_cmds_2 = + choice2[strings::vr_commands].asArray(); smart_objects::SmartArray::iterator it; it = std::find_first_of(vr_cmds_1->begin(), 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 98b5d96bb5..d013244f57 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 @@ -185,7 +185,8 @@ void PerformInteractionRequest::Run() { case mobile_apis::InteractionMode::BOTH: { LOG4CXX_DEBUG(logger_, "Interaction Mode: BOTH"); if (!CheckChoiceSetVRSynonyms(app) || !CheckChoiceSetMenuNames(app) || - !CheckVrHelpItemPositions(app) || !CheckChoiceSetList_VRCommands(app)) { + !CheckVrHelpItemPositions(app) || + !CheckChoiceSetList_VRCommands(app)) { return; } break; @@ -746,15 +747,15 @@ bool PerformInteractionRequest::CheckChoiceSetVRSynonyms( size_t jj = 0; for (; ii < (*i_choice_set)[strings::choice_set].length(); ++ii) { for (; jj < (*j_choice_set)[strings::choice_set].length(); ++jj) { - if (!((*i_choice_set)[strings::choice_set][ii].keyExists( - strings::vr_commands) && - (*j_choice_set)[strings::choice_set][jj].keyExists( - strings::vr_commands))) { - LOG4CXX_DEBUG( - logger_, - "One or both sets has missing vr commands, skipping synonym check"); - return true; - } + if (!((*i_choice_set)[strings::choice_set][ii].keyExists( + strings::vr_commands) && + (*j_choice_set)[strings::choice_set][jj].keyExists( + strings::vr_commands))) { + LOG4CXX_DEBUG(logger_, + "One or both sets has missing vr commands, skipping " + "synonym check"); + return true; + } // choice_set pointer contains SmartObject msg_params smart_objects::SmartObject& ii_vr_commands = (*i_choice_set)[strings::choice_set][ii][strings::vr_commands]; @@ -951,11 +952,10 @@ bool PerformInteractionRequest::CheckChoiceIDFromResponse( return false; } - bool PerformInteractionRequest::CheckChoiceSetList_VRCommands( ApplicationSharedPtr app) { LOG4CXX_AUTO_TRACE(logger_); - + const smart_objects::SmartObject& choice_set_id_list = (*message_)[strings::msg_params][strings::interaction_choice_set_id_list]; @@ -963,7 +963,7 @@ bool PerformInteractionRequest::CheckChoiceSetList_VRCommands( for (size_t i = 0; i < choice_set_id_list.length(); ++i) { choice_set = app->FindChoiceSet(choice_set_id_list[i].asInt()); - + // this should never ever happen since this was already checked if (choice_set == nullptr) { LOG4CXX_ERROR( @@ -971,12 +971,11 @@ bool PerformInteractionRequest::CheckChoiceSetList_VRCommands( "Couldn't find choiceset_id = " << choice_set_id_list[i].asInt()); return false; } - - + const smart_objects::SmartObject& choices_list = (*choice_set)[strings::choice_set]; int vr_status = MessageHelper::CheckChoiceSet_VRCommands(choices_list); - + // if not all choices have vr commands if (vr_status != 0) { LOG4CXX_ERROR(logger_, @@ -1010,8 +1009,7 @@ bool PerformInteractionRequest::CheckChoiceIDFromRequest( "Couldn't find choiceset_id = " << choice_set_id_list[i].asInt()); return false; } - - + choice_list_length = (*choice_set)[strings::choice_set].length(); const smart_objects::SmartObject& choices_list = (*choice_set)[strings::choice_set]; 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 349764b9e9..9066dc3a00 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 @@ -197,10 +197,10 @@ TEST_F(CreateInteractionChoiceSetRequestTest, OnEvent_VR_UNSUPPORTED_RESOURCE) { MessageSharedPtr msg_vr = CreateFullParamsVRSO(); (*msg_vr)[strings::msg_params][strings::choice_set][0][strings::choice_id] = 10; -(*msg_vr)[strings::msg_params][strings::choice_set][0][strings::menu_name] = - "menu_name"; -(*msg_vr)[strings::msg_params][strings::choice_set][0][strings::vr_commands][0] = - kVrCommands1; + (*msg_vr)[strings::msg_params][strings::choice_set][0][strings::menu_name] = + "menu_name"; + (*msg_vr)[strings::msg_params][strings::choice_set][0][strings::vr_commands] + [0] = kVrCommands1; (*msg_vr)[strings::msg_params][strings::interaction_choice_set_id] = 11; std::shared_ptr req_vr = CreateCommand(msg_vr); -- cgit v1.2.1 From 26f09adb7435f8e9770eebafbc35808135576695 Mon Sep 17 00:00:00 2001 From: Conlain Kelly Date: Wed, 25 Jul 2018 16:28:00 -0400 Subject: Fix invalid iteration segfault on shutdown --- src/components/hmi_message_handler/src/mb_controller.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/hmi_message_handler/src/mb_controller.cc b/src/components/hmi_message_handler/src/mb_controller.cc index 8d3b11add5..4f46026039 100644 --- a/src/components/hmi_message_handler/src/mb_controller.cc +++ b/src/components/hmi_message_handler/src/mb_controller.cc @@ -222,7 +222,7 @@ void CMessageBrokerController::exitReceivingThread() { it; for (it = mConnectionList.begin(); it != mConnectionList.end();) { (*it)->Shutdown(); - mConnectionList.erase(it++); + it = mConnectionList.erase(it); } mConnectionListLock.Release(); -- cgit v1.2.1 From 3463f9a85b5fe5a30ee1edf540f077855170e0bf Mon Sep 17 00:00:00 2001 From: Conlain Kelly Date: Thu, 26 Jul 2018 10:48:50 -0400 Subject: make videostreamingstate optional --- src/components/interfaces/MOBILE_API.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/interfaces/MOBILE_API.xml b/src/components/interfaces/MOBILE_API.xml index 97bc33ceae..09fe843ef3 100644 --- a/src/components/interfaces/MOBILE_API.xml +++ b/src/components/interfaces/MOBILE_API.xml @@ -6115,7 +6115,7 @@ See SystemContext - + See VideoStreamingState. If it is NOT_STREAMABLE, the app must stop streaming video to SDL. -- cgit v1.2.1 From 62d2e5847389eaf6b949e2e724ddf98cab486fc1 Mon Sep 17 00:00:00 2001 From: Ashwin Karemore Date: Mon, 18 Jun 2018 16:47:11 +0200 Subject: removed image check in RPC --- .../src/commands/mobile/add_command_request.cc | 13 ---------- .../create_interaction_choice_set_request.cc | 28 ---------------------- .../commands/mobile/perform_interaction_request.cc | 10 -------- .../src/commands/mobile/send_location_request.cc | 13 ---------- .../mobile/set_global_properties_request.cc | 26 -------------------- .../commands/mobile/show_constant_tbt_request.cc | 20 ---------------- .../src/commands/mobile/show_request.cc | 26 -------------------- .../commands/mobile/update_turn_list_request.cc | 16 ------------- 8 files changed, 152 deletions(-) diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/add_command_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/add_command_request.cc index fc836aae5f..ab9baea7ef 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/add_command_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/add_command_request.cc @@ -90,19 +90,6 @@ void AddCommandRequest::Run() { return; } - if ((*message_)[strings::msg_params].keyExists(strings::cmd_icon)) { - mobile_apis::Result::eType verification_result = MessageHelper::VerifyImage( - (*message_)[strings::msg_params][strings::cmd_icon], - app, - application_manager_); - - if (mobile_apis::Result::SUCCESS != verification_result) { - LOG4CXX_ERROR( - logger_, "MessageHelper::VerifyImage return " << verification_result); - SendResponse(false, verification_result); - return; - } - } if (!((*message_)[strings::msg_params].keyExists(strings::cmd_id))) { LOG4CXX_ERROR(logger_, "INVALID_DATA"); 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 d2d39dcd77..89ae0c1aac 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 @@ -78,34 +78,6 @@ void CreateInteractionChoiceSetRequest::Run() { SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED); return; } - for (uint32_t i = 0; - i < (*message_)[strings::msg_params][strings::choice_set].length(); - ++i) { - Result::eType verification_result_image = Result::SUCCESS; - Result::eType verification_result_secondary_image = Result::SUCCESS; - if ((*message_)[strings::msg_params][strings::choice_set][i].keyExists( - strings::image)) { - verification_result_image = MessageHelper::VerifyImage( - (*message_)[strings::msg_params][strings::choice_set][i] - [strings::image], - app, - application_manager_); - } - if ((*message_)[strings::msg_params][strings::choice_set][i].keyExists( - strings::secondary_image)) { - verification_result_secondary_image = MessageHelper::VerifyImage( - (*message_)[strings::msg_params][strings::choice_set][i] - [strings::secondary_image], - app, - application_manager_); - } - if (verification_result_image == Result::INVALID_DATA || - verification_result_secondary_image == Result::INVALID_DATA) { - LOG4CXX_ERROR(logger_, "Image verification failed."); - SendResponse(false, Result::INVALID_DATA); - return; - } - } choice_set_id_ = (*message_)[strings::msg_params][strings::interaction_choice_set_id] 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 8710f3c3d6..fb3516c24c 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 @@ -164,16 +164,6 @@ void PerformInteractionRequest::Run() { return; } - if (msg_params.keyExists(strings::vr_help)) { - if (mobile_apis::Result::SUCCESS != - MessageHelper::VerifyImageVrHelpItems( - msg_params[strings::vr_help], app, application_manager_)) { - LOG4CXX_ERROR(logger_, - "Verification of " << strings::vr_help << " failed."); - SendResponse(false, mobile_apis::Result::INVALID_DATA); - return; - } - } if (IsWhiteSpaceExist()) { LOG4CXX_ERROR(logger_, diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/send_location_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/send_location_request.cc index ab8de5923a..e9e11b3f24 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/send_location_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/send_location_request.cc @@ -117,19 +117,6 @@ void SendLocationRequest::Run() { return; } - if (msg_params.keyExists(strings::location_image)) { - mobile_apis::Result::eType verification_result = - mobile_apis::Result::SUCCESS; - verification_result = MessageHelper::VerifyImage( - (*message_)[strings::msg_params][strings::location_image], - app, - application_manager_); - if (mobile_apis::Result::SUCCESS != verification_result) { - LOG4CXX_ERROR(logger_, "VerifyImage INVALID_DATA!"); - SendResponse(false, verification_result); - return; - } - } SmartObject request_msg_params = SmartObject(smart_objects::SmartType_Map); request_msg_params = msg_params; diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_global_properties_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_global_properties_request.cc index b4b4e84f49..0e8c4fcbfc 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_global_properties_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_global_properties_request.cc @@ -88,32 +88,6 @@ void SetGlobalPropertiesRequest::Run() { return; } - mobile_apis::Result::eType verification_result = mobile_apis::Result::SUCCESS; - - if ((*message_)[strings::msg_params].keyExists(strings::menu_icon)) { - verification_result = MessageHelper::VerifyImage( - (*message_)[strings::msg_params][strings::menu_icon], - app, - application_manager_); - if (mobile_apis::Result::SUCCESS != verification_result) { - LOG4CXX_ERROR( - logger_, "MessageHelper::VerifyImage return " << verification_result); - SendResponse(false, verification_result); - return; - } - } - // Check for image file(s) in vrHelpItem - if ((*message_)[strings::msg_params].keyExists(strings::vr_help)) { - if (mobile_apis::Result::SUCCESS != - MessageHelper::VerifyImageVrHelpItems( - (*message_)[strings::msg_params][strings::vr_help], - app, - application_manager_)) { - LOG4CXX_ERROR(logger_, "MessageHelper::VerifyImage return INVALID_DATA!"); - SendResponse(false, mobile_apis::Result::INVALID_DATA); - return; - } - } if (IsWhiteSpaceExist()) { LOG4CXX_ERROR(logger_, "White spaces found"); diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/show_constant_tbt_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/show_constant_tbt_request.cc index c2eb067e18..1e5767258d 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/show_constant_tbt_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/show_constant_tbt_request.cc @@ -101,26 +101,6 @@ void ShowConstantTBTRequest::Run() { return; } - mobile_apis::Result::eType verification_result = mobile_apis::Result::SUCCESS; - if (msg_params.keyExists(strings::turn_icon)) { - verification_result = MessageHelper::VerifyImage( - msg_params[strings::turn_icon], app, application_manager_); - if (mobile_apis::Result::SUCCESS != verification_result) { - LOG4CXX_ERROR(logger_, "VerifyImage INVALID_DATA!"); - SendResponse(false, verification_result); - return; - } - } - - if (msg_params.keyExists(strings::next_turn_icon)) { - verification_result = MessageHelper::VerifyImage( - msg_params[strings::next_turn_icon], app, application_manager_); - if (mobile_apis::Result::SUCCESS != verification_result) { - LOG4CXX_ERROR(logger_, "VerifyImage INVALID_DATA!"); - SendResponse(false, verification_result); - return; - } - } msg_params[strings::app_id] = app->app_id(); diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/show_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/show_request.cc index 0fdf6d83cf..25b96d6aab 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/show_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/show_request.cc @@ -135,32 +135,6 @@ void ShowRequest::Run() { return; } - mobile_apis::Result::eType verification_result = mobile_apis::Result::SUCCESS; - if (((*message_)[strings::msg_params].keyExists(strings::graphic)) && - ((*message_)[strings::msg_params][strings::graphic][strings::value] - .asString()).length()) { - verification_result = MessageHelper::VerifyImage( - (*message_)[strings::msg_params][strings::graphic], - app, - application_manager_); - if (mobile_apis::Result::SUCCESS != verification_result) { - LOG4CXX_ERROR(logger_, "Image verification failed."); - SendResponse(false, verification_result); - return; - } - } - - if ((*message_)[strings::msg_params].keyExists(strings::secondary_graphic)) { - verification_result = MessageHelper::VerifyImage( - (*message_)[strings::msg_params][strings::secondary_graphic], - app, - application_manager_); - if (mobile_apis::Result::SUCCESS != verification_result) { - LOG4CXX_ERROR(logger_, "Image verification failed."); - SendResponse(false, verification_result); - return; - } - } smart_objects::SmartObject msg_params = smart_objects::SmartObject(smart_objects::SmartType_Map); diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/update_turn_list_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/update_turn_list_request.cc index 69379135b5..f28656514f 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/update_turn_list_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/update_turn_list_request.cc @@ -95,22 +95,6 @@ void UpdateTurnListRequest::Run() { return; } - if ((*message_)[strings::msg_params].keyExists(strings::turn_list)) { - smart_objects::SmartObject& turn_list_array = - ((*message_)[strings::msg_params][strings::turn_list]); - for (uint32_t i = 0; i < turn_list_array.length(); ++i) { - if ((turn_list_array[i].keyExists(strings::turn_icon)) && - (mobile_apis::Result::SUCCESS != - MessageHelper::VerifyImage(turn_list_array[i][strings::turn_icon], - app, - application_manager_))) { - LOG4CXX_ERROR(logger_, - "MessageHelper::VerifyImage return INVALID_DATA"); - SendResponse(false, mobile_apis::Result::INVALID_DATA); - return; - } - } - } smart_objects::SmartObject msg_params = smart_objects::SmartObject(smart_objects::SmartType_Map); -- cgit v1.2.1 From 25e00ebf5cb3dfa127a1f56a6bdead72ed0a10a9 Mon Sep 17 00:00:00 2001 From: Ashwin Karemore Date: Mon, 18 Jun 2018 16:47:40 +0200 Subject: UT fix after removing image check --- .../commands/mobile/add_command_request_test.cc | 20 ++++++ .../commands/mobile/send_location_request_test.cc | 14 +---- .../commands/mobile/set_global_properties_test.cc | 73 +++++++++++++++++++++- .../test/commands/mobile/show_test.cc | 10 --- .../mobile/update_turn_list_request_test.cc | 7 --- 5 files changed, 93 insertions(+), 31 deletions(-) diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/add_command_request_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/add_command_request_test.cc index ea1a0fafed..fedb4966f5 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/add_command_request_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/add_command_request_test.cc @@ -263,6 +263,26 @@ TEST_F(AddCommandRequestTest, Run_ImageVerificationFailed_EXPECT_INVALID_DATA) { request_ptr->Run(); } +TEST_F(AddCommandRequestTest, Run_ImageVerificationFailed_EXPECT_WARNINGS) { + CreateBasicParamsUIRequest(); + SmartObject& msg_params = (*msg_)[strings::msg_params]; + SmartObject& image = msg_params[cmd_icon]; + EXPECT_CALL(mock_message_helper_, VerifyImage(image, _, _)) + .WillOnce(Return(mobile_apis::Result::WARNINGS)); + + am::CommandsMap commands_map; + EXPECT_CALL(*mock_app_, commands_map()) + .WillRepeatedly(Return(DataAccessor( + commands_map, lock_ptr_))); + EXPECT_CALL( + mock_rpc_service_, + ManageHMICommand(HMIResultCodeIs(hmi_apis::FunctionID::UI_AddCommand))) + .WillOnce(Return(true)); + utils::SharedPtr request_ptr = + CreateCommand(msg_); + request_ptr->Run(); +} + TEST_F(AddCommandRequestTest, Run_MenuNameHasSyntaxError_EXPECT_INVALID_DATA) { CreateBasicParamsUIRequest(); SmartObject& msg_params = (*msg_)[strings::msg_params]; diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/send_location_request_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/send_location_request_test.cc index bf75e651c6..4a4fa88f33 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/send_location_request_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/send_location_request_test.cc @@ -306,27 +306,17 @@ TEST_F(SendLocationRequestTest, Run_LocationImageValid_Success) { SmartObject(smart_objects::SmartType_Map); (*message_)[strings::msg_params][strings::location_image][strings::value] = "1"; - EXPECT_CALL( - mock_message_helper_, - VerifyImage( - (*message_)[strings::msg_params][strings::location_image], _, _)) - .WillOnce(Return(mobile_apis::Result::SUCCESS)); FinishSetup(); command_->Run(); } -TEST_F(SendLocationRequestTest, Run_LocationImageInvalid_Cancelled) { +TEST_F(SendLocationRequestTest, Run_LocationImageInvalid_Warnings) { InitialSetup(message_); (*message_)[strings::msg_params][strings::location_image] = SmartObject(smart_objects::SmartType_Map); (*message_)[strings::msg_params][strings::location_image][strings::value] = "1"; - EXPECT_CALL( - mock_message_helper_, - VerifyImage( - (*message_)[strings::msg_params][strings::location_image], _, _)) - .WillOnce(Return(mobile_apis::Result::ABORTED)); - FinishSetupCancelled(mobile_apis::Result::ABORTED); + FinishSetup(); command_->Run(); } diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/set_global_properties_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/set_global_properties_test.cc index ff85180ad6..4ee5af8279 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/set_global_properties_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/set_global_properties_test.cc @@ -643,7 +643,33 @@ TEST_F(SetGlobalPropertiesRequestTest, Run_NoVR_SUCCESS) { GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_UI)) .WillByDefault(Return(am::HmiInterfaces::STATE_NOT_AVAILABLE)); - std::shared_ptr command( + SharedPtr command( + CreateCommand(msg)); + + command->Run(); +} + +TEST_F(SetGlobalPropertiesRequestTest, Run_VRCouldNotGenerate_INVALID_DATA) { + MessageSharedPtr msg = CreateMsgParams(); + SmartObject keyboard_properties(smart_objects::SmartType_Map); + (*msg)[am::strings::msg_params][am::hmi_request::keyboard_properties] = + keyboard_properties; + SmartObject menu_title("Menu_Title"); + (*msg)[am::strings::msg_params][am::hmi_request::menu_title] = menu_title; + + EXPECT_CALL(app_mngr_, application(kConnectionKey)) + .WillOnce(Return(mock_app_)); + EXPECT_CALL(app_mngr_, RemoveAppFromTTSGlobalPropertiesList(kConnectionKey)); + SmartObject* vr_help_title = NULL; + CommandsMap commands_map; + SmartObject empty_msg(smart_objects::SmartType_Map); + commands_map.insert(std::pair(1u, &empty_msg)); + DataAccessor accessor(commands_map, lock_ptr_); + EXPECT_CALL(*mock_app_, commands_map()).WillOnce(Return(accessor)); + EXPECT_CALL(*mock_app_, vr_help_title()).WillOnce(Return(vr_help_title)); + EXPECT_CALL(*mock_app_, set_menu_title(_)).Times(0); + + SharedPtr command( CreateCommand(msg)); command->Run(); @@ -700,7 +726,50 @@ TEST_F(SetGlobalPropertiesRequestTest, Run_NoVRNoDataDefaultCreated_SUCCESS) { GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_UI)) .WillByDefault(Return(am::HmiInterfaces::STATE_NOT_AVAILABLE)); - std::shared_ptr command( + SharedPtr command( + CreateCommand(msg)); + + command->Run(); +} + +TEST_F(SetGlobalPropertiesRequestTest, Run_NoVRNoDataFromSynonyms_SUCCESS) { + MessageSharedPtr msg = CreateMsgParams(); + SmartObject keyboard_properties(smart_objects::SmartType_Map); + (*msg)[am::strings::msg_params][am::hmi_request::keyboard_properties] = + keyboard_properties; + + EXPECT_CALL(app_mngr_, application(kConnectionKey)) + .WillOnce(Return(mock_app_)); + EXPECT_CALL(app_mngr_, RemoveAppFromTTSGlobalPropertiesList(kConnectionKey)); + SmartObject vr_help_title(smart_objects::SmartType_Null); + EXPECT_CALL(*mock_app_, vr_help_title()) + .Times(2) + .WillRepeatedly(Return(&vr_help_title)); + + CommandsMap commands_map; + DataAccessor accessor(commands_map, lock_ptr_); + EXPECT_CALL(*mock_app_, commands_map()).WillOnce(Return(accessor)); + SmartObject vr_help_array(smart_objects::SmartType_Array); + vr_help_array[0] = SmartObject(smart_objects::SmartType_Map); + vr_help_array[0][am::strings::text] = kText; + vr_help_array[0][am::strings::position] = kPosition; + SmartObject vr_synonyms(smart_objects::SmartType_Array); + vr_synonyms[0] = vr_help_array; + const CustomString name("name"); + EXPECT_CALL(*mock_app_, name()).WillOnce(ReturnRef(name)); + EXPECT_CALL(*mock_app_, set_vr_help_title(SmartObject(name))); + EXPECT_CALL(*mock_app_, set_menu_title(_)).Times(0); + EXPECT_CALL(*mock_app_, set_menu_icon(_)).Times(0); + EXPECT_CALL(*mock_app_, set_keyboard_props(keyboard_properties)); + EXPECT_CALL(*mock_app_, app_id()).WillOnce(Return(kAppId)); + EXPECT_CALL( + mock_hmi_interfaces_, + GetInterfaceFromFunction(hmi_apis::FunctionID::UI_SetGlobalProperties)) + .WillOnce(Return(am::HmiInterfaces::HMI_INTERFACE_UI)); + ON_CALL(mock_hmi_interfaces_, + GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_UI)) + .WillByDefault(Return(am::HmiInterfaces::STATE_NOT_AVAILABLE)); + SharedPtr command( CreateCommand(msg)); command->Run(); diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/show_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/show_test.cc index 1ea1300c35..f32aaa16c8 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/show_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/show_test.cc @@ -339,8 +339,6 @@ TEST_F(ShowRequestTest, Run_Graphic_SUCCESS) { EXPECT_CALL(app_mngr_, application(kConnectionKey)) .WillOnce(Return(mock_app_)); - EXPECT_CALL(mock_message_helper_, VerifyImage(graphic, _, _)) - .WillOnce(Return(mobile_apis::Result::SUCCESS)); EXPECT_CALL(*mock_app_, app_id()).WillOnce(Return(kAppId)); msg_params[am::strings::app_id] = kAppId; @@ -366,8 +364,6 @@ TEST_F(ShowRequestTest, Run_Graphic_Canceled) { EXPECT_CALL(app_mngr_, application(kConnectionKey)) .WillOnce(Return(mock_app_)); - EXPECT_CALL(mock_message_helper_, VerifyImage(graphic, _, _)) - .WillOnce(Return(mobile_apis::Result::ABORTED)); EXPECT_CALL(mock_rpc_service_, ManageMobileCommand(_, _)); EXPECT_CALL(*mock_app_, app_id()).Times(0); EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_)).Times(0); @@ -389,7 +385,6 @@ TEST_F(ShowRequestTest, Run_Graphic_WrongSyntax) { EXPECT_CALL(app_mngr_, application(kConnectionKey)) .WillOnce(Return(mock_app_)); - EXPECT_CALL(mock_message_helper_, VerifyImage(_, _, _)).Times(0); EXPECT_CALL(mock_rpc_service_, ManageMobileCommand(_, _)); EXPECT_CALL(*mock_app_, app_id()).Times(0); @@ -412,8 +407,6 @@ TEST_F(ShowRequestTest, Run_SecondaryGraphic_SUCCESS) { EXPECT_CALL(app_mngr_, application(kConnectionKey)) .WillOnce(Return(mock_app_)); - EXPECT_CALL(mock_message_helper_, VerifyImage(graphic, _, _)) - .WillOnce(Return(mobile_apis::Result::SUCCESS)); EXPECT_CALL(*mock_app_, app_id()).WillOnce(Return(kAppId)); msg_params[am::strings::app_id] = kAppId; @@ -438,8 +431,6 @@ TEST_F(ShowRequestTest, Run_SecondaryGraphic_Canceled) { EXPECT_CALL(app_mngr_, application(kConnectionKey)) .WillOnce(Return(mock_app_)); - EXPECT_CALL(mock_message_helper_, VerifyImage(graphic, _, _)) - .WillOnce(Return(mobile_apis::Result::ABORTED)); EXPECT_CALL(mock_rpc_service_, ManageMobileCommand(_, _)); EXPECT_CALL(*mock_app_, app_id()).Times(0); @@ -462,7 +453,6 @@ TEST_F(ShowRequestTest, Run_SecondaryGraphic_WrongSyntax) { EXPECT_CALL(app_mngr_, application(kConnectionKey)) .WillOnce(Return(mock_app_)); - EXPECT_CALL(mock_message_helper_, VerifyImage(graphic, _, _)).Times(0); EXPECT_CALL(mock_rpc_service_, ManageMobileCommand(_, _)); EXPECT_CALL(*mock_app_, app_id()).Times(0); diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/update_turn_list_request_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/update_turn_list_request_test.cc index acb421af6b..043344f7d7 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/update_turn_list_request_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/update_turn_list_request_test.cc @@ -202,13 +202,6 @@ TEST_F(UpdateTurnListRequestTest, Run_ValidTurnList_SUCCESS) { Ref(app_mngr_))) .WillOnce(Return(mobile_result::SUCCESS)); - EXPECT_CALL( - mock_message_helper_, - VerifyImage( - (*command_msg_)[am::strings::msg_params][am::strings::turn_list][0] - [am::strings::turn_icon], - Eq(mock_app), - Ref(app_mngr_))).WillOnce(Return(mobile_result::SUCCESS)); EXPECT_CALL(mock_message_helper_, SubscribeApplicationToSoftButton(_, _, kFunctionId)); -- cgit v1.2.1 From 32c4573733a9660e05d94ed6c1a192beeda177c1 Mon Sep 17 00:00:00 2001 From: Ashwin Karemore Date: Thu, 28 Jun 2018 15:35:58 +0200 Subject: fix for invalid image rpc in create interaction choice set request --- .../resumption/resume_ctrl_impl.h | 9 ---- .../mobile/create_interaction_choice_set_request.h | 1 + .../create_interaction_choice_set_request.cc | 54 ++++++++++++++++++---- .../src/message_helper/message_helper.cc | 17 ------- .../src/resumption/resume_ctrl_impl.cc | 24 +--------- 5 files changed, 46 insertions(+), 59 deletions(-) diff --git a/src/components/application_manager/include/application_manager/resumption/resume_ctrl_impl.h b/src/components/application_manager/include/application_manager/resumption/resume_ctrl_impl.h index 17aabb6d60..b3aa5d099c 100644 --- a/src/components/application_manager/include/application_manager/resumption/resume_ctrl_impl.h +++ b/src/components/application_manager/include/application_manager/resumption/resume_ctrl_impl.h @@ -398,15 +398,6 @@ class ResumeCtrlImpl : public ResumeCtrl, bool CheckAppRestrictions(app_mngr::ApplicationConstSharedPtr application, const smart_objects::SmartObject& saved_app); - /** - * @brief CheckIcons allows to check application icons - * @param application application under resumtion application - * @param json_object - * @return true in case icons exists, false otherwise - */ - bool CheckIcons(app_mngr::ApplicationSharedPtr application, - smart_objects::SmartObject& obj); - /** * @brief CheckDelayAfterIgnOn should check if SDL was started less * then N seconds ago. N will be readed from profile. diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/create_interaction_choice_set_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/create_interaction_choice_set_request.h index 950c295072..12b075af7a 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/create_interaction_choice_set_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/create_interaction_choice_set_request.h @@ -128,6 +128,7 @@ class CreateInteractionChoiceSetRequest int32_t choice_set_id_; size_t expected_chs_count_; size_t received_chs_count_; + bool should_send_warnings; /** * @brief Flag for stop sending VR commands to HMI, in case one of responses 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 89ae0c1aac..767a4e2c27 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 @@ -42,6 +42,7 @@ #include "utils/gen_hash.h" #include "utils/helpers.h" +#define INVALID_IMG_WARNING_INFO "Requested image(s) not found." namespace sdl_rpc_plugin { using namespace application_manager; @@ -95,6 +96,37 @@ void CreateInteractionChoiceSetRequest::Run() { SendResponse(false, result); return; } + + + should_send_warnings = false; + for (uint32_t i = 0; + i < (*message_)[strings::msg_params][strings::choice_set].length(); + ++i) { + Result::eType verification_result_image = Result::SUCCESS; + Result::eType verification_result_secondary_image = Result::SUCCESS; + if ((*message_)[strings::msg_params][strings::choice_set][i].keyExists( + strings::image)) { + verification_result_image = MessageHelper::VerifyImage( + (*message_)[strings::msg_params][strings::choice_set][i] + [strings::image], + app, + application_manager_); + } + if ((*message_)[strings::msg_params][strings::choice_set][i].keyExists( + strings::secondary_image)) { + verification_result_secondary_image = MessageHelper::VerifyImage( + (*message_)[strings::msg_params][strings::choice_set][i] + [strings::secondary_image], + app, + application_manager_); + } + if (verification_result_image == Result::INVALID_DATA || + verification_result_secondary_image == Result::INVALID_DATA) { + should_send_warnings = true; + break; + } + } + uint32_t grammar_id = application_manager_.GenerateGrammarID(); (*message_)[strings::msg_params][strings::grammar_id] = grammar_id; app->AddChoiceSet(choice_set_id_, (*message_)[strings::msg_params]); @@ -405,16 +437,18 @@ void CreateInteractionChoiceSetRequest::DeleteChoices() { } void CreateInteractionChoiceSetRequest::OnAllHMIResponsesReceived() { - LOG4CXX_AUTO_TRACE(logger_); - - if (!error_from_hmi_) { - SendResponse(true, mobile_apis::Result::SUCCESS); - } else { - DeleteChoices(); - } - - application_manager_.TerminateRequest( - connection_key(), correlation_id(), function_id()); + LOG4CXX_AUTO_TRACE(logger_); + + if (!error_from_hmi_ && should_send_warnings) { + SendResponse(true, mobile_apis::Result::WARNINGS,INVALID_IMG_WARNING_INFO); + } else if (!error_from_hmi_) { + SendResponse(true, mobile_apis::Result::SUCCESS); + } else { + DeleteChoices(); + } + + application_manager_.TerminateRequest( + connection_key(), correlation_id(), function_id()); } } // namespace commands diff --git a/src/components/application_manager/src/message_helper/message_helper.cc b/src/components/application_manager/src/message_helper/message_helper.cc index 978724a671..962fb767dc 100644 --- a/src/components/application_manager/src/message_helper/message_helper.cc +++ b/src/components/application_manager/src/message_helper/message_helper.cc @@ -94,9 +94,6 @@ bool ValidateSoftButtons(smart_objects::SmartObject& soft_buttons) { // Check if image parameter is valid if (button.keyExists(strings::image)) { SmartObject& buttonImage = button[strings::image]; - - // Image name must not be empty and must not contain incorrect - // character if (false == MessageHelper::VerifySoftButtonString( buttonImage[strings::value].asString())) { return false; @@ -2778,13 +2775,6 @@ mobile_apis::Result::eType MessageHelper::ProcessSoftButtons( if (request_soft_buttons[i].keyExists(strings::text)) { request_soft_buttons[i].erase(strings::text); } - - if ((!request_soft_buttons[i].keyExists(strings::image) || - (Result::SUCCESS != - VerifyImage( - request_soft_buttons[i][strings::image], app, app_mngr)))) { - return Result::INVALID_DATA; - } break; } case SoftButtonType::SBT_TEXT: { @@ -2805,13 +2795,6 @@ mobile_apis::Result::eType MessageHelper::ProcessSoftButtons( request_soft_buttons[i][strings::text].asString())))) { return Result::INVALID_DATA; } - - if ((!request_soft_buttons[i].keyExists(strings::image) || - (Result::SUCCESS != - VerifyImage( - request_soft_buttons[i][strings::image], app, app_mngr)))) { - return Result::INVALID_DATA; - } break; } default: { diff --git a/src/components/application_manager/src/resumption/resume_ctrl_impl.cc b/src/components/application_manager/src/resumption/resume_ctrl_impl.cc index 42dc335878..caa04c1ada 100644 --- a/src/components/application_manager/src/resumption/resume_ctrl_impl.cc +++ b/src/components/application_manager/src/resumption/resume_ctrl_impl.cc @@ -478,20 +478,7 @@ bool ResumeCtrlImpl::CheckPersistenceFilesForResumption( const std::string& device_mac = application->mac_address(); bool result = resumption_storage_->GetSavedApplication( application->policy_app_id(), device_mac, saved_app); - if (result) { - if (saved_app.keyExists(strings::application_commands)) { - if (!CheckIcons(application, saved_app[strings::application_commands])) { - return false; - } - } - if (saved_app.keyExists(strings::application_choice_sets)) { - if (!CheckIcons(application, - saved_app[strings::application_choice_sets])) { - return false; - } - } - } - return true; + return result; } bool ResumeCtrlImpl::CheckApplicationHash(ApplicationSharedPtr application, @@ -779,15 +766,6 @@ bool ResumeCtrlImpl::CheckAppRestrictions( return result; } -bool ResumeCtrlImpl::CheckIcons(ApplicationSharedPtr application, - smart_objects::SmartObject& obj) { - using namespace smart_objects; - LOG4CXX_AUTO_TRACE(logger_); - const mobile_apis::Result::eType verify_images = - MessageHelper::VerifyImageFiles(obj, application, application_manager_); - return mobile_apis::Result::INVALID_DATA != verify_images; -} - bool ResumeCtrlImpl::CheckDelayAfterIgnOn() { using namespace date_time; LOG4CXX_AUTO_TRACE(logger_); -- cgit v1.2.1 From fa700ca1122a7c5261170c35310e4d61f9deda27 Mon Sep 17 00:00:00 2001 From: Ashwin Karemore Date: Fri, 29 Jun 2018 15:50:57 +0200 Subject: fix build after resolving conflict --- .../sdl_rpc_plugin/test/commands/mobile/add_command_request_test.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/add_command_request_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/add_command_request_test.cc index fedb4966f5..94338aae67 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/add_command_request_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/add_command_request_test.cc @@ -272,10 +272,10 @@ TEST_F(AddCommandRequestTest, Run_ImageVerificationFailed_EXPECT_WARNINGS) { am::CommandsMap commands_map; EXPECT_CALL(*mock_app_, commands_map()) - .WillRepeatedly(Return(DataAccessor( - commands_map, lock_ptr_))); + .WillRepeatedly(Return( + DataAccessor(commands_map, lock_ptr_))); EXPECT_CALL( - mock_rpc_service_, + mock_rpc_service_, ManageHMICommand(HMIResultCodeIs(hmi_apis::FunctionID::UI_AddCommand))) .WillOnce(Return(true)); utils::SharedPtr request_ptr = -- cgit v1.2.1 From 58c57fed825fb73a01bceb17c2a2b48473fff6f2 Mon Sep 17 00:00:00 2001 From: Ashwin Karemore Date: Fri, 29 Jun 2018 16:32:30 +0200 Subject: fix for show RPC UT --- .../test/commands/mobile/show_test.cc | 27 +++++++++++++++------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/show_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/show_test.cc index f32aaa16c8..f582072398 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/show_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/show_test.cc @@ -351,7 +351,7 @@ TEST_F(ShowRequestTest, Run_Graphic_SUCCESS) { command->Run(); } -TEST_F(ShowRequestTest, Run_Graphic_Canceled) { +TEST_F(ShowRequestTest, Run_Graphic_Not_Verified) { MessageSharedPtr msg = CreateMsgParams(); SmartObject msg_params(smart_objects::SmartType_Map); @@ -364,11 +364,17 @@ TEST_F(ShowRequestTest, Run_Graphic_Canceled) { EXPECT_CALL(app_mngr_, application(kConnectionKey)) .WillOnce(Return(mock_app_)); + EXPECT_CALL(mock_message_helper_, VerifyImage(graphic, _, _)) + .Times(0); EXPECT_CALL(mock_rpc_service_, ManageMobileCommand(_, _)); - EXPECT_CALL(*mock_app_, app_id()).Times(0); - EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_)).Times(0); - EXPECT_CALL(*mock_app_, set_show_command(msg_params)).Times(0); + EXPECT_CALL(*mock_app_, app_id()).WillOnce(Return(kAppId)); + msg_params[am::strings::app_id] = kAppId; + msg_params[am::hmi_request::show_strings] = + smart_objects::SmartObject(smart_objects::SmartType_Array); + + EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_)); + EXPECT_CALL(*mock_app_, set_show_command(msg_params)); command->Run(); } @@ -418,7 +424,7 @@ TEST_F(ShowRequestTest, Run_SecondaryGraphic_SUCCESS) { command->Run(); } -TEST_F(ShowRequestTest, Run_SecondaryGraphic_Canceled) { +TEST_F(ShowRequestTest, Run_SecondaryGraphic_Not_Verified) { MessageSharedPtr msg = CreateMsgParams(); SmartObject msg_params(smart_objects::SmartType_Map); @@ -431,11 +437,16 @@ TEST_F(ShowRequestTest, Run_SecondaryGraphic_Canceled) { EXPECT_CALL(app_mngr_, application(kConnectionKey)) .WillOnce(Return(mock_app_)); + EXPECT_CALL(mock_message_helper_, VerifyImage(graphic, _, _)) + .Times(0); EXPECT_CALL(mock_rpc_service_, ManageMobileCommand(_, _)); - EXPECT_CALL(*mock_app_, app_id()).Times(0); + EXPECT_CALL(*mock_app_, app_id()).WillOnce(Return(kAppId)); - EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_)).Times(0); - EXPECT_CALL(*mock_app_, set_show_command(msg_params)).Times(0); + msg_params[am::strings::app_id] = kAppId; + msg_params[am::hmi_request::show_strings] = + smart_objects::SmartObject(smart_objects::SmartType_Array); + EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_)); + EXPECT_CALL(*mock_app_, set_show_command(msg_params)); command->Run(); } -- cgit v1.2.1 From 604057538b085ec79b766bdf6bdf8a25c9258013 Mon Sep 17 00:00:00 2001 From: Ashwin Karemore Date: Mon, 2 Jul 2018 15:37:59 +0200 Subject: revert image check and return Warning or invalid data --- .../include/application_manager/message_helper.h | 4 +- .../resumption/resume_ctrl_impl.h | 9 +++ .../src/commands/mobile/add_command_request.cc | 13 ++++ .../create_interaction_choice_set_request.cc | 29 +++++---- .../commands/mobile/perform_interaction_request.cc | 10 +++ .../src/commands/mobile/send_location_request.cc | 13 ++++ .../mobile/set_global_properties_request.cc | 26 ++++++++ .../commands/mobile/show_constant_tbt_request.cc | 20 ++++++ .../src/commands/mobile/show_request.cc | 26 ++++++++ .../commands/mobile/update_turn_list_request.cc | 16 +++++ .../commands/mobile/send_location_request_test.cc | 16 ++++- .../commands/mobile/set_global_properties_test.cc | 2 +- .../test/commands/mobile/show_test.cc | 33 +++++----- .../mobile/update_turn_list_request_test.cc | 7 +++ .../src/message_helper/message_helper.cc | 72 +++++++++++++--------- .../src/resumption/resume_ctrl_impl.cc | 24 +++++++- .../test/message_helper/message_helper_test.cc | 12 ++-- 17 files changed, 262 insertions(+), 70 deletions(-) diff --git a/src/components/application_manager/include/application_manager/message_helper.h b/src/components/application_manager/include/application_manager/message_helper.h index 9559c2007e..b1bf3bd567 100644 --- a/src/components/application_manager/include/application_manager/message_helper.h +++ b/src/components/application_manager/include/application_manager/message_helper.h @@ -615,7 +615,7 @@ class MessageHelper { * @param app current application * @return verification result */ - static mobile_apis::Result::eType VerifyImageApplyPath( + static void ApplyImagePath( smart_objects::SmartObject& image, ApplicationConstSharedPtr app, ApplicationManager& app_mngr); @@ -663,7 +663,7 @@ class MessageHelper { * @return returns FALSE if string contains incorrect character or * string is empty otherwise returns TRUE */ - static bool VerifySoftButtonString(const std::string& str); + static bool VerifyString(const std::string& str); static mobile_apis::Result::eType ProcessSoftButtons( smart_objects::SmartObject& message_params, diff --git a/src/components/application_manager/include/application_manager/resumption/resume_ctrl_impl.h b/src/components/application_manager/include/application_manager/resumption/resume_ctrl_impl.h index b3aa5d099c..17aabb6d60 100644 --- a/src/components/application_manager/include/application_manager/resumption/resume_ctrl_impl.h +++ b/src/components/application_manager/include/application_manager/resumption/resume_ctrl_impl.h @@ -398,6 +398,15 @@ class ResumeCtrlImpl : public ResumeCtrl, bool CheckAppRestrictions(app_mngr::ApplicationConstSharedPtr application, const smart_objects::SmartObject& saved_app); + /** + * @brief CheckIcons allows to check application icons + * @param application application under resumtion application + * @param json_object + * @return true in case icons exists, false otherwise + */ + bool CheckIcons(app_mngr::ApplicationSharedPtr application, + smart_objects::SmartObject& obj); + /** * @brief CheckDelayAfterIgnOn should check if SDL was started less * then N seconds ago. N will be readed from profile. diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/add_command_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/add_command_request.cc index ab9baea7ef..155f819761 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/add_command_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/add_command_request.cc @@ -90,6 +90,19 @@ void AddCommandRequest::Run() { return; } + if ((*message_)[strings::msg_params].keyExists(strings::cmd_icon)) { + mobile_apis::Result::eType verification_result = MessageHelper::VerifyImage( + (*message_)[strings::msg_params][strings::cmd_icon], + app, + application_manager_); + + if (mobile_apis::Result::INVALID_DATA == verification_result) { + LOG4CXX_ERROR( + logger_, "MessageHelper::VerifyImage return " << verification_result); + SendResponse(false, verification_result); + return; + } + } if (!((*message_)[strings::msg_params].keyExists(strings::cmd_id))) { LOG4CXX_ERROR(logger_, "INVALID_DATA"); 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 767a4e2c27..d36eda18e1 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 @@ -122,6 +122,11 @@ void CreateInteractionChoiceSetRequest::Run() { } if (verification_result_image == Result::INVALID_DATA || verification_result_secondary_image == Result::INVALID_DATA) { + LOG4CXX_ERROR(logger_, "Image verification failed."); + SendResponse(false, Result::INVALID_DATA); + return; + } else if (verification_result_image == Result::WARNINGS || + verification_result_secondary_image == Result::WARNINGS) { should_send_warnings = true; break; } @@ -437,18 +442,18 @@ void CreateInteractionChoiceSetRequest::DeleteChoices() { } void CreateInteractionChoiceSetRequest::OnAllHMIResponsesReceived() { - LOG4CXX_AUTO_TRACE(logger_); - - if (!error_from_hmi_ && should_send_warnings) { - SendResponse(true, mobile_apis::Result::WARNINGS,INVALID_IMG_WARNING_INFO); - } else if (!error_from_hmi_) { - SendResponse(true, mobile_apis::Result::SUCCESS); - } else { - DeleteChoices(); - } - - application_manager_.TerminateRequest( - connection_key(), correlation_id(), function_id()); + LOG4CXX_AUTO_TRACE(logger_); + + if (!error_from_hmi_ && should_send_warnings) { + SendResponse(true, mobile_apis::Result::WARNINGS,INVALID_IMG_WARNING_INFO); + } else if (!error_from_hmi_) { + SendResponse(true, mobile_apis::Result::SUCCESS); + } else { + DeleteChoices(); + } + + application_manager_.TerminateRequest( + connection_key(), correlation_id(), function_id()); } } // namespace commands 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 fb3516c24c..76dd30525a 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 @@ -164,6 +164,16 @@ void PerformInteractionRequest::Run() { return; } + if (msg_params.keyExists(strings::vr_help)) { + if (mobile_apis::Result::INVALID_DATA == + MessageHelper::VerifyImageVrHelpItems( + msg_params[strings::vr_help], app, application_manager_)) { + LOG4CXX_ERROR(logger_, + "Verification of " << strings::vr_help << " failed."); + SendResponse(false, mobile_apis::Result::INVALID_DATA); + return; + } + } if (IsWhiteSpaceExist()) { LOG4CXX_ERROR(logger_, diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/send_location_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/send_location_request.cc index e9e11b3f24..2719d0674d 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/send_location_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/send_location_request.cc @@ -117,6 +117,19 @@ void SendLocationRequest::Run() { return; } + if (msg_params.keyExists(strings::location_image)) { + mobile_apis::Result::eType verification_result = + mobile_apis::Result::SUCCESS; + verification_result = MessageHelper::VerifyImage( + (*message_)[strings::msg_params][strings::location_image], + app, + application_manager_); + if (mobile_apis::Result::INVALID_DATA == verification_result) { + LOG4CXX_ERROR(logger_, "VerifyImage INVALID_DATA!"); + SendResponse(false, verification_result); + return; + } + } SmartObject request_msg_params = SmartObject(smart_objects::SmartType_Map); request_msg_params = msg_params; diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_global_properties_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_global_properties_request.cc index 0e8c4fcbfc..0c217b6b4f 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_global_properties_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_global_properties_request.cc @@ -88,6 +88,32 @@ void SetGlobalPropertiesRequest::Run() { return; } + mobile_apis::Result::eType verification_result = mobile_apis::Result::SUCCESS; + + if ((*message_)[strings::msg_params].keyExists(strings::menu_icon)) { + verification_result = MessageHelper::VerifyImage( + (*message_)[strings::msg_params][strings::menu_icon], + app, + application_manager_); + if (mobile_apis::Result::INVALID_DATA == verification_result) { + LOG4CXX_ERROR( + logger_, "MessageHelper::VerifyImage return " << verification_result); + SendResponse(false, verification_result); + return; + } + } + // Check for image file(s) in vrHelpItem + if ((*message_)[strings::msg_params].keyExists(strings::vr_help)) { + if (mobile_apis::Result::INVALID_DATA == + MessageHelper::VerifyImageVrHelpItems( + (*message_)[strings::msg_params][strings::vr_help], + app, + application_manager_)) { + LOG4CXX_ERROR(logger_, "MessageHelper::VerifyImage return INVALID_DATA!"); + SendResponse(false, mobile_apis::Result::INVALID_DATA); + return; + } + } if (IsWhiteSpaceExist()) { LOG4CXX_ERROR(logger_, "White spaces found"); diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/show_constant_tbt_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/show_constant_tbt_request.cc index 1e5767258d..3b2936e6cd 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/show_constant_tbt_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/show_constant_tbt_request.cc @@ -101,6 +101,26 @@ void ShowConstantTBTRequest::Run() { return; } + mobile_apis::Result::eType verification_result = mobile_apis::Result::SUCCESS; + if (msg_params.keyExists(strings::turn_icon)) { + verification_result = MessageHelper::VerifyImage( + msg_params[strings::turn_icon], app, application_manager_); + if (mobile_apis::Result::INVALID_DATA == verification_result) { + LOG4CXX_ERROR(logger_, "VerifyImage INVALID_DATA!"); + SendResponse(false, verification_result); + return; + } + } + + if (msg_params.keyExists(strings::next_turn_icon)) { + verification_result = MessageHelper::VerifyImage( + msg_params[strings::next_turn_icon], app, application_manager_); + if (mobile_apis::Result::INVALID_DATA == verification_result) { + LOG4CXX_ERROR(logger_, "VerifyImage INVALID_DATA!"); + SendResponse(false, verification_result); + return; + } + } msg_params[strings::app_id] = app->app_id(); diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/show_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/show_request.cc index 25b96d6aab..e0c3e1da9a 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/show_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/show_request.cc @@ -135,6 +135,32 @@ void ShowRequest::Run() { return; } + mobile_apis::Result::eType verification_result = mobile_apis::Result::SUCCESS; + if (((*message_)[strings::msg_params].keyExists(strings::graphic)) && + ((*message_)[strings::msg_params][strings::graphic][strings::value] + .asString()).length()) { + verification_result = MessageHelper::VerifyImage( + (*message_)[strings::msg_params][strings::graphic], + app, + application_manager_); + if (mobile_apis::Result::INVALID_DATA == verification_result) { + LOG4CXX_ERROR(logger_, "Image verification failed."); + SendResponse(false, verification_result); + return; + } + } + + if ((*message_)[strings::msg_params].keyExists(strings::secondary_graphic)) { + verification_result = MessageHelper::VerifyImage( + (*message_)[strings::msg_params][strings::secondary_graphic], + app, + application_manager_); + if (mobile_apis::Result::INVALID_DATA == verification_result) { + LOG4CXX_ERROR(logger_, "Image verification failed."); + SendResponse(false, verification_result); + return; + } + } smart_objects::SmartObject msg_params = smart_objects::SmartObject(smart_objects::SmartType_Map); diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/update_turn_list_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/update_turn_list_request.cc index f28656514f..c04ad34f5f 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/update_turn_list_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/update_turn_list_request.cc @@ -95,6 +95,22 @@ void UpdateTurnListRequest::Run() { return; } + if ((*message_)[strings::msg_params].keyExists(strings::turn_list)) { + smart_objects::SmartObject& turn_list_array = + ((*message_)[strings::msg_params][strings::turn_list]); + for (uint32_t i = 0; i < turn_list_array.length(); ++i) { + if ((turn_list_array[i].keyExists(strings::turn_icon)) && + (mobile_apis::Result::INVALID_DATA == + MessageHelper::VerifyImage(turn_list_array[i][strings::turn_icon], + app, + application_manager_))) { + LOG4CXX_ERROR(logger_, + "MessageHelper::VerifyImage return INVALID_DATA"); + SendResponse(false, mobile_apis::Result::INVALID_DATA); + return; + } + } + } smart_objects::SmartObject msg_params = smart_objects::SmartObject(smart_objects::SmartType_Map); diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/send_location_request_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/send_location_request_test.cc index 4a4fa88f33..ebbd633912 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/send_location_request_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/send_location_request_test.cc @@ -306,17 +306,27 @@ TEST_F(SendLocationRequestTest, Run_LocationImageValid_Success) { SmartObject(smart_objects::SmartType_Map); (*message_)[strings::msg_params][strings::location_image][strings::value] = "1"; + EXPECT_CALL( + mock_message_helper_, + VerifyImage( + (*message_)[strings::msg_params][strings::location_image], _, _)) + .WillOnce(Return(mobile_apis::Result::SUCCESS)); FinishSetup(); command_->Run(); } -TEST_F(SendLocationRequestTest, Run_LocationImageInvalid_Warnings) { +TEST_F(SendLocationRequestTest, Run_LocationImageInvalid_Cancelled) { InitialSetup(message_); (*message_)[strings::msg_params][strings::location_image] = SmartObject(smart_objects::SmartType_Map); (*message_)[strings::msg_params][strings::location_image][strings::value] = - "1"; - FinishSetup(); + " 1"; + EXPECT_CALL( + mock_message_helper_, + VerifyImage( + (*message_)[strings::msg_params][strings::location_image], _, _)) + .WillOnce(Return(mobile_apis::Result::INVALID_DATA)); + FinishSetupCancelled(mobile_apis::Result::INVALID_DATA); command_->Run(); } diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/set_global_properties_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/set_global_properties_test.cc index 4ee5af8279..ae82f24b61 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/set_global_properties_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/set_global_properties_test.cc @@ -496,7 +496,7 @@ TEST_F(SetGlobalPropertiesRequestTest, Run_VRBrokenMenuIcon_Canceled) { SmartObject vr_help_title("yes"); (*msg)[am::strings::msg_params][am::strings::vr_help_title] = vr_help_title; SmartObject menu_icon(smart_objects::SmartType_Map); - menu_icon[am::strings::value] = "1"; + menu_icon[am::strings::value] = " 1"; (*msg)[am::strings::msg_params][am::hmi_request::menu_icon] = menu_icon; EXPECT_CALL(app_mngr_, application(kConnectionKey)) diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/show_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/show_test.cc index f582072398..ac2b59a613 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/show_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/show_test.cc @@ -339,6 +339,8 @@ TEST_F(ShowRequestTest, Run_Graphic_SUCCESS) { EXPECT_CALL(app_mngr_, application(kConnectionKey)) .WillOnce(Return(mock_app_)); + EXPECT_CALL(mock_message_helper_, VerifyImage(graphic, _, _)) + .WillOnce(Return(mobile_apis::Result::SUCCESS)); EXPECT_CALL(*mock_app_, app_id()).WillOnce(Return(kAppId)); msg_params[am::strings::app_id] = kAppId; @@ -351,7 +353,7 @@ TEST_F(ShowRequestTest, Run_Graphic_SUCCESS) { command->Run(); } -TEST_F(ShowRequestTest, Run_Graphic_Not_Verified) { +TEST_F(ShowRequestTest, Run_Graphic_Canceled) { MessageSharedPtr msg = CreateMsgParams(); SmartObject msg_params(smart_objects::SmartType_Map); @@ -365,16 +367,12 @@ TEST_F(ShowRequestTest, Run_Graphic_Not_Verified) { EXPECT_CALL(app_mngr_, application(kConnectionKey)) .WillOnce(Return(mock_app_)); EXPECT_CALL(mock_message_helper_, VerifyImage(graphic, _, _)) - .Times(0); + .WillOnce(Return(mobile_apis::Result::INVALID_DATA)); EXPECT_CALL(mock_rpc_service_, ManageMobileCommand(_, _)); - EXPECT_CALL(*mock_app_, app_id()).WillOnce(Return(kAppId)); - - msg_params[am::strings::app_id] = kAppId; - msg_params[am::hmi_request::show_strings] = - smart_objects::SmartObject(smart_objects::SmartType_Array); + EXPECT_CALL(*mock_app_, app_id()).Times(0); + EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_)).Times(0); + EXPECT_CALL(*mock_app_, set_show_command(msg_params)).Times(0); - EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_)); - EXPECT_CALL(*mock_app_, set_show_command(msg_params)); command->Run(); } @@ -391,6 +389,7 @@ TEST_F(ShowRequestTest, Run_Graphic_WrongSyntax) { EXPECT_CALL(app_mngr_, application(kConnectionKey)) .WillOnce(Return(mock_app_)); + EXPECT_CALL(mock_message_helper_, VerifyImage(_, _, _)).Times(0); EXPECT_CALL(mock_rpc_service_, ManageMobileCommand(_, _)); EXPECT_CALL(*mock_app_, app_id()).Times(0); @@ -413,6 +412,8 @@ TEST_F(ShowRequestTest, Run_SecondaryGraphic_SUCCESS) { EXPECT_CALL(app_mngr_, application(kConnectionKey)) .WillOnce(Return(mock_app_)); + EXPECT_CALL(mock_message_helper_, VerifyImage(graphic, _, _)) + .WillOnce(Return(mobile_apis::Result::SUCCESS)); EXPECT_CALL(*mock_app_, app_id()).WillOnce(Return(kAppId)); msg_params[am::strings::app_id] = kAppId; @@ -424,7 +425,7 @@ TEST_F(ShowRequestTest, Run_SecondaryGraphic_SUCCESS) { command->Run(); } -TEST_F(ShowRequestTest, Run_SecondaryGraphic_Not_Verified) { +TEST_F(ShowRequestTest, Run_SecondaryGraphic_Canceled) { MessageSharedPtr msg = CreateMsgParams(); SmartObject msg_params(smart_objects::SmartType_Map); @@ -438,15 +439,12 @@ TEST_F(ShowRequestTest, Run_SecondaryGraphic_Not_Verified) { EXPECT_CALL(app_mngr_, application(kConnectionKey)) .WillOnce(Return(mock_app_)); EXPECT_CALL(mock_message_helper_, VerifyImage(graphic, _, _)) - .Times(0); + .WillOnce(Return(mobile_apis::Result::INVALID_DATA)); EXPECT_CALL(mock_rpc_service_, ManageMobileCommand(_, _)); - EXPECT_CALL(*mock_app_, app_id()).WillOnce(Return(kAppId)); + EXPECT_CALL(*mock_app_, app_id()).Times(0); - msg_params[am::strings::app_id] = kAppId; - msg_params[am::hmi_request::show_strings] = - smart_objects::SmartObject(smart_objects::SmartType_Array); - EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_)); - EXPECT_CALL(*mock_app_, set_show_command(msg_params)); + EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_)).Times(0); + EXPECT_CALL(*mock_app_, set_show_command(msg_params)).Times(0); command->Run(); } @@ -464,6 +462,7 @@ TEST_F(ShowRequestTest, Run_SecondaryGraphic_WrongSyntax) { EXPECT_CALL(app_mngr_, application(kConnectionKey)) .WillOnce(Return(mock_app_)); + EXPECT_CALL(mock_message_helper_, VerifyImage(graphic, _, _)).Times(0); EXPECT_CALL(mock_rpc_service_, ManageMobileCommand(_, _)); EXPECT_CALL(*mock_app_, app_id()).Times(0); diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/update_turn_list_request_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/update_turn_list_request_test.cc index 043344f7d7..acb421af6b 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/update_turn_list_request_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/update_turn_list_request_test.cc @@ -202,6 +202,13 @@ TEST_F(UpdateTurnListRequestTest, Run_ValidTurnList_SUCCESS) { Ref(app_mngr_))) .WillOnce(Return(mobile_result::SUCCESS)); + EXPECT_CALL( + mock_message_helper_, + VerifyImage( + (*command_msg_)[am::strings::msg_params][am::strings::turn_list][0] + [am::strings::turn_icon], + Eq(mock_app), + Ref(app_mngr_))).WillOnce(Return(mobile_result::SUCCESS)); EXPECT_CALL(mock_message_helper_, SubscribeApplicationToSoftButton(_, _, kFunctionId)); diff --git a/src/components/application_manager/src/message_helper/message_helper.cc b/src/components/application_manager/src/message_helper/message_helper.cc index 962fb767dc..58b3552e9f 100644 --- a/src/components/application_manager/src/message_helper/message_helper.cc +++ b/src/components/application_manager/src/message_helper/message_helper.cc @@ -94,7 +94,7 @@ bool ValidateSoftButtons(smart_objects::SmartObject& soft_buttons) { // Check if image parameter is valid if (button.keyExists(strings::image)) { SmartObject& buttonImage = button[strings::image]; - if (false == MessageHelper::VerifySoftButtonString( + if (false == MessageHelper::VerifyString( buttonImage[strings::value].asString())) { return false; } @@ -2598,27 +2598,17 @@ mobile_apis::Result::eType MessageHelper::VerifyImageFiles( return mobile_apis::Result::SUCCESS; } -mobile_apis::Result::eType MessageHelper::VerifyImageApplyPath( +void MessageHelper::ApplyImagePath( smart_objects::SmartObject& image, ApplicationConstSharedPtr app, ApplicationManager& app_mngr) { - // Checking image type first: if STATIC - skip existence check, since it is - // HMI related file and it should know it location - const uint32_t image_type = image[strings::image_type].asUInt(); - mobile_apis::ImageType::eType type = - static_cast(image_type); - if (mobile_apis::ImageType::STATIC == type) { - return mobile_apis::Result::SUCCESS; - } const std::string& file_name = image[strings::value].asString(); const std::string& full_file_path = GetAppFilePath(file_name, app, app_mngr); image[strings::value] = full_file_path; - if (file_system::FileExists(full_file_path)) { - return mobile_apis::Result::SUCCESS; - } - return mobile_apis::Result::INVALID_DATA; + + return; } std::string MessageHelper::GetAppFilePath(std::string file_name, @@ -2679,19 +2669,29 @@ mobile_apis::Result::eType MessageHelper::VerifyImage( smart_objects::SmartObject& image, ApplicationConstSharedPtr app, ApplicationManager& app_mngr) { - smart_objects::SmartObject temp_image = image; + const uint32_t image_type = image[strings::image_type].asUInt(); - const mobile_apis::ImageType::eType type = + mobile_apis::ImageType::eType type = static_cast(image_type); + const std::string& file_name = image[strings::value].asString(); - const mobile_apis::Result::eType result = - VerifyImageApplyPath(temp_image, app, app_mngr); - if ((mobile_apis::Result::SUCCESS == result) && - (mobile_apis::ImageType::DYNAMIC == type)) { - image[strings::value] = temp_image[strings::value]; + + if(!VerifyString(file_name)){ + return mobile_apis::Result::INVALID_DATA; } - return result; + if (mobile_apis::ImageType::STATIC == type) { + return mobile_apis::Result::SUCCESS; + } + + ApplyImagePath(image, app, app_mngr); + + const std::string& imagePath = image[strings::value].asString(); + + if (file_system::FileExists(imagePath)) { + return mobile_apis::Result::SUCCESS; + } + return mobile_apis::Result::WARNINGS; } mobile_apis::Result::eType MessageHelper::VerifyImageVrHelpItems( @@ -2704,21 +2704,21 @@ mobile_apis::Result::eType MessageHelper::VerifyImageVrHelpItems( if (message[i].keyExists(strings::image)) { verification_result_image = VerifyImage(message[i][strings::image], app, app_mngr); - if (mobile_apis::Result::SUCCESS != verification_result_image) { - return verification_result_image; + if (mobile_apis::Result::INVALID_DATA == verification_result_image) { + break; } } } - return mobile_apis::Result::SUCCESS; + return verification_result_image; } -bool MessageHelper::VerifySoftButtonString(const std::string& str) { +bool MessageHelper::VerifyString(const std::string& str) { if ((std::string::npos != str.find_first_of("\t\n")) || (std::string::npos != str.find("\\n")) || (std::string::npos != str.find("\\t")) || (std::string::npos == str.find_first_not_of(' '))) { LOG4CXX_ERROR(logger_, - "MessageHelper::VerifySoftButtonString" + "MessageHelper::VerifyString" "string contains incorrect character"); return false; } @@ -2775,6 +2775,13 @@ mobile_apis::Result::eType MessageHelper::ProcessSoftButtons( if (request_soft_buttons[i].keyExists(strings::text)) { request_soft_buttons[i].erase(strings::text); } + + if ((!request_soft_buttons[i].keyExists(strings::image) || + (Result::INVALID_DATA == + VerifyImage( + request_soft_buttons[i][strings::image], app, app_mngr)))) { + return Result::INVALID_DATA; + } break; } case SoftButtonType::SBT_TEXT: { @@ -2782,7 +2789,7 @@ mobile_apis::Result::eType MessageHelper::ProcessSoftButtons( request_soft_buttons[i].erase(strings::image); } if ((!request_soft_buttons[i].keyExists(strings::text)) || - (!VerifySoftButtonString( + (!VerifyString( request_soft_buttons[i][strings::text].asString()))) { return Result::INVALID_DATA; } @@ -2791,10 +2798,17 @@ mobile_apis::Result::eType MessageHelper::ProcessSoftButtons( case SoftButtonType::SBT_BOTH: { if ((!request_soft_buttons[i].keyExists(strings::text)) || ((request_soft_buttons[i][strings::text].length()) && - (!VerifySoftButtonString( + (!VerifyString( request_soft_buttons[i][strings::text].asString())))) { return Result::INVALID_DATA; } + + if ((!request_soft_buttons[i].keyExists(strings::image) || + (Result::INVALID_DATA == + VerifyImage( + request_soft_buttons[i][strings::image], app, app_mngr)))) { + return Result::INVALID_DATA; + } break; } default: { diff --git a/src/components/application_manager/src/resumption/resume_ctrl_impl.cc b/src/components/application_manager/src/resumption/resume_ctrl_impl.cc index caa04c1ada..42dc335878 100644 --- a/src/components/application_manager/src/resumption/resume_ctrl_impl.cc +++ b/src/components/application_manager/src/resumption/resume_ctrl_impl.cc @@ -478,7 +478,20 @@ bool ResumeCtrlImpl::CheckPersistenceFilesForResumption( const std::string& device_mac = application->mac_address(); bool result = resumption_storage_->GetSavedApplication( application->policy_app_id(), device_mac, saved_app); - return result; + if (result) { + if (saved_app.keyExists(strings::application_commands)) { + if (!CheckIcons(application, saved_app[strings::application_commands])) { + return false; + } + } + if (saved_app.keyExists(strings::application_choice_sets)) { + if (!CheckIcons(application, + saved_app[strings::application_choice_sets])) { + return false; + } + } + } + return true; } bool ResumeCtrlImpl::CheckApplicationHash(ApplicationSharedPtr application, @@ -766,6 +779,15 @@ bool ResumeCtrlImpl::CheckAppRestrictions( return result; } +bool ResumeCtrlImpl::CheckIcons(ApplicationSharedPtr application, + smart_objects::SmartObject& obj) { + using namespace smart_objects; + LOG4CXX_AUTO_TRACE(logger_); + const mobile_apis::Result::eType verify_images = + MessageHelper::VerifyImageFiles(obj, application, application_manager_); + return mobile_apis::Result::INVALID_DATA != verify_images; +} + bool ResumeCtrlImpl::CheckDelayAfterIgnOn() { using namespace date_time; LOG4CXX_AUTO_TRACE(logger_); 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 1e8a5f5a40..338c359bbe 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 @@ -715,7 +715,7 @@ TEST_F(MessageHelperTest, VerifySoftButtonString_WrongStrings_False) { "soft_button1\\n", "soft_button1\\t"}; for (size_t i = 0; i < wrong_strings.size(); ++i) { - EXPECT_FALSE(MessageHelper::VerifySoftButtonString(wrong_strings[i])); + EXPECT_FALSE(MessageHelper::VerifyString(wrong_strings[i])); } } @@ -726,7 +726,7 @@ TEST_F(MessageHelperTest, VerifySoftButtonString_CorrectStrings_True) { "soft_button1??....asd", "soft_button12313fcvzxc./.,"}; for (size_t i = 0; i < wrong_strings.size(); ++i) { - EXPECT_TRUE(MessageHelper::VerifySoftButtonString(wrong_strings[i])); + EXPECT_TRUE(MessageHelper::VerifyString(wrong_strings[i])); } } @@ -771,6 +771,7 @@ TEST_F(MessageHelperTest, VerifyImage_ImageTypeIsStatic_Success) { // Creating input data for method smart_objects::SmartObject image; image[strings::image_type] = mobile_apis::ImageType::STATIC; + image[strings::value] = "static_icon"; // Method call mobile_apis::Result::eType result = MessageHelper::VerifyImage( image, appSharedMock, mock_application_manager); @@ -801,10 +802,9 @@ TEST_F(MessageHelperTest, VerifyImageApplyPath_ImageTypeIsStatic_Success) { image[strings::image_type] = mobile_apis::ImageType::STATIC; image[strings::value] = "icon.png"; // Method call - mobile_apis::Result::eType result = MessageHelper::VerifyImageApplyPath( + MessageHelper::ApplyImagePath( image, appSharedMock, mock_application_manager); // EXPECT - EXPECT_EQ(mobile_apis::Result::SUCCESS, result); EXPECT_EQ("icon.png", image[strings::value].asString()); } @@ -817,7 +817,7 @@ TEST_F(MessageHelperTest, VerifyImageApplyPath_ImageValueNotValid_InvalidData) { // Invalid value image[strings::value] = " "; // Method call - mobile_apis::Result::eType result = MessageHelper::VerifyImageApplyPath( + mobile_apis::Result::eType result = MessageHelper::VerifyImage( image, appSharedMock, mock_application_manager); // EXPECT EXPECT_EQ(mobile_apis::Result::INVALID_DATA, result); @@ -830,6 +830,8 @@ TEST_F(MessageHelperTest, VerifyImageFiles_SmartObjectWithValidData_Success) { smart_objects::SmartObject images; images[0][strings::image_type] = mobile_apis::ImageType::STATIC; images[1][strings::image_type] = mobile_apis::ImageType::STATIC; + images[0][strings::value] = "static_icon"; + images[1][strings::value] = "static_icon"; // Method call mobile_apis::Result::eType result = MessageHelper::VerifyImageFiles( images, appSharedMock, mock_application_manager); -- cgit v1.2.1 From 2b1b413d63ee94503d26d0acc039e7083730b5dd Mon Sep 17 00:00:00 2001 From: Ashwin Karemore Date: Mon, 2 Jul 2018 15:56:21 +0200 Subject: create interaction choice set run method changes --- .../create_interaction_choice_set_request.cc | 35 ++++++++++------------ 1 file changed, 16 insertions(+), 19 deletions(-) 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 d36eda18e1..0612daa3e3 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 @@ -79,25 +79,6 @@ void CreateInteractionChoiceSetRequest::Run() { SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED); return; } - - choice_set_id_ = - (*message_)[strings::msg_params][strings::interaction_choice_set_id] - .asInt(); - - if (app->FindChoiceSet(choice_set_id_)) { - LOG4CXX_ERROR(logger_, - "Choice set with id " << choice_set_id_ << " is not found."); - SendResponse(false, Result::INVALID_ID); - return; - } - - Result::eType result = CheckChoiceSet(app); - if (Result::SUCCESS != result) { - SendResponse(false, result); - return; - } - - should_send_warnings = false; for (uint32_t i = 0; i < (*message_)[strings::msg_params][strings::choice_set].length(); @@ -132,6 +113,22 @@ void CreateInteractionChoiceSetRequest::Run() { } } + choice_set_id_ = + (*message_)[strings::msg_params][strings::interaction_choice_set_id] + .asInt(); + + if (app->FindChoiceSet(choice_set_id_)) { + LOG4CXX_ERROR(logger_, + "Choice set with id " << choice_set_id_ << " is not found."); + SendResponse(false, Result::INVALID_ID); + return; + } + + Result::eType result = CheckChoiceSet(app); + if (Result::SUCCESS != result) { + SendResponse(false, result); + return; + } uint32_t grammar_id = application_manager_.GenerateGrammarID(); (*message_)[strings::msg_params][strings::grammar_id] = grammar_id; app->AddChoiceSet(choice_set_id_, (*message_)[strings::msg_params]); -- cgit v1.2.1 From 193aaf8b290128669cc0e75b176931a16d6ca5a0 Mon Sep 17 00:00:00 2001 From: Ashwin Karemore Date: Mon, 2 Jul 2018 16:23:53 +0200 Subject: added UT for warnings --- .../commands/mobile/send_location_request_test.cc | 15 ++++ .../commands/mobile/set_global_properties_test.cc | 88 ++++++++++++++++++++++ .../test/commands/mobile/show_test.cc | 53 +++++++++++++ .../mobile/update_turn_list_request_test.cc | 60 +++++++++++++++ .../test/message_helper/message_helper_test.cc | 8 +- 5 files changed, 223 insertions(+), 1 deletion(-) diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/send_location_request_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/send_location_request_test.cc index ebbd633912..e4144c0911 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/send_location_request_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/send_location_request_test.cc @@ -315,6 +315,21 @@ TEST_F(SendLocationRequestTest, Run_LocationImageValid_Success) { command_->Run(); } +TEST_F(SendLocationRequestTest, Run_LocationImageValid_Warnings) { + InitialSetup(message_); + (*message_)[strings::msg_params][strings::location_image] = + SmartObject(smart_objects::SmartType_Map); + (*message_)[strings::msg_params][strings::location_image][strings::value] = + "notavailable"; + EXPECT_CALL( + mock_message_helper_, + VerifyImage( + (*message_)[strings::msg_params][strings::location_image], _, _)) + .WillOnce(Return(mobile_apis::Result::WARNINGS)); + FinishSetup(); + command_->Run(); +} + TEST_F(SendLocationRequestTest, Run_LocationImageInvalid_Cancelled) { InitialSetup(message_); (*message_)[strings::msg_params][strings::location_image] = diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/set_global_properties_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/set_global_properties_test.cc index ae82f24b61..6b9d8cc468 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/set_global_properties_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/set_global_properties_test.cc @@ -491,6 +491,94 @@ TEST_F(SetGlobalPropertiesRequestTest, Run_VRWithMenuAndKeyboard_SUCCESS) { command->Run(); } +TEST_F(SetGlobalPropertiesRequestTest, Run_VRWithMenuAndKeyboard_Menu_WARNINGS) { + MessageSharedPtr msg = CreateMsgParams(); + SmartObject vr_help_title("yes"); + SmartObject vr_help_array(smart_objects::SmartType_Array); + VRArraySetupHelper(msg, vr_help_title, vr_help_array); + (*msg)[am::strings::msg_params][am::strings::vr_help] = vr_help_array; + SmartObject menu_title("Menu_Title"); + (*msg)[am::strings::msg_params][am::hmi_request::menu_title] = menu_title; + SmartObject menu_icon(smart_objects::SmartType_Map); + menu_icon[am::strings::value] = "1"; + (*msg)[am::strings::msg_params][am::hmi_request::menu_icon] = menu_icon; + SmartObject keyboard_properties(smart_objects::SmartType_Map); + (*msg)[am::strings::msg_params][am::hmi_request::keyboard_properties] = + keyboard_properties; + + EXPECT_CALL(mock_message_helper_, VerifyImage(menu_icon, _, _)) + .WillOnce((Return(mobile_apis::Result::WARNINGS))); + EXPECT_CALL(mock_message_helper_, VerifyImageVrHelpItems(vr_help_array, _, _)) + .WillOnce((Return(mobile_apis::Result::SUCCESS))); + EXPECT_CALL(app_mngr_, RemoveAppFromTTSGlobalPropertiesList(kConnectionKey)); + EXPECT_CALL(*mock_app_, set_vr_help_title(vr_help_title)); + EXPECT_CALL(*mock_app_, set_vr_help(vr_help_array)); + EXPECT_CALL(*mock_app_, vr_help_title()).WillOnce(Return(&vr_help_title)); + EXPECT_CALL(*mock_app_, vr_help()).WillOnce(Return(&vr_help_array)); + EXPECT_CALL(*mock_app_, set_menu_title(menu_title)); + EXPECT_CALL(*mock_app_, set_menu_icon(menu_icon)); + EXPECT_CALL(*mock_app_, set_keyboard_props(keyboard_properties)); + EXPECT_CALL(*mock_app_, app_id()).WillOnce(Return(kAppId)); + + EXPECT_CALL( + mock_hmi_interfaces_, + GetInterfaceFromFunction(hmi_apis::FunctionID::UI_SetGlobalProperties)) + .WillOnce(Return(am::HmiInterfaces::HMI_INTERFACE_UI)); + + ON_CALL(mock_hmi_interfaces_, + GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_UI)) + .WillByDefault(Return(am::HmiInterfaces::STATE_NOT_AVAILABLE)); + + SharedPtr command( + CreateCommand(msg)); + + command->Run(); +} + +TEST_F(SetGlobalPropertiesRequestTest, Run_VRWithMenuAndKeyboard_VR_WARNINGS) { + MessageSharedPtr msg = CreateMsgParams(); + SmartObject vr_help_title("yes"); + SmartObject vr_help_array(smart_objects::SmartType_Array); + VRArraySetupHelper(msg, vr_help_title, vr_help_array); + (*msg)[am::strings::msg_params][am::strings::vr_help] = vr_help_array; + SmartObject menu_title("Menu_Title"); + (*msg)[am::strings::msg_params][am::hmi_request::menu_title] = menu_title; + SmartObject menu_icon(smart_objects::SmartType_Map); + menu_icon[am::strings::value] = "1"; + (*msg)[am::strings::msg_params][am::hmi_request::menu_icon] = menu_icon; + SmartObject keyboard_properties(smart_objects::SmartType_Map); + (*msg)[am::strings::msg_params][am::hmi_request::keyboard_properties] = + keyboard_properties; + + EXPECT_CALL(mock_message_helper_, VerifyImage(menu_icon, _, _)) + .WillOnce((Return(mobile_apis::Result::SUCCESS))); + EXPECT_CALL(mock_message_helper_, VerifyImageVrHelpItems(vr_help_array, _, _)) + .WillOnce((Return(mobile_apis::Result::WARNINGS))); + EXPECT_CALL(app_mngr_, RemoveAppFromTTSGlobalPropertiesList(kConnectionKey)); + EXPECT_CALL(*mock_app_, set_vr_help_title(vr_help_title)); + EXPECT_CALL(*mock_app_, set_vr_help(vr_help_array)); + EXPECT_CALL(*mock_app_, vr_help_title()).WillOnce(Return(&vr_help_title)); + EXPECT_CALL(*mock_app_, vr_help()).WillOnce(Return(&vr_help_array)); + EXPECT_CALL(*mock_app_, set_menu_title(menu_title)); + EXPECT_CALL(*mock_app_, set_menu_icon(menu_icon)); + EXPECT_CALL(*mock_app_, set_keyboard_props(keyboard_properties)); + EXPECT_CALL(*mock_app_, app_id()).WillOnce(Return(kAppId)); + + EXPECT_CALL( + mock_hmi_interfaces_, + GetInterfaceFromFunction(hmi_apis::FunctionID::UI_SetGlobalProperties)) + .WillOnce(Return(am::HmiInterfaces::HMI_INTERFACE_UI)); + + ON_CALL(mock_hmi_interfaces_, + GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_UI)) + .WillByDefault(Return(am::HmiInterfaces::STATE_NOT_AVAILABLE)); + + SharedPtr command( + CreateCommand(msg)); + + command->Run(); +} + TEST_F(SetGlobalPropertiesRequestTest, Run_VRBrokenMenuIcon_Canceled) { MessageSharedPtr msg = CreateMsgParams(); SmartObject vr_help_title("yes"); diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/show_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/show_test.cc index ac2b59a613..2d9be1b5cf 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/show_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/show_test.cc @@ -353,6 +353,33 @@ TEST_F(ShowRequestTest, Run_Graphic_SUCCESS) { command->Run(); } +TEST_F(ShowRequestTest, Run_Graphic_WARNINGS) { + MessageSharedPtr msg = CreateMsgParams(); + + SmartObject msg_params(smart_objects::SmartType_Map); + SmartObject graphic(smart_objects::SmartType_Map); + graphic[am::strings::value] = "1"; + msg_params[am::strings::graphic] = graphic; + (*msg)[am::strings::msg_params] = msg_params; + + SharedPtr command(CreateCommand(msg)); + + EXPECT_CALL(app_mngr_, application(kConnectionKey)) + .WillOnce(Return(mock_app_)); + EXPECT_CALL(mock_message_helper_, VerifyImage(graphic, _, _)) + .WillOnce(Return(mobile_apis::Result::WARNINGS)); + EXPECT_CALL(*mock_app_, app_id()).WillOnce(Return(kAppId)); + + msg_params[am::strings::app_id] = kAppId; + msg_params[am::hmi_request::show_strings] = + smart_objects::SmartObject(smart_objects::SmartType_Array); + + EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_)); + EXPECT_CALL(*mock_app_, set_show_command(msg_params)); + + command->Run(); +} + TEST_F(ShowRequestTest, Run_Graphic_Canceled) { MessageSharedPtr msg = CreateMsgParams(); @@ -425,6 +452,32 @@ TEST_F(ShowRequestTest, Run_SecondaryGraphic_SUCCESS) { command->Run(); } +TEST_F(ShowRequestTest, Run_SecondaryGraphic_WARNINGS) { + MessageSharedPtr msg = CreateMsgParams(); + + SmartObject msg_params(smart_objects::SmartType_Map); + SmartObject graphic(smart_objects::SmartType_Map); + graphic[am::strings::value] = "1"; + msg_params[am::strings::secondary_graphic] = graphic; + (*msg)[am::strings::msg_params] = msg_params; + + SharedPtr command(CreateCommand(msg)); + + EXPECT_CALL(app_mngr_, application(kConnectionKey)) + .WillOnce(Return(mock_app_)); + EXPECT_CALL(mock_message_helper_, VerifyImage(graphic, _, _)) + .WillOnce(Return(mobile_apis::Result::WARNINGS)); + EXPECT_CALL(*mock_app_, app_id()).WillOnce(Return(kAppId)); + + msg_params[am::strings::app_id] = kAppId; + msg_params[am::hmi_request::show_strings] = + smart_objects::SmartObject(smart_objects::SmartType_Array); + EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_)); + EXPECT_CALL(*mock_app_, set_show_command(msg_params)); + + command->Run(); +} + TEST_F(ShowRequestTest, Run_SecondaryGraphic_Canceled) { MessageSharedPtr msg = CreateMsgParams(); diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/update_turn_list_request_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/update_turn_list_request_test.cc index acb421af6b..d07e76350f 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/update_turn_list_request_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/update_turn_list_request_test.cc @@ -241,6 +241,66 @@ TEST_F(UpdateTurnListRequestTest, Run_ValidTurnList_SUCCESS) { .asString()); } +TEST_F(UpdateTurnListRequestTest, Run_ValidTurnList_WARNINGS) { + const std::string kNavigationText = "valid_navigation_text"; + + (*command_msg_)[am::strings::msg_params][am::strings::turn_list][0] + [am::strings::navigation_text] = kNavigationText; + (*command_msg_)[am::strings::msg_params][am::strings::turn_list][0] + [am::strings::turn_icon][am::strings::value] = + "valid_turn_icon"; + (*command_msg_)[am::strings::msg_params][am::strings::soft_buttons] = 0; + + MockAppPtr mock_app(CreateMockApp()); + EXPECT_CALL(app_mngr_, application(kConnectionKey)) + .WillOnce(Return(mock_app)); + + EXPECT_CALL(mock_message_helper_, + ProcessSoftButtons((*command_msg_)[am::strings::msg_params], + Eq(mock_app), + Ref(mock_policy_handler_), + Ref(app_mngr_))) + .WillOnce(Return(mobile_result::SUCCESS)); + + EXPECT_CALL( + mock_message_helper_, + VerifyImage( + (*command_msg_)[am::strings::msg_params][am::strings::turn_list][0] + [am::strings::turn_icon], + Eq(mock_app), + Ref(app_mngr_))).WillOnce(Return(mobile_result::WARNINGS)); + + EXPECT_CALL(mock_message_helper_, + SubscribeApplicationToSoftButton(_, _, kFunctionId)); + + MessageSharedPtr result_msg(CatchHMICommandResult(CallRun(*command_))); + ASSERT_TRUE(result_msg); + EXPECT_EQ( + hmi_apis::FunctionID::Navigation_UpdateTurnList, + (*result_msg)[am::strings::params][am::strings::function_id].asInt()); + + ASSERT_TRUE((*result_msg)[am::strings::msg_params][am::strings::turn_list][0] + .keyExists(am::hmi_request::navi_text)); + + EXPECT_TRUE((*result_msg)[am::strings::msg_params][am::strings::turn_list][0] + [am::hmi_request::navi_text].keyExists( + am::hmi_request::field_name)); + EXPECT_EQ( + hmi_apis::Common_TextFieldName::turnText, + (*result_msg)[am::strings::msg_params][am::strings::turn_list][0] + [am::hmi_request::navi_text][am::hmi_request::field_name] + .asInt()); + + EXPECT_TRUE((*result_msg)[am::strings::msg_params][am::strings::turn_list][0] + [am::hmi_request::navi_text].keyExists( + am::hmi_request::field_text)); + EXPECT_EQ( + kNavigationText, + (*result_msg)[am::strings::msg_params][am::strings::turn_list][0] + [am::hmi_request::navi_text][am::hmi_request::field_text] + .asString()); +} + TEST_F(UpdateTurnListRequestTest, OnEvent_UnknownEvent_UNSUCCESS) { Event event(hmi_apis::FunctionID::INVALID_ENUM); EXPECT_CALL(mock_rpc_service_, ManageMobileCommand(_, _)).Times(0); 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 338c359bbe..d8cc4329d3 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 @@ -802,8 +802,9 @@ TEST_F(MessageHelperTest, VerifyImageApplyPath_ImageTypeIsStatic_Success) { image[strings::image_type] = mobile_apis::ImageType::STATIC; image[strings::value] = "icon.png"; // Method call - MessageHelper::ApplyImagePath( + mobile_apis::Result::eType result = MessageHelper::VerifyImage( image, appSharedMock, mock_application_manager); + EXPECT_EQ(mobile_apis::Result::SUCCESS, result); // EXPECT EXPECT_EQ("icon.png", image[strings::value].asString()); } @@ -867,6 +868,11 @@ TEST_F(MessageHelperTest, mobile_apis::ImageType::STATIC; message[1][strings::image][strings::image_type] = mobile_apis::ImageType::STATIC; + + message[0][strings::image][strings::value] = + "static_icon"; + message[1][strings::image][strings::value] = + "static_icon"; // Method call mobile_apis::Result::eType result = MessageHelper::VerifyImageVrHelpItems( message, appSharedMock, mock_application_manager); -- cgit v1.2.1 From ac1216b8b697b287217175b76da6ad6b0f5649ba Mon Sep 17 00:00:00 2001 From: Ashwin Karemore Date: Mon, 2 Jul 2018 17:35:54 +0200 Subject: fix style --- .../include/application_manager/message_helper.h | 7 +++---- .../test/commands/mobile/add_command_request_test.cc | 6 +++--- .../test/commands/mobile/set_global_properties_test.cc | 3 ++- .../src/message_helper/message_helper.cc | 18 +++++++----------- .../test/message_helper/message_helper_test.cc | 6 ++---- 5 files changed, 17 insertions(+), 23 deletions(-) diff --git a/src/components/application_manager/include/application_manager/message_helper.h b/src/components/application_manager/include/application_manager/message_helper.h index b1bf3bd567..127ff967b4 100644 --- a/src/components/application_manager/include/application_manager/message_helper.h +++ b/src/components/application_manager/include/application_manager/message_helper.h @@ -615,10 +615,9 @@ class MessageHelper { * @param app current application * @return verification result */ - static void ApplyImagePath( - smart_objects::SmartObject& image, - ApplicationConstSharedPtr app, - ApplicationManager& app_mngr); + static void ApplyImagePath(smart_objects::SmartObject& image, + ApplicationConstSharedPtr app, + ApplicationManager& app_mngr); /* * @brief Verify image and add image file full path diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/add_command_request_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/add_command_request_test.cc index 94338aae67..fedb4966f5 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/add_command_request_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/add_command_request_test.cc @@ -272,10 +272,10 @@ TEST_F(AddCommandRequestTest, Run_ImageVerificationFailed_EXPECT_WARNINGS) { am::CommandsMap commands_map; EXPECT_CALL(*mock_app_, commands_map()) - .WillRepeatedly(Return( - DataAccessor(commands_map, lock_ptr_))); + .WillRepeatedly(Return(DataAccessor( + commands_map, lock_ptr_))); EXPECT_CALL( - mock_rpc_service_, + mock_rpc_service_, ManageHMICommand(HMIResultCodeIs(hmi_apis::FunctionID::UI_AddCommand))) .WillOnce(Return(true)); utils::SharedPtr request_ptr = diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/set_global_properties_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/set_global_properties_test.cc index 6b9d8cc468..6f1ccb9cc3 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/set_global_properties_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/set_global_properties_test.cc @@ -491,7 +491,8 @@ TEST_F(SetGlobalPropertiesRequestTest, Run_VRWithMenuAndKeyboard_SUCCESS) { command->Run(); } -TEST_F(SetGlobalPropertiesRequestTest, Run_VRWithMenuAndKeyboard_Menu_WARNINGS) { +TEST_F(SetGlobalPropertiesRequestTest, + Run_VRWithMenuAndKeyboard_Menu_WARNINGS) { MessageSharedPtr msg = CreateMsgParams(); SmartObject vr_help_title("yes"); SmartObject vr_help_array(smart_objects::SmartType_Array); diff --git a/src/components/application_manager/src/message_helper/message_helper.cc b/src/components/application_manager/src/message_helper/message_helper.cc index 58b3552e9f..052d619fcc 100644 --- a/src/components/application_manager/src/message_helper/message_helper.cc +++ b/src/components/application_manager/src/message_helper/message_helper.cc @@ -94,8 +94,8 @@ bool ValidateSoftButtons(smart_objects::SmartObject& soft_buttons) { // Check if image parameter is valid if (button.keyExists(strings::image)) { SmartObject& buttonImage = button[strings::image]; - if (false == MessageHelper::VerifyString( - buttonImage[strings::value].asString())) { + if (false == + MessageHelper::VerifyString(buttonImage[strings::value].asString())) { return false; } } @@ -2598,11 +2598,9 @@ mobile_apis::Result::eType MessageHelper::VerifyImageFiles( return mobile_apis::Result::SUCCESS; } -void MessageHelper::ApplyImagePath( - smart_objects::SmartObject& image, - ApplicationConstSharedPtr app, - ApplicationManager& app_mngr) { - +void MessageHelper::ApplyImagePath(smart_objects::SmartObject& image, + ApplicationConstSharedPtr app, + ApplicationManager& app_mngr) { const std::string& file_name = image[strings::value].asString(); const std::string& full_file_path = GetAppFilePath(file_name, app, app_mngr); @@ -2669,19 +2667,17 @@ mobile_apis::Result::eType MessageHelper::VerifyImage( smart_objects::SmartObject& image, ApplicationConstSharedPtr app, ApplicationManager& app_mngr) { - const uint32_t image_type = image[strings::image_type].asUInt(); mobile_apis::ImageType::eType type = static_cast(image_type); const std::string& file_name = image[strings::value].asString(); - - if(!VerifyString(file_name)){ + if (!VerifyString(file_name)) { return mobile_apis::Result::INVALID_DATA; } if (mobile_apis::ImageType::STATIC == type) { - return mobile_apis::Result::SUCCESS; + return mobile_apis::Result::SUCCESS; } ApplyImagePath(image, app, app_mngr); 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 d8cc4329d3..15a09c33cc 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 @@ -869,10 +869,8 @@ TEST_F(MessageHelperTest, message[1][strings::image][strings::image_type] = mobile_apis::ImageType::STATIC; - message[0][strings::image][strings::value] = - "static_icon"; - message[1][strings::image][strings::value] = - "static_icon"; + message[0][strings::image][strings::value] = "static_icon"; + message[1][strings::image][strings::value] = "static_icon"; // Method call mobile_apis::Result::eType result = MessageHelper::VerifyImageVrHelpItems( message, appSharedMock, mock_application_manager); -- cgit v1.2.1 From 5f0bb3cd3d606adf9659e38e3348c8ed8afd3735 Mon Sep 17 00:00:00 2001 From: AKalinich-Luxoft Date: Thu, 26 Jul 2018 19:57:23 +0300 Subject: Answer Livio comments Fixed affected unit tests Reverted changes related to namespace naming --- .../create_interaction_choice_set_request.cc | 17 ++++--- .../commands/mobile/add_command_request_test.cc | 4 +- .../commands/mobile/send_location_request_test.cc | 2 +- .../commands/mobile/set_global_properties_test.cc | 59 ++++++++++++---------- .../test/commands/mobile/show_test.cc | 5 +- .../mobile/update_turn_list_request_test.cc | 2 +- 6 files changed, 47 insertions(+), 42 deletions(-) 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 0612daa3e3..9b7653ac52 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 @@ -42,12 +42,13 @@ #include "utils/gen_hash.h" #include "utils/helpers.h" -#define INVALID_IMG_WARNING_INFO "Requested image(s) not found." -namespace sdl_rpc_plugin { -using namespace application_manager; +const char* kInvalidImageWarningInfo = "Requested image(s) not found."; +namespace sdl_rpc_plugin { namespace commands { +using namespace application_manager; + CreateInteractionChoiceSetRequest::CreateInteractionChoiceSetRequest( const application_manager::commands::MessageSharedPtr& message, ApplicationManager& application_manager, @@ -106,10 +107,10 @@ void CreateInteractionChoiceSetRequest::Run() { LOG4CXX_ERROR(logger_, "Image verification failed."); SendResponse(false, Result::INVALID_DATA); return; - } else if (verification_result_image == Result::WARNINGS || - verification_result_secondary_image == Result::WARNINGS) { - should_send_warnings = true; - break; + } else if (verification_result_image == Result::WARNINGS || + verification_result_secondary_image == Result::WARNINGS) { + should_send_warnings = true; + break; } } @@ -442,7 +443,7 @@ void CreateInteractionChoiceSetRequest::OnAllHMIResponsesReceived() { LOG4CXX_AUTO_TRACE(logger_); if (!error_from_hmi_ && should_send_warnings) { - SendResponse(true, mobile_apis::Result::WARNINGS,INVALID_IMG_WARNING_INFO); + SendResponse(true, mobile_apis::Result::WARNINGS, kInvalidImageWarningInfo); } else if (!error_from_hmi_) { SendResponse(true, mobile_apis::Result::SUCCESS); } else { diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/add_command_request_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/add_command_request_test.cc index fedb4966f5..dfcceea889 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/add_command_request_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/add_command_request_test.cc @@ -31,6 +31,7 @@ */ #include +#include #include #include @@ -64,7 +65,6 @@ using am::ApplicationManager; using am::commands::MessageSharedPtr; using am::ApplicationSharedPtr; using ::testing::_; - using ::testing::Return; using ::testing::InSequence; using sdl_rpc_plugin::commands::AddCommandRequest; @@ -278,7 +278,7 @@ TEST_F(AddCommandRequestTest, Run_ImageVerificationFailed_EXPECT_WARNINGS) { mock_rpc_service_, ManageHMICommand(HMIResultCodeIs(hmi_apis::FunctionID::UI_AddCommand))) .WillOnce(Return(true)); - utils::SharedPtr request_ptr = + std::shared_ptr request_ptr = CreateCommand(msg_); request_ptr->Run(); } diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/send_location_request_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/send_location_request_test.cc index e4144c0911..4f44293fc9 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/send_location_request_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/send_location_request_test.cc @@ -335,7 +335,7 @@ TEST_F(SendLocationRequestTest, Run_LocationImageInvalid_Cancelled) { (*message_)[strings::msg_params][strings::location_image] = SmartObject(smart_objects::SmartType_Map); (*message_)[strings::msg_params][strings::location_image][strings::value] = - " 1"; + "1"; EXPECT_CALL( mock_message_helper_, VerifyImage( diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/set_global_properties_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/set_global_properties_test.cc index 6f1ccb9cc3..03aa5d85a1 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/set_global_properties_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/set_global_properties_test.cc @@ -31,6 +31,7 @@ */ #include +#include #include #include @@ -520,6 +521,10 @@ TEST_F(SetGlobalPropertiesRequestTest, EXPECT_CALL(*mock_app_, set_menu_icon(menu_icon)); EXPECT_CALL(*mock_app_, set_keyboard_props(keyboard_properties)); EXPECT_CALL(*mock_app_, app_id()).WillOnce(Return(kAppId)); + EXPECT_CALL(*mock_app_, help_prompt_manager()) + .WillOnce(ReturnRef(*mock_help_prompt_manager_.get())); + EXPECT_CALL(*mock_help_prompt_manager_, + OnSetGlobalPropertiesReceived(_, false)); EXPECT_CALL( mock_hmi_interfaces_, @@ -530,7 +535,7 @@ TEST_F(SetGlobalPropertiesRequestTest, GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_UI)) .WillByDefault(Return(am::HmiInterfaces::STATE_NOT_AVAILABLE)); - SharedPtr command( + std::shared_ptr command( CreateCommand(msg)); command->Run(); @@ -564,6 +569,10 @@ TEST_F(SetGlobalPropertiesRequestTest, Run_VRWithMenuAndKeyboard_VR_WARNINGS) { EXPECT_CALL(*mock_app_, set_menu_icon(menu_icon)); EXPECT_CALL(*mock_app_, set_keyboard_props(keyboard_properties)); EXPECT_CALL(*mock_app_, app_id()).WillOnce(Return(kAppId)); + EXPECT_CALL(*mock_app_, help_prompt_manager()) + .WillOnce(ReturnRef(*mock_help_prompt_manager_.get())); + EXPECT_CALL(*mock_help_prompt_manager_, + OnSetGlobalPropertiesReceived(_, false)); EXPECT_CALL( mock_hmi_interfaces_, @@ -574,7 +583,7 @@ TEST_F(SetGlobalPropertiesRequestTest, Run_VRWithMenuAndKeyboard_VR_WARNINGS) { GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_UI)) .WillByDefault(Return(am::HmiInterfaces::STATE_NOT_AVAILABLE)); - SharedPtr command( + std::shared_ptr command( CreateCommand(msg)); command->Run(); @@ -593,9 +602,7 @@ TEST_F(SetGlobalPropertiesRequestTest, Run_VRBrokenMenuIcon_Canceled) { EXPECT_CALL(mock_message_helper_, VerifyImage(menu_icon, _, _)) .WillOnce((Return(mobile_apis::Result::ABORTED))); EXPECT_CALL(mock_message_helper_, VerifyImageVrHelpItems(_, _, _)).Times(0); - EXPECT_CALL(app_mngr_, RemoveAppFromTTSGlobalPropertiesList(_)).Times(0); EmptyExpectationsSetupHelper(); - std::shared_ptr command( CreateCommand(msg)); @@ -610,14 +617,27 @@ TEST_F(SetGlobalPropertiesRequestTest, Run_VRBrokenVRHelp_Canceled) { (*msg)[am::strings::msg_params][am::hmi_request::menu_icon] = menu_icon; SmartObject vr_help_array(smart_objects::SmartType_Array); VRArraySetupHelper(msg, vr_help_title, vr_help_array); + SmartObject menu_title("Menu_Title"); + (*msg)[am::strings::msg_params][am::hmi_request::menu_title] = menu_title; EXPECT_CALL(mock_message_helper_, VerifyImage(menu_icon, _, _)) .WillOnce((Return(mobile_apis::Result::SUCCESS))); EXPECT_CALL(mock_message_helper_, VerifyImageVrHelpItems(vr_help_array, _, _)) .WillOnce((Return(mobile_apis::Result::ABORTED))); - EXPECT_CALL(app_mngr_, RemoveAppFromTTSGlobalPropertiesList(_)).Times(0); EmptyExpectationsSetupHelper(); + EXPECT_CALL(*mock_app_, vr_help_title()).WillOnce(Return(&vr_help_title)); + EXPECT_CALL(*mock_app_, vr_help()).WillOnce(Return(&vr_help_array)); + EXPECT_CALL(*mock_app_, set_vr_help_title(vr_help_title)); + EXPECT_CALL(*mock_app_, set_vr_help(vr_help_array)); + EXPECT_CALL(*mock_app_, set_menu_title(menu_title)); + EXPECT_CALL(*mock_app_, set_menu_icon(menu_icon)); + EXPECT_CALL(*mock_app_, app_id()).WillOnce(Return(kAppId)); + EXPECT_CALL(*mock_app_, help_prompt_manager()) + .WillOnce(ReturnRef(*mock_help_prompt_manager_.get())); + EXPECT_CALL(*mock_help_prompt_manager_, + OnSetGlobalPropertiesReceived(_, false)); + std::shared_ptr command( CreateCommand(msg)); @@ -732,7 +752,7 @@ TEST_F(SetGlobalPropertiesRequestTest, Run_NoVR_SUCCESS) { GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_UI)) .WillByDefault(Return(am::HmiInterfaces::STATE_NOT_AVAILABLE)); - SharedPtr command( + std::shared_ptr command( CreateCommand(msg)); command->Run(); @@ -749,16 +769,9 @@ TEST_F(SetGlobalPropertiesRequestTest, Run_VRCouldNotGenerate_INVALID_DATA) { EXPECT_CALL(app_mngr_, application(kConnectionKey)) .WillOnce(Return(mock_app_)); EXPECT_CALL(app_mngr_, RemoveAppFromTTSGlobalPropertiesList(kConnectionKey)); - SmartObject* vr_help_title = NULL; - CommandsMap commands_map; - SmartObject empty_msg(smart_objects::SmartType_Map); - commands_map.insert(std::pair(1u, &empty_msg)); - DataAccessor accessor(commands_map, lock_ptr_); - EXPECT_CALL(*mock_app_, commands_map()).WillOnce(Return(accessor)); - EXPECT_CALL(*mock_app_, vr_help_title()).WillOnce(Return(vr_help_title)); - EXPECT_CALL(*mock_app_, set_menu_title(_)).Times(0); + EXPECT_CALL(*mock_app_, set_menu_title(menu_title)); - SharedPtr command( + std::shared_ptr command( CreateCommand(msg)); command->Run(); @@ -815,7 +828,7 @@ TEST_F(SetGlobalPropertiesRequestTest, Run_NoVRNoDataDefaultCreated_SUCCESS) { GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_UI)) .WillByDefault(Return(am::HmiInterfaces::STATE_NOT_AVAILABLE)); - SharedPtr command( + std::shared_ptr command( CreateCommand(msg)); command->Run(); @@ -830,23 +843,13 @@ TEST_F(SetGlobalPropertiesRequestTest, Run_NoVRNoDataFromSynonyms_SUCCESS) { EXPECT_CALL(app_mngr_, application(kConnectionKey)) .WillOnce(Return(mock_app_)); EXPECT_CALL(app_mngr_, RemoveAppFromTTSGlobalPropertiesList(kConnectionKey)); - SmartObject vr_help_title(smart_objects::SmartType_Null); - EXPECT_CALL(*mock_app_, vr_help_title()) - .Times(2) - .WillRepeatedly(Return(&vr_help_title)); - - CommandsMap commands_map; - DataAccessor accessor(commands_map, lock_ptr_); - EXPECT_CALL(*mock_app_, commands_map()).WillOnce(Return(accessor)); + SmartObject vr_help_array(smart_objects::SmartType_Array); vr_help_array[0] = SmartObject(smart_objects::SmartType_Map); vr_help_array[0][am::strings::text] = kText; vr_help_array[0][am::strings::position] = kPosition; SmartObject vr_synonyms(smart_objects::SmartType_Array); vr_synonyms[0] = vr_help_array; - const CustomString name("name"); - EXPECT_CALL(*mock_app_, name()).WillOnce(ReturnRef(name)); - EXPECT_CALL(*mock_app_, set_vr_help_title(SmartObject(name))); EXPECT_CALL(*mock_app_, set_menu_title(_)).Times(0); EXPECT_CALL(*mock_app_, set_menu_icon(_)).Times(0); EXPECT_CALL(*mock_app_, set_keyboard_props(keyboard_properties)); @@ -858,7 +861,7 @@ TEST_F(SetGlobalPropertiesRequestTest, Run_NoVRNoDataFromSynonyms_SUCCESS) { ON_CALL(mock_hmi_interfaces_, GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_UI)) .WillByDefault(Return(am::HmiInterfaces::STATE_NOT_AVAILABLE)); - SharedPtr command( + std::shared_ptr command( CreateCommand(msg)); command->Run(); diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/show_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/show_test.cc index 2d9be1b5cf..4725af4671 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/show_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/show_test.cc @@ -31,6 +31,7 @@ */ #include +#include #include #include @@ -362,7 +363,7 @@ TEST_F(ShowRequestTest, Run_Graphic_WARNINGS) { msg_params[am::strings::graphic] = graphic; (*msg)[am::strings::msg_params] = msg_params; - SharedPtr command(CreateCommand(msg)); + std::shared_ptr command(CreateCommand(msg)); EXPECT_CALL(app_mngr_, application(kConnectionKey)) .WillOnce(Return(mock_app_)); @@ -461,7 +462,7 @@ TEST_F(ShowRequestTest, Run_SecondaryGraphic_WARNINGS) { msg_params[am::strings::secondary_graphic] = graphic; (*msg)[am::strings::msg_params] = msg_params; - SharedPtr command(CreateCommand(msg)); + std::shared_ptr command(CreateCommand(msg)); EXPECT_CALL(app_mngr_, application(kConnectionKey)) .WillOnce(Return(mock_app_)); diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/update_turn_list_request_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/update_turn_list_request_test.cc index d07e76350f..78fca8681a 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/update_turn_list_request_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/update_turn_list_request_test.cc @@ -274,7 +274,7 @@ TEST_F(UpdateTurnListRequestTest, Run_ValidTurnList_WARNINGS) { SubscribeApplicationToSoftButton(_, _, kFunctionId)); MessageSharedPtr result_msg(CatchHMICommandResult(CallRun(*command_))); - ASSERT_TRUE(result_msg); + ASSERT_TRUE(result_msg != nullptr); EXPECT_EQ( hmi_apis::FunctionID::Navigation_UpdateTurnList, (*result_msg)[am::strings::params][am::strings::function_id].asInt()); -- cgit v1.2.1 From 8e8305da3c0f0cc72855416f2f846a5f932c38ca Mon Sep 17 00:00:00 2001 From: AKalinich-Luxoft Date: Fri, 27 Jul 2018 19:14:46 +0300 Subject: Fix defects found after ATF testing Apply feature for AddSubMenu RPC Fixed PI request does not resend choiceId Fixed wrong RPC creation in mobile factory --- .../src/commands/mobile/add_sub_menu_request.cc | 7 +--- .../commands/mobile/perform_interaction_request.cc | 48 ++++++++++++---------- .../sdl_rpc_plugin/src/mobile_command_factory.cc | 6 +-- 3 files changed, 31 insertions(+), 30 deletions(-) diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/add_sub_menu_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/add_sub_menu_request.cc index 3dcc414f9e..183b445326 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/add_sub_menu_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/add_sub_menu_request.cc @@ -76,7 +76,7 @@ void AddSubMenuRequest::Run() { verification_result = MessageHelper::VerifyImage( received_msg_params[strings::menu_icon], app, application_manager_); - if (mobile_apis::Result::SUCCESS != verification_result) { + if (mobile_apis::Result::INVALID_DATA == verification_result) { LOG4CXX_ERROR( logger_, "MessageHelper::VerifyImage return " << verification_result); SendResponse(false, verification_result); @@ -117,10 +117,7 @@ void AddSubMenuRequest::Run() { msg_params[strings::menu_params][strings::menu_name] = received_msg_params[strings::menu_name]; msg_params[strings::app_id] = app->app_id(); - - if (mobile_apis::Result::SUCCESS == verification_result) { - msg_params[strings::menu_icon] = received_msg_params[strings::menu_icon]; - } + msg_params[strings::menu_icon] = received_msg_params[strings::menu_icon]; StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_UI); SendHMIRequest(hmi_apis::FunctionID::UI_AddSubMenu, &msg_params, true); 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 76dd30525a..ec06f0bb31 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 @@ -343,27 +343,31 @@ bool PerformInteractionRequest::ProcessVRResponse( return false; } - if (Common_Result::SUCCESS == vr_result_code_ && - InteractionMode::MANUAL_ONLY == interaction_mode_) { - LOG4CXX_DEBUG(logger_, - "VR response SUCCESS in MANUAL_ONLY mode " - << "Wait for UI response"); - // in case MANUAL_ONLY mode VR.PI SUCCESS just return - return false; - } - const SmartObject& hmi_msg_params = message[strings::msg_params]; if (hmi_msg_params.keyExists(strings::choice_id)) { - const int choise_id = hmi_msg_params[strings::choice_id].asInt(); - if (!CheckChoiceIDFromResponse(app, choise_id)) { + const int choice_id = hmi_msg_params[strings::choice_id].asInt(); + if (!CheckChoiceIDFromResponse(app, choice_id)) { LOG4CXX_ERROR(logger_, "Wrong choiceID was received from HMI"); TerminatePerformInteraction(); SendResponse( false, Result::GENERIC_ERROR, "Wrong choiceID was received from HMI"); return true; } - msg_params[strings::choice_id] = choise_id; + msg_params[strings::choice_id] = choice_id; + } + + const bool is_vr_result_success = Compare( + vr_result_code_, Common_Result::SUCCESS, Common_Result::WARNINGS); + + if (is_vr_result_success && + InteractionMode::MANUAL_ONLY == interaction_mode_) { + LOG4CXX_DEBUG(logger_, + "VR response is successfull in MANUAL_ONLY mode " + << "Wait for UI response"); + // in case MANUAL_ONLY mode VR.PI SUCCESS just return + return false; } + return false; } @@ -401,19 +405,19 @@ void PerformInteractionRequest::ProcessUIResponse( ui_result_code_, hmi_apis::Common_Result::UNSUPPORTED_RESOURCE); if (result) { - if (is_pi_warning) { - ui_result_code_ = hmi_apis::Common_Result::WARNINGS; - ui_info_ = message[strings::msg_params][strings::info].asString(); - if (message.keyExists(strings::params) && - message[strings::params].keyExists(strings::data)) { - msg_params = message[strings::params][strings::data]; - } - } else if (is_pi_unsupported) { + if (is_pi_unsupported) { ui_result_code_ = hmi_apis::Common_Result::UNSUPPORTED_RESOURCE; ui_info_ = message[strings::msg_params][strings::info].asString(); - } else if (message.keyExists(strings::msg_params)) { - msg_params = message[strings::msg_params]; + } else { + if (message.keyExists(strings::msg_params)) { + msg_params = message[strings::msg_params]; + } + if (is_pi_warning) { + ui_result_code_ = hmi_apis::Common_Result::WARNINGS; + ui_info_ = message[strings::msg_params][strings::info].asString(); + } } + // result code must be GENERIC_ERROR in case wrong choice_id if (msg_params.keyExists(strings::choice_id)) { if (!CheckChoiceIDFromResponse(app, 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 3d7e2f6437..4251eeadc9 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 @@ -263,7 +263,7 @@ CommandCreator& MobileCommandFactory::get_creator_factory( } case mobile_apis::FunctionID::GetWayPointsID: { return mobile_api::messageType::request == message_type - ? factory.GetCreator() + ? factory.GetCreator() : factory.GetCreator(); } case mobile_apis::FunctionID::SubscribeWayPointsID: { @@ -273,8 +273,8 @@ CommandCreator& MobileCommandFactory::get_creator_factory( } case mobile_apis::FunctionID::UnsubscribeWayPointsID: { return mobile_api::messageType::request == message_type - ? factory.GetCreator() - : factory.GetCreator(); + ? factory.GetCreator() + : factory.GetCreator(); } case mobile_apis::FunctionID::GetSystemCapabilityID: { return mobile_api::messageType::request == message_type -- cgit v1.2.1 From c652b54ea3224f789e04453f778cdd41b96b435e Mon Sep 17 00:00:00 2001 From: Conlain Kelly Date: Mon, 30 Jul 2018 15:18:14 -0400 Subject: Return correct pointer type in ParseArray() --- src/components/policy/policy_regular/src/policy_manager_impl.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/policy/policy_regular/src/policy_manager_impl.cc b/src/components/policy/policy_regular/src/policy_manager_impl.cc index 297d538165..ebc695142e 100644 --- a/src/components/policy/policy_regular/src/policy_manager_impl.cc +++ b/src/components/policy/policy_regular/src/policy_manager_impl.cc @@ -116,9 +116,9 @@ std::shared_ptr PolicyManagerImpl::ParseArray( // For PT Update received from SDL Server. if (value["data"].size() != 0) { Json::Value data = value["data"]; - return new policy_table::Table(&data[0]); + return std::make_shared(&data[0]); } else { - return new policy_table::Table(&value); + return std::make_shared(&value); } } else { return std::shared_ptr(); -- cgit v1.2.1 From 4d6a095eac495e7b9a4b2c7522f358eeae03271c Mon Sep 17 00:00:00 2001 From: Conlain Kelly Date: Mon, 30 Jul 2018 17:15:36 -0400 Subject: remove Lock(bool) constructors --- .../policy/policy_external/include/policy/cache_manager.h | 2 +- .../policy/policy_external/include/policy/update_status_manager.h | 2 +- src/components/policy/policy_external/src/cache_manager.cc | 6 ++---- src/components/policy/policy_external/src/update_status_manager.cc | 1 - 4 files changed, 4 insertions(+), 7 deletions(-) diff --git a/src/components/policy/policy_external/include/policy/cache_manager.h b/src/components/policy/policy_external/include/policy/cache_manager.h index 6c7bbeb9c9..d30e7cea24 100644 --- a/src/components/policy/policy_external/include/policy/cache_manager.h +++ b/src/components/policy/policy_external/include/policy/cache_manager.h @@ -789,7 +789,7 @@ class CacheManager : public CacheManagerInterface { typedef std::set UnpairedDevices; UnpairedDevices is_unpaired_; - mutable sync_primitives::Lock cache_lock_; + mutable sync_primitives::RecursiveLock cache_lock_; sync_primitives::Lock unpaired_lock_; typedef std::map AppCalculatedPermissions; diff --git a/src/components/policy/policy_external/include/policy/update_status_manager.h b/src/components/policy/policy_external/include/policy/update_status_manager.h index cdd1225ef7..b4a373d1cf 100644 --- a/src/components/policy/policy_external/include/policy/update_status_manager.h +++ b/src/components/policy/policy_external/include/policy/update_status_manager.h @@ -227,7 +227,7 @@ class UpdateStatusManager { volatile uint32_t timeout_; volatile bool stop_flag_; - sync_primitives::Lock state_lock_; + sync_primitives::RecursiveLock state_lock_; sync_primitives::ConditionalVariable termination_condition_; UpdateStatusManager* update_status_manager_; }; diff --git a/src/components/policy/policy_external/src/cache_manager.cc b/src/components/policy/policy_external/src/cache_manager.cc index cc9921be14..717baa0443 100644 --- a/src/components/policy/policy_external/src/cache_manager.cc +++ b/src/components/policy/policy_external/src/cache_manager.cc @@ -253,8 +253,7 @@ CacheManager::CacheManager() : CacheManagerInterface() , pt_(new policy_table::Table) , backup_(new SQLPTExtRepresentation()) - , update_required(false) - , cache_lock_(true) { + , update_required(false) { InitBackupThread(); } @@ -262,8 +261,7 @@ CacheManager::CacheManager(bool in_memory) : CacheManagerInterface() , pt_(new policy_table::Table) , backup_(new SQLPTExtRepresentation(in_memory)) - , update_required(false) - , cache_lock_(true) { + , update_required(false) { InitBackupThread(); } diff --git a/src/components/policy/policy_external/src/update_status_manager.cc b/src/components/policy/policy_external/src/update_status_manager.cc index 1f00a440b3..e738554799 100644 --- a/src/components/policy/policy_external/src/update_status_manager.cc +++ b/src/components/policy/policy_external/src/update_status_manager.cc @@ -209,7 +209,6 @@ UpdateStatusManager::UpdateThreadDelegate::UpdateThreadDelegate( UpdateStatusManager* update_status_manager) : timeout_(0) , stop_flag_(false) - , state_lock_(true) , update_status_manager_(update_status_manager) { LOG4CXX_AUTO_TRACE(logger_); LOG4CXX_DEBUG(logger_, "Create UpdateThreadDelegate"); -- cgit v1.2.1 From dfcf5aecebd93a8b8e99d1f4e631f6a7eb47c74d Mon Sep 17 00:00:00 2001 From: Conlain Kelly Date: Mon, 30 Jul 2018 17:43:29 -0400 Subject: general cleanup on vr commands checks --- .../include/application_manager/message_helper.h | 50 ++++++---------------- .../commands/mobile/perform_interaction_request.h | 2 +- .../create_interaction_choice_set_request.cc | 10 ++--- .../commands/mobile/perform_interaction_request.cc | 10 ++--- .../src/message_helper/message_helper.cc | 32 ++++++++++++++ 5 files changed, 56 insertions(+), 48 deletions(-) diff --git a/src/components/application_manager/include/application_manager/message_helper.h b/src/components/application_manager/include/application_manager/message_helper.h index b15cf0c615..f370cc6966 100644 --- a/src/components/application_manager/include/application_manager/message_helper.h +++ b/src/components/application_manager/include/application_manager/message_helper.h @@ -855,43 +855,19 @@ class MessageHelper { */ static smart_objects::SmartObjectSPtr CreateMessageForHMI( hmi_apis::messageType::eType message_type, const uint32_t correlation_id); - - // Check whether each choice has the vrCommands field - // returns -1 for failure, 0 if all choice include vrCommands, and 1 if none - // do - // vrCommands is an all-or-none deal - static int CheckChoiceSet_VRCommands( - const smart_objects::SmartObject& choice_set) { - // if this becomes true, someone doesn't have vrCommands - bool all_have = true; - // if this is true, no one has vrCommands - bool none_have = true; - smart_objects::SmartArray::const_iterator current_choice_set_it = - choice_set.asArray()->begin(); - // Iterate through choices - for (; choice_set.asArray()->end() != current_choice_set_it; - ++current_choice_set_it) { - // if the vrCommands is present - if (current_choice_set_it->keyExists( - application_manager::strings::vr_commands)) { - // this one has the parameter - none_have = false; - } else { - // this one doesn't - all_have = false; - } - } - // everyone has it - if (all_have) { - return 0; - } - // No one has it - if (none_have) { - return 1; - } - // mix-and-match, this is an error - return -1; - } + + enum ChoiceSetVRCommandsStatus { + MIXED, ALL, NONE + }; + + /** + * @brief Check whether each choice in the set has the vrCommands parameter + * vrCommands is an all-or-none deal + * @param choice set to check + * @return -1 for mixed, 0 if all choice include vrCommands, and 1 if none do + */ + static ChoiceSetVRCommandsStatus CheckChoiceSetVRCommands( + const smart_objects::SmartObject& choice_set); private: /** diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/perform_interaction_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/perform_interaction_request.h index 8c98a4ff30..4ae6c90a62 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/perform_interaction_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/perform_interaction_request.h @@ -220,7 +220,7 @@ class PerformInteractionRequest * @param choice_set_id_list array of choice set ids * @return returns false request has choice sets with no vrCommands */ - bool CheckChoiceSetList_VRCommands(app_mngr::ApplicationSharedPtr app); + bool CheckChoiceSetListVRCommands(app_mngr::ApplicationSharedPtr app); /** * @brief Tells if there are sent requests without responses 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 0d6114cc50..92c15afd6d 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 @@ -123,17 +123,16 @@ void CreateInteractionChoiceSetRequest::Run() { SendResponse(false, result); return; } - int vr_status = MessageHelper::CheckChoiceSet_VRCommands( + auto vr_status = MessageHelper::CheckChoiceSetVRCommands( (*message_)[strings::msg_params][strings::choice_set]); - if (vr_status == -1) { + if (vr_status == MessageHelper::ChoiceSetVRCommandsStatus::MIXED) { // this is an error SendResponse(false, Result::INVALID_DATA, "Some choices don't contain VR commands. Either all or none " "must have voice commands."); return; // exit now, this is a bad set - - } else if (vr_status == 0) { + } else if (vr_status == MessageHelper::ChoiceSetVRCommandsStatus::ALL) { // everyone had a vr command, setup the grammar uint32_t grammar_id = application_manager_.GenerateGrammarID(); (*message_)[strings::msg_params][strings::grammar_id] = grammar_id; @@ -141,10 +140,11 @@ void CreateInteractionChoiceSetRequest::Run() { // continue on as usual app->AddChoiceSet(choice_set_id_, (*message_)[strings::msg_params]); - if (vr_status == 0) { + if (vr_status == MessageHelper::ChoiceSetVRCommandsStatus::ALL) { // we have VR commands SendVRAddCommandRequests(app); } else { + // we have none, just return with success SendResponse(true, Result::SUCCESS); } } 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 d013244f57..a9370845ad 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 @@ -186,7 +186,7 @@ void PerformInteractionRequest::Run() { LOG4CXX_DEBUG(logger_, "Interaction Mode: BOTH"); if (!CheckChoiceSetVRSynonyms(app) || !CheckChoiceSetMenuNames(app) || !CheckVrHelpItemPositions(app) || - !CheckChoiceSetList_VRCommands(app)) { + !CheckChoiceSetListVRCommands(app)) { return; } break; @@ -202,7 +202,7 @@ void PerformInteractionRequest::Run() { case mobile_apis::InteractionMode::VR_ONLY: { LOG4CXX_DEBUG(logger_, "Interaction Mode: VR_ONLY"); if (!CheckChoiceSetVRSynonyms(app) || !CheckVrHelpItemPositions(app) || - !CheckChoiceSetList_VRCommands(app)) { + !CheckChoiceSetListVRCommands(app)) { return; } break; @@ -952,7 +952,7 @@ bool PerformInteractionRequest::CheckChoiceIDFromResponse( return false; } -bool PerformInteractionRequest::CheckChoiceSetList_VRCommands( +bool PerformInteractionRequest::CheckChoiceSetListVRCommands( ApplicationSharedPtr app) { LOG4CXX_AUTO_TRACE(logger_); @@ -974,10 +974,10 @@ bool PerformInteractionRequest::CheckChoiceSetList_VRCommands( const smart_objects::SmartObject& choices_list = (*choice_set)[strings::choice_set]; - int vr_status = MessageHelper::CheckChoiceSet_VRCommands(choices_list); + auto vr_status = MessageHelper::CheckChoiceSetVRCommands(choices_list); // if not all choices have vr commands - if (vr_status != 0) { + if (vr_status != MessageHelper::ChoiceSetVRCommandsStatus::ALL) { LOG4CXX_ERROR(logger_, "PerformInteraction has choice sets with " "missing vrCommands, not in MANUAL_ONLY mode"); diff --git a/src/components/application_manager/src/message_helper/message_helper.cc b/src/components/application_manager/src/message_helper/message_helper.cc index 978724a671..31622bc911 100644 --- a/src/components/application_manager/src/message_helper/message_helper.cc +++ b/src/components/application_manager/src/message_helper/message_helper.cc @@ -326,6 +326,38 @@ smart_objects::SmartObjectSPtr MessageHelper::CreateMessageForHMI( return message; } +MessageHelper::ChoiceSetVRCommandsStatus MessageHelper::CheckChoiceSetVRCommands(const smart_objects::SmartObject& choice_set) { + // if this is false, someone doesn't have vrCommands + bool all_have = true; + // if this is false, someone has vrCommands + bool none_have = true; + smart_objects::SmartArray::const_iterator current_choice_set_it = + choice_set.asArray()->begin(); + // Iterate through choices + for (; choice_set.asArray()->end() != current_choice_set_it; + ++current_choice_set_it) { + // if the vrCommands is present + if (current_choice_set_it->keyExists( + application_manager::strings::vr_commands)) { + // this one has the parameter + none_have = false; + } else { + // this one doesn't + all_have = false; + } + } + // everyone has it + if (all_have) { + return MessageHelper::ChoiceSetVRCommandsStatus::ALL; + } + // No one has it + if (none_have) { + return MessageHelper::ChoiceSetVRCommandsStatus::NONE; + } + // mix-and-match, this is an error + return MessageHelper::ChoiceSetVRCommandsStatus::MIXED; +} + smart_objects::SmartObjectSPtr MessageHelper::CreateHashUpdateNotification( const uint32_t app_id) { LOG4CXX_AUTO_TRACE(logger_); -- cgit v1.2.1 From 8bb20b6fcc0cbb1bb777331359c60d4f728674e1 Mon Sep 17 00:00:00 2001 From: Conlain Kelly Date: Tue, 31 Jul 2018 10:13:17 -0400 Subject: more cleanup, add mock implementations --- .../include/application_manager/message_helper.h | 32 ++++++----- .../src/message_helper/message_helper.cc | 66 +++++++++++----------- .../application_manager/mock_message_helper.h | 3 + .../test/mock_message_helper.cc | 6 ++ 4 files changed, 62 insertions(+), 45 deletions(-) diff --git a/src/components/application_manager/include/application_manager/message_helper.h b/src/components/application_manager/include/application_manager/message_helper.h index f370cc6966..bfdadd40c9 100644 --- a/src/components/application_manager/include/application_manager/message_helper.h +++ b/src/components/application_manager/include/application_manager/message_helper.h @@ -635,6 +635,25 @@ class MessageHelper { smart_objects::SmartObject& image, ApplicationConstSharedPtr app, ApplicationManager& app_mngr); + + /** + * @brief Stores whether a choice set has correct VRCommands + * MIXED means some choices have VRCommands and others don't + * ALL means all do, NONE means none do + */ + enum ChoiceSetVRCommandsStatus { + MIXED, ALL, NONE + }; + + + /** + * @brief Check whether each choice in the set has the vrCommands parameter + * vrCommands is an all-or-none deal + * @param choice set to check + * @return a ChoiceSetVRCommandsStatus representing the state of the choice set + */ + static ChoiceSetVRCommandsStatus CheckChoiceSetVRCommands( + const smart_objects::SmartObject& choice_set); /* * @brief Finds "Image" structure in request and verify image file presence @@ -855,19 +874,6 @@ class MessageHelper { */ static smart_objects::SmartObjectSPtr CreateMessageForHMI( hmi_apis::messageType::eType message_type, const uint32_t correlation_id); - - enum ChoiceSetVRCommandsStatus { - MIXED, ALL, NONE - }; - - /** - * @brief Check whether each choice in the set has the vrCommands parameter - * vrCommands is an all-or-none deal - * @param choice set to check - * @return -1 for mixed, 0 if all choice include vrCommands, and 1 if none do - */ - static ChoiceSetVRCommandsStatus CheckChoiceSetVRCommands( - const smart_objects::SmartObject& choice_set); private: /** diff --git a/src/components/application_manager/src/message_helper/message_helper.cc b/src/components/application_manager/src/message_helper/message_helper.cc index 31622bc911..19458ef3b2 100644 --- a/src/components/application_manager/src/message_helper/message_helper.cc +++ b/src/components/application_manager/src/message_helper/message_helper.cc @@ -326,38 +326,6 @@ smart_objects::SmartObjectSPtr MessageHelper::CreateMessageForHMI( return message; } -MessageHelper::ChoiceSetVRCommandsStatus MessageHelper::CheckChoiceSetVRCommands(const smart_objects::SmartObject& choice_set) { - // if this is false, someone doesn't have vrCommands - bool all_have = true; - // if this is false, someone has vrCommands - bool none_have = true; - smart_objects::SmartArray::const_iterator current_choice_set_it = - choice_set.asArray()->begin(); - // Iterate through choices - for (; choice_set.asArray()->end() != current_choice_set_it; - ++current_choice_set_it) { - // if the vrCommands is present - if (current_choice_set_it->keyExists( - application_manager::strings::vr_commands)) { - // this one has the parameter - none_have = false; - } else { - // this one doesn't - all_have = false; - } - } - // everyone has it - if (all_have) { - return MessageHelper::ChoiceSetVRCommandsStatus::ALL; - } - // No one has it - if (none_have) { - return MessageHelper::ChoiceSetVRCommandsStatus::NONE; - } - // mix-and-match, this is an error - return MessageHelper::ChoiceSetVRCommandsStatus::MIXED; -} - smart_objects::SmartObjectSPtr MessageHelper::CreateHashUpdateNotification( const uint32_t app_id) { LOG4CXX_AUTO_TRACE(logger_); @@ -2729,6 +2697,40 @@ mobile_apis::Result::eType MessageHelper::VerifyImage( return result; } +MessageHelper::ChoiceSetVRCommandsStatus +MessageHelper::CheckChoiceSetVRCommands( + const smart_objects::SmartObject& choice_set) { + // if this is false, someone doesn't have vrCommands + bool all_have = true; + // if this is false, someone has vrCommands + bool none_have = true; + smart_objects::SmartArray::const_iterator current_choice_set_it = + choice_set.asArray()->begin(); + // Iterate through choices + for (; choice_set.asArray()->end() != current_choice_set_it; + ++current_choice_set_it) { + // if the vrCommands is present + if (current_choice_set_it->keyExists( + application_manager::strings::vr_commands)) { + // this one has the parameter + none_have = false; + } else { + // this one doesn't + all_have = false; + } + } + // everyone has it + if (all_have) { + return MessageHelper::ChoiceSetVRCommandsStatus::ALL; + } + // No one has it + if (none_have) { + return MessageHelper::ChoiceSetVRCommandsStatus::NONE; + } + // mix-and-match + return MessageHelper::ChoiceSetVRCommandsStatus::MIXED; +} + mobile_apis::Result::eType MessageHelper::VerifyImageVrHelpItems( smart_objects::SmartObject& message, ApplicationConstSharedPtr app, diff --git a/src/components/application_manager/test/include/application_manager/mock_message_helper.h b/src/components/application_manager/test/include/application_manager/mock_message_helper.h index 8641a3781e..8a06102e99 100644 --- a/src/components/application_manager/test/include/application_manager/mock_message_helper.h +++ b/src/components/application_manager/test/include/application_manager/mock_message_helper.h @@ -195,6 +195,9 @@ class MockMessageHelper { mobile_apis::Result::eType(smart_objects::SmartObject& message, ApplicationConstSharedPtr app, ApplicationManager& app_mngr)); + MOCK_METHOD1(CheckChoiceSetVRCommands, + MessageHelper::ChoiceSetVRCommandsStatus( + const smart_objects::SmartObject&)); MOCK_METHOD6(GetBCActivateAppRequestToHMI, smart_objects::SmartObjectSPtr( diff --git a/src/components/application_manager/test/mock_message_helper.cc b/src/components/application_manager/test/mock_message_helper.cc index 9e2eb75a55..8ab70130c2 100644 --- a/src/components/application_manager/test/mock_message_helper.cc +++ b/src/components/application_manager/test/mock_message_helper.cc @@ -340,6 +340,12 @@ mobile_apis::Result::eType MessageHelper::VerifyImage( message, app, app_mngr); } +MessageHelper::ChoiceSetVRCommandsStatus +MessageHelper::CheckChoiceSetVRCommands( + const smart_objects::SmartObject& choice_set) { + return MockMessageHelper::message_helper_mock()->CheckChoiceSetVRCommands(choice_set); +} + mobile_apis::Result::eType MessageHelper::VerifyImageFiles( smart_objects::SmartObject& message, ApplicationConstSharedPtr app, -- cgit v1.2.1 From b22c65d4181a67345e79f409fd61e780be01e48c Mon Sep 17 00:00:00 2001 From: Conlain Kelly Date: Tue, 31 Jul 2018 10:57:33 -0400 Subject: style fix --- .../include/application_manager/message_helper.h | 12 +++++------- .../application_manager/test/mock_message_helper.cc | 3 ++- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/components/application_manager/include/application_manager/message_helper.h b/src/components/application_manager/include/application_manager/message_helper.h index bfdadd40c9..8e59a7307f 100644 --- a/src/components/application_manager/include/application_manager/message_helper.h +++ b/src/components/application_manager/include/application_manager/message_helper.h @@ -635,22 +635,20 @@ class MessageHelper { smart_objects::SmartObject& image, ApplicationConstSharedPtr app, ApplicationManager& app_mngr); - + /** * @brief Stores whether a choice set has correct VRCommands * MIXED means some choices have VRCommands and others don't * ALL means all do, NONE means none do - */ - enum ChoiceSetVRCommandsStatus { - MIXED, ALL, NONE - }; + */ + enum ChoiceSetVRCommandsStatus { MIXED, ALL, NONE }; - /** * @brief Check whether each choice in the set has the vrCommands parameter * vrCommands is an all-or-none deal * @param choice set to check - * @return a ChoiceSetVRCommandsStatus representing the state of the choice set + * @return a ChoiceSetVRCommandsStatus representing the state of the choice + * set */ static ChoiceSetVRCommandsStatus CheckChoiceSetVRCommands( const smart_objects::SmartObject& choice_set); diff --git a/src/components/application_manager/test/mock_message_helper.cc b/src/components/application_manager/test/mock_message_helper.cc index 8ab70130c2..0850361a20 100644 --- a/src/components/application_manager/test/mock_message_helper.cc +++ b/src/components/application_manager/test/mock_message_helper.cc @@ -343,7 +343,8 @@ mobile_apis::Result::eType MessageHelper::VerifyImage( MessageHelper::ChoiceSetVRCommandsStatus MessageHelper::CheckChoiceSetVRCommands( const smart_objects::SmartObject& choice_set) { - return MockMessageHelper::message_helper_mock()->CheckChoiceSetVRCommands(choice_set); + return MockMessageHelper::message_helper_mock()->CheckChoiceSetVRCommands( + choice_set); } mobile_apis::Result::eType MessageHelper::VerifyImageFiles( -- cgit v1.2.1 From f03fb7d68fa0a7dfce37c3ded7f771ab2f033ee7 Mon Sep 17 00:00:00 2001 From: Conlain Kelly Date: Tue, 31 Jul 2018 12:52:17 -0400 Subject: remove maxes where possible, 255 is standin --- .../policy_external/include/policy/policy_table_interface_ext.xml | 3 +-- .../policy/policy_regular/include/policy/policy_table/types.h | 2 +- src/components/policy/policy_regular/policy_table_interface_ext.xml | 3 +-- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/components/policy/policy_external/include/policy/policy_table_interface_ext.xml b/src/components/policy/policy_external/include/policy/policy_table_interface_ext.xml index 7979a0f2ba..89788daf6a 100644 --- a/src/components/policy/policy_external/include/policy/policy_table_interface_ext.xml +++ b/src/components/policy/policy_external/include/policy/policy_table_interface_ext.xml @@ -98,8 +98,7 @@ - + - - - - - - - - - - - - + + + + + + + + + + + + - - - - - - + + + + + + - + minutesFieldWidth = 2;minutesFieldMax = 19;secondsFieldWidth = 2;secondsFieldMax = 99;maxHours = 19;maxMinutes = 59;maxSeconds = 59; @@ -612,7 +613,7 @@ used for Type V headunit - + minutesFieldWidth = 2;minutesFieldMax = 59;secondsFieldWidth = 2;secondsFieldMax = 59;maxHours = 9;maxMinutes = 59;maxSeconds = 59; used for GEN1.1 MFD3/4/5 headunits @@ -649,7 +650,7 @@ used for Type V headunit - + 6 chars possible Format: c :|sp c c : c c @@ -660,22 +661,25 @@ - + See DAES for further infos regarding the displays - - - - - - - + + + + + + + + + + - + The first line of first set of main fields of the persistent display; applies to "Show" @@ -708,51 +712,51 @@ The first line of the alert text field; applies to "Alert" - + The second line of the alert text field; applies to "Alert" - + The third line of the alert text field; applies to "Alert" - + Long form body of text that can include newlines and tabs; applies to "ScrollableMessage" - + First line suggestion for a user response (in the case of VR enabled interaction) - + First line of navigation text - + Second line of navigation text - + Estimated Time of Arrival time for navigation - + Total distance to destination for navigation - + First line of text for audio pass thru - + Second line of text for audio pass thru - + Header text for slider - + Footer text for slider @@ -772,25 +776,25 @@ Optional text to label an app menu button (for certain touchscreen platforms). - + Optional name / title of intended location for SendLocation. - + Optional description of intended location / establishment (if applicable) for SendLocation. - + Optional location address (if applicable) for SendLocation. - + Optional hone number of intended location / establishment (if applicable) for SendLocation. - + The image field for SoftButton @@ -827,7 +831,7 @@ The primary image field for Show - + The secondary image field for Show @@ -839,13 +843,13 @@ The secondary image field for ShowConstantTBT - + The optional image of a destination / location - + The list of potential character sets See [@TODO: create file ref] @@ -861,14 +865,14 @@ - + The list of possible alignments, left, right, or centered - + Enumeration that describes possible states of turn-by-turn client or AppLink app. @@ -882,26 +886,26 @@ - + Enumeration that describes possible states of driver distraction. - + Contains information about the type of image. - + The mode in which the SendLocation request is sent - + Enum for each type of video streaming protocol type. Raw stream bytes that contains no timestamp data and is the lowest supported video streaming @@ -920,7 +924,7 @@ - + Enum for each type of video streaming codec. A block-oriented motion-compensation-based video compression standard. As of 2014 it is one of the most commonly used formats for the recording, compression, and distribution of video content. @@ -939,19 +943,19 @@ - + Either the static hex icon value or the binary image file name identifier (sent by PutFile). Describes, whether it is a static or dynamic image. - + Optional value to specify whether it's a template image. A template image can be (re)colored by the HMI as needed by using an image pattern - + Describes, whether it is text, highlighted text, icon, or dynamic image. See softButtonType @@ -975,24 +979,24 @@ - + A choice is an option given to the user, which can be selected either by menu, or through voice recognition system. - - + + Optional secondary text to display; e.g. address of POI in a search result entry - + Optional tertiary text to display; e.g. distance to POI for a search result entry - + Optional secondary image struct for choice - + Text to display for VR Help item @@ -1004,7 +1008,7 @@ - + Specifies the version number of the SmartDeviceLink protocol that is supported by the mobile application @@ -1013,37 +1017,37 @@ The minor version indicates a change to a previous version that should still allow to be run on an older version (with limited functionality) - + The patch version indicates a fix to existing functionality in a previous version that should still be able to be run on an older version - + The different global properties. - + The property helpPrompt of setGlobalProperties - + The property timeoutPrompt of setGlobalProperties - + The property vrHelpTitle of setGlobalProperties - + The property array of vrHelp of setGlobalProperties - + The property in-app menu name of setGlobalProperties - + The property in-app menu icon of setGlobalProperties - + The on-screen keyboard configuration of setGlobalProperties - + The list of potential compass directions @@ -1063,7 +1067,7 @@ - + The supported dimensions of the GPS No GPS at all @@ -1076,7 +1080,7 @@ - + The selected gear. Parking @@ -1117,7 +1121,7 @@ - + The volume status of a vehicle component. @@ -1133,7 +1137,7 @@ - + If set the status of the tire is not known. @@ -1160,7 +1164,7 @@ - + Park brake actuators have been fully applied. @@ -1188,7 +1192,7 @@ - + @@ -1209,7 +1213,7 @@ - + @@ -1218,19 +1222,19 @@ - + See ComponentVolumeStatus. - + The status of TPMS according to the particular tire. - + The pressure value of the particular tire in kilo pascal. - + Reflects the status of a cluster instrument warning light. @@ -1242,7 +1246,7 @@ - + Reflects the status of a vehicle data notification. @@ -1254,7 +1258,7 @@ - + Reflects the ignition switch stability. @@ -1264,7 +1268,7 @@ - + Reflects the status of ignition. @@ -1280,7 +1284,7 @@ - + Reflects the status of a vehicle data event; e.g. a seat belt event status. @@ -1294,7 +1298,7 @@ - + Reflects the reported battery status of the connected device, if reported. @@ -1310,7 +1314,7 @@ - + Reflects the current primary audio source (if selected). @@ -1328,7 +1332,7 @@ - + Reflects the status of the wipers. @@ -1347,7 +1351,7 @@ - + Reflects the status of a binary vehicle data item. @@ -1357,7 +1361,7 @@ - + Reflects the status of a vehicle maintenance mode. @@ -1369,7 +1373,7 @@ - + Reflects the status of given vehicle component. @@ -1383,7 +1387,7 @@ - + Reflects the status of the ambient light sensor. @@ -1395,45 +1399,45 @@ - + - + - + - + - + - + - + - + References signal "VedsDrvBelt_D_Ltchd". See VehicleDataEventStatus. @@ -1481,7 +1485,7 @@ - + References signal "PrkBrkActv_B_Actl". @@ -1505,7 +1509,7 @@ - + References signal "CPM_VoiceRec_STAT". @@ -1541,7 +1545,7 @@ - + Status of the low beam lamps. References signal "HeadLampLoActv_B_Stat". @@ -1553,7 +1557,7 @@ - + Contains detailed information about the registered application. @@ -1576,7 +1580,7 @@ - + Enumeration listing possible file types. @@ -1588,7 +1592,7 @@ - + Reflects the status of the RCM fuel cutoff. @@ -1598,7 +1602,7 @@ - + Reflects the emergency event status of the vehicle. @@ -1616,7 +1620,7 @@ - + Reflects the status of the eCall Notification. @@ -1634,7 +1638,7 @@ - + Reflects the status of the current power mode qualification. @@ -1646,7 +1650,7 @@ - + Reflects the status of the current power mode. @@ -1668,7 +1672,7 @@ - + Reflects the status of the current car mode. @@ -1680,7 +1684,7 @@ - + References signal "eCallNotification_4A". See VehicleDataNotificationStatus. @@ -1692,7 +1696,7 @@ - + References signal "VedsDrvBag_D_Ltchd". See VehicleDataEventStatus. @@ -1719,7 +1723,7 @@ - + References signal "VedsEvntType_D_Ltchd". See EmergencyEventType. @@ -1742,7 +1746,7 @@ - + References signal "PowerMode_UB". @@ -1757,7 +1761,7 @@ - + Indicates whether e911 override is on. References signal "MyKey_e911Override_St". See VehicleDataStatus. @@ -1767,7 +1771,7 @@ - + Enumeration that describes possible result codes of a vehicle data entry request. Individual vehicle data item / DTC / DID request or subscription successful @@ -1798,7 +1802,7 @@ - + The status and pressure of the tires. @@ -1825,7 +1829,7 @@ - + Enumeration that describes the status of the turn light indicator. Turn signal is OFF @@ -1841,7 +1845,7 @@ - + Struct with the GPS data. @@ -1948,7 +1952,7 @@ - + Individual published data request result Defined published data element type. @@ -1958,7 +1962,7 @@ - + Individual requested DID result and data Individual DID result code. @@ -1971,7 +1975,7 @@ - + The hour of the media clock. @@ -1982,7 +1986,7 @@ - + The name that identifies the field. See TextFieldName. @@ -1997,7 +2001,7 @@ - + The image resolution width. @@ -2006,7 +2010,7 @@ - + The name that identifies the field. See ImageFieldName. @@ -2018,7 +2022,7 @@ - + The x coordinate of the touch. @@ -2027,14 +2031,14 @@ - + - + - + A touch's unique identifier. The application can track the current touch events by id. @@ -2054,7 +2058,7 @@ - + @@ -2063,7 +2067,7 @@ - + The resolution of the prescribed screen area. @@ -2072,7 +2076,7 @@ - + Enumeration that describes possible permission states of a policy table entry. @@ -2080,7 +2084,7 @@ - + A set of all HMI levels that are permitted for this given RPC. @@ -2089,7 +2093,7 @@ - + A set of all parameters that are permitted for this given RPC. @@ -2098,7 +2102,7 @@ - + Name of the individual RPC in the policy table. @@ -2106,12 +2110,15 @@ - + Contains information about the display capabilities. - + The type of the display. See DisplayType + + + - + The name of the display the app is connected to. @@ -2123,22 +2130,23 @@ A set of all supported formats of the media clock. See MediaClockFormat - + The display's persistent screen supports referencing a static or dynamic image. - + A set of all predefined persistent display templates available on headunit. To be referenced in SetDisplayLayout. - + A set of all parameters related to a prescribed screen area (e.g. for video / touch input). - + The number of on-screen custom presets available (if any); otherwise omitted. - + + Contains information about a button's capabilities. The name of the button. See ButtonName. @@ -2163,7 +2171,8 @@ - + + Contains information about a SoftButton's capabilities. @@ -2188,27 +2197,30 @@ The button supports referencing a static or dynamic image. - + + Contains information about on-screen preset capabilities. Onscreen custom presets are available. - + + Availability of build in Nav. True: Available, False: Not Available Availability of build in phone. True: Available, False: Not Available - + Availability of video streaming. - + Availability of remote control feature. True: Available, False: Not Available - - + + + unique ID of the sub menu, the command will be added to. @@ -2227,8 +2239,9 @@ Text to show in the menu for this sub menu. - - + + + A TTS chunk, that consists of text/phonemes to speak or the name of a file to play, and a TTS type (like text or SAPI) @@ -2236,11 +2249,13 @@ May not be empty. + Describes whether the TTS chunk is plain text, a specific phoneme set, or an audio file. See SpeechCapabilities - + + Individual turn text. Must provide at least text or icon for a given turn. @@ -2248,7 +2263,8 @@ Individual turn icon. Must provide at least text or icon for a given turn. - + + Make of the vehicle, e.g. Ford @@ -2261,14 +2277,16 @@ Trim of the vehicle, e.g. SE - - + + + Enumeration listing possible keyboard layouts. - + + Enumeration listing possible keyboard events. @@ -2276,7 +2294,8 @@ - + + Enumeration listing possible keyboard events. Each keypress is individually sent as the user presses the keyboard keys. @@ -2288,7 +2307,8 @@ The keypresses are queue and a string is sent each time the user presses a keyboard key; the string contains the entire current entry. - + + Configuration of on-screen keyboard (if available). The keyboard language. @@ -2311,7 +2331,8 @@ Allows an app to prepopulate the text field with a suggested or completed entry as the user types - + + Various information about connecting device. Device model @@ -2332,7 +2353,8 @@ Omitted if connected not via BT. - + + Enumeration listing possible asynchronous requests. @@ -2354,9 +2376,10 @@ - + - + + Enumeration listing possible app types. @@ -2368,10 +2391,11 @@ - - + + - + + Predefined screen layout. @@ -2494,104 +2518,105 @@ - + + Enumeration linking function names with function IDs in AppLink protocol. Assumes enumeration starts at value 0. - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + - - + + - - + + - + Enumeration linking message types with function types in WiPro protocol. Assumes enumeration starts at value 0. @@ -2601,43 +2626,67 @@ - - + + Milliseconds - + Seconds part of time + + + - + Minutes part of time + + + - + Hours part of time. Note that this structure accepts time only in 24 Hr format + + + - + Day of the month + + + - + Month of the year + + + - + The year in YYYY format + + + - + Time zone offset in Hours wrt UTC. + + + - + Time zone offset in Min wrt UTC. + + + - + Describes what kind of waypoint is requested/provided. - + Latitude of the location. @@ -2646,7 +2695,7 @@ - + Name of the country (localized) @@ -2676,7 +2725,7 @@ - + Latitude/Longitude of the location. @@ -2700,7 +2749,7 @@ - + Enumerations of all available system capability types @@ -2708,7 +2757,7 @@ - + Extended capabilities for an onboard navigation system If the module has the ability to add locations to the onboard nav @@ -2718,14 +2767,14 @@ - + Extended capabilities of the module's phone feature If the module has the ability to perform dial number - + Video streaming formats and their specifications. Protocol type, see VideoStreamingProtocol @@ -2735,7 +2784,7 @@ - + Contains information about this system's video streaming capabilities. The preferred resolution of a video stream for decoding and rendering on HMI. @@ -2753,7 +2802,7 @@ - + List possible zones of a multi-contour massage seat. The back of a multi-contour massage seat. or SEAT_BACK @@ -2763,20 +2812,20 @@ - + List possible modes of a massage zone. - + Specify the mode of a massage zone. - + List possible cushions of a multi-contour massage seat. @@ -2785,13 +2834,13 @@ - + The intensity or firmness of a cushion. - + Save current seat postions and settings to seat memory. @@ -2803,19 +2852,19 @@ - + - + List possible seats that is a remote controllable seat. - + Seat control data corresponds to "SEAT" ModuleType. @@ -2839,7 +2888,7 @@ - + The short friendly name of the light control module. @@ -2878,7 +2927,7 @@ - + Temperature Unit @@ -2887,7 +2936,7 @@ - + Program Service Name @@ -2914,7 +2963,7 @@ - + The integer part of the frequency ie for 101.7 this value should be 101 @@ -2937,13 +2986,13 @@ If the signal strength falls below the set value for this parameter, the radio will tune to an alternative frequency - True if the radio is on, false is the radio is off + True if the radio is on, false is the radio is off. If set to false, no other data will be included. - + @@ -2965,8 +3014,8 @@ - - + + Contains information about a radio control module's capabilities. @@ -3031,7 +3080,7 @@ - + Contains information about a climate control module's capabilities. @@ -3104,7 +3153,7 @@ - + The moduleType indicates which type of data should be changed and identifies which data object exists in this struct. For example, if the moduleType is CLIMATE then a "climateControlData" should exist @@ -3112,11 +3161,11 @@ - + - + If included, the platform supports RC climate controls. For this baseline version, maxsize=1. i.e. only one climate control module is supported. @@ -3126,7 +3175,7 @@ If included, the platform supports RC button controls with the included button names. - + If included, the platform supports seat controls. @@ -3134,7 +3183,7 @@ - + The systemCapabilityType indicates which type of data should be changed and identifies which data object exists in this struct. For example, if the SystemCapability Type is NAVIGATION then a "navigationCapability" should exist Used as a descriptor of what data to expect in this struct. The corresponding param to this enum should be included and the only other para included. @@ -3153,7 +3202,7 @@ - + The data in this field contains the title of the currently playing audio track. @@ -3192,7 +3241,7 @@ - + The type of data contained in the "mainField1" text field. @@ -3207,7 +3256,7 @@ - + The upper left X-coordinate of the rectangle @@ -3222,7 +3271,7 @@ - + Defines haptic data for each user control object for video streaming application A user control spatial identifier @@ -3232,13 +3281,13 @@ - + - + A color scheme for all display layout templates. @@ -3254,17 +3303,17 @@ - + Establishes an interface with a mobile application. Before registerAppInterface no other commands will be accepted/executed. - + See SyncMsgVersion - + The mobile application name, e.g. "Ford Drive Green". Needs to be unique over all applications. @@ -3276,7 +3325,7 @@ - + TTS string for VR recognition of the mobile application name, e.g. "Ford Drive Green". Meant to overcome any failing on speech engine in properly pronouncing / understanding app name. @@ -3287,7 +3336,7 @@ - + Provides an abbreviated version of the app name (if needed), that will be displayed on the NGN media screen. If not provided, the appName is used instead (and will be truncated if too long) @@ -3295,7 +3344,7 @@ - + Defines an additional voice recognition command. May not interfere with any app name of previously registered applications and any predefined blacklist of words (global commands) @@ -3303,20 +3352,20 @@ - + Indicates if the application is a media or a non-media application. Only media applications will be able to stream audio to the module that is audible outside of the BT media source. - + See Language Current app's expected VR+TTS language If there is a mismatch with the module, the app will be able to change this registration with changeRegistration prior to app being brought into focus. - + See Language Current app's expected display language @@ -3324,14 +3373,14 @@ - + See AppHMIType List of all applicable app HMI types stating which HMI classifications to be given to the app. - + ID used to uniquely identify current state of all app data that can persist through connection cycles (e.g. ignition cycles). This registered data (commands, submenus, choice sets, etc.) can be reestablished without needing to explicitly reregister each piece. @@ -3339,26 +3388,26 @@ When sending hashID, all RegisterAppInterface parameters should still be provided (e.g. ttsName, etc.). - + See DeviceInfo. - + ID used to validate app with policy table entries - + See AppInfo. - + - + - + The response to registerAppInterface @@ -3394,7 +3443,7 @@ The currently active VR+TTS language on the module. See "Language" for options. - + The currently active display language on the module. See "Language" for options. @@ -3406,59 +3455,59 @@ See ButtonCapabilities - + If returned, the platform supports on-screen SoftButtons; see SoftButtonCapabilities. - + If returned, the platform supports custom on-screen Presets; see PresetBankCapabilities. - + See HmiZoneCapabilities - + See SpeechCapabilities - + See PrerecordedSpeech - + See VrCapabilities - + See AudioPassThruCapability - + See AudioPassThruCapability - + Specifies the vehicle's type. See VehicleType. - + Specifies the white-list of supported diagnostic modes (0x00-0xFF) capable for DiagnosticMessage requests. If a mode outside this list is requested, it will be rejected. - + Specifies the HMI’s capabilities. See HMICapabilities. - + The SmartDeviceLink version. - + The software version of the system that implements the SmartDeviceLink core. - + Existence of apps icon at system. If true, apps icon was resumed at system. If false, apps icon is not resumed at system @@ -3466,7 +3515,7 @@ - + Closes an interface from a mobile application. After unregisterAppInterface, no commands other than registerAppInterface will be accepted/executed. @@ -3474,7 +3523,7 @@ - + true if successful; false, if failed @@ -3496,10 +3545,10 @@ - + Allows setting global properties. - + The help prompt. An array of text chunks of type TTSChunk. See TTSChunk. @@ -3507,7 +3556,7 @@ - + Help text for a wait timeout. An array of text chunks of type TTSChunk. See TTSChunk. @@ -3515,7 +3564,7 @@ - + VR Help Title text. If omitted on supported displays, the default module help title shall be used. @@ -3523,7 +3572,7 @@ - + VR Help Items. If omitted on supported displays, the default AppLink VR help / What Can I Say? screen shall be used. @@ -3531,20 +3580,20 @@ If omitted and a vrHelpTitle is provided, the request will be rejected. - + Optional text to label an app menu button (for certain touchscreen platforms). - - >Optional icon to draw on an app menu button (for certain touchscreen platforms). + + Optional icon to draw on an app menu button (for certain touchscreen platforms). - + On-screen keyboard configuration (if available). - + true if successful; false, if failed @@ -3570,7 +3619,7 @@ - + Allows resetting global properties. @@ -3578,7 +3627,7 @@ - + true if successful; false, if failed @@ -3601,7 +3650,7 @@ - + Adds a command to the in application menu. Either menuParams or vrCommands must be provided. @@ -3622,7 +3671,7 @@ - + Image struct determining whether static or dynamic icon. If omitted on supported displays, no (or the default if applicable) icon shall be displayed. @@ -3631,7 +3680,7 @@ - + true if successful; false, if failed @@ -3659,7 +3708,7 @@ - + Deletes all commands from the in-application menu with the specified command id. @@ -3668,7 +3717,7 @@ - + true if successful; false, if failed @@ -3692,7 +3741,7 @@ - + Adds a sub menu to the in-application menu. @@ -3713,12 +3762,12 @@ Text to show in the menu for this sub menu. - + The image field for AddSubMenu - + true if successful; false, if failed @@ -3741,7 +3790,7 @@ - + Deletes a submenu from the in-application menu. @@ -3750,7 +3799,7 @@ - + true if successful; false, if failed @@ -3775,7 +3824,7 @@ - + creates interaction choice set to be used later by performInteraction @@ -3785,7 +3834,7 @@ - + true if successful; false, if failed @@ -3809,7 +3858,7 @@ - + Triggers an interaction (e.g. "Permit GPS?" - Yes, no, Always Allow). @@ -3858,21 +3907,20 @@ - + Ability to send suggested VR Help Items to display on-screen during Perform Interaction. If omitted on supported displays, the default generated list of suggested choices shall be displayed. - + See LayoutMode. - - + true if successful; false, if failed @@ -3905,7 +3953,7 @@ - + Manually entered text selection, e.g. through keyboard Can be returned in lieu of choiceID, depending on trigger source @@ -3921,7 +3969,7 @@ - + Deletes interaction choice set that has been created with "CreateInteractionChoiceSet". The interaction may only be deleted when not currently in use by a "performInteraction". @@ -3930,7 +3978,7 @@ - + true if successful; false, if failed @@ -3953,7 +4001,7 @@ - + Shows an alert which typically consists of text-to-speech message and text on the display. At least either alertText1, alertText2 or TTSChunks need to be provided. @@ -3964,7 +4012,7 @@ The second line of the alert text field - + The optional third line of the alert text field @@ -3990,13 +4038,13 @@ - + If supported on the given platform, the alert GUI will include some sort of animation indicating that loading of a feature is progressing. e.g. a spinning wheel or hourglass, etc. - + App defined SoftButtons. If omitted on supported displays, the displayed alert shall not have any SoftButtons. @@ -4005,7 +4053,7 @@ - + true if successful; false, if failed @@ -4031,7 +4079,7 @@ Provides additional human readable info regarding the result. - + Amount of time (in seconds) that an app must wait before resending an alert. If provided, another system event or overlay currently has a higher priority than this alert. @@ -4041,10 +4089,10 @@ - + Updates the persistent display. Supported fields depend on display capabilities. - + The text that should be displayed in a single or upper display line. If this text is not set, the text of mainField1 stays unchanged. @@ -4052,7 +4100,7 @@ - + The text that should be displayed on the second display line. If this text is not set, the text of mainField2 stays unchanged. @@ -4060,7 +4108,7 @@ - + The text that should be displayed on the second "page" first display line. If this text is not set, the text of mainField3 stays unchanged. @@ -4068,7 +4116,7 @@ - + The text that should be displayed on the second "page" second display line. If this text is not set, the text of mainField4 stays unchanged. @@ -4076,25 +4124,25 @@ - + Specifies how mainField1 and mainField2 texts should be aligned on display. If omitted, texts will be centered. - + Requires investigation regarding the nav display capabilities. Potentially lower lowerStatusBar, upperStatusBar, titleBar, etc. - + Text value for MediaClock field. Has to be properly formatted by Mobile App according to the module's capabilities. If this text is set, any automatic media clock updates previously set with SetMediaClockTimer will be stopped. - + The text that should be displayed in the track field. If this text is not set, the text of mediaTrack stays unchanged. @@ -4102,43 +4150,42 @@ - + Image struct determining whether static or dynamic image to display in app. If omitted on supported displays, the displayed graphic shall not change. - + Image struct determining whether static or dynamic secondary image to display in app. If omitted on supported displays, the displayed secondary graphic shall not change. - - + App defined SoftButtons. If omitted on supported displays, the currently displayed SoftButton values will not change. - + App labeled on-screen presets (i.e. on-screen media presets or dynamic search suggestions). If omitted on supported displays, the presets will be shown as not defined. - + App defined metadata information. See MetadataStruct. Uses mainField1, mainField2, mainField3, mainField4. If omitted on supported displays, the currently set metadata tags will not change. If any text field contains no tags or the none tag, the metadata tag for that textfield should be removed. - + true if successful; false, if failed @@ -4164,7 +4211,7 @@ - + Speaks a text. @@ -4176,7 +4223,7 @@ - + true if successful; false, if failed @@ -4202,7 +4249,7 @@ - + Sets the initial media clock value and automatic update method. @@ -4214,7 +4261,7 @@ - + See StartTime. endTime can be provided for "COUNTUP" and "COUNTDOWN"; to be used to calculate any visual progress bar (if not provided, this feature is ignored) @@ -4230,12 +4277,12 @@ In case of pause, resume, or clear, the start time value is ignored and shall be left out. For resume, the time continues with the same value as it was when paused. - - Indicates that a button press of the Play/Pause button would play, pause or Stop the current playback. - + + Indicates that a button press of the Play/Pause button would play, pause or Stop the current playback. + - + true if successful; false, if failed @@ -4257,7 +4304,7 @@ - + Starts audio pass thru session @@ -4293,7 +4340,7 @@ - + true if successful; false, if failed @@ -4318,11 +4365,11 @@ - + When this request is invoked, the audio capture stops. - + true if successful; false, if failed @@ -4344,7 +4391,7 @@ - + Subscribes to built-in HMI buttons. The application will be notified by the OnButtonEvent and OnButtonPress. @@ -4356,7 +4403,7 @@ - + true if successful; false, if failed @@ -4379,7 +4426,7 @@ - + Unsubscribes from built-in HMI buttons. @@ -4387,7 +4434,7 @@ - + true if successful; false, if failed @@ -4410,7 +4457,7 @@ - + Subscribes for specific published data items. The data will be only sent if it has changed. @@ -4436,13 +4483,13 @@ The instantaneous fuel consumption in microlitres - + The estimate range in KM the vehicle can travel based on fuel level and consumption The external temperature in degrees celsius - + See TurnSignal @@ -4481,10 +4528,10 @@ Current angle of the steering wheel (in deg) - + The estimated percentage of remaining oil life of the engine. - + The status of the park brake as provided by Electric Park Brake (EPB) system. @@ -4510,7 +4557,7 @@ - + true, if successful; false, if failed @@ -4552,13 +4599,13 @@ The instantaneous fuel consumption in microlitres - + The estimate range in KM the vehicle can travel based on fuel level and consumption The external temperature in degrees celsius. - + See TurnSignal @@ -4597,10 +4644,10 @@ Current angle of the steering wheel (in deg) - + The estimated percentage of remaining oil life of the engine. - + The status of the park brake as provided by Electric Park Brake (EPB) system. @@ -4625,7 +4672,7 @@ - + This function is used to unsubscribe the notifications from the subscribeVehicleData function. @@ -4646,13 +4693,13 @@ The instantaneous fuel consumption in microlitres - + The estimate range in KM the vehicle can travel based on fuel level and consumption The external temperature in degrees celsius. - + See TurnSignal @@ -4691,10 +4738,10 @@ Current angle of the steering wheel (in deg) - + The estimated percentage of remaining oil life of the engine. - + The status of the park brake as provided by Electric Park Brake (EPB) system. @@ -4719,7 +4766,7 @@ - + true, if successful; false, if failed @@ -4760,13 +4807,13 @@ The instantaneous fuel consumption in microlitres - + The estimate range in KM the vehicle can travel based on fuel level and consumption The external temperature in degrees celsius - + See TurnSignal @@ -4805,10 +4852,10 @@ Current angle of the steering wheel (in deg) - + The estimated percentage of remaining oil life of the engine. - + The status of the park brake as provided by Electric Park Brake (EPB) system. @@ -4833,7 +4880,7 @@ - + Non periodic vehicle data read request. @@ -4854,13 +4901,13 @@ The instantaneous fuel consumption in microlitres - + The estimate range in KM the vehicle can travel based on fuel level and consumption The external temperature in degrees celsius - + See TurnSignal @@ -4902,10 +4949,10 @@ Current angle of the steering wheel (in deg) - + The estimated percentage of remaining oil life of the engine. - + The status of the park brake as provided by Electric Park Brake (EPB) system. @@ -4930,7 +4977,7 @@ - + true, if successful; false, if failed @@ -4972,13 +5019,13 @@ The instantaneous fuel consumption in microlitres - + The estimate range in KM the vehicle can travel based on fuel level and consumption The external temperature in degrees celsius - + See TurnSignal @@ -5020,10 +5067,10 @@ Current angle of the steering wheel (in deg) - + The estimated percentage of remaining oil life of the engine. - + The status of the park brake as provided by Electric Park Brake (EPB) system. @@ -5048,7 +5095,7 @@ - + Non periodic vehicle data read request @@ -5059,7 +5106,7 @@ - + true, if successful; false, if failed @@ -5089,7 +5136,7 @@ - + Vehicle module diagnostic trouble code request. @@ -5102,7 +5149,7 @@ - + true, if successful; false, if failed @@ -5139,7 +5186,7 @@ - + Non periodic vehicle diagnostic request @@ -5157,7 +5204,7 @@ - + true, if successful; false, if failed @@ -5189,7 +5236,7 @@ - + Creates a full screen overlay containing a large block of formatted text that can be scrolled with up to 8 SoftButtons defined Body of text that can include newlines and tabs. @@ -5205,7 +5252,7 @@ - + true, if successful; false, if failed @@ -5231,7 +5278,7 @@ - + Creates a full screen or pop-up overlay (depending on platform) with a single user controlled slider. Number of selectable items on a horizontal axis @@ -5259,7 +5306,7 @@ - + true, if successful; false, if failed @@ -5292,40 +5339,40 @@ - - + + - + - + - + - + - + - + - + Fraction of distance till next maneuver (starting from when AlertManeuver is triggered). Used to calculate progress bar. - + Distance till next maneuver (starting from) from previous maneuver. Used to calculate progress bar. - + If and when a maneuver has completed while an AlertManeuver is active, the app must send this value set to TRUE in order to clear the AlertManeuver overlay. If omitted the value will be assumed as FALSE. - + Three dynamic SoftButtons available (first SoftButton is fixed to "Turns"). If omitted on supported displays, the currently displayed SoftButton values will not change. @@ -5333,7 +5380,7 @@ - + true, if successful; false, if failed @@ -5355,7 +5402,7 @@ - + An array of text chunks of type TTSChunk. See TTSChunk @@ -5364,7 +5411,7 @@ - + true, if successful; false, if failed @@ -5389,7 +5436,7 @@ - + @@ -5397,7 +5444,7 @@ - + true, if successful; false, if failed @@ -5419,32 +5466,29 @@ - + Requested voice engine (VR+TTS) language registration Request display language registration - + Request new app name registration - + Request new ttsName registration - + Request new app short name registration - + Request new VR synonyms registration - - - - + true, if successful @@ -5470,7 +5514,7 @@ - + Generic Response is sent, when the name of a received msg cannot be retrieved. Only used in case of an error. Currently, only resultCode INVALID_DATA is used. @@ -5489,7 +5533,7 @@ - + Used to push a binary data onto the module from a mobile device, such as icons and album art Not supported on first generation of SDL enabled modules. @@ -5531,12 +5575,12 @@ If offset is set to 0, then length is the total length of the file to be downloaded - + Additional CRC32 checksum to protect data integrity up to 512 Mbits . - + Response is sent, when the file data was copied (success case). Or when an error occurred. Not supported on first generation SDL enabled vehicles. @@ -5568,7 +5612,7 @@ - + Used to delete a file resident on the module in the app's local cache. Not supported on first generation SDL enabled vehicles. @@ -5580,7 +5624,7 @@ - + Response is sent, when the file data was deleted (success case). Or when an error occurred. Not supported on First generation SDL enabled vehicles. @@ -5610,14 +5654,14 @@ - + Requests the current list of resident filenames for the registered app. Not supported on first generation SDL enabled vehicles. - + Returns the current list of resident filenames for the registered app along with the current space available Not supported on First generation SDL enabled vehicles. @@ -5654,7 +5698,7 @@ - + Used to set existing local file on the module as the app's icon Not supported on first generation SDL enabled vehicles. @@ -5666,7 +5710,7 @@ - + Response is sent, when the file data was copied (success case). Or when an error occurred. Not supported on First generation SDL enabled vehicles. @@ -5694,7 +5738,7 @@ - + Used to set an alternate display layout. If not sent, default screen for given platform will be shown @@ -5707,12 +5751,12 @@ - + - + - + true, if successful; false, if failed @@ -5739,11 +5783,11 @@ - If returned, the platform supports on-screen SoftButtons; see SoftButtonCapabilities. + If returned, the platform supports on-screen SoftButtons; see SoftButtonCapabilities. - If returned, the platform supports custom on-screen Presets; see PresetBankCapabilities. + If returned, the platform supports custom on-screen Presets; see PresetBankCapabilities. @@ -5752,7 +5796,7 @@ - + An asynchronous request from the device; binary data can be included in hybrid part of message for some requests (such as HTTP, Proprietary, or Authentication requests) @@ -5760,7 +5804,7 @@ Note that Proprietary requests should forward the binary data to the known proprietary module on the system. - + This parameter is filled for supporting OEM proprietary data exchanges. @@ -5774,7 +5818,7 @@ - + true, if successful; false, if failed @@ -5800,7 +5844,7 @@ - + @@ -5831,21 +5875,21 @@ - + timestamp in ISO 8601 format - + Address to be used for setting destination - + Defines the mode of prompt for user - + true, if successful; false, if failed @@ -5868,7 +5912,7 @@ - + Dials a phone number and switches to phone application. @@ -5879,7 +5923,7 @@ - + true, if successful false, if failed @@ -5901,7 +5945,7 @@ - + The module where the button should be pressed @@ -5913,7 +5957,7 @@ - + See Result @@ -5934,22 +5978,25 @@ - + The type of a RC module to retrieve module data from the vehicle. In the future, this should be the Identification of a module. - + If subscribe is true, the head unit will register onInteriorVehicleData notifications for the requested moduelType. If subscribe is false, the head unit will unregister onInteriorVehicleData notifications for the requested moduelType. + + + - + @@ -5980,13 +6027,13 @@ - + The module data to set for the requested RC module. - + Used to set the values of one remote control module @@ -6013,11 +6060,11 @@ - + To subscribe in getting changes for Waypoints/destinations - + true, if successful; false, if failed @@ -6036,14 +6083,14 @@ - + Request for getting waypoint/destination data. To request for either the destination only or for all waypoints including destination - + true, if successful; false, if failed @@ -6067,11 +6114,11 @@ - + Request to unsubscribe from WayPoints and Destination - + true, if successful; false, if failed @@ -6093,14 +6140,14 @@ - + Request for expanded information about a supported system/HMI capability The type of system capability to get more information on - + @@ -6130,14 +6177,14 @@ - + Send the spatial data gathered from SDLCarWindow or VirtualDisplayEncoder to the HMI. This data will be utilized by the HMI to determine how and when haptic events should occur Array of spatial data structures that represent the locations of all user controls present on the HMI. This data should be updated if/when the application presents a new screen. When a request is sent, if successful, it will replace all spatial data previously sent through RPC. If an empty array is sent, the existing spatial data will be cleared - + true if successful; false if failed @@ -6153,7 +6200,7 @@ - + See HMILevel @@ -6165,40 +6212,40 @@ See SystemContext - + See VideoStreamingState. If it is NOT_STREAMABLE, the app must stop streaming video to SDL. - + See AppInterfaceUnregisteredReason - + Notifies application of UP/DOWN events for buttons to which the application is subscribed. Indicates whether this is an UP or DOWN event. - + If ButtonName is "CUSTOM_BUTTON", this references the integer ID passed by a custom button. (e.g. softButton ID) - + Notifies application of LONG/SHORT press events for buttons to which the application is subscribed. Indicates whether this is a LONG or SHORT button press event. - + If ButtonName is "CUSTOM_BUTTON", this references the integer ID passed by a custom button. (e.g. softButton ID) - + Callback for the periodic and non periodic vehicle data read function. See GPSData @@ -6218,13 +6265,13 @@ The instantaneous fuel consumption in microlitres - + The estimate range in KM the vehicle can travel based on fuel level and consumption The external temperature in degrees celsius - + See TurnSignal @@ -6266,10 +6313,10 @@ Current angle of the steering wheel (in deg) - + The estimated percentage of remaining oil life of the engine. - + The status of the park brake as provided by Electric Park Brake (EPB) system. @@ -6294,7 +6341,7 @@ - + Command ID, which is related to a specific menu entry @@ -6304,32 +6351,32 @@ - + Provides applications with notifications specific to the current TBT client status on the module Current State of TBT client - + Provides driver distraction state to mobile applications Current State of Driver Distraction - + Provides update to app of which policy-table-enabled functions are available Change in permissions for a given set of RPCs - + Binary data is in binary part of hybrid msg - + Current SDL voice engine (VR+TTS) language @@ -6338,7 +6385,7 @@ - + On-screen keyboard event. Can be full string or individual keypresses depending on keyboard mode. @@ -6356,7 +6403,7 @@ - + Notifies about touch events on the screen's prescribed area The type of touch event. @@ -6366,7 +6413,7 @@ - + An asynchronous request from the system for specific data from the device or the cloud or response to a request from the device or cloud Binary data can be included in hybrid part of message for some requests (such as Authentication request responses) @@ -6374,7 +6421,7 @@ The type of system request. - + This parameter is filled for supporting OEM proprietary data exchanges. @@ -6403,7 +6450,7 @@ - + Notification containing an updated hashID which can be used over connection cycles (i.e. loss of connection, ignition cycles, etc.). Sent after initial registration and subsequently after any change in the calculated hash of all persisted app data. @@ -6413,19 +6460,19 @@ - + Notification which provides the entire LocationDetails when there is a change to any waypoints or destination. See LocationDetails - + - + Issued by SDL to notify the application about remote control status change on SDL @@ -6444,7 +6491,7 @@ - + Allows encoded data in the form of SyncP packets to be sent to the SYNC module. Legacy / v1 Protocol implementation; use SyncPData instead. @@ -6457,7 +6504,7 @@ - + true, if successful; false, if failed @@ -6508,7 +6555,7 @@ --> - + Callback including encoded data of any SyncP packets that SYNC needs to send back to the mobile device. Legacy / v1 Protocol implementation; responds to EncodedSyncPData. -- cgit v1.2.1 From 438fe7b1893cc8b177f37657aec2a59ac033fd63 Mon Sep 17 00:00:00 2001 From: JackLivio Date: Wed, 15 Aug 2018 10:02:16 -0400 Subject: Add since to Result enum --- src/components/interfaces/MOBILE_API.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/interfaces/MOBILE_API.xml b/src/components/interfaces/MOBILE_API.xml index 37b19e42c3..4e2c9e5a52 100644 --- a/src/components/interfaces/MOBILE_API.xml +++ b/src/components/interfaces/MOBILE_API.xml @@ -2,7 +2,7 @@ - + The request succeeded -- cgit v1.2.1 From 64c664da19538162781886c3a1b880f02cebc439 Mon Sep 17 00:00:00 2001 From: JackLivio Date: Wed, 15 Aug 2018 13:14:04 -0400 Subject: Update mobile api with correct versioning --- src/components/interfaces/MOBILE_API.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/interfaces/MOBILE_API.xml b/src/components/interfaces/MOBILE_API.xml index b820550c1a..33e262a886 100644 --- a/src/components/interfaces/MOBILE_API.xml +++ b/src/components/interfaces/MOBILE_API.xml @@ -1,7 +1,7 @@ - + The request succeeded @@ -981,7 +981,7 @@ - + -- cgit v1.2.1 From 3a775dd456dc75ffa4488d974eb5eb7db0f5d55b Mon Sep 17 00:00:00 2001 From: Alexander Date: Wed, 15 Aug 2018 10:47:07 +0300 Subject: New RC modules initial implementation Mobile API and HMI capabilities for the rc new modules Fix RC defects - Fixed Mobile & HMI API: removed redundant default value - FIxed GetInteriorVehicleData request behavior - Fixed OnInteriorDataNotification behavior Fix header guards and add missed includes Fix control data checking by capabilities Answered to review comments Commit --- src/appMain/hmi_capabilities.json | 233 ++++++++++- .../include/rc_rpc_plugin/rc_module_constants.h | 30 ++ .../mobile/get_interior_vehicle_data_request.cc | 43 +- .../mobile/set_interior_vehicle_data_request.cc | 138 ++++++- src/components/interfaces/HMI_API.xml | 457 +++++++++++++++++---- src/components/interfaces/MOBILE_API.xml | 362 +++++++++++++++- .../include/policy/policy_table/enums.h | 9 +- .../policy_external/src/policy_table/enums.cc | 21 + .../include/policy/policy_table/enums.h | 9 +- .../policy_regular/src/policy_table/enums.cc | 24 +- 10 files changed, 1207 insertions(+), 119 deletions(-) diff --git a/src/appMain/hmi_capabilities.json b/src/appMain/hmi_capabilities.json index 4eedd6b17a..dbbb42637c 100755 --- a/src/appMain/hmi_capabilities.json +++ b/src/appMain/hmi_capabilities.json @@ -438,6 +438,10 @@ "defrostZoneAvailable": true, "desiredTemperatureAvailable": true, "dualModeEnableAvailable": true, + "heatedMirrorsAvailable":true, + "heatedRearWindowAvailable":true, + "heatedSteeringWheelAvailable":true, + "heatedWindshieldAvailable":true, "fanSpeedAvailable": true, "moduleName": "primary_climate", "ventilationMode": [ @@ -460,11 +464,22 @@ "rdsDataAvailable": true, "signalChangeThresholdAvailable": true, "signalStrengthAvailable": true, + "sisDataAvailable":true, "stateAvailable": true } ], - "seatControlCapabilities": [ - { + "audioControlCapabilities": [ + { + "moduleName": "audio", + "sourceAvailable": true, + "volumeAvailable": true, + "equalizerAvailable": true, + "keepContextAvailable" : true, + "equalizerMaxChannelId": 10 + } + ], + "seatControlCapabilities": [ + { "moduleName": "driver_seat", "heatingEnabledAvailable" : true, "coolingEnabledAvailable": true, @@ -482,7 +497,219 @@ "massageCushionFirmnessAvailable": true, "memoryAvailable": true } - ] + ], + "lightControlCapabilities": { + "moduleName": "light", + "supportedLights":[ + { + "densityAvailable":true, + "name":"FRONT_LEFT_HIGH_BEAM", + "rgbColorSpaceAvailable":true + }, + { + "densityAvailable":true, + "name":"FRONT_RIGHT_HIGH_BEAM", + "rgbColorSpaceAvailable":true + }, + { + "densityAvailable":true, + "name":"FRONT_LEFT_LOW_BEAM", + "rgbColorSpaceAvailable":true + }, + { + "densityAvailable":true, + "name":"FRONT_RIGHT_LOW_BEAM", + "rgbColorSpaceAvailable":true + }, + { + "densityAvailable":true, + "name":"FRONT_LEFT_PARKING_LIGHT", + "rgbColorSpaceAvailable":true + }, + { + "densityAvailable":true, + "name":"FRONT_RIGHT_PARKING_LIGHT", + "rgbColorSpaceAvailable":true + }, + { + "densityAvailable":true, + "name":"FRONT_LEFT_FOG_LIGHT", + "rgbColorSpaceAvailable":true + }, + { + "densityAvailable":true, + "name":"FRONT_RIGHT_FOG_LIGHT", + "rgbColorSpaceAvailable":true + }, + { + "densityAvailable":true, + "name":"FRONT_LEFT_DAYTIME_RUNNING_LIGHT", + "rgbColorSpaceAvailable":true + }, + { + "densityAvailable":true, + "name":"FRONT_RIGHT_DAYTIME_RUNNING_LIGHT", + "rgbColorSpaceAvailable":true + }, + { + "densityAvailable":true, + "name":"FRONT_LEFT_TURN_LIGHT", + "rgbColorSpaceAvailable":true + }, + { + "densityAvailable":true, + "name":"FRONT_RIGHT_TURN_LIGHT", + "rgbColorSpaceAvailable":true + }, + { + "densityAvailable":true, + "name":"REAR_LEFT_FOG_LIGHT", + "rgbColorSpaceAvailable":true + }, + { + "densityAvailable":true, + "name":"REAR_RIGHT_FOG_LIGHT", + "rgbColorSpaceAvailable":true + }, + { + "densityAvailable":true, + "name":"REAR_LEFT_TAIL_LIGHT", + "rgbColorSpaceAvailable":true + }, + { + "densityAvailable":true, + "name":"REAR_RIGHT_TAIL_LIGHT", + "rgbColorSpaceAvailable":true + }, + { + "densityAvailable":true, + "name":"REAR_LEFT_BREAK_LIGHT", + "rgbColorSpaceAvailable":true + }, + { + "densityAvailable":true, + "name":"REAR_RIGHT_BREAK_LIGHT", + "rgbColorSpaceAvailable":true + }, + { + "densityAvailable":true, + "name":"REAR_LEFT_TURN_LIGHT", + "rgbColorSpaceAvailable":true + }, + { + "densityAvailable":true, + "name":"REAR_RIGHT_TURN_LIGHT", + "rgbColorSpaceAvailable":true + }, + { + "densityAvailable":true, + "name":"REAR_REGISTRATION_PLATE_LIGHT", + "rgbColorSpaceAvailable":true + }, + { + "densityAvailable":true, + "name":"HIGH_BEAMS", + "rgbColorSpaceAvailable":true + }, + { + "densityAvailable":true, + "name":"LOW_BEAMS", + "rgbColorSpaceAvailable":true + }, + { + "densityAvailable":true, + "name":"FOG_LIGHTS", + "rgbColorSpaceAvailable":true + }, + { + "densityAvailable":true, + "name":"RUNNING_LIGHTS", + "rgbColorSpaceAvailable":true + }, + { + "densityAvailable":true, + "name":"PARKING_LIGHTS", + "rgbColorSpaceAvailable":true + }, + { + "densityAvailable":true, + "name":"BRAKE_LIGHTS", + "rgbColorSpaceAvailable":true + }, + { + "densityAvailable":true, + "name":"REAR_REVERSING_LIGHTS", + "rgbColorSpaceAvailable":true + }, + { + "densityAvailable":true, + "name":"SIDE_MARKER_LIGHTS", + "rgbColorSpaceAvailable":true + }, + { + "densityAvailable":true, + "name":"LEFT_TURN_LIGHTS", + "rgbColorSpaceAvailable":true + }, + { + "densityAvailable":true, + "name":"RIGHT_TURN_LIGHTS", + "rgbColorSpaceAvailable":true + }, + { + "densityAvailable":true, + "name":"HAZARD_LIGHTS", + "rgbColorSpaceAvailable":true + }, + { + "densityAvailable":true, + "name":"AMBIENT_LIGHTS", + "rgbColorSpaceAvailable":true + }, + { + "densityAvailable":true, + "name":"OVERHEAD_LIGHTS", + "rgbColorSpaceAvailable":true + }, + { + "densityAvailable":true, + "name":"READING_LIGHTS", + "rgbColorSpaceAvailable":true + }, + { + "densityAvailable":true, + "name":"TRUNK_LIGHTS", + "rgbColorSpaceAvailable":true + }, + { + "densityAvailable":true, + "name":"EXTERIOR_FRONT_LIGHTS", + "rgbColorSpaceAvailable":true + }, + { + "densityAvailable":true, + "name":"EXTERIOR_REAR_LIGHTS", + "rgbColorSpaceAvailable":true + }, + { + "densityAvailable":true, + "name":"EXTERIOR_LEFT_LIGHTS", + "rgbColorSpaceAvailable":true + }, + { + "densityAvailable":true, + "name":"EXTERIOR_RIGHT_LIGHTS", + "rgbColorSpaceAvailable":true + } + ] + + }, + "hmiSettingsControlCapabilities": { + "moduleName": "hmiSettings", + "distanceUnitAvailable": true, + "temperatureUnitAvailable": true, + "displayModeUnitAvailable": true + } } } }, diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_module_constants.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_module_constants.h index f2037aabbb..3013b64249 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_module_constants.h +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_module_constants.h @@ -40,7 +40,20 @@ namespace strings { const char kclimateControlCapabilities[] = "climateControlCapabilities"; const char kradioControlCapabilities[] = "radioControlCapabilities"; const char kbuttonCapabilities[] = "buttonCapabilities"; +const char kaudioControlCapabilities[] = "audioControlCapabilities"; +const char klightControlCapabilities[] = "lightControlCapabilities"; +const char khmiSettingsControlCapabilities[] = "hmiSettingsControlCapabilities"; const char kseatControlCapabilities[] = "seatControlCapabilities"; +// RemoteControlCapabilities constants + +const char kRadioControlData[] = "radioControlData"; +const char kClimateControlData[] = "climateControlData"; +const char kSupportedLights[] = "supportedLights"; + +// LightControlCapabilities +const char kName[] = "name"; +const char kDensityAvailable[] = "densityAvailable"; +const char krgbColorSpaceAvailable[] = "rgbColorSpaceAvailable"; } // strings namespace result_codes { @@ -139,6 +152,7 @@ const char kSignalStrength[] = "signalStrength"; const char kSignalChangeThreshold[] = "signalChangeThreshold"; const char kRadioEnable[] = "radioEnable"; const char kState[] = "state"; +const char kSisData[] = "sisData"; // RadioControlData struct // ClimateControlData struct @@ -153,11 +167,24 @@ const char kDefrostZone[] = "defrostZone"; const char kDualModeEnable[] = "dualModeEnable"; const char kACMaxEnable[] = "acMaxEnable"; const char kVentilationMode[] = "ventilationMode"; +const char kHeatedSteeringWheelEnable[] = "heatedSteeringWheelEnable"; +const char kHeatedWindshieldEnable[] = "heatedWindshieldEnable"; +const char kHeatedRearWindowEnable[] = "heatedRearWindowEnable"; +const char kHeatedMirrorsEnable[] = "heatedMirrorsEnable"; // ClimateControlData struct +// LightControlData +const char kLightState[] = "lightState"; +const char kStatus[] = "status"; +const char kDensity[] = "density"; +const char kColor[] = "color"; + // ModuleData struct const char kRadioControlData[] = "radioControlData"; const char kClimateControlData[] = "climateControlData"; +const char kAudioControlData[] = "audioControlData"; +const char kLightControlData[] = "lightControlData"; +const char kHmiSettingsControlData[] = "hmiSettingsControlData"; const char kSeatControlData[] = "seatControlData"; // ModuleData struct @@ -173,6 +200,9 @@ namespace enums_value { const char kClimate[] = "CLIMATE"; const char kRadio[] = "RADIO"; const char kSeat[] = "SEAT"; +const char kAudio[] = "AUDIO"; +const char kLight[] = "LIGHT"; +const char kHmiSettings[] = "HMI_SETTINGS"; // ModuleType enum // RadioBand enum diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/get_interior_vehicle_data_request.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/get_interior_vehicle_data_request.cc index 06c44d2ff3..4f76570e63 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/get_interior_vehicle_data_request.cc +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/get_interior_vehicle_data_request.cc @@ -63,20 +63,37 @@ bool CheckIfModuleTypeExistInCapabilities( const smart_objects::SmartObject& rc_capabilities, const std::string& module_type) { LOG4CXX_AUTO_TRACE(logger_); - const std::map params = { - {enums_value::kRadio, strings::kradioControlCapabilities}, - {enums_value::kClimate, strings::kclimateControlCapabilities}, - {enums_value::kSeat, strings::kseatControlCapabilities}}; - bool is_module_type_valid = false; - for (const auto& param : params) { - if (param.first == module_type) { - if (rc_capabilities.keyExists(param.second)) { - is_module_type_valid = true; - break; - } - } + if (enums_value::kRadio == module_type && + !rc_capabilities.keyExists(strings::kradioControlCapabilities)) { + LOG4CXX_DEBUG(logger_, " Radio control capabilities not present"); + return false; + } + if (enums_value::kClimate == module_type && + !rc_capabilities.keyExists(strings::kclimateControlCapabilities)) { + LOG4CXX_DEBUG(logger_, " Climate control capabilities not present"); + return false; + } + if (enums_value::kAudio == module_type && + !rc_capabilities.keyExists(strings::kaudioControlCapabilities)) { + LOG4CXX_DEBUG(logger_, " Audio control capabilities not present"); + return false; + } + if (enums_value::kLight == module_type && + !rc_capabilities.keyExists(strings::klightControlCapabilities)) { + LOG4CXX_DEBUG(logger_, " Light control capabilities not present"); + return false; + } + if (enums_value::kHmiSettings == module_type && + !rc_capabilities.keyExists(strings::khmiSettingsControlCapabilities)) { + LOG4CXX_DEBUG(logger_, " HmiSettings control capabilities not present"); + return false; + } + if (enums_value::kSeat == module_type && + !rc_capabilities.keyExists(strings::kseatControlCapabilities)) { + LOG4CXX_DEBUG(logger_, " Seat control capabilities not present"); + return false; } - return is_module_type_valid; + return true; } void GetInteriorVehicleDataRequest::Execute() { diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/set_interior_vehicle_data_request.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/set_interior_vehicle_data_request.cc index 83bb526076..a21517aa65 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/set_interior_vehicle_data_request.cc +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/set_interior_vehicle_data_request.cc @@ -57,6 +57,7 @@ std::vector GetModuleReadOnlyParams( module_ro_params.push_back(kSignalStrength); module_ro_params.push_back(kSignalChangeThreshold); module_ro_params.push_back(kState); + module_ro_params.push_back(kSisData); } return module_ro_params; } @@ -65,6 +66,9 @@ const std::map GetModuleTypeToDataMapping() { std::map mapping = { {enums_value::kRadio, message_params::kRadioControlData}, {enums_value::kClimate, message_params::kClimateControlData}, + {enums_value::kAudio, message_params::kAudioControlData}, + {enums_value::kLight, message_params::kLightControlData}, + {enums_value::kHmiSettings, message_params::kHmiSettingsControlData}, {enums_value::kSeat, message_params::kSeatControlData}}; return mapping; } @@ -82,6 +86,10 @@ const std::map GetModuleDataToCapabilitiesMapping() { mapping["dualModeEnable"] = "dualModeEnableAvailable"; mapping["acMaxEnable"] = "acMaxEnableAvailable"; mapping["ventilationMode"] = "ventilationModeAvailable"; + mapping["heatedSteeringWheelEnable"] = "heatedSteeringWheelAvailable"; + mapping["heatedWindshieldEnable"] = "heatedWindshieldAvailable"; + mapping["heatedMirrorsEnable"] = "heatedMirrorsAvailable"; + mapping["heatedRearWindowEnable"] = "heatedRearWindowAvailable"; // radio mapping["band"] = "radioBandAvailable"; @@ -94,6 +102,7 @@ const std::map GetModuleDataToCapabilitiesMapping() { mapping["signalChangeThreshold"] = "signalChangeThresholdAvailable"; mapping["radioEnable"] = "radioEnableAvailable"; mapping["state"] = "stateAvailable"; + mapping["sisData"] = "sisDataAvailable"; // seat mapping["heatingEnabled"] = "heatingEnabledAvailable"; @@ -113,6 +122,16 @@ const std::map GetModuleDataToCapabilitiesMapping() { mapping["massageMode"] = "massageModeAvailable"; mapping["massageCushionFirmness"] = "massageCushionFirmnessAvailable"; mapping["memory"] = "memoryAvailable"; + // audio + mapping["source"] = "sourceAvailable"; + mapping["keepContext"] = "sourceAvailable"; + mapping["volume"] = "volumeAvailable"; + mapping["equalizerSettings"] = "equalizerAvailable"; + + // hmi settings + mapping["distanceUnit"] = "distanceUnitAvailable"; + mapping["temperatureUnit"] = "temperatureUnitAvailable"; + mapping["displayMode"] = "displayModeUnitAvailable"; return mapping; } @@ -136,19 +155,119 @@ SetInteriorVehicleDataRequest::SetInteriorVehicleDataRequest( SetInteriorVehicleDataRequest::~SetInteriorVehicleDataRequest() {} +const std::string LightName(const smart_objects::SmartObject& light_name) { + const char* name; + const bool ok = NsSmartDeviceLink::NsSmartObjects:: + EnumConversionHelper::EnumToCString( + static_cast(light_name.asUInt()), + &name); + return ok ? name : "unknown"; +} + +bool CheckLightDataByCapabilities( + const smart_objects::SmartObject& capabilities, + const smart_objects::SmartObject& light_data) { + LOG4CXX_AUTO_TRACE(logger_); + std::map lightCapsMapping = { + {message_params::kId, strings::kName}, + {message_params::kDensity, strings::kDensityAvailable}, + {message_params::kColor, strings::krgbColorSpaceAvailable}}; + auto it = light_data.map_begin(); + for (; it != light_data.map_end(); ++it) { + if (message_params::kStatus == it->first || + message_params::kId == it->first) { + continue; + } + const std::string& caps_key = lightCapsMapping[it->first]; + LOG4CXX_DEBUG(logger_, + "Checking request parameter " + << it->first << " with capabilities. Appropriate key is " + << caps_key); + + if (!capabilities.keyExists(caps_key)) { + LOG4CXX_DEBUG(logger_, + "Capability " + << caps_key + << " is missed in RemoteControl capabilities"); + return false; + } + if (!capabilities[caps_key].asBool()) { + LOG4CXX_DEBUG(logger_, + "Capability " + << caps_key + << " is switched off in RemoteControl capabilities"); + return false; + } + } + return true; +} + +bool CheckLightNameByCapabilities( + const smart_objects::SmartObject& capabilities_status, + const smart_objects::SmartObject& light_data) { + LOG4CXX_AUTO_TRACE(logger_); + auto it = capabilities_status.asArray()->begin(); + for (; it != capabilities_status.asArray()->end(); ++it) { + const smart_objects::SmartObject& so = *it; + const int64_t current_id = so[message_params::kName].asInt(); + if (current_id == light_data[message_params::kId].asInt()) { + return CheckLightDataByCapabilities(so, light_data); + } + } + LOG4CXX_DEBUG(logger_, "There is no such light name in capabilities"); + return false; +} + bool CheckControlDataByCapabilities( const smart_objects::SmartObject& module_caps, const smart_objects::SmartObject& control_data) { + LOG4CXX_AUTO_TRACE(logger_); std::map mapping = GetModuleDataToCapabilitiesMapping(); const smart_objects::SmartObject& capabilities_status = module_caps[0]; auto it = control_data.map_begin(); for (; it != control_data.map_end(); ++it) { const std::string& request_parameter = it->first; - if (message_params::kId == request_parameter) { - continue; + if (message_params::kLightState == request_parameter) { + return CheckLightNameByCapabilities( + module_caps[strings::kSupportedLights], + control_data[request_parameter][0]); } const std::string& caps_key = mapping[request_parameter]; + LOG4CXX_DEBUG(logger_, + "Checking request parameter " + << request_parameter + << " with capabilities. Appropriate key is " << caps_key); + + if (!capabilities_status.keyExists(caps_key)) { + LOG4CXX_DEBUG(logger_, + "Capability " + << caps_key + << " is missed in RemoteControl capabilities"); + return false; + } + if (!capabilities_status[caps_key].asBool()) { + LOG4CXX_DEBUG(logger_, + "Capability " + << caps_key + << " is switched off in RemoteControl capabilities"); + return false; + } + } + return true; +} + +bool CheckHmiControlDataByCapabilities( + const smart_objects::SmartObject& module_caps, + const smart_objects::SmartObject& control_data) { + LOG4CXX_AUTO_TRACE(logger_); + std::map mapping = + GetModuleDataToCapabilitiesMapping(); + const smart_objects::SmartObject& capabilities_status = module_caps; + auto it = control_data.map_begin(); + for (; it != control_data.map_end(); ++it) { + const std::string& request_parameter = it->first; + const std::string& caps_key = mapping[request_parameter]; LOG4CXX_DEBUG(logger_, "Checking request parameter " << request_parameter @@ -179,7 +298,11 @@ bool CheckIfModuleDataExistInCapabilities( {message_params::kRadioControlData, strings::kradioControlCapabilities}, {message_params::kClimateControlData, strings::kclimateControlCapabilities}, - {message_params::kSeatControlData, strings::kseatControlCapabilities}}; + {message_params::kAudioControlData, strings::kaudioControlCapabilities}, + {message_params::kLightControlData, strings::klightControlCapabilities}, + {message_params::kSeatControlData, strings::kseatControlCapabilities}, + {message_params::kHmiSettingsControlData, + strings::khmiSettingsControlCapabilities}}; bool is_module_data_valid = false; for (const auto& param : params) { if (module_data.keyExists(param.first)) { @@ -188,8 +311,13 @@ bool CheckIfModuleDataExistInCapabilities( return false; } const smart_objects::SmartObject& caps = rc_capabilities[param.second]; - is_module_data_valid = - CheckControlDataByCapabilities(caps, module_data[param.first]); + if (message_params::kHmiSettingsControlData == param.first) { + is_module_data_valid = + CheckHmiControlDataByCapabilities(caps, module_data[param.first]); + } else { + is_module_data_valid = + CheckControlDataByCapabilities(caps, module_data[param.first]); + } } } return is_module_data_valid; diff --git a/src/components/interfaces/HMI_API.xml b/src/components/interfaces/HMI_API.xml index da25d28369..3af2911a73 100644 --- a/src/components/interfaces/HMI_API.xml +++ b/src/components/interfaces/HMI_API.xml @@ -971,6 +971,8 @@ Reflects the current primary audio source (if selected). + + @@ -983,6 +985,9 @@ + + Radio may be on AM, FM or XM + @@ -1581,6 +1586,9 @@ + + + @@ -1748,6 +1756,92 @@ + + + Binary Representation of ITU Country Code. USA Code is 001. + + + Binary representation of unique facility ID assigned by the FCC; FCC controlled for U.S. territory + + + + + Struct with the GPS data. + + + + + + The current UTC year. + + + The current UTC month. + + + The current UTC day. + + + The current UTC hour. + + + The current UTC minute. + + + The current UTC second. + + + See CompassDirection. + + + PDOP. + + + HDOP. + + + VDOP. + + + + True, if actual. + False, if infered. + + + + Number of satellites in view + + + See Dimension + + + Altitude in meters + + + The heading. North is 0. Resolution is 0.01 + + + The speed in KPH + + + + + + Identifies the 4-alpha-character station call sign plus an optional (-FM) extension + + + Used for network Application. Consists of Country Code and FCC Facility ID. + + + Identifies the station call sign or other identifying information in the long format. + + + Provides the 3-dimensional geographic station location. + + + May be used to convey textual information of general interest to the consumer such as weather forecasts or public service announcements. Includes a high priority delivery feature to convey emergencies that may be in the listening area. + + + The integer part of the frequency ie for 101.7 this value should be 101 @@ -1775,6 +1869,9 @@ + + Read-only Station Information Service (SIS) data provides basic information about the station such as call sign, as well as information not displayable to the consumer such as the station identification number + @@ -1836,6 +1933,12 @@ True: Available, False: Not Available, Not present: Not Available. + + + Availability of the getting HD radio Station Information Service (SIS) data. + True: Available, False: Not Available, Not present: Not Available. + + @@ -1887,6 +1990,18 @@ + + value false means disabled/turn off, value true means enabled/turn on. + + + value false means disabled, value true means enabled. + + + value false means disabled, value true means enabled. + + + value false means disabled, value true means enabled. + @@ -1964,6 +2079,253 @@ A set of all ventilation modes that are controllable. + + + Availability of the control (enable/disable) of heated Steering Wheel. + True: Available, False: Not Available, Not present: Not Available. + + + + + Availability of the control (enable/disable) of heated Windshield. + True: Available, False: Not Available, Not present: Not Available. + + + + + Availability of the control (enable/disable) of heated Rear Window. + True: Available, False: Not Available, Not present: Not Available. + + + + + Availability of the control (enable/disable) of heated Mirrors. + True: Available, False: Not Available, Not present: Not Available. + + + + + + Defines the each Equalizer channel settings. + + + read-only channel / frequency name (e.i. "Treble, Midrange, Bass" or "125 Hz") + + + + + + + + In a getter response or a notification, it is the current primary audio source of the system. + In a setter request, it is the target audio source that the system shall switch to. + If the value is MOBILE_APP, the system shall switch to the mobile media app that issues the setter RPC. + + + + + This parameter shall not be present in any getter responses or notifications. + This parameter is optional in a setter request. The default value is false. + If it is false, the system not only changes the audio source but also brings the default application + or system UI associated with the audio source to foreground. + If it is true, the system changes the audio source, but still keeps the current application in foreground. + + + + Reflects the volume of audio, from 0%-100%. + + + Defines the list of supported channels (band) and their current/desired settings on HMI + + + + + + + The short friendly name of the light control module. + It should not be used to identify a module by mobile application. + + + + Availability of the control of audio source. + + + Availability of the keepContext paramter. + + + Availability of the control of audio volume. + + + Availability of the control of Equalizer Settings. + + + Must be included if equalizerAvailable=true, and assume all IDs starting from 1 to this value are valid + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Include all high beam lights: front_left and front_right. + + + Include all low beam lights: front_left and front_right. + + + Include all fog lights: front_left, front_right, rear_left and rear_right. + + + Include all daytime running lights: front, left and right. + + + Include all parking lights: front_left and front_right. + + + Include all brake lights: rear_left and rear_right. + + + + + Include all left turn signal lights: front_left, rear_left, left_side and mirror_mounted. + + + Include all right turn signal lights: front_right, rear_right, right_side and mirror_mounted. + + + Include all hazard lights: front_left, front_right, rear_left and rear_right. + + + + + + + + + + + Include exterior lights located in front of the vehicle. For example, fog lights and low beams. + + + Include exterior lights located at the back of the vehicle. For example, license plate lights, reverse lights, cargo lights, bed lights an trailer assist lights. + + + Include exterior lights located at the left side of the vehicle. For example, left puddle lights and spot lights. + + + Include exterior lights located at the right side of the vehicle. For example, right puddle lights and spot lights. + + + + + + + + + + + + + + Indicates if the light's density can be set remotely (similar to a dimmer). + + + + + Indicates if the light's color can be set remotely by using the RGB color space. + + + + + + + + The short friendly name of the light control module. + It should not be used to identify a module by mobile application. + + + + An array of available light names that are controllable. + + + + + + The name of a light or a group of lights. + + + + + + + + + An array of LightNames and their current or desired status. No change to the status of the LightNames that are not listed in the array. + + + + + + + + + + + + + + + Corresponds to "HMI_SETTINGS" ModuleType + + + + + + + + + The short friendly name of the hmi setting module. + It should not be used to identify a module by mobile application. + + + + Availability of the control of distance unit. + + + Availability of the control of temperature unit. + + + Availability of the control of HMI display mode. + @@ -1976,13 +2338,19 @@ + + + + + + - Enumeration that describes possible remote control access mode the application might be in on HU. - - - + Enumeration that describes possible remote control access mode the application might be in on HU. + + + @@ -2122,11 +2490,6 @@ - - - - - @@ -2497,65 +2860,6 @@ - - Struct with the GPS data. - - - - - - The current UTC year. - - - The current UTC month. - - - The current UTC day. - - - The current UTC hour. - - - The current UTC minute. - - - The current UTC second. - - - See CompassDirection. - - - PDOP. - - - HDOP. - - - VDOP. - - - - True, if actual. - False, if infered. - - - - Number of satellites in view - - - See Dimension - - - Altitude in meters - - - The heading. North is 0. Resolution is 0.01 - - - The speed in KPH - - - The status of component volume. See ComponentVolumeStatus. @@ -2945,10 +3249,19 @@ If included, the platform supports RC button controls with the included button names. - - - If included, the platform supports seat controls. - + + + If included, the platform supports seat controls. + + + + If included, the platform supports audio controls. + + + If included, the platform supports hmi setting controls. + + + If included, the platform supports light controls. diff --git a/src/components/interfaces/MOBILE_API.xml b/src/components/interfaces/MOBILE_API.xml index fa4df2dd4a..d1c51bca89 100644 --- a/src/components/interfaces/MOBILE_API.xml +++ b/src/components/interfaces/MOBILE_API.xml @@ -1322,6 +1322,8 @@ Reflects the current primary audio source (if selected). + + @@ -1334,6 +1336,9 @@ + + Radio may be on AM, FM or XM + @@ -1407,6 +1412,9 @@ + + + @@ -2803,6 +2811,27 @@ True if the system can utilize the haptic spatial data from the source being streamed. If not included, it can be assumed the module doesn't support haptic spatial data'. + + + + + + + + + + A color scheme for all display layout templates. + + + The primary "accent" color + + + The secondary "accent" color + + + The color of the background + + @@ -2966,6 +2995,33 @@ Region + + + + Binary Representation of ITU Country Code. USA Code is 001. + + + Binary representation of unique facility ID assigned by the FCC; FCC controlled for U.S. territory + + + + + + Identifies the 4-alpha-character station call sign plus an optional (-FM) extension + + + Used for network Application. Consists of Country Code and FCC Facility ID. + + + Identifies the station call sign or other identifying information in the long format. + + + Provides the 3-dimensional geographic station location. + + + May be used to convey textual information of general interest to the consumer such as weather forecasts or public service announcements. Includes a high priority delivery feature to convey emergencies that may be in the listening area. + + @@ -2994,6 +3050,9 @@ + + Read-only Station Information Service (SIS) data provides basic information about the station such as call sign, as well as information not displayable to the consumer such as the station identification number + @@ -3017,6 +3076,18 @@ + + value false means disabled/turn off, value true means enabled/turn on. + + + value false means disabled, value true means enabled. + + + value false means disabled, value true means enabled. + + + value false means disabled, value true means enabled. + @@ -3082,6 +3153,12 @@ True: Available, False: Not Available, Not present: Not Available. + + + Availability of the getting HD radio Station Information Service (SIS) data. + True: Available, False: Not Available, Not present: Not Available. + + @@ -3091,6 +3168,12 @@ The short friendly name of the climate control module. It should not be used to identify a module by mobile application. + + + Availability of the reading of current temperature. + True: Available, False: Not Available, Not present: Not Available. + + Availability of the control of fan speed. @@ -3155,6 +3238,246 @@ A set of all ventilation modes that are controllable. + + + Availability of the control (enable/disable) of heated Steering Wheel. + True: Available, False: Not Available, Not present: Not Available. + + + + + Availability of the control (enable/disable) of heated Windshield. + True: Available, False: Not Available, Not present: Not Available. + + + + + Availability of the control (enable/disable) of heated Rear Window. + True: Available, False: Not Available, Not present: Not Available. + + + + + Availability of the control (enable/disable) of heated Mirrors. + True: Available, False: Not Available, Not present: Not Available. + + + + + + Defines the each Equalizer channel settings. + + + read-only channel / frequency name (e.i. "Treble, Midrange, Bass" or "125 Hz") + + + + + + + + In a getter response or a notification, it is the current primary audio source of the system. + In a setter request, it is the target audio source that the system shall switch to. + If the value is MOBILE_APP, the system shall switch to the mobile media app that issues the setter RPC. + + + + + This parameter shall not be present in any getter responses or notifications. + This parameter is optional in a setter request. The default value is false. + If it is false, the system not only changes the audio source but also brings the default application + or system UI associated with the audio source to foreground. + If it is true, the system changes the audio source, but still keeps the current application in foreground. + + + + Reflects the volume of audio, from 0%-100%. + + + Defines the list of supported channels (band) and their current/desired settings on HMI + + + + + + + The short friendly name of the light control module. + It should not be used to identify a module by mobile application. + + + + Availability of the control of audio source. + + + Availability of the keepContext paramter. + + + Availability of the control of audio volume. + + + Availability of the control of Equalizer Settings. + + + Must be included if equalizerAvailable=true, and assume all IDs starting from 1 to this value are valid + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Include all high beam lights: front_left and front_right. + + + Include all low beam lights: front_left and front_right. + + + Include all fog lights: front_left, front_right, rear_left and rear_right. + + + Include all daytime running lights: front, left and right. + + + Include all parking lights: front_left and front_right. + + + Include all brake lights: rear_left and rear_right. + + + + + Include all left turn signal lights: front_left, rear_left, left_side and mirror_mounted. + + + Include all right turn signal lights: front_right, rear_right, right_side and mirror_mounted. + + + Include all hazard lights: front_left, front_right, rear_left and rear_right. + + + + + + + + + + + Include exterior lights located in front of the vehicle. For example, fog lights and low beams. + + + Include exterior lights located at the back of the vehicle. For example, license plate lights, reverse lights, cargo lights, bed lights an trailer assist lights. + + + Include exterior lights located at the left side of the vehicle. For example, left puddle lights and spot lights. + + + Include exterior lights located at the right side of the vehicle. For example, right puddle lights and spot lights. + + + + + + + + + + + + + + Indicates if the light's density can be set remotely (similar to a dimmer). + + + + + Indicates if the light's color can be set remotely by using the RGB color space. + + + + + + + + The short friendly name of the light control module. + It should not be used to identify a module by mobile application. + + + + An array of available light names that are controllable. + + + + + + The name of a light or a group of lights. + + + + + + + + + An array of LightNames and their current or desired status. No change to the status of the LightNames that are not listed in the array. + + + + + + + + + + + + + + + Corresponds to "HMI_SETTINGS" ModuleType + + + + + + + + + The short friendly name of the hmi setting module. + It should not be used to identify a module by mobile application. + + + + Availability of the control of distance unit. + + + Availability of the control of temperature unit. + + + Availability of the control of HMI display mode. + @@ -3167,6 +3490,12 @@ + + + + + + @@ -3184,6 +3513,15 @@ If included, the platform supports seat controls. + + If included, the platform supports audio controls. + + + If included, the platform supports hmi setting controls. + + + If included, the platform supports light controls. + @@ -3244,7 +3582,7 @@ The data in this field describes the current humidity value. - + The type of data contained in the "mainField1" text field. @@ -3274,7 +3612,7 @@ The height of the rectangle - + Defines haptic data for each user control object for video streaming application @@ -3285,26 +3623,6 @@ - - - - - - - - - A color scheme for all display layout templates. - - - The primary "accent" color - - - The secondary "accent" color - - - The color of the background - - 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 d13c545a94..5fc43603d8 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 @@ -167,7 +167,14 @@ bool IsValidEnum(Input val); const char* EnumToJsonString(Input val); bool EnumFromJsonString(const std::string& literal, Input* result); -enum ModuleType { MT_CLIMATE, MT_RADIO, MT_SEAT }; +enum ModuleType { + MT_CLIMATE, + MT_RADIO, + MT_SEAT, + MT_AUDIO, + MT_LIGHT, + MT_HMI_SETTINGS +}; bool IsValidEnum(ModuleType val); const char* EnumToJsonString(ModuleType val); bool EnumFromJsonString(const std::string& literal, ModuleType* result); 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 58bae43000..c2b304df67 100644 --- a/src/components/policy/policy_external/src/policy_table/enums.cc +++ b/src/components/policy/policy_external/src/policy_table/enums.cc @@ -771,6 +771,12 @@ bool IsValidEnum(ModuleType val) { return true; case MT_RADIO: return true; + case MT_AUDIO: + return true; + case MT_LIGHT: + return true; + case MT_HMI_SETTINGS: + return true; case MT_SEAT: return true; default: @@ -783,6 +789,12 @@ const char* EnumToJsonString(ModuleType val) { return "CLIMATE"; case MT_RADIO: return "RADIO"; + case MT_AUDIO: + return "AUDIO"; + case MT_LIGHT: + return "LIGHT"; + case MT_HMI_SETTINGS: + return "HMI_SETTINGS"; case MT_SEAT: return "SEAT"; default: @@ -800,6 +812,15 @@ bool EnumFromJsonString(const std::string& literal, ModuleType* result) { } else if ("SEAT" == literal) { *result = MT_SEAT; return true; + } else if ("AUDIO" == literal) { + *result = MT_AUDIO; + return true; + } else if ("LIGHT" == literal) { + *result = MT_LIGHT; + return true; + } else if ("HMI_SETTINGS" == literal) { + *result = MT_HMI_SETTINGS; + return true; } else { return false; } 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 8d81a742e4..4107fad398 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 @@ -153,7 +153,14 @@ bool IsValidEnum(Input val); const char* EnumToJsonString(Input val); bool EnumFromJsonString(const std::string& literal, Input* result); -enum ModuleType { MT_CLIMATE, MT_RADIO, MT_SEAT }; +enum ModuleType { + MT_CLIMATE, + MT_RADIO, + MT_SEAT, + MT_AUDIO, + MT_LIGHT, + MT_HMI_SETTINGS +}; bool IsValidEnum(ModuleType val); const char* EnumToJsonString(ModuleType val); bool EnumFromJsonString(const std::string& literal, ModuleType* result); 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 2f5ba69ad7..83ace2feb2 100644 --- a/src/components/policy/policy_regular/src/policy_table/enums.cc +++ b/src/components/policy/policy_regular/src/policy_table/enums.cc @@ -643,6 +643,12 @@ bool IsValidEnum(ModuleType val) { return true; case MT_SEAT: return true; + case MT_AUDIO: + return true; + case MT_LIGHT: + return true; + case MT_HMI_SETTINGS: + return true; default: return false; } @@ -655,6 +661,12 @@ const char* EnumToJsonString(ModuleType val) { return "RADIO"; case MT_SEAT: return "SEAT"; + case MT_AUDIO: + return "AUDIO"; + case MT_LIGHT: + return "LIGHT"; + case MT_HMI_SETTINGS: + return "HMI_SETTINGS"; default: return ""; } @@ -670,9 +682,17 @@ bool EnumFromJsonString(const std::string& literal, ModuleType* result) { } else if ("SEAT" == literal) { *result = MT_SEAT; return true; - } else { - return false; + } else if ("AUDIO" == literal) { + *result = MT_AUDIO; + return true; + } else if ("LIGHT" == literal) { + *result = MT_LIGHT; + return true; + } else if ("HMI_SETTINGS" == literal) { + *result = MT_HMI_SETTINGS; + return true; } + return false; } const std::string kDefaultApp = "default"; -- cgit v1.2.1 From 64de9367cf37c34541aa8e5fe15309d2c48fb578 Mon Sep 17 00:00:00 2001 From: Ira Lytvynenko Date: Wed, 28 Feb 2018 13:22:50 +0200 Subject: Save current audio source Save current audio source and check it in SetInteriorVehicleDataRequest Save current audio source in app manager Fix SDL behavior when app wants to change audio source --- .../include/application_manager/application.h | 6 ++++ .../include/application_manager/application_impl.h | 6 ++++ .../application_manager/application_manager_impl.h | 5 +++ .../mobile/set_interior_vehicle_data_request.h | 9 +++++ .../include/rc_rpc_plugin/rc_module_constants.h | 4 +++ .../mobile/set_interior_vehicle_data_request.cc | 38 ++++++++++++++++++++++ .../application_manager/src/application_impl.cc | 7 ++++ .../src/application_manager_impl.cc | 8 +++++ .../include/application_manager/mock_application.h | 1 + .../application_manager/application_manager.h | 12 +++++++ .../application_manager/mock_application_manager.h | 2 ++ 11 files changed, 98 insertions(+) diff --git a/src/components/application_manager/include/application_manager/application.h b/src/components/application_manager/include/application_manager/application.h index da5860f06b..31fd04b1a2 100644 --- a/src/components/application_manager/include/application_manager/application.h +++ b/src/components/application_manager/include/application_manager/application.h @@ -737,6 +737,12 @@ class Application : public virtual InitialApplicationData, */ virtual const HmiStatePtr RegularHmiState() const = 0; + /** + * @brief Checks if app is allowed to change audio source + * @return True - if allowed, otherwise - False + */ + virtual bool IsAllowedToChangeAudioSource() const = 0; + /** * @brief PostponedHmiState returns postponed hmi state of application * if it's present diff --git a/src/components/application_manager/include/application_manager/application_impl.h b/src/components/application_manager/include/application_manager/application_impl.h index 549ccc6d0d..f5cf353c75 100644 --- a/src/components/application_manager/include/application_manager/application_impl.h +++ b/src/components/application_manager/include/application_manager/application_impl.h @@ -352,6 +352,12 @@ class ApplicationImpl : public virtual Application, */ virtual const HmiStatePtr CurrentHmiState() const; + /** + * @brief Checks if app is allowed to change audio source + * @return True - if allowed, otherwise - False + */ + virtual bool IsAllowedToChangeAudioSource() const; + /** * @brief RegularHmiState of application without active events VR, TTS etc ... * @return HmiState of application 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 87a6c521e8..5f485b76eb 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 @@ -181,6 +181,10 @@ class ApplicationManagerImpl void set_application_id(const int32_t correlation_id, const uint32_t app_id) OVERRIDE; + uint32_t get_current_audio_source() const OVERRIDE; + + void set_current_audio_source(const uint32_t source) OVERRIDE; + void OnHMILevelChanged(uint32_t app_id, mobile_apis::HMILevel::eType from, mobile_apis::HMILevel::eType to) OVERRIDE; @@ -1480,6 +1484,7 @@ class ApplicationManagerImpl bool is_vr_session_strated_; bool hmi_cooperating_; bool is_all_apps_allowed_; + uint32_t current_audio_source_; event_engine::EventDispatcherImpl event_dispatcher_; media_manager::MediaManager* media_manager_; diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/set_interior_vehicle_data_request.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/set_interior_vehicle_data_request.h index 83a8dfdd75..6e7cf05d90 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/set_interior_vehicle_data_request.h +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/set_interior_vehicle_data_request.h @@ -118,6 +118,15 @@ class SetInteriorVehicleDataRequest : public RCCommandRequest { */ const smart_objects::SmartObject& ControlData( const smart_objects::SmartObject& module_data); + + /** + * @brief CheckAudioSource check that if app wants to change + * the audio source from MOBILE_APP to other types of audio + * source without keepContext parameter or with keepContext=false + * then this app will go to HMI level 'BACKGROUND' + * @param module_data received params + */ + void CheckAudioSource(const smart_objects::SmartObject& audio_data); }; } // namespace commands } // namespace rc_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_module_constants.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_module_constants.h index 3013b64249..073b03cffa 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_module_constants.h +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_module_constants.h @@ -179,6 +179,10 @@ const char kStatus[] = "status"; const char kDensity[] = "density"; const char kColor[] = "color"; +// AudioControlData +const char kSource[] = "source"; +const char kKeepContext[] = "keepContext"; + // ModuleData struct const char kRadioControlData[] = "radioControlData"; const char kClimateControlData[] = "climateControlData"; diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/set_interior_vehicle_data_request.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/set_interior_vehicle_data_request.cc index a21517aa65..065479e298 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/set_interior_vehicle_data_request.cc +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/set_interior_vehicle_data_request.cc @@ -377,9 +377,27 @@ void SetInteriorVehicleDataRequest::Execute() { (*message_)[app_mngr::strings::msg_params][app_mngr::strings::app_id] = app->app_id(); + const bool app_wants_to_set_audio_src = + module_data.keyExists(message_params::kAudioControlData) && + module_data[message_params::kAudioControlData].keyExists( + message_params::kSource); + + if (app_wants_to_set_audio_src && !app->IsAllowedToChangeAudioSource()) { + LOG4CXX_WARN(logger_, "App is not allowed to change audio source"); + SetResourceState(ModuleType(), ResourceState::FREE); + SendResponse(false, + mobile_apis::Result::REJECTED, + "App is not allowed to change audio source"); + return; + } + SendHMIRequest(hmi_apis::FunctionID::RC_SetInteriorVehicleData, &(*message_)[app_mngr::strings::msg_params], true); + + if (enums_value::kAudio == module_type) { + CheckAudioSource(module_data[message_params::kAudioControlData]); + } } else { LOG4CXX_WARN(logger_, "Request module type & data mismatch!"); SendResponse(false, @@ -433,6 +451,26 @@ const smart_objects::SmartObject& SetInteriorVehicleDataRequest::ControlData( return module_data[0]; } +void SetInteriorVehicleDataRequest::CheckAudioSource( + const smart_objects::SmartObject& audio_data) { + LOG4CXX_AUTO_TRACE(logger_); + if (mobile_apis::PrimaryAudioSource::MOBILE_APP != + audio_data[message_params::kSource].asInt()) { + if (!audio_data.keyExists(message_params::kKeepContext) || + !audio_data[message_params::kKeepContext].asBool()) { + if (mobile_apis::PrimaryAudioSource::MOBILE_APP == + application_manager_.get_current_audio_source()) { + app_mngr::ApplicationSharedPtr app = + application_manager_.application(connection_key()); + application_manager_.ChangeAppsHMILevel( + app->app_id(), mobile_apis::HMILevel::eType::HMI_BACKGROUND); + } + } + } + application_manager_.set_current_audio_source( + audio_data[message_params::kSource].asUInt()); +} + bool SetInteriorVehicleDataRequest::AreAllParamsReadOnly( const smart_objects::SmartObject& module_data) { LOG4CXX_AUTO_TRACE(logger_); diff --git a/src/components/application_manager/src/application_impl.cc b/src/components/application_manager/src/application_impl.cc index a26418d917..222ffa6f1c 100644 --- a/src/components/application_manager/src/application_impl.cc +++ b/src/components/application_manager/src/application_impl.cc @@ -314,6 +314,13 @@ const HmiStatePtr ApplicationImpl::RegularHmiState() const { return state_.GetState(HmiState::STATE_ID_REGULAR); } +bool ApplicationImpl::IsAllowedToChangeAudioSource() const { + if (!is_remote_control_supported() || !is_media_application()) { + return false; + } + return true; +} + const HmiStatePtr ApplicationImpl::PostponedHmiState() const { return state_.GetState(HmiState::STATE_ID_POSTPONED); } diff --git a/src/components/application_manager/src/application_manager_impl.cc b/src/components/application_manager/src/application_manager_impl.cc index 9b936bdf41..ddb2a57862 100644 --- a/src/components/application_manager/src/application_manager_impl.cc +++ b/src/components/application_manager/src/application_manager_impl.cc @@ -2327,6 +2327,14 @@ void ApplicationManagerImpl::set_application_id(const int32_t correlation_id, std::pair(correlation_id, app_id)); } +uint32_t ApplicationManagerImpl::get_current_audio_source() const { + return current_audio_source_; +} + +void ApplicationManagerImpl::set_current_audio_source(const uint32_t source) { + current_audio_source_ = source; +} + void ApplicationManagerImpl::AddPolicyObserver( policy::PolicyHandlerObserver* listener) { GetPolicyHandler().add_listener(listener); diff --git a/src/components/application_manager/test/include/application_manager/mock_application.h b/src/components/application_manager/test/include/application_manager/mock_application.h index 602d228147..ef27797e29 100644 --- a/src/components/application_manager/test/include/application_manager/mock_application.h +++ b/src/components/application_manager/test/include/application_manager/mock_application.h @@ -114,6 +114,7 @@ class MockApplication : public ::application_manager::Application { MOCK_CONST_METHOD0(secondary_device, connection_handler::DeviceHandle()); MOCK_CONST_METHOD0(CurrentHmiState, const application_manager::HmiStatePtr()); MOCK_CONST_METHOD0(RegularHmiState, const application_manager::HmiStatePtr()); + MOCK_CONST_METHOD0(IsAllowedToChangeAudioSource, bool()); MOCK_CONST_METHOD0(PostponedHmiState, const application_manager::HmiStatePtr()); MOCK_METHOD1(set_tts_properties_in_none, void(bool active)); diff --git a/src/components/include/application_manager/application_manager.h b/src/components/include/application_manager/application_manager.h index 61095e388a..8397fbf790 100644 --- a/src/components/include/application_manager/application_manager.h +++ b/src/components/include/application_manager/application_manager.h @@ -239,6 +239,18 @@ class ApplicationManager { */ virtual void set_application_id(const int32_t correlation_id, const uint32_t app_id) = 0; + /** + * @brief get_current_audio_source + * @return current audio source + */ + virtual uint32_t get_current_audio_source() const = 0; + + /** + * @brief set_current_audio_source + * @param source + * set current audio source + */ + virtual void set_current_audio_source(const uint32_t source) = 0; /** * @brief OnHMILevelChanged the callback that allows SDL to react when 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 4a86c17f39..5900b760a6 100644 --- a/src/components/include/test/application_manager/mock_application_manager.h +++ b/src/components/include/test/application_manager/mock_application_manager.h @@ -318,6 +318,8 @@ class MockApplicationManager : public application_manager::ApplicationManager { MOCK_CONST_METHOD1(IsAppInReconnectMode, bool(const std::string& policy_app_id)); MOCK_CONST_METHOD0(GetCommandFactory, application_manager::CommandFactory&()); + MOCK_CONST_METHOD0(get_current_audio_source, uint32_t()); + MOCK_METHOD1(set_current_audio_source, void(const uint32_t)); }; } // namespace application_manager_test -- cgit v1.2.1 From cdfcf25d9c689b01a39653f7355960dfbf12e45c Mon Sep 17 00:00:00 2001 From: "Ira Lytvynenko (GitHub)" Date: Mon, 26 Mar 2018 15:05:16 +0300 Subject: Fix cutting off READ ONLY param channelName --- .../include/rc_rpc_plugin/rc_module_constants.h | 2 ++ .../mobile/set_interior_vehicle_data_request.cc | 37 +++++++++++++++++++++- 2 files changed, 38 insertions(+), 1 deletion(-) diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_module_constants.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_module_constants.h index 073b03cffa..54ca43e6d7 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_module_constants.h +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_module_constants.h @@ -182,6 +182,8 @@ const char kColor[] = "color"; // AudioControlData const char kSource[] = "source"; const char kKeepContext[] = "keepContext"; +const char kEqualizerSettings[] = "equalizerSettings"; +const char kChannelName[] = "channelName"; // ModuleData struct const char kRadioControlData[] = "radioControlData"; diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/set_interior_vehicle_data_request.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/set_interior_vehicle_data_request.cc index 065479e298..b9c90dd7a6 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/set_interior_vehicle_data_request.cc +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/set_interior_vehicle_data_request.cc @@ -486,13 +486,34 @@ bool SetInteriorVehicleDataRequest::AreAllParamsReadOnly( return true; } +bool CheckReadOnlyParamsForAudio( + const smart_objects::SmartObject& module_type_params) { + if (module_type_params.keyExists(message_params::kEqualizerSettings)) { + const auto& equalizer_settings = + module_type_params[message_params::kEqualizerSettings]; + auto it = equalizer_settings.asArray()->begin(); + for (; it != equalizer_settings.asArray()->end(); ++it) { + if (it->keyExists(message_params::kChannelName)) { + LOG4CXX_DEBUG(logger_, + " READ ONLY parameter: " << message_params::kChannelName); + return true; + } + } + } + return false; +} + bool SetInteriorVehicleDataRequest::AreReadOnlyParamsPresent( const smart_objects::SmartObject& module_data) { LOG4CXX_AUTO_TRACE(logger_); const smart_objects::SmartObject& module_type_params = ControlData(module_data); auto it = module_type_params.map_begin(); - std::vector ro_params = GetModuleReadOnlyParams(ModuleType()); + const std::string module_type = ModuleType(); + std::vector ro_params = GetModuleReadOnlyParams(module_type); + if (enums_value::kAudio == module_type) { + return CheckReadOnlyParamsForAudio(module_type_params); + } for (; it != module_type_params.map_end(); ++it) { if (helpers::in_range(ro_params, it->first)) { return true; @@ -520,6 +541,20 @@ void SetInteriorVehicleDataRequest::CutOffReadOnlyParams( } } } + + if (enums_value::kAudio == module_type) { + auto& equalizer_settings = module_data[message_params::kAudioControlData] + [message_params::kEqualizerSettings]; + auto it = equalizer_settings.asArray()->begin(); + for (; it != equalizer_settings.asArray()->end(); ++it) { + if (it->keyExists(message_params::kChannelName)) { + it->erase(message_params::kChannelName); + LOG4CXX_DEBUG(logger_, + "Cutting-off READ ONLY parameter: " + << message_params::kChannelName); + } + } + } } std::string SetInteriorVehicleDataRequest::ModuleType() { -- cgit v1.2.1 From 11ad0a4e75c485331ac8a1728c94b86e712cf12a Mon Sep 17 00:00:00 2001 From: BSolonenko Date: Mon, 26 Mar 2018 15:10:02 +0300 Subject: Fixed resend keepContext parameter in GetInteriorVehicleData response --- .../commands/hmi/rc_get_interior_vehicle_data_response.cc | 12 ++++++++++++ .../commands/hmi/rc_on_interior_vehicle_data_notification.cc | 12 ++++++++++++ 2 files changed, 24 insertions(+) diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_get_interior_vehicle_data_response.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_get_interior_vehicle_data_response.cc index f12512a38d..ab9fe0cc89 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_get_interior_vehicle_data_response.cc +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_get_interior_vehicle_data_response.cc @@ -31,6 +31,7 @@ */ #include "rc_rpc_plugin/commands/hmi/rc_get_interior_vehicle_data_response.h" +#include "rc_rpc_plugin/rc_module_constants.h" #include "application_manager/event_engine/event.h" namespace rc_rpc_plugin { @@ -56,6 +57,17 @@ void RCGetInteriorVehicleDataResponse::Run() { app_mngr::event_engine::Event event( hmi_apis::FunctionID::RC_GetInteriorVehicleData); + + smart_objects::SmartObject& module_data = (*message_) + [application_manager::strings::msg_params][message_params::kModuleData]; + if (module_data.keyExists(message_params::kAudioControlData)) { + smart_objects::SmartObject& audio_control_data = + module_data[message_params::kAudioControlData]; + if (audio_control_data.keyExists(message_params::kKeepContext)) { + audio_control_data.erase(message_params::kKeepContext); + } + } + event.set_smart_object(*message_); event.raise(application_manager_.event_dispatcher()); } diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_on_interior_vehicle_data_notification.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_on_interior_vehicle_data_notification.cc index 487193bc4d..3f757fab2e 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_on_interior_vehicle_data_notification.cc +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_on_interior_vehicle_data_notification.cc @@ -30,6 +30,7 @@ POSSIBILITY OF SUCH DAMAGE. */ +#include "rc_rpc_plugin/rc_module_constants.h" #include "rc_rpc_plugin/commands/hmi/rc_on_interior_vehicle_data_notification.h" #include "utils/macro.h" @@ -57,6 +58,17 @@ void RCOnInteriorVehicleDataNotification::Run() { LOG4CXX_AUTO_TRACE(logger_); (*message_)[app_mngr::strings::params][app_mngr::strings::function_id] = static_cast(mobile_apis::FunctionID::eType::OnInteriorVehicleDataID); + + smart_objects::SmartObject& module_data = (*message_) + [application_manager::strings::msg_params][message_params::kModuleData]; + if (module_data.keyExists(rc_rpc_plugin::message_params::kAudioControlData)) { + smart_objects::SmartObject& audio_control_data = + module_data[message_params::kAudioControlData]; + if (audio_control_data.keyExists(message_params::kKeepContext)) { + audio_control_data.erase(message_params::kKeepContext); + } + } + SendNotificationToMobile(message_); } -- cgit v1.2.1 From 067a91527e389a78cee24013c4030d719ad3b470 Mon Sep 17 00:00:00 2001 From: "Ira Lytvynenko (GitHub)" Date: Mon, 2 Apr 2018 14:11:26 +0300 Subject: Fix keep app's HMI level in FULL in case when HMI sends AUDIO_SOURCE event to core UTs to verify that SDL keeps app's HMI level in FULL in case when HMI sends AUDIO_SOURCE even --- .../application_manager/src/hmi_state.cc | 3 + .../test/state_controller/state_controller_test.cc | 73 ++++++++++++++++++++++ 2 files changed, 76 insertions(+) diff --git a/src/components/application_manager/src/hmi_state.cc b/src/components/application_manager/src/hmi_state.cc index 0033fe4fb6..0e67967610 100644 --- a/src/components/application_manager/src/hmi_state.cc +++ b/src/components/application_manager/src/hmi_state.cc @@ -252,6 +252,9 @@ mobile_apis::HMILevel::eType AudioSource::hmi_level() const { if (mobile_apis::HMILevel::HMI_NONE == parent()->hmi_level()) { return mobile_apis::HMILevel::HMI_NONE; } + if (mobile_apis::HMILevel::HMI_FULL == parent()->hmi_level()) { + return mobile_apis::HMILevel::HMI_FULL; + } return mobile_apis::HMILevel::HMI_BACKGROUND; } diff --git a/src/components/application_manager/test/state_controller/state_controller_test.cc b/src/components/application_manager/test/state_controller/state_controller_test.cc index fd2503da33..3731848d89 100644 --- a/src/components/application_manager/test/state_controller/state_controller_test.cc +++ b/src/components/application_manager/test/state_controller/state_controller_test.cc @@ -64,6 +64,7 @@ using ::testing::_; using ::testing::Return; using ::testing::ReturnRef; using ::testing::ReturnPointee; +using ::testing::SaveArg; using ::testing::Mock; using ::testing::NiceMock; using ::testing::InSequence; @@ -2829,6 +2830,78 @@ TEST_F(StateControllerImplTest, state_ctrl_->SetRegularState(navi_app_, hmi_state, true); } +TEST_F(StateControllerImplTest, OnEventChangedAudioSourceAppRemainInFull) { + const uint32_t app_id = simple_app_->app_id(); + InsertApplication(simple_app_); + smart_objects::SmartObject msg; + msg[am::strings::msg_params][am::strings::app_id] = app_id; + msg[am::strings::msg_params][am::hmi_notification::is_active] = true; + msg[am::strings::msg_params][am::hmi_notification::event_name] = + hmi_apis::Common_EventTypes::AUDIO_SOURCE; + + const hmi_apis::FunctionID::eType event_id = + hmi_apis::FunctionID::BasicCommunication_OnEventChanged; + am::event_engine::Event event(event_id); + event.set_smart_object(msg); + + const HmiStatePtr state = + createHmiState(mobile_apis::HMILevel::HMI_FULL, + mobile_apis::AudioStreamingState::AUDIBLE, + mobile_apis::VideoStreamingState::NOT_STREAMABLE, + mobile_apis::SystemContext::SYSCTXT_MAIN); + EXPECT_CALL(*simple_app_ptr_, RegularHmiState()).WillOnce(Return(state)); + EXPECT_CALL(*simple_app_ptr_, IsAudioApplication()) + .WillRepeatedly(Return(true)); + EXPECT_CALL(*simple_app_ptr_, CurrentHmiState()) + .WillOnce(Return(FullAudibleState())); + + HmiStatePtr new_state; + EXPECT_CALL(*simple_app_ptr_, AddHMIState(_)) + .WillOnce(SaveArg<0>(&new_state)); + + state_ctrl_->on_event(event); + + EXPECT_EQ(new_state->hmi_level(), mobile_apis::HMILevel::HMI_FULL); + EXPECT_EQ(new_state->audio_streaming_state(), + mobile_apis::AudioStreamingState::NOT_AUDIBLE); +} + +TEST_F(StateControllerImplTest, OnEventChangedAudioSourceAppToBackground) { + const uint32_t app_id = simple_app_->app_id(); + InsertApplication(simple_app_); + smart_objects::SmartObject msg; + msg[am::strings::msg_params][am::strings::app_id] = app_id; + msg[am::strings::msg_params][am::hmi_notification::is_active] = true; + msg[am::strings::msg_params][am::hmi_notification::event_name] = + hmi_apis::Common_EventTypes::AUDIO_SOURCE; + + const hmi_apis::FunctionID::eType event_id = + hmi_apis::FunctionID::BasicCommunication_OnEventChanged; + am::event_engine::Event event(event_id); + event.set_smart_object(msg); + + const HmiStatePtr state = + createHmiState(mobile_apis::HMILevel::HMI_LIMITED, + mobile_apis::AudioStreamingState::AUDIBLE, + mobile_apis::VideoStreamingState::NOT_STREAMABLE, + mobile_apis::SystemContext::SYSCTXT_MAIN); + EXPECT_CALL(*simple_app_ptr_, RegularHmiState()).WillOnce(Return(state)); + EXPECT_CALL(*simple_app_ptr_, IsAudioApplication()) + .WillRepeatedly(Return(true)); + EXPECT_CALL(*simple_app_ptr_, CurrentHmiState()) + .WillOnce(Return(LimitedState())); + + HmiStatePtr new_state; + EXPECT_CALL(*simple_app_ptr_, AddHMIState(_)) + .WillOnce(SaveArg<0>(&new_state)); + + state_ctrl_->on_event(event); + + EXPECT_EQ(new_state->hmi_level(), mobile_apis::HMILevel::HMI_BACKGROUND); + EXPECT_EQ(new_state->audio_streaming_state(), + mobile_apis::AudioStreamingState::NOT_AUDIBLE); +} + TEST_F(StateControllerImplTest, OnEventOnAppDeactivatedIncorrectHmiLevel) { smart_objects::SmartObject msg; const uint32_t app_id = simple_app_->app_id(); -- cgit v1.2.1 From a93f82e48bfd8eb210db25afe02b290144c02577 Mon Sep 17 00:00:00 2001 From: "Ira Lytvynenko (GitHub)" Date: Wed, 30 May 2018 15:05:02 +0300 Subject: Fix comments after review --- .../mobile/get_interior_vehicle_data_request.cc | 46 ++++++++-------------- .../mobile/set_interior_vehicle_data_request.cc | 23 +++++++---- .../application_manager/src/application_impl.cc | 6 +-- 3 files changed, 34 insertions(+), 41 deletions(-) diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/get_interior_vehicle_data_request.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/get_interior_vehicle_data_request.cc index 4f76570e63..f9d65a2635 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/get_interior_vehicle_data_request.cc +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/get_interior_vehicle_data_request.cc @@ -63,37 +63,23 @@ bool CheckIfModuleTypeExistInCapabilities( const smart_objects::SmartObject& rc_capabilities, const std::string& module_type) { LOG4CXX_AUTO_TRACE(logger_); - if (enums_value::kRadio == module_type && - !rc_capabilities.keyExists(strings::kradioControlCapabilities)) { - LOG4CXX_DEBUG(logger_, " Radio control capabilities not present"); - return false; - } - if (enums_value::kClimate == module_type && - !rc_capabilities.keyExists(strings::kclimateControlCapabilities)) { - LOG4CXX_DEBUG(logger_, " Climate control capabilities not present"); - return false; - } - if (enums_value::kAudio == module_type && - !rc_capabilities.keyExists(strings::kaudioControlCapabilities)) { - LOG4CXX_DEBUG(logger_, " Audio control capabilities not present"); - return false; - } - if (enums_value::kLight == module_type && - !rc_capabilities.keyExists(strings::klightControlCapabilities)) { - LOG4CXX_DEBUG(logger_, " Light control capabilities not present"); - return false; - } - if (enums_value::kHmiSettings == module_type && - !rc_capabilities.keyExists(strings::khmiSettingsControlCapabilities)) { - LOG4CXX_DEBUG(logger_, " HmiSettings control capabilities not present"); - return false; - } - if (enums_value::kSeat == module_type && - !rc_capabilities.keyExists(strings::kseatControlCapabilities)) { - LOG4CXX_DEBUG(logger_, " Seat control capabilities not present"); - return false; + const std::map params = { + {enums_value::kRadio, strings::kradioControlCapabilities}, + {enums_value::kClimate, strings::kclimateControlCapabilities}, + {enums_value::kAudio, strings::kaudioControlCapabilities}, + {enums_value::kLight, strings::klightControlCapabilities}, + {enums_value::kSeat, strings::kseatControlCapabilities}, + {enums_value::kHmiSettings, strings::khmiSettingsControlCapabilities}}; + bool is_module_type_valid = false; + for (const auto& param : params) { + if (param.first == module_type) { + if (rc_capabilities.keyExists(param.second)) { + is_module_type_valid = true; + break; + } + } } - return true; + return is_module_type_valid; } void GetInteriorVehicleDataRequest::Execute() { diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/set_interior_vehicle_data_request.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/set_interior_vehicle_data_request.cc index b9c90dd7a6..020605b64f 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/set_interior_vehicle_data_request.cc +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/set_interior_vehicle_data_request.cc @@ -124,7 +124,7 @@ const std::map GetModuleDataToCapabilitiesMapping() { mapping["memory"] = "memoryAvailable"; // audio mapping["source"] = "sourceAvailable"; - mapping["keepContext"] = "sourceAvailable"; + mapping["keepContext"] = "keepContextAvailable"; mapping["volume"] = "volumeAvailable"; mapping["equalizerSettings"] = "equalizerAvailable"; @@ -229,9 +229,15 @@ bool CheckControlDataByCapabilities( for (; it != control_data.map_end(); ++it) { const std::string& request_parameter = it->first; if (message_params::kLightState == request_parameter) { - return CheckLightNameByCapabilities( - module_caps[strings::kSupportedLights], - control_data[request_parameter][0]); + auto light_data = control_data[request_parameter].asArray()->begin(); + for (; light_data != control_data[request_parameter].asArray()->end(); + ++light_data) { + if(!CheckLightNameByCapabilities( + module_caps[strings::kSupportedLights], *light_data)){ + return false; + } + } + return true; } const std::string& caps_key = mapping[request_parameter]; LOG4CXX_DEBUG(logger_, @@ -394,10 +400,6 @@ void SetInteriorVehicleDataRequest::Execute() { SendHMIRequest(hmi_apis::FunctionID::RC_SetInteriorVehicleData, &(*message_)[app_mngr::strings::msg_params], true); - - if (enums_value::kAudio == module_type) { - CheckAudioSource(module_data[message_params::kAudioControlData]); - } } else { LOG4CXX_WARN(logger_, "Request module type & data mismatch!"); SendResponse(false, @@ -430,6 +432,11 @@ void SetInteriorVehicleDataRequest::on_event( smart_objects::SmartObject response_params; if (result) { response_params = hmi_response[app_mngr::strings::msg_params]; + if (enums_value::kAudio == ModuleType()) { + CheckAudioSource(( + *message_)[app_mngr::strings::msg_params][message_params::kModuleData] + [message_params::kAudioControlData]); + } } std::string info; GetInfo(hmi_response, info); diff --git a/src/components/application_manager/src/application_impl.cc b/src/components/application_manager/src/application_impl.cc index 222ffa6f1c..bebf923234 100644 --- a/src/components/application_manager/src/application_impl.cc +++ b/src/components/application_manager/src/application_impl.cc @@ -315,10 +315,10 @@ const HmiStatePtr ApplicationImpl::RegularHmiState() const { } bool ApplicationImpl::IsAllowedToChangeAudioSource() const { - if (!is_remote_control_supported() || !is_media_application()) { - return false; + if (is_remote_control_supported() && is_media_application()) { + return true; } - return true; + return false; } const HmiStatePtr ApplicationImpl::PostponedHmiState() const { -- cgit v1.2.1 From d13628920cb48507ad98a7e0ef2494f0034b0542 Mon Sep 17 00:00:00 2001 From: "Ira Lytvynenko (GitHub)" Date: Thu, 31 May 2018 17:50:05 +0300 Subject: Check for projection app --- .../commands/mobile/set_interior_vehicle_data_request.cc | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/set_interior_vehicle_data_request.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/set_interior_vehicle_data_request.cc index 020605b64f..8745f5a0b5 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/set_interior_vehicle_data_request.cc +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/set_interior_vehicle_data_request.cc @@ -232,9 +232,9 @@ bool CheckControlDataByCapabilities( auto light_data = control_data[request_parameter].asArray()->begin(); for (; light_data != control_data[request_parameter].asArray()->end(); ++light_data) { - if(!CheckLightNameByCapabilities( - module_caps[strings::kSupportedLights], *light_data)){ - return false; + if (!CheckLightNameByCapabilities( + module_caps[strings::kSupportedLights], *light_data)) { + return false; } } return true; @@ -469,8 +469,13 @@ void SetInteriorVehicleDataRequest::CheckAudioSource( application_manager_.get_current_audio_source()) { app_mngr::ApplicationSharedPtr app = application_manager_.application(connection_key()); - application_manager_.ChangeAppsHMILevel( - app->app_id(), mobile_apis::HMILevel::eType::HMI_BACKGROUND); + if (app->mobile_projection_enabled()) { + application_manager_.ChangeAppsHMILevel( + app->app_id(), mobile_apis::HMILevel::eType::HMI_LIMITED); + } else { + application_manager_.ChangeAppsHMILevel( + app->app_id(), mobile_apis::HMILevel::eType::HMI_BACKGROUND); + } } } } -- cgit v1.2.1 From 7d531ebc8d74e980d1d9b2ecfa1db7bd2a0f0bfc Mon Sep 17 00:00:00 2001 From: Ira Lytvynenko Date: Mon, 13 Aug 2018 11:12:11 -0400 Subject: Fix capabilities validation --- .../mobile/set_interior_vehicle_data_request.cc | 45 +++------------------- 1 file changed, 6 insertions(+), 39 deletions(-) diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/set_interior_vehicle_data_request.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/set_interior_vehicle_data_request.cc index 8745f5a0b5..3e34350711 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/set_interior_vehicle_data_request.cc +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/set_interior_vehicle_data_request.cc @@ -219,12 +219,11 @@ bool CheckLightNameByCapabilities( } bool CheckControlDataByCapabilities( - const smart_objects::SmartObject& module_caps, + const smart_objects::SmartObject& capabilities_status, const smart_objects::SmartObject& control_data) { LOG4CXX_AUTO_TRACE(logger_); std::map mapping = GetModuleDataToCapabilitiesMapping(); - const smart_objects::SmartObject& capabilities_status = module_caps[0]; auto it = control_data.map_begin(); for (; it != control_data.map_end(); ++it) { const std::string& request_parameter = it->first; @@ -233,7 +232,7 @@ bool CheckControlDataByCapabilities( for (; light_data != control_data[request_parameter].asArray()->end(); ++light_data) { if (!CheckLightNameByCapabilities( - module_caps[strings::kSupportedLights], *light_data)) { + capabilities_status[strings::kSupportedLights], *light_data)) { return false; } } @@ -263,39 +262,6 @@ bool CheckControlDataByCapabilities( return true; } -bool CheckHmiControlDataByCapabilities( - const smart_objects::SmartObject& module_caps, - const smart_objects::SmartObject& control_data) { - LOG4CXX_AUTO_TRACE(logger_); - std::map mapping = - GetModuleDataToCapabilitiesMapping(); - const smart_objects::SmartObject& capabilities_status = module_caps; - auto it = control_data.map_begin(); - for (; it != control_data.map_end(); ++it) { - const std::string& request_parameter = it->first; - const std::string& caps_key = mapping[request_parameter]; - LOG4CXX_DEBUG(logger_, - "Checking request parameter " - << request_parameter - << " with capabilities. Appropriate key is " << caps_key); - if (!capabilities_status.keyExists(caps_key)) { - LOG4CXX_DEBUG(logger_, - "Capability " - << caps_key - << " is missed in RemoteControl capabilities"); - return false; - } - if (!capabilities_status[caps_key].asBool()) { - LOG4CXX_DEBUG(logger_, - "Capability " - << caps_key - << " is switched off in RemoteControl capabilities"); - return false; - } - } - return true; -} - bool CheckIfModuleDataExistInCapabilities( const smart_objects::SmartObject& rc_capabilities, const smart_objects::SmartObject& module_data) { @@ -317,12 +283,13 @@ bool CheckIfModuleDataExistInCapabilities( return false; } const smart_objects::SmartObject& caps = rc_capabilities[param.second]; - if (message_params::kHmiSettingsControlData == param.first) { + if (message_params::kHmiSettingsControlData == param.first || + message_params::kLightControlData == param.first) { is_module_data_valid = - CheckHmiControlDataByCapabilities(caps, module_data[param.first]); + CheckControlDataByCapabilities(caps, module_data[param.first]); } else { is_module_data_valid = - CheckControlDataByCapabilities(caps, module_data[param.first]); + CheckControlDataByCapabilities(caps[0], module_data[param.first]); } } } -- cgit v1.2.1 From e9136bfa464bc844b95f867dccbbed96d3c8ff38 Mon Sep 17 00:00:00 2001 From: Ira Lytvynenko Date: Mon, 13 Aug 2018 11:25:16 -0400 Subject: Fix audio source checking --- .../mobile/set_interior_vehicle_data_request.cc | 33 +++++++++++----------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/set_interior_vehicle_data_request.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/set_interior_vehicle_data_request.cc index 3e34350711..ce449896f4 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/set_interior_vehicle_data_request.cc +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/set_interior_vehicle_data_request.cc @@ -428,22 +428,23 @@ const smart_objects::SmartObject& SetInteriorVehicleDataRequest::ControlData( void SetInteriorVehicleDataRequest::CheckAudioSource( const smart_objects::SmartObject& audio_data) { LOG4CXX_AUTO_TRACE(logger_); - if (mobile_apis::PrimaryAudioSource::MOBILE_APP != - audio_data[message_params::kSource].asInt()) { - if (!audio_data.keyExists(message_params::kKeepContext) || - !audio_data[message_params::kKeepContext].asBool()) { - if (mobile_apis::PrimaryAudioSource::MOBILE_APP == - application_manager_.get_current_audio_source()) { - app_mngr::ApplicationSharedPtr app = - application_manager_.application(connection_key()); - if (app->mobile_projection_enabled()) { - application_manager_.ChangeAppsHMILevel( - app->app_id(), mobile_apis::HMILevel::eType::HMI_LIMITED); - } else { - application_manager_.ChangeAppsHMILevel( - app->app_id(), mobile_apis::HMILevel::eType::HMI_BACKGROUND); - } - } + const bool should_keep_context = + audio_data.keyExists(message_params::kKeepContext) && + audio_data[message_params::kKeepContext].asBool(); + const bool switch_source_from_app = + mobile_apis::PrimaryAudioSource::MOBILE_APP == + application_manager_.get_current_audio_source() && + mobile_apis::PrimaryAudioSource::MOBILE_APP != + audio_data[message_params::kSource].asInt(); + if (!should_keep_context && switch_source_from_app) { + app_mngr::ApplicationSharedPtr app = + application_manager_.application(connection_key()); + if (app->mobile_projection_enabled()) { + application_manager_.ChangeAppsHMILevel( + app->app_id(), mobile_apis::HMILevel::eType::HMI_LIMITED); + } else { + application_manager_.ChangeAppsHMILevel( + app->app_id(), mobile_apis::HMILevel::eType::HMI_BACKGROUND); } } application_manager_.set_current_audio_source( -- cgit v1.2.1 From 77c92d2da199df72d66949d9ae89ef28e31c37d0 Mon Sep 17 00:00:00 2001 From: Alexander Date: Wed, 15 Aug 2018 13:16:58 +0300 Subject: Add API version to logging in case if message from mobile was not parsed --- src/components/application_manager/src/rpc_handler_impl.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/components/application_manager/src/rpc_handler_impl.cc b/src/components/application_manager/src/rpc_handler_impl.cc index bf1ff78d36..9c2aa497d6 100644 --- a/src/components/application_manager/src/rpc_handler_impl.cc +++ b/src/components/application_manager/src/rpc_handler_impl.cc @@ -267,7 +267,8 @@ bool RPCHandlerImpl::ConvertMessageToSO( ((output.validate(&report, msg_version) != smart_objects::Errors::OK))) { LOG4CXX_WARN(logger_, - "Failed to parse string to smart object :" + "Failed to parse string to smart object with API version " + << msg_version.toString() << " : " << message.json_message()); std::shared_ptr response( MessageHelper::CreateNegativeResponse( -- cgit v1.2.1 From 742dbbdb911d92ad8a9c9bcfca0d02800c9b0843 Mon Sep 17 00:00:00 2001 From: Alexander Date: Thu, 16 Aug 2018 15:22:39 +0300 Subject: Remove currentTemperatureAvailable parameter from ClimateControlCapabilities --- src/components/interfaces/HMI_API.xml | 6 ------ src/components/interfaces/MOBILE_API.xml | 6 ------ 2 files changed, 12 deletions(-) diff --git a/src/components/interfaces/HMI_API.xml b/src/components/interfaces/HMI_API.xml index 3af2911a73..070a2e98cd 100644 --- a/src/components/interfaces/HMI_API.xml +++ b/src/components/interfaces/HMI_API.xml @@ -2009,12 +2009,6 @@ The short name or a short description of the climate control module. - - - Availability of the reading of current temperature. - True: Available, False: Not Available, Not present: Not Available. - - Availability of the control of fan speed. diff --git a/src/components/interfaces/MOBILE_API.xml b/src/components/interfaces/MOBILE_API.xml index d1c51bca89..b09e8409b2 100644 --- a/src/components/interfaces/MOBILE_API.xml +++ b/src/components/interfaces/MOBILE_API.xml @@ -3168,12 +3168,6 @@ The short friendly name of the climate control module. It should not be used to identify a module by mobile application. - - - Availability of the reading of current temperature. - True: Available, False: Not Available, Not present: Not Available. - - Availability of the control of fan speed. -- cgit v1.2.1 From 5add6c28c2e171bc8d065164283b8b45e0486f90 Mon Sep 17 00:00:00 2001 From: jacobkeeler Date: Thu, 16 Aug 2018 10:34:35 -0400 Subject: Fix issues after rebase --- .../include/rc_rpc_plugin/rc_module_constants.h | 2 +- .../mobile/set_interior_vehicle_data_request.cc | 2 +- .../src/resource_allocation_manager_impl.cc | 3 ++ src/components/interfaces/HMI_API.xml | 8 +++- src/components/interfaces/MOBILE_API.xml | 48 +++++++++++----------- 5 files changed, 36 insertions(+), 27 deletions(-) diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_module_constants.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_module_constants.h index 54ca43e6d7..22db12c68b 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_module_constants.h +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_module_constants.h @@ -53,7 +53,7 @@ const char kSupportedLights[] = "supportedLights"; // LightControlCapabilities const char kName[] = "name"; const char kDensityAvailable[] = "densityAvailable"; -const char krgbColorSpaceAvailable[] = "rgbColorSpaceAvailable"; +const char kRGBColorSpaceAvailable[] = "rgbColorSpaceAvailable"; } // strings namespace result_codes { diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/set_interior_vehicle_data_request.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/set_interior_vehicle_data_request.cc index ce449896f4..0da1e4c6e7 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/set_interior_vehicle_data_request.cc +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/set_interior_vehicle_data_request.cc @@ -171,7 +171,7 @@ bool CheckLightDataByCapabilities( std::map lightCapsMapping = { {message_params::kId, strings::kName}, {message_params::kDensity, strings::kDensityAvailable}, - {message_params::kColor, strings::krgbColorSpaceAvailable}}; + {message_params::kColor, strings::kRGBColorSpaceAvailable}}; auto it = light_data.map_begin(); for (; it != light_data.map_end(); ++it) { if (message_params::kStatus == it->first || 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 011950b35a..59d1919bb5 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 @@ -367,6 +367,9 @@ ResourceAllocationManagerImpl::all_supported_modules() { result.push_back(enums_value::kClimate); result.push_back(enums_value::kRadio); result.push_back(enums_value::kSeat); + result.push_back(enums_value::kAudio); + result.push_back(enums_value::kLight); + result.push_back(enums_value::kHmiSettings); return result; } diff --git a/src/components/interfaces/HMI_API.xml b/src/components/interfaces/HMI_API.xml index 070a2e98cd..47be1f5c6d 100644 --- a/src/components/interfaces/HMI_API.xml +++ b/src/components/interfaces/HMI_API.xml @@ -2009,6 +2009,12 @@ The short name or a short description of the climate control module. + + + Availability of the reading of current temperature. + True: Available, False: Not Available, Not present: Not Available. + + Availability of the control of fan speed. @@ -2128,7 +2134,7 @@ Reflects the volume of audio, from 0%-100%. - + Defines the list of supported channels (band) and their current/desired settings on HMI diff --git a/src/components/interfaces/MOBILE_API.xml b/src/components/interfaces/MOBILE_API.xml index b09e8409b2..ec8e1f1847 100644 --- a/src/components/interfaces/MOBILE_API.xml +++ b/src/components/interfaces/MOBILE_API.xml @@ -3155,8 +3155,8 @@ - Availability of the getting HD radio Station Information Service (SIS) data. - True: Available, False: Not Available, Not present: Not Available. + Availability of the getting HD radio Station Information Service (SIS) data. + True: Available, False: Not Available, Not present: Not Available. @@ -3240,20 +3240,20 @@ - Availability of the control (enable/disable) of heated Windshield. - True: Available, False: Not Available, Not present: Not Available. + Availability of the control (enable/disable) of heated Windshield. + True: Available, False: Not Available, Not present: Not Available. - Availability of the control (enable/disable) of heated Rear Window. - True: Available, False: Not Available, Not present: Not Available. + Availability of the control (enable/disable) of heated Rear Window. + True: Available, False: Not Available, Not present: Not Available. - Availability of the control (enable/disable) of heated Mirrors. - True: Available, False: Not Available, Not present: Not Available. + Availability of the control (enable/disable) of heated Mirrors. + True: Available, False: Not Available, Not present: Not Available. @@ -3270,24 +3270,24 @@ - In a getter response or a notification, it is the current primary audio source of the system. - In a setter request, it is the target audio source that the system shall switch to. - If the value is MOBILE_APP, the system shall switch to the mobile media app that issues the setter RPC. + In a getter response or a notification, it is the current primary audio source of the system. + In a setter request, it is the target audio source that the system shall switch to. + If the value is MOBILE_APP, the system shall switch to the mobile media app that issues the setter RPC. - This parameter shall not be present in any getter responses or notifications. - This parameter is optional in a setter request. The default value is false. - If it is false, the system not only changes the audio source but also brings the default application - or system UI associated with the audio source to foreground. - If it is true, the system changes the audio source, but still keeps the current application in foreground. + This parameter shall not be present in any getter responses or notifications. + This parameter is optional in a setter request. The default value is false. + If it is false, the system not only changes the audio source but also brings the default application + or system UI associated with the audio source to foreground. + If it is true, the system changes the audio source, but still keeps the current application in foreground. Reflects the volume of audio, from 0%-100%. - + Defines the list of supported channels (band) and their current/desired settings on HMI @@ -3295,8 +3295,8 @@ - The short friendly name of the light control module. - It should not be used to identify a module by mobile application. + The short friendly name of the light control module. + It should not be used to identify a module by mobile application. @@ -3402,12 +3402,12 @@ - Indicates if the light's density can be set remotely (similar to a dimmer). + Indicates if the light's density can be set remotely (similar to a dimmer). - Indicates if the light's color can be set remotely by using the RGB color space. + Indicates if the light's color can be set remotely by using the RGB color space. @@ -3415,8 +3415,8 @@ - The short friendly name of the light control module. - It should not be used to identify a module by mobile application. + The short friendly name of the light control module. + It should not be used to identify a module by mobile application. @@ -3616,7 +3616,7 @@ The position of the haptic rectangle to be highlighted. The center of this rectangle will be "touched" when a press occurs. - + -- cgit v1.2.1 From 80b868ed6d1b0c7b488729c8c1ddafe04614fbea Mon Sep 17 00:00:00 2001 From: Alexander Date: Thu, 16 Aug 2018 19:24:22 +0300 Subject: Increase size of modules to fix UTs --- .../rc_rpc_plugin/test/resource_allocation_manager_impl_test.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/resource_allocation_manager_impl_test.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/resource_allocation_manager_impl_test.cc index 4e2e4d7895..7eb298f024 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/resource_allocation_manager_impl_test.cc +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/resource_allocation_manager_impl_test.cc @@ -71,7 +71,7 @@ const uint32_t kAppId1 = 11u; const uint32_t kHMIAppId1 = 1u; const uint32_t kAppId2 = 22u; const std::string policy_app_id_1_ = "policy_id_1"; -const uint32_t kSizeOfModules = 3u; +const uint32_t kSizeOfModules = 6u; } namespace rc_rpc_plugin_test { -- cgit v1.2.1 From 6ffe22d5ff425c0a8e5d4c77c34916a005eecefc Mon Sep 17 00:00:00 2001 From: JackLivio Date: Thu, 16 Aug 2018 15:51:15 -0400 Subject: Update mobile version negotiation Because mobile versioning did not exist prior to core 5.0, and IOS was using a hardcoded 1.0.0 for syncMsgVersion, all apps using version 1.0 to 4.5 will be negotiated to core RPC version 4.5 --- .../src/commands/mobile/register_app_interface_request.cc | 7 ++++++- src/components/application_manager/src/rpc_handler_impl.cc | 8 +++----- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/register_app_interface_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/register_app_interface_request.cc index 164c854f18..1b2bbe2b44 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/register_app_interface_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/register_app_interface_request.cc @@ -322,9 +322,14 @@ void RegisterAppInterfaceRequest::Run() { } // Version negotiation + utils::SemanticVersion ver_4_5(4,5,0); utils::SemanticVersion module_version( major_version, minor_version, patch_version); - if (mobile_version < module_version) { + if (mobile_version <= ver_4_5) { + // Mobile versioning did not exist for + // versions 4.5 and prior. + application->set_msg_version(ver_4_5); + } else if (mobile_version < module_version) { // Use mobile RPC version as negotiated version application->set_msg_version(mobile_version); } else { diff --git a/src/components/application_manager/src/rpc_handler_impl.cc b/src/components/application_manager/src/rpc_handler_impl.cc index bf1ff78d36..c46a99fa39 100644 --- a/src/components/application_manager/src/rpc_handler_impl.cc +++ b/src/components/application_manager/src/rpc_handler_impl.cc @@ -219,7 +219,8 @@ void RPCHandlerImpl::GetMessageVersion( } utils::SemanticVersion temp_version(major, minor, patch); if (temp_version.isValid()) { - message_version = temp_version; + utils::SemanticVersion ver_4_5(4,5,0); + message_version = (temp_version > ver_4_5) ? temp_version : ver_4_5; } } } @@ -251,10 +252,7 @@ bool RPCHandlerImpl::ConvertMessageToSO( // Attach RPC version to SmartObject if it does not exist yet. auto app_ptr = app_manager_.application(message.connection_key()); utils::SemanticVersion msg_version(0, 0, 0); - if (app_ptr && - (output[NsSmartDeviceLink::NsJSONHandler::strings::S_PARAMS] - .keyExists(NsSmartDeviceLink::NsJSONHandler::strings:: - S_RPC_MSG_VERSION) == false)) { + if (app_ptr) { msg_version = app_ptr->msg_version(); } else if (mobile_apis::FunctionID::RegisterAppInterfaceID == static_cast( -- cgit v1.2.1 From 86585a299a650e9740e5bbe504a71ddb04e2beb5 Mon Sep 17 00:00:00 2001 From: Alexander Date: Fri, 17 Aug 2018 16:20:21 +0300 Subject: Ignore id parameter fo radio controll data. Id parameter should not be checked by capabilities --- .../src/commands/mobile/set_interior_vehicle_data_request.cc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/set_interior_vehicle_data_request.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/set_interior_vehicle_data_request.cc index 0da1e4c6e7..f561cba6ff 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/set_interior_vehicle_data_request.cc +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/set_interior_vehicle_data_request.cc @@ -227,6 +227,9 @@ bool CheckControlDataByCapabilities( auto it = control_data.map_begin(); for (; it != control_data.map_end(); ++it) { const std::string& request_parameter = it->first; + if (message_params::kId == request_parameter) { + continue; + } if (message_params::kLightState == request_parameter) { auto light_data = control_data[request_parameter].asArray()->begin(); for (; light_data != control_data[request_parameter].asArray()->end(); -- cgit v1.2.1 From ceea340f632345c4de87d93f97f2efb6de9b9c30 Mon Sep 17 00:00:00 2001 From: "Ira Lytvynenko (GitHub)" Date: Wed, 18 Jul 2018 14:06:42 +0300 Subject: Replace the RADIO_TUNER with four enumeration elements AM, FM, XM and DAB --- src/components/interfaces/HMI_API.xml | 9 +++++++-- src/components/interfaces/MOBILE_API.xml | 9 +++++++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/components/interfaces/HMI_API.xml b/src/components/interfaces/HMI_API.xml index 47be1f5c6d..b341532cff 100644 --- a/src/components/interfaces/HMI_API.xml +++ b/src/components/interfaces/HMI_API.xml @@ -985,8 +985,13 @@ - - Radio may be on AM, FM or XM + + + + + + + diff --git a/src/components/interfaces/MOBILE_API.xml b/src/components/interfaces/MOBILE_API.xml index ec8e1f1847..033c38bdf3 100644 --- a/src/components/interfaces/MOBILE_API.xml +++ b/src/components/interfaces/MOBILE_API.xml @@ -1336,8 +1336,13 @@ - - Radio may be on AM, FM or XM + + + + + + + -- cgit v1.2.1 From 2817291bf59e17e4b95aa6465a4d597afe41c838 Mon Sep 17 00:00:00 2001 From: JackLivio Date: Fri, 17 Aug 2018 09:54:49 -0400 Subject: Remove app link mention --- src/components/policy/policy_external/src/policy_helper.cc | 1 - 1 file changed, 1 deletion(-) diff --git a/src/components/policy/policy_external/src/policy_helper.cc b/src/components/policy/policy_external/src/policy_helper.cc index 98546ef318..2358c54bef 100644 --- a/src/components/policy/policy_external/src/policy_helper.cc +++ b/src/components/policy/policy_external/src/policy_helper.cc @@ -620,7 +620,6 @@ void FillNotificationData::UpdateParameters( ParametersConstItr it_parameters = in_parameters.begin(); ParametersConstItr it_parameters_end = in_parameters.end(); - // From AppLink Policies Manager specification: // To determine consent for a particular RPC in a particular HMI level with // particular parameters (if applicable), the system shall find all of the // functional groups the RPC is included in. If user consent is needed as -- cgit v1.2.1 From f08b36868129dc283d3aff54e754b78f7b9c58f3 Mon Sep 17 00:00:00 2001 From: Alexander Date: Wed, 15 Aug 2018 11:15:39 +0300 Subject: Use existing RGB color structure against adding new SRGB --- src/appMain/hmi_capabilities.json | 1 - src/components/interfaces/HMI_API.xml | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/src/appMain/hmi_capabilities.json b/src/appMain/hmi_capabilities.json index dbbb42637c..097da28ef2 100755 --- a/src/appMain/hmi_capabilities.json +++ b/src/appMain/hmi_capabilities.json @@ -702,7 +702,6 @@ "rgbColorSpaceAvailable":true } ] - }, "hmiSettingsControlCapabilities": { "moduleName": "hmiSettings", diff --git a/src/components/interfaces/HMI_API.xml b/src/components/interfaces/HMI_API.xml index 47be1f5c6d..11f251dff8 100644 --- a/src/components/interfaces/HMI_API.xml +++ b/src/components/interfaces/HMI_API.xml @@ -2259,7 +2259,7 @@ Indicates if the light's density can be set remotely (similar to a dimmer). - + Indicates if the light's color can be set remotely by using the RGB color space. -- cgit v1.2.1 From eb7b4eba938562aa1ef2f15473a394e40624782a Mon Sep 17 00:00:00 2001 From: "Anna Pipko (GitHub)" Date: Tue, 22 May 2018 18:17:34 +0300 Subject: Add Remote Control Radio Parameter Update to API --- src/components/interfaces/HMI_API.xml | 21 ++++++++++++++++++--- src/components/interfaces/MOBILE_API.xml | 19 +++++++++++++++++-- 2 files changed, 35 insertions(+), 5 deletions(-) diff --git a/src/components/interfaces/HMI_API.xml b/src/components/interfaces/HMI_API.xml index 11f251dff8..4fbbfea108 100644 --- a/src/components/interfaces/HMI_API.xml +++ b/src/components/interfaces/HMI_API.xml @@ -1853,10 +1853,13 @@ - + + True if the hd radio is on, false is the radio is off + + number of HD sub-channels if available - + Current HD sub-channel if available @@ -1939,6 +1942,18 @@ True: Available, False: Not Available, Not present: Not Available. + + + Availability of the control of enable/disable HD radio. + True: Available, False: Not Available, Not present: Not Available. + + + + + Availability of sirius XM radio. + True: Available, False: Not Available, Not present: Not Available. + + @@ -2259,7 +2274,7 @@ Indicates if the light's density can be set remotely (similar to a dimmer). - + Indicates if the light's color can be set remotely by using the RGB color space. diff --git a/src/components/interfaces/MOBILE_API.xml b/src/components/interfaces/MOBILE_API.xml index ec8e1f1847..a7eca9d192 100644 --- a/src/components/interfaces/MOBILE_API.xml +++ b/src/components/interfaces/MOBILE_API.xml @@ -3034,10 +3034,13 @@ - + + True if the hd radio is on, false is the radio is off + + number of HD sub-channels if available - + Current HD sub-channel if available @@ -3159,6 +3162,18 @@ True: Available, False: Not Available, Not present: Not Available. + + + Availability of the control of enable/disable HD radio. + True: Available, False: Not Available, Not present: Not Available. + + + + + Availability of sirius XM radio. + True: Available, False: Not Available, Not present: Not Available. + + -- cgit v1.2.1 From 5e130741f0dfa391ecf5dc1c0d6ab5db9ab9c154 Mon Sep 17 00:00:00 2001 From: Elvis Kuliiev Date: Wed, 23 May 2018 19:59:47 +0300 Subject: Add param 'hdRadioEnable' to Compatibilities map --- .../rc_rpc_plugin/include/rc_rpc_plugin/rc_module_constants.h | 3 +++ .../src/commands/mobile/set_interior_vehicle_data_request.cc | 1 + 2 files changed, 4 insertions(+) diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_module_constants.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_module_constants.h index 22db12c68b..a38887572c 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_module_constants.h +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_module_constants.h @@ -54,6 +54,9 @@ const char kSupportedLights[] = "supportedLights"; const char kName[] = "name"; const char kDensityAvailable[] = "densityAvailable"; const char kRGBColorSpaceAvailable[] = "rgbColorSpaceAvailable"; + +// RadioControlCapabilities +const char kSiriusxmRadioAvailable[] = "siriusxmRadioAvailable"; } // strings namespace result_codes { diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/set_interior_vehicle_data_request.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/set_interior_vehicle_data_request.cc index f561cba6ff..6fc61bcfe7 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/set_interior_vehicle_data_request.cc +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/set_interior_vehicle_data_request.cc @@ -98,6 +98,7 @@ const std::map GetModuleDataToCapabilitiesMapping() { mapping["rdsData"] = "rdsDataAvailable"; mapping["availableHDs"] = "availableHDsAvailable"; mapping["hdChannel"] = "availableHDsAvailable"; + mapping["hdRadioEnable"] = "hdRadioEnableAvailable"; mapping["signalStrength"] = "signalStrengthAvailable"; mapping["signalChangeThreshold"] = "signalChangeThresholdAvailable"; mapping["radioEnable"] = "radioEnableAvailable"; -- cgit v1.2.1 From a1102abc2853cc6016000e71ac16d10d700383d2 Mon Sep 17 00:00:00 2001 From: "Ira Lytvynenko (GitHub)" Date: Wed, 13 Jun 2018 14:06:15 +0300 Subject: Add param siriusxmRadioAvailable to capabilities --- .../mobile/set_interior_vehicle_data_request.cc | 29 ++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/set_interior_vehicle_data_request.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/set_interior_vehicle_data_request.cc index 6fc61bcfe7..f305f88872 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/set_interior_vehicle_data_request.cc +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/set_interior_vehicle_data_request.cc @@ -219,6 +219,30 @@ bool CheckLightNameByCapabilities( return false; } +bool CheckRadioBandByCapabilities( + const smart_objects::SmartObject& capabilities_status, + const smart_objects::SmartObject& request_parameter) { + mobile_apis::RadioBand::eType radio_band = + static_cast(request_parameter.asUInt()); + if (mobile_apis::RadioBand::XM == radio_band) { + if (!capabilities_status.keyExists(strings::kSiriusxmRadioAvailable)) { + LOG4CXX_DEBUG(logger_, + "Capability " + << strings::kSiriusxmRadioAvailable + << " is missed in RemoteControl capabilities"); + return false; + } + if (!capabilities_status[strings::kSiriusxmRadioAvailable].asBool()) { + LOG4CXX_DEBUG(logger_, + "Capability " + << strings::kSiriusxmRadioAvailable + << " is switched off in RemoteControl capabilities"); + return false; + } + } + return true; +} + bool CheckControlDataByCapabilities( const smart_objects::SmartObject& capabilities_status, const smart_objects::SmartObject& control_data) { @@ -262,6 +286,11 @@ bool CheckControlDataByCapabilities( << " is switched off in RemoteControl capabilities"); return false; } + if (message_params::kBand == request_parameter && + !CheckRadioBandByCapabilities(capabilities_status, + control_data[request_parameter])) { + return false; + } } return true; } -- cgit v1.2.1 From 8aba98dc89c47d4279175cd4c42ce3dc8722309a Mon Sep 17 00:00:00 2001 From: "Ira Lytvynenko (GitHub)" Date: Wed, 13 Jun 2018 14:32:17 +0300 Subject: Add new params for radio to hmi capabilities --- src/appMain/hmi_capabilities.json | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/appMain/hmi_capabilities.json b/src/appMain/hmi_capabilities.json index 097da28ef2..a3f7bcd0a1 100755 --- a/src/appMain/hmi_capabilities.json +++ b/src/appMain/hmi_capabilities.json @@ -464,6 +464,8 @@ "rdsDataAvailable": true, "signalChangeThresholdAvailable": true, "signalStrengthAvailable": true, + "hdRadioEnableAvailable" : true, + "siriusxmRadioAvailable" : true, "sisDataAvailable":true, "stateAvailable": true } -- cgit v1.2.1 From 8d9e17589b01cad866478532297f554f909feefb Mon Sep 17 00:00:00 2001 From: ZhdanovP Date: Fri, 17 Aug 2018 18:18:35 +0300 Subject: Add version and history for parameters in mobile api --- src/components/interfaces/MOBILE_API.xml | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/components/interfaces/MOBILE_API.xml b/src/components/interfaces/MOBILE_API.xml index a7eca9d192..2f345c1350 100644 --- a/src/components/interfaces/MOBILE_API.xml +++ b/src/components/interfaces/MOBILE_API.xml @@ -3034,14 +3034,20 @@ - + True if the hd radio is on, false is the radio is off - + number of HD sub-channels if available + + + - + Current HD sub-channel if available + + + -- cgit v1.2.1 From d1d41de4f1b9716504faa60b5d908c5c8b1c8454 Mon Sep 17 00:00:00 2001 From: Jacob Keeler Date: Fri, 17 Aug 2018 19:55:00 -0400 Subject: Make history entries standalone tags --- src/components/interfaces/MOBILE_API.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/interfaces/MOBILE_API.xml b/src/components/interfaces/MOBILE_API.xml index 2f345c1350..189a9a51f9 100644 --- a/src/components/interfaces/MOBILE_API.xml +++ b/src/components/interfaces/MOBILE_API.xml @@ -3040,13 +3040,13 @@ number of HD sub-channels if available - + Current HD sub-channel if available - + -- cgit v1.2.1 From 150b945b1484758d891ed449ac8ca1d860e22ac7 Mon Sep 17 00:00:00 2001 From: jacobkeeler Date: Fri, 17 Aug 2018 19:02:02 -0400 Subject: Remove deprecated methods from project --- .../include/application_manager/application.h | 12 -- .../include/application_manager/application_impl.h | 8 - .../application_manager/application_manager_impl.h | 120 ------------ .../application_manager/commands/command_impl.h | 14 -- .../commands/command_request_impl.h | 2 - .../include/application_manager/hmi_state.h | 35 ---- .../include/application_manager/message.h | 1 - .../resumption/resumption_data.h | 11 -- .../resumption/resumption_data_db.h | 11 -- .../resumption/resumption_data_json.h | 12 -- .../mobile/perform_audio_pass_thru_request.h | 9 - .../mobile/register_app_interface_request.h | 6 - .../mobile/perform_audio_pass_thru_request.cc | 7 - .../mobile/register_app_interface_request.cc | 5 - .../mobile/subscribe_vehicle_data_request.h | 8 - .../mobile/subscribe_vehicle_data_request.cc | 15 -- .../application_manager/src/application_impl.cc | 4 - .../src/application_manager_impl.cc | 218 +-------------------- .../src/commands/command_impl.cc | 14 -- .../application_manager/src/hmi_state.cc | 49 ----- src/components/application_manager/src/message.cc | 13 -- .../src/resumption/resumption_data_db.cc | 4 - .../src/resumption/resumption_data_json.cc | 4 - .../test/application_manager_impl_test.cc | 3 +- .../include/application_manager/mock_application.h | 3 - .../include/config_profile/profile.h | 6 - src/components/config_profile/src/profile.cc | 4 - .../connection_handler/connection_handler_impl.h | 36 +--- .../src/connection_handler_impl.cc | 81 -------- .../application_manager/application_manager.h | 53 ----- .../connection_handler_observer.h | 13 -- .../policy_external/policy/policy_listener.h | 7 - .../include/protocol_handler/protocol_handler.h | 21 -- .../protocol_handler/protocol_handler_settings.h | 6 - .../include/protocol_handler/session_observer.h | 38 ---- .../application_manager/mock_application_manager.h | 14 -- .../mock_connection_handler_observer.h | 5 - .../test/protocol_handler/mock_protocol_handler.h | 7 - .../test/protocol_handler/mock_session_observer.h | 7 - .../transport_adapter/transport_adapter.h | 4 - .../transport_adapter/transport_adapter_event.h | 24 --- .../include/protocol_handler/handshake_handler.h | 13 -- .../protocol_handler/protocol_handler_impl.h | 24 --- .../protocol_handler/src/handshake_handler.cc | 20 -- .../protocol_handler/src/protocol_handler_impl.cc | 178 ----------------- .../security_manager/security_manager_impl.h | 6 - .../security_manager/src/security_manager_impl.cc | 4 - .../smart_objects/always_false_schema_item.h | 7 - .../smart_objects/always_true_schema_item.h | 7 - .../include/smart_objects/array_schema_item.h | 11 -- .../include/smart_objects/default_shema_item.h | 14 -- .../include/smart_objects/enum_schema_item.h | 13 -- .../include/smart_objects/number_schema_item.h | 15 -- .../include/smart_objects/object_schema_item.h | 7 - .../include/smart_objects/schema_item.h | 11 -- .../include/smart_objects/smart_object.h | 8 - .../include/smart_objects/smart_schema.h | 11 -- .../include/smart_objects/string_schema_item.h | 7 - .../smart_objects/src/always_false_schema_item.cc | 5 - .../smart_objects/src/always_true_schema_item.cc | 4 - .../smart_objects/src/array_schema_item.cc | 5 - .../smart_objects/src/object_schema_item.cc | 5 - src/components/smart_objects/src/schema_item.cc | 4 - src/components/smart_objects/src/smart_object.cc | 5 - src/components/smart_objects/src/smart_schema.cc | 5 - .../smart_objects/src/string_schema_item.cc | 5 - .../include/telemetry_monitor/telemetry_monitor.h | 1 - .../telemetry_monitor/src/telemetry_monitor.cc | 2 - .../transport_manager/transport_manager_impl.h | 14 +- .../transport_adapter/transport_adapter_impl.cc | 4 - 70 files changed, 10 insertions(+), 1319 deletions(-) diff --git a/src/components/application_manager/include/application_manager/application.h b/src/components/application_manager/include/application_manager/application.h index 31fd04b1a2..c3a4ecbb30 100644 --- a/src/components/application_manager/include/application_manager/application.h +++ b/src/components/application_manager/include/application_manager/application.h @@ -597,8 +597,6 @@ class Application : public virtual InitialApplicationData, virtual void increment_list_files_in_none_count() = 0; virtual bool set_app_icon_path(const std::string& file_name) = 0; virtual void set_app_allowed(const bool allowed) = 0; - DEPRECATED virtual void set_device( - connection_handler::DeviceHandle device) = 0; /** * @brief Sets the handle of the device on which secondary transport of this * app is running @@ -790,16 +788,6 @@ class Application : public virtual InitialApplicationData, */ virtual bool IsVideoApplication() const = 0; - /** - * DEPRECATED - * @brief GetDeviceId allows to obtain device id which posseses - * by this application. - * @return device the device id. - */ - std::string GetDeviceId() const { - return device_id_; - } - /** * @brief IsRegistered allows to distinguish if this * application has been registered. diff --git a/src/components/application_manager/include/application_manager/application_impl.h b/src/components/application_manager/include/application_manager/application_impl.h index f5cf353c75..d86203cd84 100644 --- a/src/components/application_manager/include/application_manager/application_impl.h +++ b/src/components/application_manager/include/application_manager/application_impl.h @@ -94,14 +94,6 @@ class ApplicationImpl : public virtual Application, std::shared_ptr statistics_manager, ApplicationManager& application_manager); - DEPRECATED ApplicationImpl( - uint32_t application_id, - const std::string& policy_app_id, - const std::string& mac_address, - const custom_str::CustomString& app_name, - std::shared_ptr statistics_manager, - ApplicationManager& application_manager); - ~ApplicationImpl(); /** 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 5f485b76eb..d297b09557 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 @@ -227,29 +227,6 @@ class ApplicationManagerImpl */ bool IsAppTypeExistsInFullOrLimited(ApplicationConstSharedPtr app) const; - /** - * DEPRECATED - * @brief Checks if Application is subscribed for way points - * @param Application AppID - * @return true if Application is subscribed for way points - * otherwise false - */ - bool IsAppSubscribedForWayPoints(const uint32_t app_id) const OVERRIDE; - - /** - * DEPRECATED - * @brief Subscribe Application for way points - * @param Application AppID - */ - void SubscribeAppForWayPoints(const uint32_t app_id) OVERRIDE; - - /** - * DEPRECATED - * @brief Unsubscribe Application for way points - * @param Application AppID - */ - void UnsubscribeAppFromWayPoints(const uint32_t app_id) OVERRIDE; - /** * @brief Checks if Application is subscribed for way points * @param Application pointer @@ -369,10 +346,6 @@ class ApplicationManagerImpl * @brief Closes all registered applications */ void UnregisterAllApplications(); - - DEPRECATED bool RemoveAppDataFromHMI(ApplicationSharedPtr app); - - DEPRECATED bool LoadAppDataToHMI(ApplicationSharedPtr app); bool ActivateApplication(ApplicationSharedPtr app) OVERRIDE; /** @@ -394,13 +367,6 @@ class ApplicationManagerImpl */ uint32_t GetNextHMICorrelationID() OVERRIDE; - /* @brief Starts audio passthru process - * @deprecated Use BeginAudioPassThru(uint32_t app_id) instead - * - * @return true on success, false if passthru is already in process - */ - bool BeginAudioPassThrough() OVERRIDE; - /** * @brief Starts AudioPassThru process by given application * @param app_id ID of the application which starts the process @@ -408,14 +374,6 @@ class ApplicationManagerImpl */ bool BeginAudioPassThru(uint32_t app_id) OVERRIDE; - /* - * @brief Finishes already started audio passthru process - * @deprecated Use EndAudioPassThru(uint32_t app_id) instead - * - * @return true on success, false if passthru is not active - */ - bool EndAudioPassThrough() OVERRIDE; - /** * @brief Finishes already started AudioPassThru process by given application * @param app_id ID of the application which started the process @@ -440,22 +398,6 @@ class ApplicationManagerImpl void set_driver_distraction_state( const hmi_apis::Common_DriverDistractionState::eType state) OVERRIDE; - /* - * DEPRECATED - * @brief Retrieves if VR session has started - * - * @return Current VR session state (started, stopped) - */ - inline bool vr_session_started() const; - - /* - * DEPRECATED - * @brief Sets VR session state - * - * @param state Current HMI VR session state - */ - void set_vr_session_started(const bool state); - /* * @brief Retrieves SDL access to all mobile apps * @@ -485,21 +427,6 @@ class ApplicationManagerImpl mobile_apis::VideoStreamingState::eType video_state, mobile_apis::SystemContext::eType system_context) const OVERRIDE; - /** - * DEPRECATED - * @brief CreateRegularState create regular HMI state for application - * @param app_id Application id - * @param hmi_level of returned state - * @param audio_state of returned state - * @param system_context of returned state - * @return new regular HMI state - */ - DEPRECATED HmiStatePtr CreateRegularState( - uint32_t app_id, - mobile_apis::HMILevel::eType hmi_level, - mobile_apis::AudioStreamingState::eType audio_state, - mobile_apis::SystemContext::eType system_context) const OVERRIDE; - /** * @brief Checks, if given RPC is allowed at current HMI level for specific * application in policy table @@ -664,10 +591,6 @@ class ApplicationManagerImpl */ void OnDeviceSwitchingFinish(const std::string& device_uid) FINAL; - DEPRECATED bool OnServiceStartedCallback( - const connection_handler::DeviceHandle& device_handle, - const int32_t& session_key, - const protocol_handler::ServiceType& type) OVERRIDE; void OnServiceStartedCallback( const connection_handler::DeviceHandle& device_handle, const int32_t& session_key, @@ -865,20 +788,6 @@ class ApplicationManagerImpl */ uint32_t GenerateNewHMIAppID() OVERRIDE; - /** - * DERPECATED - * @brief Parse smartObject and replace mobile app Id by HMI app ID - * @param message Smartobject to be parsed - */ - void ReplaceMobileByHMIAppId(smart_objects::SmartObject& message); - - /** - * DEPRECATED - * @brief Parse smartObject and replace HMI app ID by mobile app Id - * @param message Smartobject to be parsed - */ - void ReplaceHMIByMobileAppId(smart_objects::SmartObject& message); - /* * @brief Save binary data to specified directory * @@ -930,22 +839,6 @@ class ApplicationManagerImpl */ void RemoveAppFromTTSGlobalPropertiesList(const uint32_t app_id) OVERRIDE; - /** - * DEPRECATED - * @brief method adds application in FULL and LIMITED state - * to on_phone_call_app_list_. - * Also OnHMIStateNotification with BACKGROUND state sent for these apps - */ - void CreatePhoneCallAppList(); - - /** - * DEPRECATED - * @brief method removes application from on_phone_call_app_list_. - * - * Also OnHMIStateNotification with previous HMI state sent for these apps - */ - void ResetPhoneCallAppList(); - // TODO(AOleynik): Temporary added, to fix build. Should be reworked. connection_handler::ConnectionHandler& connection_handler() const OVERRIDE; protocol_handler::ProtocolHandler& protocol_handler() const OVERRIDE; @@ -1311,15 +1204,6 @@ class ApplicationManagerImpl */ void EndNaviStreaming(); - /** - * @brief Starts specified navi service for application - * @param app_id Application to proceed - * @param service_type Type of service to start - * @return True on success, false on fail - */ - DEPRECATED bool StartNaviService(uint32_t app_id, - protocol_handler::ServiceType service_type); - /** * @brief Starts specified navi service for application * @param app_id Application to proceed @@ -1609,10 +1493,6 @@ class ApplicationManagerImpl DISALLOW_COPY_AND_ASSIGN(ApplicationManagerImpl); }; -DEPRECATED bool ApplicationManagerImpl::vr_session_started() const { - return is_vr_session_strated_; -} - inline bool ApplicationManagerImpl::all_apps_allowed() const { return is_all_apps_allowed_; } diff --git a/src/components/application_manager/include/application_manager/commands/command_impl.h b/src/components/application_manager/include/application_manager/commands/command_impl.h index be79d9e8d1..4859f73a55 100644 --- a/src/components/application_manager/include/application_manager/commands/command_impl.h +++ b/src/components/application_manager/include/application_manager/commands/command_impl.h @@ -151,13 +151,6 @@ class CommandImpl : public Command { */ bool ReplaceMobileWithHMIAppId(smart_objects::SmartObject& message); - /** - * DEPRECATED - * @brief Parses mobile message and replaces mobile app id with HMI app id - * @param message Message to replace its ids - */ - void ReplaceMobileByHMIAppId(smart_objects::SmartObject& message); - /** * @brief Parses message from HMI and replaces HMI app id with mobile app id * @param message Message to replace its ids @@ -165,13 +158,6 @@ class CommandImpl : public Command { */ bool ReplaceHMIWithMobileAppId(smart_objects::SmartObject& message); - /** - * DEPRECATED - * @brief Parses message from HMI and replaces HMI app id with mobile app id - * @param message Message to replace its ids - */ - void ReplaceHMIByMobileAppId(smart_objects::SmartObject& message); - MessageSharedPtr message_; uint32_t default_timeout_; bool allowed_to_terminate_; 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 e790fc9af6..6fdeaea332 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 @@ -43,8 +43,6 @@ namespace application_manager { namespace commands { struct ResponseInfo { - DEPRECATED ResponseInfo(hmi_apis::Common_Result::eType result, - HmiInterfaces::InterfaceID interface); ResponseInfo(); ResponseInfo(const hmi_apis::Common_Result::eType result, const HmiInterfaces::InterfaceID hmi_interface, diff --git a/src/components/application_manager/include/application_manager/hmi_state.h b/src/components/application_manager/include/application_manager/hmi_state.h index e333cb9bbc..4b7779e08c 100644 --- a/src/components/application_manager/include/application_manager/hmi_state.h +++ b/src/components/application_manager/include/application_manager/hmi_state.h @@ -94,25 +94,6 @@ class HmiState { const ApplicationManager& app_mngr, StateID state_id); - /** - * DEPRECATED - * @brief HmiState constructor - * @param app_id Application id - * @param app_mngr Application manager - */ - HmiState(uint32_t app_id, const ApplicationManager& app_mngr); - - /** - * DEPRECATED - * @brief HmiState constructor - * @param app_id Application id - * @param app_mngr Application manager - * @param state_id HMI state to assign - */ - HmiState(uint32_t app_id, - const ApplicationManager& app_mngr, - StateID state_id); - virtual ~HmiState() {} /** @@ -274,8 +255,6 @@ class VRHmiState : public HmiState { const OVERRIDE; VRHmiState(std::shared_ptr app, const ApplicationManager& app_mngr); - - DEPRECATED VRHmiState(uint32_t app_id, const ApplicationManager& app_mngr); }; /** @@ -286,8 +265,6 @@ class TTSHmiState : public HmiState { TTSHmiState(std::shared_ptr app, const ApplicationManager& app_mngr); - DEPRECATED TTSHmiState(uint32_t app_id, const ApplicationManager& app_mngr); - virtual mobile_apis::AudioStreamingState::eType audio_streaming_state() const OVERRIDE; }; @@ -327,9 +304,6 @@ class PhoneCallHmiState : public HmiState { PhoneCallHmiState(std::shared_ptr app, const ApplicationManager& app_mngr); - DEPRECATED PhoneCallHmiState(uint32_t app_id, - const ApplicationManager& app_mngr); - mobile_apis::HMILevel::eType hmi_level() const OVERRIDE; mobile_apis::AudioStreamingState::eType audio_streaming_state() const OVERRIDE { @@ -346,9 +320,6 @@ class SafetyModeHmiState : public HmiState { SafetyModeHmiState(std::shared_ptr app, const ApplicationManager& app_mngr); - DEPRECATED SafetyModeHmiState(uint32_t app_id, - const ApplicationManager& app_mngr); - mobile_apis::AudioStreamingState::eType audio_streaming_state() const OVERRIDE { return mobile_apis::AudioStreamingState::NOT_AUDIBLE; @@ -368,8 +339,6 @@ class DeactivateHMI : public HmiState { DeactivateHMI(std::shared_ptr app, const ApplicationManager& app_mngr); - DEPRECATED DeactivateHMI(uint32_t app_id, const ApplicationManager& app_mngr); - mobile_apis::HMILevel::eType hmi_level() const OVERRIDE; mobile_apis::AudioStreamingState::eType audio_streaming_state() const OVERRIDE { @@ -390,8 +359,6 @@ class AudioSource : public HmiState { AudioSource(std::shared_ptr app, const ApplicationManager& app_mngr); - DEPRECATED AudioSource(uint32_t app_id, const ApplicationManager& app_mngr); - mobile_apis::HMILevel::eType hmi_level() const OVERRIDE; mobile_apis::AudioStreamingState::eType audio_streaming_state() const OVERRIDE { @@ -413,8 +380,6 @@ class EmbeddedNavi : public HmiState { EmbeddedNavi(std::shared_ptr app, const ApplicationManager& app_mngr); - DEPRECATED EmbeddedNavi(uint32_t app_id, const ApplicationManager& app_mngr); - mobile_apis::HMILevel::eType hmi_level() const OVERRIDE; mobile_apis::AudioStreamingState::eType audio_streaming_state() const OVERRIDE { diff --git a/src/components/application_manager/include/application_manager/message.h b/src/components/application_manager/include/application_manager/message.h index 7c3f0a13c9..1c319cf204 100644 --- a/src/components/application_manager/include/application_manager/message.h +++ b/src/components/application_manager/include/application_manager/message.h @@ -88,7 +88,6 @@ class Message { void set_correlation_id(int32_t id); void set_connection_key(int32_t key); void set_message_type(MessageType type); - DEPRECATED void set_binary_data(BinaryData* data); void set_binary_data(const BinaryData* data); void set_json_message(const std::string& json_message); void set_protocol_version(protocol_handler::MajorProtocolVersion version); diff --git a/src/components/application_manager/include/application_manager/resumption/resumption_data.h b/src/components/application_manager/include/application_manager/resumption/resumption_data.h index 5ecfaf3c11..24dc712607 100644 --- a/src/components/application_manager/include/application_manager/resumption/resumption_data.h +++ b/src/components/application_manager/include/application_manager/resumption/resumption_data.h @@ -94,22 +94,11 @@ class ResumptionData { */ virtual void IncrementIgnOffCount() = 0; - /** - * @brief Increments ignition counter for all registered applications - * and remember ign_off time stamp - */ - DEPRECATED virtual void OnSuspend() = 0; - /** * @brief Decrements ignition counter for all registered applications */ virtual void DecrementIgnOffCount() = 0; - /** - * @brief Decrements ignition counter for all registered applications - */ - DEPRECATED virtual void OnAwake() = 0; - /** * @brief Retrieves hash ID for the given mobile app ID * and device ID from stored information. diff --git a/src/components/application_manager/include/application_manager/resumption/resumption_data_db.h b/src/components/application_manager/include/application_manager/resumption/resumption_data_db.h index 780aac82c1..2405e39087 100644 --- a/src/components/application_manager/include/application_manager/resumption/resumption_data_db.h +++ b/src/components/application_manager/include/application_manager/resumption/resumption_data_db.h @@ -110,17 +110,6 @@ class ResumptionDataDB : public ResumptionData { virtual uint32_t GetHMIApplicationID(const std::string& policy_app_id, const std::string& device_id) const; - /** - * @brief Increments ignition counter for all registered applications - * and remember ign_off time stamp - */ - DEPRECATED void OnSuspend() FINAL; - - /** - * @brief Decrements ignition counter for all registered applications - */ - DEPRECATED void OnAwake() FINAL; - /** * @brief Increments ignition counter for all registered applications * and remember ign_off time stamp diff --git a/src/components/application_manager/include/application_manager/resumption/resumption_data_json.h b/src/components/application_manager/include/application_manager/resumption/resumption_data_json.h index 82ec1d9e5c..ff3414d97a 100644 --- a/src/components/application_manager/include/application_manager/resumption/resumption_data_json.h +++ b/src/components/application_manager/include/application_manager/resumption/resumption_data_json.h @@ -80,18 +80,6 @@ class ResumptionDataJson : public ResumptionData { */ virtual uint32_t GetHMIApplicationID(const std::string& policy_app_id, const std::string& device_id) const; - - /** - * @brief Increments ignition counter for all registered applications - * and remember ign_off time stamp - */ - DEPRECATED void OnSuspend() FINAL; - - /** - * @brief Decrements ignition counter for all registered applications - */ - DEPRECATED void OnAwake() FINAL; - /** * @brief Increments ignition counter for all registered applications * and remember ign_off time stamp diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/perform_audio_pass_thru_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/perform_audio_pass_thru_request.h index 6db222a401..1a4c248a02 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/perform_audio_pass_thru_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/perform_audio_pass_thru_request.h @@ -108,15 +108,6 @@ class PerformAudioPassThruRequest ResponseParams response_params_; - /** - * @brief Prepare result code, result and info for sending to mobile - * application - * @param result_code contains result code for sending to mobile application - * @return result for sending to mobile application. - * @deprecated - */ - DEPRECATED bool PrepareResponseParameters( - mobile_apis::Result::eType& result_code, std::string& info); /** * @brief Prepare result code, 'success' result and info for sending * to mobile application diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/register_app_interface_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/register_app_interface_request.h index 9cac2ab34f..542fdac5f8 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/register_app_interface_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/register_app_interface_request.h @@ -83,12 +83,6 @@ class RegisterAppInterfaceRequest **/ virtual void Run(); - /** - * @brief Prepares and sends RegisterAppInterface response to mobile - * considering application type - **/ - void SendRegisterAppInterfaceResponseToMobile(); - private: /** * @brief The AppicationType enum defines whether application is newly 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 86a644a778..c90038a8b7 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 @@ -250,13 +250,6 @@ PerformAudioPassThruRequest::PrepareResponseParameters() { return response_params_; } -bool PerformAudioPassThruRequest::PrepareResponseParameters( - mobile_apis::Result::eType& result_code, std::string& info) { - LOG4CXX_AUTO_TRACE(logger_); - NOTREACHED(); - return false; -} - void PerformAudioPassThruRequest::SendSpeakRequest() { LOG4CXX_AUTO_TRACE(logger_); diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/register_app_interface_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/register_app_interface_request.cc index 164c854f18..03dc43e6d0 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/register_app_interface_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/register_app_interface_request.cc @@ -830,11 +830,6 @@ void RegisterAppInterfaceRequest::SendRegisterAppInterfaceResponseToMobile( SendChangeRegistrationOnHMI(application); } -DEPRECATED void -RegisterAppInterfaceRequest::SendRegisterAppInterfaceResponseToMobile() { - SendRegisterAppInterfaceResponseToMobile(ApplicationType::kNewApplication); -} - void RegisterAppInterfaceRequest::SendChangeRegistration( const hmi_apis::FunctionID::eType function_id, const int32_t language, diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/subscribe_vehicle_data_request.h b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/subscribe_vehicle_data_request.h index 6e084e0869..7c6e1754da 100644 --- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/subscribe_vehicle_data_request.h +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/subscribe_vehicle_data_request.h @@ -113,14 +113,6 @@ class SubscribeVehicleDataRequest app_mngr::ApplicationSharedPtr app, const smart_objects::SmartObject& msg_params) const; - DEPRECATED void CheckVISubscribtions( - app_mngr::ApplicationSharedPtr app, - std::string& out_info, - mobile_apis::Result::eType& out_result_code, - smart_objects::SmartObject& out_response_params, - smart_objects::SmartObject& out_request_params, - bool& out_result); - /** * @brief Checks if current application and other applications * were subscribed to VI, prepare data that need to send to mobile app diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/subscribe_vehicle_data_request.cc b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/subscribe_vehicle_data_request.cc index 41fd35b8b5..65f4fde0b2 100644 --- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/subscribe_vehicle_data_request.cc +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/subscribe_vehicle_data_request.cc @@ -234,21 +234,6 @@ bool SubscribeVehicleDataRequest::IsSomeoneSubscribedFor( return it != accessor.GetData().end(); } -void SubscribeVehicleDataRequest::CheckVISubscribtions( - ApplicationSharedPtr app, - std::string& out_info, - mobile_apis::Result::eType& out_result_code, - smart_objects::SmartObject& out_response_params, - smart_objects::SmartObject& out_request_params, - bool& out_result) { - CheckVISubscriptions(app, - out_info, - out_result_code, - out_response_params, - out_request_params, - out_result); -} - void SubscribeVehicleDataRequest::CheckVISubscriptions( ApplicationSharedPtr app, std::string& out_info, diff --git a/src/components/application_manager/src/application_impl.cc b/src/components/application_manager/src/application_impl.cc index bebf923234..8f76d81104 100644 --- a/src/components/application_manager/src/application_impl.cc +++ b/src/components/application_manager/src/application_impl.cc @@ -671,10 +671,6 @@ void ApplicationImpl::set_app_allowed(const bool allowed) { is_app_allowed_ = allowed; } -void ApplicationImpl::set_device(connection_handler::DeviceHandle device) { - device_id_ = device; -} - void ApplicationImpl::set_secondary_device( connection_handler::DeviceHandle secondary_device) { secondary_device_id_ = secondary_device; diff --git a/src/components/application_manager/src/application_manager_impl.cc b/src/components/application_manager/src/application_manager_impl.cc index 386bfe4825..a5e93fbc40 100644 --- a/src/components/application_manager/src/application_manager_impl.cc +++ b/src/components/application_manager/src/application_manager_impl.cc @@ -664,16 +664,6 @@ ApplicationSharedPtr ApplicationManagerImpl::RegisterApplication( return application; } -DEPRECATED bool ApplicationManagerImpl::RemoveAppDataFromHMI( - ApplicationSharedPtr app) { - return true; -} - -DEPRECATED bool ApplicationManagerImpl::LoadAppDataToHMI( - ApplicationSharedPtr app) { - return true; -} - bool ApplicationManagerImpl::ActivateApplication(ApplicationSharedPtr app) { using namespace mobile_api; LOG4CXX_AUTO_TRACE(logger_); @@ -800,16 +790,6 @@ uint32_t ApplicationManagerImpl::GetNextHMICorrelationID() { return corelation_id_; } -bool ApplicationManagerImpl::BeginAudioPassThrough() { - sync_primitives::AutoLock lock(audio_pass_thru_lock_); - if (audio_pass_thru_active_) { - return false; - } else { - audio_pass_thru_active_ = true; - return true; - } -} - bool ApplicationManagerImpl::BeginAudioPassThru(uint32_t app_id) { sync_primitives::AutoLock lock(audio_pass_thru_lock_); if (audio_pass_thru_active_) { @@ -821,16 +801,6 @@ bool ApplicationManagerImpl::BeginAudioPassThru(uint32_t app_id) { } } -bool ApplicationManagerImpl::EndAudioPassThrough() { - sync_primitives::AutoLock lock(audio_pass_thru_lock_); - if (audio_pass_thru_active_) { - audio_pass_thru_active_ = false; - return true; - } else { - return false; - } -} - bool ApplicationManagerImpl::EndAudioPassThru(uint32_t app_id) { sync_primitives::AutoLock lock(audio_pass_thru_lock_); if (audio_pass_thru_active_ && audio_pass_thru_app_id_ == app_id) { @@ -852,11 +822,6 @@ void ApplicationManagerImpl::set_driver_distraction_state( driver_distraction_state_ = state; } -DEPRECATED void ApplicationManagerImpl::set_vr_session_started( - const bool state) { - is_vr_session_strated_ = state; -} - void ApplicationManagerImpl::SetAllAppsAllowed(const bool allowed) { is_all_apps_allowed_ = allowed; } @@ -875,18 +840,6 @@ HmiStatePtr ApplicationManagerImpl::CreateRegularState( return state; } -HmiStatePtr ApplicationManagerImpl::CreateRegularState( - uint32_t app_id, - mobile_apis::HMILevel::eType hmi_level, - mobile_apis::AudioStreamingState::eType audio_state, - mobile_apis::SystemContext::eType system_context) const { - HmiStatePtr state(new HmiState(app_id, *this)); - state->set_hmi_level(hmi_level); - state->set_audio_streaming_state(audio_state); - state->set_system_context(system_context); - return state; -} - void ApplicationManagerImpl::StartAudioPassThruThread(int32_t session_key, int32_t correlation_id, int32_t max_duration, @@ -1290,111 +1243,6 @@ uint32_t ApplicationManagerImpl::GenerateNewHMIAppID() { return hmi_app_id; } -void ApplicationManagerImpl::ReplaceMobileByHMIAppId( - smart_objects::SmartObject& message) { - MessageHelper::PrintSmartObject(message); - if (message.keyExists(strings::app_id)) { - ApplicationSharedPtr application_ptr = - application(message[strings::app_id].asUInt()); - if (application_ptr.use_count() != 0) { - LOG4CXX_DEBUG(logger_, - "ReplaceMobileByHMIAppId from " - << message[strings::app_id].asInt() << " to " - << application_ptr->hmi_app_id()); - message[strings::app_id] = application_ptr->hmi_app_id(); - } - } else { - switch (message.getType()) { - case smart_objects::SmartType::SmartType_Array: { - smart_objects::SmartArray* message_array = message.asArray(); - smart_objects::SmartArray::iterator it = message_array->begin(); - for (; it != message_array->end(); ++it) { - ReplaceMobileByHMIAppId(*it); - } - break; - } - case smart_objects::SmartType::SmartType_Map: { - std::set keys = message.enumerate(); - std::set::const_iterator key = keys.begin(); - for (; key != keys.end(); ++key) { - std::string k = *key; - ReplaceMobileByHMIAppId(message[*key]); - } - break; - } - default: { break; } - } - } -} - -void ApplicationManagerImpl::ReplaceHMIByMobileAppId( - smart_objects::SmartObject& message) { - if (message.keyExists(strings::app_id)) { - ApplicationSharedPtr application = - application_by_hmi_app(message[strings::app_id].asUInt()); - - if (application.use_count() != 0) { - LOG4CXX_DEBUG(logger_, - "ReplaceHMIByMobileAppId from " - << message[strings::app_id].asInt() << " to " - << application->app_id()); - message[strings::app_id] = application->app_id(); - } - } else { - switch (message.getType()) { - case smart_objects::SmartType::SmartType_Array: { - smart_objects::SmartArray* message_array = message.asArray(); - smart_objects::SmartArray::iterator it = message_array->begin(); - for (; it != message_array->end(); ++it) { - ReplaceHMIByMobileAppId(*it); - } - break; - } - case smart_objects::SmartType::SmartType_Map: { - std::set keys = message.enumerate(); - std::set::const_iterator key = keys.begin(); - for (; key != keys.end(); ++key) { - ReplaceHMIByMobileAppId(message[*key]); - } - break; - } - default: { break; } - } - } -} - -bool ApplicationManagerImpl::StartNaviService( - uint32_t app_id, protocol_handler::ServiceType service_type) { - using namespace protocol_handler; - LOG4CXX_AUTO_TRACE(logger_); - - if (HMILevelAllowsStreaming(app_id, service_type)) { - NaviServiceStatusMap::iterator it = navi_service_status_.find(app_id); - if (navi_service_status_.end() == it) { - std::pair res = - navi_service_status_.insert( - std::pair >( - app_id, std::make_pair(false, false))); - if (!res.second) { - LOG4CXX_WARN(logger_, "Navi service refused"); - return false; - } - it = res.first; - } - // Fill NaviServices map. Set true to first value of pair if - // we've started video service or to second value if we've - // started audio service - service_type == ServiceType::kMobileNav ? it->second.first = true - : it->second.second = true; - - application(app_id)->StartStreaming(service_type); - return true; - } else { - LOG4CXX_WARN(logger_, "Refused navi service by HMI level"); - } - return false; -} - bool ApplicationManagerImpl::StartNaviService( uint32_t app_id, protocol_handler::ServiceType service_type, @@ -1534,46 +1382,6 @@ void ApplicationManagerImpl::StopNaviService( app->StopStreaming(service_type); } -// Suppress warning for deprecated method used within another deprecated method -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wdeprecated-declarations" -bool ApplicationManagerImpl::OnServiceStartedCallback( - const connection_handler::DeviceHandle& device_handle, - const int32_t& session_key, - const protocol_handler::ServiceType& type) { - using namespace helpers; - using namespace protocol_handler; - LOG4CXX_AUTO_TRACE(logger_); - LOG4CXX_DEBUG(logger_, - "ServiceType = " << type << ". Session = " << std::hex - << session_key); - - if (type == kRpc) { - LOG4CXX_DEBUG(logger_, "RPC service is about to be started."); - return true; - } - ApplicationSharedPtr app = application(session_key); - if (!app) { - LOG4CXX_WARN(logger_, - "The application with id:" << session_key - << " doesn't exists."); - return false; - } - - if (Compare( - type, ServiceType::kMobileNav, ServiceType::kAudio)) { - if (app->is_navi()) { - return StartNaviService(session_key, type); - } else { - LOG4CXX_WARN(logger_, "Refuse not navi application"); - } - } else { - LOG4CXX_WARN(logger_, "Refuse unknown service"); - } - return false; -} -#pragma GCC diagnostic pop - void ApplicationManagerImpl::OnServiceStartedCallback( const connection_handler::DeviceHandle& device_handle, const int32_t& session_key, @@ -1949,7 +1757,7 @@ bool ApplicationManagerImpl::Stop() { application_list_update_timer_.Stop(); try { SetUnregisterAllApplicationsReason( - mobile_api::AppInterfaceUnregisteredReason::IGNITION_OFF); + mobile_api::AppInterfaceUnregisteredReason::IGNITION_OFF); UnregisterAllApplications(); } catch (...) { LOG4CXX_ERROR(logger_, @@ -3621,30 +3429,6 @@ void ApplicationManagerImpl::ClearTTSGlobalPropertiesList() { tts_global_properties_app_list_.clear(); } -bool ApplicationManagerImpl::IsAppSubscribedForWayPoints( - const uint32_t app_id) const { - LOG4CXX_AUTO_TRACE(logger_); - sync_primitives::AutoLock lock(subscribed_way_points_apps_lock_); - if (subscribed_way_points_apps_list_.find(app_id) == - subscribed_way_points_apps_list_.end()) { - return false; - } - return true; -} - -void ApplicationManagerImpl::SubscribeAppForWayPoints(const uint32_t app_id) { - LOG4CXX_AUTO_TRACE(logger_); - sync_primitives::AutoLock lock(subscribed_way_points_apps_lock_); - subscribed_way_points_apps_list_.insert(app_id); -} - -void ApplicationManagerImpl::UnsubscribeAppFromWayPoints( - const uint32_t app_id) { - LOG4CXX_AUTO_TRACE(logger_); - sync_primitives::AutoLock lock(subscribed_way_points_apps_lock_); - subscribed_way_points_apps_list_.erase(app_id); -} - bool ApplicationManagerImpl::IsAppSubscribedForWayPoints( ApplicationSharedPtr app) const { LOG4CXX_AUTO_TRACE(logger_); diff --git a/src/components/application_manager/src/commands/command_impl.cc b/src/components/application_manager/src/commands/command_impl.cc index db78ad15f0..dcc521ae57 100644 --- a/src/components/application_manager/src/commands/command_impl.cc +++ b/src/components/application_manager/src/commands/command_impl.cc @@ -155,13 +155,6 @@ bool CommandImpl::ReplaceMobileWithHMIAppId( return true; } -DEPRECATED void CommandImpl::ReplaceMobileByHMIAppId( - NsSmartDeviceLink::NsSmartObjects::SmartObject& message) { - if (!ReplaceMobileWithHMIAppId(message)) { - LOG4CXX_ERROR(logger_, "Substitution mobile --> HMI id is failed."); - } -} - bool CommandImpl::ReplaceHMIWithMobileAppId( NsSmartDeviceLink::NsSmartObjects::SmartObject& message) { if (message.keyExists(strings::app_id)) { @@ -207,12 +200,5 @@ bool CommandImpl::ReplaceHMIWithMobileAppId( return true; } -DEPRECATED void CommandImpl::ReplaceHMIByMobileAppId( - NsSmartDeviceLink::NsSmartObjects::SmartObject& message) { - if (!ReplaceHMIWithMobileAppId(message)) { - LOG4CXX_ERROR(logger_, "Substitution HMI --> mobile id is failed."); - } -} - } // namespace commands } // namespace application_manager diff --git a/src/components/application_manager/src/hmi_state.cc b/src/components/application_manager/src/hmi_state.cc index 0e67967610..aa4c979ae7 100644 --- a/src/components/application_manager/src/hmi_state.cc +++ b/src/components/application_manager/src/hmi_state.cc @@ -67,27 +67,6 @@ HmiState::HmiState(std::shared_ptr app, LOG4CXX_DEBUG(logger_, *this); } -DEPRECATED HmiState::HmiState(uint32_t app_id, - const ApplicationManager& app_mngr, - StateID state_id) - : state_id_(state_id) - , app_mngr_(app_mngr) - , hmi_level_(mobile_apis::HMILevel::INVALID_ENUM) - , audio_streaming_state_(mobile_apis::AudioStreamingState::INVALID_ENUM) - , system_context_(mobile_apis::SystemContext::INVALID_ENUM) { - app_ = app_mngr_.application(app_id); -} - -DEPRECATED HmiState::HmiState(uint32_t app_id, - const ApplicationManager& app_mngr) - : state_id_(STATE_ID_REGULAR) - , app_mngr_(app_mngr) - , hmi_level_(mobile_apis::HMILevel::INVALID_ENUM) - , audio_streaming_state_(mobile_apis::AudioStreamingState::INVALID_ENUM) - , system_context_(mobile_apis::SystemContext::INVALID_ENUM) { - app_ = app_mngr_.application(app_id); -} - void HmiState::set_parent(HmiStatePtr parent) { DCHECK_OR_RETURN_VOID(parent); parent_ = parent; @@ -119,18 +98,10 @@ VRHmiState::VRHmiState(std::shared_ptr app, const ApplicationManager& app_mngr) : HmiState(app, app_mngr, STATE_ID_VR_SESSION) {} -DEPRECATED VRHmiState::VRHmiState(uint32_t app_id, - const ApplicationManager& app_mngr) - : HmiState(app_id, app_mngr, STATE_ID_VR_SESSION) {} - TTSHmiState::TTSHmiState(std::shared_ptr app, const ApplicationManager& app_mngr) : HmiState(app, app_mngr, STATE_ID_TTS_SESSION) {} -DEPRECATED TTSHmiState::TTSHmiState(uint32_t app_id, - const ApplicationManager& app_mngr) - : HmiState(app_id, app_mngr, STATE_ID_TTS_SESSION) {} - mobile_apis::AudioStreamingState::eType TTSHmiState::audio_streaming_state() const { using namespace helpers; @@ -189,10 +160,6 @@ PhoneCallHmiState::PhoneCallHmiState(std::shared_ptr app, const ApplicationManager& app_mngr) : HmiState(app, app_mngr, STATE_ID_PHONE_CALL) {} -DEPRECATED PhoneCallHmiState::PhoneCallHmiState( - uint32_t app_id, const ApplicationManager& app_mngr) - : HmiState(app_id, app_mngr, STATE_ID_PHONE_CALL) {} - mobile_apis::HMILevel::eType PhoneCallHmiState::hmi_level() const { using namespace helpers; using namespace mobile_apis; @@ -214,18 +181,10 @@ SafetyModeHmiState::SafetyModeHmiState(std::shared_ptr app, const ApplicationManager& app_mngr) : HmiState(app, app_mngr, STATE_ID_SAFETY_MODE) {} -DEPRECATED SafetyModeHmiState::SafetyModeHmiState( - uint32_t app_id, const ApplicationManager& app_mngr) - : HmiState(app_id, app_mngr, STATE_ID_SAFETY_MODE) {} - DeactivateHMI::DeactivateHMI(std::shared_ptr app, const ApplicationManager& app_mngr) : HmiState(app, app_mngr, STATE_ID_DEACTIVATE_HMI) {} -DEPRECATED DeactivateHMI::DeactivateHMI(uint32_t app_id, - const ApplicationManager& app_mngr) - : HmiState(app_id, app_mngr, STATE_ID_DEACTIVATE_HMI) {} - mobile_apis::HMILevel::eType DeactivateHMI::hmi_level() const { using namespace helpers; using namespace mobile_apis; @@ -242,10 +201,6 @@ AudioSource::AudioSource(std::shared_ptr app, const ApplicationManager& app_mngr) : HmiState(app, app_mngr, STATE_ID_AUDIO_SOURCE) {} -DEPRECATED AudioSource::AudioSource(uint32_t app_id, - const ApplicationManager& app_mngr) - : HmiState(app_id, app_mngr, STATE_ID_AUDIO_SOURCE) {} - mobile_apis::HMILevel::eType AudioSource::hmi_level() const { // Checking for NONE is necessary to avoid issue during // calculation of HMI level during setting default HMI level @@ -263,10 +218,6 @@ EmbeddedNavi::EmbeddedNavi(std::shared_ptr app, const ApplicationManager& app_mngr) : HmiState(app, app_mngr, STATE_ID_EMBEDDED_NAVI) {} -DEPRECATED EmbeddedNavi::EmbeddedNavi(uint32_t app_id, - const ApplicationManager& app_mngr) - : HmiState(app_id, app_mngr, STATE_ID_EMBEDDED_NAVI) {} - mobile_apis::HMILevel::eType EmbeddedNavi::hmi_level() const { using namespace mobile_apis; using namespace helpers; diff --git a/src/components/application_manager/src/message.cc b/src/components/application_manager/src/message.cc index b005af0fb5..332d68adbf 100644 --- a/src/components/application_manager/src/message.cc +++ b/src/components/application_manager/src/message.cc @@ -190,19 +190,6 @@ void Message::set_message_type(MessageType type) { type_ = type; } -void Message::set_binary_data(BinaryData* data) { - if (NULL == data) { - NOTREACHED(); - return; - } - - if (binary_data_) { - delete binary_data_; - } - - binary_data_ = new BinaryData(*data); -} - void Message::set_binary_data(const BinaryData* data) { if (NULL == data) { NOTREACHED(); diff --git a/src/components/application_manager/src/resumption/resumption_data_db.cc b/src/components/application_manager/src/resumption/resumption_data_db.cc index 2fe7330a9c..f75718af79 100644 --- a/src/components/application_manager/src/resumption/resumption_data_db.cc +++ b/src/components/application_manager/src/resumption/resumption_data_db.cc @@ -212,8 +212,6 @@ uint32_t ResumptionDataDB::GetHMIApplicationID( return hmi_app_id; } -DEPRECATED void ResumptionDataDB::OnSuspend() {} - void ResumptionDataDB::IncrementIgnOffCount() { LOG4CXX_AUTO_TRACE(logger_); @@ -293,8 +291,6 @@ bool ResumptionDataDB::GetHashId(const std::string& policy_app_id, return SelectHashId(policy_app_id, device_id, hash_id); } -DEPRECATED void ResumptionDataDB::OnAwake() {} - void ResumptionDataDB::DecrementIgnOffCount() { LOG4CXX_AUTO_TRACE(logger_); diff --git a/src/components/application_manager/src/resumption/resumption_data_json.cc b/src/components/application_manager/src/resumption/resumption_data_json.cc index b6a50fd5de..4bd5bc8d47 100644 --- a/src/components/application_manager/src/resumption/resumption_data_json.cc +++ b/src/components/application_manager/src/resumption/resumption_data_json.cc @@ -143,8 +143,6 @@ uint32_t ResumptionDataJson::GetHMIApplicationID( return hmi_app_id; } -DEPRECATED void ResumptionDataJson::OnSuspend() {} - void ResumptionDataJson::IncrementIgnOffCount() { using namespace app_mngr; LOG4CXX_AUTO_TRACE(logger_); @@ -169,8 +167,6 @@ void ResumptionDataJson::IncrementIgnOffCount() { LOG4CXX_DEBUG(logger_, GetResumptionData().toStyledString()); } -DEPRECATED void ResumptionDataJson::OnAwake() {} - void ResumptionDataJson::DecrementIgnOffCount() { using namespace app_mngr; LOG4CXX_AUTO_TRACE(logger_); diff --git a/src/components/application_manager/test/application_manager_impl_test.cc b/src/components/application_manager/test/application_manager_impl_test.cc index e368163cca..36cf890351 100644 --- a/src/components/application_manager/test/application_manager_impl_test.cc +++ b/src/components/application_manager/test/application_manager_impl_test.cc @@ -252,7 +252,8 @@ TEST_F( ApplicationManagerImplTest, IsAnyAppSubscribedForWayPoints_SubcribeAppForWayPoints_ExpectCorrectResult) { EXPECT_FALSE(app_manager_impl_->IsAnyAppSubscribedForWayPoints()); - app_manager_impl_->SubscribeAppForWayPoints(app_id_); + auto app_ptr = std::static_pointer_cast(mock_app_ptr_); + app_manager_impl_->SubscribeAppForWayPoints(app_ptr); EXPECT_TRUE(app_manager_impl_->IsAnyAppSubscribedForWayPoints()); } diff --git a/src/components/application_manager/test/include/application_manager/mock_application.h b/src/components/application_manager/test/include/application_manager/mock_application.h index ef27797e29..d7552060ff 100644 --- a/src/components/application_manager/test/include/application_manager/mock_application.h +++ b/src/components/application_manager/test/include/application_manager/mock_application.h @@ -51,9 +51,6 @@ class MockApplication : public ::application_manager::Application { MOCK_CONST_METHOD0(active_message, const smart_objects::SmartObject*()); MOCK_CONST_METHOD0(curHash, const std::string&()); MOCK_METHOD0(UpdateHash, void()); - DEPRECATED MOCK_CONST_METHOD0(flag_sending_hash_change_after_awake, bool()); - DEPRECATED MOCK_METHOD1(set_flag_sending_hash_change_after_awake, - void(bool flag)); MOCK_CONST_METHOD0(IsHashChangedDuringSuspend, bool()); MOCK_METHOD1(SetHashChangedDuringSuspend, void(const bool flag)); MOCK_CONST_METHOD0(is_application_data_changed, bool()); diff --git a/src/components/config_profile/include/config_profile/profile.h b/src/components/config_profile/include/config_profile/profile.h index 4c2be53228..81e38504d7 100644 --- a/src/components/config_profile/include/config_profile/profile.h +++ b/src/components/config_profile/include/config_profile/profile.h @@ -109,12 +109,6 @@ class Profile : public protocol_handler::ProtocolHandlerSettings, */ const std::string& app_resource_folder() const; - /** - * @brief Returns true, if SDL 4.0 is enabled - * @deprecated use max_supported_protocol_version instead - */ - DEPRECATED bool enable_protocol_4() const OVERRIDE; - /** * @brief Returns application icons folder path */ diff --git a/src/components/config_profile/src/profile.cc b/src/components/config_profile/src/profile.cc index 3f3ec7eb63..cdb9d543f0 100644 --- a/src/components/config_profile/src/profile.cc +++ b/src/components/config_profile/src/profile.cc @@ -530,10 +530,6 @@ const std::string& Profile::app_resource_folder() const { return app_resource_folder_; } -bool Profile::enable_protocol_4() const { - return max_supported_protocol_version_ >= 4; -} - const std::string& Profile::app_icons_folder() const { return app_icons_folder_; } diff --git a/src/components/connection_handler/include/connection_handler/connection_handler_impl.h b/src/components/connection_handler/include/connection_handler/connection_handler_impl.h index 730d7ebe32..1ab70ce702 100644 --- a/src/components/connection_handler/include/connection_handler/connection_handler_impl.h +++ b/src/components/connection_handler/include/connection_handler/connection_handler_impl.h @@ -193,25 +193,6 @@ class ConnectionHandlerImpl const connection_handler::DeviceHandle& device, const transport_manager::DisconnectDeviceError& error) OVERRIDE; - /** - * \brief Callback function used by ProtocolHandler - * when Mobile Application initiates start of new session. - * \param connection_handle Connection identifier within which session has to - * be started. - * \param session_id Identifier of the session to be started - * \param service_type Type of service - * \param is_protected would be service protected - * \param hash_id pointer for session hash identifier - * \return uint32_t Id (number) of new session if successful, otherwise 0. - * \deprecated - */ - virtual uint32_t OnSessionStartedCallback( - const transport_manager::ConnectionUID connection_handle, - const uint8_t session_id, - const protocol_handler::ServiceType& service_type, - const bool is_protected, - uint32_t* hash_id); - /** * \brief Callback function used by ProtocolHandler * when Mobile Application initiates start of new session. @@ -230,22 +211,7 @@ class ConnectionHandlerImpl const protocol_handler::ServiceType& service_type, const bool is_protected, const BsonObject* params); - /** - * \brief Callback function used by ProtocolHandler - * when Mobile Application initiates session ending. - * \param connection_handle Connection identifier within which session exists - * \param sessionId Identifier of the session to be ended - * \param hashCode Hash used only in second version of SmartDeviceLink - * protocol. - * If not equal to hash assigned to session on start then operation fails. - * \return uint32_t 0 if operation fails, session key otherwise - * \deprecated - */ - uint32_t OnSessionEndedCallback( - const transport_manager::ConnectionUID connection_handle, - const uint8_t session_id, - const uint32_t& hashCode, - const protocol_handler::ServiceType& service_type) OVERRIDE; + /** * \brief Callback function used by ProtocolHandler * when Mobile Application initiates session ending. diff --git a/src/components/connection_handler/src/connection_handler_impl.cc b/src/components/connection_handler/src/connection_handler_impl.cc index 9aa84989d9..045985f650 100644 --- a/src/components/connection_handler/src/connection_handler_impl.cc +++ b/src/components/connection_handler/src/connection_handler_impl.cc @@ -338,77 +338,6 @@ bool AllowProtection(const ConnectionHandlerSettings& settings, } #endif // ENABLE_SECURITY -uint32_t ConnectionHandlerImpl::OnSessionStartedCallback( - const transport_manager::ConnectionUID connection_handle, - const uint8_t session_id, - const protocol_handler::ServiceType& service_type, - const bool is_protected, - uint32_t* hash_id) { - LOG4CXX_AUTO_TRACE(logger_); - - if (hash_id) { - *hash_id = protocol_handler::HASH_ID_WRONG; - } - -#ifdef ENABLE_SECURITY - if (!AllowProtection(get_settings(), service_type, is_protected)) { - return 0; - } -#endif // ENABLE_SECURITY - sync_primitives::AutoReadLock lock(connection_list_lock_); - ConnectionList::iterator it = connection_list_.find(connection_handle); - if (connection_list_.end() == it) { - LOG4CXX_ERROR(logger_, "Unknown connection!"); - return 0; - } - uint32_t new_session_id = 0; - - Connection* connection = it->second; - if ((0 == session_id) && (protocol_handler::kRpc == service_type)) { - new_session_id = connection->AddNewSession(connection_handle); - if (0 == new_session_id) { - LOG4CXX_ERROR(logger_, "Couldn't start new session!"); - return 0; - } - if (hash_id) { - *hash_id = KeyFromPair(connection_handle, new_session_id); - } - } else { // Could be create new service or protected exists one - if (!connection->AddNewService( - session_id, service_type, is_protected, connection_handle)) { - LOG4CXX_ERROR(logger_, - "Couldn't establish " -#ifdef ENABLE_SECURITY - << (is_protected ? "protected" : "non-protected") -#endif // ENABLE_SECURITY - << " service " << static_cast(service_type) - << " for session " << static_cast(session_id)); - return 0; - } - new_session_id = session_id; - if (hash_id) { - *hash_id = protocol_handler::HASH_ID_NOT_SUPPORTED; - } - } - sync_primitives::AutoReadLock read_lock(connection_handler_observer_lock_); - if (connection_handler_observer_) { - const uint32_t session_key = KeyFromPair(connection_handle, new_session_id); - const bool success = connection_handler_observer_->OnServiceStartedCallback( - connection->connection_device_handle(), session_key, service_type); - if (!success) { - LOG4CXX_WARN(logger_, - "Service starting forbidden by connection_handler_observer"); - if (protocol_handler::kRpc == service_type) { - connection->RemoveSession(new_session_id); - } else { - connection->RemoveService(session_id, service_type); - } - return 0; - } - } - return new_session_id; -} - void ConnectionHandlerImpl::OnSessionStartedCallback( const transport_manager::ConnectionUID connection_handle, const uint8_t session_id, @@ -640,16 +569,6 @@ void ConnectionHandlerImpl::OnMalformedMessageCallback( CloseConnection(connection_handle); } -uint32_t ConnectionHandlerImpl::OnSessionEndedCallback( - const transport_manager::ConnectionUID connection_handle, - const uint8_t session_id, - const uint32_t& hashCode, - const protocol_handler::ServiceType& service_type) { - uint32_t hashValue = hashCode; - return OnSessionEndedCallback( - connection_handle, session_id, &hashValue, service_type); -} - uint32_t ConnectionHandlerImpl::OnSessionEndedCallback( const transport_manager::ConnectionUID connection_handle, const uint8_t session_id, diff --git a/src/components/include/application_manager/application_manager.h b/src/components/include/application_manager/application_manager.h index 8397fbf790..5858178fd8 100644 --- a/src/components/include/application_manager/application_manager.h +++ b/src/components/include/application_manager/application_manager.h @@ -282,29 +282,6 @@ class ApplicationManager { */ virtual void SendDriverDistractionState(ApplicationSharedPtr application) = 0; - /** - * DEPRECATED - * @brief Checks if Application is subscribed for way points - * @param Application AppID - * @return true if Application is subscribed for way points - * otherwise false - */ - virtual bool IsAppSubscribedForWayPoints(const uint32_t app_id) const = 0; - - /** - * DEPRECATED - * @brief Subscribe Application for way points - * @param Application AppID - */ - virtual void SubscribeAppForWayPoints(const uint32_t app_id) = 0; - - /** - * DEPRECATED - * @brief Unsubscribe Application for way points - * @param Application AppID - */ - virtual void UnsubscribeAppFromWayPoints(const uint32_t app_id) = 0; - /** * @brief Checks if Application is subscribed for way points * @param Application pointer @@ -424,13 +401,6 @@ class ApplicationManager { */ virtual void EndNaviServices(uint32_t app_id) = 0; - /* @brief Starts audio passthru process - * @deprecated Use BeginAudioPassThru(uint32_t app_id) instead - * - * @return true on success, false if passthru is already in process - */ - DEPRECATED virtual bool BeginAudioPassThrough() = 0; - /** * @brief Starts AudioPassThru process by given application * @param app_id ID of the application which starts the process @@ -438,14 +408,6 @@ class ApplicationManager { */ virtual bool BeginAudioPassThru(uint32_t app_id) = 0; - /* - * @brief Finishes already started audio passthru process - * @deprecated Use EndAudioPassThru(uint32_t app_id) instead - * - * @return true on success, false if passthru is not active - */ - DEPRECATED virtual bool EndAudioPassThrough() = 0; - /** * @brief Finishes already started AudioPassThru process by given application * @param app_id ID of the application which started the process @@ -715,21 +677,6 @@ class ApplicationManager { mobile_apis::VideoStreamingState::eType video_state, mobile_apis::SystemContext::eType system_context) const = 0; - /** - * DEPRECATED - * @brief CreateRegularState create regular HMI state for application - * @param app_id Application id - * @param hmi_level of returned state - * @param audio_state of returned state - * @param system_context of returned state - * @return new regular HMI state - */ - virtual HmiStatePtr CreateRegularState( - uint32_t app_id, - mobile_apis::HMILevel::eType hmi_level, - mobile_apis::AudioStreamingState::eType audio_state, - mobile_apis::SystemContext::eType system_context) const = 0; - /** * @brief Checks if application can stream (streaming service is started and * streaming is enabled in application) diff --git a/src/components/include/connection_handler/connection_handler_observer.h b/src/components/include/connection_handler/connection_handler_observer.h index 2f4ee94449..154a2a8e34 100644 --- a/src/components/include/connection_handler/connection_handler_observer.h +++ b/src/components/include/connection_handler/connection_handler_observer.h @@ -83,19 +83,6 @@ class ConnectionHandlerObserver { virtual void RemoveDevice( const connection_handler::DeviceHandle& device_handle) = 0; - /** - * \brief Callback function used by connection_handler - * when Mobile Application initiates start of new service. - * \param deviceHandle Device identifier within which session has to be - * started. - * \param sessionKey Key of started session. - * \param type Established service type - */ - virtual bool OnServiceStartedCallback( - const connection_handler::DeviceHandle& device_handle, - const int32_t& session_key, - const protocol_handler::ServiceType& type) = 0; - /** * \brief Callback function used by connection_handler * when Mobile Application initiates start of new service. diff --git a/src/components/include/policy/policy_external/policy/policy_listener.h b/src/components/include/policy/policy_external/policy/policy_listener.h index c023f3c7fc..c446c87d1b 100644 --- a/src/components/include/policy/policy_external/policy/policy_listener.h +++ b/src/components/include/policy/policy_external/policy/policy_listener.h @@ -52,13 +52,6 @@ class PolicyListener { const Permissions& permissions) = 0; virtual void OnPendingPermissionChange(const std::string& policy_app_id) = 0; virtual void OnUpdateStatusChanged(const std::string&) = 0; - - /** - * Gets device ID - * @param policy_app_id - * @return device ID - * @deprecated see std::vector GetDevicesIds(const std::string&) - */ virtual std::string OnCurrentDeviceIdUpdateRequired( const std::string& policy_app_id) = 0; virtual void OnSystemInfoUpdateRequired() = 0; diff --git a/src/components/include/protocol_handler/protocol_handler.h b/src/components/include/protocol_handler/protocol_handler.h index bb79964b12..d65902030b 100644 --- a/src/components/include/protocol_handler/protocol_handler.h +++ b/src/components/include/protocol_handler/protocol_handler.h @@ -124,27 +124,6 @@ class ProtocolHandler { virtual const ProtocolHandlerSettings& get_settings() const = 0; virtual SessionObserver& get_session_observer() = 0; - /** - * \brief Called by connection handler to notify the result of - * OnSessionStartedCallback(). - * \param connection_id Identifier of connection within which session exists - * \param session_id session ID passed to OnSessionStartedCallback() - * \param generated_session_id Generated session ID, will be 0 if session is - * not started - * \param hash_id Generated Hash ID - * \param protection whether the service will be protected - * \param rejected_params list of parameters' name that are rejected. - * Only valid when generated_session_id is 0. Note, even if - * generated_session_id is 0, the list may be empty. - */ - DEPRECATED virtual void NotifySessionStartedResult( - int32_t connection_id, - uint8_t session_id, - uint8_t generated_session_id, - uint32_t hash_id, - bool protection, - std::vector& rejected_params) = 0; - /** * @brief Called by connection handler to notify the context of * OnSessionStartedCallback(). diff --git a/src/components/include/protocol_handler/protocol_handler_settings.h b/src/components/include/protocol_handler/protocol_handler_settings.h index c4f9bb6420..62a24df32c 100644 --- a/src/components/include/protocol_handler/protocol_handler_settings.h +++ b/src/components/include/protocol_handler/protocol_handler_settings.h @@ -34,12 +34,6 @@ class ProtocolHandlerSettings { */ virtual uint16_t max_supported_protocol_version() const = 0; - /* - * @brief Returns true, if SDL 4.0 is enabled - * @deprecated Use max_supported_protocol_version instead - */ - DEPRECATED virtual bool enable_protocol_4() const = 0; - virtual uint32_t multiframe_waiting_timeout() const = 0; #ifdef ENABLE_SECURITY /** diff --git a/src/components/include/protocol_handler/session_observer.h b/src/components/include/protocol_handler/session_observer.h index d50b1e694e..e71557fecf 100644 --- a/src/components/include/protocol_handler/session_observer.h +++ b/src/components/include/protocol_handler/session_observer.h @@ -122,26 +122,6 @@ struct SessionContext { // TODO(EZamakhov): Reconsider rename KeyFromPair and PairFromKey class SessionObserver { public: - /** - * \brief Callback function used by ProtocolHandler - * when Mobile Application initiates start of new session. - * \param connection_handle Connection identifier within which session - * has to be started. - * \param sessionId Identifier of the session to be start - * \param service_type Type of service - * \param protocol_version Version of protocol - * \param is_protected would be service protected - * \param hash_id pointer for session hash identifier, uint32_t* hash_id - * \return uint32_t Id (number) of new session if successful, otherwise 0. - * \deprecated - */ - DEPRECATED virtual uint32_t OnSessionStartedCallback( - const transport_manager::ConnectionUID connection_handle, - const uint8_t sessionId, - const protocol_handler::ServiceType& service_type, - const bool is_protected, - uint32_t* hash_id) = 0; - /** * \brief Callback function used by ProtocolHandler * when Mobile Application initiates start of new session. @@ -161,24 +141,6 @@ class SessionObserver { const bool is_protected, const BsonObject* params) = 0; - /** - * \brief Callback function used by ProtocolHandler - * when Mobile Application initiates session ending. - * \param connection_handle Connection identifier within which session exists - * \param sessionId Identifier of the session to be ended - * \param hashCode Hash used only in second version of SmartDeviceLink - * protocol. - * If not equal to hash assigned to session on start then operation fails. - * \param service_type Type of service - * \return uint32_t 0 if operation fails, session key otherwise - * \deprecated - */ - DEPRECATED virtual uint32_t OnSessionEndedCallback( - const transport_manager::ConnectionUID connection_handle, - const uint8_t sessionId, - const uint32_t& hashCode, - const protocol_handler::ServiceType& service_type) = 0; - /** * \brief Callback function used by ProtocolHandler * when Mobile Application initiates session ending. 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 5900b760a6..37e38e3ed7 100644 --- a/src/components/include/test/application_manager/mock_application_manager.h +++ b/src/components/include/test/application_manager/mock_application_manager.h @@ -160,9 +160,7 @@ class MockApplicationManager : public application_manager::ApplicationManager { MOCK_METHOD0(GetNextHMICorrelationID, uint32_t()); MOCK_METHOD0(GenerateNewHMIAppID, uint32_t()); MOCK_METHOD1(EndNaviServices, void(uint32_t app_id)); - DEPRECATED MOCK_METHOD0(BeginAudioPassThrough, bool()); MOCK_METHOD1(BeginAudioPassThru, bool(uint32_t app_id)); - DEPRECATED MOCK_METHOD0(EndAudioPassThrough, bool()); MOCK_METHOD1(EndAudioPassThru, bool(uint32_t app_id)); MOCK_METHOD1(ConnectToDevice, void(const std::string& device_mac)); MOCK_METHOD0(OnHMIStartedCooperation, void()); @@ -256,13 +254,6 @@ class MockApplicationManager : public application_manager::ApplicationManager { mobile_apis::AudioStreamingState::eType audio_state, mobile_apis::VideoStreamingState::eType video_state, mobile_apis::SystemContext::eType system_context)); - DEPRECATED MOCK_CONST_METHOD4( - CreateRegularState, - application_manager::HmiStatePtr( - uint32_t app_id, - mobile_apis::HMILevel::eType hmi_level, - mobile_apis::AudioStreamingState::eType audio_state, - mobile_apis::SystemContext::eType system_context)); MOCK_METHOD2(SendAudioPassThroughNotification, void(uint32_t session_key, std::vector& binary_data)); @@ -278,11 +269,6 @@ class MockApplicationManager : public application_manager::ApplicationManager { MOCK_METHOD2(IsSOStructValid, bool(const hmi_apis::StructIdentifiers::eType struct_id, const smart_objects::SmartObject& display_capabilities)); - - DEPRECATED MOCK_CONST_METHOD1(IsAppSubscribedForWayPoints, - bool(const uint32_t)); - DEPRECATED MOCK_METHOD1(SubscribeAppForWayPoints, void(const uint32_t)); - DEPRECATED MOCK_METHOD1(UnsubscribeAppFromWayPoints, void(const uint32_t)); MOCK_CONST_METHOD1(IsAppSubscribedForWayPoints, bool(application_manager::ApplicationSharedPtr)); MOCK_METHOD1(SubscribeAppForWayPoints, diff --git a/src/components/include/test/connection_handler/mock_connection_handler_observer.h b/src/components/include/test/connection_handler/mock_connection_handler_observer.h index ede08a9a4a..a9e4349bec 100644 --- a/src/components/include/test/connection_handler/mock_connection_handler_observer.h +++ b/src/components/include/test/connection_handler/mock_connection_handler_observer.h @@ -48,11 +48,6 @@ class MockConnectionHandlerObserver MOCK_METHOD0(OnFindNewApplicationsRequest, void()); MOCK_METHOD1(RemoveDevice, void(const connection_handler::DeviceHandle& device_handle)); - DEPRECATED MOCK_METHOD3( - OnServiceStartedCallback, - bool(const connection_handler::DeviceHandle& device_handle, - const int32_t& session_key, - const protocol_handler::ServiceType& type)); MOCK_METHOD4(OnServiceStartedCallback, void(const connection_handler::DeviceHandle& device_handle, const int32_t& session_key, diff --git a/src/components/include/test/protocol_handler/mock_protocol_handler.h b/src/components/include/test/protocol_handler/mock_protocol_handler.h index 13c0264cb8..f6db0c7097 100644 --- a/src/components/include/test/protocol_handler/mock_protocol_handler.h +++ b/src/components/include/test/protocol_handler/mock_protocol_handler.h @@ -63,13 +63,6 @@ class MockProtocolHandler : public ::protocol_handler::ProtocolHandler { MOCK_CONST_METHOD0(get_settings, const ::protocol_handler::ProtocolHandlerSettings&()); MOCK_METHOD0(get_session_observer, protocol_handler::SessionObserver&()); - DEPRECATED MOCK_METHOD6(NotifySessionStartedResult, - void(int32_t connection_id, - uint8_t session_id, - uint8_t generated_session_id, - uint32_t hash_id, - bool protection, - std::vector& rejected_params)); MOCK_METHOD2(NotifySessionStarted, void(const ::protocol_handler::SessionContext& context, std::vector& rejected_params)); diff --git a/src/components/include/test/protocol_handler/mock_session_observer.h b/src/components/include/test/protocol_handler/mock_session_observer.h index c0612ce137..0d74b15f64 100644 --- a/src/components/include/test/protocol_handler/mock_session_observer.h +++ b/src/components/include/test/protocol_handler/mock_session_observer.h @@ -47,13 +47,6 @@ namespace protocol_handler_test { */ class MockSessionObserver : public ::protocol_handler::SessionObserver { public: - DEPRECATED MOCK_METHOD5( - OnSessionStartedCallback, - uint32_t(const transport_manager::ConnectionUID connection_handle, - const uint8_t sessionId, - const protocol_handler::ServiceType& service_type, - const bool is_protected, - uint32_t* hash_id)); MOCK_METHOD5(OnSessionStartedCallback, void(const transport_manager::ConnectionUID connection_handle, const uint8_t sessionId, diff --git a/src/components/include/transport_manager/transport_adapter/transport_adapter.h b/src/components/include/transport_manager/transport_adapter/transport_adapter.h index 8bba7ade8b..e63469190c 100644 --- a/src/components/include/transport_manager/transport_adapter/transport_adapter.h +++ b/src/components/include/transport_manager/transport_adapter/transport_adapter.h @@ -60,14 +60,10 @@ class TransportAdapterListener; /** * @brief The DeviceType enum defines types based on available transport * adapters - * @deprecated PASA_AOA, PASA_BLUETOOTH, MME */ enum DeviceType { AOA, - PASA_AOA, BLUETOOTH, - PASA_BLUETOOTH, - MME, IOS_BT, IOS_USB, TCP, diff --git a/src/components/include/transport_manager/transport_adapter/transport_adapter_event.h b/src/components/include/transport_manager/transport_adapter/transport_adapter_event.h index 5d55960943..7a001a85cc 100644 --- a/src/components/include/transport_manager/transport_adapter/transport_adapter_event.h +++ b/src/components/include/transport_manager/transport_adapter/transport_adapter_event.h @@ -90,30 +90,6 @@ class TransportAdapterEvent { , event_data(data) , event_error(error) {} - /** - * DEPRECATED - * @brief Constructor. - * - * @param type Event type. - * @param transport_adapter Transport adapter - * @param device_handle Handle of device. - * @param application_id Handle of application. - * @param data Smart pointer to the raw message. - * @param error Error class that contains details of this error situation. - */ - TransportAdapterEvent(int type, - transport_adapter::TransportAdapter* adapter, - const DeviceUID& device_handle, - const ApplicationHandle& application_id, - ::protocol_handler::RawMessagePtr data, - BaseErrorPtr error) - : event_type(static_cast(type)) - , application_id(application_id) - , device_uid(device_handle) - , transport_adapter(adapter) - , event_data(data) - , event_error(error) {} - /** * @brief Value that describe event type. */ diff --git a/src/components/protocol_handler/include/protocol_handler/handshake_handler.h b/src/components/protocol_handler/include/protocol_handler/handshake_handler.h index be81493e7a..cb52c9d375 100644 --- a/src/components/protocol_handler/include/protocol_handler/handshake_handler.h +++ b/src/components/protocol_handler/include/protocol_handler/handshake_handler.h @@ -52,19 +52,6 @@ class ProtocolHandlerImpl; */ class HandshakeHandler : public security_manager::SecurityManagerListener { public: - DEPRECATED HandshakeHandler(ProtocolHandlerImpl& protocol_handler, - SessionObserver& session_observer, - uint32_t connection_key, - ConnectionID connection_id, - uint8_t session_id, - uint8_t protocol_version, - uint32_t hash_id, - ServiceType service_type, - const std::vector& force_protected_service, - const bool is_new_service, - utils::SemanticVersion& full_version, - std::shared_ptr payload); - HandshakeHandler(ProtocolHandlerImpl& protocol_handler, SessionObserver& session_observer, utils::SemanticVersion& full_version, diff --git a/src/components/protocol_handler/include/protocol_handler/protocol_handler_impl.h b/src/components/protocol_handler/include/protocol_handler/protocol_handler_impl.h index e763be8c1b..3e7d64e9d2 100644 --- a/src/components/protocol_handler/include/protocol_handler/protocol_handler_impl.h +++ b/src/components/protocol_handler/include/protocol_handler/protocol_handler_impl.h @@ -417,27 +417,6 @@ class ProtocolHandlerImpl SessionObserver& get_session_observer() OVERRIDE; - /** - * \brief Called by connection handler to notify the result of - * OnSessionStartedCallback(). - * \param connection_id Identifier of connection within which session exists - * \param session_id session ID passed to OnSessionStartedCallback() - * \param generated_session_id Generated session ID, will be 0 if session is - * not started - * \param hash_id Generated Hash ID - * \param protection whether the service will be protected - * \param rejected_params list of parameters' name that are rejected. - * Only valid when generated_session_id is 0. Note, even if - * generated_session_id is 0, the list may be empty. - */ - DEPRECATED void NotifySessionStartedResult( - int32_t connection_id, - uint8_t session_id, - uint8_t generated_session_id, - uint32_t hash_id, - bool protection, - std::vector& rejected_params) OVERRIDE; - /** * @brief Called by connection handler to notify the result of * OnSessionStartedCallback(). @@ -649,9 +628,6 @@ class ProtocolHandlerImpl RESULT_CODE HandleControlMessageEndServiceACK(const ProtocolPacket& packet); - DEPRECATED RESULT_CODE - HandleControlMessageStartSession(const ProtocolPacket& packet); - RESULT_CODE HandleControlMessageStartSession(const ProtocolFramePtr packet); RESULT_CODE HandleControlMessageRegisterSecondaryTransport( diff --git a/src/components/protocol_handler/src/handshake_handler.cc b/src/components/protocol_handler/src/handshake_handler.cc index f6ab08319e..775d77db66 100644 --- a/src/components/protocol_handler/src/handshake_handler.cc +++ b/src/components/protocol_handler/src/handshake_handler.cc @@ -43,26 +43,6 @@ namespace protocol_handler { CREATE_LOGGERPTR_GLOBAL(logger_, "ProtocolHandler") -HandshakeHandler::HandshakeHandler( - ProtocolHandlerImpl& protocol_handler, - SessionObserver& session_observer, - uint32_t connection_key, - ConnectionID connection_id, - uint8_t session_id, - uint8_t protocol_version, - uint32_t hash_id, - ServiceType service_type, - const std::vector& force_protected_service, - const bool is_new_service, - utils::SemanticVersion& full_version, - std::shared_ptr payload) - : protocol_handler_(protocol_handler) - , session_observer_(session_observer) - , context_() - , full_version_(full_version) - , protocol_version_(protocol_version) - , payload_(payload) {} - HandshakeHandler::HandshakeHandler(ProtocolHandlerImpl& protocol_handler, SessionObserver& session_observer, utils::SemanticVersion& full_version, diff --git a/src/components/protocol_handler/src/protocol_handler_impl.cc b/src/components/protocol_handler/src/protocol_handler_impl.cc index 0e49e28397..7dcf4d97f7 100644 --- a/src/components/protocol_handler/src/protocol_handler_impl.cc +++ b/src/components/protocol_handler/src/protocol_handler_impl.cc @@ -1546,166 +1546,6 @@ RESULT_CODE ProtocolHandlerImpl::HandleControlMessageEndServiceACK( return RESULT_OK; } -// Suppress warning for deprecated method used within another deprecated method -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wdeprecated-declarations" -RESULT_CODE ProtocolHandlerImpl::HandleControlMessageStartSession( - const ProtocolPacket& packet) { - LOG4CXX_AUTO_TRACE(logger_); - LOG4CXX_DEBUG( - logger_, - "Protocol version:" << static_cast(packet.protocol_version())); - const ServiceType service_type = ServiceTypeFromByte(packet.service_type()); - -#ifdef ENABLE_SECURITY - const bool protection = - // Protocol version 1 is not support protection - (packet.protocol_version() > PROTOCOL_VERSION_1) - ? packet.protection_flag() - : false; -#else - const bool protection = false; -#endif // ENABLE_SECURITY - - uint32_t hash_id; - const ConnectionID connection_id = packet.connection_id(); - const uint32_t session_id = session_observer_.OnSessionStartedCallback( - connection_id, packet.session_id(), service_type, protection, &hash_id); - - if (0 == session_id) { - LOG4CXX_WARN(logger_, - "Refused by session_observer to create service " - << static_cast(service_type) << " type."); - SendStartSessionNAck(connection_id, - packet.session_id(), - packet.protocol_version(), - packet.service_type()); - return RESULT_OK; - } - -#ifdef ENABLE_SECURITY - // for packet is encrypted and security plugin is enable - if (protection && security_manager_) { - const uint32_t connection_key = - session_observer_.KeyFromPair(connection_id, session_id); - - security_manager::SSLContext* ssl_context = - security_manager_->CreateSSLContext( - connection_key, security_manager::SecurityManager::kUseExisting); - if (!ssl_context) { - const std::string error("CreateSSLContext failed"); - LOG4CXX_ERROR(logger_, error); - security_manager_->SendInternalError( - connection_key, - security_manager::SecurityManager::ERROR_INTERNAL, - error); - // Start service without protection - SendStartSessionAck(connection_id, - session_id, - packet.protocol_version(), - hash_id, - packet.service_type(), - PROTECTION_OFF); - return RESULT_OK; - } - utils::SemanticVersion* fullVersion; - std::vector rejectedParams(0, std::string("")); - // Can't check protocol_version because the first packet is v1, but there - // could still be a payload, in which case we can get the real protocol - // version - if (packet.service_type() == kRpc && packet.data_size() != 0) { - BsonObject obj = bson_object_from_bytes(packet.data()); - fullVersion = new utils::SemanticVersion( - std::string(bson_object_get_string(&obj, "protocolVersion"))); - bson_object_deinitialize(&obj); - // Constructed payloads added in Protocol v5 - if (fullVersion->major_version_ < PROTOCOL_VERSION_5) { - rejectedParams.push_back(std::string("protocolVersion")); - } - } else { - fullVersion = new utils::SemanticVersion(); - } - if (!rejectedParams.empty()) { - SendStartSessionNAck(connection_id, - packet.session_id(), - packet.protocol_version(), - packet.service_type(), - rejectedParams); - } else if (ssl_context->IsInitCompleted()) { - // mark service as protected - session_observer_.SetProtectionFlag(connection_key, service_type); - // Start service as protected with current SSLContext - SendStartSessionAck(connection_id, - session_id, - packet.protocol_version(), - hash_id, - packet.service_type(), - PROTECTION_ON, - *fullVersion); - } else { - security_manager_->AddListener( - new HandshakeHandler(*this, - session_observer_, - connection_key, - connection_id, - session_id, - packet.protocol_version(), - hash_id, - service_type, - get_settings().force_protected_service(), - false, - *fullVersion, - NULL)); - if (!ssl_context->IsHandshakePending()) { - // Start handshake process - security_manager_->StartHandshake(connection_key); - } - } - delete fullVersion; - LOG4CXX_DEBUG(logger_, - "Protection establishing for connection " - << connection_key << " is in progress"); - return RESULT_OK; - } -#endif // ENABLE_SECURITY - if (packet.service_type() == kRpc && packet.data_size() != 0) { - BsonObject obj = bson_object_from_bytes(packet.data()); - utils::SemanticVersion fullVersion( - bson_object_get_string(&obj, "protocolVersion")); - bson_object_deinitialize(&obj); - - if (fullVersion.major_version_ >= PROTOCOL_VERSION_5) { - // Start service without protection - SendStartSessionAck(connection_id, - session_id, - packet.protocol_version(), - hash_id, - packet.service_type(), - PROTECTION_OFF, - fullVersion); - } else { - std::vector rejectedParams(1, - std::string("protocolVersion")); - SendStartSessionNAck(connection_id, - packet.session_id(), - packet.protocol_version(), - packet.service_type(), - rejectedParams); - } - - } else { - // Start service without protection - SendStartSessionAck(connection_id, - session_id, - packet.protocol_version(), - hash_id, - packet.service_type(), - PROTECTION_OFF); - } - return RESULT_OK; -} -#pragma GCC diagnostic pop - RESULT_CODE ProtocolHandlerImpl::HandleControlMessageStartSession( const ProtocolFramePtr packet) { LOG4CXX_AUTO_TRACE(logger_); @@ -1795,24 +1635,6 @@ RESULT_CODE ProtocolHandlerImpl::HandleControlMessageRegisterSecondaryTransport( return RESULT_OK; } -void ProtocolHandlerImpl::NotifySessionStartedResult( - int32_t connection_id, - uint8_t session_id, - uint8_t generated_session_id, - uint32_t hash_id, - bool protection, - std::vector& rejected_params) { - LOG4CXX_AUTO_TRACE(logger_); - protocol_handler::SessionContext context(connection_id, - connection_id, - session_id, - generated_session_id, - ServiceType::kInvalidServiceType, - hash_id, - protection); - NotifySessionStarted(context, rejected_params); -} - void ProtocolHandlerImpl::NotifySessionStarted( const SessionContext& context, std::vector& rejected_params) { LOG4CXX_AUTO_TRACE(logger_); diff --git a/src/components/security_manager/include/security_manager/security_manager_impl.h b/src/components/security_manager/include/security_manager/security_manager_impl.h index 70b87de0ef..c53d39ba87 100644 --- a/src/components/security_manager/include/security_manager/security_manager_impl.h +++ b/src/components/security_manager/include/security_manager/security_manager_impl.h @@ -191,12 +191,6 @@ class SecurityManagerImpl : public SecurityManager, void NotifyListenersOnHandshakeDone(const uint32_t& connection_key, SSLContext::HandshakeResult error); - /** - * @brief Notifiers for listeners. - * Allows to notify that certificate should be updated - */ - DEPRECATED void NotifyOnCertififcateUpdateRequired(); - /** * @brief Notifiers for listeners. * Allows to notify that certificate should be updated diff --git a/src/components/security_manager/src/security_manager_impl.cc b/src/components/security_manager/src/security_manager_impl.cc index c5d14406a9..70f835fb93 100644 --- a/src/components/security_manager/src/security_manager_impl.cc +++ b/src/components/security_manager/src/security_manager_impl.cc @@ -403,10 +403,6 @@ void SecurityManagerImpl::NotifyListenersOnHandshakeDone( } } -void SecurityManagerImpl::NotifyOnCertififcateUpdateRequired() { - NotifyOnCertificateUpdateRequired(); -} - void SecurityManagerImpl::NotifyOnCertificateUpdateRequired() { LOG4CXX_AUTO_TRACE(logger_); std::list::iterator it = listeners_.begin(); diff --git a/src/components/smart_objects/include/smart_objects/always_false_schema_item.h b/src/components/smart_objects/include/smart_objects/always_false_schema_item.h index a7b93012bb..a6cd1cb4ed 100644 --- a/src/components/smart_objects/include/smart_objects/always_false_schema_item.h +++ b/src/components/smart_objects/include/smart_objects/always_false_schema_item.h @@ -47,13 +47,6 @@ class CAlwaysFalseSchemaItem : public ISchemaItem { * @return Shared pointer to a new schema item. **/ static std::shared_ptr create(); - /** - * @deprecated - * @brief Validate smart object. - * @param Object Object to validate. - * @return Errors::ERROR - **/ - Errors::eType validate(const SmartObject& Object) OVERRIDE; /** * @brief Validate smart object. diff --git a/src/components/smart_objects/include/smart_objects/always_true_schema_item.h b/src/components/smart_objects/include/smart_objects/always_true_schema_item.h index b025723ea6..5651cffc9e 100644 --- a/src/components/smart_objects/include/smart_objects/always_true_schema_item.h +++ b/src/components/smart_objects/include/smart_objects/always_true_schema_item.h @@ -47,13 +47,6 @@ class CAlwaysTrueSchemaItem : public ISchemaItem { * @return Shared pointer to a new schema item. **/ static std::shared_ptr create(); - /** - * @deprecated - * @brief Validate smart object. - * @param Object Object to validate. - * @return NsSmartObjects::Errors::eType - **/ - Errors::eType validate(const SmartObject& Object) OVERRIDE; /** * @brief Validate smart object. diff --git a/src/components/smart_objects/include/smart_objects/array_schema_item.h b/src/components/smart_objects/include/smart_objects/array_schema_item.h index 4dc416007a..d92283ba76 100644 --- a/src/components/smart_objects/include/smart_objects/array_schema_item.h +++ b/src/components/smart_objects/include/smart_objects/array_schema_item.h @@ -63,17 +63,6 @@ class CArraySchemaItem : public ISchemaItem { const TSchemaItemParameter& MaxSize = TSchemaItemParameter()); - /** - * @deprecated - * - * @brief Validate smart object. - * - * @param Object Object to validate. - * - * @return NsSmartObjects::Errors::eType - **/ - Errors::eType validate(const SmartObject& Object) OVERRIDE; - /** * @brief Validate smart object. * @param Object Object to validate. diff --git a/src/components/smart_objects/include/smart_objects/default_shema_item.h b/src/components/smart_objects/include/smart_objects/default_shema_item.h index 7d5b33b1a6..2b0802ee7e 100644 --- a/src/components/smart_objects/include/smart_objects/default_shema_item.h +++ b/src/components/smart_objects/include/smart_objects/default_shema_item.h @@ -48,14 +48,6 @@ template class CDefaultSchemaItem : public ISchemaItem { public: typedef TSchemaItemParameter ParameterType; - /** - * @deprecated - * @brief Validate smart object. - * @param Object Object to validate. - * @return Errors::ERROR - **/ - Errors::eType validate(const SmartObject& Object) OVERRIDE; - /** * @brief Validate smart object. * @param Object Object to validate. @@ -109,12 +101,6 @@ template CDefaultSchemaItem::CDefaultSchemaItem(const ParameterType& DefaultValue) : mDefaultValue(DefaultValue) {} -template -Errors::eType CDefaultSchemaItem::validate(const SmartObject& Object) { - rpc::ValidationReport report("RPC"); - return validate(Object, &report); -} - template Errors::eType CDefaultSchemaItem::validate( const SmartObject& Object, diff --git a/src/components/smart_objects/include/smart_objects/enum_schema_item.h b/src/components/smart_objects/include/smart_objects/enum_schema_item.h index 41102933f3..52301656e1 100644 --- a/src/components/smart_objects/include/smart_objects/enum_schema_item.h +++ b/src/components/smart_objects/include/smart_objects/enum_schema_item.h @@ -102,13 +102,6 @@ class TEnumSchemaItem : public CDefaultSchemaItem { ElementSignatures, const TSchemaItemParameter& DefaultValue = TSchemaItemParameter()); - /** - * @deprecated - * @brief Validate smart object. - * @param Object Object to validate. - * @return NsSmartObjects::Errors::eType - **/ - Errors::eType validate(const SmartObject& Object) OVERRIDE; /** * @brief Validate smart object. @@ -285,12 +278,6 @@ TEnumSchemaItem::createWithSignatures( AllowedElements, DefaultValue, ElementSignatures)); } -template -Errors::eType TEnumSchemaItem::validate(const SmartObject& Object) { - rpc::ValidationReport report("RPC"); - return validate(Object, &report); -} - template const ElementSignature TEnumSchemaItem::getSignature( const std::vector& signatures, diff --git a/src/components/smart_objects/include/smart_objects/number_schema_item.h b/src/components/smart_objects/include/smart_objects/number_schema_item.h index 0f3246ef5f..dff3617246 100644 --- a/src/components/smart_objects/include/smart_objects/number_schema_item.h +++ b/src/components/smart_objects/include/smart_objects/number_schema_item.h @@ -65,14 +65,6 @@ class TNumberSchemaItem : public CDefaultSchemaItem { const TSchemaItemParameter& DefaultValue = TSchemaItemParameter()); - /** - * @deprecated - * @brief Validate smart object. - * @param Object Object to validate. - * @return Errors::ERROR - **/ - Errors::eType validate(const SmartObject& Object) OVERRIDE; - /** * @brief Validate smart object. * @param Object Object to validate. @@ -141,13 +133,6 @@ bool TNumberSchemaItem::isValidNumberType(SmartType type) { return false; } -template -Errors::eType TNumberSchemaItem::validate( - const SmartObject& Object) { - rpc::ValidationReport report("RPC"); - return validate(Object, &report); -} - template Errors::eType TNumberSchemaItem::validate( const SmartObject& Object, diff --git a/src/components/smart_objects/include/smart_objects/object_schema_item.h b/src/components/smart_objects/include/smart_objects/object_schema_item.h index 4785211694..ddb34ea518 100644 --- a/src/components/smart_objects/include/smart_objects/object_schema_item.h +++ b/src/components/smart_objects/include/smart_objects/object_schema_item.h @@ -103,13 +103,6 @@ class CObjectSchemaItem : public ISchemaItem { * @return Shared pointer to a new schema item. **/ static std::shared_ptr create(const Members& Members); - /** - * @deprecated - * @brief Validate smart object. - * @param Object Object to validate. - * @return NsSmartObjects::Errors::eType - **/ - Errors::eType validate(const SmartObject& Object) OVERRIDE; /** * @brief Validate smart object. diff --git a/src/components/smart_objects/include/smart_objects/schema_item.h b/src/components/smart_objects/include/smart_objects/schema_item.h index 2e951f7f9f..2670e4a340 100644 --- a/src/components/smart_objects/include/smart_objects/schema_item.h +++ b/src/components/smart_objects/include/smart_objects/schema_item.h @@ -51,17 +51,6 @@ class SmartObject; **/ class ISchemaItem { public: - /** - * @deprecated - * - * @brief Validate smart object. - * - * @param Object Object to validate. - * - * @return NsSmartObjects::Errors::eType - **/ - DEPRECATED virtual Errors::eType validate(const SmartObject& Object); - /** * @brief Validate smart object. * diff --git a/src/components/smart_objects/include/smart_objects/smart_object.h b/src/components/smart_objects/include/smart_objects/smart_object.h index d81e18569f..112f40b959 100644 --- a/src/components/smart_objects/include/smart_objects/smart_object.h +++ b/src/components/smart_objects/include/smart_objects/smart_object.h @@ -670,14 +670,6 @@ class SmartObject FINAL { **/ bool isValid() const; - /** - * @deprecated - * @brief Validates object according to attached schema. - * - * @return Result of validation. - */ - DEPRECATED Errors::eType validate(); - /** * @brief Validates object according to attached schema. * diff --git a/src/components/smart_objects/include/smart_objects/smart_schema.h b/src/components/smart_objects/include/smart_objects/smart_schema.h index d3fcc0e28d..80a85e1778 100644 --- a/src/components/smart_objects/include/smart_objects/smart_schema.h +++ b/src/components/smart_objects/include/smart_objects/smart_schema.h @@ -60,17 +60,6 @@ class CSmartSchema FINAL { */ explicit CSmartSchema(const ISchemaItemPtr SchemaItem); - /** - * @deprecated - * - * @brief Validate smart object. - * - * @param Object Object to validate. - * - * @return NsSmartObjects::Errors::eType - **/ - DEPRECATED Errors::eType validate(const SmartObject& Object) const; - /** * @brief Validate smart object. * diff --git a/src/components/smart_objects/include/smart_objects/string_schema_item.h b/src/components/smart_objects/include/smart_objects/string_schema_item.h index dcaad364b2..709cf7d568 100644 --- a/src/components/smart_objects/include/smart_objects/string_schema_item.h +++ b/src/components/smart_objects/include/smart_objects/string_schema_item.h @@ -59,13 +59,6 @@ class CStringSchemaItem : public CDefaultSchemaItem { TSchemaItemParameter(), const TSchemaItemParameter& DefaultValue = TSchemaItemParameter()); - /** - * @deprecated - * @brief Validate smart object. - * @param Object Object to validate. - * @return NsSmartObjects::Errors::eType - **/ - Errors::eType validate(const SmartObject& Object) OVERRIDE; /** * @brief Validate smart object. diff --git a/src/components/smart_objects/src/always_false_schema_item.cc b/src/components/smart_objects/src/always_false_schema_item.cc index db16640265..9975085b79 100644 --- a/src/components/smart_objects/src/always_false_schema_item.cc +++ b/src/components/smart_objects/src/always_false_schema_item.cc @@ -41,11 +41,6 @@ std::shared_ptr CAlwaysFalseSchemaItem::create() { return std::shared_ptr(new CAlwaysFalseSchemaItem()); } -Errors::eType CAlwaysFalseSchemaItem::validate(const SmartObject& object) { - rpc::ValidationReport report("RPC"); - return validate(object, &report); -} - Errors::eType CAlwaysFalseSchemaItem::validate( const SmartObject& Object, rpc::ValidationReport* report__, diff --git a/src/components/smart_objects/src/always_true_schema_item.cc b/src/components/smart_objects/src/always_true_schema_item.cc index 0a3b8be134..93c20c9bce 100644 --- a/src/components/smart_objects/src/always_true_schema_item.cc +++ b/src/components/smart_objects/src/always_true_schema_item.cc @@ -39,10 +39,6 @@ std::shared_ptr CAlwaysTrueSchemaItem::create() { return std::shared_ptr(new CAlwaysTrueSchemaItem()); } -Errors::eType CAlwaysTrueSchemaItem::validate(const SmartObject& object) { - return Errors::OK; -} - Errors::eType CAlwaysTrueSchemaItem::validate( const SmartObject& Object, rpc::ValidationReport* report__, diff --git a/src/components/smart_objects/src/array_schema_item.cc b/src/components/smart_objects/src/array_schema_item.cc index 60081c5222..56a52da761 100644 --- a/src/components/smart_objects/src/array_schema_item.cc +++ b/src/components/smart_objects/src/array_schema_item.cc @@ -42,11 +42,6 @@ std::shared_ptr CArraySchemaItem::create( new CArraySchemaItem(ElementSchemaItem, MinSize, MaxSize)); } -Errors::eType CArraySchemaItem::validate(const SmartObject& Object) { - rpc::ValidationReport report("RPC"); - return validate(Object, &report); -} - Errors::eType CArraySchemaItem::validate( const SmartObject& Object, rpc::ValidationReport* report__, diff --git a/src/components/smart_objects/src/object_schema_item.cc b/src/components/smart_objects/src/object_schema_item.cc index 879c280a67..cfe6f58efa 100644 --- a/src/components/smart_objects/src/object_schema_item.cc +++ b/src/components/smart_objects/src/object_schema_item.cc @@ -104,11 +104,6 @@ std::shared_ptr CObjectSchemaItem::create( return std::shared_ptr(new CObjectSchemaItem(members)); } -Errors::eType CObjectSchemaItem::validate(const SmartObject& object) { - rpc::ValidationReport report("RPC"); - return validate(object, &report); -} - Errors::eType CObjectSchemaItem::validate( const SmartObject& object, rpc::ValidationReport* report__, diff --git a/src/components/smart_objects/src/schema_item.cc b/src/components/smart_objects/src/schema_item.cc index ae7f3665bb..a47fe4d1fb 100644 --- a/src/components/smart_objects/src/schema_item.cc +++ b/src/components/smart_objects/src/schema_item.cc @@ -35,10 +35,6 @@ namespace NsSmartDeviceLink { namespace NsSmartObjects { -Errors::eType ISchemaItem::validate(const SmartObject& Object) { - return Errors::ERROR; -} - Errors::eType ISchemaItem::validate( const SmartObject& object, rpc::ValidationReport* report__, diff --git a/src/components/smart_objects/src/smart_object.cc b/src/components/smart_objects/src/smart_object.cc index 691f45f63b..cf6f290971 100644 --- a/src/components/smart_objects/src/smart_object.cc +++ b/src/components/smart_objects/src/smart_object.cc @@ -873,11 +873,6 @@ bool SmartObject::isValid() const { return (Errors::OK == m_schema.validate(*this, &report)); } -Errors::eType SmartObject::validate() { - rpc::ValidationReport report("RPC"); - return validate(&report); -} - Errors::eType SmartObject::validate( rpc::ValidationReport* report__, const utils::SemanticVersion& MessageVersion) { diff --git a/src/components/smart_objects/src/smart_schema.cc b/src/components/smart_objects/src/smart_schema.cc index 3ab94caf85..62f2101f03 100644 --- a/src/components/smart_objects/src/smart_schema.cc +++ b/src/components/smart_objects/src/smart_schema.cc @@ -40,11 +40,6 @@ CSmartSchema::CSmartSchema() : mSchemaItem(CAlwaysTrueSchemaItem::create()) {} CSmartSchema::CSmartSchema(const ISchemaItemPtr SchemaItem) : mSchemaItem(SchemaItem) {} -Errors::eType CSmartSchema::validate(const SmartObject& Object) const { - rpc::ValidationReport report("RPC"); - return validate(Object, &report); -} - Errors::eType CSmartSchema::validate( const SmartObject& object, rpc::ValidationReport* report__, diff --git a/src/components/smart_objects/src/string_schema_item.cc b/src/components/smart_objects/src/string_schema_item.cc index f3c39eff8f..936db7dbc9 100644 --- a/src/components/smart_objects/src/string_schema_item.cc +++ b/src/components/smart_objects/src/string_schema_item.cc @@ -46,11 +46,6 @@ std::shared_ptr CStringSchemaItem::create( new CStringSchemaItem(MinLength, MaxLength, DefaultValue)); } -Errors::eType CStringSchemaItem::validate(const SmartObject& Object) { - rpc::ValidationReport report("RPC"); - return validate(Object, &report); -} - Errors::eType CStringSchemaItem::validate( const SmartObject& Object, rpc::ValidationReport* report__, diff --git a/src/components/telemetry_monitor/include/telemetry_monitor/telemetry_monitor.h b/src/components/telemetry_monitor/include/telemetry_monitor/telemetry_monitor.h index ccdfe3ea2e..ff7b9da9d6 100644 --- a/src/components/telemetry_monitor/include/telemetry_monitor/telemetry_monitor.h +++ b/src/components/telemetry_monitor/include/telemetry_monitor/telemetry_monitor.h @@ -87,7 +87,6 @@ class TelemetryMonitor { virtual void Stop(); virtual void Start(); virtual void SendMetric(std::shared_ptr metric); - DEPRECATED void set_streamer(Streamer* streamer); void set_streamer(std::shared_ptr streamer); const std::string& ip() const; int16_t port() const; diff --git a/src/components/telemetry_monitor/src/telemetry_monitor.cc b/src/components/telemetry_monitor/src/telemetry_monitor.cc index c17b09c567..c101672bbd 100644 --- a/src/components/telemetry_monitor/src/telemetry_monitor.cc +++ b/src/components/telemetry_monitor/src/telemetry_monitor.cc @@ -63,8 +63,6 @@ void TelemetryMonitor::Start() { thread_ = threads::CreateThread("TelemetryMonitor", streamer_.get()); } -void TelemetryMonitor::set_streamer(Streamer* streamer) {} - void TelemetryMonitor::set_streamer(std::shared_ptr streamer) { LOG4CXX_AUTO_TRACE(logger_); if (thread_ && !thread_->is_running()) { diff --git a/src/components/transport_manager/include/transport_manager/transport_manager_impl.h b/src/components/transport_manager/include/transport_manager/transport_manager_impl.h index 356776cea9..c1df49f91b 100644 --- a/src/components/transport_manager/include/transport_manager/transport_manager_impl.h +++ b/src/components/transport_manager/include/transport_manager/transport_manager_impl.h @@ -244,14 +244,6 @@ class TransportManagerImpl */ int Visibility(const bool& on_off) const OVERRIDE; - /** - * DEPRECATED - * Must be moved under 'private' section - * @brief Updates total device list with info from specific transport adapter. - * @param ta Transport adapter - */ - void UpdateDeviceList(TransportAdapter* ta); - /** * @brief OnDeviceListUpdated updates device list and sends appropriate * notifications to listeners in case of something is changed @@ -501,6 +493,12 @@ class TransportManagerImpl * @return True if mapping has been updated, otherwise - false */ bool UpdateDeviceMapping(TransportAdapter* ta); + + /** + * @brief Updates total device list with info from specific transport adapter. + * @param ta Transport adapter + */ + void UpdateDeviceList(TransportAdapter* ta); }; // class TransportManagerImpl } // namespace transport_manager #endif // SRC_COMPONENTS_TRANSPORT_MANAGER_INCLUDE_TRANSPORT_MANAGER_TRANSPORT_MANAGER_IMPL_H_ diff --git a/src/components/transport_manager/src/transport_adapter/transport_adapter_impl.cc b/src/components/transport_manager/src/transport_adapter/transport_adapter_impl.cc index c50309d437..9b6b09e44a 100644 --- a/src/components/transport_manager/src/transport_adapter/transport_adapter_impl.cc +++ b/src/components/transport_manager/src/transport_adapter/transport_adapter_impl.cc @@ -52,13 +52,9 @@ const char* tc_tcp_ip_address = "tcp_ip_address"; CREATE_LOGGERPTR_GLOBAL(logger_, "TransportManager") namespace { -// @deprecated DeviceTypes: PASA_AOA, PASA_BLUETOOTH, MME DeviceTypes devicesType = { std::make_pair(DeviceType::AOA, std::string("USB_AOA")), - std::make_pair(DeviceType::PASA_AOA, std::string("USB_AOA")), std::make_pair(DeviceType::BLUETOOTH, std::string("BLUETOOTH")), - std::make_pair(DeviceType::PASA_BLUETOOTH, std::string("BLUETOOTH")), - std::make_pair(DeviceType::MME, std::string("USB_IOS")), std::make_pair(DeviceType::IOS_BT, std::string("BLUETOOTH_IOS")), std::make_pair(DeviceType::IOS_USB, std::string("USB_IOS")), std::make_pair(DeviceType::TCP, std::string("WIFI")), -- cgit v1.2.1 From 6ef639ff154c305f48bcbdfaf88e15db1b1803d7 Mon Sep 17 00:00:00 2001 From: Alexander Date: Fri, 20 Jul 2018 12:58:47 +0300 Subject: Remove app_id from HMI_API --- src/components/interfaces/HMI_API.xml | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/components/interfaces/HMI_API.xml b/src/components/interfaces/HMI_API.xml index 4dc5e7f331..a9854ef730 100644 --- a/src/components/interfaces/HMI_API.xml +++ b/src/components/interfaces/HMI_API.xml @@ -5696,9 +5696,6 @@ If subscribe is true, the head unit will send onInteriorVehicleData notifications for the module type - - Internal SDL-assigned ID of the related application - -- cgit v1.2.1 From c3466b57c8c783f0919101f9d350870a14859b02 Mon Sep 17 00:00:00 2001 From: Alexander Date: Fri, 20 Jul 2018 13:06:09 +0300 Subject: Add Interior data cache and interior data manager Add helpers functions for RC --- .../include/rc_rpc_plugin/interior_data_cache.h | 81 +++++++++++ .../rc_rpc_plugin/interior_data_cache_impl.h | 64 +++++++++ .../include/rc_rpc_plugin/interior_data_manager.h | 86 +++++++++++ .../rc_rpc_plugin/interior_data_manager_impl.h | 122 ++++++++++++++++ .../include/rc_rpc_plugin/rc_helpers.h | 82 +++++++++++ .../rc_rpc_plugin/src/interior_data_cache_impl.cc | 121 ++++++++++++++++ .../src/interior_data_manager_impl.cc | 159 ++++++++++++++++++++ .../rpc_plugins/rc_rpc_plugin/src/rc_helpers.cc | 88 ++++++++++++ .../rc_rpc_plugin/mock/mock_interior_data_cache.h | 54 +++++++ .../mock/mock_interior_data_manager.h | 55 +++++++ .../rc_rpc_plugin/test/interior_data_cache_test.cc | 160 +++++++++++++++++++++ 11 files changed, 1072 insertions(+) create mode 100644 src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/interior_data_cache.h create mode 100644 src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/interior_data_cache_impl.h create mode 100644 src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/interior_data_manager.h create mode 100644 src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/interior_data_manager_impl.h create mode 100644 src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_helpers.h create mode 100644 src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/interior_data_cache_impl.cc create mode 100644 src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/interior_data_manager_impl.cc create mode 100644 src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/rc_helpers.cc create mode 100644 src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/include/rc_rpc_plugin/mock/mock_interior_data_cache.h create mode 100644 src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/include/rc_rpc_plugin/mock/mock_interior_data_manager.h create mode 100644 src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/interior_data_cache_test.cc diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/interior_data_cache.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/interior_data_cache.h new file mode 100644 index 0000000000..f12566d14c --- /dev/null +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/interior_data_cache.h @@ -0,0 +1,81 @@ +/* + * 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_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_INTERIOR_DATA_CACHE_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_INTERIOR_DATA_CACHE_H_ +#include +#include "smart_objects/smart_object.h" + +namespace rc_rpc_plugin { + +/** + * @brief The InteriorDataCache interface for caching data class + * Provide ability to cache module data by module type name and clear cache + */ +class InteriorDataCache { + public: + /** + * @brief Add module data to cache + * @param module_type module type name + * @param module_data data to be cached + */ + virtual void Add(const std::string& module_type, + const smart_objects::SmartObject& module_data) = 0; + + /** + * @brief Retrieve Get cached data + * @param module_type data type to get from cache + * @return smart object with cached data, or nulll smart object + */ + virtual smart_objects::SmartObject Retrieve( + const std::string& module_type) const = 0; + + /** + * @brief Contains check if data exists in cache + * @param module_type module type name to check in cache + * @return true if cached, false otherwize + */ + virtual bool Contains(const std::string& module_type) const = 0; + + /** + * @brief Remove cached data + * @param module_type data type to remove from cache + */ + virtual void Remove(const std::string& module_type) = 0; + + /** + * @brief Clear clear all cached data + */ + virtual void Clear() = 0; +}; +} // rc_rpc_plugin + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_INTERIOR_DATA_CACHE_H_ diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/interior_data_cache_impl.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/interior_data_cache_impl.h new file mode 100644 index 0000000000..f2971e3d72 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/interior_data_cache_impl.h @@ -0,0 +1,64 @@ +/* + * 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_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_INTERIOR_DATA_CACHE_IMPL_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_INTERIOR_DATA_CACHE_IMPL_H_ + +#include + +#include "utils/macro.h" +#include "utils/lock.h" +#include "rc_rpc_plugin/interior_data_cache.h" + +namespace rc_rpc_plugin { +class InteriorDataCacheImpl : public InteriorDataCache { + public: + InteriorDataCacheImpl(); + + ~InteriorDataCacheImpl(); + + void Add(const std::string& module_type, + const smart_objects::SmartObject& module_data) OVERRIDE; + smart_objects::SmartObject Retrieve( + const std::string& module_type) const OVERRIDE; + bool Contains(const std::string& module_type) const OVERRIDE; + void Remove(const std::string& module_type) OVERRIDE; + void Clear() OVERRIDE; + + private: + std::map cached_data_; + mutable sync_primitives::Lock cached_data_lock_; +}; + +} // rc_rpc_plugin + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_INTERIOR_DATA_CACHE_IMPL_H_ diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/interior_data_manager.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/interior_data_manager.h new file mode 100644 index 0000000000..f28c388055 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/interior_data_manager.h @@ -0,0 +1,86 @@ +/* + 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_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_INTERIOR_DATA_MANAGER_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_INTERIOR_DATA_MANAGER_H_ + +#include "application_manager/application.h" +#include "application_manager/plugin_manager/rpc_plugin.h" + +namespace rc_rpc_plugin { + +namespace app_mngr = application_manager; +namespace plugins = application_manager::plugin_manager; + +class InteriorDataManager { + public: + /** + * @brief OnPolicyEvent Processes policy related events + * @param event Policy event + */ + virtual void OnPolicyEvent(app_mngr::plugin_manager::PolicyEvent event) = 0; + + /** + * @brief OnApplicationEvent Notifies modules on certain application events + * @param event Event + * @param application Pointer to application struct + */ + virtual void OnApplicationEvent( + plugins::ApplicationEvent event, + app_mngr::ApplicationSharedPtr application) = 0; + + /** + * @brief OnDisablingRC process disable RC event. Unsubscribe from all modules + * and clear cache + */ + virtual void OnDisablingRC() = 0; + + /** + * @brief StoreRequestToHMITime save information and time stamp of + * current interior data subscriptions + */ + virtual void StoreRequestToHMITime(const std::string& module_type) = 0; + + /** + * @brief CheckRequestsToHMIFrequency check that rate limits are not allowed of + * bounce during current time frame. + * calculate amount of requests per module type in time frame and checks if it + * bigger then allowed by ini file + * @param module_type moduletype to calculate frequency on + * @return true if amount of requests was not exceeded, otherwise return false. + */ + virtual bool CheckRequestsToHMIFrequency(const std::string& module_type) = 0; +}; + +} // namespace rc_rpc_plugin + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_INTERIOR_DATA_MANAGER_H_ diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/interior_data_manager_impl.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/interior_data_manager_impl.h new file mode 100644 index 0000000000..b36f47f260 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/interior_data_manager_impl.h @@ -0,0 +1,122 @@ +/* + 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_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_INTERIOR_DATA_MANAGER_IMPL_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_INTERIOR_DATA_MANAGER_IMPL_H_ +#include "rc_rpc_plugin/interior_data_manager.h" +#include "utils/date_time.h" + +namespace application_manager { +class ApplicationManager; +namespace rpc_service { +class RPCService; +} +} +namespace rc_rpc_plugin { + +class InteriorDataCache; +class RCRPCPlugin; + +class InteriorDataManagerImpl : public InteriorDataManager { + public: + InteriorDataManagerImpl( + RCRPCPlugin& rc_plugin, + InteriorDataCache& cache, + application_manager::ApplicationManager& app_mngr, + application_manager::rpc_service::RPCService& rpc_service); + + void OnPolicyEvent(app_mngr::plugin_manager::PolicyEvent event) OVERRIDE; + + void OnApplicationEvent(plugins::ApplicationEvent event, + app_mngr::ApplicationSharedPtr application) OVERRIDE; + + void OnDisablingRC() OVERRIDE; + + void StoreRequestToHMITime(const std::string& module_type) OVERRIDE; + + bool CheckRequestsToHMIFrequency(const std::string& module_type) OVERRIDE; + + private: + /** + * @brief UpdateHMISubscriptionsOnPolicyUpdated process policy update event. + * If some modules was disabeled by policies and there are no applications + * that subscribed to them - send RC.GetInteriorVehicleData(subscribe=false) + * and clear cache + */ + void UpdateHMISubscriptionsOnPolicyUpdated(); + + /** + * @brief UpdateHMISubscriptionsOnAppUnregistered process AppUnregistered + * event and unsubscribed from not actual module types + * @param app application that was unregistered + */ + void UpdateHMISubscriptionsOnAppUnregistered( + application_manager::Application& app); + + /** + * @brief UnsubscribeFromInteriorVehicleData remove module_type from cache and + * send RC.GetInteriorVehicleData(subscribe=false) to HMI + * @param module_type module type that need to be unsubscribed + */ + void UnsubscribeFromInteriorVehicleData(const std::string& module_type); + + void ClearOldRequestsToHMIHistory(); + /** + * @brief AppsModules mapping from applications to list of modules + */ + typedef std::map > AppsModules; + + /** + * @brief AppsSubscribedModules get mapping of application to list of + * subscribed modules + * @return map of applications to list of subscribed modules + */ + AppsModules AppsSubscribedModules(); + + /** + * @brief RequestsToHMIHistory mapping from module type to vector of time + * stamps + */ + typedef std::map > + RequestsToHMIHistory; + RequestsToHMIHistory requests_to_hmi_history_; + mutable sync_primitives::Lock requests_to_hmi_history_lock_; + + RCRPCPlugin& rc_plugin_; + InteriorDataCache& cache_; + application_manager::ApplicationManager& app_mngr_; + application_manager::rpc_service::RPCService& rpc_service_; +}; + +} // namespace rc_rpc_plugin +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_INTERIOR_DATA_MANAGER_IMPL_H_ diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_helpers.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_helpers.h new file mode 100644 index 0000000000..e20a982d91 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_helpers.h @@ -0,0 +1,82 @@ +/* + 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_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_RC_HELPERS_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_RC_HELPERS_H_ + +#include +#include +#include "application_manager/application.h" +#include "rc_rpc_plugin/rc_app_extension.h" + +namespace rc_rpc_plugin { +class RCRPCPlugin; + +/** + * @brief The RCHelpers class contains frequently used static data + * structures related strictly to RC + * Converters, mapping, factory functions + */ +class RCHelpers { + public: + /** + * @brief GetModuleTypeToDataMapping get mapping of module type enum naming to + * actual module data filed name + * @return module mapping from enum naming to filed name + */ + static const std::function + GetModuleTypeToDataMapping(); + + /** + * @brief GetRCExtension extract RC extension from application + * @param app application to extract extension + * @return rc extension of app is rc applicaiton, otherwise return emty shared + * pointer. + */ + static RCAppExtensionPtr GetRCExtension( + application_manager::Application& app); + + static smart_objects::SmartObjectSPtr CreateUnsubscribeRequestToHMI( + const std::string& module_type, const uint32_t correlation_id); + + static std::vector + AppsSubscribedToModuleType(application_manager::ApplicationManager& app_mngr, + const std::string& module_type); + + typedef std::map > AppsModules; + static AppsModules GetApplicaitonsAllowedModules( + application_manager::ApplicationManager& app_mngr); +}; + +} // rc_rpc_plugin +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_RC_HELPERS_H_ diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/interior_data_cache_impl.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/interior_data_cache_impl.cc new file mode 100644 index 0000000000..0eb175aa25 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/interior_data_cache_impl.cc @@ -0,0 +1,121 @@ +/* + * 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. + */ + +#include +#include +#include +#include "rc_rpc_plugin/interior_data_cache_impl.h" +#include "utils/date_time.h" +#include "utils/logger.h" + +namespace rc_rpc_plugin { + +CREATE_LOGGERPTR_GLOBAL(logger_, "RemoteControlModule"); + +InteriorDataCacheImpl::InteriorDataCacheImpl() {} + +InteriorDataCacheImpl::~InteriorDataCacheImpl() {} + +/** + * @brief MergeModuleData key all keys and values from first parameter and + * update and append keys and values from the second + * @param data1 - initial data + * @param data2 - updated data + * @return updated data1 with data2 keys and values + */ +smart_objects::SmartObject MergeModuleData( + const smart_objects::SmartObject& data1, + const smart_objects::SmartObject& data2) { + smart_objects::SmartObject result = data1; + auto it = data2.map_begin(); + for (; it != data2.map_end(); ++it) { + const std::string& key = it->first; + const smart_objects::SmartObject& value = it->second; + result[key] = value; + } + return result; +} + +void InteriorDataCacheImpl::Add(const std::string& module_type, + const smart_objects::SmartObject& module_data) { + LOG4CXX_TRACE(logger_, "module_type : " << module_type); + sync_primitives::AutoLock autolock(cached_data_lock_); + auto it = cached_data_.find(module_type); + if (cached_data_.end() == it) { + cached_data_[module_type] = module_data; + return; + } + cached_data_[module_type] = MergeModuleData(it->second, module_data); +} + +smart_objects::SmartObject InteriorDataCacheImpl::Retrieve( + const std::string& module_type) const { + LOG4CXX_AUTO_TRACE(logger_); + sync_primitives::AutoLock autolock(cached_data_lock_); + auto it = cached_data_.find(module_type); + if (it == cached_data_.end()) { + LOG4CXX_WARN(logger_, + "Module type " << module_type << " was not found in cache"); + return smart_objects::SmartObject(smart_objects::SmartType_Null); + } + LOG4CXX_TRACE(logger_, "module_type : " << module_type); + return it->second; +} + +bool InteriorDataCacheImpl::Contains(const std::string& module_type) const { + LOG4CXX_AUTO_TRACE(logger_); + sync_primitives::AutoLock autolock(cached_data_lock_); + auto it = cached_data_.find(module_type); + const bool contains = it != cached_data_.end(); + LOG4CXX_TRACE(logger_, + "module_type : " << module_type << " " + << (contains ? "true" : "false")); + return contains; +} + +void InteriorDataCacheImpl::Remove(const std::string& module_type) { + LOG4CXX_TRACE(logger_, "module_type : " << module_type); + sync_primitives::AutoLock autolock(cached_data_lock_); + auto it = cached_data_.find(module_type); + if (cached_data_.end() == it) { + LOG4CXX_TRACE(logger_, "Not existing module_type : " << module_type); + return; + } + cached_data_.erase(it); +} + +void InteriorDataCacheImpl::Clear() { + LOG4CXX_AUTO_TRACE(logger_); + sync_primitives::AutoLock autolock(cached_data_lock_); + cached_data_.clear(); +} +} diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/interior_data_manager_impl.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/interior_data_manager_impl.cc new file mode 100644 index 0000000000..1f6290ad10 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/interior_data_manager_impl.cc @@ -0,0 +1,159 @@ +#include "rc_rpc_plugin/interior_data_manager_impl.h" +#include "rc_rpc_plugin/rc_helpers.h" +#include "rc_rpc_plugin/rc_rpc_plugin.h" +#include "application_manager/application_manager.h" +#include "application_manager/rpc_service.h" + +namespace rc_rpc_plugin { +CREATE_LOGGERPTR_GLOBAL(logger_, "RemoteControlModule"); + +InteriorDataManagerImpl::InteriorDataManagerImpl( + RCRPCPlugin& rc_plugin, + InteriorDataCache& cache, + application_manager::ApplicationManager& app_mngr, + application_manager::rpc_service::RPCService& rpc_service) + : rc_plugin_(rc_plugin) + , cache_(cache) + , app_mngr_(app_mngr) + , rpc_service_(rpc_service) {} + +void InteriorDataManagerImpl::OnPolicyEvent(plugins::PolicyEvent event) { + UpdateHMISubscriptionsOnPolicyUpdated(); +} + +void InteriorDataManagerImpl::OnApplicationEvent( + plugins::ApplicationEvent event, + app_mngr::ApplicationSharedPtr application) { + if (plugins::ApplicationEvent::kApplicationUnregistered == event || + plugins::ApplicationEvent::kApplicationExit == event) { + UpdateHMISubscriptionsOnAppUnregistered(*application); + } +} + +void InteriorDataManagerImpl::OnDisablingRC() { + LOG4CXX_AUTO_TRACE(logger_); + auto existing_subscription = AppsSubscribedModules(); + std::set subscribed_modules; + for (auto& pair : existing_subscription) { + auto& app = pair.first; + auto rc_extension = RCHelpers::GetRCExtension(*app); + for (const auto& module : pair.second) { + subscribed_modules.insert(module); + rc_extension->UnsubscribeFromInteriorVehicleData(module); + } + } + for (auto& module : subscribed_modules) { + LOG4CXX_TRACE(logger_, "unsubscribe " << module); + UnsubscribeFromInteriorVehicleData(module); + } +} + +void InteriorDataManagerImpl::StoreRequestToHMITime( + const std::string& module_type) { + LOG4CXX_AUTO_TRACE(logger_); + sync_primitives::AutoLock autolock(requests_to_hmi_history_lock_); + requests_to_hmi_history_[module_type].push_back( + date_time::DateTime::getCurrentTime()); +} + +bool InteriorDataManagerImpl::CheckRequestsToHMIFrequency( + const std::string& module_type) { + LOG4CXX_AUTO_TRACE(logger_); + sync_primitives::AutoLock autolock(requests_to_hmi_history_lock_); + ClearOldRequestsToHMIHistory(); + const auto& history = requests_to_hmi_history_[module_type]; + const auto limit = + app_mngr_.get_settings().get_interior_vehicle_data_frequency().first; + return history.size() < limit; +} + +void InteriorDataManagerImpl::UpdateHMISubscriptionsOnPolicyUpdated() { + auto apps_allowed_modules = + RCHelpers::GetApplicaitonsAllowedModules(app_mngr_); + auto apps_subscribed_modules = AppsSubscribedModules(); + InteriorDataManagerImpl::AppsModules apps_disallowed_modules; + for (auto& pair : apps_subscribed_modules) { + auto& allowed = apps_allowed_modules[pair.first]; + auto& subscribed = pair.second; + std::vector disallowed_modules; + std::set_difference(subscribed.begin(), + subscribed.end(), + allowed.begin(), + allowed.end(), + std::back_inserter(disallowed_modules)); + apps_disallowed_modules[pair.first] = disallowed_modules; + } + + for (auto& pair : apps_disallowed_modules) { + auto& app = pair.first; + auto rc_extension = RCHelpers::GetRCExtension(*app); + for (const auto& module : pair.second) { + rc_extension->UnsubscribeFromInteriorVehicleData(module); + auto apps_subscribed = + RCHelpers::AppsSubscribedToModuleType(app_mngr_, module); + if (apps_subscribed.empty()) { + UnsubscribeFromInteriorVehicleData(module); + } + } + } +} + +void InteriorDataManagerImpl::UpdateHMISubscriptionsOnAppUnregistered( + application_manager::Application& app) { + LOG4CXX_AUTO_TRACE(logger_); + auto rc_extension = RCHelpers::GetRCExtension(app); + auto subscribed_data = rc_extension->InteriorVehicleDataSubscriptions(); + rc_extension->UnsubscribeFromInteriorVehicleData(); + for (auto& data : subscribed_data) { + auto apps_subscribed = + RCHelpers::AppsSubscribedToModuleType(app_mngr_, data); + if (apps_subscribed.empty()) { + UnsubscribeFromInteriorVehicleData(data); + } + if (apps_subscribed.size() == 1 && + apps_subscribed.front()->hmi_app_id() == app.hmi_app_id()) { + UnsubscribeFromInteriorVehicleData(data); + } + } +} + +void InteriorDataManagerImpl::UnsubscribeFromInteriorVehicleData( + const std::string& module_type) { + cache_.Remove(module_type); + auto unsubscribe_request = RCHelpers::CreateUnsubscribeRequestToHMI( + module_type, app_mngr_.GetNextHMICorrelationID()); + LOG4CXX_DEBUG(logger_, "Send Unsubscribe from " << module_type); + rpc_service_.ManageHMICommand(unsubscribe_request); +} + +void InteriorDataManagerImpl::ClearOldRequestsToHMIHistory() { + auto limit = + app_mngr_.get_settings().get_interior_vehicle_data_frequency().second; + uint32_t time_frame = limit * date_time::DateTime::MILLISECONDS_IN_SECOND; + auto lest_that_time_frame_ago = [time_frame](TimevalStruct time) { + auto span = date_time::DateTime::calculateTimeSpan(time); + return span < time_frame; + }; + for (auto& it : requests_to_hmi_history_) { + auto& history = it.second; + auto first_actual = + std::find_if(history.begin(), history.end(), lest_that_time_frame_ago); + history.erase(history.begin(), first_actual); + } +} + +InteriorDataManagerImpl::AppsModules +InteriorDataManagerImpl::AppsSubscribedModules() { + auto apps_list = RCRPCPlugin::GetRCApplications(app_mngr_); + InteriorDataManagerImpl::AppsModules result; + for (auto& app_ptr : apps_list) { + const auto rc_extension = RCHelpers::GetRCExtension(*app_ptr); + auto app_subscriptions = rc_extension->InteriorVehicleDataSubscriptions(); + result[app_ptr] = std::vector(app_subscriptions.size()); + std::copy(app_subscriptions.begin(), + app_subscriptions.end(), + result[app_ptr].begin()); + } + return result; +} +} // namespace rc_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/rc_helpers.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/rc_helpers.cc new file mode 100644 index 0000000000..a8c29752d7 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/rc_helpers.cc @@ -0,0 +1,88 @@ +#include "rc_rpc_plugin/rc_helpers.h" +#include "rc_rpc_plugin/rc_module_constants.h" +#include "rc_rpc_plugin/rc_rpc_plugin.h" +#include "application_manager/smart_object_keys.h" +#include "application_manager/commands/command_impl.h" +#include "application_manager/message.h" + +namespace rc_rpc_plugin { +CREATE_LOGGERPTR_GLOBAL(logger_, "RemoteControlModule"); + +const std::function +RCHelpers::GetModuleTypeToDataMapping() { + auto mapping_lambda = [](const std::string& module_type) -> std::string { + static std::map mapping = { + {enums_value::kRadio, message_params::kRadioControlData}, + {enums_value::kClimate, message_params::kClimateControlData}, + {enums_value::kSeat, message_params::kSeatControlData}}; + auto it = mapping.find(module_type); + if (mapping.end() == it) { + return std::string(); + } + return it->second; + }; + + return mapping_lambda; +} + +RCAppExtensionPtr RCHelpers::GetRCExtension( + application_manager::Application& app) { + auto extension_interface = app.QueryInterface(RCRPCPlugin::kRCPluginID); + auto extension = + std::static_pointer_cast(extension_interface); + return extension; +} + +smart_objects::SmartObjectSPtr RCHelpers::CreateUnsubscribeRequestToHMI( + const std::string& module_type, const uint32_t correlation_id) { + using namespace smart_objects; + namespace commands = application_manager::commands; + namespace am_strings = application_manager::strings; + + SmartObjectSPtr message = std::make_shared(SmartType_Map); + SmartObject& params = (*message)[am_strings::params]; + SmartObject& msg_params = (*message)[am_strings::msg_params]; + + params[am_strings::message_type] = + static_cast(application_manager::kRequest); + params[am_strings::protocol_version] = + commands::CommandImpl::protocol_version_; + params[am_strings::protocol_type] = commands::CommandImpl::hmi_protocol_type_; + params[am_strings::correlation_id] = correlation_id; + params[am_strings::function_id] = + hmi_apis::FunctionID::RC_GetInteriorVehicleData; + msg_params[message_params::kSubscribe] = false; + msg_params[message_params::kModuleType] = module_type; + return message; +} + +std::vector +RCHelpers::AppsSubscribedToModuleType( + application_manager::ApplicationManager& app_mngr, + const std::string& module_type) { + std::vector result; + auto rc_apps = RCRPCPlugin::GetRCApplications(app_mngr); + for (auto& app : rc_apps) { + auto rc_ext = RCHelpers::GetRCExtension(*app); + DCHECK_OR_RETURN(rc_ext, result); + if (rc_ext->IsSubscibedToInteriorVehicleData(module_type)) { + result.push_back(app); + } + } + return result; +} + +RCHelpers::AppsModules RCHelpers::GetApplicaitonsAllowedModules( + app_mngr::ApplicationManager& app_mngr) { + auto apps_list = RCRPCPlugin::GetRCApplications(app_mngr); + RCHelpers::AppsModules result; + for (auto& app_ptr : apps_list) { + std::vector allowed_modules; + app_mngr.GetPolicyHandler().GetModuleTypes(app_ptr->policy_app_id(), + &allowed_modules); + std::sort(allowed_modules.begin(), allowed_modules.end()); + result[app_ptr] = allowed_modules; + } + return result; +} +} diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/include/rc_rpc_plugin/mock/mock_interior_data_cache.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/include/rc_rpc_plugin/mock/mock_interior_data_cache.h new file mode 100644 index 0000000000..45465f96b0 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/include/rc_rpc_plugin/mock/mock_interior_data_cache.h @@ -0,0 +1,54 @@ +/* + * 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_RC_RPC_PLUGIN_TEST_INCLUDE_RC_RPC_PLUGIN_MOCK_MOCK_INTERIOR_DATA_CACHE_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_TEST_INCLUDE_RC_RPC_PLUGIN_MOCK_MOCK_INTERIOR_DATA_CACHE_H_ + +#include +#include "gmock/gmock.h" +#include "rc_rpc_plugin/interior_data_cache.h" + +namespace rc_rpc_plugin_test { + +class MockInteriorDataCache : public rc_rpc_plugin::InteriorDataCache { + public: + MOCK_METHOD2(Add, + void(const std::string&, const smart_objects::SmartObject&)); + MOCK_CONST_METHOD1(Retrieve, smart_objects::SmartObject(const std::string&)); + MOCK_CONST_METHOD1(Contains, bool(const std::string&)); + MOCK_METHOD1(Remove, void(const std::string&)); + MOCK_METHOD0(Clear, void()); +}; + +} // namespace rc_rpc_plugin_test + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_TEST_INCLUDE_RC_RPC_PLUGIN_MOCK_MOCK_INTERIOR_DATA_CACHE_H_ diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/include/rc_rpc_plugin/mock/mock_interior_data_manager.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/include/rc_rpc_plugin/mock/mock_interior_data_manager.h new file mode 100644 index 0000000000..fc19c6a889 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/include/rc_rpc_plugin/mock/mock_interior_data_manager.h @@ -0,0 +1,55 @@ +/* + * 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_RC_RPC_PLUGIN_TEST_INCLUDE_RC_RPC_PLUGIN_MOCK_MOCK_INTERIOR_DATA_MANAGER_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_TEST_INCLUDE_RC_RPC_PLUGIN_MOCK_MOCK_INTERIOR_DATA_MANAGER_H_ + +#include +#include "gmock/gmock.h" +#include "rc_rpc_plugin/interior_data_manager.h" +namespace rc_rpc_plugin_test { + +class MockInteriorDataManager : public rc_rpc_plugin::InteriorDataManager { + public: + MOCK_METHOD1(OnPolicyEvent, + void(application_manager::plugin_manager::PolicyEvent)); + MOCK_METHOD2(OnApplicationEvent, + void(application_manager::plugin_manager::ApplicationEvent, + application_manager::ApplicationSharedPtr)); + MOCK_METHOD0(OnDisablingRC, void()); + MOCK_METHOD1(StoreRequestToHMITime, void(const std::string&)); + MOCK_METHOD1(CheckRequestsToHMIFrequency, bool(const std::string&)); +}; + +} // namespace rc_rpc_plugin_test + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_TEST_INCLUDE_RC_RPC_PLUGIN_MOCK_MOCK_INTERIOR_DATA_MANAGER_H_ diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/interior_data_cache_test.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/interior_data_cache_test.cc new file mode 100644 index 0000000000..e6922a4c83 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/interior_data_cache_test.cc @@ -0,0 +1,160 @@ +/* + * 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. */ + +#include "gtest/gtest.h" +#include "rc_rpc_plugin/interior_data_cache_impl.h" + +namespace rc_rpc_plugin_test { + +class InteriorDataCacheTest : public ::testing::Test {}; + +namespace { +const uint32_t time_frame_alowed_requests = 1; +} // namespace + +TEST_F(InteriorDataCacheTest, + InteriorDataCacheDoesNotContainRandomDataInitialy) { + rc_rpc_plugin::InteriorDataCacheImpl cache; + std::string module_type_key = "random_module_type"; + EXPECT_FALSE(cache.Contains(module_type_key)); + auto retrieved_data = cache.Retrieve(module_type_key); + EXPECT_EQ(smart_objects::SmartType_Null, retrieved_data.getType()); +} + +TEST_F(InteriorDataCacheTest, CheckThatCacheContansDataAfterAdding) { + rc_rpc_plugin::InteriorDataCacheImpl cache; + const std::string module_type_key = "random_module_type"; + smart_objects::SmartObject data; + data["key"] = "value"; + + cache.Add(module_type_key, data); + EXPECT_TRUE(cache.Contains(module_type_key)); + auto retrieved_data = cache.Retrieve(module_type_key); + EXPECT_EQ(data, retrieved_data); +} + +TEST_F(InteriorDataCacheTest, DataDoesNotExistAfterClear) { + rc_rpc_plugin::InteriorDataCacheImpl cache; + const std::string module_type_key = "random_module_type"; + smart_objects::SmartObject data; + data["key"] = "value"; + + cache.Add(module_type_key, data); + EXPECT_TRUE(cache.Contains(module_type_key)); + auto Retrieved_data = cache.Retrieve(module_type_key); + EXPECT_EQ(Retrieved_data, data); + cache.Clear(); + auto Retrieved_data_after_clear = cache.Retrieve(module_type_key); + EXPECT_EQ(smart_objects::SmartType_Null, + Retrieved_data_after_clear.getType()); +} + +TEST_F(InteriorDataCacheTest, MultipleDataCached) { + rc_rpc_plugin::InteriorDataCacheImpl cache; + + const std::string module_type_key1 = "random_module_type"; + smart_objects::SmartObject data1; + data1["key"] = "value1"; + cache.Add(module_type_key1, data1); + EXPECT_TRUE(cache.Contains(module_type_key1)); + auto retrieved_data1 = cache.Retrieve(module_type_key1); + EXPECT_EQ(data1, retrieved_data1); + + std::string module_type_key2 = "random_module_type2"; + smart_objects::SmartObject data2; + data2["key"] = "value2"; + cache.Add(module_type_key2, data2); + EXPECT_TRUE(cache.Contains(module_type_key2)); + auto retrieved_data2 = cache.Retrieve(module_type_key2); + EXPECT_EQ(retrieved_data2, data2); + + ASSERT_TRUE(data1 != data2); + EXPECT_TRUE(data2 != retrieved_data1); + EXPECT_TRUE(data1 != retrieved_data2); +} + +TEST_F(InteriorDataCacheTest, RemoveFromChacheSuccessful) { + rc_rpc_plugin::InteriorDataCacheImpl cache; + + const std::string module_type = "random_module_type"; + smart_objects::SmartObject data; + data["key"] = "value1"; + cache.Add(module_type, data); + EXPECT_TRUE(cache.Contains(module_type)); + auto retrieved_data1 = cache.Retrieve(module_type); + EXPECT_EQ(data, retrieved_data1); + + cache.Remove(module_type); + EXPECT_FALSE(cache.Contains(module_type)); + auto retreived = cache.Retrieve(module_type); + EXPECT_EQ(smart_objects::SmartType_Null, retreived.getType()); +} + +TEST_F(InteriorDataCacheTest, RemoveNotExistingNoSideEffects) { + rc_rpc_plugin::InteriorDataCacheImpl cache; + const std::string module_type_key = "random_module_type"; + smart_objects::SmartObject data; + data["key"] = "value"; + + cache.Add(module_type_key, data); + cache.Remove("some other module_type"); + + EXPECT_TRUE(cache.Contains(module_type_key)); + auto retrieved_data = cache.Retrieve(module_type_key); + EXPECT_EQ(data, retrieved_data); +} + +TEST_F(InteriorDataCacheTest, Exist2ModuleTypesRemoveOneAnotherOneLeft) { + rc_rpc_plugin::InteriorDataCacheImpl cache; + + const std::string module_type_key1 = "random_module_type"; + smart_objects::SmartObject data1; + data1["key"] = "value1"; + cache.Add(module_type_key1, data1); + + std::string module_type_key2 = "random_module_type2"; + smart_objects::SmartObject data2; + data2["key"] = "value2"; + cache.Add(module_type_key2, data2); + + ASSERT_TRUE(data1 != data2); + + cache.Remove(module_type_key1); + EXPECT_FALSE(cache.Contains(module_type_key1)); + EXPECT_TRUE(cache.Contains(module_type_key2)); + + auto retrieved_data1 = cache.Retrieve(module_type_key1); + EXPECT_EQ(smart_objects::SmartType_Null, retrieved_data1.getType()); + auto retrieved_data2 = cache.Retrieve(module_type_key2); + EXPECT_EQ(data2, retrieved_data2); +} + +} // rc_rpc_plugin_test -- cgit v1.2.1 From 298ff1d4653862eba66616712cdf4286a0cbfb69 Mon Sep 17 00:00:00 2001 From: Alexander Date: Fri, 20 Jul 2018 13:08:11 +0300 Subject: Namespace fix Add namespace to RPCService --- .../include/application_manager/command_factory.h | 9 ++++----- .../commands/mobile/get_interior_vehicle_data_request.h | 3 +-- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/components/application_manager/include/application_manager/command_factory.h b/src/components/application_manager/include/application_manager/command_factory.h index b8267ed438..f494fd64f8 100644 --- a/src/components/application_manager/include/application_manager/command_factory.h +++ b/src/components/application_manager/include/application_manager/command_factory.h @@ -40,7 +40,6 @@ #include "utils/macro.h" namespace application_manager { -using rpc_service::RPCService; using policy::PolicyHandlerInterface; typedef std::shared_ptr CommandSharedPtr; @@ -105,7 +104,7 @@ class DefaultCommandCreator : public CommandCreator { * @param policy_handler PolicyHandlerInterface. */ DefaultCommandCreator(ApplicationManager& application_manager, - RPCService& rpc_service, + rpc_service::RPCService& rpc_service, HMICapabilities& hmi_capabilities, PolicyHandlerInterface& policy_handler) : application_manager_(application_manager) @@ -137,7 +136,7 @@ class DefaultCommandCreator : public CommandCreator { } ApplicationManager& application_manager_; - RPCService& rpc_service_; + rpc_service::RPCService& rpc_service_; HMICapabilities& hmi_capabilities_; PolicyHandlerInterface& policy_handler_; }; @@ -158,7 +157,7 @@ class DefaultCommandCreator : public CommandCreator { * @param policy_handler PolicyHandlerInterface. */ DefaultCommandCreator(ApplicationManager& application_manager, - RPCService& rpc_service, + rpc_service::RPCService& rpc_service, HMICapabilities& hmi_capabilities, PolicyHandlerInterface& policy_handler) { UNUSED(application_manager); @@ -203,7 +202,7 @@ struct CommandCreatorFactory { return res; } ApplicationManager& application_manager_; - RPCService& rpc_service_; + rpc_service::RPCService& rpc_service_; HMICapabilities& hmi_capabilities_; PolicyHandlerInterface& policy_handler_; }; diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/get_interior_vehicle_data_request.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/get_interior_vehicle_data_request.h index c2ae0e887f..2ffb770159 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/get_interior_vehicle_data_request.h +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/get_interior_vehicle_data_request.h @@ -80,8 +80,7 @@ class GetInteriorVehicleDataRequest : public RCCommandRequest { * @brief Handle subscription to vehicle data * @param hmi_response json message with response from HMI */ - void ProccessSubscription( - const NsSmartDeviceLink::NsSmartObjects::SmartObject& hmi_response); + void ProccessSubscription(const smart_objects::SmartObject& hmi_response); /** * @brief Cuts off subscribe parameter -- cgit v1.2.1 From 7c702d26c10380d14583c2fba6c955080bd6cbef Mon Sep 17 00:00:00 2001 From: Alexander Date: Fri, 20 Jul 2018 13:25:28 +0300 Subject: Rework dependency injection in RC commands Pass components to RC commands with RCParams struct to avoid big changes on every adding component Add InteriorDataCache and manager to RC commands --- .../commands/hmi/rc_button_press_request.h | 17 +- .../commands/hmi/rc_button_press_response.h | 14 +- .../rc_get_interior_vehicle_data_consent_request.h | 10 +- ...rc_get_interior_vehicle_data_consent_response.h | 10 +- .../hmi/rc_get_interior_vehicle_data_request.h | 10 +- .../hmi/rc_get_interior_vehicle_data_response.h | 10 +- .../hmi/rc_on_interior_vehicle_data_notification.h | 16 +- .../rc_on_remote_control_settings_notification.h | 19 +- .../hmi/rc_set_interior_vehicle_data_request.h | 10 +- .../hmi/rc_set_interior_vehicle_data_response.h | 16 +- .../commands/mobile/button_press_request.h | 15 +- .../commands/mobile/button_press_response.h | 17 +- .../mobile/get_interior_vehicle_data_request.h | 8 +- .../mobile/get_interior_vehicle_data_response.h | 16 +- .../mobile/on_interior_vehicle_data_notification.h | 13 +- .../mobile/set_interior_vehicle_data_request.h | 14 +- .../mobile/set_interior_vehicle_data_response.h | 16 +- .../rc_rpc_plugin/commands/rc_command_params.h | 64 +++ .../rc_rpc_plugin/commands/rc_command_request.h | 20 +- .../include/rc_rpc_plugin/rc_app_extension.h | 6 +- .../include/rc_rpc_plugin/rc_command_factory.h | 20 +- .../include/rc_rpc_plugin/rc_module_constants.h | 6 +- .../include/rc_rpc_plugin/rc_rpc_plugin.h | 17 +- .../rc_rpc_plugin/resource_allocation_manager.h | 6 +- .../resource_allocation_manager_impl.h | 7 +- .../src/commands/hmi/rc_button_press_request.cc | 20 +- .../src/commands/hmi/rc_button_press_response.cc | 21 +- ...rc_get_interior_vehicle_data_consent_request.cc | 16 +- ...c_get_interior_vehicle_data_consent_response.cc | 21 +- .../hmi/rc_get_interior_vehicle_data_request.cc | 16 +- .../hmi/rc_get_interior_vehicle_data_response.cc | 19 +- .../rc_on_interior_vehicle_data_notification.cc | 19 +- .../rc_on_remote_control_settings_notification.cc | 22 +- .../hmi/rc_set_interior_vehicle_data_request.cc | 16 +- .../hmi/rc_set_interior_vehicle_data_response.cc | 19 +- .../src/commands/mobile/button_press_request.cc | 13 +- .../src/commands/mobile/button_press_response.cc | 19 +- .../mobile/get_interior_vehicle_data_request.cc | 16 +- .../mobile/get_interior_vehicle_data_response.cc | 19 +- .../on_interior_vehicle_data_notification.cc | 18 +- .../mobile/set_interior_vehicle_data_request.cc | 13 +- .../mobile/set_interior_vehicle_data_response.cc | 20 +- .../src/commands/rc_command_request.cc | 22 +- .../rc_rpc_plugin/src/rc_command_factory.cc | 90 +--- .../rpc_plugins/rc_rpc_plugin/src/rc_rpc_plugin.cc | 25 +- .../test/commands/button_press_request_test.cc | 18 +- .../get_interior_vehicle_data_request_test.cc | 469 ++++++++++++++++++--- .../on_interior_vehicle_data_notification_test.cc | 70 +-- .../commands/on_remote_control_settings_test.cc | 20 +- .../rc_get_interior_vehicle_data_consent_test.cc | 36 +- .../set_interior_vehicle_data_request_test.cc | 20 +- .../mock/mock_resource_allocation_manager.h | 6 +- 52 files changed, 881 insertions(+), 579 deletions(-) create mode 100644 src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/rc_command_params.h diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/hmi/rc_button_press_request.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/hmi/rc_button_press_request.h index fc3721e763..3bc34be8d1 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/hmi/rc_button_press_request.h +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/hmi/rc_button_press_request.h @@ -30,19 +30,20 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_COMMANDS_HMI_RC_BUTTON_PRESS_REQUEST_H -#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_COMMANDS_HMI_RC_BUTTON_PRESS_REQUEST_H +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_COMMANDS_HMI_RC_BUTTON_PRESS_REQUEST_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_COMMANDS_HMI_RC_BUTTON_PRESS_REQUEST_H_ #include "application_manager/commands/request_to_hmi.h" +#include "rc_rpc_plugin/commands/rc_command_request.h" #include "rc_rpc_plugin/resource_allocation_manager.h" +#include "rc_rpc_plugin/interior_data_cache.h" #include "utils/macro.h" namespace rc_rpc_plugin { namespace app_mngr = application_manager; namespace commands { -class RCButtonPressRequest - : public application_manager::commands::RequestToHMI { +class RCButtonPressRequest : public app_mngr::commands::RequestToHMI { public: /** * @brief RCButtonPressRequest class constructor @@ -54,11 +55,7 @@ class RCButtonPressRequest * @param resource_allocation_manager ResourceAllocationManager **/ RCButtonPressRequest(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, - ResourceAllocationManager& resource_allocation_manager); + const RCCommandParams& params); /** * @brief Execute command */ @@ -68,4 +65,4 @@ class RCButtonPressRequest } // namespace commands } // namespace rc_rpc_plugin -#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_COMMANDS_HMI_RC_BUTTON_PRESS_REQUEST_H +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_COMMANDS_HMI_RC_BUTTON_PRESS_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/hmi/rc_button_press_response.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/hmi/rc_button_press_response.h index c16f4de0cc..939d5fa468 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/hmi/rc_button_press_response.h +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/hmi/rc_button_press_response.h @@ -30,11 +30,13 @@ POSSIBILITY OF SUCH DAMAGE. */ -#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_COMMANDS_HMI_RC_BUTTON_PRESS_RESPONSE_H -#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_COMMANDS_HMI_RC_BUTTON_PRESS_RESPONSE_H +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_COMMANDS_HMI_RC_BUTTON_PRESS_RESPONSE_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_COMMANDS_HMI_RC_BUTTON_PRESS_RESPONSE_H_ #include "application_manager/commands/response_from_hmi.h" +#include "rc_rpc_plugin/commands/rc_command_request.h" #include "rc_rpc_plugin/resource_allocation_manager.h" +#include "rc_rpc_plugin/interior_data_cache.h" #include "utils/macro.h" namespace rc_rpc_plugin { @@ -54,11 +56,7 @@ class RCButtonPressResponse * @param resource_allocation_manager ResourceAllocationManager **/ RCButtonPressResponse(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, - ResourceAllocationManager& resource_allocation_manager); + const RCCommandParams& params); void Run() OVERRIDE; @@ -67,4 +65,4 @@ class RCButtonPressResponse } // namespace commands } // namespace rc_rpc_plugin -#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_COMMANDS_HMI_RC_BUTTON_PRESS_RESPONSE_H +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_COMMANDS_HMI_RC_BUTTON_PRESS_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/hmi/rc_get_interior_vehicle_data_consent_request.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/hmi/rc_get_interior_vehicle_data_consent_request.h index fc2e0d6536..97df5e8390 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/hmi/rc_get_interior_vehicle_data_consent_request.h +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/hmi/rc_get_interior_vehicle_data_consent_request.h @@ -34,7 +34,9 @@ #define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_COMMANDS_HMI_RC_GET_INTERIOR_VEHICLE_DATA_CONSENT_REQUEST_H_ #include "application_manager/commands/request_to_hmi.h" +#include "rc_rpc_plugin/commands/rc_command_request.h" #include "rc_rpc_plugin/resource_allocation_manager.h" +#include "rc_rpc_plugin/interior_data_cache.h" #include "utils/macro.h" namespace rc_rpc_plugin { @@ -45,12 +47,8 @@ class RCGetInteriorVehicleDataConsentRequest : public application_manager::commands::RequestToHMI { public: RCGetInteriorVehicleDataConsentRequest( - 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, - ResourceAllocationManager& resource_allocation_manager); + const application_manager::commands::MessageSharedPtr& message, + const RCCommandParams& params); void Run() OVERRIDE; ~RCGetInteriorVehicleDataConsentRequest(); diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/hmi/rc_get_interior_vehicle_data_consent_response.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/hmi/rc_get_interior_vehicle_data_consent_response.h index a037d33d5a..46232987a5 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/hmi/rc_get_interior_vehicle_data_consent_response.h +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/hmi/rc_get_interior_vehicle_data_consent_response.h @@ -34,7 +34,9 @@ #define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_COMMANDS_HMI_RC_GET_INTERIOR_VEHICLE_DATA_CONSENT_RESPONSE_H_ #include "application_manager/commands/response_from_hmi.h" +#include "rc_rpc_plugin/commands/rc_command_request.h" #include "rc_rpc_plugin/resource_allocation_manager.h" +#include "rc_rpc_plugin/interior_data_cache.h" #include "utils/macro.h" namespace rc_rpc_plugin { @@ -54,12 +56,8 @@ class RCGetInteriorVehicleDataConsentResponse * @param resource_allocation_manager ResourceAllocationManager **/ RCGetInteriorVehicleDataConsentResponse( - 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, - ResourceAllocationManager& resource_allocation_manager); + const application_manager::commands::MessageSharedPtr& message, + const RCCommandParams& params); void Run() OVERRIDE; diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/hmi/rc_get_interior_vehicle_data_request.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/hmi/rc_get_interior_vehicle_data_request.h index 9f7b1211b7..a88a39aa7a 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/hmi/rc_get_interior_vehicle_data_request.h +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/hmi/rc_get_interior_vehicle_data_request.h @@ -34,7 +34,9 @@ #define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_COMMANDS_HMI_RC_GET_INTERIOR_VEHICLE_DATA_REQUEST_H_ #include "application_manager/commands/request_to_hmi.h" +#include "rc_rpc_plugin/commands/rc_command_request.h" #include "rc_rpc_plugin/resource_allocation_manager.h" +#include "rc_rpc_plugin/interior_data_cache.h" #include "utils/macro.h" namespace rc_rpc_plugin { @@ -45,12 +47,8 @@ class RCGetInteriorVehicleDataRequest : public application_manager::commands::RequestToHMI { public: RCGetInteriorVehicleDataRequest( - 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, - ResourceAllocationManager& resource_allocation_manager); + const application_manager::commands::MessageSharedPtr& message, + const RCCommandParams& params); void Run() OVERRIDE; ~RCGetInteriorVehicleDataRequest(); diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/hmi/rc_get_interior_vehicle_data_response.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/hmi/rc_get_interior_vehicle_data_response.h index 28f9b4b9c7..c9e5d39d1d 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/hmi/rc_get_interior_vehicle_data_response.h +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/hmi/rc_get_interior_vehicle_data_response.h @@ -34,7 +34,9 @@ #define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_COMMANDS_HMI_RC_GET_INTERIOR_VEHICLE_DATA_RESPONSE_H_ #include "application_manager/commands/response_from_hmi.h" +#include "rc_rpc_plugin/commands/rc_command_request.h" #include "rc_rpc_plugin/resource_allocation_manager.h" +#include "rc_rpc_plugin/interior_data_cache.h" #include "utils/macro.h" namespace rc_rpc_plugin { @@ -45,12 +47,8 @@ class RCGetInteriorVehicleDataResponse : public application_manager::commands::ResponseFromHMI { public: RCGetInteriorVehicleDataResponse( - 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, - ResourceAllocationManager& resource_allocation_manager); + const application_manager::commands::MessageSharedPtr& message, + const RCCommandParams& params); void Run() OVERRIDE; diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/hmi/rc_on_interior_vehicle_data_notification.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/hmi/rc_on_interior_vehicle_data_notification.h index 0afa613c7c..aeb0a06d22 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/hmi/rc_on_interior_vehicle_data_notification.h +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/hmi/rc_on_interior_vehicle_data_notification.h @@ -30,11 +30,13 @@ POSSIBILITY OF SUCH DAMAGE. */ -#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_COMMANDS_HMI_RC_ON_INTERIOR_VEHICLE_DATA_NOTIFICATION_H -#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_COMMANDS_HMI_RC_ON_INTERIOR_VEHICLE_DATA_NOTIFICATION_H +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_COMMANDS_HMI_RC_ON_INTERIOR_VEHICLE_DATA_NOTIFICATION_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_COMMANDS_HMI_RC_ON_INTERIOR_VEHICLE_DATA_NOTIFICATION_H_ #include "application_manager/commands/notification_from_hmi.h" +#include "rc_rpc_plugin/commands/rc_command_request.h" #include "rc_rpc_plugin/resource_allocation_manager.h" +#include "rc_rpc_plugin/interior_data_cache.h" #include "utils/macro.h" namespace rc_rpc_plugin { @@ -54,12 +56,8 @@ class RCOnInteriorVehicleDataNotification * @param resource_allocation_manager ResourceAllocationManager **/ RCOnInteriorVehicleDataNotification( - 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, - ResourceAllocationManager& resource_allocation_manager); + const application_manager::commands::MessageSharedPtr& message, + const RCCommandParams& params); ~RCOnInteriorVehicleDataNotification(); @@ -71,4 +69,4 @@ class RCOnInteriorVehicleDataNotification } // namespace commands } // namespace rc_rpc_plugin -#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_COMMANDS_HMI_RC_ON_INTERIOR_VEHICLE_DATA_NOTIFICATION_H +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_COMMANDS_HMI_RC_ON_INTERIOR_VEHICLE_DATA_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/hmi/rc_on_remote_control_settings_notification.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/hmi/rc_on_remote_control_settings_notification.h index b9ab821176..7aa1aa3dba 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/hmi/rc_on_remote_control_settings_notification.h +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/hmi/rc_on_remote_control_settings_notification.h @@ -30,15 +30,18 @@ POSSIBILITY OF SUCH DAMAGE. */ -#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_COMMANDS_HMI_RC_ON_REMOTE_CONTROL_SETTINGS_NOTIFICATION_H -#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_COMMANDS_HMI_RC_ON_REMOTE_CONTROL_SETTINGS_NOTIFICATION_H +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_COMMANDS_HMI_RC_ON_REMOTE_CONTROL_SETTINGS_NOTIFICATION_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_COMMANDS_HMI_RC_ON_REMOTE_CONTROL_SETTINGS_NOTIFICATION_H_ #include "application_manager/commands/notification_from_hmi.h" +#include "rc_rpc_plugin/commands/rc_command_request.h" +#include "rc_rpc_plugin/interior_data_cache.h" #include "rc_rpc_plugin/resource_allocation_manager.h" #include "utils/macro.h" namespace rc_rpc_plugin { namespace app_mngr = application_manager; +class InteriorDataManager; namespace commands { class RCOnRemoteControlSettingsNotification @@ -54,12 +57,8 @@ class RCOnRemoteControlSettingsNotification * @param resource_allocation_manager ResourceAllocationManager **/ RCOnRemoteControlSettingsNotification( - 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, - rc_rpc_plugin::ResourceAllocationManager& resource_allocation_manager); + const application_manager::commands::MessageSharedPtr& message, + const RCCommandParams& params); /** * @brief Execute command **/ @@ -69,7 +68,7 @@ class RCOnRemoteControlSettingsNotification private: ResourceAllocationManager& resource_allocation_manager_; - + InteriorDataManager& interior_data_manager_; /** * @brief Disalows RC functionality for all RC apps * All registered apps will be unsubsribed from OnInteriorVehicleData @@ -80,4 +79,4 @@ class RCOnRemoteControlSettingsNotification } // namespace commands } // namespace rc_rpc_plugin -#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_COMMANDS_HMI_RC_ON_REMOTE_CONTROL_SETTINGS_NOTIFICATION_H +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_COMMANDS_HMI_RC_ON_REMOTE_CONTROL_SETTINGS_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/hmi/rc_set_interior_vehicle_data_request.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/hmi/rc_set_interior_vehicle_data_request.h index 194b423b1a..69b48bfecf 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/hmi/rc_set_interior_vehicle_data_request.h +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/hmi/rc_set_interior_vehicle_data_request.h @@ -34,7 +34,9 @@ #define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_COMMANDS_HMI_RC_SET_INTERIOR_VEHICLE_DATA_REQUEST_H_ #include "application_manager/commands/request_to_hmi.h" +#include "rc_rpc_plugin/commands/rc_command_request.h" #include "rc_rpc_plugin/resource_allocation_manager.h" +#include "rc_rpc_plugin/interior_data_cache.h" #include "utils/macro.h" namespace rc_rpc_plugin { @@ -54,12 +56,8 @@ class RCSetInteriorVehicleDataRequest * @param resource_allocation_manager ResourceAllocationManager **/ RCSetInteriorVehicleDataRequest( - 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, - ResourceAllocationManager& resource_allocation_manager); + const application_manager::commands::MessageSharedPtr& message, + const RCCommandParams& params); void Run() OVERRIDE; ~RCSetInteriorVehicleDataRequest(); }; diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/hmi/rc_set_interior_vehicle_data_response.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/hmi/rc_set_interior_vehicle_data_response.h index f23acda4d4..8a63503220 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/hmi/rc_set_interior_vehicle_data_response.h +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/hmi/rc_set_interior_vehicle_data_response.h @@ -30,11 +30,13 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_COMMANDS_HMI_SET_INTERIOR_VEHICLE_DATA_RESPONSE_H -#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_COMMANDS_HMI_SET_INTERIOR_VEHICLE_DATA_RESPONSE_H +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_COMMANDS_HMI_RC_SET_INTERIOR_VEHICLE_DATA_RESPONSE_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_COMMANDS_HMI_RC_SET_INTERIOR_VEHICLE_DATA_RESPONSE_H_ #include "application_manager/commands/response_from_hmi.h" +#include "rc_rpc_plugin/commands/rc_command_request.h" #include "rc_rpc_plugin/resource_allocation_manager.h" +#include "rc_rpc_plugin/interior_data_cache.h" #include "utils/macro.h" namespace rc_rpc_plugin { @@ -54,12 +56,8 @@ class RCSetInteriorVehicleDataResponse * @param resource_allocation_manager ResourceAllocationManager **/ RCSetInteriorVehicleDataResponse( - 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, - ResourceAllocationManager& resource_allocation_manager); + const application_manager::commands::MessageSharedPtr& message, + const RCCommandParams& params); void Run() OVERRIDE; @@ -68,4 +66,4 @@ class RCSetInteriorVehicleDataResponse } // namespace commands } // namespace rc_rpc_plugin -#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_COMMANDS_HMI_SET_INTERIOR_VEHICLE_DATA_RESPONSE_H +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_COMMANDS_HMI_RC_SET_INTERIOR_VEHICLE_DATA_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/button_press_request.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/button_press_request.h index fa89c10bf9..d6ecfd0128 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/button_press_request.h +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/button_press_request.h @@ -30,8 +30,8 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_COMMANDS_BUTTON_PRESS_REQUEST_H -#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_COMMANDS_BUTTON_PRESS_REQUEST_H +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_COMMANDS_MOBILE_BUTTON_PRESS_REQUEST_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_COMMANDS_MOBILE_BUTTON_PRESS_REQUEST_H_ #include "rc_rpc_plugin/commands/rc_command_request.h" @@ -41,12 +41,9 @@ namespace app_mngr = application_manager; namespace commands { class ButtonPressRequest : public RCCommandRequest { public: - ButtonPressRequest(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, - ResourceAllocationManager& resource_allocation_manager); + ButtonPressRequest( + const application_manager::commands::MessageSharedPtr& message, + const RCCommandParams& params); /** * @brief Execute command @@ -96,4 +93,4 @@ class ButtonPressRequest : public RCCommandRequest { } // namespace commands } // namespace rc_rpc_plugin -#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_COMMANDS_BUTTON_PRESS_REQUEST_H +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_COMMANDS_MOBILE_BUTTON_PRESS_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/button_press_response.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/button_press_response.h index 16d7b0e3fe..0f3964494e 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/button_press_response.h +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/button_press_response.h @@ -30,11 +30,13 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_COMMANDS_BUTTON_PRESS_RESPONSE_H -#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_COMMANDS_BUTTON_PRESS_RESPONSE_H +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_COMMANDS_MOBILE_BUTTON_PRESS_RESPONSE_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_COMMANDS_MOBILE_BUTTON_PRESS_RESPONSE_H_ #include "application_manager/commands/command_response_impl.h" #include "rc_rpc_plugin/resource_allocation_manager.h" +#include "rc_rpc_plugin/commands/rc_command_request.h" +#include "rc_rpc_plugin/interior_data_cache.h" #include "utils/macro.h" namespace rc_rpc_plugin { @@ -44,12 +46,9 @@ namespace commands { class ButtonPressResponse : public application_manager::commands::CommandResponseImpl { public: - ButtonPressResponse(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, - ResourceAllocationManager& resource_allocation_manager); + ButtonPressResponse( + const application_manager::commands::MessageSharedPtr& message, + const RCCommandParams& params); void Run() OVERRIDE; /** * @brief ButtonPressResponse class destructor @@ -59,4 +58,4 @@ class ButtonPressResponse } // namespace commands } // namespace rc_rpc_plugin -#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_COMMANDS_BUTTON_PRESS_RESPONSE_H +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_COMMANDS_MOBILE_BUTTON_PRESS_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/get_interior_vehicle_data_request.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/get_interior_vehicle_data_request.h index 2ffb770159..debc78eaa1 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/get_interior_vehicle_data_request.h +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/get_interior_vehicle_data_request.h @@ -43,12 +43,8 @@ namespace commands { class GetInteriorVehicleDataRequest : public RCCommandRequest { public: GetInteriorVehicleDataRequest( - 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, - ResourceAllocationManager& resource_allocation_manager); + const application_manager::commands::MessageSharedPtr& message, + const RCCommandParams& params); /** * @brief Execute command */ diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/get_interior_vehicle_data_response.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/get_interior_vehicle_data_response.h index 78148ab7df..bf8208edc2 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/get_interior_vehicle_data_response.h +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/get_interior_vehicle_data_response.h @@ -30,11 +30,13 @@ POSSIBILITY OF SUCH DAMAGE. */ -#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_COMMANDS_GET_INTERIOR_VEHICLE_DATA_RESPONSE_H -#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_COMMANDS_GET_INTERIOR_VEHICLE_DATA_RESPONSE_H +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_COMMANDS_MOBILE_GET_INTERIOR_VEHICLE_DATA_RESPONSE_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_COMMANDS_MOBILE_GET_INTERIOR_VEHICLE_DATA_RESPONSE_H_ #include "application_manager/commands/command_response_impl.h" +#include "rc_rpc_plugin/commands/rc_command_request.h" #include "rc_rpc_plugin/resource_allocation_manager.h" +#include "rc_rpc_plugin/interior_data_cache.h" #include "utils/macro.h" namespace rc_rpc_plugin { @@ -45,12 +47,8 @@ class GetInteriorVehicleDataResponse : public application_manager::commands::CommandResponseImpl { public: GetInteriorVehicleDataResponse( - 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, - ResourceAllocationManager& resource_allocation_manager); + const application_manager::commands::MessageSharedPtr& message, + const RCCommandParams& params); void Run() OVERRIDE; @@ -59,4 +57,4 @@ class GetInteriorVehicleDataResponse } // namespace commands } // namespace rc_rpc_plugin -#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_COMMANDS_GET_INTERIOR_VEHICLE_DATA_RESPONSE_H +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_COMMANDS_MOBILE_GET_INTERIOR_VEHICLE_DATA_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/on_interior_vehicle_data_notification.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/on_interior_vehicle_data_notification.h index 20a7e69868..f018e2daf4 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/on_interior_vehicle_data_notification.h +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/on_interior_vehicle_data_notification.h @@ -36,6 +36,8 @@ #include #include "application_manager/commands/command_notification_impl.h" #include "rc_rpc_plugin/resource_allocation_manager.h" +#include "rc_rpc_plugin/interior_data_cache.h" +#include "rc_rpc_plugin/commands/rc_command_request.h" #include "utils/macro.h" namespace rc_rpc_plugin { @@ -46,18 +48,17 @@ class OnInteriorVehicleDataNotification : public application_manager::commands::CommandNotificationImpl { public: OnInteriorVehicleDataNotification( - 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, - ResourceAllocationManager& resource_allocation_manager); + const application_manager::commands::MessageSharedPtr& message, + const RCCommandParams& params); void Run() OVERRIDE; std::string ModuleType(); ~OnInteriorVehicleDataNotification(); + + private: + InteriorDataCache& interior_data_cache_; }; } // namespace commands } // namespace rc_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/set_interior_vehicle_data_request.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/set_interior_vehicle_data_request.h index 6e7cf05d90..d5de4981c6 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/set_interior_vehicle_data_request.h +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/set_interior_vehicle_data_request.h @@ -30,8 +30,8 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_COMMANDS_SET_INTERIOR_VEHICLE_DATA_REQUEST_H -#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_COMMANDS_SET_INTERIOR_VEHICLE_DATA_REQUEST_H +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_COMMANDS_MOBILE_SET_INTERIOR_VEHICLE_DATA_REQUEST_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_COMMANDS_MOBILE_SET_INTERIOR_VEHICLE_DATA_REQUEST_H_ #include "rc_rpc_plugin/commands/rc_command_request.h" @@ -42,12 +42,8 @@ namespace commands { class SetInteriorVehicleDataRequest : public RCCommandRequest { public: SetInteriorVehicleDataRequest( - 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, - rc_rpc_plugin::ResourceAllocationManager& resource_allocation_manager); + const application_manager::commands::MessageSharedPtr& message, + const RCCommandParams& params); /** * @brief Execute command @@ -131,4 +127,4 @@ class SetInteriorVehicleDataRequest : public RCCommandRequest { } // namespace commands } // namespace rc_rpc_plugin -#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_COMMANDS_SET_INTERIOR_VEHICLE_DATA_REQUEST_H +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_COMMANDS_MOBILE_SET_INTERIOR_VEHICLE_DATA_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/set_interior_vehicle_data_response.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/set_interior_vehicle_data_response.h index 5661a57c07..1ab5ccc6bc 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/set_interior_vehicle_data_response.h +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/set_interior_vehicle_data_response.h @@ -30,11 +30,13 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_COMMANDS_SET_INTERIOR_VEHICLE_DATA_RESPONSE_H -#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_COMMANDS_SET_INTERIOR_VEHICLE_DATA_RESPONSE_H +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_COMMANDS_MOBILE_SET_INTERIOR_VEHICLE_DATA_RESPONSE_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_COMMANDS_MOBILE_SET_INTERIOR_VEHICLE_DATA_RESPONSE_H_ #include "application_manager/commands/command_response_impl.h" #include "rc_rpc_plugin/resource_allocation_manager.h" +#include "rc_rpc_plugin/interior_data_cache.h" +#include "rc_rpc_plugin/commands/rc_command_request.h" #include "utils/macro.h" namespace rc_rpc_plugin { @@ -45,12 +47,8 @@ class SetInteriorVehicleDataResponse : public application_manager::commands::CommandResponseImpl { public: SetInteriorVehicleDataResponse( - 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, - ResourceAllocationManager& resource_allocation_manager); + const application_manager::commands::MessageSharedPtr& message, + const RCCommandParams& params); void Run() OVERRIDE; @@ -59,4 +57,4 @@ class SetInteriorVehicleDataResponse } // namespace commands } // namespace rc_rpc_plugin -#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_COMMANDS_SET_INTERIOR_VEHICLE_DATA_RESPONSE_H +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_COMMANDS_MOBILE_SET_INTERIOR_VEHICLE_DATA_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/rc_command_params.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/rc_command_params.h new file mode 100644 index 0000000000..8e7ed9c667 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/rc_command_params.h @@ -0,0 +1,64 @@ +/* + 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_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_COMMANDS_RC_COMMAND_PARAMS_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_COMMANDS_RC_COMMAND_PARAMS_H_ + +namespace application_manager { +class ApplicationManager; +namespace rpc_service { +class RPCService; +} +class HMICapabilities; +} + +namespace policy { +class PolicyHandlerInterface; +} + +namespace rc_rpc_plugin { + +class ResourceAllocationManager; +class InteriorDataCache; +class InteriorDataManager; + +struct RCCommandParams { + application_manager::ApplicationManager& application_manager_; + application_manager::rpc_service::RPCService& rpc_service_; + application_manager::HMICapabilities& hmi_capabilities_; + policy::PolicyHandlerInterface& policy_handler_; + rc_rpc_plugin::ResourceAllocationManager& resource_allocation_manager_; + rc_rpc_plugin::InteriorDataCache& interior_data_cache_; + rc_rpc_plugin::InteriorDataManager& interior_data_manager_; +}; +} +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_COMMANDS_RC_COMMAND_PARAMS_H_ diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/rc_command_request.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/rc_command_request.h index 7c5e6f0ebc..ce95617b6c 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/rc_command_request.h +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/rc_command_request.h @@ -30,12 +30,14 @@ POSSIBILITY OF SUCH DAMAGE. */ -#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_COMMANDS_RC_COMMAND_REQUEST_H -#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_COMMANDS_RC_COMMAND_REQUEST_H +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_COMMANDS_RC_COMMAND_REQUEST_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_COMMANDS_RC_COMMAND_REQUEST_H_ #include "rc_rpc_plugin/resource_allocation_manager.h" #include "rc_rpc_plugin/rc_app_extension.h" #include "application_manager/commands/command_request_impl.h" +#include "rc_rpc_plugin/interior_data_cache.h" +#include "rc_rpc_plugin/commands/rc_command_params.h" namespace rc_rpc_plugin { namespace app_mngr = application_manager; @@ -56,12 +58,8 @@ class RCCommandRequest : public app_mngr::commands::CommandRequestImpl { * @param resource_allocation_manager ResourceAllocationManager **/ RCCommandRequest( - 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_handl, - rc_rpc_plugin::ResourceAllocationManager& resource_allocation_manager); + const application_manager::commands::MessageSharedPtr& message, + const RCCommandParams& params); virtual ~RCCommandRequest(); @@ -73,9 +71,11 @@ class RCCommandRequest : public app_mngr::commands::CommandRequestImpl { protected: bool is_subscribed; - ResourceAllocationManager& resource_allocation_manager_; bool auto_allowed_; + ResourceAllocationManager& resource_allocation_manager_; + InteriorDataCache& interior_data_cache_; + InteriorDataManager& interior_data_manager_; /** * @brief AcquireResource try to allocate resource for application * In case if allocation of resource is not required, return ALLOWED by @@ -169,4 +169,4 @@ class RCCommandRequest : public app_mngr::commands::CommandRequestImpl { } } -#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_COMMANDS_RC_COMMAND_REQUEST_H +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_COMMANDS_RC_COMMAND_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_app_extension.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_app_extension.h index 72f29c7de1..8cf107d3d8 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_app_extension.h +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_app_extension.h @@ -30,8 +30,8 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#ifndef SRC_COMPONENTS_REMOTE_CONTROL_INCLUDE_REMOTE_CONTROL_RC_APP_EXTENSION_H_ -#define SRC_COMPONENTS_REMOTE_CONTROL_INCLUDE_REMOTE_CONTROL_RC_APP_EXTENSION_H_ +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_RC_APP_EXTENSION_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_RC_APP_EXTENSION_H_ #include #include @@ -84,4 +84,4 @@ typedef std::shared_ptr RCAppExtensionPtr; } // namespace rc_rpc_plugin -#endif // SRC_COMPONENTS_REMOTE_CONTROL_INCLUDE_REMOTE_CONTROL_RC_APP_EXTENSION_H_ +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_RC_APP_EXTENSION_H_ diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_command_factory.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_command_factory.h index 6f101cefef..56be342b56 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_command_factory.h +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_command_factory.h @@ -30,8 +30,8 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_RC_COMMAND_FACTORY_H -#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_RC_COMMAND_FACTORY_H +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_RC_COMMAND_FACTORY_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_RC_COMMAND_FACTORY_H_ #include #include "application_manager/command_factory.h" @@ -41,6 +41,8 @@ #include "application_manager/hmi_capabilities.h" #include "application_manager/policies/policy_handler_interface.h" #include "rc_rpc_plugin/resource_allocation_manager.h" +#include "rc_rpc_plugin/interior_data_cache.h" +#include "rc_rpc_plugin/commands/rc_command_params.h" #include "utils/macro.h" namespace rc_rpc_plugin { @@ -56,11 +58,7 @@ class RCCommandFactory : public application_manager::CommandFactory { * @param policy_handler PolicyHandlerInterface * @param allocation_manager ResourceAllocationManager **/ - RCCommandFactory(app_mngr::ApplicationManager& app_manager, - app_mngr::rpc_service::RPCService& rpc_service, - app_mngr::HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handler, - ResourceAllocationManager& allocation_manager); + RCCommandFactory(const RCCommandParams& params); application_manager::CommandSharedPtr CreateCommand( const app_mngr::commands::MessageSharedPtr& message, app_mngr::commands::Command::CommandSource source) OVERRIDE; @@ -84,11 +82,7 @@ class RCCommandFactory : public application_manager::CommandFactory { hmi_apis::FunctionID::eType id, hmi_apis::messageType::eType message_type) const; - app_mngr::ApplicationManager& app_manager_; - app_mngr::rpc_service::RPCService& rpc_service_; - app_mngr::HMICapabilities& hmi_capabilities_; - PolicyHandlerInterface& policy_handler_; - ResourceAllocationManager& allocation_manager_; + RCCommandParams params_; }; } // namespace rc_rpc_plugin -#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_RC_COMMAND_FACTORY_H +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_RC_COMMAND_FACTORY_H_ diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_module_constants.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_module_constants.h index a38887572c..e80507445b 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_module_constants.h +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_module_constants.h @@ -30,8 +30,8 @@ POSSIBILITY OF SUCH DAMAGE. */ -#ifndef SRC_COMPONENTS_REMOTE_CONTROL_INCLUDE_REMOTE_CONTROL_RC_MODULE_CONSTANTS_H_ -#define SRC_COMPONENTS_REMOTE_CONTROL_INCLUDE_REMOTE_CONTROL_RC_MODULE_CONSTANTS_H_ +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_RC_MODULE_CONSTANTS_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_RC_MODULE_CONSTANTS_H_ namespace rc_rpc_plugin { @@ -274,4 +274,4 @@ const char kAskDriver[] = "ASK_DRIVER"; } // namespace remote_control -#endif // SRC_COMPONENTS_REMOTE_CONTROL_INCLUDE_REMOTE_CONTROL_RC_MODULE_CONSTANTS_H_ +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_RC_MODULE_CONSTANTS_H_ diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_rpc_plugin.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_rpc_plugin.h index 910eda6d3c..ae88ed9cc0 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_rpc_plugin.h +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_rpc_plugin.h @@ -30,15 +30,21 @@ POSSIBILITY OF SUCH DAMAGE. */ -#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_RC_PLUGIN_H -#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_RC_PLUGIN_H +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_RC_RPC_PLUGIN_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_RC_RPC_PLUGIN_H_ + +#include + #include "application_manager/plugin_manager/rpc_plugin.h" #include "application_manager/command_factory.h" #include "rc_rpc_plugin/resource_allocation_manager.h" +#include "rc_rpc_plugin/interior_data_cache.h" +#include "rc_rpc_plugin/interior_data_manager.h" namespace rc_rpc_plugin { namespace plugins = application_manager::plugin_manager; namespace app_mngr = application_manager; + class RCRPCPlugin : public plugins::RPCPlugin { public: /** @@ -72,6 +78,7 @@ class RCRPCPlugin : public plugins::RPCPlugin { * @return plugins command factory */ app_mngr::CommandFactory& GetCommandFactory() OVERRIDE; + /** * @brief OnPolicyEvent Processes policy related events * @param event Policy event @@ -92,11 +99,15 @@ class RCRPCPlugin : public plugins::RPCPlugin { application_manager::ApplicationManager& app_mngr); private: + application_manager::rpc_service::RPCService* rpc_service_; + application_manager::ApplicationManager* app_mngr_; std::unique_ptr command_factory_; std::unique_ptr resource_allocation_manager_; + std::unique_ptr interior_data_cache_; + std::unique_ptr interior_data_manager_; }; } // namespace rc_rpc_plugin extern "C" application_manager::plugin_manager::RPCPlugin* Create(); -#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_RC_PLUGIN_H +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_RC_RPC_PLUGIN_H_ 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 91d1b09fca..2f9659f0ec 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 @@ -30,8 +30,8 @@ POSSIBILITY OF SUCH DAMAGE. */ -#ifndef SRC_COMPONENTS_REMOTE_CONTROL_INCLUDE_REMOTE_CONTROL_RESOURCE_ALLOCATION_H -#define SRC_COMPONENTS_REMOTE_CONTROL_INCLUDE_REMOTE_CONTROL_RESOURCE_ALLOCATION_H +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_RESOURCE_ALLOCATION_MANAGER_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_RESOURCE_ALLOCATION_MANAGER_H_ #include #include "utils/macro.h" @@ -178,4 +178,4 @@ class ResourceAllocationManager { }; } // namespace rc_rpc_plugin -#endif // SRC_COMPONENTS_REMOTE_CONTROL_INCLUDE_REMOTE_CONTROL_RESOURCE_ALLOCATION_H +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_RESOURCE_ALLOCATION_MANAGER_H_ 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 d6124a026b..7ba2aefcdc 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 @@ -30,8 +30,8 @@ POSSIBILITY OF SUCH DAMAGE. */ -#ifndef SRC_COMPONENTS_REMOTE_CONTROL_INCLUDE_REMOTE_CONTROL_RESOURCE_ALLOCATION_IMPL_H -#define SRC_COMPONENTS_REMOTE_CONTROL_INCLUDE_REMOTE_CONTROL_RESOURCE_ALLOCATION_IMPL_H +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_RESOURCE_ALLOCATION_MANAGER_IMPL_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_RESOURCE_ALLOCATION_MANAGER_IMPL_H_ #include "rc_rpc_plugin/resource_allocation_manager.h" #include "application_manager/application_impl.h" #include "rc_rpc_plugin/rc_app_extension.h" @@ -199,7 +199,6 @@ class ResourceAllocationManagerImpl : public ResourceAllocationManager { void SetResourceFree(const std::string& module_type, const uint32_t app_id); std::vector all_supported_modules(); - /** * @brief AllocatedResources contains link between resource and application * owning that resource @@ -231,4 +230,4 @@ class ResourceAllocationManagerImpl : public ResourceAllocationManager { }; } // rc_rpc_plugin -#endif // SRC_COMPONENTS_REMOTE_CONTROL_INCLUDE_REMOTE_CONTROL_RESOURCE_ALLOCATION_IMPL_H +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_RESOURCE_ALLOCATION_MANAGER_IMPL_H_ diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_button_press_request.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_button_press_request.cc index d392420238..75faf5db8c 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_button_press_request.cc +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_button_press_request.cc @@ -31,6 +31,8 @@ */ #include "rc_rpc_plugin/commands/hmi/rc_button_press_request.h" +#include "rc_rpc_plugin/resource_allocation_manager_impl.h" + #include "utils/macro.h" namespace rc_rpc_plugin { @@ -38,18 +40,12 @@ namespace commands { RCButtonPressRequest::RCButtonPressRequest( 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, - ResourceAllocationManager& resource_allocation_manager) - : application_manager::commands::RequestToHMI(message, - application_manager, - rpc_service, - hmi_capabilities, - policy_handle) { - UNUSED(resource_allocation_manager); -} + const RCCommandParams& params) + : app_mngr::commands::RequestToHMI(message, + params.application_manager_, + params.rpc_service_, + params.hmi_capabilities_, + params.policy_handler_) {} RCButtonPressRequest::~RCButtonPressRequest() {} diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_button_press_response.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_button_press_response.cc index c7c11354c7..5c1691ed7b 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_button_press_response.cc +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_button_press_response.cc @@ -37,19 +37,14 @@ namespace rc_rpc_plugin { namespace commands { RCButtonPressResponse::RCButtonPressResponse( - 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, - ResourceAllocationManager& resource_allocation_manager) - : application_manager::commands::ResponseFromHMI(message, - application_manager, - rpc_service, - hmi_capabilities, - policy_handle) { - UNUSED(resource_allocation_manager); -} + const application_manager::commands::MessageSharedPtr& message, + const RCCommandParams& params) + : application_manager::commands::ResponseFromHMI( + message, + params.application_manager_, + params.rpc_service_, + params.hmi_capabilities_, + params.policy_handler_) {} void RCButtonPressResponse::Run() { LOG4CXX_AUTO_TRACE(logger_); diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_get_interior_vehicle_data_consent_request.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_get_interior_vehicle_data_consent_request.cc index 875f1c8fbf..774ee04677 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_get_interior_vehicle_data_consent_request.cc +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_get_interior_vehicle_data_consent_request.cc @@ -38,18 +38,12 @@ namespace commands { RCGetInteriorVehicleDataConsentRequest::RCGetInteriorVehicleDataConsentRequest( 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, - ResourceAllocationManager& resource_allocation_manager) + const RCCommandParams& params) : application_manager::commands::RequestToHMI(message, - application_manager, - rpc_service, - hmi_capabilities, - policy_handle) { - UNUSED(resource_allocation_manager); -} + params.application_manager_, + params.rpc_service_, + params.hmi_capabilities_, + params.policy_handler_) {} RCGetInteriorVehicleDataConsentRequest:: ~RCGetInteriorVehicleDataConsentRequest() {} diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_get_interior_vehicle_data_consent_response.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_get_interior_vehicle_data_consent_response.cc index 3a9bb12df1..3244857656 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_get_interior_vehicle_data_consent_response.cc +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_get_interior_vehicle_data_consent_response.cc @@ -38,19 +38,14 @@ namespace commands { RCGetInteriorVehicleDataConsentResponse:: RCGetInteriorVehicleDataConsentResponse( - 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, - ResourceAllocationManager& resource_allocation_manager) - : application_manager::commands::ResponseFromHMI(message, - application_manager, - rpc_service, - hmi_capabilities, - policy_handle) { - UNUSED(resource_allocation_manager); -} + const application_manager::commands::MessageSharedPtr& message, + const RCCommandParams& params) + : application_manager::commands::ResponseFromHMI( + message, + params.application_manager_, + params.rpc_service_, + params.hmi_capabilities_, + params.policy_handler_) {} void RCGetInteriorVehicleDataConsentResponse::Run() { LOG4CXX_AUTO_TRACE(logger_); diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_get_interior_vehicle_data_request.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_get_interior_vehicle_data_request.cc index 0bb5f73c1b..c7baf75e27 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_get_interior_vehicle_data_request.cc +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_get_interior_vehicle_data_request.cc @@ -38,18 +38,12 @@ namespace commands { RCGetInteriorVehicleDataRequest::RCGetInteriorVehicleDataRequest( 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, - ResourceAllocationManager& resource_allocation_manager) + const RCCommandParams& params) : application_manager::commands::RequestToHMI(message, - application_manager, - rpc_service, - hmi_capabilities, - policy_handle) { - UNUSED(resource_allocation_manager); -} + params.application_manager_, + params.rpc_service_, + params.hmi_capabilities_, + params.policy_handler_) {} RCGetInteriorVehicleDataRequest::~RCGetInteriorVehicleDataRequest() {} diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_get_interior_vehicle_data_response.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_get_interior_vehicle_data_response.cc index ab9fe0cc89..e56f9088bc 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_get_interior_vehicle_data_response.cc +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_get_interior_vehicle_data_response.cc @@ -39,18 +39,13 @@ namespace commands { RCGetInteriorVehicleDataResponse::RCGetInteriorVehicleDataResponse( 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, - ResourceAllocationManager& resource_allocation_manager) - : application_manager::commands::ResponseFromHMI(message, - application_manager, - rpc_service, - hmi_capabilities, - policy_handle) { - UNUSED(resource_allocation_manager); -} + const RCCommandParams& params) + : application_manager::commands::ResponseFromHMI( + message, + params.application_manager_, + params.rpc_service_, + params.hmi_capabilities_, + params.policy_handler_) {} void RCGetInteriorVehicleDataResponse::Run() { LOG4CXX_AUTO_TRACE(logger_); diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_on_interior_vehicle_data_notification.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_on_interior_vehicle_data_notification.cc index 3f757fab2e..0117003f11 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_on_interior_vehicle_data_notification.cc +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_on_interior_vehicle_data_notification.cc @@ -39,18 +39,13 @@ namespace commands { RCOnInteriorVehicleDataNotification::RCOnInteriorVehicleDataNotification( 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, - ResourceAllocationManager& resource_allocation_manager) - : application_manager::commands::NotificationFromHMI(message, - application_manager, - rpc_service, - hmi_capabilities, - policy_handle) { - UNUSED(resource_allocation_manager); -} + const RCCommandParams& params) + : application_manager::commands::NotificationFromHMI( + message, + params.application_manager_, + params.rpc_service_, + params.hmi_capabilities_, + params.policy_handler_) {} RCOnInteriorVehicleDataNotification::~RCOnInteriorVehicleDataNotification() {} diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_on_remote_control_settings_notification.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_on_remote_control_settings_notification.cc index 8bcb6b08ed..fd404601a3 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_on_remote_control_settings_notification.cc +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_on_remote_control_settings_notification.cc @@ -32,7 +32,9 @@ #include "rc_rpc_plugin/commands/hmi/rc_on_remote_control_settings_notification.h" #include "rc_rpc_plugin/rc_rpc_plugin.h" +#include "rc_rpc_plugin/interior_data_manager.h" #include "rc_rpc_plugin/rc_module_constants.h" +#include "rc_rpc_plugin/rc_helpers.h" #include "utils/macro.h" namespace rc_rpc_plugin { @@ -49,17 +51,15 @@ CREATE_LOGGERPTR_GLOBAL(logger_, "RemoteControlModule") RCOnRemoteControlSettingsNotification::RCOnRemoteControlSettingsNotification( 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, - ResourceAllocationManager& resource_allocation_manager) - : application_manager::commands::NotificationFromHMI(message, - application_manager, - rpc_service, - hmi_capabilities, - policy_handle) - , resource_allocation_manager_(resource_allocation_manager) {} + const RCCommandParams& params) + : application_manager::commands::NotificationFromHMI( + message, + params.application_manager_, + params.rpc_service_, + params.hmi_capabilities_, + params.policy_handler_) + , resource_allocation_manager_(params.resource_allocation_manager_) + , interior_data_manager_(params.interior_data_manager_) {} RCOnRemoteControlSettingsNotification:: ~RCOnRemoteControlSettingsNotification() {} diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_set_interior_vehicle_data_request.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_set_interior_vehicle_data_request.cc index 69ceed17e9..f0d5ecc177 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_set_interior_vehicle_data_request.cc +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_set_interior_vehicle_data_request.cc @@ -38,18 +38,12 @@ namespace commands { RCSetInteriorVehicleDataRequest::RCSetInteriorVehicleDataRequest( 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, - ResourceAllocationManager& resource_allocation_manager) + const RCCommandParams& params) : application_manager::commands::RequestToHMI(message, - application_manager, - rpc_service, - hmi_capabilities, - policy_handle) { - UNUSED(resource_allocation_manager); -} + params.application_manager_, + params.rpc_service_, + params.hmi_capabilities_, + params.policy_handler_) {} RCSetInteriorVehicleDataRequest::~RCSetInteriorVehicleDataRequest() {} void RCSetInteriorVehicleDataRequest::Run() { diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_set_interior_vehicle_data_response.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_set_interior_vehicle_data_response.cc index 42c2452943..56d924debe 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_set_interior_vehicle_data_response.cc +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_set_interior_vehicle_data_response.cc @@ -38,18 +38,13 @@ namespace commands { RCSetInteriorVehicleDataResponse::RCSetInteriorVehicleDataResponse( 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, - ResourceAllocationManager& resource_allocation_manager) - : application_manager::commands::ResponseFromHMI(message, - application_manager, - rpc_service, - hmi_capabilities, - policy_handle) { - UNUSED(resource_allocation_manager); -} + const RCCommandParams& params) + : application_manager::commands::ResponseFromHMI( + message, + params.application_manager_, + params.rpc_service_, + params.hmi_capabilities_, + params.policy_handler_) {} void RCSetInteriorVehicleDataResponse::Run() { LOG4CXX_AUTO_TRACE(logger_); diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/button_press_request.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/button_press_request.cc index 88e4ebaa3c..05e44cfb44 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/button_press_request.cc +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/button_press_request.cc @@ -50,17 +50,8 @@ typedef std::map ButtonsMap; ButtonPressRequest::ButtonPressRequest( 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, - ResourceAllocationManager& resource_allocation_manager) - : RCCommandRequest(message, - application_manager, - rpc_service, - hmi_capabilities, - policy_handle, - resource_allocation_manager) {} + const RCCommandParams& params) + : RCCommandRequest(message, params) {} ButtonPressRequest::~ButtonPressRequest() {} diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/button_press_response.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/button_press_response.cc index dfdb128322..491b0363c9 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/button_press_response.cc +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/button_press_response.cc @@ -38,18 +38,13 @@ namespace commands { ButtonPressResponse::ButtonPressResponse( 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, - ResourceAllocationManager& resource_allocation_manager) - : application_manager::commands::CommandResponseImpl(message, - application_manager, - rpc_service, - hmi_capabilities, - policy_handle) { - UNUSED(resource_allocation_manager); -} + const RCCommandParams& params) + : application_manager::commands::CommandResponseImpl( + message, + params.application_manager_, + params.rpc_service_, + params.hmi_capabilities_, + params.policy_handler_) {} ButtonPressResponse::~ButtonPressResponse() {} void ButtonPressResponse::Run() { diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/get_interior_vehicle_data_request.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/get_interior_vehicle_data_request.cc index f9d65a2635..9e8e0c24ee 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/get_interior_vehicle_data_request.cc +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/get_interior_vehicle_data_request.cc @@ -32,6 +32,8 @@ #include "rc_rpc_plugin/commands/mobile/get_interior_vehicle_data_request.h" #include "rc_rpc_plugin/rc_module_constants.h" +#include "rc_rpc_plugin/rc_helpers.h" +#include "rc_rpc_plugin/rc_rpc_plugin.h" #include "smart_objects/enum_schema_item.h" #include "utils/macro.h" #include "interfaces/MOBILE_API.h" @@ -46,17 +48,9 @@ CREATE_LOGGERPTR_GLOBAL(logger_, "RemoteControlModule") GetInteriorVehicleDataRequest::GetInteriorVehicleDataRequest( 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, - ResourceAllocationManager& resource_allocation_manager) - : RCCommandRequest(message, - application_manager, - rpc_service, - hmi_capabilities, - policy_handle, - resource_allocation_manager) + const RCCommandParams& params) + : RCCommandRequest(message, params) + , excessive_subscription_occured_(false) {} bool CheckIfModuleTypeExistInCapabilities( diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/get_interior_vehicle_data_response.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/get_interior_vehicle_data_response.cc index 18ccc5b497..a7572f1d62 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/get_interior_vehicle_data_response.cc +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/get_interior_vehicle_data_response.cc @@ -38,18 +38,13 @@ namespace commands { GetInteriorVehicleDataResponse::GetInteriorVehicleDataResponse( 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, - ResourceAllocationManager& resource_allocation_manager) - : application_manager::commands::CommandResponseImpl(message, - application_manager, - rpc_service, - hmi_capabilities, - policy_handle) { - UNUSED(resource_allocation_manager); -} + const RCCommandParams& params) + : application_manager::commands::CommandResponseImpl( + message, + params.application_manager_, + params.rpc_service_, + params.hmi_capabilities_, + params.policy_handler_) {} GetInteriorVehicleDataResponse::~GetInteriorVehicleDataResponse() {} void GetInteriorVehicleDataResponse::Run() { diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/on_interior_vehicle_data_notification.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/on_interior_vehicle_data_notification.cc index fca9962fb5..261cdd49b1 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/on_interior_vehicle_data_notification.cc +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/on_interior_vehicle_data_notification.cc @@ -33,6 +33,7 @@ #include "rc_rpc_plugin/commands/mobile/on_interior_vehicle_data_notification.h" #include "rc_rpc_plugin/rc_rpc_plugin.h" #include "rc_rpc_plugin/rc_module_constants.h" +#include "rc_rpc_plugin/rc_helpers.h" #include "smart_objects/enum_schema_item.h" #include "utils/macro.h" @@ -43,18 +44,13 @@ CREATE_LOGGERPTR_GLOBAL(logger_, "RemoteControlModule") OnInteriorVehicleDataNotification::OnInteriorVehicleDataNotification( 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, - ResourceAllocationManager& resource_allocation_manager) + const RCCommandParams& params) : app_mngr::commands::CommandNotificationImpl(message, - application_manager, - rpc_service, - hmi_capabilities, - policy_handler) { - UNUSED(resource_allocation_manager); -} + params.application_manager_, + params.rpc_service_, + params.hmi_capabilities_, + params.policy_handler_) + , interior_data_cache_(params.interior_data_cache_) {} OnInteriorVehicleDataNotification::~OnInteriorVehicleDataNotification() {} diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/set_interior_vehicle_data_request.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/set_interior_vehicle_data_request.cc index f305f88872..e1bec1ce5f 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/set_interior_vehicle_data_request.cc +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/set_interior_vehicle_data_request.cc @@ -142,17 +142,8 @@ CREATE_LOGGERPTR_GLOBAL(logger_, "RemoteControlModule") SetInteriorVehicleDataRequest::SetInteriorVehicleDataRequest( 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, - ResourceAllocationManager& resource_allocation_manager) - : RCCommandRequest(message, - application_manager, - rpc_service, - hmi_capabilities, - policy_handle, - resource_allocation_manager) {} + const RCCommandParams& params) + : RCCommandRequest(message, params) {} SetInteriorVehicleDataRequest::~SetInteriorVehicleDataRequest() {} diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/set_interior_vehicle_data_response.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/set_interior_vehicle_data_response.cc index 2d5d0350e1..4dedd4b5a2 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/set_interior_vehicle_data_response.cc +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/set_interior_vehicle_data_response.cc @@ -1,4 +1,5 @@ #include "rc_rpc_plugin/commands/mobile/set_interior_vehicle_data_response.h" +#include "rc_rpc_plugin/interior_data_cache.h" #include "utils/macro.h" namespace rc_rpc_plugin { @@ -6,18 +7,13 @@ namespace commands { SetInteriorVehicleDataResponse::SetInteriorVehicleDataResponse( 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, - ResourceAllocationManager& resource_allocation_manager) - : application_manager::commands::CommandResponseImpl(message, - application_manager, - rpc_service, - hmi_capabilities, - policy_handle) { - UNUSED(resource_allocation_manager); -} + const RCCommandParams& params) + : application_manager::commands::CommandResponseImpl( + message, + params.application_manager_, + params.rpc_service_, + params.hmi_capabilities_, + params.policy_handler_) {} SetInteriorVehicleDataResponse::~SetInteriorVehicleDataResponse() {} void SetInteriorVehicleDataResponse::Run() { 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 524e4db7fa..9e3308b825 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 @@ -35,6 +35,7 @@ #include "application_manager/message_helper.h" #include "application_manager/hmi_interfaces.h" #include "smart_objects/enum_schema_item.h" +#include "rc_rpc_plugin/interior_data_cache.h" CREATE_LOGGERPTR_GLOBAL(logger_, "RemoteControlModule") @@ -43,18 +44,17 @@ namespace commands { RCCommandRequest::RCCommandRequest( 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, - rc_rpc_plugin::ResourceAllocationManager& resource_allocation_manager) - : application_manager::commands::CommandRequestImpl(message, - application_manager, - rpc_service, - hmi_capabilities, - policy_handle) + const RCCommandParams& params) + : application_manager::commands::CommandRequestImpl( + message, + params.application_manager_, + params.rpc_service_, + params.hmi_capabilities_, + params.policy_handler_) , is_subscribed(false) - , resource_allocation_manager_(resource_allocation_manager) {} + , resource_allocation_manager_(params.resource_allocation_manager_) + , interior_data_cache_(params.interior_data_cache_) + , interior_data_manager_(params.interior_data_manager_) {} RCCommandRequest::~RCCommandRequest() {} diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/rc_command_factory.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/rc_command_factory.cc index 707d35aa0f..ecfc1dcda4 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/rc_command_factory.cc +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/rc_command_factory.cc @@ -29,6 +29,7 @@ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#include #include "rc_rpc_plugin/rc_command_factory.h" #include "rc_rpc_plugin/commands/mobile/button_press_request.h" @@ -53,24 +54,18 @@ #include "interfaces/HMI_API.h" #include "rc_rpc_plugin/resource_allocation_manager.h" +#include "rc_rpc_plugin/interior_data_cache.h" CREATE_LOGGERPTR_GLOBAL(logger_, "RemoteControlModule") namespace application_manager { using rc_rpc_plugin::ResourceAllocationManager; +using rc_rpc_plugin::InteriorDataCache; +using rc_rpc_plugin::RCCommandParams; template class RCCommandCreator : public CommandCreator { public: - RCCommandCreator(ApplicationManager& application_manager, - rpc_service::RPCService& rpc_service, - HMICapabilities& hmi_capabilities, - PolicyHandlerInterface& policy_handler, - ResourceAllocationManager& resource_allocation_manager) - : application_manager_(application_manager) - , rpc_service_(rpc_service) - , hmi_capabilities_(hmi_capabilities) - , policy_handler_(policy_handler) - , resource_allocation_manager_(resource_allocation_manager) {} + RCCommandCreator(const RCCommandParams& params) : params_(params) {} private: bool CanBeCreated() const override { @@ -79,20 +74,11 @@ class RCCommandCreator : public CommandCreator { CommandSharedPtr create( const commands::MessageSharedPtr& message) const override { - CommandSharedPtr command(new RCCommandType(message, - application_manager_, - rpc_service_, - hmi_capabilities_, - policy_handler_, - resource_allocation_manager_)); + CommandSharedPtr command(new RCCommandType(message, params_)); return command; } - ApplicationManager& application_manager_; - RPCService& rpc_service_; - HMICapabilities& hmi_capabilities_; - PolicyHandlerInterface& policy_handler_; - ResourceAllocationManager& resource_allocation_manager_; + RCCommandParams params_; }; struct RCInvalidCommand {}; @@ -100,16 +86,8 @@ struct RCInvalidCommand {}; template <> class RCCommandCreator : public CommandCreator { public: - RCCommandCreator(ApplicationManager& application_manager, - RPCService& rpc_service, - HMICapabilities& hmi_capabilities, - PolicyHandlerInterface& policy_handler, - ResourceAllocationManager& resource_allocation_manager) { - UNUSED(application_manager); - UNUSED(rpc_service); - UNUSED(hmi_capabilities); - UNUSED(policy_handler); - UNUSED(resource_allocation_manager); + RCCommandCreator(const RCCommandParams& params) { + UNUSED(params); } private: @@ -125,49 +103,23 @@ class RCCommandCreator : public CommandCreator { }; struct RCCommandCreatorFactory { - RCCommandCreatorFactory( - ApplicationManager& application_manager, - rpc_service::RPCService& rpc_service, - HMICapabilities& hmi_capabilities, - PolicyHandlerInterface& policy_handler, - ResourceAllocationManager& resource_allocation_manager) - : application_manager_(application_manager) - , rpc_service_(rpc_service) - , hmi_capabilities_(hmi_capabilities) - , policy_handler_(policy_handler) - , resource_allocation_manager_(resource_allocation_manager) {} + RCCommandCreatorFactory(const RCCommandParams& params) : params_(params) {} template CommandCreator& GetCreator() { - static RCCommandCreator res(application_manager_, - rpc_service_, - hmi_capabilities_, - policy_handler_, - resource_allocation_manager_); + LOG4CXX_AUTO_TRACE(logger_); + static RCCommandCreator res(params_); return res; } - ApplicationManager& application_manager_; - RPCService& rpc_service_; - HMICapabilities& hmi_capabilities_; - PolicyHandlerInterface& policy_handler_; - ResourceAllocationManager& resource_allocation_manager_; + const RCCommandParams params_; }; } namespace rc_rpc_plugin { using namespace application_manager; -RCCommandFactory::RCCommandFactory( - app_mngr::ApplicationManager& app_manager, - app_mngr::rpc_service::RPCService& rpc_service, - app_mngr::HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handler, - ResourceAllocationManager& allocation_manager) - : app_manager_(app_manager) - , rpc_service_(rpc_service) - , hmi_capabilities_(hmi_capabilities) - , policy_handler_(policy_handler) - , allocation_manager_(allocation_manager) {} +RCCommandFactory::RCCommandFactory(const RCCommandParams& params) + : params_(params) {} CommandSharedPtr RCCommandFactory::CreateCommand( const app_mngr::commands::MessageSharedPtr& message, @@ -218,11 +170,7 @@ CommandCreator& RCCommandFactory::get_mobile_creator_factory( LOG4CXX_DEBUG(logger_, "CreateMobileCommand function_id: " << id << " message_type: " << message_type); - RCCommandCreatorFactory rc_factory(app_manager_, - rpc_service_, - hmi_capabilities_, - policy_handler_, - allocation_manager_); + RCCommandCreatorFactory rc_factory(params_); switch (id) { case mobile_apis::FunctionID::ButtonPressID: { @@ -259,11 +207,7 @@ CommandCreator& RCCommandFactory::get_hmi_creator_factory( "CreateHMICommand function_id: " << id << " message_type: " << message_type); - RCCommandCreatorFactory rc_factory(app_manager_, - rpc_service_, - hmi_capabilities_, - policy_handler_, - allocation_manager_); + RCCommandCreatorFactory rc_factory(params_); switch (id) { case hmi_apis::FunctionID::Buttons_ButtonPress: { diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/rc_rpc_plugin.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/rc_rpc_plugin.cc index 984d6ec9a0..1579412cac 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/rc_rpc_plugin.cc +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/rc_rpc_plugin.cc @@ -34,10 +34,15 @@ #include "rc_rpc_plugin/rc_command_factory.h" #include "rc_rpc_plugin/rc_app_extension.h" #include "rc_rpc_plugin/resource_allocation_manager_impl.h" +#include "rc_rpc_plugin/interior_data_cache_impl.h" +#include "rc_rpc_plugin/interior_data_manager_impl.h" +#include "rc_rpc_plugin/rc_helpers.h" #include "utils/helpers.h" #include namespace rc_rpc_plugin { +CREATE_LOGGERPTR_GLOBAL(logger_, "RemoteControlModule"); + namespace plugins = application_manager::plugin_manager; bool RCRPCPlugin::Init( @@ -45,14 +50,22 @@ bool RCRPCPlugin::Init( application_manager::rpc_service::RPCService& rpc_service, application_manager::HMICapabilities& hmi_capabilities, policy::PolicyHandlerInterface& policy_handler) { + interior_data_cache_.reset(new InteriorDataCacheImpl()); + interior_data_manager_.reset(new InteriorDataManagerImpl( + *this, *interior_data_cache_, app_manager, rpc_service)); + resource_allocation_manager_.reset( new ResourceAllocationManagerImpl(app_manager, rpc_service)); - command_factory_.reset( - new rc_rpc_plugin::RCCommandFactory(app_manager, - rpc_service, - hmi_capabilities, - policy_handler, - *resource_allocation_manager_)); + RCCommandParams params{app_manager, + rpc_service, + hmi_capabilities, + policy_handler, + *(resource_allocation_manager_.get()), + *(interior_data_cache_.get()), + *(interior_data_manager_.get())}; + command_factory_.reset(new rc_rpc_plugin::RCCommandFactory(params)); + rpc_service_ = &rpc_service; + app_mngr_ = &app_manager; return true; } 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 8ddcaa469d..d9b21afe20 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 @@ -147,12 +147,14 @@ class ButtonPressRequestTest template std::shared_ptr CreateRCCommand(MessageSharedPtr& msg) { InitCommand(kDefaultTimeout_); - return std::make_shared(msg ? msg : msg = CreateMessage(), - app_mngr_, - mock_rpc_service_, - mock_hmi_capabilities_, - mock_policy_handler_, - mock_allocation_manager_); + RCCommandParams params{app_mngr_, + mock_rpc_service_, + mock_hmi_capabilities_, + mock_policy_handler_, + mock_allocation_manager_, + mock_interior_data_cache_, + mock_interior_data_manager_}; + return std::make_shared(msg ? msg : msg = CreateMessage(), params); } protected: @@ -163,6 +165,10 @@ class ButtonPressRequestTest mock_policy_handler_; testing::NiceMock mock_allocation_manager_; + testing::NiceMock + mock_interior_data_cache_; + testing::NiceMock + mock_interior_data_manager_; }; TEST_F(ButtonPressRequestTest, diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/get_interior_vehicle_data_request_test.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/get_interior_vehicle_data_request_test.cc index a6f0ee12ca..148f184b3c 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/get_interior_vehicle_data_request_test.cc +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/get_interior_vehicle_data_request_test.cc @@ -35,11 +35,16 @@ #include "application_manager/mock_application.h" #include "rc_rpc_plugin/rc_app_extension.h" #include "rc_rpc_plugin/rc_module_constants.h" +#include "rc_rpc_plugin/rc_rpc_plugin.h" #include "application_manager/message_helper.h" #include "rc_rpc_plugin/rc_command_factory.h" #include "application_manager/event_engine/event_dispatcher.h" #include "application_manager/commands/command_request_test.h" #include "rc_rpc_plugin/mock/mock_resource_allocation_manager.h" +#include "rc_rpc_plugin/mock/mock_interior_data_cache.h" +#include "rc_rpc_plugin/mock/mock_interior_data_manager.h" +#include +#include using ::testing::_; using ::testing::Mock; @@ -50,6 +55,7 @@ using ::testing::ReturnRef; using ::testing::SaveArg; using ::application_manager::Message; using ::application_manager::MessageType; +using application_manager::ApplicationSet; using application_manager::commands::MessageSharedPtr; using ::application_manager::ApplicationSharedPtr; using ::protocol_handler::MessagePriority; @@ -64,7 +70,11 @@ using test::components::commands_test::MobileResultCodeIs; namespace { const int32_t kConnectionKey = 5u; const uint32_t kAppId = 0u; +const uint32_t kAppId2 = 1u; const int kModuleId = 153u; +const auto module_type = mobile_apis::ModuleType::RADIO; +const int32_t time_frame_of_allowed_requests = 1; +const uint32_t max_request_in_time_frame = 5u; } namespace rc_rpc_plugin_test { @@ -75,163 +85,508 @@ class GetInteriorVehicleDataRequestTest public: GetInteriorVehicleDataRequestTest() : mock_app_(std::make_shared >()) - , rc_app_extention_(std::make_shared(kModuleId)) { + , mock_app2_(std::make_shared >()) + , rc_app_extention_(std::make_shared(kModuleId)) + , rc_app_extention2_(std::make_shared(kModuleId)) + , apps_lock_(std::make_shared()) + , apps_da_(apps_, apps_lock_) { ON_CALL(*mock_app_, app_id()).WillByDefault(Return(kAppId)); + ON_CALL(*mock_app2_, app_id()).WillByDefault(Return(kAppId2)); + ON_CALL(*mock_app_, is_remote_control_supported()) + .WillByDefault(Return(true)); + ON_CALL(*mock_app2_, is_remote_control_supported()) + .WillByDefault(Return(true)); + ON_CALL(*mock_app_, QueryInterface(_)) + .WillByDefault(Return(rc_app_extention_)); + ON_CALL(*mock_app2_, QueryInterface(_)) + .WillByDefault(Return(rc_app_extention2_)); + } + + /** + * @brief CreateBasicMessage creates message for + * GetInteriorVehicleData request for app1 + * @return message shared ptr + */ + MessageSharedPtr CreateBasicMessage() { + MessageSharedPtr message = CreateMessage(); + (*message)[application_manager::strings::params] + [application_manager::strings::function_id] = + mobile_apis::FunctionID::GetInteriorVehicleDataID; + (*message)[application_manager::strings::params] + [application_manager::strings::connection_key] = kConnectionKey; + (*message)[application_manager::strings::params] + [application_manager::strings::connection_key] = kAppId; + return message; + } + + void SetUp() OVERRIDE { + std::pair frequency; + frequency.first = max_request_in_time_frame; + frequency.second = time_frame_of_allowed_requests; + ON_CALL(app_mngr_, get_settings()) + .WillByDefault(ReturnRef(app_mngr_settings_)); + ON_CALL(app_mngr_settings_, get_interior_vehicle_data_frequency()) + .WillByDefault(ReturnRef(frequency)); + ON_CALL(app_mngr_, hmi_interfaces()) .WillByDefault(ReturnRef(mock_hmi_interfaces_)); - ON_CALL( mock_hmi_interfaces_, GetInterfaceState(application_manager::HmiInterfaces::HMI_INTERFACE_RC)) .WillByDefault(Return(application_manager::HmiInterfaces:: InterfaceState::STATE_AVAILABLE)); ON_CALL(app_mngr_, application(kAppId)).WillByDefault(Return(mock_app_)); - ON_CALL(mock_allocation_manager_, GetApplicationExtention(_)) - .WillByDefault(Return(rc_app_extention_)); + ON_CALL(app_mngr_, application(kAppId2)).WillByDefault(Return(mock_app2_)); ON_CALL(app_mngr_, GetPolicyHandler()) .WillByDefault(ReturnRef(mock_policy_handler_)); ON_CALL(app_mngr_, hmi_capabilities()) .WillByDefault(ReturnRef(mock_hmi_capabilities_)); ON_CALL(mock_hmi_capabilities_, rc_capability()) - .WillByDefault(Return(&rc_capabilities_)); + .WillByDefault(Return(nullptr)); ON_CALL(mock_policy_handler_, CheckHMIType( _, mobile_apis::AppHMIType::eType::REMOTE_CONTROL, nullptr)) .WillByDefault(Return(true)); + ON_CALL(mock_policy_handler_, CheckModule(_, _)) + .WillByDefault(Return(true)); ON_CALL(mock_allocation_manager_, is_rc_enabled()) .WillByDefault(Return(true)); } - MessageSharedPtr CreateBasicMessage() { - MessageSharedPtr message = CreateMessage(); - (*message)[application_manager::strings::params] - [application_manager::strings::function_id] = - mobile_apis::FunctionID::GetInteriorVehicleDataID; - (*message)[application_manager::strings::params] - [application_manager::strings::connection_key] = kConnectionKey; - (*message)[application_manager::strings::params] - [application_manager::strings::connection_key] = kAppId; - return message; - } template std::shared_ptr CreateRCCommand(MessageSharedPtr& msg) { InitCommand(kDefaultTimeout_); - return std::make_shared(msg ? msg : msg = CreateMessage(), - app_mngr_, - mock_rpc_service_, - mock_hmi_capabilities_, - mock_policy_handler_, - mock_allocation_manager_); + RCCommandParams params{app_mngr_, + mock_rpc_service_, + mock_hmi_capabilities_, + mock_policy_handler_, + mock_allocation_manager_, + mock_interior_data_cache_, + mock_interior_data_manager_}; + return std::make_shared(msg ? msg : msg = CreateMessage(), params); } protected: - smart_objects::SmartObject rc_capabilities_; std::shared_ptr mock_app_; + std::shared_ptr mock_app2_; std::shared_ptr rc_app_extention_; + std::shared_ptr rc_app_extention2_; testing::NiceMock mock_allocation_manager_; + testing::NiceMock + mock_interior_data_cache_; + testing::NiceMock + mock_interior_data_manager_; + application_manager::ApplicationSet apps_; + const std::shared_ptr apps_lock_; + DataAccessor apps_da_; }; + TEST_F(GetInteriorVehicleDataRequestTest, - Execute_MessageValidationOk_ExpectCorrectMessageSentToHMI) { + Execute_ExpectCorrectMessageSentToHMI_NoSubscriptionNoCache) { // Arrange - ON_CALL(mock_policy_handler_, CheckModule(_, _)).WillByDefault(Return(true)); - EXPECT_CALL(mock_hmi_capabilities_, rc_capability()) - .WillOnce(Return(nullptr)); + MessageSharedPtr mobile_message = CreateBasicMessage(); + (*mobile_message)[application_manager::strings::msg_params] + [message_params::kModuleType] = module_type; + ON_CALL(mock_interior_data_cache_, Contains(enums_value::kRadio)) + .WillByDefault(Return(false)); + ON_CALL(mock_interior_data_manager_, CheckRequestsToHMIFrequency(_)) + .WillByDefault(Return(true)); + std::shared_ptr< + rc_rpc_plugin::commands::GetInteriorVehicleDataRequest> command = + CreateRCCommand( + mobile_message); + + // Expectations EXPECT_CALL(mock_rpc_service_, ManageHMICommand(HMIResultCodeIs( hmi_apis::FunctionID::RC_GetInteriorVehicleData))) .WillOnce(Return(true)); + // Act + command->Run(); +} + +TEST_F(GetInteriorVehicleDataRequestTest, + Execute_ExpectCorrectMessageSentToHMI_SupscribeAppNoCache) { + // Arrange MessageSharedPtr mobile_message = CreateBasicMessage(); + (*mobile_message)[application_manager::strings::msg_params] + [message_params::kModuleType] = module_type; + (*mobile_message)[application_manager::strings::msg_params] + [message_params::kSubscribe] = true; + ON_CALL(mock_interior_data_cache_, Contains(enums_value::kRadio)) + .WillByDefault(Return(false)); + ON_CALL(mock_interior_data_manager_, CheckRequestsToHMIFrequency(_)) + .WillByDefault(Return(true)); std::shared_ptr< rc_rpc_plugin::commands::GetInteriorVehicleDataRequest> command = CreateRCCommand( mobile_message); + + // Expectations + EXPECT_CALL(mock_rpc_service_, + ManageHMICommand(HMIResultCodeIs( + hmi_apis::FunctionID::RC_GetInteriorVehicleData))) + .WillOnce(Return(true)); + // Act command->Run(); } TEST_F( GetInteriorVehicleDataRequestTest, - Execute_MessageValidationFailed_ExpectMessageNotSentToHMI_AndFalseSentToMobile) { + Execute_ExpectMessageNotSentToHMI_SuccessSentToMobile_AppSubscribed_DataFromCache) { // Arrange + rc_app_extention_->SubscribeToInteriorVehicleData(enums_value::kRadio); MessageSharedPtr mobile_message = CreateBasicMessage(); - NsSmartDeviceLink::NsSmartObjects::SmartObject& msg_params = - (*mobile_message)[application_manager::strings::msg_params]; - msg_params[message_params::kModuleType] = mobile_apis::ModuleType::RADIO; - ON_CALL(mock_policy_handler_, CheckModule(_, _)).WillByDefault(Return(true)); - MessageSharedPtr command_result; - EXPECT_CALL(mock_rpc_service_, - ManageHMICommand(HMIResultCodeIs( - hmi_apis::FunctionID::RC_GetInteriorVehicleData))).Times(0); - EXPECT_CALL( - mock_rpc_service_, - ManageMobileCommand( - MobileResultCodeIs(mobile_apis::Result::UNSUPPORTED_RESOURCE), _)) - .WillOnce(DoAll(SaveArg<0>(&command_result), Return(true))); + (*mobile_message)[application_manager::strings::msg_params] + [message_params::kModuleType] = module_type; + smart_objects::SmartObject radio_data; + radio_data[message_params::kBand] = enums_value::kAM; std::shared_ptr< rc_rpc_plugin::commands::GetInteriorVehicleDataRequest> command = CreateRCCommand( mobile_message); + + // Expectations + EXPECT_CALL(mock_interior_data_cache_, Contains(enums_value::kRadio)) + .WillOnce(Return(true)); + EXPECT_CALL(mock_interior_data_cache_, Retrieve(enums_value::kRadio)) + .WillOnce(Return(radio_data)); + EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_)).Times(0); + MessageSharedPtr command_result; + EXPECT_CALL( + mock_rpc_service_, + ManageMobileCommand(MobileResultCodeIs(mobile_apis::Result::SUCCESS), _)) + .WillOnce(DoAll(SaveArg<0>(&command_result), Return(true))); + + // Act command->Run(); + + // Assert + EXPECT_EQ((*command_result)[application_manager::strings::msg_params] + [message_params::kModuleData] + [message_params::kRadioControlData], + radio_data); } -TEST_F(GetInteriorVehicleDataRequestTest, - OnEvent_ValidHmiResponse_ExpectSuccessfullResponseSentToMobile) { +TEST_F( + GetInteriorVehicleDataRequestTest, + Execute_ExpectCorrectMessageSentToHMI_LastAppSubscribedUnsubscibe_ClearCache) { // Arrange MessageSharedPtr mobile_message = CreateBasicMessage(); - NsSmartDeviceLink::NsSmartObjects::SmartObject& msg_params = - (*mobile_message)[application_manager::strings::msg_params]; - msg_params[message_params::kModuleType] = mobile_apis::ModuleType::CLIMATE; + (*mobile_message)[application_manager::strings::msg_params] + [message_params::kModuleType] = module_type; + (*mobile_message)[application_manager::strings::msg_params] + [message_params::kSubscribe] = false; - MessageSharedPtr hmi_message = CreateBasicMessage(); + MessageSharedPtr hmi_response = CreateBasicMessage(); NsSmartDeviceLink::NsSmartObjects::SmartObject& hmi_msg_params = - (*hmi_message)[application_manager::strings::msg_params]; + (*hmi_response)[application_manager::strings::msg_params]; hmi_apis::Common_Result::eType response_code = hmi_apis::Common_Result::SUCCESS; hmi_msg_params[application_manager::hmi_response::code] = response_code; hmi_msg_params[application_manager::strings::connection_key] = kConnectionKey; + apps_.insert(mock_app_); + rc_app_extention_->SubscribeToInteriorVehicleData(enums_value::kRadio); + ON_CALL(app_mngr_, applications()).WillByDefault(Return(apps_da_)); + ON_CALL(mock_interior_data_manager_, CheckRequestsToHMIFrequency(_)) + .WillByDefault(Return(true)); + + // Expectations + EXPECT_CALL(mock_rpc_service_, + ManageHMICommand(HMIResultCodeIs( + hmi_apis::FunctionID::RC_GetInteriorVehicleData))) + .WillOnce(Return(true)); EXPECT_CALL( mock_rpc_service_, ManageMobileCommand(MobileResultCodeIs(mobile_apis::Result::SUCCESS), _)) .WillOnce(Return(true)); + EXPECT_CALL(mock_interior_data_cache_, Remove(enums_value::kRadio)); + + // Act + std::shared_ptr< + rc_rpc_plugin::commands::GetInteriorVehicleDataRequest> command = + CreateRCCommand( + mobile_message); + command->Run(); application_manager::event_engine::Event event( hmi_apis::FunctionID::RC_GetInteriorVehicleData); - event.set_smart_object(*hmi_message); + event.set_smart_object(*hmi_response); + command->on_event(event); +} + +TEST_F(GetInteriorVehicleDataRequestTest, + Execute_ExpectMessageNotSentToHMI_TwoApps_OneUnsubscribed) { + // Arrange + MessageSharedPtr mobile_message = CreateBasicMessage(); + (*mobile_message)[application_manager::strings::msg_params] + [message_params::kModuleType] = module_type; + (*mobile_message)[application_manager::strings::msg_params] + [message_params::kSubscribe] = false; + + apps_.insert(mock_app_); + apps_.insert(mock_app2_); + rc_app_extention_->SubscribeToInteriorVehicleData(enums_value::kRadio); + rc_app_extention2_->SubscribeToInteriorVehicleData(enums_value::kRadio); + + smart_objects::SmartObject radio_data; + radio_data[message_params::kBand] = enums_value::kAM; + ON_CALL(app_mngr_, applications()).WillByDefault(Return(apps_da_)); + + std::shared_ptr< + rc_rpc_plugin::commands::GetInteriorVehicleDataRequest> command = + CreateRCCommand( + mobile_message); + + // Expectations + EXPECT_CALL(mock_interior_data_cache_, Contains(enums_value::kRadio)) + .WillOnce(Return(true)); + EXPECT_CALL(mock_interior_data_cache_, Retrieve(enums_value::kRadio)) + .WillOnce(Return(radio_data)); + + EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_)).Times(0); + MessageSharedPtr command_result; + EXPECT_CALL( + mock_rpc_service_, + ManageMobileCommand(MobileResultCodeIs(mobile_apis::Result::SUCCESS), _)) + .WillOnce(DoAll(SaveArg<0>(&command_result), Return(true))); + + // Act + command->Run(); + + // Assert + EXPECT_FALSE( + rc_app_extention_->IsSubscibedToInteriorVehicleData(enums_value::kRadio)); + EXPECT_EQ((*command_result)[application_manager::strings::msg_params] + [message_params::kModuleData] + [message_params::kRadioControlData], + radio_data); +} + +TEST_F( + GetInteriorVehicleDataRequestTest, + Execute_CapabilitiesValidationFailed_ExpectMessageNotSentToHMI_AndFalseSentToMobile) { + // Arrange + MessageSharedPtr mobile_message = CreateBasicMessage(); + NsSmartDeviceLink::NsSmartObjects::SmartObject& msg_params = + (*mobile_message)[application_manager::strings::msg_params]; + msg_params[message_params::kModuleType] = mobile_apis::ModuleType::RADIO; + std::shared_ptr< + rc_rpc_plugin::commands::GetInteriorVehicleDataRequest> command = + CreateRCCommand( + mobile_message); + smart_objects::SmartObject rc_capabilities; + ON_CALL(mock_hmi_capabilities_, rc_capability()) + .WillByDefault(Return(&rc_capabilities)); + + // Expectations + EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_)).Times(0); + EXPECT_CALL(mock_rpc_service_, + ManageMobileCommand( + MobileResultCodeIs(mobile_apis::Result::UNSUPPORTED_RESOURCE), + _)).WillOnce((Return(true))); + // Act + command->Run(); +} + +TEST_F( + GetInteriorVehicleDataRequestTest, + Execute_PolicyValidationFailed_ExpectMessageNotSentToHMI_AndFalseSentToMobile) { + // Arrange + MessageSharedPtr mobile_message = CreateBasicMessage(); + NsSmartDeviceLink::NsSmartObjects::SmartObject& msg_params = + (*mobile_message)[application_manager::strings::msg_params]; + msg_params[message_params::kModuleType] = mobile_apis::ModuleType::RADIO; std::shared_ptr< rc_rpc_plugin::commands::GetInteriorVehicleDataRequest> command = CreateRCCommand( mobile_message); + ON_CALL(mock_policy_handler_, CheckModule(_, _)).WillByDefault(Return(false)); + + // Expectations + EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_)).Times(0); + EXPECT_CALL(mock_rpc_service_, + ManageMobileCommand( + MobileResultCodeIs(mobile_apis::Result::DISALLOWED), _)) + .WillOnce((Return(true))); + + // Act + command->Run(); +} + +TEST_F(GetInteriorVehicleDataRequestTest, + OnEvent_ValidHmiResponse_ExpectSuccessfulResponseSentToMobile_NoCache) { + using rc_rpc_plugin::commands::GetInteriorVehicleDataRequest; + namespace hmi_response = application_manager::hmi_response; + namespace strings = application_manager::strings; + + // Arrange + MessageSharedPtr mobile_message = CreateBasicMessage(); + auto& msg_params = (*mobile_message)[strings::msg_params]; + msg_params[message_params::kModuleType] = module_type; + + MessageSharedPtr hmi_response_message = CreateBasicMessage(); + auto& hmi_response_params = (*hmi_response_message)[strings::msg_params]; + hmi_response_params[hmi_response::code] = hmi_apis::Common_Result::SUCCESS; + hmi_response_params[strings::connection_key] = kConnectionKey; + + ON_CALL(mock_interior_data_cache_, Contains(_)).WillByDefault(Return(false)); + ON_CALL(mock_interior_data_manager_, CheckRequestsToHMIFrequency(_)) + .WillByDefault(Return(true)); + + // Expectations + EXPECT_CALL( + mock_rpc_service_, + ManageMobileCommand(MobileResultCodeIs(mobile_apis::Result::SUCCESS), _)) + .WillOnce(Return(true)); + + EXPECT_CALL(mock_rpc_service_, + ManageHMICommand(HMIResultCodeIs( + hmi_apis::FunctionID::RC_GetInteriorVehicleData))) + .WillOnce(Return(true)); + + // Act + auto command = CreateRCCommand(mobile_message); + application_manager::event_engine::Event event( + hmi_apis::FunctionID::RC_GetInteriorVehicleData); + event.set_smart_object(*hmi_response_message); + command->Run(); command->on_event(event); } TEST_F(GetInteriorVehicleDataRequestTest, OnEvent_InvalidHmiResponse_ExpectGenericErrorResponseSentToMobile) { + using rc_rpc_plugin::commands::GetInteriorVehicleDataRequest; + namespace hmi_response = application_manager::hmi_response; + namespace strings = application_manager::strings; + // Arrange MessageSharedPtr mobile_message = CreateBasicMessage(); - NsSmartDeviceLink::NsSmartObjects::SmartObject& msg_params = + auto& msg_params = (*mobile_message)[application_manager::strings::msg_params]; - msg_params[message_params::kModuleType] = mobile_apis::ModuleType::CLIMATE; + msg_params[message_params::kModuleType] = module_type; MessageSharedPtr hmi_message = CreateBasicMessage(); + auto& hmi_msg_params = (*hmi_message)[strings::params]; + hmi_msg_params[hmi_response::code] = hmi_apis::Common_Result::READ_ONLY; + hmi_msg_params[strings::connection_key] = kConnectionKey; + ON_CALL(mock_interior_data_cache_, Contains(_)).WillByDefault(Return(false)); + ON_CALL(mock_interior_data_manager_, CheckRequestsToHMIFrequency(_)) + .WillByDefault(Return(true)); + + // Expectations + EXPECT_CALL(mock_rpc_service_, + ManageHMICommand(HMIResultCodeIs( + hmi_apis::FunctionID::RC_GetInteriorVehicleData))) + .WillOnce(Return(true)); + EXPECT_CALL(mock_rpc_service_, + ManageMobileCommand( + MobileResultCodeIs(mobile_apis::Result::GENERIC_ERROR), _)) + .WillOnce(Return(true)); + + // Act + application_manager::event_engine::Event event( + hmi_apis::FunctionID::RC_GetInteriorVehicleData); + event.set_smart_object(*hmi_message); + auto command = CreateRCCommand(mobile_message); + command->Run(); + command->on_event(event); +} + +TEST_F(GetInteriorVehicleDataRequestTest, + OnEvent_InvalidHmiResponse_DontUnsubscibeLastApp_NoClearCache) { + // Arrange + MessageSharedPtr mobile_message = CreateBasicMessage(); + (*mobile_message)[application_manager::strings::msg_params] + [message_params::kModuleType] = module_type; + (*mobile_message)[application_manager::strings::msg_params] + [message_params::kSubscribe] = false; + + MessageSharedPtr hmi_response = CreateBasicMessage(); NsSmartDeviceLink::NsSmartObjects::SmartObject& hmi_msg_params = - (*hmi_message)[application_manager::strings::params]; - hmi_apis::Common_Result::eType response_code = + (*hmi_response)[application_manager::strings::params]; + hmi_msg_params[application_manager::hmi_response::code] = hmi_apis::Common_Result::READ_ONLY; - hmi_msg_params[application_manager::hmi_response::code] = response_code; hmi_msg_params[application_manager::strings::connection_key] = kConnectionKey; + + apps_.insert(mock_app_); + rc_app_extention_->SubscribeToInteriorVehicleData(enums_value::kRadio); + ON_CALL(app_mngr_, applications()).WillByDefault(Return(apps_da_)); + ON_CALL(mock_interior_data_manager_, CheckRequestsToHMIFrequency(_)) + .WillByDefault(Return(true)); + + // Expectations + EXPECT_CALL(mock_rpc_service_, + ManageHMICommand(HMIResultCodeIs( + hmi_apis::FunctionID::RC_GetInteriorVehicleData))) + .WillOnce(Return(true)); EXPECT_CALL(mock_rpc_service_, ManageMobileCommand( MobileResultCodeIs(mobile_apis::Result::GENERIC_ERROR), _)) - .WillOnce(Return(false)); + .WillOnce(Return(true)); + EXPECT_CALL(mock_interior_data_cache_, Clear()).Times(0); + + // Act + std::shared_ptr< + rc_rpc_plugin::commands::GetInteriorVehicleDataRequest> command = + CreateRCCommand( + mobile_message); + command->Run(); application_manager::event_engine::Event event( hmi_apis::FunctionID::RC_GetInteriorVehicleData); - event.set_smart_object(*hmi_message); + event.set_smart_object(*hmi_response); + command->on_event(event); + + // Assert + EXPECT_TRUE( + rc_app_extention_->IsSubscibedToInteriorVehicleData(enums_value::kRadio)); +} + +TEST_F(GetInteriorVehicleDataRequestTest, + Execute_ExpectRejectDuToRequestLimitation_NoCahce) { + // Arrange + rc_app_extention_->UnsubscribeFromInteriorVehicleData(enums_value::kRadio); + MessageSharedPtr mobile_message = CreateBasicMessage(); + (*mobile_message)[application_manager::strings::msg_params] + [message_params::kModuleType] = module_type; + smart_objects::SmartObject radio_data; + radio_data[message_params::kBand] = enums_value::kAM; std::shared_ptr< rc_rpc_plugin::commands::GetInteriorVehicleDataRequest> command = CreateRCCommand( mobile_message); - command->on_event(event); + size_t i = 0; + for (; i <= max_request_in_time_frame; ++i) { + // Expectations + EXPECT_CALL(mock_interior_data_manager_, + CheckRequestsToHMIFrequency(enums_value::kRadio)) + .WillOnce(Return(true)); + EXPECT_CALL(mock_interior_data_manager_, + StoreRequestToHMITime(enums_value::kRadio)); + EXPECT_CALL(mock_interior_data_cache_, Contains(enums_value::kRadio)) + .WillRepeatedly(Return(false)); + EXPECT_CALL(mock_rpc_service_, + ManageHMICommand(HMIResultCodeIs( + hmi_apis::FunctionID::RC_GetInteriorVehicleData))) + .WillRepeatedly(Return(true)); + // Act + command->Run(); + } + + // Expectations + EXPECT_CALL(mock_interior_data_manager_, + CheckRequestsToHMIFrequency(enums_value::kRadio)) + .WillOnce(Return(false)); + EXPECT_CALL( + mock_rpc_service_, + ManageMobileCommand(MobileResultCodeIs(mobile_apis::Result::REJECTED), _)) + .WillOnce(Return(false)); + EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_)).Times(0); + + // Act + command->Run(); } } // namespace rc_rpc_plugin_test diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/on_interior_vehicle_data_notification_test.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/on_interior_vehicle_data_notification_test.cc index df11bf8c88..b344471254 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/on_interior_vehicle_data_notification_test.cc +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/on_interior_vehicle_data_notification_test.cc @@ -37,6 +37,8 @@ #include "rc_rpc_plugin/rc_rpc_plugin.h" #include "rc_rpc_plugin/rc_module_constants.h" #include "rc_rpc_plugin/mock/mock_resource_allocation_manager.h" +#include "rc_rpc_plugin/mock/mock_interior_data_cache.h" +#include "rc_rpc_plugin/mock/mock_interior_data_manager.h" #include "gtest/gtest.h" #include "interfaces/MOBILE_API.h" @@ -56,6 +58,7 @@ namespace { const uint32_t kAppId = 0u; const uint32_t kConnectionKey = 1u; const std::string kPolicyAppId = "Test"; +const int kModuleId = 153u; } namespace rc_rpc_plugin_test { @@ -66,62 +69,72 @@ class OnInteriorVehicleDataNotificationTest : public CommandsTest { public: OnInteriorVehicleDataNotificationTest() - : mock_app_(std::make_shared >()) {} + : mock_app_(std::make_shared >()) + , rc_app_extention_(std::make_shared(kModuleId)) + , apps_lock_(std::make_shared()) + , apps_da_(apps_, apps_lock_) { + ON_CALL(*mock_app_, app_id()).WillByDefault(Return(kAppId)); + ON_CALL(*mock_app_, is_remote_control_supported()) + .WillByDefault(Return(true)); + ON_CALL(*mock_app_, QueryInterface(_)) + .WillByDefault(Return(rc_app_extention_)); + } MessageSharedPtr CreateBasicMessage() { MessageSharedPtr message = CreateMessage(); (*message)[application_manager::strings::params] [application_manager::strings::function_id] = - mobile_apis::FunctionID::SetInteriorVehicleDataID; + mobile_apis::FunctionID::OnInteriorVehicleDataID; (*message)[application_manager::strings::params] [application_manager::strings::connection_key] = kConnectionKey; (*message)[application_manager::strings::params] - [application_manager::strings::connection_key] = kAppId; + [application_manager::strings::app_id] = kAppId; smart_objects::SmartObject& msg_param = (*message)[application_manager::strings::msg_params]; - msg_param[message_params::kModuleType] = mobile_apis::ModuleType::CLIMATE; - + msg_param[message_params::kModuleData][message_params::kModuleType] = + mobile_apis::ModuleType::CLIMATE; return message; } template std::shared_ptr CreateRCCommand(MessageSharedPtr& msg) { InitCommand(kDefaultTimeout_); - return std::make_shared(msg ? msg : msg = CreateMessage(), - app_mngr_, - mock_rpc_service_, - mock_hmi_capabilities_, - mock_policy_handler_, - mock_allocation_manager_); + RCCommandParams params{app_mngr_, + mock_rpc_service_, + mock_hmi_capabilities_, + mock_policy_handler_, + mock_allocation_manager_, + mock_interior_data_cache_, + mock_interior_data_manager_}; + return ::std::make_shared(msg ? msg : msg = CreateMessage(), + params); } protected: std::shared_ptr mock_app_; + std::shared_ptr rc_app_extention_; testing::NiceMock mock_allocation_manager_; + testing::NiceMock + mock_interior_data_cache_; + testing::NiceMock + mock_interior_data_manager_; + application_manager::ApplicationSet apps_; + const std::shared_ptr apps_lock_; + DataAccessor apps_da_; }; TEST_F(OnInteriorVehicleDataNotificationTest, Run_SendMessageToMobile_Notification) { // Arrange MessageSharedPtr mobile_message = CreateBasicMessage(); - ApplicationSet app_set = {mock_app_}; - MessageSharedPtr message; - std::shared_ptr apps_lock = - std::make_shared(); - DataAccessor accessor(app_set, apps_lock); - // Expectations - EXPECT_CALL(app_mngr_, applications()).WillOnce(Return(accessor)); - - RCAppExtensionPtr rc_extention_ptr = - std::make_shared(application_manager::AppExtensionUID( - rc_rpc_plugin::RCRPCPlugin::kRCPluginID)); - rc_extention_ptr->SubscribeToInteriorVehicleData(enums_value::kClimate); - ON_CALL(*mock_app_, QueryInterface(_)) - .WillByDefault(Return(rc_extention_ptr)); - ON_CALL(*mock_app_, is_remote_control_supported()) - .WillByDefault(Return(true)); + apps_.insert(mock_app_); + rc_app_extention_->SubscribeToInteriorVehicleData(enums_value::kClimate); + ON_CALL(app_mngr_, applications()).WillByDefault(Return(apps_da_)); + // Expectations + EXPECT_CALL(mock_interior_data_cache_, Add(enums_value::kClimate, _)); + MessageSharedPtr message; EXPECT_CALL(mock_rpc_service_, SendMessageToMobile(_, false)) .WillOnce(SaveArg<0>(&message)); // Act @@ -130,8 +143,9 @@ TEST_F(OnInteriorVehicleDataNotificationTest, rc_rpc_plugin::commands::OnInteriorVehicleDataNotification>( mobile_message); command->Run(); + // Assertions - ASSERT_TRUE((bool)message); + ASSERT_TRUE(message.get()); Mock::VerifyAndClearExpectations(&app_mngr_); } diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/on_remote_control_settings_test.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/on_remote_control_settings_test.cc index 9054ce4830..164623d926 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/on_remote_control_settings_test.cc +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/on_remote_control_settings_test.cc @@ -38,6 +38,8 @@ #include "rc_rpc_plugin/rc_rpc_plugin.h" #include "rc_rpc_plugin/rc_module_constants.h" #include "rc_rpc_plugin/mock/mock_resource_allocation_manager.h" +#include "rc_rpc_plugin/mock/mock_interior_data_cache.h" +#include "rc_rpc_plugin/mock/mock_interior_data_manager.h" #include "gtest/gtest.h" #include "interfaces/MOBILE_API.h" @@ -87,18 +89,24 @@ class RCOnRemoteControlSettingsNotificationTest template std::shared_ptr CreateRCCommand(MessageSharedPtr& msg) { InitCommand(kDefaultTimeout_); - return std::make_shared(msg ? msg : msg = CreateMessage(), - app_mngr_, - mock_rpc_service_, - mock_hmi_capabilities_, - mock_policy_handler_, - mock_allocation_manager_); + RCCommandParams params{app_mngr_, + mock_rpc_service_, + mock_hmi_capabilities_, + mock_policy_handler_, + mock_allocation_manager_, + mock_interior_data_cache_, + mock_interior_data_manager_}; + return std::make_shared(msg ? msg : msg = CreateMessage(), params); } protected: std::shared_ptr mock_app_; testing::NiceMock mock_allocation_manager_; + testing::NiceMock + mock_interior_data_cache_; + testing::NiceMock + mock_interior_data_manager_; }; TEST_F(RCOnRemoteControlSettingsNotificationTest, 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 7f36d251cc..567d4b1e20 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 @@ -46,6 +46,8 @@ #include "rc_rpc_plugin/rc_rpc_plugin.h" #include "rc_rpc_plugin/rc_module_constants.h" #include "rc_rpc_plugin/mock/mock_resource_allocation_manager.h" +#include "rc_rpc_plugin/mock/mock_interior_data_cache.h" +#include "rc_rpc_plugin/mock/mock_interior_data_manager.h" #include "rc_rpc_plugin/commands/mobile/button_press_request.h" #include "rc_rpc_plugin/commands/hmi/rc_get_interior_vehicle_data_consent_response.h" #include "rc_rpc_plugin/commands/hmi/rc_get_interior_vehicle_data_consent_request.h" @@ -100,11 +102,11 @@ class RCGetInteriorVehicleDataConsentTest : mock_app_(std::make_shared >()) , command_holder(app_mngr_) , request_controller(mock_request_controler) - , rpc_service(app_mngr_, - request_controller, - &mock_protocol_handler, - &mock_hmi_handler, - command_holder) + , rpc_service_(app_mngr_, + request_controller, + &mock_protocol_handler, + &mock_hmi_handler, + command_holder) , rc_app_extention_(std::make_shared(kPluginID)) , mock_rpc_plugin_manager( std::make_shared >()) @@ -119,8 +121,10 @@ class RCGetInteriorVehicleDataConsentTest .WillByDefault(Return(application_manager::HmiInterfaces:: InterfaceState::STATE_AVAILABLE)); ON_CALL(app_mngr_, application(kAppId)).WillByDefault(Return(mock_app_)); - ON_CALL(mock_allocation_manager_, GetApplicationExtention(_)) + ON_CALL(*mock_app_, QueryInterface(RCRPCPlugin::kRCPluginID)) .WillByDefault(Return(rc_app_extention_)); + testing::NiceMock + mock_interior_data_cache_; ON_CALL(app_mngr_, GetPolicyHandler()) .WillByDefault(ReturnRef(mock_policy_handler_)); ON_CALL(app_mngr_, hmi_capabilities()) @@ -146,12 +150,14 @@ class RCGetInteriorVehicleDataConsentTest template std::shared_ptr CreateRCCommand(MessageSharedPtr& msg) { InitCommand(kDefaultTimeout_); - return std::make_shared(msg ? msg : msg = CreateMessage(), - app_mngr_, - rpc_service, - mock_hmi_capabilities_, - mock_policy_handler_, - mock_allocation_manager_); + RCCommandParams params{app_mngr_, + rpc_service_, + mock_hmi_capabilities_, + mock_policy_handler_, + mock_allocation_manager_, + mock_interior_data_cache_, + mock_interior_data_manager_}; + return std::make_shared(msg ? msg : msg = CreateMessage(), params); } MessageSharedPtr CreateBasicMessage() { @@ -174,11 +180,15 @@ class RCGetInteriorVehicleDataConsentTest am::CommandHolderImpl command_holder; testing::NiceMock mock_allocation_manager_; + testing::NiceMock + mock_interior_data_cache_; + testing::NiceMock + mock_interior_data_manager_; smart_objects::SmartObject rc_capabilities_; MockRPCPlugin mock_rpc_plugin; MockCommandFactory mock_command_factory; am::request_controller::RequestController request_controller; - am::rpc_service::RPCServiceImpl rpc_service; + am::rpc_service::RPCServiceImpl rpc_service_; std::shared_ptr rc_app_extention_; std::shared_ptr mock_rpc_plugin_manager; 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 8072783a71..deb912c49f 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 @@ -37,6 +37,8 @@ #include "rc_rpc_plugin/rc_rpc_plugin.h" #include "rc_rpc_plugin/rc_module_constants.h" #include "rc_rpc_plugin/mock/mock_resource_allocation_manager.h" +#include "rc_rpc_plugin/mock/mock_interior_data_cache.h" +#include "rc_rpc_plugin/mock/mock_interior_data_manager.h" #include "gtest/gtest.h" #include "interfaces/MOBILE_API.h" @@ -108,17 +110,23 @@ class SetInteriorVehicleDataRequestTest template std::shared_ptr CreateRCCommand(MessageSharedPtr& msg) { InitCommand(kDefaultTimeout_); - return std::make_shared(msg ? msg : msg = CreateMessage(), - app_mngr_, - mock_rpc_service_, - mock_hmi_capabilities_, - mock_policy_handler_, - mock_allocation_manager_); + RCCommandParams params{app_mngr_, + mock_rpc_service_, + mock_hmi_capabilities_, + mock_policy_handler_, + mock_allocation_manager_, + mock_interior_data_cache_, + mock_interior_data_manager_}; + return std::make_shared(msg ? msg : msg = CreateMessage(), params); } protected: testing::NiceMock mock_allocation_manager_; + testing::NiceMock + mock_interior_data_cache_; + testing::NiceMock + mock_interior_data_manager_; std::shared_ptr mock_app_; std::shared_ptr rc_app_extention_; }; 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 d74e8fcb65..18308f62cf 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 @@ -30,8 +30,8 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#ifndef SRC_COMPONENTS_REMOTE_CONTROL_TEST_INCLUDE_MOCK_RESOURCE_ALLOCATION_MANAGER_H_ -#define SRC_COMPONENTS_REMOTE_CONTROL_TEST_INCLUDE_MOCK_RESOURCE_ALLOCATION_MANAGER_H_ +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_TEST_INCLUDE_RC_RPC_PLUGIN_MOCK_MOCK_RESOURCE_ALLOCATION_MANAGER_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_TEST_INCLUDE_RC_RPC_PLUGIN_MOCK_MOCK_RESOURCE_ALLOCATION_MANAGER_H_ #include "gmock/gmock.h" #include "application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/resource_allocation_manager.h" @@ -74,4 +74,4 @@ class MockResourceAllocationManager } // namespace rc_rpc_plugin_test -#endif // SRC_COMPONENTS_REMOTE_CONTROL_TEST_INCLUDE_MOCK_RESOURCE_ALLOCATION_MANAGER_H_ +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_TEST_INCLUDE_RC_RPC_PLUGIN_MOCK_MOCK_RESOURCE_ALLOCATION_MANAGER_H_ -- cgit v1.2.1 From 32afdbfdb111f604a8911943c08a06744d7f9a0c Mon Sep 17 00:00:00 2001 From: Alexander Date: Fri, 20 Jul 2018 13:26:50 +0300 Subject: Add reading interior data rate limits from ini file --- .../config_profile/include/config_profile/profile.h | 8 ++++++++ src/components/config_profile/src/profile.cc | 13 +++++++++++++ .../application_manager/application_manager_settings.h | 2 ++ .../application_manager/mock_application_manager_settings.h | 2 ++ 4 files changed, 25 insertions(+) diff --git a/src/components/config_profile/include/config_profile/profile.h b/src/components/config_profile/include/config_profile/profile.h index 4c2be53228..7502eddffa 100644 --- a/src/components/config_profile/include/config_profile/profile.h +++ b/src/components/config_profile/include/config_profile/profile.h @@ -747,6 +747,8 @@ class Profile : public protocol_handler::ProtocolHandlerSettings, const std::pair& get_vehicle_data_frequency() const OVERRIDE; + const std::pair& get_interior_vehicle_data_frequency() + const OVERRIDE; const std::pair& start_stream_retry_amount() const OVERRIDE; @@ -972,6 +974,12 @@ class Profile : public protocol_handler::ProtocolHandlerSettings, */ std::pair get_vehicle_data_frequency_; + /* + * first value is count of request + * second is time scale + */ + std::pair get_interior_vehicle_data_frequency_; + /** * first value is count of retries for start stream * second for timer diff --git a/src/components/config_profile/src/profile.cc b/src/components/config_profile/src/profile.cc index 3f3ec7eb63..9688d94a83 100644 --- a/src/components/config_profile/src/profile.cc +++ b/src/components/config_profile/src/profile.cc @@ -189,6 +189,8 @@ const char* kAckMQKey = "AckMQ"; const char* kApplicationListUpdateTimeoutKey = "ApplicationListUpdateTimeout"; const char* kReadDIDFrequencykey = "ReadDIDRequest"; const char* kGetVehicleDataFrequencyKey = "GetVehicleDataRequest"; +const char* kGetInteriorVehicleDataFrequencyKey = + "GetInteriorVehicleDataRequest"; const char* kLegacyProtocolMaskKey = "LegacyProtocol"; const char* kHubProtocolMaskKey = "HubProtocol"; const char* kPoolProtocolMaskKey = "PoolProtocol"; @@ -339,6 +341,7 @@ const uint32_t kDefaultTransportManagerDisconnectTimeout = 0; const uint32_t kDefaultApplicationListUpdateTimeout = 1; const std::pair kReadDIDFrequency = {5, 1}; const std::pair kGetVehicleDataFrequency = {5, 1}; +const std::pair kGetInteriorVehicleDataFrequency = {20, 1}; const std::pair kStartStreamRetryAmount = {3, 1}; const uint32_t kDefaultMaxThreadPoolSize = 2; const int kDefaultIAP2HubConnectAttempts = 0; @@ -790,6 +793,11 @@ const std::pair& Profile::get_vehicle_data_frequency() return get_vehicle_data_frequency_; } +const std::pair& +Profile::get_interior_vehicle_data_frequency() const { + return get_interior_vehicle_data_frequency_; +} + const std::pair& Profile::start_stream_retry_amount() const { return start_stream_retry_amount_; } @@ -1863,6 +1871,11 @@ void Profile::UpdateValues() { kMainSection, kGetVehicleDataFrequencyKey); + ReadUintIntPairValue(&get_interior_vehicle_data_frequency_, + kGetInteriorVehicleDataFrequency, + kMainSection, + kGetInteriorVehicleDataFrequencyKey); + ReadUIntValue(&max_thread_pool_size_, kDefaultMaxThreadPoolSize, kApplicationManagerSection, diff --git a/src/components/include/application_manager/application_manager_settings.h b/src/components/include/application_manager/application_manager_settings.h index 8f9d7496c8..3c9e573c57 100644 --- a/src/components/include/application_manager/application_manager_settings.h +++ b/src/components/include/application_manager/application_manager_settings.h @@ -50,6 +50,8 @@ class ApplicationManagerSettings : public RequestControlerSettings, virtual const std::pair& read_did_frequency() const = 0; virtual const std::pair& get_vehicle_data_frequency() const = 0; + virtual const std::pair& + get_interior_vehicle_data_frequency() const = 0; virtual uint32_t hash_string_size() const = 0; virtual const uint32_t& app_dir_quota() const = 0; virtual uint32_t stop_streaming_timeout() const = 0; 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 735539156a..e0c4a6b9c2 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 @@ -55,6 +55,8 @@ class MockApplicationManagerSettings // typedef for the return type. MOCK_CONST_METHOD0(get_vehicle_data_frequency, const std::pair&()); + MOCK_CONST_METHOD0(get_interior_vehicle_data_frequency, + const std::pair&()); MOCK_CONST_METHOD0(hash_string_size, uint32_t()); MOCK_CONST_METHOD0(app_storage_folder, const std::string&()); MOCK_CONST_METHOD0(app_info_storage, const std::string&()); -- cgit v1.2.1 From 36ccbe8e8386a5e6229cf6ac9a55dc2162b6ced0 Mon Sep 17 00:00:00 2001 From: Alexander Date: Fri, 20 Jul 2018 13:33:43 +0300 Subject: Add cache processing on GetInteriorVehicleData request On GetInteriorVehicleData request from mobile add lookup for cached data. In case if no data available in cache SDL transfer request to HMI. On HMI response SDL will add data to cache. If the last application unsubscribes from data, SDL transfer request to HMI, and clear cache by module type. --- .../mobile/get_interior_vehicle_data_request.h | 8 ++ .../include/rc_rpc_plugin/rc_app_extension.h | 6 + .../mobile/get_interior_vehicle_data_request.cc | 131 ++++++++++++++++++--- .../rc_rpc_plugin/src/rc_app_extension.cc | 4 + .../get_interior_vehicle_data_request_test.cc | 1 + 5 files changed, 131 insertions(+), 19 deletions(-) diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/get_interior_vehicle_data_request.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/get_interior_vehicle_data_request.h index debc78eaa1..4624d79b56 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/get_interior_vehicle_data_request.h +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/get_interior_vehicle_data_request.h @@ -63,6 +63,9 @@ class GetInteriorVehicleDataRequest : public RCCommandRequest { ~GetInteriorVehicleDataRequest(); private: + std::vector + AppsSubscribedToModuleType(const std::string& module_type); + /** * @brief Check if app wants to proceed with already setup subscription * @param request_params request parameters to check @@ -86,6 +89,11 @@ class GetInteriorVehicleDataRequest : public RCCommandRequest { std::string ModuleType() FINAL; bool excessive_subscription_occured_; + bool ProcessCapabilities(); + void ProcessResponseToMobileFromCache(app_mngr::ApplicationSharedPtr app); + bool CheckRateLimits(); + bool AppShouldBeUnsubscribed(); + bool TheLastAppShouldBeUnsubscribed(app_mngr::ApplicationSharedPtr app); }; } // namespace commands } // namespace rc_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_app_extension.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_app_extension.h index 8cf107d3d8..14397237c5 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_app_extension.h +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_app_extension.h @@ -69,6 +69,12 @@ class RCAppExtension : public application_manager::AppExtension { */ bool IsSubscibedToInteriorVehicleData(const std::string& module_type); + /** + * @brief get list of subscriptions of application + * @return list of subscriptions of application + */ + std::set InteriorVehicleDataSubscriptions() const; + private: std::set subscribed_interior_vehicle_data_; diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/get_interior_vehicle_data_request.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/get_interior_vehicle_data_request.cc index 9e8e0c24ee..c5c888a6b1 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/get_interior_vehicle_data_request.cc +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/get_interior_vehicle_data_request.cc @@ -76,9 +76,8 @@ bool CheckIfModuleTypeExistInCapabilities( return is_module_type_valid; } -void GetInteriorVehicleDataRequest::Execute() { +bool GetInteriorVehicleDataRequest::ProcessCapabilities() { LOG4CXX_AUTO_TRACE(logger_); - const smart_objects::SmartObject* rc_capabilities = hmi_capabilities_.rc_capability(); @@ -90,26 +89,107 @@ void GetInteriorVehicleDataRequest::Execute() { SendResponse(false, mobile_apis::Result::UNSUPPORTED_RESOURCE, "Accessing not supported module data"); + return false; + } + return true; +} + +void GetInteriorVehicleDataRequest::ProcessResponseToMobileFromCache( + app_mngr::ApplicationSharedPtr app) { + LOG4CXX_AUTO_TRACE(logger_); + const auto& data_mapping = RCHelpers::GetModuleTypeToDataMapping(); + auto data = interior_data_cache_.Retrieve(ModuleType()); + auto response_msg_params = + smart_objects::SmartObject(smart_objects::SmartType_Map); + response_msg_params[message_params::kModuleData][data_mapping(ModuleType())] = + data; + response_msg_params[message_params::kModuleData] + [message_params::kModuleType] = ModuleType(); + + const auto& request_msg_params = (*message_)[app_mngr::strings::msg_params]; + LOG4CXX_DEBUG(logger_, + "kSubscribe exist" << request_msg_params.keyExists( + message_params::kSubscribe)); + if (request_msg_params.keyExists(message_params::kSubscribe)) { + response_msg_params[message_params::kIsSubscribed] = + request_msg_params[message_params::kSubscribe].asBool(); + if (request_msg_params[message_params::kSubscribe].asBool()) { + auto extension = RCHelpers::GetRCExtension(*app); + DCHECK(extension); + extension->SubscribeToInteriorVehicleData(ModuleType()); + } + } + SendResponse( + true, mobile_apis::Result::SUCCESS, nullptr, &response_msg_params); + if (AppShouldBeUnsubscribed()) { + auto extension = RCHelpers::GetRCExtension(*app); + DCHECK(extension); + extension->UnsubscribeFromInteriorVehicleData(ModuleType()); + } +} + +bool GetInteriorVehicleDataRequest::CheckRateLimits() { + LOG4CXX_AUTO_TRACE(logger_); + return interior_data_manager_.CheckRequestsToHMIFrequency(ModuleType()); +} + +bool GetInteriorVehicleDataRequest::AppShouldBeUnsubscribed() { + LOG4CXX_AUTO_TRACE(logger_); + const auto& msg_params = (*message_)[app_mngr::strings::msg_params]; + if (msg_params.keyExists(message_params::kSubscribe)) { + return !(msg_params[message_params::kSubscribe].asBool()); + } + return false; +} + +bool GetInteriorVehicleDataRequest::TheLastAppShouldBeUnsubscribed( + app_mngr::ApplicationSharedPtr app) { + LOG4CXX_AUTO_TRACE(logger_); + if (AppShouldBeUnsubscribed()) { + const auto subscribed_to_module_type = + RCHelpers::AppsSubscribedToModuleType(application_manager_, + ModuleType()); + if (subscribed_to_module_type.size() == 1 && + subscribed_to_module_type.front() == app) { + LOG4CXX_DEBUG(logger_, + "The last application unsubscribes from " << ModuleType()); + return true; + } + } + return false; +} + +void GetInteriorVehicleDataRequest::Execute() { + LOG4CXX_AUTO_TRACE(logger_); + + if (!ProcessCapabilities()) { return; } app_mngr::ApplicationSharedPtr app = application_manager_.application(connection_key()); - if (HasRequestExcessiveSubscription()) { - excessive_subscription_occured_ = true; - is_subscribed = - (*message_)[app_mngr::strings::msg_params][message_params::kSubscribe] - .asBool(); - RemoveExcessiveSubscription(); + if (TheLastAppShouldBeUnsubscribed(app) || + !interior_data_cache_.Contains(ModuleType())) { + if (HasRequestExcessiveSubscription()) { + excessive_subscription_occured_ = true; + is_subscribed = + (*message_)[app_mngr::strings::msg_params][message_params::kSubscribe] + .asBool(); + RemoveExcessiveSubscription(); + } + if (!CheckRateLimits()) { + LOG4CXX_WARN(logger_, "GetInteriorVehicleData frequency is too high."); + SendResponse(false, mobile_apis::Result::REJECTED); + return; + } + interior_data_manager_.StoreRequestToHMITime(ModuleType()); + SendHMIRequest(hmi_apis::FunctionID::RC_GetInteriorVehicleData, + &(*message_)[app_mngr::strings::msg_params], + true); + return; } - - (*message_)[app_mngr::strings::msg_params][app_mngr::strings::app_id] = - app->app_id(); - - SendHMIRequest(hmi_apis::FunctionID::RC_GetInteriorVehicleData, - &(*message_)[app_mngr::strings::msg_params], - true); + ProcessResponseToMobileFromCache(app); } void GetInteriorVehicleDataRequest::on_event( @@ -141,7 +221,21 @@ void GetInteriorVehicleDataRequest::on_event( } if (result) { + app_mngr::ApplicationSharedPtr app = + application_manager_.application(connection_key()); + + DCHECK_OR_RETURN_VOID(app); + if (TheLastAppShouldBeUnsubscribed(app)) { + interior_data_cache_.Remove(ModuleType()); + } ProccessSubscription(hmi_response); + if (is_subscribed) { + const auto& data_mapping = RCHelpers::GetModuleTypeToDataMapping(); + const auto module_data = + hmi_response[app_mngr::strings::msg_params] + [message_params::kModuleData][data_mapping(ModuleType())]; + interior_data_cache_.Add(ModuleType(), module_data); + } } else { hmi_response[app_mngr::strings::msg_params].erase( message_params::kIsSubscribed); @@ -149,6 +243,7 @@ void GetInteriorVehicleDataRequest::on_event( std::string response_info; GetInfo(hmi_response, response_info); SetResourceState(ModuleType(), ResourceState::FREE); + SendResponse(result, result_code, response_info.c_str(), @@ -175,8 +270,7 @@ void GetInteriorVehicleDataRequest::ProccessSubscription( app_mngr::ApplicationSharedPtr app = application_manager_.application(CommandRequestImpl::connection_key()); - RCAppExtensionPtr extension = - resource_allocation_manager_.GetApplicationExtention(app); + const auto extension = RCHelpers::GetRCExtension(*app); const char* module_type; NsSmartDeviceLink::NsSmartObjects:: EnumConversionHelper::EnumToCString( @@ -255,8 +349,7 @@ bool GetInteriorVehicleDataRequest::HasRequestExcessiveSubscription() { if (is_subscribe_present_in_request) { app_mngr::ApplicationSharedPtr app = application_manager_.application(CommandRequestImpl::connection_key()); - RCAppExtensionPtr extension = - resource_allocation_manager_.GetApplicationExtention(app); + const auto extension = RCHelpers::GetRCExtension(*app); const bool is_app_already_subscribed = extension->IsSubscibedToInteriorVehicleData(ModuleType()); diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/rc_app_extension.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/rc_app_extension.cc index 5c0a94cccc..17f19e24e8 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/rc_app_extension.cc +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/rc_app_extension.cc @@ -64,5 +64,9 @@ void RCAppExtension::SaveResumptionData( void RCAppExtension::ProcessResumption( const NsSmartDeviceLink::NsSmartObjects::SmartObject& resumption_data) {} +std::set RCAppExtension::InteriorVehicleDataSubscriptions() const { + return subscribed_interior_vehicle_data_; +} + RCAppExtension::~RCAppExtension() {} } // namespace rc_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/get_interior_vehicle_data_request_test.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/get_interior_vehicle_data_request_test.cc index 148f184b3c..0b30bbf654 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/get_interior_vehicle_data_request_test.cc +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/get_interior_vehicle_data_request_test.cc @@ -43,6 +43,7 @@ #include "rc_rpc_plugin/mock/mock_resource_allocation_manager.h" #include "rc_rpc_plugin/mock/mock_interior_data_cache.h" #include "rc_rpc_plugin/mock/mock_interior_data_manager.h" + #include #include -- cgit v1.2.1 From 861cbf1da2fc9e480ea9e9197d858930a6bb7f5b Mon Sep 17 00:00:00 2001 From: Alexander Date: Fri, 20 Jul 2018 13:35:02 +0300 Subject: Add data to cache on interior data update Add data to cache in case if there are applications subscribed to certain interior vehicle data --- .../mobile/on_interior_vehicle_data_notification.h | 1 + .../mobile/on_interior_vehicle_data_notification.cc | 18 +++++++++++++++--- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/on_interior_vehicle_data_notification.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/on_interior_vehicle_data_notification.h index f018e2daf4..931e79366c 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/on_interior_vehicle_data_notification.h +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/on_interior_vehicle_data_notification.h @@ -59,6 +59,7 @@ class OnInteriorVehicleDataNotification private: InteriorDataCache& interior_data_cache_; + void AddDataToCache(const std::string& module_type); }; } // namespace commands } // namespace rc_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/on_interior_vehicle_data_notification.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/on_interior_vehicle_data_notification.cc index 261cdd49b1..c8d1329c02 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/on_interior_vehicle_data_notification.cc +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/on_interior_vehicle_data_notification.cc @@ -54,11 +54,24 @@ OnInteriorVehicleDataNotification::OnInteriorVehicleDataNotification( OnInteriorVehicleDataNotification::~OnInteriorVehicleDataNotification() {} +void OnInteriorVehicleDataNotification::AddDataToCache( + const std::string& module_type) { + const auto& data_mapping = RCHelpers::GetModuleTypeToDataMapping(); + const auto module_data = + (*message_)[app_mngr::strings::msg_params][message_params::kModuleData] + [data_mapping(module_type)]; + interior_data_cache_.Add(module_type, module_data); +} + void OnInteriorVehicleDataNotification::Run() { LOG4CXX_AUTO_TRACE(logger_); const std::string module_type = ModuleType(); - + auto apps_subscribed = + RCHelpers::AppsSubscribedToModuleType(application_manager_, module_type); + if (!apps_subscribed.empty()) { + AddDataToCache(module_type); + } typedef std::vector AppPtrs; AppPtrs apps = RCRPCPlugin::GetRCApplications(application_manager_); @@ -66,8 +79,7 @@ void OnInteriorVehicleDataNotification::Run() { DCHECK(*it); application_manager::Application& app = **it; - RCAppExtensionPtr extension = std::static_pointer_cast( - app.QueryInterface(RCRPCPlugin::kRCPluginID)); + const auto extension = RCHelpers::GetRCExtension(app); DCHECK(extension); LOG4CXX_TRACE(logger_, "Check subscription for " -- cgit v1.2.1 From f778780a4a8aa2e1213f47d39abe89c435ff416d Mon Sep 17 00:00:00 2001 From: Alexander Date: Fri, 20 Jul 2018 13:35:36 +0300 Subject: Rename RC unit tests and add interior data cache test --- .../application_manager/rpc_plugins/rc_rpc_plugin/test/CMakeLists.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/CMakeLists.txt b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/CMakeLists.txt index a1f0f5a6ff..c1c59d7e78 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/CMakeLists.txt +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/CMakeLists.txt @@ -41,6 +41,7 @@ include_directories ( set (RC_TEST_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/resource_allocation_manager_impl_test.cc +${CMAKE_CURRENT_SOURCE_DIR}/interior_data_cache_test.cc ) set(RC_COMMANDS_TEST_DIR ${CMAKE_CURRENT_SOURCE_DIR}/commands) @@ -72,5 +73,5 @@ if(ENABLE_LOG) endif() create_test("rc_commands_test" "${SOURCES}" "${LIBRARIES}" ) -create_test("resource_allocation_manager_test" "${RC_TEST_SOURCES}" "${LIBRARIES}") +create_test("rc_plugin_test" "${RC_TEST_SOURCES}" "${LIBRARIES}") -- cgit v1.2.1 From 8add3513c37111f00708e1cc809838808c6cc6f8 Mon Sep 17 00:00:00 2001 From: Alexander Date: Fri, 20 Jul 2018 13:39:34 +0300 Subject: Process policy events and application events in InteriorDataManager --- .../rc_rpc_plugin/resource_allocation_manager.h | 3 -- .../resource_allocation_manager_impl.h | 8 ---- .../rpc_plugins/rc_rpc_plugin/src/rc_rpc_plugin.cc | 12 ++---- .../src/resource_allocation_manager_impl.cc | 48 ++-------------------- .../test/commands/button_press_request_test.cc | 4 +- .../set_interior_vehicle_data_request_test.cc | 2 +- .../mock/mock_resource_allocation_manager.h | 3 -- 7 files changed, 12 insertions(+), 68 deletions(-) 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 2f9659f0ec..67598b667b 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 @@ -154,9 +154,6 @@ class ResourceAllocationManager { */ virtual void ResetAllAllocations() = 0; - virtual RCAppExtensionPtr GetApplicationExtention( - application_manager::ApplicationSharedPtr application) = 0; - /** * @brief Create and send OnRCStatusNotification to mobile and HMI * @param event trigger for notification sending 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 7ba2aefcdc..d7d3a4743f 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 @@ -110,14 +110,6 @@ class ResourceAllocationManagerImpl : public ResourceAllocationManager { void ResetAllAllocations() FINAL; - /** - * @brief GetApplicationExtention Provides access to application RC extention - * @param application Application - * @return Pointer to RC extention of application or NULL if not available - */ - RCAppExtensionPtr GetApplicationExtention( - application_manager::ApplicationSharedPtr application) FINAL; - void SendOnRCStatusNotifications( NotificationTrigger::eType event, application_manager::ApplicationSharedPtr application) FINAL; diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/rc_rpc_plugin.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/rc_rpc_plugin.cc index 1579412cac..fd6b4e86ac 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/rc_rpc_plugin.cc +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/rc_rpc_plugin.cc @@ -86,14 +86,8 @@ application_manager::CommandFactory& RCRPCPlugin::GetCommandFactory() { void RCRPCPlugin::OnPolicyEvent( application_manager::plugin_manager::PolicyEvent event) { - switch (event) { - case plugins::kApplicationPolicyUpdated: { - resource_allocation_manager_->OnPolicyEvent(event); - break; - } - default: - break; - } + resource_allocation_manager_->OnPolicyEvent(event); + interior_data_manager_->OnPolicyEvent(event); } void RCRPCPlugin::OnApplicationEvent( @@ -112,10 +106,12 @@ void RCRPCPlugin::OnApplicationEvent( } case plugins::kApplicationExit: { resource_allocation_manager_->OnApplicationEvent(event, application); + interior_data_manager_->OnApplicationEvent(event, application); break; } case plugins::kApplicationUnregistered: { resource_allocation_manager_->OnApplicationEvent(event, application); + interior_data_manager_->OnApplicationEvent(event, application); break; } default: 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 59d1919bb5..c841566949 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 @@ -36,9 +36,10 @@ #include "interfaces/HMI_API.h" #include "interfaces/MOBILE_API.h" #include "smart_objects/enum_schema_item.h" -#include "rc_rpc_plugin/rc_rpc_plugin.h" #include "application_manager/message_helper.h" +#include "rc_rpc_plugin/rc_rpc_plugin.h" #include "rc_rpc_plugin/rc_module_constants.h" +#include "rc_rpc_plugin/rc_helpers.h" #include "json/json.h" #include "utils/helpers.h" @@ -166,13 +167,10 @@ void ResourceAllocationManagerImpl::ProcessApplicationPolicyUpdate() { allowed_modules.end(), std::back_inserter(disallowed_modules)); - RCAppExtensionPtr rc_extention = GetApplicationExtention(app_ptr); + auto rc_extention = RCHelpers::GetRCExtension(**app); Resources::const_iterator module = disallowed_modules.begin(); for (; disallowed_modules.end() != module; ++module) { ReleaseResource(*module, application_id); - if (rc_extention) { - rc_extention->UnsubscribeFromInteriorVehicleData(*module); - } } if (!disallowed_modules.empty()) { SendOnRCStatusNotifications( @@ -182,40 +180,6 @@ void ResourceAllocationManagerImpl::ProcessApplicationPolicyUpdate() { } } -RCAppExtensionPtr ResourceAllocationManagerImpl::GetApplicationExtention( - application_manager::ApplicationSharedPtr application) { - LOG4CXX_AUTO_TRACE(logger_); - RCAppExtensionPtr rc_app_extension; - if (!application) { - return rc_app_extension; - } - - application_manager::AppExtensionPtr app_extension = - application->QueryInterface(RCRPCPlugin::kRCPluginID); - if (!app_extension) { - return rc_app_extension; - } - - rc_app_extension = std::static_pointer_cast(app_extension); - - return rc_app_extension; -} - -void ResourceAllocationManagerImpl::RemoveAppsSubscriptions(const Apps& apps) { - LOG4CXX_AUTO_TRACE(logger_); - Apps::const_iterator app = apps.begin(); - for (; apps.end() != app; ++app) { - application_manager::ApplicationSharedPtr app_ptr = *app; - if (!app_ptr) { - continue; - } - RCAppExtensionPtr rc_extention = GetApplicationExtention(app_ptr); - if (rc_extention) { - rc_extention->UnsubscribeFromInteriorVehicleData(); - } - } -} - template EnumType StringToEnum(const std::string& str) { using smart_objects::EnumConversionHelper; @@ -235,6 +199,7 @@ void ConstructOnRCStatusNotificationParams( using smart_objects::SmartType_Map; using smart_objects::SmartType_Array; LOG4CXX_AUTO_TRACE(logger_); + auto modules_inserter = [](SmartObject& result_modules) { return [&result_modules](const std::string& module_name) { smart_objects::SmartObject module_data = @@ -513,9 +478,6 @@ void ResourceAllocationManagerImpl::OnApplicationEvent( NotificationTrigger::MODULE_ALLOCATION, std::shared_ptr()); } - Apps app_list; - app_list.push_back(application); - RemoveAppsSubscriptions(app_list); } } @@ -532,8 +494,6 @@ void ResourceAllocationManagerImpl::OnPolicyEvent( if (PolicyEvent::kApplicationsDisabled == event) { ResetAllAllocations(); - Apps app_list = RCRPCPlugin::GetRCApplications(app_mngr_); - RemoveAppsSubscriptions(app_list); return; } } 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 d9b21afe20..022a3e51c9 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 @@ -37,6 +37,8 @@ #include "rc_rpc_plugin/rc_rpc_plugin.h" #include "rc_rpc_plugin/rc_module_constants.h" #include "rc_rpc_plugin/mock/mock_resource_allocation_manager.h" +#include "rc_rpc_plugin/mock/mock_interior_data_cache.h" +#include "rc_rpc_plugin/mock/mock_interior_data_manager.h" #include "application_manager/mock_application.h" #include "application_manager/mock_application_manager.h" #include "application_manager/commands/command_request_test.h" @@ -115,7 +117,7 @@ class ButtonPressRequestTest } rc_capabilities_[strings::kbuttonCapabilities] = button_caps; ON_CALL(app_mngr_, application(_)).WillByDefault(Return(mock_app_)); - ON_CALL(mock_allocation_manager_, GetApplicationExtention(_)) + ON_CALL(*mock_app_, QueryInterface(RCRPCPlugin::kRCPluginID)) .WillByDefault(Return(rc_app_extention_)); ON_CALL(app_mngr_, GetPolicyHandler()) .WillByDefault(ReturnRef(mock_policy_handler_)); 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 deb912c49f..4144beea2a 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 @@ -78,7 +78,7 @@ class SetInteriorVehicleDataRequestTest .WillByDefault(Return(application_manager::HmiInterfaces:: InterfaceState::STATE_AVAILABLE)); ON_CALL(app_mngr_, application(kAppId)).WillByDefault(Return(mock_app_)); - ON_CALL(mock_allocation_manager_, GetApplicationExtention(_)) + ON_CALL(*mock_app_, QueryInterface(RCRPCPlugin::kRCPluginID)) .WillByDefault(Return(rc_app_extention_)); ON_CALL(*mock_app_, policy_app_id()).WillByDefault(Return(kPolicyAppId)); 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 18308f62cf..72ace1432a 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 @@ -61,9 +61,6 @@ class MockResourceAllocationManager const uint32_t app_id, const rc_rpc_plugin::ResourceState::eType state)); MOCK_CONST_METHOD1(IsResourceFree, bool(const std::string& module_type)); - MOCK_METHOD1(GetApplicationExtention, - rc_rpc_plugin::RCAppExtensionPtr( - application_manager::ApplicationSharedPtr application)); MOCK_METHOD0(ResetAllAllocations, void()); MOCK_METHOD2(SendOnRCStatusNotifications, void(rc_rpc_plugin::NotificationTrigger::eType, -- cgit v1.2.1 From 4c80d2df3a2607cbda93533e5eda89db28a7954b Mon Sep 17 00:00:00 2001 From: Alexander Date: Fri, 20 Jul 2018 13:39:57 +0300 Subject: Add Nice mock to avoid GmockWarnings --- .../test/include/application_manager/commands/commands_test.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) 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 d795557f80..9a961ea1a9 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 @@ -44,6 +44,7 @@ #include "application_manager/test/include/application_manager/mock_hmi_interface.h" #include "application_manager/test/include/application_manager/mock_application.h" #include "application_manager/test/include/application_manager/mock_message_helper.h" +#include "application_manager/mock_application_manager_settings.h" #include "application_manager/mock_rpc_service.h" #include "application_manager/mock_hmi_capabilities.h" #include "application_manager/policies/mock_policy_handler_interface.h" @@ -149,8 +150,10 @@ class CommandsTest : public ::testing::Test { MockAppManager app_mngr_; MockRPCService mock_rpc_service_; - application_manager_test::MockHMICapabilities mock_hmi_capabilities_; - policy_test::MockPolicyHandlerInterface mock_policy_handler_; + testing::NiceMock + mock_hmi_capabilities_; + testing::NiceMock + mock_policy_handler_; MockAppManagerSettings app_mngr_settings_; MOCK(am::MockHmiInterfaces) mock_hmi_interfaces_; am::MockMessageHelper& mock_message_helper_; -- cgit v1.2.1 From 87263afd5168650e9fe0980e6a3fb56ebe360d8e Mon Sep 17 00:00:00 2001 From: Alexander Date: Fri, 20 Jul 2018 13:41:46 +0300 Subject: Process disabling RC with interior_data_manager --- .../hmi/rc_on_remote_control_settings_notification.cc | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_on_remote_control_settings_notification.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_on_remote_control_settings_notification.cc index fd404601a3..b67e3e2553 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_on_remote_control_settings_notification.cc +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_on_remote_control_settings_notification.cc @@ -87,13 +87,6 @@ std::string AccessModeToString( return error; } -void UnsubscribeFromInteriorVehicleDataForAllModules( - RCAppExtensionPtr extension) { - LOG4CXX_AUTO_TRACE(logger_); - extension->UnsubscribeFromInteriorVehicleData(enums_value::kClimate); - extension->UnsubscribeFromInteriorVehicleData(enums_value::kRadio); -} - void RCOnRemoteControlSettingsNotification::DisallowRCFunctionality() { LOG4CXX_AUTO_TRACE(logger_); typedef std::vector Apps; @@ -103,14 +96,8 @@ void RCOnRemoteControlSettingsNotification::DisallowRCFunctionality() { DCHECK(app); application_manager_.ChangeAppsHMILevel( app->app_id(), mobile_apis::HMILevel::eType::HMI_NONE); - - const RCAppExtensionPtr extension = - std::static_pointer_cast( - app->QueryInterface(RCRPCPlugin::kRCPluginID)); - if (extension) { - UnsubscribeFromInteriorVehicleDataForAllModules(extension); - } } + interior_data_manager_.OnDisablingRC(); } void RCOnRemoteControlSettingsNotification::Run() { -- cgit v1.2.1 From bc71ed85044358a7eb2f2e72bb52047a9b5e6d37 Mon Sep 17 00:00:00 2001 From: Alexander Date: Fri, 20 Jul 2018 13:42:08 +0300 Subject: Remove redundant check of RC extension --- .../rc_rpc_plugin/src/commands/rc_command_request.cc | 6 ------ .../test/resource_allocation_manager_impl_test.cc | 14 -------------- 2 files changed, 20 deletions(-) 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 9e3308b825..40249387a7 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 @@ -79,12 +79,6 @@ bool RCCommandRequest::CheckDriverConsent() { LOG4CXX_AUTO_TRACE(logger_); app_mngr::ApplicationSharedPtr app = application_manager_.application(CommandRequestImpl::connection_key()); - RCAppExtensionPtr extension = - resource_allocation_manager_.GetApplicationExtention(app); - if (!extension) { - LOG4CXX_ERROR(logger_, "NULL pointer."); - return false; - } const std::string module_type = ModuleType(); rc_rpc_plugin::TypeAccess access = CheckModule(module_type, app); diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/resource_allocation_manager_impl_test.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/resource_allocation_manager_impl_test.cc index 7eb298f024..86c58b9d46 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/resource_allocation_manager_impl_test.cc +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/resource_allocation_manager_impl_test.cc @@ -298,13 +298,6 @@ TEST_F(RAManagerTest, AnotherAppExit_NoReleaseResource) { EXPECT_CALL(mock_app_mngr_, application(kAppId2)) .WillRepeatedly(Return(mock_app_2_)); - RCAppExtensionPtr rc_extention_ptr = - std::make_shared(application_manager::AppExtensionUID( - rc_rpc_plugin::RCRPCPlugin::kRCPluginID)); - - EXPECT_CALL(*mock_app_2_, QueryInterface(_)) - .WillOnce(Return(rc_extention_ptr)); - // Act application_manager::ApplicationSharedPtr app_ptr(mock_app_2_); EXPECT_CALL(*mock_app_2_, app_id()).WillRepeatedly(Return(kAppId2)); @@ -358,13 +351,6 @@ TEST_F(RAManagerTest, AnotherAppUnregistered_NoReleaseResource) { EXPECT_CALL(mock_app_mngr_, application(kAppId1)) .WillRepeatedly(Return(mock_app_2_)); - RCAppExtensionPtr rc_extention_ptr = - std::make_shared(application_manager::AppExtensionUID( - rc_rpc_plugin::RCRPCPlugin::kRCPluginID)); - - EXPECT_CALL(*mock_app_2_, QueryInterface(_)) - .WillOnce(Return(rc_extention_ptr)); - // Act application_manager::ApplicationSharedPtr app_ptr(mock_app_2_); EXPECT_CALL(*mock_app_2_, app_id()).WillRepeatedly(Return(kAppId2)); -- cgit v1.2.1 From 9db61e9d048bb0d5b76d058262326ecb108dbcbf Mon Sep 17 00:00:00 2001 From: Alexander Date: Thu, 16 Aug 2018 20:52:50 +0300 Subject: fixup! Add Interior data cache and interior data manager --- .../rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_helpers.h | 2 +- .../rpc_plugins/rc_rpc_plugin/src/interior_data_manager_impl.cc | 2 +- .../application_manager/rpc_plugins/rc_rpc_plugin/src/rc_helpers.cc | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_helpers.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_helpers.h index e20a982d91..4116777747 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_helpers.h +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_helpers.h @@ -74,7 +74,7 @@ class RCHelpers { typedef std::map > AppsModules; - static AppsModules GetApplicaitonsAllowedModules( + static AppsModules GetApplicationsAllowedModules( application_manager::ApplicationManager& app_mngr); }; diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/interior_data_manager_impl.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/interior_data_manager_impl.cc index 1f6290ad10..28ed2cd941 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/interior_data_manager_impl.cc +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/interior_data_manager_impl.cc @@ -69,7 +69,7 @@ bool InteriorDataManagerImpl::CheckRequestsToHMIFrequency( void InteriorDataManagerImpl::UpdateHMISubscriptionsOnPolicyUpdated() { auto apps_allowed_modules = - RCHelpers::GetApplicaitonsAllowedModules(app_mngr_); + RCHelpers::GetApplicationsAllowedModules(app_mngr_); auto apps_subscribed_modules = AppsSubscribedModules(); InteriorDataManagerImpl::AppsModules apps_disallowed_modules; for (auto& pair : apps_subscribed_modules) { diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/rc_helpers.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/rc_helpers.cc index a8c29752d7..f46a76a151 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/rc_helpers.cc +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/rc_helpers.cc @@ -72,7 +72,7 @@ RCHelpers::AppsSubscribedToModuleType( return result; } -RCHelpers::AppsModules RCHelpers::GetApplicaitonsAllowedModules( +RCHelpers::AppsModules RCHelpers::GetApplicationsAllowedModules( app_mngr::ApplicationManager& app_mngr) { auto apps_list = RCRPCPlugin::GetRCApplications(app_mngr); RCHelpers::AppsModules result; -- cgit v1.2.1 From 5833c44448111077753e237f5aa670af69f762be Mon Sep 17 00:00:00 2001 From: vkushnirenko-luxoft Date: Mon, 20 Aug 2018 12:34:22 +0300 Subject: Fix Jenkins CI status --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 80a6fbc88d..86d07c3d83 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ [![Slack Status](http://sdlslack.herokuapp.com/badge.svg)](http://slack.smartdevicelink.com) [![codecov.io](https://codecov.io/github/smartdevicelink/sdl_core/coverage.svg?branch=develop)](https://codecov.io/github/smartdevicelink/sdl_core?branch=develop) -[![Build Status](http://opensdl-jenkins.luxoft.com:8080/buildStatus/icon?job=OpenSDL_Nightly)](http://opensdl-jenkins.luxoft.com:8080/view/All/job/OpenSDL_Nightly/) +[![Build Status](http://opensdl-jenkins.luxoft.com:8080/view/develop/job/develop_nightly_coverage/badge/icon)](http://opensdl-jenkins.luxoft.com:8080/view/develop/job/develop_nightly_coverage/) # SmartDeviceLink (SDL) -- cgit v1.2.1 From 37c6d3a65228fa61b44bc3164e0dd1bf3c1833df Mon Sep 17 00:00:00 2001 From: Alexander Date: Mon, 20 Aug 2018 14:04:20 +0300 Subject: Moved mapping from module types to module data and capabilities keys in one place --- .../include/rc_rpc_plugin/rc_helpers.h | 14 +++++ .../resource_allocation_manager_impl.h | 1 - .../mobile/get_interior_vehicle_data_request.cc | 15 ++--- .../mobile/set_interior_vehicle_data_request.cc | 71 ++++++++++------------ .../rpc_plugins/rc_rpc_plugin/src/rc_helpers.cc | 34 ++++++++++- .../src/resource_allocation_manager_impl.cc | 20 ++---- 6 files changed, 87 insertions(+), 68 deletions(-) diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_helpers.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_helpers.h index 4116777747..cf3c6cd5e4 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_helpers.h +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_helpers.h @@ -56,6 +56,20 @@ class RCHelpers { static const std::function GetModuleTypeToDataMapping(); + /** + * @brief GetModuleTypeToDataMapping get mapping of module type enum naming to + * actual module capabilities key + * @return module mapping from enum naming to capabilities key + */ + static const std::function + GetModuleTypeToCapabilitiesMapping(); + + /** + * @brief GetModulesList get list of all known modules + * @return vector contains all known modules + */ + static const std::vector GetModulesList(); + /** * @brief GetRCExtension extract RC extension from application * @param app application to extract extension 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 d7d3a4743f..b359ee4d29 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 @@ -190,7 +190,6 @@ class ResourceAllocationManagerImpl : public ResourceAllocationManager { */ void SetResourceFree(const std::string& module_type, const uint32_t app_id); - std::vector all_supported_modules(); /** * @brief AllocatedResources contains link between resource and application * owning that resource diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/get_interior_vehicle_data_request.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/get_interior_vehicle_data_request.cc index c5c888a6b1..6178405808 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/get_interior_vehicle_data_request.cc +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/get_interior_vehicle_data_request.cc @@ -57,17 +57,12 @@ bool CheckIfModuleTypeExistInCapabilities( const smart_objects::SmartObject& rc_capabilities, const std::string& module_type) { LOG4CXX_AUTO_TRACE(logger_); - const std::map params = { - {enums_value::kRadio, strings::kradioControlCapabilities}, - {enums_value::kClimate, strings::kclimateControlCapabilities}, - {enums_value::kAudio, strings::kaudioControlCapabilities}, - {enums_value::kLight, strings::klightControlCapabilities}, - {enums_value::kSeat, strings::kseatControlCapabilities}, - {enums_value::kHmiSettings, strings::khmiSettingsControlCapabilities}}; + const auto& mapping = RCHelpers::GetModuleTypeToCapabilitiesMapping(); + const auto& module_list = RCHelpers::GetModulesList(); bool is_module_type_valid = false; - for (const auto& param : params) { - if (param.first == module_type) { - if (rc_capabilities.keyExists(param.second)) { + for (const auto& module : module_list) { + if (module == module_type) { + if (rc_capabilities.keyExists(mapping(module))) { is_module_type_valid = true; break; } diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/set_interior_vehicle_data_request.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/set_interior_vehicle_data_request.cc index e1bec1ce5f..17a492b5aa 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/set_interior_vehicle_data_request.cc +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/set_interior_vehicle_data_request.cc @@ -33,6 +33,7 @@ #include "rc_rpc_plugin/commands/mobile/set_interior_vehicle_data_request.h" #include "rc_rpc_plugin/rc_module_constants.h" #include "rc_rpc_plugin/rc_rpc_plugin.h" +#include "rc_rpc_plugin/rc_helpers.h" #include "smart_objects/enum_schema_item.h" #include "utils/macro.h" #include "json/json.h" @@ -62,17 +63,6 @@ std::vector GetModuleReadOnlyParams( return module_ro_params; } -const std::map GetModuleTypeToDataMapping() { - std::map mapping = { - {enums_value::kRadio, message_params::kRadioControlData}, - {enums_value::kClimate, message_params::kClimateControlData}, - {enums_value::kAudio, message_params::kAudioControlData}, - {enums_value::kLight, message_params::kLightControlData}, - {enums_value::kHmiSettings, message_params::kHmiSettingsControlData}, - {enums_value::kSeat, message_params::kSeatControlData}}; - return mapping; -} - const std::map GetModuleDataToCapabilitiesMapping() { std::map mapping; // climate @@ -290,30 +280,30 @@ bool CheckIfModuleDataExistInCapabilities( const smart_objects::SmartObject& rc_capabilities, const smart_objects::SmartObject& module_data) { LOG4CXX_AUTO_TRACE(logger_); - const std::map params = { - {message_params::kRadioControlData, strings::kradioControlCapabilities}, - {message_params::kClimateControlData, - strings::kclimateControlCapabilities}, - {message_params::kAudioControlData, strings::kaudioControlCapabilities}, - {message_params::kLightControlData, strings::klightControlCapabilities}, - {message_params::kSeatControlData, strings::kseatControlCapabilities}, - {message_params::kHmiSettingsControlData, - strings::khmiSettingsControlCapabilities}}; + + const auto& all_module_types = RCHelpers::GetModulesList(); + const auto& get_module_data_key = RCHelpers::GetModuleTypeToDataMapping(); + const auto& get_capabilities_key = + RCHelpers::GetModuleTypeToCapabilitiesMapping(); + bool is_module_data_valid = false; - for (const auto& param : params) { - if (module_data.keyExists(param.first)) { - if (!rc_capabilities.keyExists(param.second)) { - LOG4CXX_DEBUG(logger_, param.first << " capabilities not present"); + for (const auto& module_type : all_module_types) { + const auto module_data_key = get_module_data_key(module_type); + const auto capabilities_key = get_capabilities_key(module_type); + if (module_data.keyExists(module_data_key)) { + if (!rc_capabilities.keyExists(capabilities_key)) { + LOG4CXX_DEBUG(logger_, module_data_key << " capabilities not present"); return false; } - const smart_objects::SmartObject& caps = rc_capabilities[param.second]; - if (message_params::kHmiSettingsControlData == param.first || - message_params::kLightControlData == param.first) { + const smart_objects::SmartObject& caps = + rc_capabilities[capabilities_key]; + if (message_params::kHmiSettingsControlData == module_data_key || + message_params::kLightControlData == module_data_key) { is_module_data_valid = - CheckControlDataByCapabilities(caps, module_data[param.first]); + CheckControlDataByCapabilities(caps, module_data[module_data_key]); } else { - is_module_data_valid = - CheckControlDataByCapabilities(caps[0], module_data[param.first]); + is_module_data_valid = CheckControlDataByCapabilities( + caps[0], module_data[module_data_key]); } } } @@ -323,12 +313,12 @@ bool CheckIfModuleDataExistInCapabilities( bool isModuleTypeAndDataMatch(const std::string& module_type, const smart_objects::SmartObject& module_data) { LOG4CXX_AUTO_TRACE(logger_); - std::map data_mapping = - GetModuleTypeToDataMapping(); + const auto& all_module_types = RCHelpers::GetModulesList(); + const auto& data_mapping = RCHelpers::GetModuleTypeToDataMapping(); bool module_type_and_data_match = false; - for (const auto& data : data_mapping) { - if (data.first == module_type) { - module_type_and_data_match = module_data.keyExists(data.second); + for (const auto& type : all_module_types) { + if (type == module_type) { + module_type_and_data_match = module_data.keyExists(data_mapping(type)); break; } } @@ -438,11 +428,12 @@ void SetInteriorVehicleDataRequest::on_event( const smart_objects::SmartObject& SetInteriorVehicleDataRequest::ControlData( const smart_objects::SmartObject& module_data) { const std::string module_type = ModuleType(); - std::map data_mapping = - GetModuleTypeToDataMapping(); - for (const auto& data : data_mapping) { - if (data.first == module_type) { - return module_data[data.second]; + + const auto& all_module_types = RCHelpers::GetModulesList(); + const auto& data_mapping = RCHelpers::GetModuleTypeToDataMapping(); + for (const auto& type : all_module_types) { + if (type == module_type) { + return module_data[data_mapping(type)]; } } NOTREACHED(); diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/rc_helpers.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/rc_helpers.cc index f46a76a151..0bdec55733 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/rc_helpers.cc +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/rc_helpers.cc @@ -12,11 +12,15 @@ const std::function RCHelpers::GetModuleTypeToDataMapping() { auto mapping_lambda = [](const std::string& module_type) -> std::string { static std::map mapping = { - {enums_value::kRadio, message_params::kRadioControlData}, {enums_value::kClimate, message_params::kClimateControlData}, - {enums_value::kSeat, message_params::kSeatControlData}}; + {enums_value::kRadio, message_params::kRadioControlData}, + {enums_value::kSeat, message_params::kSeatControlData}, + {enums_value::kAudio, message_params::kAudioControlData}, + {enums_value::kLight, message_params::kLightControlData}, + {enums_value::kHmiSettings, message_params::kHmiSettingsControlData}}; auto it = mapping.find(module_type); if (mapping.end() == it) { + LOG4CXX_ERROR(logger_, "Unknown module type" << module_type); return std::string(); } return it->second; @@ -25,6 +29,32 @@ RCHelpers::GetModuleTypeToDataMapping() { return mapping_lambda; } +const std::function +RCHelpers::GetModuleTypeToCapabilitiesMapping() { + auto mapping_lambda = [](const std::string& module_type) -> std::string { + static std::map mapping = { + {enums_value::kClimate, strings::kclimateControlCapabilities}, + {enums_value::kRadio, strings::kradioControlCapabilities}, + {enums_value::kSeat, strings::kseatControlCapabilities}, + {enums_value::kAudio, strings::kaudioControlCapabilities}, + {enums_value::kLight, strings::klightControlCapabilities}, + {enums_value::kHmiSettings, strings::khmiSettingsControlCapabilities}}; + auto it = mapping.find(module_type); + if (mapping.end() == it) { + LOG4CXX_ERROR(logger_, "Unknown module type" << module_type); + return std::string(); + } + return it->second; + }; + + return mapping_lambda; +} + +const std::vector RCHelpers::GetModulesList() { + using namespace enums_value; + return {kClimate, kRadio, kSeat, kAudio, kLight, kHmiSettings}; +} + RCAppExtensionPtr RCHelpers::GetRCExtension( application_manager::Application& app) { auto extension_interface = app.QueryInterface(RCRPCPlugin::kRCPluginID); 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 c841566949..ecd263b77a 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 @@ -238,7 +238,7 @@ ResourceAllocationManagerImpl::CreateOnRCStatusNotificationToMobile( if (is_rc_enabled()) { ConstructOnRCStatusNotificationParams(msg_params, allocated_resources_, - all_supported_modules(), + RCHelpers::GetModulesList(), app->app_id()); } else { msg_params[message_params::kAllocatedModules] = @@ -257,8 +257,10 @@ ResourceAllocationManagerImpl::CreateOnRCStatusNotificationToHmi( auto msg_to_hmi = MessageHelper::CreateHMINotification(hmi_apis::FunctionID::RC_OnRCStatus); auto& msg_params = (*msg_to_hmi)[application_manager::strings::msg_params]; - ConstructOnRCStatusNotificationParams( - msg_params, allocated_resources_, all_supported_modules(), app->app_id()); + ConstructOnRCStatusNotificationParams(msg_params, + allocated_resources_, + RCHelpers::GetModulesList(), + app->app_id()); msg_params[application_manager::strings::app_id] = app->hmi_app_id(); return msg_to_hmi; } @@ -326,18 +328,6 @@ void ResourceAllocationManagerImpl::SetResourceFree( LOG4CXX_DEBUG(logger_, "Resource " << module_type << " is released."); } -std::vector -ResourceAllocationManagerImpl::all_supported_modules() { - std::vector result; - result.push_back(enums_value::kClimate); - result.push_back(enums_value::kRadio); - result.push_back(enums_value::kSeat); - result.push_back(enums_value::kAudio); - result.push_back(enums_value::kLight); - result.push_back(enums_value::kHmiSettings); - return result; -} - std::vector ResourceAllocationManagerImpl::GetAcquiredResources( const uint32_t application_id) const { LOG4CXX_AUTO_TRACE(logger_); -- cgit v1.2.1 From 688036eb1de0a4f9ae378f95c73e6bb03081c799 Mon Sep 17 00:00:00 2001 From: Alexander Date: Mon, 20 Aug 2018 14:04:33 +0300 Subject: Fix style in application_manager --- src/components/application_manager/src/application_manager_impl.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/application_manager/src/application_manager_impl.cc b/src/components/application_manager/src/application_manager_impl.cc index 386bfe4825..951f2529a1 100644 --- a/src/components/application_manager/src/application_manager_impl.cc +++ b/src/components/application_manager/src/application_manager_impl.cc @@ -1949,7 +1949,7 @@ bool ApplicationManagerImpl::Stop() { application_list_update_timer_.Stop(); try { SetUnregisterAllApplicationsReason( - mobile_api::AppInterfaceUnregisteredReason::IGNITION_OFF); + mobile_api::AppInterfaceUnregisteredReason::IGNITION_OFF); UnregisterAllApplications(); } catch (...) { LOG4CXX_ERROR(logger_, -- cgit v1.2.1 From d3b1ab462a1617a89cd4372c0aaa58a12c96287f Mon Sep 17 00:00:00 2001 From: Andriy Byzhynar Date: Wed, 27 Jun 2018 11:59:04 +0300 Subject: Edit error in function name --- src/appMain/main.cc | 4 ++-- src/components/utils/include/utils/signals.h | 2 +- src/components/utils/src/signals_posix.cc | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/appMain/main.cc b/src/appMain/main.cc index feb5b5830e..02f1023ff4 100644 --- a/src/appMain/main.cc +++ b/src/appMain/main.cc @@ -94,8 +94,8 @@ bool InitHmi(std::string hmi_link) { * \return EXIT_SUCCESS or EXIT_FAILURE */ int32_t main(int32_t argc, char** argv) { - // Unsibscribe once for all threads - if (!utils::UnsibscribeFromTermination()) { + // Unsubscribe once for all threads + if (!utils::UnsubscribeFromTermination()) { // Can't use internal logger here exit(EXIT_FAILURE); } diff --git a/src/components/utils/include/utils/signals.h b/src/components/utils/include/utils/signals.h index 72d29a9e28..e413a2576f 100644 --- a/src/components/utils/include/utils/signals.h +++ b/src/components/utils/include/utils/signals.h @@ -41,7 +41,7 @@ typedef void (*sighandler_t)(int); namespace utils { -bool UnsibscribeFromTermination(); +bool UnsubscribeFromTermination(); bool WaitTerminationSignals(sighandler_t sig_handler); } // namespace utils diff --git a/src/components/utils/src/signals_posix.cc b/src/components/utils/src/signals_posix.cc index 274c254716..45923e4f9b 100644 --- a/src/components/utils/src/signals_posix.cc +++ b/src/components/utils/src/signals_posix.cc @@ -35,7 +35,7 @@ #include "utils/signals.h" -bool utils::UnsibscribeFromTermination() { +bool utils::UnsubscribeFromTermination() { // Disable some system signals receiving in thread // by blocking those signals // (system signals processes only in the main thread) -- cgit v1.2.1 From af2f7dfa77e92694095104fe6949c412f8edf12e Mon Sep 17 00:00:00 2001 From: Andriy Byzhynar Date: Wed, 27 Jun 2018 13:11:11 +0300 Subject: Create Life Cycle class interface Created Life cycle class interface in order: - to make unit-testing available - to decrease components coupling --- src/appMain/CMakeLists.txt | 1 + src/appMain/life_cycle.cc | 319 ---------------------------------------- src/appMain/life_cycle.h | 87 ++++------- src/appMain/life_cycle_impl.cc | 320 +++++++++++++++++++++++++++++++++++++++++ src/appMain/life_cycle_impl.h | 136 ++++++++++++++++++ src/appMain/main.cc | 18 +-- src/appMain/signal_handlers.cc | 4 +- 7 files changed, 495 insertions(+), 390 deletions(-) delete mode 100644 src/appMain/life_cycle.cc create mode 100644 src/appMain/life_cycle_impl.cc create mode 100644 src/appMain/life_cycle_impl.h diff --git a/src/appMain/CMakeLists.txt b/src/appMain/CMakeLists.txt index b821c94260..51b6a947e8 100644 --- a/src/appMain/CMakeLists.txt +++ b/src/appMain/CMakeLists.txt @@ -70,6 +70,7 @@ include_directories( ${default_media_inc} ${MESSAGE_BROKER_INCLUDE_DIRECTORY} ${BOOST_INCLUDE_DIR} + ${CMAKE_SOURCE_DIR}/src ) collect_sources(SOURCES "${CMAKE_CURRENT_SOURCE_DIR}") diff --git a/src/appMain/life_cycle.cc b/src/appMain/life_cycle.cc deleted file mode 100644 index dae70e3318..0000000000 --- a/src/appMain/life_cycle.cc +++ /dev/null @@ -1,319 +0,0 @@ -/* -* Copyright (c) 2017, 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 "life_cycle.h" -#include "utils/signals.h" -#include "config_profile/profile.h" -#include "application_manager/system_time/system_time_handler_impl.h" -#include "resumption/last_state_impl.h" - -#ifdef ENABLE_SECURITY -#include "security_manager/security_manager_impl.h" -#include "security_manager/crypto_manager_impl.h" -#include "security_manager/crypto_manager_settings_impl.h" -#include "application_manager/policies/policy_handler.h" -#endif // ENABLE_SECURITY - -#ifdef ENABLE_LOG -#include "utils/log_message_loop_thread.h" -#endif // ENABLE_LOG - -using threads::Thread; - -namespace main_namespace { - -CREATE_LOGGERPTR_GLOBAL(logger_, "SDLMain") - -LifeCycle::LifeCycle(const profile::Profile& profile) - : transport_manager_(NULL) - , protocol_handler_(NULL) - , connection_handler_(NULL) - , app_manager_(NULL) -#ifdef ENABLE_SECURITY - , crypto_manager_(NULL) - , security_manager_(NULL) -#endif // ENABLE_SECURITY - , hmi_handler_(NULL) - , hmi_message_adapter_(NULL) - , media_manager_(NULL) - , last_state_(NULL) -#ifdef TELEMETRY_MONITOR - , telemetry_monitor_(NULL) -#endif // TELEMETRY_MONITOR -#ifdef MESSAGEBROKER_HMIADAPTER - , mb_adapter_(NULL) - , mb_adapter_thread_(NULL) -#endif // MESSAGEBROKER_HMIADAPTER - , profile_(profile) { -} - -bool LifeCycle::StartComponents() { - LOG4CXX_AUTO_TRACE(logger_); - DCHECK(!last_state_); - last_state_ = new resumption::LastStateImpl(profile_.app_storage_folder(), - profile_.app_info_storage()); - - DCHECK(!transport_manager_); - transport_manager_ = new transport_manager::TransportManagerDefault(profile_); - - DCHECK(!connection_handler_); - connection_handler_ = new connection_handler::ConnectionHandlerImpl( - profile_, *transport_manager_); - - DCHECK(!protocol_handler_); - protocol_handler_ = - new protocol_handler::ProtocolHandlerImpl(profile_, - *connection_handler_, - *connection_handler_, - *transport_manager_); - DCHECK(protocol_handler_); - - DCHECK(!app_manager_); - app_manager_ = - new application_manager::ApplicationManagerImpl(profile_, profile_); - - DCHECK(!hmi_handler_); - hmi_handler_ = new hmi_message_handler::HMIMessageHandlerImpl(profile_); - - hmi_handler_->set_message_observer(&(app_manager_->GetRPCHandler())); - app_manager_->set_hmi_message_handler(hmi_handler_); - - media_manager_ = new media_manager::MediaManagerImpl(*app_manager_, profile_); - app_manager_->set_connection_handler(connection_handler_); - if (!app_manager_->Init(*last_state_, media_manager_)) { - LOG4CXX_ERROR(logger_, "Application manager init failed."); - return false; - } - -#ifdef ENABLE_SECURITY - auto system_time_handler = - std::unique_ptr( - new application_manager::SystemTimeHandlerImpl(*app_manager_)); - security_manager_ = - new security_manager::SecurityManagerImpl(std::move(system_time_handler)); - crypto_manager_ = new security_manager::CryptoManagerImpl( - std::make_shared( - profile_, app_manager_->GetPolicyHandler().RetrieveCertificate())); - protocol_handler_->AddProtocolObserver(security_manager_); - protocol_handler_->set_security_manager(security_manager_); - - security_manager_->set_session_observer(connection_handler_); - security_manager_->set_protocol_handler(protocol_handler_); - security_manager_->set_crypto_manager(crypto_manager_); - security_manager_->AddListener(app_manager_); - - app_manager_->AddPolicyObserver(security_manager_); - app_manager_->AddPolicyObserver(protocol_handler_); - if (!crypto_manager_->Init()) { - LOG4CXX_ERROR(logger_, "CryptoManager initialization fail."); - return false; - } -#endif // ENABLE_SECURITY - - transport_manager_->AddEventListener(protocol_handler_); - transport_manager_->AddEventListener(connection_handler_); - - protocol_handler_->AddProtocolObserver(media_manager_); - protocol_handler_->AddProtocolObserver(&(app_manager_->GetRPCHandler())); - - media_manager_->SetProtocolHandler(protocol_handler_); - - connection_handler_->set_protocol_handler(protocol_handler_); - connection_handler_->set_connection_handler_observer(app_manager_); - -// it is important to initialise TelemetryMonitor before TM to listen TM -// Adapters -#ifdef TELEMETRY_MONITOR - telemetry_monitor_ = new telemetry_monitor::TelemetryMonitor( - profile_.server_address(), profile_.time_testing_port()); - telemetry_monitor_->Start(); - telemetry_monitor_->Init(protocol_handler_, app_manager_, transport_manager_); -#endif // TELEMETRY_MONITOR - // It's important to initialise TM after setting up listener chain - // [TM -> CH -> AM], otherwise some events from TM could arrive at nowhere - app_manager_->set_protocol_handler(protocol_handler_); - transport_manager_->Init(*last_state_); - // start transport manager - transport_manager_->Visibility(true); - - return true; -} - -#ifdef MESSAGEBROKER_HMIADAPTER -bool LifeCycle::InitMessageSystem() { - mb_adapter_ = new hmi_message_handler::MessageBrokerAdapter( - hmi_handler_, profile_.server_address(), profile_.server_port()); - - if (!mb_adapter_->StartListener()) { - return false; - } - - hmi_handler_->AddHMIMessageAdapter(mb_adapter_); - mb_adapter_thread_ = new std::thread( - &hmi_message_handler::MessageBrokerAdapter::Run, mb_adapter_); - return true; -} -#endif // MESSAGEBROKER_HMIADAPTER - -namespace { -void sig_handler(int sig) { - switch (sig) { - case SIGINT: - LOG4CXX_DEBUG(logger_, "SIGINT signal has been caught"); - break; - case SIGTERM: - LOG4CXX_DEBUG(logger_, "SIGTERM signal has been caught"); - break; - case SIGSEGV: - LOG4CXX_DEBUG(logger_, "SIGSEGV signal has been caught"); - FLUSH_LOGGER(); - // exit need to prevent endless sending SIGSEGV - // http://stackoverflow.com/questions/2663456/how-to-write-a-signal-handler-to-catch-sigsegv - abort(); - default: - LOG4CXX_DEBUG(logger_, "Unexpected signal has been caught"); - exit(EXIT_FAILURE); - } -} -} // namespace - -void LifeCycle::Run() { - LOG4CXX_AUTO_TRACE(logger_); - // Register signal handlers and wait sys signals - // from OS - if (!utils::WaitTerminationSignals(&sig_handler)) { - LOG4CXX_FATAL(logger_, "Fail to catch system signal!"); - } -} - -void LifeCycle::StopComponents() { - LOG4CXX_AUTO_TRACE(logger_); - - DCHECK_OR_RETURN_VOID(hmi_handler_); - hmi_handler_->set_message_observer(NULL); - - DCHECK_OR_RETURN_VOID(connection_handler_); - connection_handler_->set_connection_handler_observer(NULL); - - DCHECK_OR_RETURN_VOID(protocol_handler_); - protocol_handler_->RemoveProtocolObserver(&(app_manager_->GetRPCHandler())); - - DCHECK_OR_RETURN_VOID(app_manager_); - app_manager_->Stop(); - - LOG4CXX_INFO(logger_, "Stopping Protocol Handler"); - DCHECK_OR_RETURN_VOID(protocol_handler_); - protocol_handler_->RemoveProtocolObserver(media_manager_); - -#ifdef ENABLE_SECURITY - protocol_handler_->RemoveProtocolObserver(security_manager_); - if (security_manager_) { - security_manager_->RemoveListener(app_manager_); - LOG4CXX_INFO(logger_, "Destroying Crypto Manager"); - delete crypto_manager_; - crypto_manager_ = NULL; - LOG4CXX_INFO(logger_, "Destroying Security Manager"); - delete security_manager_; - security_manager_ = NULL; - } -#endif // ENABLE_SECURITY - protocol_handler_->Stop(); - - LOG4CXX_INFO(logger_, "Destroying Media Manager"); - DCHECK_OR_RETURN_VOID(media_manager_); - media_manager_->SetProtocolHandler(NULL); - delete media_manager_; - media_manager_ = NULL; - - LOG4CXX_INFO(logger_, "Destroying Transport Manager."); - DCHECK_OR_RETURN_VOID(transport_manager_); - transport_manager_->Visibility(false); - transport_manager_->Stop(); - delete transport_manager_; - transport_manager_ = NULL; - - LOG4CXX_INFO(logger_, "Stopping Connection Handler."); - DCHECK_OR_RETURN_VOID(connection_handler_); - connection_handler_->Stop(); - - LOG4CXX_INFO(logger_, "Destroying Protocol Handler"); - DCHECK(protocol_handler_); - delete protocol_handler_; - protocol_handler_ = NULL; - - LOG4CXX_INFO(logger_, "Destroying Connection Handler."); - delete connection_handler_; - connection_handler_ = NULL; - - LOG4CXX_INFO(logger_, "Destroying Last State"); - DCHECK(last_state_); - delete last_state_; - last_state_ = NULL; - - LOG4CXX_INFO(logger_, "Destroying Application Manager."); - DCHECK(app_manager_); - delete app_manager_; - app_manager_ = NULL; - - LOG4CXX_INFO(logger_, "Destroying HMI Message Handler and MB adapter."); - -#ifdef MESSAGEBROKER_HMIADAPTER - if (mb_adapter_) { - DCHECK_OR_RETURN_VOID(hmi_handler_); - hmi_handler_->RemoveHMIMessageAdapter(mb_adapter_); - mb_adapter_->unregisterController(); - mb_adapter_->exitReceivingThread(); - if (mb_adapter_thread_ != NULL) { - mb_adapter_thread_->join(); - } - delete mb_adapter_; - mb_adapter_ = NULL; - delete mb_adapter_thread_; - mb_adapter_thread_ = NULL; - } - LOG4CXX_INFO(logger_, "Destroying Message Broker"); -#endif // MESSAGEBROKER_HMIADAPTER - DCHECK_OR_RETURN_VOID(hmi_handler_); - delete hmi_handler_; - hmi_handler_ = NULL; - -#ifdef TELEMETRY_MONITOR - // It's important to delete tester Obcervers after TM adapters destruction - if (telemetry_monitor_) { - telemetry_monitor_->Stop(); - delete telemetry_monitor_; - telemetry_monitor_ = NULL; - } -#endif // TELEMETRY_MONITOR -} - -} // namespace main_namespace diff --git a/src/appMain/life_cycle.h b/src/appMain/life_cycle.h index a9b18e1bd9..d14b91d13f 100644 --- a/src/appMain/life_cycle.h +++ b/src/appMain/life_cycle.h @@ -1,5 +1,5 @@ /* -* Copyright (c) 2016, Ford Motor Company +* Copyright (c) 2018, Ford Motor Company * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -32,77 +32,42 @@ #ifndef SRC_APPMAIN_LIFE_CYCLE_H_ #define SRC_APPMAIN_LIFE_CYCLE_H_ -#include -#include -#include "utils/macro.h" -#include "config_profile/profile.h" -#include "hmi_message_handler/hmi_message_handler_impl.h" -#if (defined(MESSAGEBROKER_HMIADAPTER) || defined(PASA_HMI)) -#include "hmi_message_handler/messagebroker_adapter.h" -#endif // #if ( defined (MESSAGEBROKER_HMIADAPTER) || defined(PASA_HMI) ) -#include "application_manager/application_manager_impl.h" -#include "connection_handler/connection_handler_impl.h" -#include "protocol_handler/protocol_handler_impl.h" -#include "transport_manager/transport_manager.h" -#include "transport_manager/transport_manager_default.h" -#include "media_manager/media_manager_impl.h" -#ifdef TELEMETRY_MONITOR -#include "telemetry_monitor/telemetry_monitor.h" -#endif - -#ifdef ENABLE_SECURITY -namespace security_manager { -class CryptoManager; -class SecurityManagerImpl; -} // namespace security_manager -#endif // ENABLE_SECURITY +namespace main_namespace { -namespace utils { -class SystemTimeHandler; -} // namespace utils +/** + * Class responsible for all system components creation, + * start, stop, suspend and restore + */ -namespace main_namespace { class LifeCycle { public: - LifeCycle(const profile::Profile& profile); - bool StartComponents(); + virtual ~LifeCycle() {} /** - * Initialize MessageBroker component - * @return true if success otherwise false. - */ - bool InitMessageSystem(); + * Creates and starts all system components + * @return true if all components started successfully + * otherwise false. + */ + virtual bool StartComponents() = 0; + /** - * \brief Main loop - */ - void Run(); - void StopComponents(); + * Initializes MessageBroker component + * @return true if success otherwise false. + */ + virtual bool InitMessageSystem() = 0; + + /** + * @brief Main loop + */ + virtual void Run() = 0; - private: - transport_manager::TransportManagerImpl* transport_manager_; - protocol_handler::ProtocolHandlerImpl* protocol_handler_; - connection_handler::ConnectionHandlerImpl* connection_handler_; - application_manager::ApplicationManagerImpl* app_manager_; -#ifdef ENABLE_SECURITY - security_manager::CryptoManager* crypto_manager_; - security_manager::SecurityManager* security_manager_; -#endif // ENABLE_SECURITY - hmi_message_handler::HMIMessageHandlerImpl* hmi_handler_; - hmi_message_handler::HMIMessageAdapter* hmi_message_adapter_; - media_manager::MediaManagerImpl* media_manager_; - resumption::LastState* last_state_; -#ifdef TELEMETRY_MONITOR - telemetry_monitor::TelemetryMonitor* telemetry_monitor_; -#endif // TELEMETRY_MONITOR + /** + * Stops all system components + */ + virtual void StopComponents() = 0; -#ifdef MESSAGEBROKER_HMIADAPTER - hmi_message_handler::MessageBrokerAdapter* mb_adapter_; - std::thread* mb_adapter_thread_; -#endif // MESSAGEBROKER_HMIADAPTER - const profile::Profile& profile_; - DISALLOW_COPY_AND_ASSIGN(LifeCycle); }; } // namespace main_namespace diff --git a/src/appMain/life_cycle_impl.cc b/src/appMain/life_cycle_impl.cc new file mode 100644 index 0000000000..bf55a1f346 --- /dev/null +++ b/src/appMain/life_cycle_impl.cc @@ -0,0 +1,320 @@ +/* +* 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. +*/ + +#include "appMain/life_cycle_impl.h" +#include "utils/signals.h" +#include "utils/make_shared.h" +#include "config_profile/profile.h" +#include "application_manager/system_time/system_time_handler_impl.h" +#include "resumption/last_state_impl.h" + +#ifdef ENABLE_SECURITY +#include "security_manager/security_manager_impl.h" +#include "security_manager/crypto_manager_impl.h" +#include "security_manager/crypto_manager_settings_impl.h" +#include "application_manager/policies/policy_handler.h" +#endif // ENABLE_SECURITY + +#ifdef ENABLE_LOG +#include "utils/log_message_loop_thread.h" +#endif // ENABLE_LOG + +using threads::Thread; + +namespace main_namespace { + +CREATE_LOGGERPTR_GLOBAL(logger_, "SDLMain") + +LifeCycle::LifeCycle(const profile::Profile& profile) + : transport_manager_(NULL) + , protocol_handler_(NULL) + , connection_handler_(NULL) + , app_manager_(NULL) +#ifdef ENABLE_SECURITY + , crypto_manager_(NULL) + , security_manager_(NULL) +#endif // ENABLE_SECURITY + , hmi_handler_(NULL) + , hmi_message_adapter_(NULL) + , media_manager_(NULL) + , last_state_(NULL) +#ifdef TELEMETRY_MONITOR + , telemetry_monitor_(NULL) +#endif // TELEMETRY_MONITOR +#ifdef MESSAGEBROKER_HMIADAPTER + , mb_adapter_(NULL) + , mb_adapter_thread_(NULL) +#endif // MESSAGEBROKER_HMIADAPTER + , profile_(profile) { +} + +bool LifeCycleImpl::StartComponents() { + LOG4CXX_AUTO_TRACE(logger_); + DCHECK(!last_state_); + last_state_ = new resumption::LastStateImpl(profile_.app_storage_folder(), + profile_.app_info_storage()); + + DCHECK(!transport_manager_); + transport_manager_ = new transport_manager::TransportManagerDefault(profile_); + + DCHECK(!connection_handler_); + connection_handler_ = new connection_handler::ConnectionHandlerImpl( + profile_, *transport_manager_); + + DCHECK(!protocol_handler_); + protocol_handler_ = + new protocol_handler::ProtocolHandlerImpl(profile_, + *connection_handler_, + *connection_handler_, + *transport_manager_); + DCHECK(protocol_handler_); + + DCHECK(!app_manager_); + app_manager_ = + new application_manager::ApplicationManagerImpl(profile_, profile_); + + DCHECK(!hmi_handler_); + hmi_handler_ = new hmi_message_handler::HMIMessageHandlerImpl(profile_); + + hmi_handler_->set_message_observer(&(app_manager_->GetRPCHandler())); + app_manager_->set_hmi_message_handler(hmi_handler_); + + media_manager_ = new media_manager::MediaManagerImpl(*app_manager_, profile_); + app_manager_->set_connection_handler(connection_handler_); + if (!app_manager_->Init(*last_state_, media_manager_)) { + LOG4CXX_ERROR(logger_, "Application manager init failed."); + return false; + } + +#ifdef ENABLE_SECURITY + auto system_time_handler = + std::unique_ptr( + new application_manager::SystemTimeHandlerImpl(*app_manager_)); + security_manager_ = + new security_manager::SecurityManagerImpl(std::move(system_time_handler)); + crypto_manager_ = new security_manager::CryptoManagerImpl( + std::make_shared( + profile_, app_manager_->GetPolicyHandler().RetrieveCertificate())); + protocol_handler_->AddProtocolObserver(security_manager_); + protocol_handler_->set_security_manager(security_manager_); + + security_manager_->set_session_observer(connection_handler_); + security_manager_->set_protocol_handler(protocol_handler_); + security_manager_->set_crypto_manager(crypto_manager_); + security_manager_->AddListener(app_manager_); + + app_manager_->AddPolicyObserver(security_manager_); + app_manager_->AddPolicyObserver(protocol_handler_); + if (!crypto_manager_->Init()) { + LOG4CXX_ERROR(logger_, "CryptoManager initialization fail."); + return false; + } +#endif // ENABLE_SECURITY + + transport_manager_->AddEventListener(protocol_handler_); + transport_manager_->AddEventListener(connection_handler_); + + protocol_handler_->AddProtocolObserver(media_manager_); + protocol_handler_->AddProtocolObserver(&(app_manager_->GetRPCHandler())); + + media_manager_->SetProtocolHandler(protocol_handler_); + + connection_handler_->set_protocol_handler(protocol_handler_); + connection_handler_->set_connection_handler_observer(app_manager_); + +// it is important to initialise TelemetryMonitor before TM to listen TM +// Adapters +#ifdef TELEMETRY_MONITOR + telemetry_monitor_ = new telemetry_monitor::TelemetryMonitor( + profile_.server_address(), profile_.time_testing_port()); + telemetry_monitor_->Start(); + telemetry_monitor_->Init(protocol_handler_, app_manager_, transport_manager_); +#endif // TELEMETRY_MONITOR + // It's important to initialise TM after setting up listener chain + // [TM -> CH -> AM], otherwise some events from TM could arrive at nowhere + app_manager_->set_protocol_handler(protocol_handler_); + transport_manager_->Init(*last_state_); + // start transport manager + transport_manager_->Visibility(true); + + return true; +} + +#ifdef MESSAGEBROKER_HMIADAPTER +bool LifeCycleImpl::InitMessageSystem() { + mb_adapter_ = new hmi_message_handler::MessageBrokerAdapter( + hmi_handler_, profile_.server_address(), profile_.server_port()); + + if (!mb_adapter_->StartListener()) { + return false; + } + + hmi_handler_->AddHMIMessageAdapter(mb_adapter_); + mb_adapter_thread_ = new std::thread( + &hmi_message_handler::MessageBrokerAdapter::Run, mb_adapter_); + return true; +} +#endif // MESSAGEBROKER_HMIADAPTER + +namespace { +void sig_handler(int sig) { + switch (sig) { + case SIGINT: + LOG4CXX_DEBUG(logger_, "SIGINT signal has been caught"); + break; + case SIGTERM: + LOG4CXX_DEBUG(logger_, "SIGTERM signal has been caught"); + break; + case SIGSEGV: + LOG4CXX_DEBUG(logger_, "SIGSEGV signal has been caught"); + FLUSH_LOGGER(); + // exit need to prevent endless sending SIGSEGV + // http://stackoverflow.com/questions/2663456/how-to-write-a-signal-handler-to-catch-sigsegv + abort(); + default: + LOG4CXX_DEBUG(logger_, "Unexpected signal has been caught"); + exit(EXIT_FAILURE); + } +} +} // namespace + +void LifeCycleImpl::Run() { + LOG4CXX_AUTO_TRACE(logger_); + // Register signal handlers and wait sys signals + // from OS + if (!utils::WaitTerminationSignals(&sig_handler)) { + LOG4CXX_FATAL(logger_, "Fail to catch system signal!"); + } +} + +void LifeCycleImpl::StopComponents() { + LOG4CXX_AUTO_TRACE(logger_); + + DCHECK_OR_RETURN_VOID(hmi_handler_); + hmi_handler_->set_message_observer(NULL); + + DCHECK_OR_RETURN_VOID(connection_handler_); + connection_handler_->set_connection_handler_observer(NULL); + + DCHECK_OR_RETURN_VOID(protocol_handler_); + protocol_handler_->RemoveProtocolObserver(&(app_manager_->GetRPCHandler())); + + DCHECK_OR_RETURN_VOID(app_manager_); + app_manager_->Stop(); + + LOG4CXX_INFO(logger_, "Stopping Protocol Handler"); + DCHECK_OR_RETURN_VOID(protocol_handler_); + protocol_handler_->RemoveProtocolObserver(media_manager_); + +#ifdef ENABLE_SECURITY + protocol_handler_->RemoveProtocolObserver(security_manager_); + if (security_manager_) { + security_manager_->RemoveListener(app_manager_); + LOG4CXX_INFO(logger_, "Destroying Crypto Manager"); + delete crypto_manager_; + crypto_manager_ = NULL; + LOG4CXX_INFO(logger_, "Destroying Security Manager"); + delete security_manager_; + security_manager_ = NULL; + } +#endif // ENABLE_SECURITY + protocol_handler_->Stop(); + + LOG4CXX_INFO(logger_, "Destroying Media Manager"); + DCHECK_OR_RETURN_VOID(media_manager_); + media_manager_->SetProtocolHandler(NULL); + delete media_manager_; + media_manager_ = NULL; + + LOG4CXX_INFO(logger_, "Destroying Transport Manager."); + DCHECK_OR_RETURN_VOID(transport_manager_); + transport_manager_->Visibility(false); + transport_manager_->Stop(); + delete transport_manager_; + transport_manager_ = NULL; + + LOG4CXX_INFO(logger_, "Stopping Connection Handler."); + DCHECK_OR_RETURN_VOID(connection_handler_); + connection_handler_->Stop(); + + LOG4CXX_INFO(logger_, "Destroying Protocol Handler"); + DCHECK(protocol_handler_); + delete protocol_handler_; + protocol_handler_ = NULL; + + LOG4CXX_INFO(logger_, "Destroying Connection Handler."); + delete connection_handler_; + connection_handler_ = NULL; + + LOG4CXX_INFO(logger_, "Destroying Last State"); + DCHECK(last_state_); + delete last_state_; + last_state_ = NULL; + + LOG4CXX_INFO(logger_, "Destroying Application Manager."); + DCHECK(app_manager_); + delete app_manager_; + app_manager_ = NULL; + + LOG4CXX_INFO(logger_, "Destroying HMI Message Handler and MB adapter."); + +#ifdef MESSAGEBROKER_HMIADAPTER + if (mb_adapter_) { + DCHECK_OR_RETURN_VOID(hmi_handler_); + hmi_handler_->RemoveHMIMessageAdapter(mb_adapter_); + mb_adapter_->unregisterController(); + mb_adapter_->exitReceivingThread(); + if (mb_adapter_thread_ != NULL) { + mb_adapter_thread_->join(); + } + delete mb_adapter_; + mb_adapter_ = NULL; + delete mb_adapter_thread_; + mb_adapter_thread_ = NULL; + } + LOG4CXX_INFO(logger_, "Destroying Message Broker"); +#endif // MESSAGEBROKER_HMIADAPTER + DCHECK_OR_RETURN_VOID(hmi_handler_); + delete hmi_handler_; + hmi_handler_ = NULL; + +#ifdef TELEMETRY_MONITOR + // It's important to delete tester Obcervers after TM adapters destruction + if (telemetry_monitor_) { + telemetry_monitor_->Stop(); + delete telemetry_monitor_; + telemetry_monitor_ = NULL; + } +#endif // TELEMETRY_MONITOR +} + +} // namespace main_namespace diff --git a/src/appMain/life_cycle_impl.h b/src/appMain/life_cycle_impl.h new file mode 100644 index 0000000000..a190a5734d --- /dev/null +++ b/src/appMain/life_cycle_impl.h @@ -0,0 +1,136 @@ +/* +* 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_APPMAIN_LIFE_CYCLE_IMPL_H_ +#define SRC_APPMAIN_LIFE_CYCLE_IMPL_H_ + +#include "appMain/life_cycle.h" + +#include +#include +#include +#include "utils/macro.h" +#include "utils/shared_ptr.h" + +#include "config_profile/profile.h" +#include "hmi_message_handler/hmi_message_handler_impl.h" +#ifdef DBUS_HMIADAPTER +#include "hmi_message_handler/dbus_message_adapter.h" +#endif // DBUS_HMIADAPTER +#if (defined(MESSAGEBROKER_HMIADAPTER) || defined(PASA_HMI)) +#include "hmi_message_handler/messagebroker_adapter.h" +#endif // #if ( defined (MESSAGEBROKER_HMIADAPTER) || defined(PASA_HMI) ) +#include "application_manager/application_manager_impl.h" +#ifdef SDL_REMOTE_CONTROL +#include "application_manager/core_service.h" +#include "functional_module/plugin_manager.h" +#endif // SDL_REMOTE_CONTROL +#include "connection_handler/connection_handler_impl.h" +#include "protocol_handler/protocol_handler_impl.h" +#include "transport_manager/transport_manager.h" +#include "transport_manager/transport_manager_default.h" +#include "media_manager/media_manager_impl.h" +#ifdef TELEMETRY_MONITOR +#include "telemetry_monitor/telemetry_monitor.h" +#endif + +#ifdef ENABLE_SECURITY +namespace security_manager { +class CryptoManager; +class SecurityManagerImpl; +} // namespace security_manager +#endif // ENABLE_SECURITY + +namespace utils { +class SystemTimeHandler; +} // namespace utils + +namespace main_namespace { + +class LifeCycleImpl : public LifeCycle { + public: + explicit LifeCycleImpl(const profile::Profile& profile); + + /** + * Creates and starts all system components + * @return true if all components started successfully + * otherwise false. + */ + bool StartComponents() OVERRIDE; + + /** + * Initialize MessageBroker component + * @return true if success otherwise false. + */ + bool InitMessageSystem() OVERRIDE; + /** + * @brief Main loop + */ + void Run() OVERRIDE; + + /** + * Stops all system components + */ + void StopComponents() OVERRIDE; + + private: + transport_manager::TransportManagerImpl* transport_manager_; + protocol_handler::ProtocolHandlerImpl* protocol_handler_; + connection_handler::ConnectionHandlerImpl* connection_handler_; + application_manager::ApplicationManagerImpl* app_manager_; +#ifdef ENABLE_SECURITY + security_manager::CryptoManager* crypto_manager_; + security_manager::SecurityManager* security_manager_; +#endif // ENABLE_SECURITY + hmi_message_handler::HMIMessageHandlerImpl* hmi_handler_; + hmi_message_handler::HMIMessageAdapter* hmi_message_adapter_; + media_manager::MediaManagerImpl* media_manager_; + resumption::LastState* last_state_; +#ifdef TELEMETRY_MONITOR + telemetry_monitor::TelemetryMonitor* telemetry_monitor_; +#endif // TELEMETRY_MONITOR +#ifdef DBUS_HMIADAPTER + hmi_message_handler::DBusMessageAdapter* dbus_adapter_; + std::thread* dbus_adapter_thread_; +#endif // DBUS_HMIADAPTER + +#ifdef MESSAGEBROKER_HMIADAPTER + hmi_message_handler::MessageBrokerAdapter* mb_adapter_; + std::thread* mb_adapter_thread_; +#endif // MESSAGEBROKER_HMIADAPTER + + const profile::Profile& profile_; + DISALLOW_COPY_AND_ASSIGN(LifeCycleImpl); +}; +} // namespace main_namespace + +#endif // SRC_APPMAIN_LIFE_CYCLE_IMPL_H_ diff --git a/src/appMain/main.cc b/src/appMain/main.cc index 02f1023ff4..e9625cc33a 100644 --- a/src/appMain/main.cc +++ b/src/appMain/main.cc @@ -35,6 +35,7 @@ #include #include #include +#include #include #include #include // cpplint: Streams are highly discouraged. @@ -45,7 +46,7 @@ #include "utils/log_message_loop_thread.h" #include "utils/logger.h" -#include "./life_cycle.h" +#include "appMain/life_cycle_impl.h" #include "signal_handlers.h" #include "utils/signals.h" @@ -103,7 +104,8 @@ int32_t main(int32_t argc, char** argv) { // -------------------------------------------------------------------------- // Components initialization profile::Profile profile_instance; - main_namespace::LifeCycle life_cycle(profile_instance); + std::unique_ptr life_cycle( + new main_namespace::LifeCycleImpl(profile_instance)); if ((argc > 1) && (0 != argv)) { profile_instance.set_config_file_name(argv[1]); } else { @@ -134,9 +136,9 @@ int32_t main(int32_t argc, char** argv) { // -------------------------------------------------------------------------- // Components initialization - if (!life_cycle.StartComponents()) { + if (!life_cycle->StartComponents()) { LOG4CXX_FATAL(logger_, "Failed to start components"); - life_cycle.StopComponents(); + life_cycle->StopComponents(); DEINIT_LOGGER(); exit(EXIT_FAILURE); } @@ -145,9 +147,9 @@ int32_t main(int32_t argc, char** argv) { // -------------------------------------------------------------------------- // Third-Party components initialization. - if (!life_cycle.InitMessageSystem()) { + if (!life_cycle->InitMessageSystem()) { LOG4CXX_FATAL(logger_, "Failed to init message system"); - life_cycle.StopComponents(); + life_cycle->StopComponents(); DEINIT_LOGGER(); _exit(EXIT_FAILURE); } @@ -167,10 +169,10 @@ int32_t main(int32_t argc, char** argv) { } // -------------------------------------------------------------------------- - life_cycle.Run(); + life_cycle->Run(); LOG4CXX_INFO(logger_, "Stop SDL due to caught signal"); - life_cycle.StopComponents(); + life_cycle->StopComponents(); LOG4CXX_INFO(logger_, "Application has been stopped successfuly"); DEINIT_LOGGER(); diff --git a/src/appMain/signal_handlers.cc b/src/appMain/signal_handlers.cc index c695467ae2..649f162ec6 100644 --- a/src/appMain/signal_handlers.cc +++ b/src/appMain/signal_handlers.cc @@ -30,8 +30,8 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include "signal_handlers.h" -#include "life_cycle.h" +#include "appMain/signal_handlers.h" +#include "appMain/life_cycle.h" #include "utils/logger.h" namespace main_namespace { -- cgit v1.2.1 From d1308d1c87ff7176258fe43d14e70f04894e0494 Mon Sep 17 00:00:00 2001 From: Andriy Byzhynar Date: Wed, 27 Jun 2018 14:53:12 +0300 Subject: Initial implementation of Low Voltage feature Implemented Low Voltage feature based on POSIX real-time signals --- src/appMain/CMakeLists.txt | 11 +- src/appMain/life_cycle.h | 18 ++ src/appMain/life_cycle_impl.cc | 33 +++- src/appMain/life_cycle_impl.h | 35 ++-- src/appMain/low_voltage_signals_handler.cc | 185 +++++++++++++++++++++ src/appMain/low_voltage_signals_handler.h | 143 ++++++++++++++++ src/appMain/main.cc | 17 ++ src/appMain/smartDeviceLink.ini | 6 + .../src/application_manager_impl.cc | 5 +- .../test/commands/CMakeLists.txt | 1 + .../include/config_profile/profile.h | 24 +++ src/components/config_profile/src/profile.cc | 49 +++++- src/components/include/utils/typed_enum_print.h | 52 ++++++ .../src/transport_manager_impl.cc | 2 + src/components/utils/CMakeLists.txt | 1 + src/components/utils/include/utils/signals.h | 3 + src/components/utils/src/signals_posix.cc | 17 ++ 17 files changed, 584 insertions(+), 18 deletions(-) create mode 100644 src/appMain/low_voltage_signals_handler.cc create mode 100644 src/appMain/low_voltage_signals_handler.h create mode 100644 src/components/include/utils/typed_enum_print.h diff --git a/src/appMain/CMakeLists.txt b/src/appMain/CMakeLists.txt index 51b6a947e8..41d3d4202e 100644 --- a/src/appMain/CMakeLists.txt +++ b/src/appMain/CMakeLists.txt @@ -73,7 +73,16 @@ include_directories( ${CMAKE_SOURCE_DIR}/src ) -collect_sources(SOURCES "${CMAKE_CURRENT_SOURCE_DIR}") +# Create object library +add_library("LowVoltageHandlerObjLibrary" OBJECT ${CMAKE_CURRENT_SOURCE_DIR}/low_voltage_signals_handler.cc +) + +set (SOURCES + ${CMAKE_CURRENT_SOURCE_DIR}/main.cc + ${CMAKE_CURRENT_SOURCE_DIR}/life_cycle_impl.cc + ${CMAKE_CURRENT_SOURCE_DIR}/signal_handlers.cc + $ +) cmake_policy(PUSH) # make link_directories() treat paths relative to the source dir diff --git a/src/appMain/life_cycle.h b/src/appMain/life_cycle.h index d14b91d13f..ff8fa2cc40 100644 --- a/src/appMain/life_cycle.h +++ b/src/appMain/life_cycle.h @@ -67,7 +67,25 @@ class LifeCycle { */ virtual void StopComponents() = 0; + /** + * Makes appropriate actions when Low Voltage signal received: + * Stops all SDL activities except of waiting of UNIX signals + * from HMI + */ + virtual void LowVoltage() = 0; + /** + * Makes appropriate actions when Wake Up signal received: + * Restores all SDL activities stopped due to LOW VOLTAGE + * from HMI + */ + virtual void WakeUp() = 0; + + /** + * Makes appropriate actions when Ignition Off signal received: + * Triggers all SDL components stop and deletion + */ + virtual void IgnitionOff() = 0; }; } // namespace main_namespace diff --git a/src/appMain/life_cycle_impl.cc b/src/appMain/life_cycle_impl.cc index bf55a1f346..d211771a39 100644 --- a/src/appMain/life_cycle_impl.cc +++ b/src/appMain/life_cycle_impl.cc @@ -32,7 +32,6 @@ #include "appMain/life_cycle_impl.h" #include "utils/signals.h" -#include "utils/make_shared.h" #include "config_profile/profile.h" #include "application_manager/system_time/system_time_handler_impl.h" #include "resumption/last_state_impl.h" @@ -48,13 +47,15 @@ #include "utils/log_message_loop_thread.h" #endif // ENABLE_LOG +#include "appMain/low_voltage_signals_handler.h" + using threads::Thread; namespace main_namespace { CREATE_LOGGERPTR_GLOBAL(logger_, "SDLMain") -LifeCycle::LifeCycle(const profile::Profile& profile) +LifeCycleImpl::LifeCycleImpl(const profile::Profile& profile) : transport_manager_(NULL) , protocol_handler_(NULL) , connection_handler_(NULL) @@ -166,9 +167,34 @@ bool LifeCycleImpl::StartComponents() { // start transport manager transport_manager_->Visibility(true); + LowVoltageSignalsOffset signals_offset{profile_.low_voltage_signal_offset(), + profile_.wake_up_signal_offset(), + profile_.ignition_off_signal_offset()}; + + low_voltage_signals_handler_.reset( + new LowVoltageSignalsHandler(*this, signals_offset)); + return true; } +void LifeCycleImpl::LowVoltage() { + LOG4CXX_AUTO_TRACE(logger_); + transport_manager_->Visibility(false); + app_manager_->OnLowVoltage(); +} + +void LifeCycleImpl::IgnitionOff() { + LOG4CXX_AUTO_TRACE(logger_); + kill(getpid(), SIGINT); +} + +void LifeCycleImpl::WakeUp() { + LOG4CXX_AUTO_TRACE(logger_); + app_manager_->OnWakeUp(); + transport_manager_->Reinit(); + transport_manager_->Visibility(true); +} + #ifdef MESSAGEBROKER_HMIADAPTER bool LifeCycleImpl::InitMessageSystem() { mb_adapter_ = new hmi_message_handler::MessageBrokerAdapter( @@ -285,6 +311,9 @@ void LifeCycleImpl::StopComponents() { delete app_manager_; app_manager_ = NULL; + LOG4CXX_INFO(logger_, "Destroying Low Voltage Signals Handler."); + low_voltage_signals_handler_.reset(); + LOG4CXX_INFO(logger_, "Destroying HMI Message Handler and MB adapter."); #ifdef MESSAGEBROKER_HMIADAPTER diff --git a/src/appMain/life_cycle_impl.h b/src/appMain/life_cycle_impl.h index a190a5734d..b898f0c589 100644 --- a/src/appMain/life_cycle_impl.h +++ b/src/appMain/life_cycle_impl.h @@ -39,21 +39,13 @@ #include #include #include "utils/macro.h" -#include "utils/shared_ptr.h" #include "config_profile/profile.h" #include "hmi_message_handler/hmi_message_handler_impl.h" -#ifdef DBUS_HMIADAPTER -#include "hmi_message_handler/dbus_message_adapter.h" -#endif // DBUS_HMIADAPTER #if (defined(MESSAGEBROKER_HMIADAPTER) || defined(PASA_HMI)) #include "hmi_message_handler/messagebroker_adapter.h" #endif // #if ( defined (MESSAGEBROKER_HMIADAPTER) || defined(PASA_HMI) ) #include "application_manager/application_manager_impl.h" -#ifdef SDL_REMOTE_CONTROL -#include "application_manager/core_service.h" -#include "functional_module/plugin_manager.h" -#endif // SDL_REMOTE_CONTROL #include "connection_handler/connection_handler_impl.h" #include "protocol_handler/protocol_handler_impl.h" #include "transport_manager/transport_manager.h" @@ -76,6 +68,8 @@ class SystemTimeHandler; namespace main_namespace { +class LowVoltageSignalsHandler; + class LifeCycleImpl : public LifeCycle { public: explicit LifeCycleImpl(const profile::Profile& profile); @@ -102,11 +96,32 @@ class LifeCycleImpl : public LifeCycle { */ void StopComponents() OVERRIDE; + /** + * Makes appropriate actions when Low Voltage signal received: + * Stops all SDL activities except of waiting of UNIX signals + * from HMI + */ + void LowVoltage() OVERRIDE; + + /** + * Makes appropriate actions when Wake Up signal received: + * Restores all SDL activities stopped due to LOW VOLTAGE + * from HMI + */ + void WakeUp() OVERRIDE; + + /** + * Makes appropriate actions when Ignition Off signal received: + * Triggers all SDL components stop and deletion + */ + void IgnitionOff() OVERRIDE; + private: transport_manager::TransportManagerImpl* transport_manager_; protocol_handler::ProtocolHandlerImpl* protocol_handler_; connection_handler::ConnectionHandlerImpl* connection_handler_; application_manager::ApplicationManagerImpl* app_manager_; + std::unique_ptr low_voltage_signals_handler_; #ifdef ENABLE_SECURITY security_manager::CryptoManager* crypto_manager_; security_manager::SecurityManager* security_manager_; @@ -118,10 +133,6 @@ class LifeCycleImpl : public LifeCycle { #ifdef TELEMETRY_MONITOR telemetry_monitor::TelemetryMonitor* telemetry_monitor_; #endif // TELEMETRY_MONITOR -#ifdef DBUS_HMIADAPTER - hmi_message_handler::DBusMessageAdapter* dbus_adapter_; - std::thread* dbus_adapter_thread_; -#endif // DBUS_HMIADAPTER #ifdef MESSAGEBROKER_HMIADAPTER hmi_message_handler::MessageBrokerAdapter* mb_adapter_; diff --git a/src/appMain/low_voltage_signals_handler.cc b/src/appMain/low_voltage_signals_handler.cc new file mode 100644 index 0000000000..b514ac6d55 --- /dev/null +++ b/src/appMain/low_voltage_signals_handler.cc @@ -0,0 +1,185 @@ +/* + * 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. + */ + +#include "appMain/low_voltage_signals_handler.h" + +#include +#include "appMain/life_cycle.h" +#include "utils/logger.h" +#include "utils/typed_enum_print.h" +#include "config_profile/profile.h" + +namespace main_namespace { + +CREATE_LOGGERPTR_GLOBAL(logger_, "LowVoltageSignalsHandler") + +LowVoltageSignalsHandler::LowVoltageSignalsHandler( + LifeCycle& life_cycle, const LowVoltageSignalsOffset& offset_data) + : state_(SDLState::kRun) + , notifications_delegate_(new NotificationThreadDelegate(*this)) + , signals_handler_thread_(threads::CreateThread( + "LV_SIGNALS_HANDLER_THREAD", notifications_delegate_.get())) + , life_cycle_(life_cycle) + , SIGLOWVOLTAGE_(offset_data.low_voltage_signal_offset + SIGRTMIN) + , SIGWAKEUP_(offset_data.wake_up_signal_offset + SIGRTMIN) + , SIGIGNOFF_(offset_data.ignition_off_signal_offset + SIGRTMIN) { + signals_handler_thread_->start(); +} + +SDLState LowVoltageSignalsHandler::get_current_sdl_state() const { + return state_; +} + +int LowVoltageSignalsHandler::low_voltage_signo() const { + return SIGLOWVOLTAGE_; +} + +int LowVoltageSignalsHandler::wake_up_signo() const { + return SIGWAKEUP_; +} + +int LowVoltageSignalsHandler::ignition_off_signo() const { + return SIGIGNOFF_; +} + +void LowVoltageSignalsHandler::Destroy() { + state_ = SDLState::kStop; + if (signals_handler_thread_) { + signals_handler_thread_->join(); + } + notifications_delegate_.reset(); + threads::DeleteThread(signals_handler_thread_); +} + +LowVoltageSignalsHandler::~LowVoltageSignalsHandler() { + Destroy(); +} + +void LowVoltageSignalsHandler::HandleSignal(const int signo) { + using utils::operator<<; + LOG4CXX_DEBUG(logger_, "Received Signal: " << signo); + LOG4CXX_DEBUG(logger_, "Current state is : " << get_current_sdl_state()); + + auto handle_run_state = [this, signo]() { + + if (SIGLOWVOLTAGE_ == signo) { + LOG4CXX_DEBUG(logger_, "Received LOW_VOLTAGE signal"); + state_ = SDLState::kSleep; + life_cycle_.LowVoltage(); + return; + } + + if (SIGIGNOFF_ == signo) { + LOG4CXX_DEBUG(logger_, + "Received IGNITION_OFF signal. But SDL is in active state"); + // Do nothing + return; + } + + if (SIGWAKEUP_ == signo) { + LOG4CXX_DEBUG(logger_, + "Received WAKE_UP signal. But SDL is in active state"); + // Do nothing + return; + } + LOG4CXX_DEBUG(logger_, "Received UNKNOWN signal"); + }; + + auto handle_sleep_state = [this, signo]() { + + if (SIGWAKEUP_ == signo) { + LOG4CXX_DEBUG(logger_, "Received WAKE UP signal"); + state_ = SDLState::kRun; + life_cycle_.WakeUp(); + return; + } + + if (SIGIGNOFF_ == signo) { + LOG4CXX_DEBUG(logger_, "Received IGNITION_OFF signal"); + state_ = SDLState::kStop; + life_cycle_.IgnitionOff(); + return; + } + + if (SIGLOWVOLTAGE_ == signo) { + LOG4CXX_DEBUG( + logger_, + "Received LOW VOLTAGE signal. But SDL is already in sleep state"); + // Do nothing + return; + } + LOG4CXX_DEBUG(logger_, "Received UNKNOWN signal"); + }; + + switch (state_) { + case SDLState::kRun: + handle_run_state(); + break; + case SDLState::kSleep: + handle_sleep_state(); + break; + case SDLState::kStop: /* nothing to do here */ + LOG4CXX_DEBUG(logger_, "SDL is in stopping state"); + break; + } +} + +bool LowVoltageSignalsHandler::IsActive() const { + return SDLState::kStop != state_; +} + +void NotificationThreadDelegate::threadMain() { + sigset_t lv_mask; + sigemptyset(&lv_mask); + sigaddset(&lv_mask, low_voltage_signals_handler_.low_voltage_signo()); + sigaddset(&lv_mask, low_voltage_signals_handler_.wake_up_signo()); + sigaddset(&lv_mask, low_voltage_signals_handler_.ignition_off_signo()); + + while (low_voltage_signals_handler_.IsActive()) { + int signo = 0; + const int err = sigwait(&lv_mask, &signo); + if (0 != err) { + LOG4CXX_ERROR( + logger_, + "Sigwait() error! Signals set contains an invalid signal number!"); + continue; + } + low_voltage_signals_handler_.HandleSignal(signo); + } +} + +void NotificationThreadDelegate::exitThreadMain() { + LOG4CXX_AUTO_TRACE(logger_); + ThreadDelegate::exitThreadMain(); +} + +} // namespace main_namespace diff --git a/src/appMain/low_voltage_signals_handler.h b/src/appMain/low_voltage_signals_handler.h new file mode 100644 index 0000000000..4b2902659e --- /dev/null +++ b/src/appMain/low_voltage_signals_handler.h @@ -0,0 +1,143 @@ +/* + * 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_APPMAIN_LOW_VOLTAGE_SIGNALS_HANDLER_H_ +#define SRC_APPMAIN_LOW_VOLTAGE_SIGNALS_HANDLER_H_ + +#include +#include +#include "utils/threads/thread_delegate.h" +#include "utils/threads/thread.h" + +namespace main_namespace { + +typedef struct LowVoltageSignalsOffset { + int low_voltage_signal_offset; + int wake_up_signal_offset; + int ignition_off_signal_offset; +} LowVoltageSignalsOffset; + +class LifeCycle; +class NotificationThreadDelegate; + +/** + * @brief The SDLState enum defines current Smartdevicelink app state + * which can be changed due to received UNIX RT signals dedicated for + * Low Voltage functionality handling + * e.g. LowVoltage, WakeUp, IgnitionOff signals + */ +enum class SDLState { kRun, kSleep, kStop }; + +/** + * @brief Class which handles real-time POSIX signals + * dedicated for LOW VOLTAGE functionality + */ +class LowVoltageSignalsHandler { + public: + /** + * @brief Constructor + * @param life_cycle - life_cycle object to interact with other system + * components + * @param offset_data offset data needed to calculate correct SIGNAL numbers + * used for LOW VOLTAGE functionality (as offset from SIGRTMIN) + */ + LowVoltageSignalsHandler(LifeCycle& life_cycle, + const LowVoltageSignalsOffset& offset_data); + /** + * @brief Handles RT signals related to Low Voltage functionality + */ + void HandleSignal(const int signo); + + /** + * @brief Checks if SDL is in active state + * therefore not yet in sleep state due to Low Voltage event + */ + bool IsActive() const; + + /** + * @brief Returns current LOW VOLTAGE SDL state + */ + SDLState get_current_sdl_state() const; + + /** + * @brief Returns LOW VOLTAGE signal number + */ + int low_voltage_signo() const; + + /** + * @brief Returns WAKE UP signal number + */ + int wake_up_signo() const; + + /** + * @brief Returns IGNITION OFF signal number + */ + int ignition_off_signo() const; + + /** + * @brief Destructor + */ + ~LowVoltageSignalsHandler(); + + private: + /** + * @brief Destroys all parts of Low Voltage signals handler + * Invoked from destructor + */ + void Destroy(); + SDLState state_; + std::unique_ptr notifications_delegate_; + threads::Thread* signals_handler_thread_; + LifeCycle& life_cycle_; + int SIGLOWVOLTAGE_; + int SIGWAKEUP_; + int SIGIGNOFF_; +}; + +class NotificationThreadDelegate : public threads::ThreadDelegate { + public: + NotificationThreadDelegate( + LowVoltageSignalsHandler& low_voltage_signals_handler) + : low_voltage_signals_handler_(low_voltage_signals_handler) {} + + ~NotificationThreadDelegate() {} + + void threadMain() OVERRIDE; + void exitThreadMain() OVERRIDE; + + private: + LowVoltageSignalsHandler& low_voltage_signals_handler_; +}; + +} // namespace main_namespace + +#endif // SRC_APPMAIN_LOW_VOLTAGE_SIGNALS_HANDLER_H_ diff --git a/src/appMain/main.cc b/src/appMain/main.cc index e9625cc33a..d1f0594daf 100644 --- a/src/appMain/main.cc +++ b/src/appMain/main.cc @@ -106,12 +106,29 @@ int32_t main(int32_t argc, char** argv) { profile::Profile profile_instance; std::unique_ptr life_cycle( new main_namespace::LifeCycleImpl(profile_instance)); + if ((argc > 1) && (0 != argv)) { profile_instance.set_config_file_name(argv[1]); } else { profile_instance.set_config_file_name("smartDeviceLink.ini"); } + // Reading profile offsets for real-time signals dedicated + // for Low Voltage functionality handling + main_namespace::LowVoltageSignalsOffset signals_offset{ + profile_instance.low_voltage_signal_offset(), + profile_instance.wake_up_signal_offset(), + profile_instance.ignition_off_signal_offset()}; + + // Unsubscribe once for all threads + // except specific thread dedicated for + // Low Voltage signals handling + // Thread will be created later + if (!utils::UnsubscribeFromLowVoltageSignals(signals_offset)) { + // Can't use internal logger here + exit(EXIT_FAILURE); + } + // -------------------------------------------------------------------------- // Logger initialization INIT_LOGGER("log4cxx.properties", profile_instance.logs_enabled()); diff --git a/src/appMain/smartDeviceLink.ini b/src/appMain/smartDeviceLink.ini index 444affc06c..037a6efb14 100644 --- a/src/appMain/smartDeviceLink.ini +++ b/src/appMain/smartDeviceLink.ini @@ -96,6 +96,12 @@ AppTransportChangeTimer = 500 ; The time used as addition for AppTransportChangeTimer AppTransportChangeTimerAddition = 0 +; Signal offsets used by SDL for setting up real time signals +; used by LOW VOLTAGE functionality +LowVoltageSignal = 1 ; Offset from SIGRTMIN +WakeUpSignal = 2 ; Offset from SIGRTMIN +IgnitionOffSignal = 3 ; Offset from SIGRTMIN + [MEDIA MANAGER] ; where 3 is a number of retries and 1000 is a timeout in milliseconds for request frequency StartStreamRetry = 3, 1000 diff --git a/src/components/application_manager/src/application_manager_impl.cc b/src/components/application_manager/src/application_manager_impl.cc index 386bfe4825..374b5bb8b2 100644 --- a/src/components/application_manager/src/application_manager_impl.cc +++ b/src/components/application_manager/src/application_manager_impl.cc @@ -2429,7 +2429,10 @@ void ApplicationManagerImpl::ClearAppsPersistentData() { void ApplicationManagerImpl::SendOnSDLClose() { LOG4CXX_AUTO_TRACE(logger_); - + if (IsLowVoltage()) { + LOG4CXX_TRACE(logger_, "SDL is in Low Voltage State"); + return; + } // must be sent to PASA HMI on shutdown synchronously smart_objects::SmartObjectSPtr msg = std::make_shared( diff --git a/src/components/application_manager/test/commands/CMakeLists.txt b/src/components/application_manager/test/commands/CMakeLists.txt index 165b5fc0fb..33258e60db 100644 --- a/src/components/application_manager/test/commands/CMakeLists.txt +++ b/src/components/application_manager/test/commands/CMakeLists.txt @@ -35,6 +35,7 @@ include_directories( ${COMPONENTS_DIR}/application_manager/include/ ${COMPONENTS_DIR}/application_manager/include/application_manager/ ${COMPONENTS_DIR}/application_manager/include/application_manager/commands/ + ${CMAKE_SOURCE_DIR}/src ) set(COMMANDS_TEST_DIR ${AM_TEST_DIR}/commands) diff --git a/src/components/config_profile/include/config_profile/profile.h b/src/components/config_profile/include/config_profile/profile.h index 4c2be53228..17437a04a3 100644 --- a/src/components/config_profile/include/config_profile/profile.h +++ b/src/components/config_profile/include/config_profile/profile.h @@ -109,6 +109,27 @@ class Profile : public protocol_handler::ProtocolHandlerSettings, */ const std::string& app_resource_folder() const; + /** + * @brief Returns offset from SIGRTMIN for user defined signal + * SIGLOWVOLTAGE + * which is used for handling LOW Voltage functionality + */ + int low_voltage_signal_offset() const; + + /** + * @brief Returns offset from SIGRTMIN for user defined signal + * SIGWAKEUP + * which is used for handling LOW Voltage functionality + */ + int wake_up_signal_offset() const; + + /** + * @brief Returns offset from SIGRTMIN for user defined signal + * SIGIGNITIONOFF + * which is used for handling LOW Voltage functionality + */ + int ignition_off_signal_offset() const; + /** * @brief Returns true, if SDL 4.0 is enabled * @deprecated use max_supported_protocol_version instead @@ -1018,6 +1039,9 @@ class Profile : public protocol_handler::ProtocolHandlerSettings, std::vector video_service_transports_; bool error_occured_; std::string error_description_; + int low_voltage_signal_offset_; + int wake_up_signal_offset_; + int ignition_off_signal_offset_; DISALLOW_COPY_AND_ASSIGN(Profile); }; diff --git a/src/components/config_profile/src/profile.cc b/src/components/config_profile/src/profile.cc index 3f3ec7eb63..d869d6b65e 100644 --- a/src/components/config_profile/src/profile.cc +++ b/src/components/config_profile/src/profile.cc @@ -222,6 +222,9 @@ const char* kEnableAppLaunchIOSKey = "EnableAppLaunchIOS"; const char* kAppTransportChangeTimerKey = "AppTransportChangeTimer"; const char* kAppTransportChangeTimerAdditionKey = "AppTransportChangeTimerAddition"; +const char* kLowVoltageSignalOffsetKey = "LowVoltageSignal"; +const char* kWakeUpSignalOffsetKey = "WakeUpSignal"; +const char* kIgnitionOffSignalOffsetKey = "IgnitionOffSignal"; const char* kMultipleTransportsEnabledKey = "MultipleTransportsEnabled"; const char* kSecondaryTransportForBluetoothKey = "SecondaryTransportForBluetooth"; @@ -372,6 +375,9 @@ const uint16_t kDefaultWaitTimeBetweenApps = 4000; const bool kDefaultEnableAppLaunchIOS = true; const uint32_t kDefaultAppTransportChangeTimer = 500u; const uint32_t kDefaultAppTransportChangeTimerAddition = 0u; +const int32_t kDefaultLowVoltageSignalOffset = 1; +const int32_t kDefaultWakeUpSignalOffset = 2; +const int32_t kDefaultIgnitionOffSignalOffset = 3; const std::string kAllowedSymbols = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890_.-"; const bool kDefaultMultipleTransportsEnabled = false; @@ -485,7 +491,10 @@ Profile::Profile() kDefaultAppTransportChangeTimerAddition) , multiple_transports_enabled_(kDefaultMultipleTransportsEnabled) , error_occured_(false) - , error_description_() { + , error_description_() + , low_voltage_signal_offset_(kDefaultLowVoltageSignalOffset) + , wake_up_signal_offset_(kDefaultWakeUpSignalOffset) + , ignition_off_signal_offset_(kDefaultIgnitionOffSignalOffset) { // SDL version ReadStringValue( &sdl_version_, kDefaultSDLVersion, kMainSection, kSDLVersionKey); @@ -530,6 +539,18 @@ const std::string& Profile::app_resource_folder() const { return app_resource_folder_; } +int Profile::low_voltage_signal_offset() const { + return low_voltage_signal_offset_; +} + +int Profile::wake_up_signal_offset() const { + return wake_up_signal_offset_; +} + +int Profile::ignition_off_signal_offset() const { + return ignition_off_signal_offset_; +} + bool Profile::enable_protocol_4() const { return max_supported_protocol_version_ >= 4; } @@ -2124,7 +2145,31 @@ void Profile::UpdateValues() { kAppTransportChangeTimerAdditionKey, kMainSection); - ReadBoolValue(&multiple_transports_enabled_, + ReadIntValue(&low_voltage_signal_offset_, + kDefaultLowVoltageSignalOffset, + kMainSection, + kLowVoltageSignalOffsetKey); + + LOG_UPDATED_VALUE( + low_voltage_signal_offset_, kLowVoltageSignalOffsetKey, kMainSection); + + ReadIntValue(&wake_up_signal_offset_, + kDefaultWakeUpSignalOffset, + kMainSection, + kWakeUpSignalOffsetKey); + + LOG_UPDATED_VALUE( + wake_up_signal_offset_, kWakeUpSignalOffsetKey, kMainSection); + + ReadIntValue(&ignition_off_signal_offset_, + kDefaultIgnitionOffSignalOffset, + kMainSection, + kIgnitionOffSignalOffsetKey); + + LOG_UPDATED_VALUE( + ignition_off_signal_offset_, kIgnitionOffSignalOffsetKey, kMainSection); + + ReadBoolValue(&multiple_transports_enabled_, kDefaultMultipleTransportsEnabled, kMultipleTransportsSection, kMultipleTransportsEnabledKey); diff --git a/src/components/include/utils/typed_enum_print.h b/src/components/include/utils/typed_enum_print.h new file mode 100644 index 0000000000..e2b903c948 --- /dev/null +++ b/src/components/include/utils/typed_enum_print.h @@ -0,0 +1,52 @@ +/* + * 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_INCLUDE_UTILS_TYPED_ENUM_PRINT_H_ +#define SRC_COMPONENTS_INCLUDE_UTILS_TYPED_ENUM_PRINT_H_ + +#include +#include + +namespace utils { + +// Generic overloaded operator "<<" to be able to send enum class values to +// std::ostream +template +std::ostream& operator<<( + typename std::enable_if::value, std::ostream>::type& stream, + const T& e) { + return stream << static_cast(e); +} + +} // namespace utils + +#endif // SRC_COMPONENTS_INCLUDE_UTILS_TYPED_ENUM_PRINT_H_ diff --git a/src/components/transport_manager/src/transport_manager_impl.cc b/src/components/transport_manager/src/transport_manager_impl.cc index abe4edd812..143498205c 100644 --- a/src/components/transport_manager/src/transport_manager_impl.cc +++ b/src/components/transport_manager/src/transport_manager_impl.cc @@ -532,6 +532,8 @@ int TransportManagerImpl::Reinit() { LOG4CXX_AUTO_TRACE(logger_); DisconnectAllDevices(); TerminateAllAdapters(); + device_to_adapter_map_.clear(); + connection_id_counter_ = 0; int ret = InitAllAdapters(); return ret; } diff --git a/src/components/utils/CMakeLists.txt b/src/components/utils/CMakeLists.txt index ed90c6fb45..a6ded9a186 100644 --- a/src/components/utils/CMakeLists.txt +++ b/src/components/utils/CMakeLists.txt @@ -40,6 +40,7 @@ include_directories ( ${COMPONENTS_DIR}/protocol_handler/include ${JSONCPP_INCLUDE_DIRECTORY} ${LOG4CXX_INCLUDE_DIRECTORY} + ${CMAKE_SOURCE_DIR}/src ) # dbms diff --git a/src/components/utils/include/utils/signals.h b/src/components/utils/include/utils/signals.h index e413a2576f..4efdaaa4e8 100644 --- a/src/components/utils/include/utils/signals.h +++ b/src/components/utils/include/utils/signals.h @@ -38,11 +38,14 @@ typedef void (*sighandler_t)(int); #else #include #endif +#include "appMain/low_voltage_signals_handler.h" namespace utils { bool UnsubscribeFromTermination(); bool WaitTerminationSignals(sighandler_t sig_handler); +bool UnsubscribeFromLowVoltageSignals( + const main_namespace::LowVoltageSignalsOffset& offset_data); } // namespace utils diff --git a/src/components/utils/src/signals_posix.cc b/src/components/utils/src/signals_posix.cc index 45923e4f9b..dd569a96d6 100644 --- a/src/components/utils/src/signals_posix.cc +++ b/src/components/utils/src/signals_posix.cc @@ -51,6 +51,23 @@ bool utils::UnsubscribeFromTermination() { return !pthread_sigmask(SIG_BLOCK, &signal_set, NULL); } +bool utils::UnsubscribeFromLowVoltageSignals( + const main_namespace::LowVoltageSignalsOffset& offset_data) { + // Disable Low Voltage signals in main thread + // due to all further threads will inherit signals mask + sigset_t signal_set; + sigemptyset(&signal_set); + const int SIGLOWVOLTAGE = SIGRTMIN + offset_data.low_voltage_signal_offset; + const int SIGWAKEUP = SIGRTMIN + offset_data.wake_up_signal_offset; + const int SIGIGNOFF = SIGRTMIN + offset_data.ignition_off_signal_offset; + sigaddset(&signal_set, SIGLOWVOLTAGE); + sigaddset(&signal_set, SIGWAKEUP); + sigaddset(&signal_set, SIGIGNOFF); + + // Set signals mask to be blocked by thread + return !pthread_sigmask(SIG_BLOCK, &signal_set, nullptr); +} + namespace { bool CatchSIGSEGV(sighandler_t handler) { struct sigaction act; -- cgit v1.2.1 From b003a5f4bf1859190bc00c138a8e97f9f83f19e5 Mon Sep 17 00:00:00 2001 From: Andriy Byzhynar Date: Wed, 27 Jun 2018 15:22:19 +0300 Subject: Implement unit tests for Low Voltage Signals handler --- src/appMain/CMakeLists.txt | 3 + src/appMain/test/CMakeLists.txt | 44 ++++++++ .../test/low_voltage_signals_handler_test.cc | 125 +++++++++++++++++++++ src/appMain/test/mock_life_cycle.h | 54 +++++++++ .../rpc_plugins/sdl_rpc_plugin/test/CMakeLists.txt | 1 + 5 files changed, 227 insertions(+) create mode 100644 src/appMain/test/CMakeLists.txt create mode 100644 src/appMain/test/low_voltage_signals_handler_test.cc create mode 100644 src/appMain/test/mock_life_cycle.h diff --git a/src/appMain/CMakeLists.txt b/src/appMain/CMakeLists.txt index 41d3d4202e..fe9a6af3f7 100644 --- a/src/appMain/CMakeLists.txt +++ b/src/appMain/CMakeLists.txt @@ -253,3 +253,6 @@ else() GROUP_EXECUTE WORLD_READ WORLD_EXECUTE) endif() +if(BUILD_TESTS) + add_subdirectory(test) +endif() diff --git a/src/appMain/test/CMakeLists.txt b/src/appMain/test/CMakeLists.txt new file mode 100644 index 0000000000..c90cad203b --- /dev/null +++ b/src/appMain/test/CMakeLists.txt @@ -0,0 +1,44 @@ +# 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. + +include_directories ( + ${GMOCK_INCLUDE_DIRECTORY} +) + +set(testSources + $ + ${CMAKE_SOURCE_DIR}/src/appMain/test/low_voltage_signals_handler_test.cc +) + +set(LIBRARIES + gmock +) + +create_test(low_voltage_signals_handler_test "${testSources}" "${LIBRARIES}") diff --git a/src/appMain/test/low_voltage_signals_handler_test.cc b/src/appMain/test/low_voltage_signals_handler_test.cc new file mode 100644 index 0000000000..c6be92e558 --- /dev/null +++ b/src/appMain/test/low_voltage_signals_handler_test.cc @@ -0,0 +1,125 @@ +/* +* 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. +*/ + +#include "appMain/low_voltage_signals_handler.h" + +#include +#include "gtest/gtest.h" +#include "appMain/test/mock_life_cycle.h" +#include "config_profile/profile.h" +#include "utils/macro.h" + +namespace test { + +class LowVoltageSignalsHandlerTest : public ::testing::Test { + protected: + void SetUp() OVERRIDE { + profile_.set_config_file_name("smartDeviceLink.ini"); + signals_offset_ = {profile_.low_voltage_signal_offset(), + profile_.wake_up_signal_offset(), + profile_.ignition_off_signal_offset()}; + + low_voltage_signals_handler_ = + std::unique_ptr( + new main_namespace::LowVoltageSignalsHandler(mock_life_cycle_, + signals_offset_)); + } + + profile::Profile profile_; + main_namespace::LowVoltageSignalsOffset signals_offset_; + std::unique_ptr + low_voltage_signals_handler_; + main_namespace::MockLifeCycle mock_life_cycle_; +}; + +TEST_F(LowVoltageSignalsHandlerTest, + LowVoltageSignalReceived_ExpectLifeCycleLowVoltageCall) { + // Check that initial SDL state is running + EXPECT_EQ(main_namespace::SDLState::kRun, + low_voltage_signals_handler_->get_current_sdl_state()); + // Set expectation after LOW VOLTAGE signal + EXPECT_CALL(mock_life_cycle_, LowVoltage()); + const int low_voltage_signo = + low_voltage_signals_handler_->low_voltage_signo(); + // Emulate LOW VOLTAGE signal receipt and handling + low_voltage_signals_handler_->HandleSignal(low_voltage_signo); + // Check that SDL is in sleep state after LOW VOLTAGE + EXPECT_EQ(main_namespace::SDLState::kSleep, + low_voltage_signals_handler_->get_current_sdl_state()); +} + +TEST_F(LowVoltageSignalsHandlerTest, + WakeUpSignalReceived_ExpectLifeCycleWakeUpCall) { + // Check that initial SDL state is running + EXPECT_EQ(main_namespace::SDLState::kRun, + low_voltage_signals_handler_->get_current_sdl_state()); + EXPECT_CALL(mock_life_cycle_, LowVoltage()); + const int low_voltage_signo = + low_voltage_signals_handler_->low_voltage_signo(); + // Emulate LOW VOLTAGE signals receipt and handling + low_voltage_signals_handler_->HandleSignal(low_voltage_signo); + // Check that SDL is in sleep state after LOW VOLTAGE + EXPECT_EQ(main_namespace::SDLState::kSleep, + low_voltage_signals_handler_->get_current_sdl_state()); + EXPECT_CALL(mock_life_cycle_, WakeUp()); + const int wake_up_signo = low_voltage_signals_handler_->wake_up_signo(); + // Emulate WAKE UP signal receipt and handling + low_voltage_signals_handler_->HandleSignal(wake_up_signo); + // Check that SDL is in running state after WAKE UP + EXPECT_EQ(main_namespace::SDLState::kRun, + low_voltage_signals_handler_->get_current_sdl_state()); +} + +TEST_F(LowVoltageSignalsHandlerTest, + IgnitionOffSignalReceived_ExpectLifeCycleIgnitionOffCall) { + // Check that initial SDL state is running + EXPECT_EQ(main_namespace::SDLState::kRun, + low_voltage_signals_handler_->get_current_sdl_state()); + EXPECT_CALL(mock_life_cycle_, LowVoltage()); + const int low_voltage_signo = + low_voltage_signals_handler_->low_voltage_signo(); + // Emulate LOW VOLTAGE signals receipt and handling + low_voltage_signals_handler_->HandleSignal(low_voltage_signo); + // Check that SDL is in sleep state after LOW VOLTAGE + EXPECT_EQ(main_namespace::SDLState::kSleep, + low_voltage_signals_handler_->get_current_sdl_state()); + EXPECT_CALL(mock_life_cycle_, IgnitionOff()); + const int ignition_off_signo = + low_voltage_signals_handler_->ignition_off_signo(); + + // Emulate IGNITION OFF signal receipt and handling + low_voltage_signals_handler_->HandleSignal(ignition_off_signo); + // Check that SDL is in stopped state after IGNITION OFF + EXPECT_EQ(main_namespace::SDLState::kStop, + low_voltage_signals_handler_->get_current_sdl_state()); +} +} // namespace test diff --git a/src/appMain/test/mock_life_cycle.h b/src/appMain/test/mock_life_cycle.h new file mode 100644 index 0000000000..fc24b26080 --- /dev/null +++ b/src/appMain/test/mock_life_cycle.h @@ -0,0 +1,54 @@ +/* +* 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_APPMAIN_TEST_MOCK_LIFE_CYCLE_H_ +#define SRC_APPMAIN_TEST_MOCK_LIFE_CYCLE_H_ + +#include "appMain/life_cycle.h" +#include "gmock/gmock.h" + +namespace main_namespace { + +class MockLifeCycle : public LifeCycle { + public: + MOCK_METHOD0(StartComponents, bool()); + MOCK_METHOD0(InitMessageSystem, bool()); + MOCK_METHOD0(Run, void()); + MOCK_METHOD0(StopComponents, void()); + MOCK_METHOD0(LowVoltage, void()); + MOCK_METHOD0(WakeUp, void()); + MOCK_METHOD0(IgnitionOff, void()); +}; + +} // namespace main_namespace + +#endif // SRC_APPMAIN_TEST_MOCK_LIFE_CYCLE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/CMakeLists.txt b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/CMakeLists.txt index da51c3e4e4..1a206c2cce 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/CMakeLists.txt +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/CMakeLists.txt @@ -6,6 +6,7 @@ include_directories( ${COMPONENTS_DIR}/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/ ${COMPONENTS_DIR}/application_manager/test/include/ ${POLICY_MOCK_INCLUDE_PATH}/ + ${CMAKE_SOURCE_DIR}/src ) -- cgit v1.2.1 From 5ca9746469583369244adda2e1ce1fd5a5f03e27 Mon Sep 17 00:00:00 2001 From: Andriy Byzhynar Date: Mon, 23 Jul 2018 16:00:03 +0300 Subject: Implement resumption during Low Voltage Implemented resumption logic during Low Voltage (used app_info.dat file for resumption.Configurable in smartdevicelink.ini file) --- .../application_manager/application_manager_impl.h | 4 +- .../application_manager/resumption/resume_ctrl.h | 20 +- .../resumption/resume_ctrl_impl.h | 97 +++++++- .../resumption/resumption_data.h | 24 ++ .../resumption/resumption_data_db.h | 24 ++ .../resumption/resumption_data_json.h | 24 ++ .../application_manager/smart_object_keys.h | 3 + .../src/application_manager_impl.cc | 25 +- .../src/resumption/resume_ctrl_impl.cc | 257 ++++++++++++++++++--- .../src/resumption/resumption_data_db.cc | 14 ++ .../src/resumption/resumption_data_json.cc | 65 ++++++ .../application_manager/src/smart_object_keys.cc | 2 + .../src/state_controller_impl.cc | 3 + .../include/application_manager/mock_resume_ctrl.h | 7 + .../application_manager/mock_resumption_data.h | 5 + .../application_manager/application_manager.h | 8 +- .../application_manager/mock_application_manager.h | 2 +- 17 files changed, 535 insertions(+), 49 deletions(-) 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 5f485b76eb..4f604f940e 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 @@ -1238,10 +1238,10 @@ class ApplicationManagerImpl */ void SendOnSDLClose(); - /* + /** * @brief returns true if low voltage state is active */ - bool IsLowVoltage(); + bool IsLowVoltage() const OVERRIDE; /** * @brief Allows to process postponed commands for application diff --git a/src/components/application_manager/include/application_manager/resumption/resume_ctrl.h b/src/components/application_manager/include/application_manager/resumption/resume_ctrl.h index 90c6c5c208..f9a60c862b 100644 --- a/src/components/application_manager/include/application_manager/resumption/resume_ctrl.h +++ b/src/components/application_manager/include/application_manager/resumption/resume_ctrl.h @@ -34,7 +34,7 @@ #define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_RESUMPTION_RESUME_CTRL_H_ #include - +#include #include "application_manager/resumption/resumption_data.h" namespace application_manager { @@ -124,6 +124,16 @@ class ResumeCtrl { */ virtual void OnAwake() = 0; + /** + * @brief Saves Low Voltage signal timestamp + */ + virtual void SaveLowVoltageTime() = 0; + + /** + * @brief Saves Wake Up signal timestamp + */ + virtual void SaveWakeUpTime() = 0; + /** * @brief Checks if SDL has already received OnExitAllApplication notification * with "SUSPEND" reason @@ -134,12 +144,18 @@ class ResumeCtrl { virtual bool is_suspended() const = 0; /** - * @brief Method stops timer "RsmCtrlPercist" when SDL + * @brief Method stops timer "RsmCtrlPersist" when SDL * receives OnExitAllApplication notification * with reason "SUSPEND" */ virtual void StopSavePersistentDataTimer() = 0; + /** + * @brief Method starts timer "RsmCtrlPersist" when + * SDL receives onAwakeSDL notification + */ + virtual void StartSavePersistentDataTimer() = 0; + /** * @brief Start timer for resumption applications * Restore D1-D5 data diff --git a/src/components/application_manager/include/application_manager/resumption/resume_ctrl_impl.h b/src/components/application_manager/include/application_manager/resumption/resume_ctrl_impl.h index 17aabb6d60..85e232fe92 100644 --- a/src/components/application_manager/include/application_manager/resumption/resume_ctrl_impl.h +++ b/src/components/application_manager/include/application_manager/resumption/resume_ctrl_impl.h @@ -33,6 +33,8 @@ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_RESUMPTION_RESUME_CTRL_IMPL_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_RESUMPTION_RESUME_CTRL_IMPL_H_ +#include "application_manager/resumption/resume_ctrl.h" + #include #include #include @@ -46,7 +48,6 @@ #include "smart_objects/smart_object.h" #include "application_manager/application.h" #include "application_manager/resumption/resumption_data.h" -#include "application_manager/resumption/resume_ctrl.h" #include "utils/timer.h" namespace resumption { @@ -138,6 +139,10 @@ class ResumeCtrlImpl : public ResumeCtrl, */ void OnAwake() OVERRIDE; + void SaveLowVoltageTime() OVERRIDE; + + void SaveWakeUpTime() OVERRIDE; + /** * @brief Checks if SDL has already received OnExitAllApplication notification * with "SUSPEND" reason @@ -154,6 +159,13 @@ class ResumeCtrlImpl : public ResumeCtrl, */ void StopSavePersistentDataTimer() OVERRIDE; + /** + * @brief Check if all IGNITION OFF and IGNITION ON records + * saved in resumption data base + * @return True if all records saved, otherwise False + */ + bool CheckIgnCyclesData() const; + /** * @brief Method stops restore_hmi_level_timer_ "RsmCtrlRstore" in OnSuspend() */ @@ -300,7 +312,7 @@ class ResumeCtrlImpl : public ResumeCtrl, * @brief Method starts timer "RsmCtrlPercist" when * SDL receives onAwakeSDL notification */ - void StartSavePersistentDataTimer(); + void StartSavePersistentDataTimer() OVERRIDE; #ifdef BUILD_TESTS void set_resumption_storage( @@ -309,6 +321,30 @@ class ResumeCtrlImpl : public ResumeCtrl, bool get_resumption_active() const OVERRIDE; #endif // BUILD_TESTS private: + /** + * @brief Returns Low Voltage signal timestamp + * @return Low Voltage event timestamp if event LOW VOLTAGE event occures + * otherwise 0 + */ + time_t LowVoltageTime() const; + + /** + * @brief Returns Wake Up signal timestamp + * @return Wake Up timestamp if Wake Up signal occures + * otherwise 0 + */ + time_t WakeUpTime() const; + + /** + * @brief Resets Low Voltage signal timestamp to zero + */ + void ResetLowVoltageTime(); + + /** + * @brief Resets Wake Up signal timestamp to zero + */ + void ResetWakeUpTime(); + /** * @brief restores saved data of application * @param application contains application for which restores data @@ -390,11 +426,30 @@ class ResumeCtrlImpl : public ResumeCtrl, void AddWayPointsSubscription(app_mngr::ApplicationSharedPtr application, const smart_objects::SmartObject& saved_app); + /** + * @brief Checks if saved HMI level is allowed for resumption + * by Ignition Cycle restrictions + * @param saved_app application specific section from backup file + * @return True if allowed , otherwise - False + */ bool CheckIgnCycleRestrictions(const smart_objects::SmartObject& saved_app); - bool DisconnectedJustBeforeIgnOff( + /** + * @brief Checks if saved HMI level is allowed for resumption + * by Low Voltage restrictions + * @param saved_app application specific section from backup file + * @return True if allowed , otherwise - False + */ + bool CheckLowVoltageRestrictions(const smart_objects::SmartObject& saved_app); + + DEPRECATED bool DisconnectedJustBeforeIgnOff( const smart_objects::SmartObject& saved_app); + /** + * @brief Checks if saved HMI level is applicable for resumption + * @param saved_app application specific section from backup file + * @return True fs allowed , otherwise - False + */ bool CheckAppRestrictions(app_mngr::ApplicationConstSharedPtr application, const smart_objects::SmartObject& saved_app); @@ -409,10 +464,38 @@ class ResumeCtrlImpl : public ResumeCtrl, /** * @brief CheckDelayAfterIgnOn should check if SDL was started less - * then N seconds ago. N will be readed from profile. + * than N seconds ago. N will be read from profile. * @return true if SDL started N seconds ago, otherwise return false */ - bool CheckDelayAfterIgnOn(); + bool CheckDelayAfterIgnOn() const; + + /** + * @brief CheckDelayBeforeIgnOff checks if app was unregistered less + * than N seconds before Ignition OFF. N will be read from profile. + * @return true if app was disconnected within timeframe of N seconds before + * Ignition Off, + * otherwise return false + */ + bool CheckDelayBeforeIgnOff( + const smart_objects::SmartObject& saved_app) const; + + /** + * @brief CheckDelayAfterWakeUp should check if app was registered + * during the first N seconds after WakeUp signal. N will be read from + * profile. + * @return true if app registered within N seconds after WakeUp, otherwise + * return false + */ + bool CheckDelayAfterWakeUp() const; + + /** + * @brief CheckDelayBeforeLowVoltage checks if app was unregistered within + * N seconds before Low Voltage signal. N will be read from profile. + * @return true if app was disconnected within timeframe of N seconds before + * Low Voltage , otherwise return false + */ + bool CheckDelayBeforeLowVoltage( + const smart_objects::SmartObject& saved_app) const; typedef std::pair application_timestamp; @@ -447,7 +530,7 @@ class ResumeCtrlImpl : public ResumeCtrl, * @brief Get the last ignition off time from LastState * @return the last ignition off time from LastState */ - time_t GetIgnOffTime(); + time_t GetIgnOffTime() const; /** * @brief Setup IgnOff time to LastState @@ -535,6 +618,8 @@ class ResumeCtrlImpl : public ResumeCtrl, bool is_data_saved_; bool is_suspended_; time_t launch_time_; + time_t low_voltage_time_; + time_t wake_up_time_; std::shared_ptr resumption_storage_; application_manager::ApplicationManager& application_manager_; }; diff --git a/src/components/application_manager/include/application_manager/resumption/resumption_data.h b/src/components/application_manager/include/application_manager/resumption/resumption_data.h index 5ecfaf3c11..ee866719c8 100644 --- a/src/components/application_manager/include/application_manager/resumption/resumption_data.h +++ b/src/components/application_manager/include/application_manager/resumption/resumption_data.h @@ -110,6 +110,30 @@ class ResumptionData { */ DEPRECATED virtual void OnAwake() = 0; + /** + * @brief Increments global ignition on counter + * by 1 + */ + virtual void IncrementGlobalIgnOnCounter() = 0; + + /** + * @brief Get the global ignition on counter + * @return the global ignition on counter + */ + virtual uint32_t GetGlobalIgnOnCounter() const = 0; + + /** + * @brief Increments global ignition off counter + * by 1 + */ + virtual void IncrementGlobalIgnOffCounter() = 0; + + /** + * @brief Get the global ignition off counter + * @return the global ignition off counter + */ + virtual uint32_t GetGlobalIgnOffCounter() const = 0; + /** * @brief Retrieves hash ID for the given mobile app ID * and device ID from stored information. diff --git a/src/components/application_manager/include/application_manager/resumption/resumption_data_db.h b/src/components/application_manager/include/application_manager/resumption/resumption_data_db.h index 780aac82c1..08e9b04e62 100644 --- a/src/components/application_manager/include/application_manager/resumption/resumption_data_db.h +++ b/src/components/application_manager/include/application_manager/resumption/resumption_data_db.h @@ -110,6 +110,30 @@ class ResumptionDataDB : public ResumptionData { virtual uint32_t GetHMIApplicationID(const std::string& policy_app_id, const std::string& device_id) const; + /** + * @brief Increments global ignition on counter + * by 1 + */ + void IncrementGlobalIgnOnCounter() OVERRIDE; + + /** + * @brief Get the global ignition on counter + * @return the global ignition on counter + */ + virtual uint32_t GetGlobalIgnOnCounter() const OVERRIDE; + + /** + * @brief Increments global ignition off counter + * by 1 + */ + virtual void IncrementGlobalIgnOffCounter() OVERRIDE; + + /** + * @brief Get the global ignition off counter + * @return the global ignition off counter + */ + virtual uint32_t GetGlobalIgnOffCounter() const OVERRIDE; + /** * @brief Increments ignition counter for all registered applications * and remember ign_off time stamp diff --git a/src/components/application_manager/include/application_manager/resumption/resumption_data_json.h b/src/components/application_manager/include/application_manager/resumption/resumption_data_json.h index 82ec1d9e5c..1a48ff20d5 100644 --- a/src/components/application_manager/include/application_manager/resumption/resumption_data_json.h +++ b/src/components/application_manager/include/application_manager/resumption/resumption_data_json.h @@ -145,6 +145,30 @@ class ResumptionDataJson : public ResumptionData { */ virtual uint32_t GetIgnOffTime() const; + /** + * @brief Increments global ignition on counter + * by 1 + */ + void IncrementGlobalIgnOnCounter() OVERRIDE; + + /** + * @brief Get the global ignition on counter + * @return the global ignition on counter + */ + virtual uint32_t GetGlobalIgnOnCounter() const OVERRIDE; + + /** + * @brief Increments global ignition off counter + * by 1 + */ + virtual void IncrementGlobalIgnOffCounter() OVERRIDE; + + /** + * @brief Get the global ignition off counter + * @return the global ignition off counter + */ + virtual uint32_t GetGlobalIgnOffCounter() const OVERRIDE; + /** * @brief Checks if saved data have application * @param policy_app_id - mobile application id 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 d0a3c1ed96..90c9d403f7 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 @@ -313,6 +313,9 @@ extern const char* resume_vr_grammars; extern const char* ign_off_count; +extern const char* global_ign_on_counter; +extern const char* global_ign_off_counter; + extern const char* connection_info; extern const char* is_download_complete; diff --git a/src/components/application_manager/src/application_manager_impl.cc b/src/components/application_manager/src/application_manager_impl.cc index 374b5bb8b2..6ff0689408 100644 --- a/src/components/application_manager/src/application_manager_impl.cc +++ b/src/components/application_manager/src/application_manager_impl.cc @@ -178,7 +178,7 @@ ApplicationManagerImpl::ApplicationManagerImpl( , is_low_voltage_(false) , apps_size_(0) , is_stopping_(false) { - std::srand(std::time(0)); + std::srand(std::time(nullptr)); AddPolicyObserver(this); dir_type_to_string_map_ = {{TYPE_STORAGE, "Storage"}, @@ -405,6 +405,7 @@ void ApplicationManagerImpl::OnApplicationSwitched(ApplicationSharedPtr app) { bool ApplicationManagerImpl::IsAppTypeExistsInFullOrLimited( ApplicationConstSharedPtr app) const { + LOG4CXX_AUTO_TRACE(logger_); bool voice_state = app->is_voice_communication_supported(); bool media_state = app->is_media_application(); bool navi_state = app->is_navi(); @@ -2622,11 +2623,13 @@ void ApplicationManagerImpl::UnregisterApplication( return; } + if (is_resuming) { resume_controller().SaveApplication(app_to_remove); } else { resume_controller().RemoveApplicationFromSaved(app_to_remove); } + (hmi_capabilities_->get_hmi_language_handler()) .OnUnregisterApplication(app_id); AppV4DevicePredicate finder(handle); @@ -2730,14 +2733,24 @@ bool ApplicationManagerImpl::is_audio_pass_thru_active() const { void ApplicationManagerImpl::OnLowVoltage() { LOG4CXX_AUTO_TRACE(logger_); is_low_voltage_ = true; + resume_ctrl_->SaveLowVoltageTime(); + resume_ctrl_->StopSavePersistentDataTimer(); request_ctrl_.OnLowVoltage(); } -bool ApplicationManagerImpl::IsLowVoltage() { - LOG4CXX_TRACE(logger_, "result: " << is_low_voltage_); +bool ApplicationManagerImpl::IsLowVoltage() const { + LOG4CXX_TRACE(logger_, "Result: " << is_low_voltage_); return is_low_voltage_; } +void ApplicationManagerImpl::OnWakeUp() { + LOG4CXX_AUTO_TRACE(logger_); + is_low_voltage_ = false; + resume_ctrl_->SaveWakeUpTime(); + resume_ctrl_->StartSavePersistentDataTimer(); + request_ctrl_.OnWakeUp(); +} + std::string ApplicationManagerImpl::GetHashedAppID( uint32_t connection_key, const std::string& mobile_app_id) const { connection_handler::DeviceHandle device_id = 0; @@ -3156,12 +3169,6 @@ policy::DeviceConsent ApplicationManagerImpl::GetUserConsentForDevice( return GetPolicyHandler().GetUserConsentForDevice(device_id); } -void ApplicationManagerImpl::OnWakeUp() { - LOG4CXX_AUTO_TRACE(logger_); - is_low_voltage_ = false; - request_ctrl_.OnWakeUp(); -} - mobile_apis::Result::eType ApplicationManagerImpl::SaveBinary( const std::vector& binary_data, const std::string& file_path, diff --git a/src/components/application_manager/src/resumption/resume_ctrl_impl.cc b/src/components/application_manager/src/resumption/resume_ctrl_impl.cc index 42dc335878..d52a495d17 100644 --- a/src/components/application_manager/src/resumption/resume_ctrl_impl.cc +++ b/src/components/application_manager/src/resumption/resume_ctrl_impl.cc @@ -74,7 +74,9 @@ ResumeCtrlImpl::ResumeCtrlImpl(ApplicationManager& application_manager) , is_resumption_active_(false) , is_data_saved_(false) , is_suspended_(false) - , launch_time_(time(NULL)) + , launch_time_(time(nullptr)) + , low_voltage_time_(0) + , wake_up_time_(0) , application_manager_(application_manager) {} #ifdef BUILD_TESTS void ResumeCtrlImpl::set_resumption_storage( @@ -144,9 +146,13 @@ void ResumeCtrlImpl::SaveAllApplications() { void ResumeCtrlImpl::SaveApplication(ApplicationSharedPtr application) { LOG4CXX_AUTO_TRACE(logger_); DCHECK_OR_RETURN_VOID(application); - LOG4CXX_INFO(logger_, - "application with appID " << application->app_id() - << " will be saved"); + if (application_manager_.IsLowVoltage()) { + LOG4CXX_DEBUG(logger_, "Low Voltage state is active"); + return; + } + LOG4CXX_DEBUG(logger_, + "application with appID " << application->app_id() + << " will be saved"); resumption_storage_->SaveApplication(application); } @@ -310,6 +316,10 @@ uint32_t ResumeCtrlImpl::GetHMIApplicationID( bool ResumeCtrlImpl::RemoveApplicationFromSaved( ApplicationConstSharedPtr application) { + if (application_manager_.IsLowVoltage()) { + LOG4CXX_DEBUG(logger_, "Low Voltage state is active"); + return false; + } const std::string& device_mac = application->mac_address(); return resumption_storage_->RemoveApplicationFromSaved( application->policy_app_id(), device_mac); @@ -323,8 +333,10 @@ void ResumeCtrlImpl::OnSuspend() { void ResumeCtrlImpl::OnIgnitionOff() { LOG4CXX_AUTO_TRACE(logger_); - resumption_storage_->IncrementIgnOffCount(); - FinalPersistData(); + if (!application_manager_.IsLowVoltage()) { + resumption_storage_->IncrementIgnOffCount(); + FinalPersistData(); + } } void ResumeCtrlImpl::OnAwake() { @@ -334,6 +346,37 @@ void ResumeCtrlImpl::OnAwake() { StartSavePersistentDataTimer(); } +void ResumeCtrlImpl::SaveLowVoltageTime() { + ResetLowVoltageTime(); + low_voltage_time_ = time(nullptr); + LOG4CXX_DEBUG(logger_, + "Low Voltage timestamp : " << low_voltage_time_ << " saved"); +} + +void ResumeCtrlImpl::ResetLowVoltageTime() { + low_voltage_time_ = 0; + LOG4CXX_DEBUG(logger_, "Resetting Low Voltage timestamp"); +} + +void ResumeCtrlImpl::SaveWakeUpTime() { + ResetWakeUpTime(); + wake_up_time_ = std::time(nullptr); + LOG4CXX_DEBUG(logger_, "Wake Up timestamp : " << wake_up_time_ << " saved"); +} + +void ResumeCtrlImpl::ResetWakeUpTime() { + wake_up_time_ = 0; + LOG4CXX_DEBUG(logger_, "Resetting Wake Up timestamp"); +} + +time_t ResumeCtrlImpl::LowVoltageTime() const { + return low_voltage_time_; +} + +time_t ResumeCtrlImpl::WakeUpTime() const { + return wake_up_time_; +} + bool ResumeCtrlImpl::is_suspended() const { return is_suspended_; } @@ -440,12 +483,25 @@ void ResumeCtrlImpl::StartAppHmiStateResumption( LOG4CXX_ERROR(logger_, "Application was not saved"); return; } - const uint32_t ign_off_count = saved_app[strings::ign_off_count].asUInt(); - bool restore_data_allowed = false; - restore_data_allowed = - CheckAppRestrictions(application, saved_app) && - ((0 == ign_off_count) || CheckIgnCycleRestrictions(saved_app)); - if (restore_data_allowed) { + + const bool is_hmi_level_applicable_to_resume = + CheckAppRestrictions(application, saved_app); + + if (!is_hmi_level_applicable_to_resume) { + LOG4CXX_DEBUG(logger_, "No applicable HMI level found for resuming"); + return; + } + + const bool is_resume_allowed_by_low_voltage = + CheckLowVoltageRestrictions(saved_app); + + const bool is_hmi_level_allowed_by_ign_cycle = + CheckIgnCycleRestrictions(saved_app); + + const bool restore_hmi_level_allowed = + is_resume_allowed_by_low_voltage && is_hmi_level_allowed_by_ign_cycle; + + if (restore_hmi_level_allowed) { LOG4CXX_INFO(logger_, "Resume application " << application->policy_app_id()); RestoreAppHMIState(application); @@ -716,21 +772,39 @@ void ResumeCtrlImpl::AddSubscriptions( bool ResumeCtrlImpl::CheckIgnCycleRestrictions( const smart_objects::SmartObject& saved_app) { LOG4CXX_AUTO_TRACE(logger_); - bool result = true; if (!CheckDelayAfterIgnOn()) { - LOG4CXX_INFO(logger_, "Application was connected long after ign on"); - result = false; + LOG4CXX_DEBUG(logger_, "Application was connected long after ign on"); + return false; } - if (!DisconnectedJustBeforeIgnOff(saved_app)) { - LOG4CXX_INFO(logger_, "Application was dissconnected long before ign off"); - result = false; + if (!CheckDelayBeforeIgnOff(saved_app)) { + LOG4CXX_DEBUG(logger_, "Application was disconnected long before ign off"); + return false; } - return result; + return true; } -bool ResumeCtrlImpl::DisconnectedJustBeforeIgnOff( +bool ResumeCtrlImpl::CheckLowVoltageRestrictions( + const smart_objects::SmartObject& saved_app) { + LOG4CXX_AUTO_TRACE(logger_); + + if (!CheckDelayBeforeLowVoltage(saved_app)) { + LOG4CXX_DEBUG(logger_, + "Application was disconnected long before low voltage"); + return false; + } + + if (!CheckDelayAfterWakeUp()) { + LOG4CXX_DEBUG(logger_, "Application was connected long after wake up"); + return false; + } + + LOG4CXX_DEBUG(logger_, "HMI Level resuming in not restricted by Low Voltage"); + return true; +} + +DEPRECATED bool ResumeCtrlImpl::DisconnectedJustBeforeIgnOff( const smart_objects::SmartObject& saved_app) { using namespace date_time; LOG4CXX_AUTO_TRACE(logger_); @@ -738,8 +812,9 @@ bool ResumeCtrlImpl::DisconnectedJustBeforeIgnOff( const time_t time_stamp = static_cast(saved_app[strings::time_stamp].asInt()); - time_t ign_off_time = + const time_t ign_off_time = static_cast(resumption_storage_->GetIgnOffTime()); + const uint32_t sec_spent_before_ign = labs(ign_off_time - time_stamp); LOG4CXX_DEBUG( logger_, @@ -752,6 +827,107 @@ bool ResumeCtrlImpl::DisconnectedJustBeforeIgnOff( application_manager_.get_settings().resumption_delay_before_ign(); } +bool ResumeCtrlImpl::CheckDelayBeforeIgnOff( + const smart_objects::SmartObject& saved_app) const { + using namespace date_time; + LOG4CXX_AUTO_TRACE(logger_); + DCHECK_OR_RETURN(saved_app.keyExists(strings::time_stamp), false); + + const time_t time_stamp = + static_cast(saved_app[strings::time_stamp].asInt()); + const time_t ign_off_time = + static_cast(resumption_storage_->GetIgnOffTime()); + + if (CheckIgnCyclesData() && 0 == ign_off_time) { + LOG4CXX_DEBUG( + logger_, "No IGNITION OFF records found: This is first Ignition cycle"); + return true; + } + + // This means that ignition off timestamp was not saved + // Possible reasons: Low Voltage event, core crash etc. + if (ign_off_time < time_stamp) { + LOG4CXX_DEBUG(logger_, "Last IGNITION OFF record missed"); + return true; + } + + const uint32_t sec_spent_before_ign = labs(ign_off_time - time_stamp); + LOG4CXX_DEBUG( + logger_, + "ign_off_time " + << ign_off_time << "; app_disconnect_time " << time_stamp + << "; sec_spent_before_ign " << sec_spent_before_ign + << "; resumption_delay_before_ign " + << application_manager_.get_settings().resumption_delay_before_ign()); + return sec_spent_before_ign <= + application_manager_.get_settings().resumption_delay_before_ign(); +} + +bool ResumeCtrlImpl::CheckDelayBeforeLowVoltage( + const smart_objects::SmartObject& saved_app) const { + using namespace date_time; + LOG4CXX_AUTO_TRACE(logger_); + DCHECK_OR_RETURN(saved_app.keyExists(strings::time_stamp), false); + + if (0 == LowVoltageTime()) { + LOG4CXX_DEBUG(logger_, "No Low Voltage signal timestamp saved"); + return true; + } + + const time_t unregistration_time_stamp = + static_cast(saved_app[strings::time_stamp].asInt()); + const time_t low_voltage_timestamp = static_cast(LowVoltageTime()); + const int32_t sec_spent_before_low_voltage = + (low_voltage_timestamp - unregistration_time_stamp); + if (0 > sec_spent_before_low_voltage) { + LOG4CXX_DEBUG(logger_, + "Low Voltage time: " + << low_voltage_timestamp + << "; App disconnect time: " << unregistration_time_stamp + << "; Secs between app disconnect and low voltage event " + << sec_spent_before_low_voltage); + return true; + } + + const uint32_t secs_between_app_disconnect_and_low_voltage = + static_cast(sec_spent_before_low_voltage); + const uint32_t wait_time = + application_manager_.get_settings().resumption_delay_before_ign(); + LOG4CXX_DEBUG(logger_, + "Low Voltage time: " + << low_voltage_timestamp + << "; App disconnect time: " << unregistration_time_stamp + << "; Secs between app disconnect and low voltage event " + << secs_between_app_disconnect_and_low_voltage + << "; Timeout for HMI level resuming: " << wait_time); + return secs_between_app_disconnect_and_low_voltage <= wait_time; +} + +bool ResumeCtrlImpl::CheckDelayAfterWakeUp() const { + using namespace date_time; + LOG4CXX_AUTO_TRACE(logger_); + + if (0 == WakeUpTime()) { + LOG4CXX_DEBUG(logger_, "No WakeUp signal timestamp saved"); + return true; + } + + const time_t current_time = time(nullptr); + const time_t wake_up_timestamp = static_cast(WakeUpTime()); + + const uint32_t seconds_from_wake_up_signal = + labs(current_time - wake_up_timestamp); + const uint32_t wait_time = + application_manager_.get_settings().resumption_delay_after_ign(); + LOG4CXX_DEBUG( + logger_, + "Current time: " << current_time << "; WakeUp Signal time: " + << wake_up_timestamp << "; Seconds passed from wake up: " + << seconds_from_wake_up_signal + << "; Timeout for HMI level resuming: " << wait_time); + return seconds_from_wake_up_signal <= wait_time; +} + bool ResumeCtrlImpl::CheckAppRestrictions( ApplicationConstSharedPtr application, const smart_objects::SmartObject& saved_app) { @@ -773,9 +949,10 @@ bool ResumeCtrlImpl::CheckAppRestrictions( ? true : false; LOG4CXX_DEBUG(logger_, - "is_media_app " << application->is_media_application() - << "; hmi_level " << hmi_level << " result " - << result); + "is_media_app: " << application->is_media_application() + << "; hmi_level: " << hmi_level << "; result: " + << (result ? "Applicable for resume" + : "Non-applicable for resume")); return result; } @@ -788,11 +965,35 @@ bool ResumeCtrlImpl::CheckIcons(ApplicationSharedPtr application, return mobile_apis::Result::INVALID_DATA != verify_images; } -bool ResumeCtrlImpl::CheckDelayAfterIgnOn() { +bool ResumeCtrlImpl::CheckIgnCyclesData() const { + LOG4CXX_AUTO_TRACE(logger_); + const uint32_t global_ign_off_count = + resumption_storage_->GetGlobalIgnOffCounter(); + const uint32_t global_ign_on_count = + resumption_storage_->GetGlobalIgnOnCounter(); + const uint32_t diff = global_ign_on_count - global_ign_off_count; + const bool is_ign_off_record_missed = diff >= 2; + if (is_ign_off_record_missed) { + LOG4CXX_WARN(logger_, + "Some IGN OFF records missed. Possibly due to Low Voltage"); + return false; + } + return true; +} + +bool ResumeCtrlImpl::CheckDelayAfterIgnOn() const { using namespace date_time; LOG4CXX_AUTO_TRACE(logger_); - const time_t curr_time = time(NULL); + const time_t ign_off_time = GetIgnOffTime(); + + if (CheckIgnCyclesData() && 0 == ign_off_time) { + LOG4CXX_DEBUG( + logger_, "No IGNITION OFF records found: This is first Ignition cycle"); + return true; + } + const time_t curr_time = time(nullptr); const time_t sdl_launch_time = LaunchTime(); + const uint32_t seconds_from_sdl_start = labs(curr_time - sdl_launch_time); const uint32_t wait_time = application_manager_.get_settings().resumption_delay_after_ign(); @@ -808,7 +1009,7 @@ time_t ResumeCtrlImpl::LaunchTime() const { return launch_time_; } -time_t ResumeCtrlImpl::GetIgnOffTime() { +time_t ResumeCtrlImpl::GetIgnOffTime() const { return resumption_storage_->GetIgnOffTime(); } @@ -856,6 +1057,8 @@ void ResumeCtrlImpl::AddToResumptionTimerQueue(const uint32_t app_id) { "Application ID " << app_id << " have been added" " to resumption queue."); if (run_resumption) { + LOG4CXX_DEBUG(logger_, + "Application ID " << app_id << " will be restored by timer"); restore_hmi_level_timer_.Start( application_manager_.get_settings().app_resuming_timeout(), timer::kSingleShot); diff --git a/src/components/application_manager/src/resumption/resumption_data_db.cc b/src/components/application_manager/src/resumption/resumption_data_db.cc index 2fe7330a9c..90c8a20e83 100644 --- a/src/components/application_manager/src/resumption/resumption_data_db.cc +++ b/src/components/application_manager/src/resumption/resumption_data_db.cc @@ -380,6 +380,20 @@ uint32_t ResumptionDataDB::GetIgnOffTime() const { return SelectIgnOffTime(); } +uint32_t ResumptionDataDB::GetGlobalIgnOnCounter() const { + return 0; +} + +uint32_t ResumptionDataDB::GetGlobalIgnOffCounter() const { + return 0; +} + +void ResumptionDataDB::IncrementGlobalIgnOffCounter() { +} + +void ResumptionDataDB::IncrementGlobalIgnOnCounter() { +} + ssize_t ResumptionDataDB::IsApplicationSaved( const std::string& policy_app_id, const std::string& device_id) const { LOG4CXX_AUTO_TRACE(logger_); diff --git a/src/components/application_manager/src/resumption/resumption_data_json.cc b/src/components/application_manager/src/resumption/resumption_data_json.cc index b6a50fd5de..e11f482ad6 100644 --- a/src/components/application_manager/src/resumption/resumption_data_json.cc +++ b/src/components/application_manager/src/resumption/resumption_data_json.cc @@ -149,6 +149,7 @@ void ResumptionDataJson::IncrementIgnOffCount() { using namespace app_mngr; LOG4CXX_AUTO_TRACE(logger_); sync_primitives::AutoLock autolock(resumption_lock_); + IncrementGlobalIgnOffCounter(); Json::Value to_save = Json::arrayValue; for (Json::Value::iterator it = GetSavedApplications().begin(); it != GetSavedApplications().end(); @@ -283,6 +284,69 @@ uint32_t ResumptionDataJson::GetIgnOffTime() const { return resumption[strings::last_ign_off_time].asUInt(); } +uint32_t ResumptionDataJson::GetGlobalIgnOnCounter() const { + using namespace app_mngr; + LOG4CXX_AUTO_TRACE(logger_); + sync_primitives::AutoLock autolock(resumption_lock_); + Json::Value& resumption = GetResumptionData(); + if (resumption.isMember(strings::global_ign_on_counter)) { + return resumption[strings::global_ign_on_counter].asUInt(); + } + return 1; +} + +uint32_t ResumptionDataJson::GetGlobalIgnOffCounter() const { + using namespace app_mngr; + LOG4CXX_AUTO_TRACE(logger_); + sync_primitives::AutoLock autolock(resumption_lock_); + Json::Value& resumption = GetResumptionData(); + if (resumption.isMember(strings::global_ign_off_counter)) { + return resumption[strings::global_ign_off_counter].asUInt(); + } + return 0; +} + +void ResumptionDataJson::IncrementGlobalIgnOffCounter() { + using namespace app_mngr; + LOG4CXX_AUTO_TRACE(logger_); + sync_primitives::AutoLock autolock(resumption_lock_); + Json::Value& resumption = GetResumptionData(); + if (resumption.isMember(strings::global_ign_off_counter)) { + const uint32_t global_ign_off_counter = + resumption[strings::global_ign_off_counter].asUInt(); + LOG4CXX_DEBUG(logger_, + "Global IGN OFF counter in resumption data: " + << global_ign_off_counter); + resumption[strings::global_ign_off_counter] = global_ign_off_counter + 1; + LOG4CXX_DEBUG(logger_, + "Global IGN OFF counter new value: " + << resumption[strings::global_ign_off_counter].asUInt()); + } else { + resumption[strings::global_ign_off_counter] = 1; + } +} + +void ResumptionDataJson::IncrementGlobalIgnOnCounter() { + using namespace app_mngr; + LOG4CXX_AUTO_TRACE(logger_); + sync_primitives::AutoLock autolock(resumption_lock_); + Json::Value& resumption = GetResumptionData(); + if (resumption.isMember(strings::global_ign_on_counter)) { + const uint32_t global_ign_on_counter = + resumption[strings::global_ign_on_counter].asUInt(); + LOG4CXX_DEBUG( + logger_, + "Global IGN ON counter in resumption data: " << global_ign_on_counter); + resumption[strings::global_ign_on_counter] = global_ign_on_counter + 1; + LOG4CXX_DEBUG(logger_, + "Global IGN ON counter new value: " + << resumption[strings::global_ign_on_counter].asUInt()); + } else { + resumption[strings::global_ign_on_counter] = 1; + } + last_state().SaveStateToFileSystem(); +} + ssize_t ResumptionDataJson::IsApplicationSaved( const std::string& policy_app_id, const std::string& device_id) const { LOG4CXX_AUTO_TRACE(logger_); @@ -454,6 +518,7 @@ void ResumptionDataJson::SetLastIgnOffTime(time_t ign_off_time) { bool ResumptionDataJson::Init() { LOG4CXX_AUTO_TRACE(logger_); + IncrementGlobalIgnOnCounter(); return true; } diff --git a/src/components/application_manager/src/smart_object_keys.cc b/src/components/application_manager/src/smart_object_keys.cc index 006b8c9249..ebc114347e 100644 --- a/src/components/application_manager/src/smart_object_keys.cc +++ b/src/components/application_manager/src/smart_object_keys.cc @@ -276,6 +276,8 @@ const char* last_ign_off_time = "last_ign_off_time"; const char* resume_vr_grammars = "resumeVrGrammars"; const char* ign_off_count = "ign_off_count"; +const char* global_ign_on_counter = "global_ign_on_counter"; +const char* global_ign_off_counter = "global_ign_off_counter"; const char* suspend_count = "suspend_count"; const char* connection_info = "connection_info"; diff --git a/src/components/application_manager/src/state_controller_impl.cc b/src/components/application_manager/src/state_controller_impl.cc index f7a147d6df..3d44709657 100644 --- a/src/components/application_manager/src/state_controller_impl.cc +++ b/src/components/application_manager/src/state_controller_impl.cc @@ -458,6 +458,8 @@ mobile_apis::HMILevel::eType StateControllerImpl::GetAvailableHmiLevel( LOG4CXX_AUTO_TRACE(logger_); mobile_apis::HMILevel::eType result = hmi_level; + LOG4CXX_DEBUG(logger_, "HMI Level: " << hmi_level); + if (!IsStreamableHMILevel(hmi_level)) { return result; } @@ -465,6 +467,7 @@ mobile_apis::HMILevel::eType StateControllerImpl::GetAvailableHmiLevel( const bool is_audio_app = app->IsAudioApplication(); const bool does_audio_app_with_same_type_exist = app_mngr_.IsAppTypeExistsInFullOrLimited(app); + if (mobile_apis::HMILevel::HMI_LIMITED == hmi_level) { if (!is_audio_app || does_audio_app_with_same_type_exist) { result = app_mngr_.GetDefaultHmiLevel(app); diff --git a/src/components/application_manager/test/include/application_manager/mock_resume_ctrl.h b/src/components/application_manager/test/include/application_manager/mock_resume_ctrl.h index 3c4a3806d6..0fa7a898be 100644 --- a/src/components/application_manager/test/include/application_manager/mock_resume_ctrl.h +++ b/src/components/application_manager/test/include/application_manager/mock_resume_ctrl.h @@ -50,8 +50,15 @@ class MockResumeCtrl : public resumption::ResumeCtrl { MOCK_METHOD0(OnSuspend, void()); MOCK_METHOD0(OnIgnitionOff, void()); MOCK_METHOD0(OnAwake, void()); + MOCK_CONST_METHOD0(LowVoltageTime, time_t()); + MOCK_CONST_METHOD0(WakeUpTime, time_t()); + MOCK_METHOD0(SaveLowVoltageTime, void()); + MOCK_METHOD0(SaveWakeUpTime, void()); + MOCK_METHOD0(ResetLowVoltageTime, void()); + MOCK_METHOD0(ResetWakeUpTime, void()); MOCK_CONST_METHOD0(is_suspended, bool()); MOCK_METHOD0(StopSavePersistentDataTimer, void()); + MOCK_METHOD0(StartSavePersistentDataTimer, void()); MOCK_METHOD2(StartResumption, bool(app_mngr::ApplicationSharedPtr application, const std::string& hash)); diff --git a/src/components/application_manager/test/include/application_manager/mock_resumption_data.h b/src/components/application_manager/test/include/application_manager/mock_resumption_data.h index cfec034653..a3ac670fa4 100644 --- a/src/components/application_manager/test/include/application_manager/mock_resumption_data.h +++ b/src/components/application_manager/test/include/application_manager/mock_resumption_data.h @@ -66,6 +66,11 @@ class MockResumptionData : public ::resumption::ResumptionData { const std::string& device_id, std::string& hash_id)); MOCK_METHOD0(OnAwake, void()); + MOCK_METHOD0(IncrementGlobalIgnOnCounter, void()); + MOCK_CONST_METHOD0(GetGlobalIgnOnCounter, uint32_t()); + MOCK_METHOD0(IncrementGlobalIgnOffCounter, void()); + MOCK_CONST_METHOD0(GetGlobalIgnOffCounter, uint32_t()); + MOCK_METHOD0(DecrementIgnOffCount, void()); MOCK_CONST_METHOD3(GetSavedApplication, bool(const std::string& policy_app_id, diff --git a/src/components/include/application_manager/application_manager.h b/src/components/include/application_manager/application_manager.h index 8397fbf790..ed9d3c0114 100644 --- a/src/components/include/application_manager/application_manager.h +++ b/src/components/include/application_manager/application_manager.h @@ -33,6 +33,7 @@ #ifndef SRC_COMPONENTS_INCLUDE_APPLICATION_MANAGER_APPLICATION_MANAGER_H_ #define SRC_COMPONENTS_INCLUDE_APPLICATION_MANAGER_APPLICATION_MANAGER_H_ +#include #include #include #include @@ -424,6 +425,11 @@ class ApplicationManager { */ virtual void EndNaviServices(uint32_t app_id) = 0; + /** + * @brief returns true if low voltage state is active + */ + virtual bool IsLowVoltage() const = 0; + /* @brief Starts audio passthru process * @deprecated Use BeginAudioPassThru(uint32_t app_id) instead * @@ -498,8 +504,6 @@ class ApplicationManager { virtual bool IsStopping() const = 0; - virtual bool IsLowVoltage() = 0; - virtual void RemoveAppFromTTSGlobalPropertiesList(const uint32_t app_id) = 0; virtual mobile_apis::Result::eType SaveBinary( 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 5900b760a6..25340d7c2a 100644 --- a/src/components/include/test/application_manager/mock_application_manager.h +++ b/src/components/include/test/application_manager/mock_application_manager.h @@ -140,6 +140,7 @@ class MockApplicationManager : public application_manager::ApplicationManager { void(const smart_objects::SmartObject& sm_object, const uint32_t connection_key)); MOCK_CONST_METHOD0(is_attenuated_supported, bool()); + MOCK_CONST_METHOD0(IsLowVoltage, bool()); MOCK_CONST_METHOD1(IsAppTypeExistsInFullOrLimited, bool(application_manager::ApplicationConstSharedPtr app)); MOCK_METHOD1(OnApplicationRegistered, @@ -180,7 +181,6 @@ class MockApplicationManager : public application_manager::ApplicationManager { MOCK_CONST_METHOD1(IsAppsQueriedFrom, bool(const connection_handler::DeviceHandle handle)); MOCK_CONST_METHOD0(IsStopping, bool()); - MOCK_METHOD0(IsLowVoltage, bool()); MOCK_METHOD1(RemoveAppFromTTSGlobalPropertiesList, void(const uint32_t app_id)); MOCK_METHOD4( -- cgit v1.2.1 From 890d96271c0159ed4ecfca3bfad4c04af9fd63fb Mon Sep 17 00:00:00 2001 From: ZhdanovP Date: Tue, 24 Jul 2018 19:46:24 +0300 Subject: Add unit tests for resumption during low voltage --- .../test/resumption/resume_ctrl_test.cc | 251 ++++++++++++++++++++- 1 file changed, 249 insertions(+), 2 deletions(-) diff --git a/src/components/application_manager/test/resumption/resume_ctrl_test.cc b/src/components/application_manager/test/resumption/resume_ctrl_test.cc index 54c76fcf94..5bae980e0d 100644 --- a/src/components/application_manager/test/resumption/resume_ctrl_test.cc +++ b/src/components/application_manager/test/resumption/resume_ctrl_test.cc @@ -44,6 +44,7 @@ #include "application_manager/application_manager_impl.h" #include "application_manager/application.h" #include "utils/data_accessor.h" +#include "config_profile/profile.h" #include "application_manager/mock_message_helper.h" #include "application_manager/mock_application_manager.h" @@ -89,7 +90,11 @@ class ResumeCtrlTest : public ::testing::Test { , kDefaultDeferredTestLevel_(eType::INVALID_ENUM) , kNaviLowbandwidthLevel_("LIMITED") , kProjectionLowbandwidthLevel_("NONE") - , kMediaLowbandwidthLevel_("NONE") {} + , kMediaLowbandwidthLevel_("NONE") { + profile::Profile profile_; + profile_.set_config_file_name("smartDeviceLink.ini"); + resumption_delay_before_ign_ = profile_.resumption_delay_before_ign(); + } virtual void SetUp() OVERRIDE { Mock::VerifyAndClearExpectations(&mock_app_mngr_); @@ -153,7 +158,7 @@ class ResumeCtrlTest : public ::testing::Test { NiceMock mock_event_dispatcher_; application_manager_test::MockApplicationManagerSettings mock_application_manager_settings_; - application_manager_test::MockApplicationManager mock_app_mngr_; + NiceMock mock_app_mngr_; std::shared_ptr > mock_app_extension_; MockStateController mock_state_controller_; @@ -172,6 +177,7 @@ class ResumeCtrlTest : public ::testing::Test { const std::string kHash_; const uint32_t kAppResumingTimeout_; const uint32_t kTestTimeStamp_; + uint32_t resumption_delay_before_ign_; std::shared_ptr app_set_lock_ptr_; sync_primitives::Lock app_set_lock_; const mobile_apis::HMILevel::eType kDefaultDeferredTestLevel_; @@ -613,8 +619,12 @@ TEST_F(ResumeCtrlTest, StartAppHmiStateResumption_AppInFull) { mobile_apis::HMILevel::eType restored_test_type = eType::HMI_FULL; uint32_t ign_off_count = 0; smart_objects::SmartObject saved_app; + const uint32_t time_offset = 5; + const uint32_t time_stamp = + time(nullptr) - resumption_delay_before_ign_ + time_offset; saved_app[application_manager::strings::ign_off_count] = ign_off_count; saved_app[application_manager::strings::hmi_level] = restored_test_type; + saved_app[application_manager::strings::time_stamp] = time_stamp; application_manager::CommandsMap command; DataAccessor data_accessor( @@ -661,8 +671,12 @@ TEST_F(ResumeCtrlTest, StartAppHmiStateResumption_AppHasDeferredResumption) { mobile_apis::HMILevel::eType deferred_level = eType::HMI_FULL; uint32_t ign_off_count = 0; smart_objects::SmartObject saved_app; + const uint32_t time_offset = 5; + const uint32_t time_stamp = + time(nullptr) - resumption_delay_before_ign_ + time_offset; saved_app[application_manager::strings::ign_off_count] = ign_off_count; saved_app[application_manager::strings::hmi_level] = restored_test_type; + saved_app[application_manager::strings::time_stamp] = time_stamp; // resume into deferred level instead of restored level EXPECT_CALL(mock_state_controller_, SetRegularState(_, deferred_level)) @@ -693,8 +707,12 @@ TEST_F(ResumeCtrlTest, mobile_apis::HMILevel::eType restored_test_type = eType::HMI_FULL; uint32_t ign_off_count = 0; smart_objects::SmartObject saved_app; + const uint32_t time_offset = 5; + const uint32_t time_stamp = + time(nullptr) - resumption_delay_before_ign_ + time_offset; saved_app[application_manager::strings::ign_off_count] = ign_off_count; saved_app[application_manager::strings::hmi_level] = restored_test_type; + saved_app[application_manager::strings::time_stamp] = time_stamp; EXPECT_CALL(mock_state_controller_, SetRegularState(_, eType::HMI_LIMITED)) .Times(AtLeast(1)); @@ -731,8 +749,12 @@ TEST_F( mobile_apis::HMILevel::eType restored_test_type = eType::HMI_LIMITED; uint32_t ign_off_count = 0; smart_objects::SmartObject saved_app; + const uint32_t time_offset = 5; + const uint32_t time_stamp = + time(nullptr) - resumption_delay_before_ign_ + time_offset; saved_app[application_manager::strings::ign_off_count] = ign_off_count; saved_app[application_manager::strings::hmi_level] = restored_test_type; + saved_app[application_manager::strings::time_stamp] = time_stamp; // in this test, it is expected that the app will resume into LIMITED, which // is the higher level among NONE and LIMITED @@ -869,8 +891,12 @@ TEST_F(ResumeCtrlTest, ApplicationResumptiOnTimer_AppInFull) { mobile_apis::HMILevel::eType restored_test_type = eType::HMI_FULL; const uint32_t ign_off_count = 0u; smart_objects::SmartObject saved_app; + const uint32_t time_offset = 5; + const uint32_t time_stamp = + time(nullptr) - resumption_delay_before_ign_ + time_offset; saved_app[application_manager::strings::ign_off_count] = ign_off_count; saved_app[application_manager::strings::hmi_level] = restored_test_type; + saved_app[application_manager::strings::time_stamp] = time_stamp; MockStateController state_controller; EXPECT_CALL(mock_app_mngr_, state_controller()) @@ -1203,6 +1229,227 @@ TEST_F(ResumeCtrlTest, GetSavedAppHmiLevel_AskedAppFound_INVALID_ENUM) { res_ctrl_->GetSavedAppHmiLevel(kTestPolicyAppId_, kMacAddress_)); } +TEST_F(ResumeCtrlTest, ResumptiLowVoltage_AppInFull_Restored) { + const mobile_apis::HMILevel::eType restored_test_type = eType::HMI_FULL; + const uint32_t time_offset = 5; + const uint32_t time_stamp = + time(nullptr) - resumption_delay_before_ign_ + time_offset; + smart_objects::SmartObject saved_app; + saved_app[application_manager::strings::hmi_level] = restored_test_type; + saved_app[application_manager::strings::time_stamp] = time_stamp; + + application_manager::CommandsMap command; + DataAccessor data_accessor( + command, app_set_lock_ptr_); + + EXPECT_CALL(mock_state_controller_, SetRegularState(_, restored_test_type)) + .Times(AtLeast(1)); + GetInfoFromApp(); + EXPECT_CALL(mock_app_mngr_, GetDefaultHmiLevel(const_app_)) + .WillRepeatedly(Return(kDefaultTestLevel_)); + EXPECT_CALL(*mock_app_, commands_map()).WillRepeatedly(Return(data_accessor)); + ON_CALL(*mock_storage_, + GetSavedApplication(kTestPolicyAppId_, kMacAddress_, _)) + .WillByDefault(DoAll(SetArgReferee<2>(saved_app), Return(true))); + + EXPECT_CALL(*mock_storage_, + RemoveApplicationFromSaved(kTestPolicyAppId_, kMacAddress_)) + .WillOnce(Return(true)); + + ON_CALL(mock_app_mngr_, GetUserConsentForDevice("12345")) + .WillByDefault(Return(policy::kDeviceAllowed)); + + NiceMock app_mngr_settings_; + EXPECT_CALL(mock_app_mngr_, get_settings()) + .WillOnce(ReturnRef(app_mngr_settings_)); + + EXPECT_CALL(app_mngr_settings_, resumption_delay_before_ign()) + .WillOnce(Return(resumption_delay_before_ign_)); + + res_ctrl_->SaveLowVoltageTime(); + res_ctrl_->StartAppHmiStateResumption(mock_app_); +} + +TEST_F(ResumeCtrlTest, ResumptiLowVoltage_AppInFull_NotRestored) { + const mobile_apis::HMILevel::eType restored_test_type = eType::HMI_FULL; + const uint32_t time_offset = 5; + const uint32_t time_stamp = + time(nullptr) - resumption_delay_before_ign_ - time_offset; + smart_objects::SmartObject saved_app; + saved_app[application_manager::strings::hmi_level] = restored_test_type; + saved_app[application_manager::strings::time_stamp] = time_stamp; + + application_manager::CommandsMap command; + DataAccessor data_accessor( + command, app_set_lock_ptr_); + + EXPECT_CALL(mock_app_mngr_, state_controller()).Times(0); + GetInfoFromApp(); + EXPECT_CALL(mock_app_mngr_, GetDefaultHmiLevel(const_app_)) + .WillRepeatedly(Return(kDefaultTestLevel_)); + EXPECT_CALL(*mock_app_, commands_map()).WillRepeatedly(Return(data_accessor)); + ON_CALL(*mock_storage_, + GetSavedApplication(kTestPolicyAppId_, kMacAddress_, _)) + .WillByDefault(DoAll(SetArgReferee<2>(saved_app), Return(true))); + + ON_CALL(mock_app_mngr_, GetUserConsentForDevice("12345")) + .WillByDefault(Return(policy::kDeviceAllowed)); + + NiceMock app_mngr_settings_; + EXPECT_CALL(mock_app_mngr_, get_settings()) + .WillOnce(ReturnRef(app_mngr_settings_)); + + EXPECT_CALL(app_mngr_settings_, resumption_delay_before_ign()) + .WillOnce(Return(resumption_delay_before_ign_)); + + res_ctrl_->SaveLowVoltageTime(); + res_ctrl_->StartAppHmiStateResumption(mock_app_); +} + +TEST_F(ResumeCtrlTest, LowVoltage_AppInFull_Restored2) { + const mobile_apis::HMILevel::eType restored_test_type = eType::HMI_FULL; + const uint32_t time_offset = 5; + const uint32_t time_stamp = + time(nullptr) - resumption_delay_before_ign_ + time_offset; + smart_objects::SmartObject saved_app; + saved_app[application_manager::strings::hmi_level] = restored_test_type; + saved_app[application_manager::strings::time_stamp] = time_stamp; + + application_manager::CommandsMap command; + DataAccessor data_accessor( + command, app_set_lock_ptr_); + + EXPECT_CALL(mock_state_controller_, SetRegularState(_, restored_test_type)) + .Times(AtLeast(1)); + GetInfoFromApp(); + EXPECT_CALL(mock_app_mngr_, GetDefaultHmiLevel(const_app_)) + .WillRepeatedly(Return(kDefaultTestLevel_)); + EXPECT_CALL(*mock_app_, commands_map()).WillRepeatedly(Return(data_accessor)); + ON_CALL(*mock_storage_, + GetSavedApplication(kTestPolicyAppId_, kMacAddress_, _)) + .WillByDefault(DoAll(SetArgReferee<2>(saved_app), Return(true))); + + EXPECT_CALL(*mock_storage_, + RemoveApplicationFromSaved(kTestPolicyAppId_, kMacAddress_)) + .WillOnce(Return(true)); + + ON_CALL(mock_app_mngr_, GetUserConsentForDevice("12345")) + .WillByDefault(Return(policy::kDeviceAllowed)); + + NiceMock app_mngr_settings_; + EXPECT_CALL(mock_app_mngr_, get_settings()) + .WillOnce(ReturnRef(app_mngr_settings_)); + + EXPECT_CALL(app_mngr_settings_, resumption_delay_before_ign()) + .WillOnce(Return(resumption_delay_before_ign_ + time_offset)); + + res_ctrl_->SaveLowVoltageTime(); + res_ctrl_->StartAppHmiStateResumption(mock_app_); +} + +TEST_F(ResumeCtrlTest, ResumptiLowVoltage_AppInBackground_Restored) { + const mobile_apis::HMILevel::eType restored_test_type = eType::HMI_BACKGROUND; + const uint32_t time_offset = 5; + const uint32_t time_stamp = + time(nullptr) - resumption_delay_before_ign_ - time_offset; + smart_objects::SmartObject saved_app; + saved_app[application_manager::strings::hmi_level] = restored_test_type; + saved_app[application_manager::strings::time_stamp] = time_stamp; + + application_manager::CommandsMap command; + DataAccessor data_accessor( + command, app_set_lock_ptr_); + + EXPECT_CALL(mock_app_mngr_, state_controller()).Times(0); + GetInfoFromApp(); + EXPECT_CALL(mock_app_mngr_, GetDefaultHmiLevel(const_app_)) + .WillRepeatedly(Return(kDefaultTestLevel_)); + EXPECT_CALL(*mock_app_, commands_map()).WillRepeatedly(Return(data_accessor)); + ON_CALL(*mock_storage_, + GetSavedApplication(kTestPolicyAppId_, kMacAddress_, _)) + .WillByDefault(DoAll(SetArgReferee<2>(saved_app), Return(true))); + + res_ctrl_->SaveLowVoltageTime(); + res_ctrl_->StartAppHmiStateResumption(mock_app_); +} + +TEST_F(ResumeCtrlTest, ResumptiLowVoltage_AppInLimited_Restored) { + const mobile_apis::HMILevel::eType restored_test_type = eType::HMI_LIMITED; + const uint32_t time_offset = 5; + const uint32_t time_stamp = + time(nullptr) - resumption_delay_before_ign_ + time_offset; + smart_objects::SmartObject saved_app; + saved_app[application_manager::strings::hmi_level] = restored_test_type; + saved_app[application_manager::strings::time_stamp] = time_stamp; + + application_manager::CommandsMap command; + DataAccessor data_accessor( + command, app_set_lock_ptr_); + + EXPECT_CALL(mock_state_controller_, SetRegularState(_, restored_test_type)) + .Times(AtLeast(1)); + GetInfoFromApp(); + EXPECT_CALL(mock_app_mngr_, GetDefaultHmiLevel(const_app_)) + .WillRepeatedly(Return(kDefaultTestLevel_)); + EXPECT_CALL(*mock_app_, commands_map()).WillRepeatedly(Return(data_accessor)); + ON_CALL(*mock_storage_, + GetSavedApplication(kTestPolicyAppId_, kMacAddress_, _)) + .WillByDefault(DoAll(SetArgReferee<2>(saved_app), Return(true))); + + EXPECT_CALL(*mock_storage_, + RemoveApplicationFromSaved(kTestPolicyAppId_, kMacAddress_)) + .WillOnce(Return(true)); + + ON_CALL(mock_app_mngr_, GetUserConsentForDevice("12345")) + .WillByDefault(Return(policy::kDeviceAllowed)); + + NiceMock app_mngr_settings_; + EXPECT_CALL(mock_app_mngr_, get_settings()) + .WillOnce(ReturnRef(app_mngr_settings_)); + + EXPECT_CALL(app_mngr_settings_, resumption_delay_before_ign()) + .WillOnce(Return(resumption_delay_before_ign_ + time_offset)); + + res_ctrl_->SaveLowVoltageTime(); + res_ctrl_->StartAppHmiStateResumption(mock_app_); +} + +TEST_F(ResumeCtrlTest, ResumptiLowVoltage_AppInLimited_NotRestored) { + const mobile_apis::HMILevel::eType restored_test_type = eType::HMI_LIMITED; + const uint32_t time_offset = 5; + const uint32_t time_stamp = + time(nullptr) - resumption_delay_before_ign_ - time_offset; + smart_objects::SmartObject saved_app; + saved_app[application_manager::strings::hmi_level] = restored_test_type; + saved_app[application_manager::strings::time_stamp] = time_stamp; + + application_manager::CommandsMap command; + DataAccessor data_accessor( + command, app_set_lock_ptr_); + + EXPECT_CALL(mock_app_mngr_, state_controller()).Times(0); + GetInfoFromApp(); + EXPECT_CALL(mock_app_mngr_, GetDefaultHmiLevel(const_app_)) + .WillRepeatedly(Return(kDefaultTestLevel_)); + EXPECT_CALL(*mock_app_, commands_map()).WillRepeatedly(Return(data_accessor)); + ON_CALL(*mock_storage_, + GetSavedApplication(kTestPolicyAppId_, kMacAddress_, _)) + .WillByDefault(DoAll(SetArgReferee<2>(saved_app), Return(true))); + + ON_CALL(mock_app_mngr_, GetUserConsentForDevice("12345")) + .WillByDefault(Return(policy::kDeviceAllowed)); + + NiceMock app_mngr_settings_; + EXPECT_CALL(mock_app_mngr_, get_settings()) + .WillOnce(ReturnRef(app_mngr_settings_)); + + EXPECT_CALL(app_mngr_settings_, resumption_delay_before_ign()) + .WillOnce(Return(resumption_delay_before_ign_)); + + res_ctrl_->SaveLowVoltageTime(); + res_ctrl_->StartAppHmiStateResumption(mock_app_); +} + } // namespace resumption_test } // namespace components } // namespace test -- cgit v1.2.1 From d930a5414e13fa5c1b0cfdb6166d69c65540450a Mon Sep 17 00:00:00 2001 From: Andriy Byzhynar Date: Fri, 27 Jul 2018 14:15:40 +0300 Subject: Remove redundant function descriptions from Impl class --- src/appMain/life_cycle_impl.h | 34 ---------------------------------- 1 file changed, 34 deletions(-) diff --git a/src/appMain/life_cycle_impl.h b/src/appMain/life_cycle_impl.h index b898f0c589..5dfc4641ab 100644 --- a/src/appMain/life_cycle_impl.h +++ b/src/appMain/life_cycle_impl.h @@ -74,46 +74,12 @@ class LifeCycleImpl : public LifeCycle { public: explicit LifeCycleImpl(const profile::Profile& profile); - /** - * Creates and starts all system components - * @return true if all components started successfully - * otherwise false. - */ bool StartComponents() OVERRIDE; - - /** - * Initialize MessageBroker component - * @return true if success otherwise false. - */ bool InitMessageSystem() OVERRIDE; - /** - * @brief Main loop - */ void Run() OVERRIDE; - - /** - * Stops all system components - */ void StopComponents() OVERRIDE; - - /** - * Makes appropriate actions when Low Voltage signal received: - * Stops all SDL activities except of waiting of UNIX signals - * from HMI - */ void LowVoltage() OVERRIDE; - - /** - * Makes appropriate actions when Wake Up signal received: - * Restores all SDL activities stopped due to LOW VOLTAGE - * from HMI - */ void WakeUp() OVERRIDE; - - /** - * Makes appropriate actions when Ignition Off signal received: - * Triggers all SDL components stop and deletion - */ void IgnitionOff() OVERRIDE; private: -- cgit v1.2.1 From c6d78822277b599826d1c4eedc7e00ce3e4b8c95 Mon Sep 17 00:00:00 2001 From: ZhdanovP Date: Fri, 27 Jul 2018 16:00:31 +0300 Subject: Fix unit tests names --- .../test/resumption/resume_ctrl_test.cc | 44 +++++++++++++--------- 1 file changed, 27 insertions(+), 17 deletions(-) diff --git a/src/components/application_manager/test/resumption/resume_ctrl_test.cc b/src/components/application_manager/test/resumption/resume_ctrl_test.cc index 5bae980e0d..151860ed15 100644 --- a/src/components/application_manager/test/resumption/resume_ctrl_test.cc +++ b/src/components/application_manager/test/resumption/resume_ctrl_test.cc @@ -1229,7 +1229,9 @@ TEST_F(ResumeCtrlTest, GetSavedAppHmiLevel_AskedAppFound_INVALID_ENUM) { res_ctrl_->GetSavedAppHmiLevel(kTestPolicyAppId_, kMacAddress_)); } -TEST_F(ResumeCtrlTest, ResumptiLowVoltage_AppInFull_Restored) { +TEST_F( + ResumeCtrlTest, + ResumptionLowVoltage_AppInFullUnregisteredWithinTimeFrame_HMILevelRestored) { const mobile_apis::HMILevel::eType restored_test_type = eType::HMI_FULL; const uint32_t time_offset = 5; const uint32_t time_stamp = @@ -1270,11 +1272,13 @@ TEST_F(ResumeCtrlTest, ResumptiLowVoltage_AppInFull_Restored) { res_ctrl_->StartAppHmiStateResumption(mock_app_); } -TEST_F(ResumeCtrlTest, ResumptiLowVoltage_AppInFull_NotRestored) { +TEST_F( + ResumeCtrlTest, + ResumptionLowVoltage_AppInFullUnregisteredOnTheBorderOfTimeFrame_HMILevelRestored) { const mobile_apis::HMILevel::eType restored_test_type = eType::HMI_FULL; const uint32_t time_offset = 5; const uint32_t time_stamp = - time(nullptr) - resumption_delay_before_ign_ - time_offset; + time(nullptr) - resumption_delay_before_ign_ + time_offset; smart_objects::SmartObject saved_app; saved_app[application_manager::strings::hmi_level] = restored_test_type; saved_app[application_manager::strings::time_stamp] = time_stamp; @@ -1283,7 +1287,8 @@ TEST_F(ResumeCtrlTest, ResumptiLowVoltage_AppInFull_NotRestored) { DataAccessor data_accessor( command, app_set_lock_ptr_); - EXPECT_CALL(mock_app_mngr_, state_controller()).Times(0); + EXPECT_CALL(mock_state_controller_, SetRegularState(_, restored_test_type)) + .Times(AtLeast(1)); GetInfoFromApp(); EXPECT_CALL(mock_app_mngr_, GetDefaultHmiLevel(const_app_)) .WillRepeatedly(Return(kDefaultTestLevel_)); @@ -1292,6 +1297,10 @@ TEST_F(ResumeCtrlTest, ResumptiLowVoltage_AppInFull_NotRestored) { GetSavedApplication(kTestPolicyAppId_, kMacAddress_, _)) .WillByDefault(DoAll(SetArgReferee<2>(saved_app), Return(true))); + EXPECT_CALL(*mock_storage_, + RemoveApplicationFromSaved(kTestPolicyAppId_, kMacAddress_)) + .WillOnce(Return(true)); + ON_CALL(mock_app_mngr_, GetUserConsentForDevice("12345")) .WillByDefault(Return(policy::kDeviceAllowed)); @@ -1300,17 +1309,19 @@ TEST_F(ResumeCtrlTest, ResumptiLowVoltage_AppInFull_NotRestored) { .WillOnce(ReturnRef(app_mngr_settings_)); EXPECT_CALL(app_mngr_settings_, resumption_delay_before_ign()) - .WillOnce(Return(resumption_delay_before_ign_)); + .WillOnce(Return(resumption_delay_before_ign_ + time_offset)); res_ctrl_->SaveLowVoltageTime(); res_ctrl_->StartAppHmiStateResumption(mock_app_); } -TEST_F(ResumeCtrlTest, LowVoltage_AppInFull_Restored2) { +TEST_F( + ResumeCtrlTest, + ResumptionLowVoltage_AppInFullUnregisteredBeyondTimeFrame_HMILevelNotRestored) { const mobile_apis::HMILevel::eType restored_test_type = eType::HMI_FULL; const uint32_t time_offset = 5; const uint32_t time_stamp = - time(nullptr) - resumption_delay_before_ign_ + time_offset; + time(nullptr) - resumption_delay_before_ign_ - time_offset; smart_objects::SmartObject saved_app; saved_app[application_manager::strings::hmi_level] = restored_test_type; saved_app[application_manager::strings::time_stamp] = time_stamp; @@ -1319,8 +1330,7 @@ TEST_F(ResumeCtrlTest, LowVoltage_AppInFull_Restored2) { DataAccessor data_accessor( command, app_set_lock_ptr_); - EXPECT_CALL(mock_state_controller_, SetRegularState(_, restored_test_type)) - .Times(AtLeast(1)); + EXPECT_CALL(mock_app_mngr_, state_controller()).Times(0); GetInfoFromApp(); EXPECT_CALL(mock_app_mngr_, GetDefaultHmiLevel(const_app_)) .WillRepeatedly(Return(kDefaultTestLevel_)); @@ -1329,10 +1339,6 @@ TEST_F(ResumeCtrlTest, LowVoltage_AppInFull_Restored2) { GetSavedApplication(kTestPolicyAppId_, kMacAddress_, _)) .WillByDefault(DoAll(SetArgReferee<2>(saved_app), Return(true))); - EXPECT_CALL(*mock_storage_, - RemoveApplicationFromSaved(kTestPolicyAppId_, kMacAddress_)) - .WillOnce(Return(true)); - ON_CALL(mock_app_mngr_, GetUserConsentForDevice("12345")) .WillByDefault(Return(policy::kDeviceAllowed)); @@ -1341,13 +1347,13 @@ TEST_F(ResumeCtrlTest, LowVoltage_AppInFull_Restored2) { .WillOnce(ReturnRef(app_mngr_settings_)); EXPECT_CALL(app_mngr_settings_, resumption_delay_before_ign()) - .WillOnce(Return(resumption_delay_before_ign_ + time_offset)); + .WillOnce(Return(resumption_delay_before_ign_)); res_ctrl_->SaveLowVoltageTime(); res_ctrl_->StartAppHmiStateResumption(mock_app_); } -TEST_F(ResumeCtrlTest, ResumptiLowVoltage_AppInBackground_Restored) { +TEST_F(ResumeCtrlTest, ResumptionLowVoltage_AppInBackground_NotRestored) { const mobile_apis::HMILevel::eType restored_test_type = eType::HMI_BACKGROUND; const uint32_t time_offset = 5; const uint32_t time_stamp = @@ -1373,7 +1379,9 @@ TEST_F(ResumeCtrlTest, ResumptiLowVoltage_AppInBackground_Restored) { res_ctrl_->StartAppHmiStateResumption(mock_app_); } -TEST_F(ResumeCtrlTest, ResumptiLowVoltage_AppInLimited_Restored) { +TEST_F( + ResumeCtrlTest, + ResumptionLowVoltage_AppInLimitedlUnregisteredWithinTimeFrame_HMILevelRestored) { const mobile_apis::HMILevel::eType restored_test_type = eType::HMI_LIMITED; const uint32_t time_offset = 5; const uint32_t time_stamp = @@ -1414,7 +1422,9 @@ TEST_F(ResumeCtrlTest, ResumptiLowVoltage_AppInLimited_Restored) { res_ctrl_->StartAppHmiStateResumption(mock_app_); } -TEST_F(ResumeCtrlTest, ResumptiLowVoltage_AppInLimited_NotRestored) { +TEST_F( + ResumeCtrlTest, + ResumptionLowVoltage_AppInLimitedlUnregisteredBeyondTimeFrame_HMILevelNotRestored) { const mobile_apis::HMILevel::eType restored_test_type = eType::HMI_LIMITED; const uint32_t time_offset = 5; const uint32_t time_stamp = -- cgit v1.2.1 From 79b4ac8e5659afe08cbc5a7e322a7621119664c6 Mon Sep 17 00:00:00 2001 From: Andriy Byzhynar Date: Sat, 28 Jul 2018 20:02:20 +0300 Subject: Simplify resumption logic Removed redundant functions Simplified ingintion cycle data correctness check --- .../resumption/resume_ctrl_impl.h | 10 ----- .../resumption/resumption_data.h | 11 +---- .../resumption/resumption_data_db.h | 22 +--------- .../resumption/resumption_data_json.h | 22 +--------- .../src/resumption/resume_ctrl_impl.cc | 32 ++++++--------- .../src/resumption/resumption_data_db.cc | 15 +++---- .../src/resumption/resumption_data_json.cc | 48 +++++++--------------- .../application_manager/mock_resumption_data.h | 3 +- 8 files changed, 39 insertions(+), 124 deletions(-) diff --git a/src/components/application_manager/include/application_manager/resumption/resume_ctrl_impl.h b/src/components/application_manager/include/application_manager/resumption/resume_ctrl_impl.h index 85e232fe92..c316d11d86 100644 --- a/src/components/application_manager/include/application_manager/resumption/resume_ctrl_impl.h +++ b/src/components/application_manager/include/application_manager/resumption/resume_ctrl_impl.h @@ -335,16 +335,6 @@ class ResumeCtrlImpl : public ResumeCtrl, */ time_t WakeUpTime() const; - /** - * @brief Resets Low Voltage signal timestamp to zero - */ - void ResetLowVoltageTime(); - - /** - * @brief Resets Wake Up signal timestamp to zero - */ - void ResetWakeUpTime(); - /** * @brief restores saved data of application * @param application contains application for which restores data diff --git a/src/components/application_manager/include/application_manager/resumption/resumption_data.h b/src/components/application_manager/include/application_manager/resumption/resumption_data.h index ee866719c8..8d88f3a420 100644 --- a/src/components/application_manager/include/application_manager/resumption/resumption_data.h +++ b/src/components/application_manager/include/application_manager/resumption/resumption_data.h @@ -123,16 +123,9 @@ class ResumptionData { virtual uint32_t GetGlobalIgnOnCounter() const = 0; /** - * @brief Increments global ignition off counter - * by 1 - */ - virtual void IncrementGlobalIgnOffCounter() = 0; - - /** - * @brief Get the global ignition off counter - * @return the global ignition off counter + * @brief Resets global ignition on counter */ - virtual uint32_t GetGlobalIgnOffCounter() const = 0; + virtual void ResetGlobalIgnOnCount() = 0; /** * @brief Retrieves hash ID for the given mobile app ID diff --git a/src/components/application_manager/include/application_manager/resumption/resumption_data_db.h b/src/components/application_manager/include/application_manager/resumption/resumption_data_db.h index 08e9b04e62..007b6064b5 100644 --- a/src/components/application_manager/include/application_manager/resumption/resumption_data_db.h +++ b/src/components/application_manager/include/application_manager/resumption/resumption_data_db.h @@ -110,29 +110,11 @@ class ResumptionDataDB : public ResumptionData { virtual uint32_t GetHMIApplicationID(const std::string& policy_app_id, const std::string& device_id) const; - /** - * @brief Increments global ignition on counter - * by 1 - */ void IncrementGlobalIgnOnCounter() OVERRIDE; - /** - * @brief Get the global ignition on counter - * @return the global ignition on counter - */ - virtual uint32_t GetGlobalIgnOnCounter() const OVERRIDE; + uint32_t GetGlobalIgnOnCounter() const OVERRIDE; - /** - * @brief Increments global ignition off counter - * by 1 - */ - virtual void IncrementGlobalIgnOffCounter() OVERRIDE; - - /** - * @brief Get the global ignition off counter - * @return the global ignition off counter - */ - virtual uint32_t GetGlobalIgnOffCounter() const OVERRIDE; + void ResetGlobalIgnOnCount() OVERRIDE; /** * @brief Increments ignition counter for all registered applications diff --git a/src/components/application_manager/include/application_manager/resumption/resumption_data_json.h b/src/components/application_manager/include/application_manager/resumption/resumption_data_json.h index 1a48ff20d5..5683d4f533 100644 --- a/src/components/application_manager/include/application_manager/resumption/resumption_data_json.h +++ b/src/components/application_manager/include/application_manager/resumption/resumption_data_json.h @@ -145,29 +145,11 @@ class ResumptionDataJson : public ResumptionData { */ virtual uint32_t GetIgnOffTime() const; - /** - * @brief Increments global ignition on counter - * by 1 - */ void IncrementGlobalIgnOnCounter() OVERRIDE; - /** - * @brief Get the global ignition on counter - * @return the global ignition on counter - */ - virtual uint32_t GetGlobalIgnOnCounter() const OVERRIDE; + uint32_t GetGlobalIgnOnCounter() const OVERRIDE; - /** - * @brief Increments global ignition off counter - * by 1 - */ - virtual void IncrementGlobalIgnOffCounter() OVERRIDE; - - /** - * @brief Get the global ignition off counter - * @return the global ignition off counter - */ - virtual uint32_t GetGlobalIgnOffCounter() const OVERRIDE; + void ResetGlobalIgnOnCount() OVERRIDE; /** * @brief Checks if saved data have application diff --git a/src/components/application_manager/src/resumption/resume_ctrl_impl.cc b/src/components/application_manager/src/resumption/resume_ctrl_impl.cc index d52a495d17..80f45d6980 100644 --- a/src/components/application_manager/src/resumption/resume_ctrl_impl.cc +++ b/src/components/application_manager/src/resumption/resume_ctrl_impl.cc @@ -130,6 +130,8 @@ bool ResumeCtrlImpl::Init(resumption::LastState& last_state) { application_manager_.get_settings() .app_resumption_save_persistent_data_timeout(), timer::kPeriodic); + + resumption_storage_->IncrementGlobalIgnOnCounter(); return true; } @@ -335,6 +337,7 @@ void ResumeCtrlImpl::OnIgnitionOff() { LOG4CXX_AUTO_TRACE(logger_); if (!application_manager_.IsLowVoltage()) { resumption_storage_->IncrementIgnOffCount(); + resumption_storage_->ResetGlobalIgnOnCount(); FinalPersistData(); } } @@ -347,28 +350,16 @@ void ResumeCtrlImpl::OnAwake() { } void ResumeCtrlImpl::SaveLowVoltageTime() { - ResetLowVoltageTime(); low_voltage_time_ = time(nullptr); LOG4CXX_DEBUG(logger_, "Low Voltage timestamp : " << low_voltage_time_ << " saved"); } -void ResumeCtrlImpl::ResetLowVoltageTime() { - low_voltage_time_ = 0; - LOG4CXX_DEBUG(logger_, "Resetting Low Voltage timestamp"); -} - void ResumeCtrlImpl::SaveWakeUpTime() { - ResetWakeUpTime(); wake_up_time_ = std::time(nullptr); LOG4CXX_DEBUG(logger_, "Wake Up timestamp : " << wake_up_time_ << " saved"); } -void ResumeCtrlImpl::ResetWakeUpTime() { - wake_up_time_ = 0; - LOG4CXX_DEBUG(logger_, "Resetting Wake Up timestamp"); -} - time_t ResumeCtrlImpl::LowVoltageTime() const { return low_voltage_time_; } @@ -967,15 +958,17 @@ bool ResumeCtrlImpl::CheckIcons(ApplicationSharedPtr application, bool ResumeCtrlImpl::CheckIgnCyclesData() const { LOG4CXX_AUTO_TRACE(logger_); - const uint32_t global_ign_off_count = - resumption_storage_->GetGlobalIgnOffCounter(); const uint32_t global_ign_on_count = resumption_storage_->GetGlobalIgnOnCounter(); - const uint32_t diff = global_ign_on_count - global_ign_off_count; - const bool is_ign_off_record_missed = diff >= 2; - if (is_ign_off_record_missed) { + const uint32_t the_first_ignition = 1; + const bool is_emergency_ign_off_occurred = + global_ign_on_count > the_first_ignition; + // global_ign_on_count is reseting to 0 at ignition off + // global_ign_on_count is incrementing at ignition on + // global_ign_on_count > 1 means that correct ignition off was not present. + if (is_emergency_ign_off_occurred) { LOG4CXX_WARN(logger_, - "Some IGN OFF records missed. Possibly due to Low Voltage"); + "Emergency IGN OFF occurred. Possibly after Low Voltage"); return false; } return true; @@ -987,8 +980,7 @@ bool ResumeCtrlImpl::CheckDelayAfterIgnOn() const { const time_t ign_off_time = GetIgnOffTime(); if (CheckIgnCyclesData() && 0 == ign_off_time) { - LOG4CXX_DEBUG( - logger_, "No IGNITION OFF records found: This is first Ignition cycle"); + LOG4CXX_DEBUG(logger_, "This is first Ignition cycle"); return true; } const time_t curr_time = time(nullptr); diff --git a/src/components/application_manager/src/resumption/resumption_data_db.cc b/src/components/application_manager/src/resumption/resumption_data_db.cc index 90c8a20e83..2dfb230c7e 100644 --- a/src/components/application_manager/src/resumption/resumption_data_db.cc +++ b/src/components/application_manager/src/resumption/resumption_data_db.cc @@ -376,22 +376,20 @@ bool ResumptionDataDB::RemoveApplicationFromSaved( uint32_t ResumptionDataDB::GetIgnOffTime() const { LOG4CXX_AUTO_TRACE(logger_); - return SelectIgnOffTime(); } uint32_t ResumptionDataDB::GetGlobalIgnOnCounter() const { - return 0; -} - -uint32_t ResumptionDataDB::GetGlobalIgnOffCounter() const { - return 0; + // To be implemented + return 1; } -void ResumptionDataDB::IncrementGlobalIgnOffCounter() { +void ResumptionDataDB::IncrementGlobalIgnOnCounter() { + // To be implemented } -void ResumptionDataDB::IncrementGlobalIgnOnCounter() { +void ResumptionDataDB::ResetGlobalIgnOnCount() { + // To be implemented } ssize_t ResumptionDataDB::IsApplicationSaved( @@ -571,7 +569,6 @@ void ResumptionDataDB::SelectDataForLoadResumeData( using namespace app_mngr; using namespace smart_objects; LOG4CXX_AUTO_TRACE(logger_); - utils::dbms::SQLQuery select_data(db()); utils::dbms::SQLQuery count_application(db()); if (!select_data.Prepare(kSelectDataForLoadResumeData) || diff --git a/src/components/application_manager/src/resumption/resumption_data_json.cc b/src/components/application_manager/src/resumption/resumption_data_json.cc index e11f482ad6..98e84cc3a8 100644 --- a/src/components/application_manager/src/resumption/resumption_data_json.cc +++ b/src/components/application_manager/src/resumption/resumption_data_json.cc @@ -149,7 +149,6 @@ void ResumptionDataJson::IncrementIgnOffCount() { using namespace app_mngr; LOG4CXX_AUTO_TRACE(logger_); sync_primitives::AutoLock autolock(resumption_lock_); - IncrementGlobalIgnOffCounter(); Json::Value to_save = Json::arrayValue; for (Json::Value::iterator it = GetSavedApplications().begin(); it != GetSavedApplications().end(); @@ -290,42 +289,14 @@ uint32_t ResumptionDataJson::GetGlobalIgnOnCounter() const { sync_primitives::AutoLock autolock(resumption_lock_); Json::Value& resumption = GetResumptionData(); if (resumption.isMember(strings::global_ign_on_counter)) { - return resumption[strings::global_ign_on_counter].asUInt(); + const uint32_t global_ign_on_counter = + resumption[strings::global_ign_on_counter].asUInt(); + LOG4CXX_DEBUG(logger_, "Global Ign On Counter = " << global_ign_on_counter); + return global_ign_on_counter; } return 1; } -uint32_t ResumptionDataJson::GetGlobalIgnOffCounter() const { - using namespace app_mngr; - LOG4CXX_AUTO_TRACE(logger_); - sync_primitives::AutoLock autolock(resumption_lock_); - Json::Value& resumption = GetResumptionData(); - if (resumption.isMember(strings::global_ign_off_counter)) { - return resumption[strings::global_ign_off_counter].asUInt(); - } - return 0; -} - -void ResumptionDataJson::IncrementGlobalIgnOffCounter() { - using namespace app_mngr; - LOG4CXX_AUTO_TRACE(logger_); - sync_primitives::AutoLock autolock(resumption_lock_); - Json::Value& resumption = GetResumptionData(); - if (resumption.isMember(strings::global_ign_off_counter)) { - const uint32_t global_ign_off_counter = - resumption[strings::global_ign_off_counter].asUInt(); - LOG4CXX_DEBUG(logger_, - "Global IGN OFF counter in resumption data: " - << global_ign_off_counter); - resumption[strings::global_ign_off_counter] = global_ign_off_counter + 1; - LOG4CXX_DEBUG(logger_, - "Global IGN OFF counter new value: " - << resumption[strings::global_ign_off_counter].asUInt()); - } else { - resumption[strings::global_ign_off_counter] = 1; - } -} - void ResumptionDataJson::IncrementGlobalIgnOnCounter() { using namespace app_mngr; LOG4CXX_AUTO_TRACE(logger_); @@ -347,6 +318,16 @@ void ResumptionDataJson::IncrementGlobalIgnOnCounter() { last_state().SaveStateToFileSystem(); } +void ResumptionDataJson::ResetGlobalIgnOnCount() { + using namespace app_mngr; + LOG4CXX_AUTO_TRACE(logger_); + sync_primitives::AutoLock autolock(resumption_lock_); + Json::Value& resumption = GetResumptionData(); + + resumption[strings::global_ign_on_counter] = 0; + LOG4CXX_DEBUG(logger_, "Global IGN ON counter resetting"); +} + ssize_t ResumptionDataJson::IsApplicationSaved( const std::string& policy_app_id, const std::string& device_id) const { LOG4CXX_AUTO_TRACE(logger_); @@ -518,7 +499,6 @@ void ResumptionDataJson::SetLastIgnOffTime(time_t ign_off_time) { bool ResumptionDataJson::Init() { LOG4CXX_AUTO_TRACE(logger_); - IncrementGlobalIgnOnCounter(); return true; } diff --git a/src/components/application_manager/test/include/application_manager/mock_resumption_data.h b/src/components/application_manager/test/include/application_manager/mock_resumption_data.h index a3ac670fa4..38d1944dba 100644 --- a/src/components/application_manager/test/include/application_manager/mock_resumption_data.h +++ b/src/components/application_manager/test/include/application_manager/mock_resumption_data.h @@ -68,8 +68,7 @@ class MockResumptionData : public ::resumption::ResumptionData { MOCK_METHOD0(OnAwake, void()); MOCK_METHOD0(IncrementGlobalIgnOnCounter, void()); MOCK_CONST_METHOD0(GetGlobalIgnOnCounter, uint32_t()); - MOCK_METHOD0(IncrementGlobalIgnOffCounter, void()); - MOCK_CONST_METHOD0(GetGlobalIgnOffCounter, uint32_t()); + MOCK_METHOD0(ResetGlobalIgnOnCount, void()); MOCK_METHOD0(DecrementIgnOffCount, void()); MOCK_CONST_METHOD3(GetSavedApplication, -- cgit v1.2.1 From 6829d454e3c8fa8b42a9c8a7dc824d38f4ad3dd6 Mon Sep 17 00:00:00 2001 From: Andriy Byzhynar Date: Sat, 28 Jul 2018 20:36:10 +0300 Subject: Implement Low Voltage Handling in separate process Implemented Low Voltage functionality handling in separate process in order to have possibility to suspend entire SDL process in case of Low Voltage signal After receipt of WakeUp signal SDL process is beeing waken up and resumes all its activities. --- src/appMain/life_cycle_impl.cc | 2 +- src/appMain/low_voltage_signals_handler.cc | 128 +++++++++------------ src/appMain/low_voltage_signals_handler.h | 23 +--- src/appMain/main.cc | 4 +- src/appMain/test/CMakeLists.txt | 44 ------- .../test/low_voltage_signals_handler_test.cc | 125 -------------------- .../test/commands/hmi/hmi_notifications_test.cc | 4 +- src/components/config_profile/src/profile.cc | 2 +- src/components/utils/include/utils/signals.h | 55 ++++++++- src/components/utils/src/signals_posix.cc | 29 ++++- 10 files changed, 143 insertions(+), 273 deletions(-) delete mode 100644 src/appMain/test/CMakeLists.txt delete mode 100644 src/appMain/test/low_voltage_signals_handler_test.cc diff --git a/src/appMain/life_cycle_impl.cc b/src/appMain/life_cycle_impl.cc index d211771a39..186be3c829 100644 --- a/src/appMain/life_cycle_impl.cc +++ b/src/appMain/life_cycle_impl.cc @@ -237,7 +237,7 @@ void LifeCycleImpl::Run() { LOG4CXX_AUTO_TRACE(logger_); // Register signal handlers and wait sys signals // from OS - if (!utils::WaitTerminationSignals(&sig_handler)) { + if (!utils::Signals::WaitTerminationSignals(&sig_handler)) { LOG4CXX_FATAL(logger_, "Fail to catch system signal!"); } } diff --git a/src/appMain/low_voltage_signals_handler.cc b/src/appMain/low_voltage_signals_handler.cc index b514ac6d55..936d91ba18 100644 --- a/src/appMain/low_voltage_signals_handler.cc +++ b/src/appMain/low_voltage_signals_handler.cc @@ -33,7 +33,13 @@ #include "appMain/low_voltage_signals_handler.h" #include +#include +#include +#include +#include +#include #include "appMain/life_cycle.h" +#include "utils/signals.h" #include "utils/logger.h" #include "utils/typed_enum_print.h" #include "config_profile/profile.h" @@ -44,19 +50,21 @@ CREATE_LOGGERPTR_GLOBAL(logger_, "LowVoltageSignalsHandler") LowVoltageSignalsHandler::LowVoltageSignalsHandler( LifeCycle& life_cycle, const LowVoltageSignalsOffset& offset_data) - : state_(SDLState::kRun) - , notifications_delegate_(new NotificationThreadDelegate(*this)) + : notifications_delegate_(new NotificationThreadDelegate(*this)) , signals_handler_thread_(threads::CreateThread( "LV_SIGNALS_HANDLER_THREAD", notifications_delegate_.get())) , life_cycle_(life_cycle) , SIGLOWVOLTAGE_(offset_data.low_voltage_signal_offset + SIGRTMIN) , SIGWAKEUP_(offset_data.wake_up_signal_offset + SIGRTMIN) - , SIGIGNOFF_(offset_data.ignition_off_signal_offset + SIGRTMIN) { + , SIGIGNOFF_(offset_data.ignition_off_signal_offset + SIGRTMIN) + , cpid_(-1) { + sigemptyset(&lv_mask_); + sigaddset(&lv_mask_, SIGLOWVOLTAGE_); signals_handler_thread_->start(); } -SDLState LowVoltageSignalsHandler::get_current_sdl_state() const { - return state_; +sigset_t LowVoltageSignalsHandler::LowVoltageSignalsMask() const { + return lv_mask_; } int LowVoltageSignalsHandler::low_voltage_signo() const { @@ -72,7 +80,6 @@ int LowVoltageSignalsHandler::ignition_off_signo() const { } void LowVoltageSignalsHandler::Destroy() { - state_ = SDLState::kStop; if (signals_handler_thread_) { signals_handler_thread_->join(); } @@ -85,87 +92,60 @@ LowVoltageSignalsHandler::~LowVoltageSignalsHandler() { } void LowVoltageSignalsHandler::HandleSignal(const int signo) { - using utils::operator<<; - LOG4CXX_DEBUG(logger_, "Received Signal: " << signo); - LOG4CXX_DEBUG(logger_, "Current state is : " << get_current_sdl_state()); + if (SIGLOWVOLTAGE_ == signo) { + LOG4CXX_DEBUG(logger_, "Received LOW_VOLTAGE signal"); - auto handle_run_state = [this, signo]() { + life_cycle_.LowVoltage(); + cpid_ = utils::Signals::Fork(); - if (SIGLOWVOLTAGE_ == signo) { - LOG4CXX_DEBUG(logger_, "Received LOW_VOLTAGE signal"); - state_ = SDLState::kSleep; - life_cycle_.LowVoltage(); - return; + if (0 > cpid_) { + LOG4CXX_FATAL(logger_, + "Error due fork() call. Error: " << strerror(errno)); + utils::Signals::ExitProcess(EXIT_FAILURE); } - if (SIGIGNOFF_ == signo) { - LOG4CXX_DEBUG(logger_, - "Received IGNITION_OFF signal. But SDL is in active state"); - // Do nothing - return; - } - - if (SIGWAKEUP_ == signo) { - LOG4CXX_DEBUG(logger_, - "Received WAKE_UP signal. But SDL is in active state"); - // Do nothing - return; - } - LOG4CXX_DEBUG(logger_, "Received UNKNOWN signal"); - }; - - auto handle_sleep_state = [this, signo]() { - - if (SIGWAKEUP_ == signo) { - LOG4CXX_DEBUG(logger_, "Received WAKE UP signal"); - state_ = SDLState::kRun; + if (0 != cpid_) { + // In Parent process + LOG4CXX_DEBUG(logger_, "Child PID: " << cpid_); + utils::Signals::WaitPid(cpid_, nullptr, 0); + LOG4CXX_DEBUG(logger_, "Child process: " << cpid_ << " is stopped"); life_cycle_.WakeUp(); - return; - } - - if (SIGIGNOFF_ == signo) { - LOG4CXX_DEBUG(logger_, "Received IGNITION_OFF signal"); - state_ = SDLState::kStop; - life_cycle_.IgnitionOff(); - return; + } else { + // In Child process + sigset_t signal_set; + sigfillset(&signal_set); + pthread_sigmask(SIG_BLOCK, &signal_set, nullptr); + sigemptyset(&lv_mask_); + sigaddset(&lv_mask_, SIGWAKEUP_); + sigaddset(&lv_mask_, SIGIGNOFF_); + std::cout << "Stopping parent process: " << getppid() << std::endl; + utils::Signals::SendSignal(SIGSTOP, getppid()); + std::cout << "SIGSTOP signal sent to " << getppid() << std::endl; } + return; + } - if (SIGLOWVOLTAGE_ == signo) { - LOG4CXX_DEBUG( - logger_, - "Received LOW VOLTAGE signal. But SDL is already in sleep state"); - // Do nothing - return; - } - LOG4CXX_DEBUG(logger_, "Received UNKNOWN signal"); - }; - - switch (state_) { - case SDLState::kRun: - handle_run_state(); - break; - case SDLState::kSleep: - handle_sleep_state(); - break; - case SDLState::kStop: /* nothing to do here */ - LOG4CXX_DEBUG(logger_, "SDL is in stopping state"); - break; + if (SIGWAKEUP_ == signo) { + std::cout << "Received WAKE UP signal" << std::endl; + std::cout << "Waking Up parent process: " << getppid() << std::endl; + utils::Signals::SendSignal(SIGCONT, getppid()); + std::cout << "Stopping child process: " << getpid() << std::endl; + utils::Signals::ExitProcess(0); } -} -bool LowVoltageSignalsHandler::IsActive() const { - return SDLState::kStop != state_; + if (SIGIGNOFF_ == signo) { + std::cout << "Received IGNITION_OFF signal" << std::endl; + std::cout << "Stopping all SDL processes..." << std::endl; + utils::Signals::SendSignal(SIGKILL, getppid()); + utils::Signals::ExitProcess(0); + } } void NotificationThreadDelegate::threadMain() { - sigset_t lv_mask; - sigemptyset(&lv_mask); - sigaddset(&lv_mask, low_voltage_signals_handler_.low_voltage_signo()); - sigaddset(&lv_mask, low_voltage_signals_handler_.wake_up_signo()); - sigaddset(&lv_mask, low_voltage_signals_handler_.ignition_off_signo()); - - while (low_voltage_signals_handler_.IsActive()) { + while (true) { int signo = 0; + const sigset_t lv_mask = + low_voltage_signals_handler_.LowVoltageSignalsMask(); const int err = sigwait(&lv_mask, &signo); if (0 != err) { LOG4CXX_ERROR( diff --git a/src/appMain/low_voltage_signals_handler.h b/src/appMain/low_voltage_signals_handler.h index 4b2902659e..8c139c6836 100644 --- a/src/appMain/low_voltage_signals_handler.h +++ b/src/appMain/low_voltage_signals_handler.h @@ -49,14 +49,6 @@ typedef struct LowVoltageSignalsOffset { class LifeCycle; class NotificationThreadDelegate; -/** - * @brief The SDLState enum defines current Smartdevicelink app state - * which can be changed due to received UNIX RT signals dedicated for - * Low Voltage functionality handling - * e.g. LowVoltage, WakeUp, IgnitionOff signals - */ -enum class SDLState { kRun, kSleep, kStop }; - /** * @brief Class which handles real-time POSIX signals * dedicated for LOW VOLTAGE functionality @@ -74,19 +66,15 @@ class LowVoltageSignalsHandler { const LowVoltageSignalsOffset& offset_data); /** * @brief Handles RT signals related to Low Voltage functionality + * @param signal number to handle */ void HandleSignal(const int signo); /** - * @brief Checks if SDL is in active state - * therefore not yet in sleep state due to Low Voltage event - */ - bool IsActive() const; - - /** - * @brief Returns current LOW VOLTAGE SDL state + * @brief Returns signals mask required for handling + * LOW VOLTAGE functionality */ - SDLState get_current_sdl_state() const; + sigset_t LowVoltageSignalsMask() const; /** * @brief Returns LOW VOLTAGE signal number @@ -114,13 +102,14 @@ class LowVoltageSignalsHandler { * Invoked from destructor */ void Destroy(); - SDLState state_; std::unique_ptr notifications_delegate_; threads::Thread* signals_handler_thread_; LifeCycle& life_cycle_; int SIGLOWVOLTAGE_; int SIGWAKEUP_; int SIGIGNOFF_; + pid_t cpid_; + sigset_t lv_mask_; }; class NotificationThreadDelegate : public threads::ThreadDelegate { diff --git a/src/appMain/main.cc b/src/appMain/main.cc index d1f0594daf..752cfb7bb9 100644 --- a/src/appMain/main.cc +++ b/src/appMain/main.cc @@ -96,7 +96,7 @@ bool InitHmi(std::string hmi_link) { */ int32_t main(int32_t argc, char** argv) { // Unsubscribe once for all threads - if (!utils::UnsubscribeFromTermination()) { + if (!utils::Signals::UnsubscribeFromTermination()) { // Can't use internal logger here exit(EXIT_FAILURE); } @@ -124,7 +124,7 @@ int32_t main(int32_t argc, char** argv) { // except specific thread dedicated for // Low Voltage signals handling // Thread will be created later - if (!utils::UnsubscribeFromLowVoltageSignals(signals_offset)) { + if (!utils::Signals::UnsubscribeFromLowVoltageSignals(signals_offset)) { // Can't use internal logger here exit(EXIT_FAILURE); } diff --git a/src/appMain/test/CMakeLists.txt b/src/appMain/test/CMakeLists.txt deleted file mode 100644 index c90cad203b..0000000000 --- a/src/appMain/test/CMakeLists.txt +++ /dev/null @@ -1,44 +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. - -include_directories ( - ${GMOCK_INCLUDE_DIRECTORY} -) - -set(testSources - $ - ${CMAKE_SOURCE_DIR}/src/appMain/test/low_voltage_signals_handler_test.cc -) - -set(LIBRARIES - gmock -) - -create_test(low_voltage_signals_handler_test "${testSources}" "${LIBRARIES}") diff --git a/src/appMain/test/low_voltage_signals_handler_test.cc b/src/appMain/test/low_voltage_signals_handler_test.cc deleted file mode 100644 index c6be92e558..0000000000 --- a/src/appMain/test/low_voltage_signals_handler_test.cc +++ /dev/null @@ -1,125 +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. -*/ - -#include "appMain/low_voltage_signals_handler.h" - -#include -#include "gtest/gtest.h" -#include "appMain/test/mock_life_cycle.h" -#include "config_profile/profile.h" -#include "utils/macro.h" - -namespace test { - -class LowVoltageSignalsHandlerTest : public ::testing::Test { - protected: - void SetUp() OVERRIDE { - profile_.set_config_file_name("smartDeviceLink.ini"); - signals_offset_ = {profile_.low_voltage_signal_offset(), - profile_.wake_up_signal_offset(), - profile_.ignition_off_signal_offset()}; - - low_voltage_signals_handler_ = - std::unique_ptr( - new main_namespace::LowVoltageSignalsHandler(mock_life_cycle_, - signals_offset_)); - } - - profile::Profile profile_; - main_namespace::LowVoltageSignalsOffset signals_offset_; - std::unique_ptr - low_voltage_signals_handler_; - main_namespace::MockLifeCycle mock_life_cycle_; -}; - -TEST_F(LowVoltageSignalsHandlerTest, - LowVoltageSignalReceived_ExpectLifeCycleLowVoltageCall) { - // Check that initial SDL state is running - EXPECT_EQ(main_namespace::SDLState::kRun, - low_voltage_signals_handler_->get_current_sdl_state()); - // Set expectation after LOW VOLTAGE signal - EXPECT_CALL(mock_life_cycle_, LowVoltage()); - const int low_voltage_signo = - low_voltage_signals_handler_->low_voltage_signo(); - // Emulate LOW VOLTAGE signal receipt and handling - low_voltage_signals_handler_->HandleSignal(low_voltage_signo); - // Check that SDL is in sleep state after LOW VOLTAGE - EXPECT_EQ(main_namespace::SDLState::kSleep, - low_voltage_signals_handler_->get_current_sdl_state()); -} - -TEST_F(LowVoltageSignalsHandlerTest, - WakeUpSignalReceived_ExpectLifeCycleWakeUpCall) { - // Check that initial SDL state is running - EXPECT_EQ(main_namespace::SDLState::kRun, - low_voltage_signals_handler_->get_current_sdl_state()); - EXPECT_CALL(mock_life_cycle_, LowVoltage()); - const int low_voltage_signo = - low_voltage_signals_handler_->low_voltage_signo(); - // Emulate LOW VOLTAGE signals receipt and handling - low_voltage_signals_handler_->HandleSignal(low_voltage_signo); - // Check that SDL is in sleep state after LOW VOLTAGE - EXPECT_EQ(main_namespace::SDLState::kSleep, - low_voltage_signals_handler_->get_current_sdl_state()); - EXPECT_CALL(mock_life_cycle_, WakeUp()); - const int wake_up_signo = low_voltage_signals_handler_->wake_up_signo(); - // Emulate WAKE UP signal receipt and handling - low_voltage_signals_handler_->HandleSignal(wake_up_signo); - // Check that SDL is in running state after WAKE UP - EXPECT_EQ(main_namespace::SDLState::kRun, - low_voltage_signals_handler_->get_current_sdl_state()); -} - -TEST_F(LowVoltageSignalsHandlerTest, - IgnitionOffSignalReceived_ExpectLifeCycleIgnitionOffCall) { - // Check that initial SDL state is running - EXPECT_EQ(main_namespace::SDLState::kRun, - low_voltage_signals_handler_->get_current_sdl_state()); - EXPECT_CALL(mock_life_cycle_, LowVoltage()); - const int low_voltage_signo = - low_voltage_signals_handler_->low_voltage_signo(); - // Emulate LOW VOLTAGE signals receipt and handling - low_voltage_signals_handler_->HandleSignal(low_voltage_signo); - // Check that SDL is in sleep state after LOW VOLTAGE - EXPECT_EQ(main_namespace::SDLState::kSleep, - low_voltage_signals_handler_->get_current_sdl_state()); - EXPECT_CALL(mock_life_cycle_, IgnitionOff()); - const int ignition_off_signo = - low_voltage_signals_handler_->ignition_off_signo(); - - // Emulate IGNITION OFF signal receipt and handling - low_voltage_signals_handler_->HandleSignal(ignition_off_signo); - // Check that SDL is in stopped state after IGNITION OFF - EXPECT_EQ(main_namespace::SDLState::kStop, - low_voltage_signals_handler_->get_current_sdl_state()); -} -} // namespace test 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 dd51078614..fe82b16f3f 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 @@ -872,7 +872,7 @@ TEST_F(HMICommandsNotificationsTest, SubscribeForSignal(); command->Run(); - utils::WaitTerminationSignals(sig_handler); + utils::Signals::WaitTerminationSignals(sig_handler); EXPECT_EQ(am::mobile_api::AppInterfaceUnregisteredReason::IGNITION_OFF, mob_reason); @@ -914,7 +914,7 @@ TEST_F(HMICommandsNotificationsTest, SubscribeForSignal(); command->Run(); - utils::WaitTerminationSignals(sig_handler); + utils::Signals::WaitTerminationSignals(sig_handler); #endif } } diff --git a/src/components/config_profile/src/profile.cc b/src/components/config_profile/src/profile.cc index d869d6b65e..3db4dda816 100644 --- a/src/components/config_profile/src/profile.cc +++ b/src/components/config_profile/src/profile.cc @@ -2169,7 +2169,7 @@ void Profile::UpdateValues() { LOG_UPDATED_VALUE( ignition_off_signal_offset_, kIgnitionOffSignalOffsetKey, kMainSection); - ReadBoolValue(&multiple_transports_enabled_, + ReadBoolValue(&multiple_transports_enabled_, kDefaultMultipleTransportsEnabled, kMultipleTransportsSection, kMultipleTransportsEnabledKey); diff --git a/src/components/utils/include/utils/signals.h b/src/components/utils/include/utils/signals.h index 4efdaaa4e8..bda83f315f 100644 --- a/src/components/utils/include/utils/signals.h +++ b/src/components/utils/include/utils/signals.h @@ -42,10 +42,57 @@ typedef void (*sighandler_t)(int); namespace utils { -bool UnsubscribeFromTermination(); -bool WaitTerminationSignals(sighandler_t sig_handler); -bool UnsubscribeFromLowVoltageSignals( - const main_namespace::LowVoltageSignalsOffset& offset_data); +class Signals { + public: + /** + * @brief Unsubscribe thread from termination signals SIGINT and SIGTERM + * @return True if thread unsubscribed successfuly, otherwise false + */ + static bool UnsubscribeFromTermination(); + + /** + * @brief Triggers thread to wait for termination signals SIGINT and SIGTERM + * @param sig_handler - handler to work with signals specidied above + * @return True if handler handles signals successfuly, otherwise false + */ + static bool WaitTerminationSignals(sighandler_t sig_handler); + + /** + * @brief Unsubscribe thread from low voltage signals + * SIGLOWVOLTAGE, SIGWAKEUP and SIGIGNOFF + * @return True if thread unsubscribed successfuly, otherwise false + */ + static bool UnsubscribeFromLowVoltageSignals( + const main_namespace::LowVoltageSignalsOffset& offset_data); + + /** + * @brief Sends signal to specified process + * @param signal to send + * @param destination process signal to be sent to + */ + static void SendSignal(const int signo, const pid_t pid); + + /** + * @brief Creates child process + * @return created process id or -1 in case of error + */ + static pid_t Fork(); + + /** + * @brief Wait for child process to be terminated + * @param cpid - process to wait for termination + * @param status store status information in the int to which it points + * @param options - options for exit form function + * detailed options can be found here: https://linux.die.net/man/2/waitpid + */ + static void WaitPid(pid_t cpid, int* status, int options); + + /** + * @brief Exits for process + * @param status - exit status code + */ + static void ExitProcess(const int status); +}; } // namespace utils diff --git a/src/components/utils/src/signals_posix.cc b/src/components/utils/src/signals_posix.cc index dd569a96d6..e13dc04f40 100644 --- a/src/components/utils/src/signals_posix.cc +++ b/src/components/utils/src/signals_posix.cc @@ -29,13 +29,16 @@ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ +#include #include #include #include +#include #include "utils/signals.h" -bool utils::UnsubscribeFromTermination() { +namespace utils { +bool Signals::UnsubscribeFromTermination() { // Disable some system signals receiving in thread // by blocking those signals // (system signals processes only in the main thread) @@ -51,7 +54,7 @@ bool utils::UnsubscribeFromTermination() { return !pthread_sigmask(SIG_BLOCK, &signal_set, NULL); } -bool utils::UnsubscribeFromLowVoltageSignals( +bool Signals::UnsubscribeFromLowVoltageSignals( const main_namespace::LowVoltageSignalsOffset& offset_data) { // Disable Low Voltage signals in main thread // due to all further threads will inherit signals mask @@ -68,6 +71,25 @@ bool utils::UnsubscribeFromLowVoltageSignals( return !pthread_sigmask(SIG_BLOCK, &signal_set, nullptr); } +void Signals::SendSignal(const int signo, const pid_t pid) { + if (kill(pid, signo) == -1) { + std::cerr << "Error sending signal: " << strsignal(signo) << " to " << pid + << " .Error: " << strerror(errno) << std::endl; + } +} + +pid_t Signals::Fork() { + return fork(); +} + +void Signals::ExitProcess(const int status) { + exit(status); +} + +void Signals::WaitPid(pid_t cpid, int* status, int options) { + waitpid(cpid, status, options); +} + namespace { bool CatchSIGSEGV(sighandler_t handler) { struct sigaction act; @@ -80,7 +102,7 @@ bool CatchSIGSEGV(sighandler_t handler) { } } // namespace -bool utils::WaitTerminationSignals(sighandler_t sig_handler) { +bool Signals::WaitTerminationSignals(sighandler_t sig_handler) { sigset_t signal_set; int sig = -1; @@ -98,3 +120,4 @@ bool utils::WaitTerminationSignals(sighandler_t sig_handler) { } return false; } +} // namespace utils -- cgit v1.2.1 From 1b490070d28e94a008bfa69eeba2f4c60398a296 Mon Sep 17 00:00:00 2001 From: Andriy Byzhynar Date: Mon, 30 Jul 2018 13:47:23 +0300 Subject: Add new unit tests for Low Voltage Signals Handler --- src/appMain/test/CMakeLists.txt | 46 +++++++ .../test/low_voltage_signals_handler_test.cc | 138 +++++++++++++++++++++ .../utils/test/include/utils/mock_signals_posix.h | 59 +++++++++ src/components/utils/test/mock_signals_posix.cc | 76 ++++++++++++ 4 files changed, 319 insertions(+) create mode 100644 src/appMain/test/CMakeLists.txt create mode 100644 src/appMain/test/low_voltage_signals_handler_test.cc create mode 100644 src/components/utils/test/include/utils/mock_signals_posix.h create mode 100644 src/components/utils/test/mock_signals_posix.cc diff --git a/src/appMain/test/CMakeLists.txt b/src/appMain/test/CMakeLists.txt new file mode 100644 index 0000000000..057e1e9869 --- /dev/null +++ b/src/appMain/test/CMakeLists.txt @@ -0,0 +1,46 @@ +# 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. + +include_directories ( + ${GMOCK_INCLUDE_DIRECTORY} + ${COMPONENTS_DIR}/utils/test/include +) + +set(testSources + $ + ${CMAKE_SOURCE_DIR}/src/appMain/test/low_voltage_signals_handler_test.cc + ${COMPONENTS_DIR}/utils/test/mock_signals_posix.cc +) + +set(LIBRARIES + gmock +) + +create_test(low_voltage_signals_handler_test "${testSources}" "${LIBRARIES}") diff --git a/src/appMain/test/low_voltage_signals_handler_test.cc b/src/appMain/test/low_voltage_signals_handler_test.cc new file mode 100644 index 0000000000..14210df71d --- /dev/null +++ b/src/appMain/test/low_voltage_signals_handler_test.cc @@ -0,0 +1,138 @@ +/* +* 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. +*/ + +#include "appMain/low_voltage_signals_handler.h" + +#include +#include "gtest/gtest.h" +#include "appMain/test/mock_life_cycle.h" +#include "utils/mock_signals_posix.h" +#include "config_profile/profile.h" +#include "utils/macro.h" + +namespace test { + +using ::testing::_; +using ::testing::Return; +using ::testing::InSequence; + +class LowVoltageSignalsHandlerTest : public ::testing::Test { + protected: + LowVoltageSignalsHandlerTest() + : mock_life_cycle_(std::make_shared()) + , mock_signals_posix_(*utils::MockSignalsPosix::signals_posix_mock()) {} + + void SetUp() OVERRIDE { + profile_.set_config_file_name("smartDeviceLink.ini"); + signals_offset_ = {profile_.low_voltage_signal_offset(), + profile_.wake_up_signal_offset(), + profile_.ignition_off_signal_offset()}; + + low_voltage_signals_handler_ = + std::unique_ptr( + new main_namespace::LowVoltageSignalsHandler( + *mock_life_cycle_.get(), signals_offset_)); + } + + profile::Profile profile_; + main_namespace::LowVoltageSignalsOffset signals_offset_; + std::unique_ptr + low_voltage_signals_handler_; + std::shared_ptr mock_life_cycle_; + utils::MockSignalsPosix& mock_signals_posix_; +}; + +TEST_F( + LowVoltageSignalsHandlerTest, + LowVoltageSignalReceived_CheckParentProcessBehavior_ExpectChildCreationAndtLowVoltageCall) { + // To guarantee strict call orders + InSequence guarantees_calls_sequence; + // Set expectation after LOW VOLTAGE signal + EXPECT_CALL(*mock_life_cycle_, LowVoltage()); + // Expect child process creation + const pid_t cpid = 111; + EXPECT_CALL(mock_signals_posix_, Fork()).WillOnce(Return(cpid)); + // Expect parent process sleep + EXPECT_CALL(mock_signals_posix_, WaitPid(_, nullptr, 0)); + // Expect parent process wakes up + EXPECT_CALL(*mock_life_cycle_, WakeUp()); + const int low_voltage_signo = + low_voltage_signals_handler_->low_voltage_signo(); + // Emulate LOW VOLTAGE signal receipt and handling + low_voltage_signals_handler_->HandleSignal(low_voltage_signo); +} + +TEST_F( + LowVoltageSignalsHandlerTest, + LowVoltageSignalReceived_CheckChildProcessBehavior_ExpectChildSendsStopToParentProcess) { + // To guarantee strict call orders + InSequence guarantees_calls_sequence; + // Set expectation after LOW VOLTAGE signal + EXPECT_CALL(*mock_life_cycle_, LowVoltage()); + // Expect child process creation + const pid_t cpid = 0; + EXPECT_CALL(mock_signals_posix_, Fork()).WillOnce(Return(cpid)); + // Expect SIGCONT signal to be sent to parent process + EXPECT_CALL(mock_signals_posix_, SendSignal(SIGSTOP, _)); + const int low_voltage_signo = + low_voltage_signals_handler_->low_voltage_signo(); + // Emulate LOW VOLTAGE signal receipt and handling + low_voltage_signals_handler_->HandleSignal(low_voltage_signo); +} + +TEST_F(LowVoltageSignalsHandlerTest, + WakeUpSignalReceived_ExpectParentProcessWakeUpAndChildProcessExit) { + // To guarantee strict call orders + InSequence guarantees_calls_sequence; + // Expect SIGCONT signal to be sent to parent process + EXPECT_CALL(mock_signals_posix_, SendSignal(SIGCONT, _)); + // Expect child process exit + EXPECT_CALL(mock_signals_posix_, ExitProcess(0)); + const int wake_up_signo = low_voltage_signals_handler_->wake_up_signo(); + // Emulate WAKE UP signal receipt and handling + low_voltage_signals_handler_->HandleSignal(wake_up_signo); +} + +TEST_F(LowVoltageSignalsHandlerTest, + IgnitionOffSignalReceived_ExpectAllProcessesStopped) { + // To guarantee strict call orders + InSequence guarantees_calls_sequence; + // Expect SIGKILL signal to be sent to parent process + EXPECT_CALL(mock_signals_posix_, SendSignal(SIGKILL, _)); + // Expect child process exit + EXPECT_CALL(mock_signals_posix_, ExitProcess(0)); + const int ign_off_signo = low_voltage_signals_handler_->ignition_off_signo(); + // Emulate IGN OFF signal receipt and handling + low_voltage_signals_handler_->HandleSignal(ign_off_signo); +} + +} // namespace test diff --git a/src/components/utils/test/include/utils/mock_signals_posix.h b/src/components/utils/test/include/utils/mock_signals_posix.h new file mode 100644 index 0000000000..1aad2d5873 --- /dev/null +++ b/src/components/utils/test/include/utils/mock_signals_posix.h @@ -0,0 +1,59 @@ +/* + * 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_UTILS_TEST_INCLUDE_UTILS_MOCK_SIGNALS_POSIX_H_ +#define SRC_COMPONENTS_UTILS_TEST_INCLUDE_UTILS_MOCK_SIGNALS_POSIX_H_ + +#include "gmock/gmock.h" +#include "utils/signals.h" +#include +#include "appMain/low_voltage_signals_handler.h" + +namespace utils { + +class MockSignalsPosix { + public: + MOCK_METHOD0(UnsubscribeFromTermination, bool()); + MOCK_METHOD1(WaitTerminationSignals, bool(sighandler_t sig_handler)); + MOCK_METHOD1( + UnsubscribeFromLowVoltageSignals, + bool(const main_namespace::LowVoltageSignalsOffset& offset_data)); + MOCK_METHOD2(SendSignal, void(const int signo, const pid_t pid)); + MOCK_METHOD0(Fork, pid_t()); + MOCK_METHOD1(ExitProcess, void(const int status)); + MOCK_METHOD3(WaitPid, void(pid_t cpid, int* status, int options)); + + static MockSignalsPosix* signals_posix_mock(); +}; + +} // namespace utils +#endif // SRC_COMPONENTS_UTILS_TEST_INCLUDE_UTILS_MOCK_SIGNALS_POSIX_H_ diff --git a/src/components/utils/test/mock_signals_posix.cc b/src/components/utils/test/mock_signals_posix.cc new file mode 100644 index 0000000000..47531b4a9f --- /dev/null +++ b/src/components/utils/test/mock_signals_posix.cc @@ -0,0 +1,76 @@ +/* + * 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. + */ + +#include "gtest/gtest.h" +#include "gmock/gmock.h" +#include "utils/mock_signals_posix.h" +#include "utils/signals.h" + +namespace utils { + +bool Signals::UnsubscribeFromTermination() { + return MockSignalsPosix::signals_posix_mock()->UnsubscribeFromTermination(); +} + +bool Signals::WaitTerminationSignals(sighandler_t sig_handler) { + return MockSignalsPosix::signals_posix_mock()->WaitTerminationSignals( + sig_handler); +} + +bool Signals::UnsubscribeFromLowVoltageSignals( + const main_namespace::LowVoltageSignalsOffset& offset_data) { + return MockSignalsPosix::signals_posix_mock() + ->UnsubscribeFromLowVoltageSignals(offset_data); +} + +void Signals::SendSignal(const int signo, const pid_t pid) { + MockSignalsPosix::signals_posix_mock()->SendSignal(signo, pid); +} + +void Signals::ExitProcess(const int status) { + MockSignalsPosix::signals_posix_mock()->ExitProcess(status); +} + +void Signals::WaitPid(pid_t cpid, int* status, int options) { + MockSignalsPosix::signals_posix_mock()->WaitPid(cpid, status, options); +} + +pid_t Signals::Fork() { + return MockSignalsPosix::signals_posix_mock()->Fork(); +} + +MockSignalsPosix* MockSignalsPosix::signals_posix_mock() { + static ::testing::NiceMock signals_posix_mock; + return &signals_posix_mock; +} + +} // namespace utils -- cgit v1.2.1 From e8d9e67884c54086cc6a407d333ee718166e63b3 Mon Sep 17 00:00:00 2001 From: ZhdanovP Date: Mon, 30 Jul 2018 15:18:45 +0300 Subject: Add implementation of resumption DB for low voltage --- .../resumption/resumption_sql_queries.h | 5 +- .../src/resumption/resumption_data_db.cc | 82 +++++++++++++++------- .../src/resumption/resumption_sql_queries.cc | 18 ++++- 3 files changed, 76 insertions(+), 29 deletions(-) diff --git a/src/components/application_manager/include/application_manager/resumption/resumption_sql_queries.h b/src/components/application_manager/include/application_manager/resumption/resumption_sql_queries.h index 33d62740f7..eee7650697 100644 --- a/src/components/application_manager/include/application_manager/resumption/resumption_sql_queries.h +++ b/src/components/application_manager/include/application_manager/resumption/resumption_sql_queries.h @@ -57,7 +57,10 @@ extern const std::string kUpdateIgnOffCount; extern const std::string kCountApplicationsIgnOff; extern const std::string kSelectApplicationsIgnOffCount; extern const std::string kUpdateSuspendData; -extern const std::string KUpdateLastIgnOffTime; +extern const std::string kUpdateLastIgnOffTime; +extern const std::string kUpdateGlobalIgnOnCount; +extern const std::string kResetGlobalIgnOnCount; +extern const std::string kSelectGlobalIgnOnCounter; extern const std::string kDeleteFile; extern const std::string kDeleteApplicationFilesArray; extern const std::string kDeleteSubMenu; diff --git a/src/components/application_manager/src/resumption/resumption_data_db.cc b/src/components/application_manager/src/resumption/resumption_data_db.cc index 2dfb230c7e..755b209314 100644 --- a/src/components/application_manager/src/resumption/resumption_data_db.cc +++ b/src/components/application_manager/src/resumption/resumption_data_db.cc @@ -163,11 +163,10 @@ void ResumptionDataDB::SaveApplication( } if (application->is_application_data_changed()) { - if (application_exist) { - if (!DeleteSavedApplication(policy_app_id, device_mac)) { - LOG4CXX_ERROR(logger_, "Deleting of application data is not finished"); - return; - } + if (application_exist && + !DeleteSavedApplication(policy_app_id, device_mac)) { + LOG4CXX_ERROR(logger_, "Deleting of application data is not finished"); + return; } if (!SaveApplicationToDB(application, policy_app_id, device_mac)) { @@ -176,23 +175,15 @@ void ResumptionDataDB::SaveApplication( } LOG4CXX_INFO(logger_, "All data from application were saved successfully"); application->set_is_application_data_changed(false); - } else { - if (application_exist) { - if (!UpdateApplicationData(application, policy_app_id, device_mac)) { - LOG4CXX_ERROR(logger_, "Updating application data is failed"); - return; - } - LOG4CXX_INFO(logger_, "Application data were updated successfully"); - } else { - if (Compare(application->hmi_level(), - HMILevel::HMI_FULL, - HMILevel::HMI_LIMITED)) { - if (!InsertApplicationData(application, policy_app_id, device_mac)) { - LOG4CXX_ERROR(logger_, "Saving data of application is failed"); - return; - } - } + } else if (application_exist) { + if (!UpdateApplicationData(application, policy_app_id, device_mac)) { + LOG4CXX_ERROR(logger_, "Updating application data is failed"); + return; } + LOG4CXX_INFO(logger_, "Application data were updated successfully"); + } else if (!InsertApplicationData(application, policy_app_id, device_mac)) { + LOG4CXX_ERROR(logger_, "Saving data of application is failed"); + return; } WriteDb(); } @@ -240,7 +231,7 @@ void ResumptionDataDB::IncrementIgnOffCount() { } } - if (query_update_last_ign_off_time.Prepare(KUpdateLastIgnOffTime)) { + if (query_update_last_ign_off_time.Prepare(kUpdateLastIgnOffTime)) { query_update_last_ign_off_time.Bind(0, static_cast(time(NULL))); if (query_update_last_ign_off_time.Exec()) { LOG4CXX_INFO(logger_, "Data last_ign_off_time was updated"); @@ -380,16 +371,55 @@ uint32_t ResumptionDataDB::GetIgnOffTime() const { } uint32_t ResumptionDataDB::GetGlobalIgnOnCounter() const { - // To be implemented - return 1; + LOG4CXX_AUTO_TRACE(logger_); + sync_primitives::AutoLock autolock(resumption_lock_); + + utils::dbms::SQLQuery query(db()); + if (!query.Prepare(kSelectGlobalIgnOnCounter)) { + LOG4CXX_ERROR(logger_, + "Problem with prepare query : " << kSelectGlobalIgnOnCounter); + return 1; + } + + if (!query.Exec()) { + LOG4CXX_ERROR(logger_, + "Problem with exec query : " << kSelectGlobalIgnOnCounter); + return 1; + } + + const auto global_ign_on_counter = query.GetUInteger(0); + LOG4CXX_DEBUG(logger_, "Global Ign On Counter = " << global_ign_on_counter); + return global_ign_on_counter; } void ResumptionDataDB::IncrementGlobalIgnOnCounter() { - // To be implemented + LOG4CXX_AUTO_TRACE(logger_); + sync_primitives::AutoLock autolock(resumption_lock_); + + db_->BeginTransaction(); + utils::dbms::SQLQuery query_update_global_ign_on_count(db()); + if (query_update_global_ign_on_count.Prepare(kUpdateGlobalIgnOnCount)) { + if (query_update_global_ign_on_count.Exec()) { + LOG4CXX_DEBUG(logger_, + "Data query_update_global_ign_on_count was updated"); + } + } + db_->CommitTransaction(); + WriteDb(); } void ResumptionDataDB::ResetGlobalIgnOnCount() { - // To be implemented + LOG4CXX_AUTO_TRACE(logger_); + sync_primitives::AutoLock autolock(resumption_lock_); + + LOG4CXX_DEBUG(logger_, "Global IGN ON counter resetting"); + + utils::dbms::SQLQuery query_update_global_ign_on_count(db()); + if (query_update_global_ign_on_count.Prepare(kResetGlobalIgnOnCount)) { + if (query_update_global_ign_on_count.Exec()) { + LOG4CXX_DEBUG(logger_, "Data was updated"); + } + } } ssize_t ResumptionDataDB::IsApplicationSaved( diff --git a/src/components/application_manager/src/resumption/resumption_sql_queries.cc b/src/components/application_manager/src/resumption/resumption_sql_queries.cc index 9ca91e859a..4770bafef4 100644 --- a/src/components/application_manager/src/resumption/resumption_sql_queries.cc +++ b/src/components/application_manager/src/resumption/resumption_sql_queries.cc @@ -37,6 +37,7 @@ const std::string kCreateSchema = "BEGIN ; " "CREATE TABLE IF NOT EXISTS `resumption`( " " `idresumption` INTEGER PRIMARY KEY, " + " `global_ign_on_count` INTEGER, " " `last_ign_off_time` INTEGER " " ); " "CREATE TABLE IF NOT EXISTS `subscribedForWayPoints`( " @@ -372,7 +373,9 @@ const std::string kDropSchema = "VACUUM;"; const std::string kInsertInitData = - "INSERT OR IGNORE INTO `resumption` (`last_ign_off_time`) VALUES (0); " + "INSERT OR IGNORE INTO `resumption` " + "(`last_ign_off_time`, `global_ign_on_count`) " + "VALUES (0, 0); " "INSERT OR IGNORE INTO `_internal_data` (`db_version_hash`) VALUES(0); "; const std::string kChecksResumptionData = @@ -410,6 +413,17 @@ const std::string kSelectHashId = const std::string kSelectIgnOffTime = "SELECT `last_ign_off_time` FROM `resumption`"; +const std::string kSelectGlobalIgnOnCounter = + "SELECT `global_ign_on_count` FROM `resumption`"; + +const std::string kResetGlobalIgnOnCount = + "UPDATE `resumption` " + "SET `global_ign_on_count` = 0"; + +const std::string kUpdateGlobalIgnOnCount = + "UPDATE `resumption` " + "SET `global_ign_on_count` = `global_ign_on_count` + 1 "; + const std::string kCheckApplication = "SELECT COUNT (`deviceID`) FROM `application` " "WHERE `deviceID` = ? AND `appID` = ?"; @@ -445,7 +459,7 @@ const std::string kUpdateSuspendData = "UPDATE `application` " "SET `ign_off_count` = `ign_off_count` + 1"; -const std::string KUpdateLastIgnOffTime = +const std::string kUpdateLastIgnOffTime = "UPDATE `resumption` " "SET `last_ign_off_time` = ?"; -- cgit v1.2.1 From 83e5c2517de849cf14631c0eaac5e554b7199a01 Mon Sep 17 00:00:00 2001 From: ZhdanovP Date: Mon, 30 Jul 2018 15:21:00 +0300 Subject: Fix unit test --- .../application_manager/test/resumption/resumption_data_db_test.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/application_manager/test/resumption/resumption_data_db_test.cc b/src/components/application_manager/test/resumption/resumption_data_db_test.cc index 953f43e056..8423520b9f 100644 --- a/src/components/application_manager/test/resumption/resumption_data_db_test.cc +++ b/src/components/application_manager/test/resumption/resumption_data_db_test.cc @@ -123,7 +123,7 @@ class ResumptionDataDBTest : public ResumptionDataTest { void SetZeroIgnOffTime() { utils::dbms::SQLQuery query(test_db()); - EXPECT_TRUE(query.Prepare(KUpdateLastIgnOffTime)); + EXPECT_TRUE(query.Prepare(kUpdateLastIgnOffTime)); query.Bind(0, 0); EXPECT_TRUE(query.Exec()); } -- cgit v1.2.1 From 429972ec7b281acf5358d607962d289c75f1221f Mon Sep 17 00:00:00 2001 From: Andriy Byzhynar Date: Tue, 31 Jul 2018 12:48:47 +0300 Subject: Remove unused variables --- .../application_manager/include/application_manager/smart_object_keys.h | 1 - src/components/application_manager/src/smart_object_keys.cc | 1 - 2 files changed, 2 deletions(-) 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 90c9d403f7..4646ef5e8f 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 @@ -314,7 +314,6 @@ extern const char* resume_vr_grammars; extern const char* ign_off_count; extern const char* global_ign_on_counter; -extern const char* global_ign_off_counter; extern const char* connection_info; extern const char* is_download_complete; diff --git a/src/components/application_manager/src/smart_object_keys.cc b/src/components/application_manager/src/smart_object_keys.cc index ebc114347e..7f742fcd9b 100644 --- a/src/components/application_manager/src/smart_object_keys.cc +++ b/src/components/application_manager/src/smart_object_keys.cc @@ -277,7 +277,6 @@ const char* resume_vr_grammars = "resumeVrGrammars"; const char* ign_off_count = "ign_off_count"; const char* global_ign_on_counter = "global_ign_on_counter"; -const char* global_ign_off_counter = "global_ign_off_counter"; const char* suspend_count = "suspend_count"; const char* connection_info = "connection_info"; -- cgit v1.2.1 From 0d5978fa6a6b0959cd95f5c805cb64c39b1a9411 Mon Sep 17 00:00:00 2001 From: Alexander Date: Wed, 15 Aug 2018 15:14:03 +0300 Subject: Remove deprecated DisconnectedJustBeforeIgnOff method --- .../resumption/resume_ctrl_impl.h | 3 --- .../src/resumption/resume_ctrl_impl.cc | 23 ---------------------- 2 files changed, 26 deletions(-) diff --git a/src/components/application_manager/include/application_manager/resumption/resume_ctrl_impl.h b/src/components/application_manager/include/application_manager/resumption/resume_ctrl_impl.h index c316d11d86..e749118140 100644 --- a/src/components/application_manager/include/application_manager/resumption/resume_ctrl_impl.h +++ b/src/components/application_manager/include/application_manager/resumption/resume_ctrl_impl.h @@ -432,9 +432,6 @@ class ResumeCtrlImpl : public ResumeCtrl, */ bool CheckLowVoltageRestrictions(const smart_objects::SmartObject& saved_app); - DEPRECATED bool DisconnectedJustBeforeIgnOff( - const smart_objects::SmartObject& saved_app); - /** * @brief Checks if saved HMI level is applicable for resumption * @param saved_app application specific section from backup file diff --git a/src/components/application_manager/src/resumption/resume_ctrl_impl.cc b/src/components/application_manager/src/resumption/resume_ctrl_impl.cc index 80f45d6980..3e77078ee5 100644 --- a/src/components/application_manager/src/resumption/resume_ctrl_impl.cc +++ b/src/components/application_manager/src/resumption/resume_ctrl_impl.cc @@ -795,29 +795,6 @@ bool ResumeCtrlImpl::CheckLowVoltageRestrictions( return true; } -DEPRECATED bool ResumeCtrlImpl::DisconnectedJustBeforeIgnOff( - const smart_objects::SmartObject& saved_app) { - using namespace date_time; - LOG4CXX_AUTO_TRACE(logger_); - DCHECK_OR_RETURN(saved_app.keyExists(strings::time_stamp), false); - - const time_t time_stamp = - static_cast(saved_app[strings::time_stamp].asInt()); - const time_t ign_off_time = - static_cast(resumption_storage_->GetIgnOffTime()); - - const uint32_t sec_spent_before_ign = labs(ign_off_time - time_stamp); - LOG4CXX_DEBUG( - logger_, - "ign_off_time " - << ign_off_time << "; app_disconnect_time " << time_stamp - << "; sec_spent_before_ign " << sec_spent_before_ign - << "; resumption_delay_before_ign " - << application_manager_.get_settings().resumption_delay_before_ign()); - return sec_spent_before_ign <= - application_manager_.get_settings().resumption_delay_before_ign(); -} - bool ResumeCtrlImpl::CheckDelayBeforeIgnOff( const smart_objects::SmartObject& saved_app) const { using namespace date_time; -- cgit v1.2.1 From 5224964d04b61cefef075ab9edd34c3dfac7886f Mon Sep 17 00:00:00 2001 From: Alexander Date: Tue, 21 Aug 2018 14:34:09 +0300 Subject: Remove ResumptionLowVoltage_AppInFullUnregisteredOnTheBorderOfTimeFrame_HMILevelRestored unit test Remove unit test beause of possible sporadic failures --- .../test/resumption/resume_ctrl_test.cc | 42 ---------------------- 1 file changed, 42 deletions(-) diff --git a/src/components/application_manager/test/resumption/resume_ctrl_test.cc b/src/components/application_manager/test/resumption/resume_ctrl_test.cc index 151860ed15..c1c1b9fe8b 100644 --- a/src/components/application_manager/test/resumption/resume_ctrl_test.cc +++ b/src/components/application_manager/test/resumption/resume_ctrl_test.cc @@ -1272,48 +1272,6 @@ TEST_F( res_ctrl_->StartAppHmiStateResumption(mock_app_); } -TEST_F( - ResumeCtrlTest, - ResumptionLowVoltage_AppInFullUnregisteredOnTheBorderOfTimeFrame_HMILevelRestored) { - const mobile_apis::HMILevel::eType restored_test_type = eType::HMI_FULL; - const uint32_t time_offset = 5; - const uint32_t time_stamp = - time(nullptr) - resumption_delay_before_ign_ + time_offset; - smart_objects::SmartObject saved_app; - saved_app[application_manager::strings::hmi_level] = restored_test_type; - saved_app[application_manager::strings::time_stamp] = time_stamp; - - application_manager::CommandsMap command; - DataAccessor data_accessor( - command, app_set_lock_ptr_); - - EXPECT_CALL(mock_state_controller_, SetRegularState(_, restored_test_type)) - .Times(AtLeast(1)); - GetInfoFromApp(); - EXPECT_CALL(mock_app_mngr_, GetDefaultHmiLevel(const_app_)) - .WillRepeatedly(Return(kDefaultTestLevel_)); - EXPECT_CALL(*mock_app_, commands_map()).WillRepeatedly(Return(data_accessor)); - ON_CALL(*mock_storage_, - GetSavedApplication(kTestPolicyAppId_, kMacAddress_, _)) - .WillByDefault(DoAll(SetArgReferee<2>(saved_app), Return(true))); - - EXPECT_CALL(*mock_storage_, - RemoveApplicationFromSaved(kTestPolicyAppId_, kMacAddress_)) - .WillOnce(Return(true)); - - ON_CALL(mock_app_mngr_, GetUserConsentForDevice("12345")) - .WillByDefault(Return(policy::kDeviceAllowed)); - - NiceMock app_mngr_settings_; - EXPECT_CALL(mock_app_mngr_, get_settings()) - .WillOnce(ReturnRef(app_mngr_settings_)); - - EXPECT_CALL(app_mngr_settings_, resumption_delay_before_ign()) - .WillOnce(Return(resumption_delay_before_ign_ + time_offset)); - - res_ctrl_->SaveLowVoltageTime(); - res_ctrl_->StartAppHmiStateResumption(mock_app_); -} TEST_F( ResumeCtrlTest, -- cgit v1.2.1 From e183f2ad9068cf2b6d9fa1ac661478d89e9e6a1c Mon Sep 17 00:00:00 2001 From: JackLivio Date: Tue, 21 Aug 2018 10:03:14 -0400 Subject: Check style --- .../src/commands/mobile/register_app_interface_request.cc | 4 ++-- src/components/application_manager/src/rpc_handler_impl.cc | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/register_app_interface_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/register_app_interface_request.cc index 1b2bbe2b44..c5e368f216 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/register_app_interface_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/register_app_interface_request.cc @@ -322,11 +322,11 @@ void RegisterAppInterfaceRequest::Run() { } // Version negotiation - utils::SemanticVersion ver_4_5(4,5,0); + utils::SemanticVersion ver_4_5(4, 5, 0); utils::SemanticVersion module_version( major_version, minor_version, patch_version); if (mobile_version <= ver_4_5) { - // Mobile versioning did not exist for + // Mobile versioning did not exist for // versions 4.5 and prior. application->set_msg_version(ver_4_5); } else if (mobile_version < module_version) { diff --git a/src/components/application_manager/src/rpc_handler_impl.cc b/src/components/application_manager/src/rpc_handler_impl.cc index c46a99fa39..2deda30994 100644 --- a/src/components/application_manager/src/rpc_handler_impl.cc +++ b/src/components/application_manager/src/rpc_handler_impl.cc @@ -219,7 +219,7 @@ void RPCHandlerImpl::GetMessageVersion( } utils::SemanticVersion temp_version(major, minor, patch); if (temp_version.isValid()) { - utils::SemanticVersion ver_4_5(4,5,0); + utils::SemanticVersion ver_4_5(4, 5, 0); message_version = (temp_version > ver_4_5) ? temp_version : ver_4_5; } } -- cgit v1.2.1 From c1252c6e985d159757b9ed0d6729906ec80515de Mon Sep 17 00:00:00 2001 From: jacobkeeler Date: Tue, 21 Aug 2018 10:46:51 -0400 Subject: Fix style --- src/components/application_manager/test/resumption/resume_ctrl_test.cc | 1 - 1 file changed, 1 deletion(-) diff --git a/src/components/application_manager/test/resumption/resume_ctrl_test.cc b/src/components/application_manager/test/resumption/resume_ctrl_test.cc index c1c1b9fe8b..1c2339096c 100644 --- a/src/components/application_manager/test/resumption/resume_ctrl_test.cc +++ b/src/components/application_manager/test/resumption/resume_ctrl_test.cc @@ -1272,7 +1272,6 @@ TEST_F( res_ctrl_->StartAppHmiStateResumption(mock_app_); } - TEST_F( ResumeCtrlTest, ResumptionLowVoltage_AppInFullUnregisteredBeyondTimeFrame_HMILevelNotRestored) { -- cgit v1.2.1 From c64e00ccfbedd780f1428d7e8e93ae643dc2f5ed Mon Sep 17 00:00:00 2001 From: jacobkeeler Date: Tue, 21 Aug 2018 11:25:43 -0400 Subject: Fix build failures when ENABLE_LOG=OFF --- .../sdl_rpc_plugin/src/commands/mobile/put_file_request.cc | 5 ++--- .../vehicle_info_plugin/src/vehicle_info_hmi_command_factory.cc | 1 + .../vehicle_info_plugin/src/vehicle_info_mobile_command_factory.cc | 1 + .../application_manager/test/application_manager_impl_test.cc | 2 ++ src/components/protocol_handler/src/protocol_handler_impl.cc | 3 +++ src/components/smart_objects/include/smart_objects/schema_item.h | 1 + src/components/smart_objects/include/smart_objects/smart_object.h | 1 + .../transport_manager/src/iap2_emulation/iap2_transport_adapter.cc | 2 ++ .../linux/platform_specific_network_interface_listener.cc | 1 + 9 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/put_file_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/put_file_request.cc index 4d1e4339f5..d5a13c99a0 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/put_file_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/put_file_request.cc @@ -212,10 +212,9 @@ void PutFileRequest::Run() { return; } const std::string full_path = file_path + "/" + sync_file_name_; - const size_t bin_data_size = binary_data.size(); if ((*message_)[strings::msg_params].keyExists(strings::crc32_check_sum)) { - LOG4CXX_TRACE(logger_, "Binary Data Size: " << bin_data_size); + LOG4CXX_TRACE(logger_, "Binary Data Size: " << binary_data.size()); const uint32_t crc_received = (*message_)[strings::msg_params][strings::crc32_check_sum].asUInt(); LOG4CXX_TRACE(logger_, "CRC32 SUM Received: " << crc_received); @@ -232,7 +231,7 @@ void PutFileRequest::Run() { } LOG4CXX_DEBUG(logger_, - "Writing " << bin_data_size << " bytes to " << full_path + "Writing " << binary_data.size() << " bytes to " << full_path << " (current size is" << file_system::FileSize(full_path) << ")"); diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/vehicle_info_hmi_command_factory.cc b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/vehicle_info_hmi_command_factory.cc index 3855d6733b..9311cea6d7 100644 --- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/vehicle_info_hmi_command_factory.cc +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/vehicle_info_hmi_command_factory.cc @@ -89,6 +89,7 @@ app_mngr::CommandSharedPtr VehicleInfoHmiCommandFactory::CreateCommand( message_type_str = "error response"; } + UNUSED(message_type_str); LOG4CXX_DEBUG(logger_, "HMICommandFactory::CreateCommand function_id: " << function_id << ", message type: " << message_type_str); diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/vehicle_info_mobile_command_factory.cc b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/vehicle_info_mobile_command_factory.cc index caa832dde4..7600afa091 100644 --- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/vehicle_info_mobile_command_factory.cc +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/vehicle_info_mobile_command_factory.cc @@ -86,6 +86,7 @@ app_mngr::CommandSharedPtr VehicleInfoMobileCommandFactory::CreateCommand( message_type_str = "notification"; } + UNUSED(message_type_str); LOG4CXX_DEBUG(logger_, "HMICommandFactory::CreateCommand function_id: " << function_id << ", message type: " << message_type_str); diff --git a/src/components/application_manager/test/application_manager_impl_test.cc b/src/components/application_manager/test/application_manager_impl_test.cc index 36cf890351..22ac534215 100644 --- a/src/components/application_manager/test/application_manager_impl_test.cc +++ b/src/components/application_manager/test/application_manager_impl_test.cc @@ -110,7 +110,9 @@ class ApplicationManagerImplTest : public ::testing::Test { application_manager::MockMessageHelper::message_helper_mock()) { +#ifdef ENABLE_LOG logger::create_log_message_loop_thread(); +#endif Mock::VerifyAndClearExpectations(mock_message_helper_); } ~ApplicationManagerImplTest() { diff --git a/src/components/protocol_handler/src/protocol_handler_impl.cc b/src/components/protocol_handler/src/protocol_handler_impl.cc index 7dcf4d97f7..b595c977aa 100644 --- a/src/components/protocol_handler/src/protocol_handler_impl.cc +++ b/src/components/protocol_handler/src/protocol_handler_impl.cc @@ -290,6 +290,7 @@ void ProtocolHandlerImpl::SendStartSessionAck( static_cast( protocol_header_validator_.max_payload_size_by_service_type( serviceTypeValue))); + UNUSED(mtu_written) LOG4CXX_DEBUG(logger_, "MTU parameter was written to bson params: " << mtu_written << "; Value: " @@ -300,6 +301,7 @@ void ProtocolHandlerImpl::SendStartSessionAck( // Hash ID is only used in RPC case const bool hash_written = bson_object_put_int32( ¶ms, strings::hash_id, static_cast(hash_id)); + UNUSED(hash_written); LOG4CXX_DEBUG(logger_, "Hash parameter was written to bson params: " << hash_written << "; Value: " @@ -317,6 +319,7 @@ void ProtocolHandlerImpl::SendStartSessionAck( const bool protocol_ver_written = bson_object_put_string( ¶ms, strings::protocol_version, protocolVersionString); + UNUSED(protocol_ver_written); LOG4CXX_DEBUG( logger_, "Protocol version parameter was written to bson params: " diff --git a/src/components/smart_objects/include/smart_objects/schema_item.h b/src/components/smart_objects/include/smart_objects/schema_item.h index 2670e4a340..5626b0cf23 100644 --- a/src/components/smart_objects/include/smart_objects/schema_item.h +++ b/src/components/smart_objects/include/smart_objects/schema_item.h @@ -39,6 +39,7 @@ #include "smart_objects/errors.h" #include +#include #include "utils/macro.h" #include "utils/semantic_version.h" diff --git a/src/components/smart_objects/include/smart_objects/smart_object.h b/src/components/smart_objects/include/smart_objects/smart_object.h index 112f40b959..022dc6cb13 100644 --- a/src/components/smart_objects/include/smart_objects/smart_object.h +++ b/src/components/smart_objects/include/smart_objects/smart_object.h @@ -35,6 +35,7 @@ #include #include +#include #include #include diff --git a/src/components/transport_manager/src/iap2_emulation/iap2_transport_adapter.cc b/src/components/transport_manager/src/iap2_emulation/iap2_transport_adapter.cc index 6b7d44ea8d..e2e5b98190 100644 --- a/src/components/transport_manager/src/iap2_emulation/iap2_transport_adapter.cc +++ b/src/components/transport_manager/src/iap2_emulation/iap2_transport_adapter.cc @@ -78,6 +78,7 @@ IAP2USBEmulationTransportAdapter::IAP2USBEmulationTransportAdapter( signal_handler_ = threads::CreateThread("iAP signal handler", delegate); signal_handler_->start(); const auto result = mkfifo(out_signals_channel, mode); + UNUSED(result); LOG4CXX_DEBUG(logger_, "Out signals channel creation result: " << result); } @@ -123,6 +124,7 @@ IAP2USBEmulationTransportAdapter::IAPSignalHandlerDelegate:: IAPSignalHandlerDelegate(IAP2USBEmulationTransportAdapter& adapter) : adapter_(adapter), run_flag_(true), in_(0) { const auto result = mkfifo(in_signals_channel, mode); + UNUSED(result); LOG4CXX_DEBUG(logger_, "In signals channel creation result: " << result); } diff --git a/src/components/transport_manager/src/tcp/platform_specific/linux/platform_specific_network_interface_listener.cc b/src/components/transport_manager/src/tcp/platform_specific/linux/platform_specific_network_interface_listener.cc index 29e55b97dd..7f4562004f 100644 --- a/src/components/transport_manager/src/tcp/platform_specific/linux/platform_specific_network_interface_listener.cc +++ b/src/components/transport_manager/src/tcp/platform_specific/linux/platform_specific_network_interface_listener.cc @@ -652,6 +652,7 @@ void PlatformSpecificNetworkInterfaceListener::DumpTable() const { for (auto it = status_table_.begin(); it != status_table_.end(); ++it) { const std::string ifname = it->first; const InterfaceStatus& status = it->second; + UNUSED(status); LOG4CXX_DEBUG( logger_, -- cgit v1.2.1 From d087438d1445dd4596dcedd61c9934b803942b19 Mon Sep 17 00:00:00 2001 From: JackLivio Date: Tue, 21 Aug 2018 15:20:13 -0400 Subject: Flush logger before deleting message loop thread --- src/components/utils/src/logger.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/src/components/utils/src/logger.cc b/src/components/utils/src/logger.cc index 4e93ca3d14..5b346ca868 100644 --- a/src/components/utils/src/logger.cc +++ b/src/components/utils/src/logger.cc @@ -39,6 +39,7 @@ void deinit_logger() { CREATE_LOGGERPTR_LOCAL(logger_, "Utils") LOG4CXX_DEBUG(logger_, "Logger deinitialization"); logger::set_logs_enabled(false); + logger::flush_logger(); logger::delete_log_message_loop_thread(); log4cxx::LoggerPtr rootLogger = log4cxx::Logger::getRootLogger(); log4cxx::spi::LoggerRepositoryPtr repository = -- cgit v1.2.1 From e9302a6d65efdac264808fed96541974696e3f36 Mon Sep 17 00:00:00 2001 From: JackLivio Date: Tue, 21 Aug 2018 19:07:27 -0400 Subject: Make LogMessageLoopThread a handler Before when the LogMessageLoopThread desctructor was called, it would delete the handler before deleting the message loop thread. This would cause a segfault in MessageLoopThread::DrainQueue() when trying to access the null handler_ pointer. --- src/components/utils/include/utils/log_message_loop_thread.h | 10 +++------- src/components/utils/src/log_message_loop_thread.cc | 6 ++---- 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/src/components/utils/include/utils/log_message_loop_thread.h b/src/components/utils/include/utils/log_message_loop_thread.h index d6a9edd072..b20b43c251 100644 --- a/src/components/utils/include/utils/log_message_loop_thread.h +++ b/src/components/utils/include/utils/log_message_loop_thread.h @@ -56,18 +56,14 @@ typedef std::queue LogMessageQueue; typedef threads::MessageLoopThread LogMessageLoopThreadTemplate; -class LogMessageHandler : public LogMessageLoopThreadTemplate::Handler { - public: - virtual void Handle(const LogMessage message) OVERRIDE; -}; - -class LogMessageLoopThread : public LogMessageLoopThreadTemplate { +class LogMessageLoopThread : public LogMessageLoopThreadTemplate, + public LogMessageLoopThreadTemplate::Handler { public: LogMessageLoopThread(); ~LogMessageLoopThread(); + void Handle(const LogMessage message) OVERRIDE; private: - LogMessageHandler* handler_; DISALLOW_COPY_AND_ASSIGN(LogMessageLoopThread); }; diff --git a/src/components/utils/src/log_message_loop_thread.cc b/src/components/utils/src/log_message_loop_thread.cc index 2b7f28fbfd..25cf5ab7bb 100644 --- a/src/components/utils/src/log_message_loop_thread.cc +++ b/src/components/utils/src/log_message_loop_thread.cc @@ -35,7 +35,7 @@ namespace logger { -void LogMessageHandler::Handle(const LogMessage message) { +void LogMessageLoopThread::Handle(const LogMessage message) { message.logger->forcedLog(message.level, message.entry, message.timeStamp, @@ -44,14 +44,12 @@ void LogMessageHandler::Handle(const LogMessage message) { } LogMessageLoopThread::LogMessageLoopThread() - : LogMessageLoopThreadTemplate("Logger", - handler_ = new LogMessageHandler()) {} + : LogMessageLoopThreadTemplate("Logger", this) {} LogMessageLoopThread::~LogMessageLoopThread() { // we'll have to drop messages // while deleting logger thread logger_status = DeletingLoggerThread; - delete handler_; } } // namespace logger -- cgit v1.2.1 From e992bc90919a756351ec26bb848f7450c31a530d Mon Sep 17 00:00:00 2001 From: Alexander Date: Wed, 22 Aug 2018 12:10:05 +0300 Subject: Modify hmi_capabilities, MOBILE, HMI API according SDL-0099 Add `statusAvailable` to capabilities and to params of LightCapabilities RPC in MOBILE_API, HMI_API Add to hmi_capabilities, MOBILE_API, HMI_API following light names : - REAR_CARGO_LIGHTS - REAR_TRUCK_BED_LIGHTS - REAR_TRAILER_LIGHTS - LEFT_SPOT_LIGHTS - RIGHT_SPOT_LIGHTS - RIGHT_PUDDLE_LIGHTS - EXTERIOR_ALL_LIGHTS Add to MOBILE_API following LightStatus: - RAMP_UP - RAMP_DOWN - UNKNOWN - INVALID --- src/appMain/hmi_capabilities.json | 92 +++++++++++++++++++++++++++++++- src/components/interfaces/HMI_API.xml | 34 +++++++++++- src/components/interfaces/MOBILE_API.xml | 34 +++++++++++- 3 files changed, 156 insertions(+), 4 deletions(-) diff --git a/src/appMain/hmi_capabilities.json b/src/appMain/hmi_capabilities.json index a3f7bcd0a1..46fd31a352 100755 --- a/src/appMain/hmi_capabilities.json +++ b/src/appMain/hmi_capabilities.json @@ -504,204 +504,292 @@ "moduleName": "light", "supportedLights":[ { + "statusAvailable":true, "densityAvailable":true, "name":"FRONT_LEFT_HIGH_BEAM", "rgbColorSpaceAvailable":true }, { + "statusAvailable":true, "densityAvailable":true, "name":"FRONT_RIGHT_HIGH_BEAM", "rgbColorSpaceAvailable":true }, { + "statusAvailable":true, "densityAvailable":true, "name":"FRONT_LEFT_LOW_BEAM", "rgbColorSpaceAvailable":true }, { + "statusAvailable":true, "densityAvailable":true, "name":"FRONT_RIGHT_LOW_BEAM", "rgbColorSpaceAvailable":true }, { + "statusAvailable":true, "densityAvailable":true, "name":"FRONT_LEFT_PARKING_LIGHT", "rgbColorSpaceAvailable":true }, { + "statusAvailable":true, "densityAvailable":true, "name":"FRONT_RIGHT_PARKING_LIGHT", "rgbColorSpaceAvailable":true }, { + "statusAvailable":true, "densityAvailable":true, "name":"FRONT_LEFT_FOG_LIGHT", "rgbColorSpaceAvailable":true }, { + "statusAvailable":true, "densityAvailable":true, "name":"FRONT_RIGHT_FOG_LIGHT", "rgbColorSpaceAvailable":true }, { + "statusAvailable":true, "densityAvailable":true, "name":"FRONT_LEFT_DAYTIME_RUNNING_LIGHT", "rgbColorSpaceAvailable":true }, { + "statusAvailable":true, "densityAvailable":true, "name":"FRONT_RIGHT_DAYTIME_RUNNING_LIGHT", "rgbColorSpaceAvailable":true }, { + "statusAvailable":true, "densityAvailable":true, "name":"FRONT_LEFT_TURN_LIGHT", "rgbColorSpaceAvailable":true }, { + "statusAvailable":true, "densityAvailable":true, "name":"FRONT_RIGHT_TURN_LIGHT", "rgbColorSpaceAvailable":true }, { + "statusAvailable":true, "densityAvailable":true, "name":"REAR_LEFT_FOG_LIGHT", "rgbColorSpaceAvailable":true }, { + "statusAvailable":true, "densityAvailable":true, "name":"REAR_RIGHT_FOG_LIGHT", "rgbColorSpaceAvailable":true }, { + "statusAvailable":true, "densityAvailable":true, "name":"REAR_LEFT_TAIL_LIGHT", "rgbColorSpaceAvailable":true }, { + "statusAvailable":true, "densityAvailable":true, "name":"REAR_RIGHT_TAIL_LIGHT", "rgbColorSpaceAvailable":true }, { + "statusAvailable":true, "densityAvailable":true, - "name":"REAR_LEFT_BREAK_LIGHT", + "name":"REAR_LEFT_BRAKE_LIGHT", "rgbColorSpaceAvailable":true }, { + "statusAvailable":true, "densityAvailable":true, - "name":"REAR_RIGHT_BREAK_LIGHT", + "name":"REAR_RIGHT_BRAKE_LIGHT", "rgbColorSpaceAvailable":true }, { + "statusAvailable":true, "densityAvailable":true, "name":"REAR_LEFT_TURN_LIGHT", "rgbColorSpaceAvailable":true }, { + "statusAvailable":true, "densityAvailable":true, "name":"REAR_RIGHT_TURN_LIGHT", "rgbColorSpaceAvailable":true }, { + "statusAvailable":true, "densityAvailable":true, "name":"REAR_REGISTRATION_PLATE_LIGHT", "rgbColorSpaceAvailable":true }, { + "statusAvailable":true, "densityAvailable":true, "name":"HIGH_BEAMS", "rgbColorSpaceAvailable":true }, { + "statusAvailable":true, "densityAvailable":true, "name":"LOW_BEAMS", "rgbColorSpaceAvailable":true }, { + "statusAvailable":true, "densityAvailable":true, "name":"FOG_LIGHTS", "rgbColorSpaceAvailable":true }, { + "statusAvailable":true, "densityAvailable":true, "name":"RUNNING_LIGHTS", "rgbColorSpaceAvailable":true }, { + "statusAvailable":true, "densityAvailable":true, "name":"PARKING_LIGHTS", "rgbColorSpaceAvailable":true }, { + "statusAvailable":true, "densityAvailable":true, "name":"BRAKE_LIGHTS", "rgbColorSpaceAvailable":true }, { + "statusAvailable":true, "densityAvailable":true, "name":"REAR_REVERSING_LIGHTS", "rgbColorSpaceAvailable":true }, { + "statusAvailable":true, "densityAvailable":true, "name":"SIDE_MARKER_LIGHTS", "rgbColorSpaceAvailable":true }, { + "statusAvailable":true, "densityAvailable":true, "name":"LEFT_TURN_LIGHTS", "rgbColorSpaceAvailable":true }, { + "statusAvailable":true, "densityAvailable":true, "name":"RIGHT_TURN_LIGHTS", "rgbColorSpaceAvailable":true }, { + "statusAvailable":true, "densityAvailable":true, "name":"HAZARD_LIGHTS", "rgbColorSpaceAvailable":true }, { + "statusAvailable":true, "densityAvailable":true, "name":"AMBIENT_LIGHTS", "rgbColorSpaceAvailable":true }, { + "statusAvailable":true, "densityAvailable":true, "name":"OVERHEAD_LIGHTS", "rgbColorSpaceAvailable":true }, { + "statusAvailable":true, "densityAvailable":true, "name":"READING_LIGHTS", "rgbColorSpaceAvailable":true }, { + "statusAvailable":true, "densityAvailable":true, "name":"TRUNK_LIGHTS", "rgbColorSpaceAvailable":true }, { + "statusAvailable":true, "densityAvailable":true, "name":"EXTERIOR_FRONT_LIGHTS", "rgbColorSpaceAvailable":true }, { + "statusAvailable":true, "densityAvailable":true, "name":"EXTERIOR_REAR_LIGHTS", "rgbColorSpaceAvailable":true }, { + "statusAvailable":true, "densityAvailable":true, "name":"EXTERIOR_LEFT_LIGHTS", "rgbColorSpaceAvailable":true }, { + "statusAvailable":true, "densityAvailable":true, "name":"EXTERIOR_RIGHT_LIGHTS", "rgbColorSpaceAvailable":true + }, + { + "statusAvailable":false, + "densityAvailable":false, + "name":"REAR_CARGO_LIGHTS", + "rgbColorSpaceAvailable":false + }, + { + "statusAvailable":false, + "densityAvailable":false, + "name":"REAR_TRUCK_BED_LIGHTS", + "rgbColorSpaceAvailable":false + }, + { + "statusAvailable":false, + "densityAvailable":false, + "name":"REAR_TRAILER_LIGHTS", + "rgbColorSpaceAvailable":false + }, + { + "statusAvailable":false, + "densityAvailable":false, + "name":"LEFT_SPOT_LIGHTS", + "rgbColorSpaceAvailable":false + }, + { + "statusAvailable":false, + "densityAvailable":false, + "name":"RIGHT_SPOT_LIGHTS", + "rgbColorSpaceAvailable":false + }, + { + "statusAvailable":false, + "densityAvailable":false, + "name":"LEFT_PUDDLE_LIGHTS", + "rgbColorSpaceAvailable":false + }, + { + "statusAvailable":false, + "densityAvailable":false, + "name":"RIGHT_PUDDLE_LIGHTS", + "rgbColorSpaceAvailable":false + }, + { + "statusAvailable":true, + "densityAvailable":false, + "name":"EXTERIOR_ALL_LIGHTS", + "rgbColorSpaceAvailable":false } ] }, diff --git a/src/components/interfaces/HMI_API.xml b/src/components/interfaces/HMI_API.xml index a9854ef730..a6f8bd3ce2 100644 --- a/src/components/interfaces/HMI_API.xml +++ b/src/components/interfaces/HMI_API.xml @@ -2244,6 +2244,27 @@ Include all hazard lights: front_left, front_right, rear_left and rear_right. + + Cargo lamps illuminate the cargo area. + + + Truck bed lamps light up the bed of the truck. + + + Trailer lights are lamps mounted on a trailer hitch. + + + It is the spotlights mounted on the left side of a vehicle. + + + It is the spotlights mounted on the right side of a vehicle. + + + Puddle lamps illuminate the ground beside the door as the customer is opening or approaching the door. + + + Puddle lamps illuminate the ground beside the door as the customer is opening or approaching the door. + @@ -2264,16 +2285,27 @@ Include exterior lights located at the right side of the vehicle. For example, right puddle lights and spot lights. + + Include all exterior lights around the vehicle. + + + + + - + + + Indicates if the status (ON/OFF) can be set remotely. App shall not use read-only values (RAMP_UP/RAMP_DOWN/UNKNOWN/INVALID) in a setInteriorVehicleData request. + + Indicates if the light's density can be set remotely (similar to a dimmer). diff --git a/src/components/interfaces/MOBILE_API.xml b/src/components/interfaces/MOBILE_API.xml index 88a9c59203..ca8bd55d63 100644 --- a/src/components/interfaces/MOBILE_API.xml +++ b/src/components/interfaces/MOBILE_API.xml @@ -3396,6 +3396,27 @@ Include all hazard lights: front_left, front_right, rear_left and rear_right. + + Cargo lamps illuminate the cargo area. + + + Truck bed lamps light up the bed of the truck. + + + Trailer lights are lamps mounted on a trailer hitch. + + + It is the spotlights mounted on the left side of a vehicle. + + + It is the spotlights mounted on the right side of a vehicle. + + + Puddle lamps illuminate the ground beside the door as the customer is opening or approaching the door. + + + Puddle lamps illuminate the ground beside the door as the customer is opening or approaching the door. + @@ -3416,16 +3437,27 @@ Include exterior lights located at the right side of the vehicle. For example, right puddle lights and spot lights. + + Include all exterior lights around the vehicle. + + + + + - + + + Indicates if the status (ON/OFF) can be set remotely. App shall not use read-only values (RAMP_UP/RAMP_DOWN/UNKNOWN/INVALID) in a setInteriorVehicleData request. + + Indicates if the light's density can be set remotely (similar to a dimmer). -- cgit v1.2.1 From 088cae01ca7ff71240ce1cc0cae3667d85e91aa3 Mon Sep 17 00:00:00 2001 From: Alexander Date: Wed, 22 Aug 2018 12:11:12 +0300 Subject: Add statusAvailable param to constants --- .../rc_rpc_plugin/include/rc_rpc_plugin/rc_module_constants.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_module_constants.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_module_constants.h index e80507445b..195cec0ced 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_module_constants.h +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_module_constants.h @@ -52,6 +52,7 @@ const char kSupportedLights[] = "supportedLights"; // LightControlCapabilities const char kName[] = "name"; +const char kStatusAvailable[] = "statusAvailable"; const char kDensityAvailable[] = "densityAvailable"; const char kRGBColorSpaceAvailable[] = "rgbColorSpaceAvailable"; -- cgit v1.2.1 From 4dce835c7917fb09795bb475fc9fb9153c523f99 Mon Sep 17 00:00:00 2001 From: JackLivio Date: Wed, 22 Aug 2018 11:51:54 -0400 Subject: Update unit tests and add condition for flush logger --- src/components/utils/src/logger.cc | 4 +++- src/components/utils/test/log_message_loop_thread_test.cc | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/components/utils/src/logger.cc b/src/components/utils/src/logger.cc index 5b346ca868..af21aeac77 100644 --- a/src/components/utils/src/logger.cc +++ b/src/components/utils/src/logger.cc @@ -39,7 +39,9 @@ void deinit_logger() { CREATE_LOGGERPTR_LOCAL(logger_, "Utils") LOG4CXX_DEBUG(logger_, "Logger deinitialization"); logger::set_logs_enabled(false); - logger::flush_logger(); + if (logger::logger_status == logger::LoggerThreadCreated) { + logger::flush_logger(); + } logger::delete_log_message_loop_thread(); log4cxx::LoggerPtr rootLogger = log4cxx::Logger::getRootLogger(); log4cxx::spi::LoggerRepositoryPtr repository = diff --git a/src/components/utils/test/log_message_loop_thread_test.cc b/src/components/utils/test/log_message_loop_thread_test.cc index 032c7ecae1..92287fb45b 100644 --- a/src/components/utils/test/log_message_loop_thread_test.cc +++ b/src/components/utils/test/log_message_loop_thread_test.cc @@ -57,7 +57,7 @@ TEST(LogMessageLoopThread, DestroyLogMessage_loggerStatusDeletingLogger) { logger::logger_status = LoggerThreadNotCreated; } -class MockLogMessageTest : public LogMessageHandler { +class MockLogMessageTest : public LogMessageLoopThread { public: MOCK_CONST_METHOD1(Handle, void(const LogMessage message)); }; -- cgit v1.2.1 From f0e50bf99171a05e3b5c4e0fc9392a3c14720695 Mon Sep 17 00:00:00 2001 From: Alexander Date: Wed, 22 Aug 2018 12:12:43 +0300 Subject: Add processing new light capabilities to set_interior_vehicle_data --- .../mobile/set_interior_vehicle_data_request.h | 13 +- .../include/rc_rpc_plugin/rc_module_constants.h | 6 +- .../mobile/set_interior_vehicle_data_request.cc | 414 +++++++++++++++------ 3 files changed, 313 insertions(+), 120 deletions(-) diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/set_interior_vehicle_data_request.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/set_interior_vehicle_data_request.h index d5de4981c6..128c668ee9 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/set_interior_vehicle_data_request.h +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/set_interior_vehicle_data_request.h @@ -39,6 +39,11 @@ namespace rc_rpc_plugin { namespace app_mngr = application_manager; namespace commands { + +enum capabilitiesStatus { success, missedLightName, missedParam, readOnly }; + +typedef std::pair ModuleCapability; + class SetInteriorVehicleDataRequest : public RCCommandRequest { public: SetInteriorVehicleDataRequest( @@ -81,10 +86,12 @@ class SetInteriorVehicleDataRequest : public RCCommandRequest { /** * @brief Method that check if READ_ONLY parameters present - * @param request_params params from received message + * @param request_params params from received message, + * @param module_data_capabilities info for notification to mobile * @return true if present , false - otherwise */ - bool AreReadOnlyParamsPresent(const smart_objects::SmartObject& module_data); + bool AreReadOnlyParamsPresent(const smart_objects::SmartObject& module_data, + ModuleCapability& module_data_capabilities); /** * @brief Method that check if all request parameters are READ_ONLY @@ -95,7 +102,7 @@ class SetInteriorVehicleDataRequest : public RCCommandRequest { /** * @brief Method that cuts-off READ_ONLY parameters - * @param request_params params to handle + * @param module_data params to handle */ void CutOffReadOnlyParams(smart_objects::SmartObject& module_data); diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_module_constants.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_module_constants.h index 195cec0ced..1951af1a24 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_module_constants.h +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_module_constants.h @@ -179,9 +179,9 @@ const char kHeatedMirrorsEnable[] = "heatedMirrorsEnable"; // LightControlData const char kLightState[] = "lightState"; -const char kStatus[] = "status"; -const char kDensity[] = "density"; -const char kColor[] = "color"; +const char kLightStatus[] = "status"; +const char kLightDensity[] = "density"; +const char kLightColor[] = "color"; // AudioControlData const char kSource[] = "source"; diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/set_interior_vehicle_data_request.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/set_interior_vehicle_data_request.cc index 17a492b5aa..e6f19a889c 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/set_interior_vehicle_data_request.cc +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/set_interior_vehicle_data_request.cc @@ -59,10 +59,22 @@ std::vector GetModuleReadOnlyParams( module_ro_params.push_back(kSignalChangeThreshold); module_ro_params.push_back(kState); module_ro_params.push_back(kSisData); + } else if (enums_value::kLight == module_type) { + module_ro_params.push_back(kLightStatus); } + return module_ro_params; } +const std::map GetLightCapabilitiesMapping() { + std::map mapping = { + {message_params::kId, strings::kName}, + {message_params::kLightStatus, strings::kStatusAvailable}, + {message_params::kLightDensity, strings::kDensityAvailable}, + {message_params::kLightColor, strings::kRGBColorSpaceAvailable}}; + return mapping; +} + const std::map GetModuleDataToCapabilitiesMapping() { std::map mapping; // climate @@ -113,6 +125,7 @@ const std::map GetModuleDataToCapabilitiesMapping() { mapping["massageMode"] = "massageModeAvailable"; mapping["massageCushionFirmness"] = "massageCushionFirmnessAvailable"; mapping["memory"] = "memoryAvailable"; + // audio mapping["source"] = "sourceAvailable"; mapping["keepContext"] = "keepContextAvailable"; @@ -146,45 +159,98 @@ const std::string LightName(const smart_objects::SmartObject& light_name) { return ok ? name : "unknown"; } -bool CheckLightDataByCapabilities( +/** + * @brief Check whether the parameter exist in capabilities + * @param smart object of capabilities + * @param mapping - map of module data and capabilities + * @param request_parameter - string + * @param switched_off_result - ref of mobile_apis::Result + * @return success if parameter exist in capabilities missedParam otherwise + */ +capabilitiesStatus GetItemCapability( const smart_objects::SmartObject& capabilities, - const smart_objects::SmartObject& light_data) { + const std::map& mapping, + const std::string& request_parameter, + const mobile_apis::Result::eType& switched_off_result) { + const auto it = mapping.find(request_parameter); + + if (it == mapping.end()) { + LOG4CXX_DEBUG(logger_, + "Parameter " << request_parameter + << " doesn't exist in capabilities."); + return capabilitiesStatus::missedParam; + } + + const std::string& caps_key = it->second; + + LOG4CXX_DEBUG(logger_, + "Checking request parameter " + << request_parameter + << " with capabilities. Appropriate key is " << caps_key); + + if (!capabilities.keyExists(caps_key)) { + LOG4CXX_DEBUG(logger_, + "Capability " << caps_key + << " is missed in RemoteControl capabilities"); + return capabilitiesStatus::missedParam; + } + + if (!capabilities[caps_key].asBool()) { + LOG4CXX_DEBUG(logger_, + "Capability " + << caps_key + << " is switched off in RemoteControl capabilities"); + capabilitiesStatus status = capabilitiesStatus::missedParam; + if (mobile_apis::Result::READ_ONLY == switched_off_result) { + status = capabilitiesStatus::readOnly; + } + return status; + } + + return capabilitiesStatus::success; +} + +/** + * @brief Check whether the cpabilities for light allowed + * @param smart object of capabilities + * @param smart object of control_data + * @return pair of state and capability status - ModuleCapability + */ +ModuleCapability GetLightDataCapabilities( + const smart_objects::SmartObject& capabilities, + const smart_objects::SmartObject& control_data) { LOG4CXX_AUTO_TRACE(logger_); - std::map lightCapsMapping = { - {message_params::kId, strings::kName}, - {message_params::kDensity, strings::kDensityAvailable}, - {message_params::kColor, strings::kRGBColorSpaceAvailable}}; - auto it = light_data.map_begin(); - for (; it != light_data.map_end(); ++it) { - if (message_params::kStatus == it->first || - message_params::kId == it->first) { + std::map mapping = GetLightCapabilitiesMapping(); + + for (auto it = control_data.map_begin(); it != control_data.map_end(); ++it) { + const std::string& request_parameter = it->first; + + if (message_params::kId == request_parameter) { continue; } - const std::string& caps_key = lightCapsMapping[it->first]; - LOG4CXX_DEBUG(logger_, - "Checking request parameter " - << it->first << " with capabilities. Appropriate key is " - << caps_key); - - if (!capabilities.keyExists(caps_key)) { - LOG4CXX_DEBUG(logger_, - "Capability " - << caps_key - << " is missed in RemoteControl capabilities"); - return false; - } - if (!capabilities[caps_key].asBool()) { - LOG4CXX_DEBUG(logger_, - "Capability " - << caps_key - << " is switched off in RemoteControl capabilities"); - return false; + + const capabilitiesStatus status_item_capability = + GetItemCapability(capabilities, + mapping, + request_parameter, + mobile_apis::Result::READ_ONLY); + + if (capabilitiesStatus::success != status_item_capability) { + return std::make_pair(message_params::kLightState, + status_item_capability); } } - return true; + + return std::make_pair("", capabilitiesStatus::success); } -bool CheckLightNameByCapabilities( +/** + * @brief Check whether the light name exists in capabilities + * @param smart object of capabilities_status + * @param smart object of light_data + * @return pair of state and capability status - ModuleCapability + */ +ModuleCapability GetLightNameCapabilities( const smart_objects::SmartObject& capabilities_status, const smart_objects::SmartObject& light_data) { LOG4CXX_AUTO_TRACE(logger_); @@ -193,90 +259,101 @@ bool CheckLightNameByCapabilities( const smart_objects::SmartObject& so = *it; const int64_t current_id = so[message_params::kName].asInt(); if (current_id == light_data[message_params::kId].asInt()) { - return CheckLightDataByCapabilities(so, light_data); + return GetLightDataCapabilities(so, light_data); } } LOG4CXX_DEBUG(logger_, "There is no such light name in capabilities"); - return false; -} - -bool CheckRadioBandByCapabilities( - const smart_objects::SmartObject& capabilities_status, - const smart_objects::SmartObject& request_parameter) { - mobile_apis::RadioBand::eType radio_band = - static_cast(request_parameter.asUInt()); - if (mobile_apis::RadioBand::XM == radio_band) { - if (!capabilities_status.keyExists(strings::kSiriusxmRadioAvailable)) { - LOG4CXX_DEBUG(logger_, - "Capability " - << strings::kSiriusxmRadioAvailable - << " is missed in RemoteControl capabilities"); - return false; - } - if (!capabilities_status[strings::kSiriusxmRadioAvailable].asBool()) { - LOG4CXX_DEBUG(logger_, - "Capability " - << strings::kSiriusxmRadioAvailable - << " is switched off in RemoteControl capabilities"); - return false; - } - } - return true; + return std::make_pair(message_params::kLightState, + capabilitiesStatus::missedLightName); } -bool CheckControlDataByCapabilities( - const smart_objects::SmartObject& capabilities_status, +/** + * @brief Check whether the exists light data related to correspondent + * capabilities + * @param smart object of capabilities + * @param smart object of control_data + * @return pair of state and capability status - ModuleCapability + */ +ModuleCapability GetControlDataCapabilities( + const smart_objects::SmartObject& capabilities, const smart_objects::SmartObject& control_data) { LOG4CXX_AUTO_TRACE(logger_); std::map mapping = GetModuleDataToCapabilitiesMapping(); - auto it = control_data.map_begin(); - for (; it != control_data.map_end(); ++it) { + + for (auto it = control_data.map_begin(); it != control_data.map_end(); ++it) { const std::string& request_parameter = it->first; if (message_params::kId == request_parameter) { continue; } if (message_params::kLightState == request_parameter) { auto light_data = control_data[request_parameter].asArray()->begin(); + ModuleCapability light_capability = + std::make_pair("", capabilitiesStatus::success); + for (; light_data != control_data[request_parameter].asArray()->end(); ++light_data) { - if (!CheckLightNameByCapabilities( - capabilities_status[strings::kSupportedLights], *light_data)) { - return false; + light_capability = GetLightNameCapabilities( + capabilities[strings::kSupportedLights], *light_data); + + if (capabilitiesStatus::success != light_capability.second) { + return light_capability; } } - return true; - } - const std::string& caps_key = mapping[request_parameter]; - LOG4CXX_DEBUG(logger_, - "Checking request parameter " - << request_parameter - << " with capabilities. Appropriate key is " << caps_key); - - if (!capabilities_status.keyExists(caps_key)) { - LOG4CXX_DEBUG(logger_, - "Capability " - << caps_key - << " is missed in RemoteControl capabilities"); - return false; + + return light_capability; } - if (!capabilities_status[caps_key].asBool()) { - LOG4CXX_DEBUG(logger_, - "Capability " - << caps_key - << " is switched off in RemoteControl capabilities"); - return false; + + const capabilitiesStatus status_item_capability = + GetItemCapability(capabilities[0], + mapping, + request_parameter, + mobile_apis::Result::UNSUPPORTED_RESOURCE); + + if (capabilitiesStatus::success != status_item_capability) { + return std::make_pair("", status_item_capability); } - if (message_params::kBand == request_parameter && - !CheckRadioBandByCapabilities(capabilities_status, - control_data[request_parameter])) { - return false; + } + + return std::make_pair("", capabilitiesStatus::success); +} + +/** + * @brief Check whether the exists hmi data related to correspondent + * capabilities + * @param smart object of capabilities + * @param smart object of control_data + * @return pair of state and capability status - ModuleCapability + */ +ModuleCapability GetHmiControlDataCapabilities( + const smart_objects::SmartObject& capabilities, + const smart_objects::SmartObject& control_data) { + LOG4CXX_AUTO_TRACE(logger_); + std::map mapping = + GetModuleDataToCapabilitiesMapping(); + + for (auto it = control_data.map_begin(); it != control_data.map_end(); ++it) { + const capabilitiesStatus status_item_capability = + GetItemCapability(capabilities, + mapping, + it->first, + mobile_apis::Result::UNSUPPORTED_RESOURCE); + + if (capabilitiesStatus::success != status_item_capability) { + return std::make_pair("", status_item_capability); } } - return true; + + return std::make_pair("", capabilitiesStatus::success); } -bool CheckIfModuleDataExistInCapabilities( +/** + * @brief Check whether rc module data capabilities are presented + * @param smart object of rc_capabilities + * @param smart object of module_data + * @return pair of state and capability status - ModuleCapability + */ +ModuleCapability GetModuleDataCapabilities( const smart_objects::SmartObject& rc_capabilities, const smart_objects::SmartObject& module_data) { LOG4CXX_AUTO_TRACE(logger_); @@ -285,29 +362,31 @@ bool CheckIfModuleDataExistInCapabilities( const auto& get_module_data_key = RCHelpers::GetModuleTypeToDataMapping(); const auto& get_capabilities_key = RCHelpers::GetModuleTypeToCapabilitiesMapping(); + ModuleCapability module_data_capabilities = + std::make_pair("", capabilitiesStatus::missedParam); - bool is_module_data_valid = false; for (const auto& module_type : all_module_types) { const auto module_data_key = get_module_data_key(module_type); const auto capabilities_key = get_capabilities_key(module_type); if (module_data.keyExists(module_data_key)) { if (!rc_capabilities.keyExists(capabilities_key)) { LOG4CXX_DEBUG(logger_, module_data_key << " capabilities not present"); - return false; + return module_data_capabilities; } const smart_objects::SmartObject& caps = rc_capabilities[capabilities_key]; - if (message_params::kHmiSettingsControlData == module_data_key || - message_params::kLightControlData == module_data_key) { - is_module_data_valid = - CheckControlDataByCapabilities(caps, module_data[module_data_key]); + + if (message_params::kHmiSettingsControlData == module_data_key) { + module_data_capabilities = + GetHmiControlDataCapabilities(caps, module_data[module_data_key]); } else { - is_module_data_valid = CheckControlDataByCapabilities( - caps[0], module_data[module_data_key]); + module_data_capabilities = + GetControlDataCapabilities(caps, module_data[module_data_key]); } } } - return is_module_data_valid; + + return module_data_capabilities; } bool isModuleTypeAndDataMatch(const std::string& module_type, @@ -325,6 +404,35 @@ bool isModuleTypeAndDataMatch(const std::string& module_type, return module_type_and_data_match; } +mobile_apis::Result::eType PrepareResultCodeAndInfo( + const ModuleCapability module_data_capabilities, std::string& info) { + mobile_apis::Result::eType result_code = + mobile_apis::Result::UNSUPPORTED_RESOURCE; + if (message_params::kLightState == module_data_capabilities.first) { + switch (module_data_capabilities.second) { + case capabilitiesStatus::missedLightName: + info = "The requested LightName is not supported by the vehicle."; + break; + case capabilitiesStatus::missedParam: + info = + "The requested parameter of the given LightName is not supported " + "by the vehicle."; + break; + case capabilitiesStatus::readOnly: + info = "The requested parameter is read-only."; + result_code = mobile_apis::Result::READ_ONLY; + break; + default: + break; + } + + } else { + info = "Accessing not supported module data."; + } + return result_code; + LOG4CXX_WARN(logger_, info); +} + void SetInteriorVehicleDataRequest::Execute() { LOG4CXX_AUTO_TRACE(logger_); @@ -335,15 +443,22 @@ void SetInteriorVehicleDataRequest::Execute() { if (isModuleTypeAndDataMatch(module_type, module_data)) { const smart_objects::SmartObject* rc_capabilities = hmi_capabilities_.rc_capability(); - if (rc_capabilities && - !CheckIfModuleDataExistInCapabilities(*rc_capabilities, module_data)) { - LOG4CXX_WARN(logger_, "Accessing not supported module data"); - SetResourceState(ModuleType(), ResourceState::FREE); - SendResponse(false, - mobile_apis::Result::UNSUPPORTED_RESOURCE, - "Accessing not supported module data"); - return; + ModuleCapability module_data_capabilities; + + if (rc_capabilities) { + module_data_capabilities = + GetModuleDataCapabilities(*rc_capabilities, module_data); + + if (capabilitiesStatus::success != module_data_capabilities.second) { + SetResourceState(ModuleType(), ResourceState::FREE); + std::string info; + mobile_apis::Result::eType result = + PrepareResultCodeAndInfo(module_data_capabilities, info); + SendResponse(false, result, info.c_str()); + return; + } } + if (AreAllParamsReadOnly(module_data)) { LOG4CXX_WARN(logger_, "All request params in module type are READ ONLY!"); SetResourceState(ModuleType(), ResourceState::FREE); @@ -352,11 +467,27 @@ void SetInteriorVehicleDataRequest::Execute() { "All request params in module type are READ ONLY!"); return; } - if (AreReadOnlyParamsPresent(module_data)) { + + module_data_capabilities = std::make_pair("", capabilitiesStatus::success); + + if (AreReadOnlyParamsPresent(module_data, module_data_capabilities)) { LOG4CXX_DEBUG(logger_, "Request module type has READ ONLY parameters"); + + if (enums_value::kLight == module_data_capabilities.first && + capabilitiesStatus::success != module_data_capabilities.second) { + SetResourceState(ModuleType(), ResourceState::FREE); + SendResponse( + false, + mobile_apis::Result::READ_ONLY, + "The LightStatus enum passed is READ ONLY and cannot be written."); + return; + } + LOG4CXX_DEBUG(logger_, "Cutting-off READ ONLY parameters... "); + CutOffReadOnlyParams(module_data); } + application_manager_.RemoveHMIFakeParameters(message_); app_mngr::ApplicationSharedPtr app = @@ -478,6 +609,8 @@ bool SetInteriorVehicleDataRequest::AreAllParamsReadOnly( return false; } } + + LOG4CXX_DEBUG(logger_, "All params are ReadOnly"); return true; } @@ -487,33 +620,84 @@ bool CheckReadOnlyParamsForAudio( const auto& equalizer_settings = module_type_params[message_params::kEqualizerSettings]; auto it = equalizer_settings.asArray()->begin(); + for (; it != equalizer_settings.asArray()->end(); ++it) { if (it->keyExists(message_params::kChannelName)) { LOG4CXX_DEBUG(logger_, - " READ ONLY parameter: " << message_params::kChannelName); + "READ ONLY parameter. ChannelName = " + << (*it)[message_params::kChannelName].asString()); return true; } } } + + return false; +} + +bool CheckReadOnlyParamsForLight( + const smart_objects::SmartObject& module_type_params) { + if (module_type_params.keyExists(message_params::kLightState)) { + const auto& light_state = module_type_params[message_params::kLightState]; + auto it = light_state.asArray()->begin(); + + for (; it != light_state.asArray()->end(); ++it) { + if (it->keyExists(message_params::kLightStatus)) { + const mobile_apis::LightStatus::eType light_status = + static_cast( + (*it)[message_params::kLightStatus].asUInt()); + + if (helpers::Compare(light_status, + mobile_apis::LightStatus::RAMP_UP, + mobile_apis::LightStatus::RAMP_DOWN, + mobile_apis::LightStatus::UNKNOWN, + mobile_apis::LightStatus::INVALID)) { + LOG4CXX_DEBUG(logger_, + "READ ONLY parameter. Status = " + << (*it)[message_params::kLightStatus].asInt()); + return true; + } + } + } + } + return false; } bool SetInteriorVehicleDataRequest::AreReadOnlyParamsPresent( - const smart_objects::SmartObject& module_data) { + const smart_objects::SmartObject& module_data, + ModuleCapability& module_data_capabilities) { LOG4CXX_AUTO_TRACE(logger_); const smart_objects::SmartObject& module_type_params = ControlData(module_data); - auto it = module_type_params.map_begin(); const std::string module_type = ModuleType(); - std::vector ro_params = GetModuleReadOnlyParams(module_type); + if (enums_value::kAudio == module_type) { return CheckReadOnlyParamsForAudio(module_type_params); } + + if (enums_value::kLight == module_type) { + const bool result = CheckReadOnlyParamsForLight(module_type_params); + + if (result) { + module_data_capabilities = + std::make_pair(module_type, capabilitiesStatus::readOnly); + } + + return result; + } + + const std::vector ro_params = + GetModuleReadOnlyParams(module_type); + auto it = module_type_params.map_begin(); + for (; it != module_type_params.map_end(); ++it) { if (helpers::in_range(ro_params, it->first)) { return true; } } + return false; } @@ -529,11 +713,13 @@ void SetInteriorVehicleDataRequest::CutOffReadOnlyParams( if (module_type_params.keyExists(it)) { if (enums_value::kClimate == module_type) { module_data[message_params::kClimateControlData].erase(it); - LOG4CXX_DEBUG(logger_, "Cutting-off READ ONLY parameter: " << it); } else if (enums_value::kRadio == module_type) { module_data[message_params::kRadioControlData].erase(it); - LOG4CXX_DEBUG(logger_, "Cutting-off READ ONLY parameter: " << it); + } else { + continue; } + + LOG4CXX_DEBUG(logger_, "Cutting-off READ ONLY parameter: " << it); } } -- cgit v1.2.1 From 06aab6afd823d2960f22dd8ad2fba5e9a83a07d3 Mon Sep 17 00:00:00 2001 From: JackLivio Date: Wed, 22 Aug 2018 14:33:43 -0400 Subject: Add play_pause to hmi_capabilities test file --- src/components/application_manager/test/hmi_capabilities.json | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/components/application_manager/test/hmi_capabilities.json b/src/components/application_manager/test/hmi_capabilities.json index 1c024f2669..ca67d81d8c 100644 --- a/src/components/application_manager/test/hmi_capabilities.json +++ b/src/components/application_manager/test/hmi_capabilities.json @@ -683,6 +683,12 @@ "longPressAvailable": true, "upDownAvailable": true }, + { + "name": "PLAY_PAUSE", + "shortPressAvailable": true, + "longPressAvailable": true, + "upDownAvailable": true + }, { "name": "SEEKLEFT", "shortPressAvailable": true, -- cgit v1.2.1 From 2f291580c61af8198597c2bd5863c2efe253a7f6 Mon Sep 17 00:00:00 2001 From: Alexander Date: Thu, 23 Aug 2018 12:16:21 +0300 Subject: Do not send HMI level NONE in RC disabled --- .../commands/hmi/rc_on_remote_control_settings_notification.cc | 8 -------- 1 file changed, 8 deletions(-) diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_on_remote_control_settings_notification.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_on_remote_control_settings_notification.cc index b67e3e2553..91cb6cb7ee 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_on_remote_control_settings_notification.cc +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_on_remote_control_settings_notification.cc @@ -89,14 +89,6 @@ std::string AccessModeToString( void RCOnRemoteControlSettingsNotification::DisallowRCFunctionality() { LOG4CXX_AUTO_TRACE(logger_); - typedef std::vector Apps; - Apps apps = RCRPCPlugin::GetRCApplications(application_manager_); - for (Apps::iterator it = apps.begin(); it != apps.end(); ++it) { - application_manager::ApplicationSharedPtr app = *it; - DCHECK(app); - application_manager_.ChangeAppsHMILevel( - app->app_id(), mobile_apis::HMILevel::eType::HMI_NONE); - } interior_data_manager_.OnDisablingRC(); } -- cgit v1.2.1 From 07316fedaa20d88790ee2c6ce99e97673b23ef00 Mon Sep 17 00:00:00 2001 From: Alexander Date: Thu, 23 Aug 2018 12:35:59 +0300 Subject: Fix unit tests --- .../test/commands/on_remote_control_settings_test.cc | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/on_remote_control_settings_test.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/on_remote_control_settings_test.cc index 164623d926..8a078d4e21 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/on_remote_control_settings_test.cc +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/on_remote_control_settings_test.cc @@ -139,22 +139,9 @@ TEST_F(RCOnRemoteControlSettingsNotificationTest, (*mobile_message)[application_manager::strings::msg_params] [message_params::kAllowed] = false; - ApplicationSet app_set = {mock_app_}; - - std::shared_ptr apps_lock = - std::make_shared(); - DataAccessor accessor(app_set, apps_lock); - // Expectations - EXPECT_CALL(app_mngr_, applications()).WillOnce(Return(accessor)); - - RCAppExtensionPtr rc_extention_ptr = - std::make_shared(application_manager::AppExtensionUID( - rc_rpc_plugin::RCRPCPlugin::kRCPluginID)); - rc_extention_ptr->SubscribeToInteriorVehicleData(enums_value::kClimate); - ON_CALL(*mock_app_, QueryInterface(_)) - .WillByDefault(Return(rc_extention_ptr)); EXPECT_CALL(mock_allocation_manager_, ResetAllAllocations()); + EXPECT_CALL(mock_interior_data_manager_, OnDisablingRC()); // Act std::shared_ptr< -- cgit v1.2.1 From 370c752cc6f7c27845c129c73a41d069323055f1 Mon Sep 17 00:00:00 2001 From: jacobkeeler Date: Wed, 22 Aug 2018 21:43:02 -0400 Subject: Fix build failures after merge --- .../include/rc_rpc_plugin/interior_data_manager_impl.h | 2 +- .../rpc_plugins/rc_rpc_plugin/src/interior_data_manager_impl.cc | 9 ++++----- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/interior_data_manager_impl.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/interior_data_manager_impl.h index b36f47f260..9b16a2c4da 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/interior_data_manager_impl.h +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/interior_data_manager_impl.h @@ -107,7 +107,7 @@ class InteriorDataManagerImpl : public InteriorDataManager { * @brief RequestsToHMIHistory mapping from module type to vector of time * stamps */ - typedef std::map > + typedef std::map > RequestsToHMIHistory; RequestsToHMIHistory requests_to_hmi_history_; mutable sync_primitives::Lock requests_to_hmi_history_lock_; diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/interior_data_manager_impl.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/interior_data_manager_impl.cc index 28ed2cd941..0c42f6e3de 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/interior_data_manager_impl.cc +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/interior_data_manager_impl.cc @@ -52,8 +52,7 @@ void InteriorDataManagerImpl::StoreRequestToHMITime( const std::string& module_type) { LOG4CXX_AUTO_TRACE(logger_); sync_primitives::AutoLock autolock(requests_to_hmi_history_lock_); - requests_to_hmi_history_[module_type].push_back( - date_time::DateTime::getCurrentTime()); + requests_to_hmi_history_[module_type].push_back(date_time::getCurrentTime()); } bool InteriorDataManagerImpl::CheckRequestsToHMIFrequency( @@ -129,9 +128,9 @@ void InteriorDataManagerImpl::UnsubscribeFromInteriorVehicleData( void InteriorDataManagerImpl::ClearOldRequestsToHMIHistory() { auto limit = app_mngr_.get_settings().get_interior_vehicle_data_frequency().second; - uint32_t time_frame = limit * date_time::DateTime::MILLISECONDS_IN_SECOND; - auto lest_that_time_frame_ago = [time_frame](TimevalStruct time) { - auto span = date_time::DateTime::calculateTimeSpan(time); + uint32_t time_frame = limit * date_time::MILLISECONDS_IN_SECOND; + auto lest_that_time_frame_ago = [time_frame](date_time::TimeDuration time) { + auto span = date_time::calculateTimeSpan(time); return span < time_frame; }; for (auto& it : requests_to_hmi_history_) { -- cgit v1.2.1 From 82e1657c140951da1f11da06c26075c2ed1e6a01 Mon Sep 17 00:00:00 2001 From: JackLivio Date: Thu, 23 Aug 2018 10:03:11 -0400 Subject: =?UTF-8?q?Update=20fullAppID=20to=20mandatory=3D=E2=80=9Cfalse?= =?UTF-8?q?=E2=80=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/interfaces/MOBILE_API.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/interfaces/MOBILE_API.xml b/src/components/interfaces/MOBILE_API.xml index 7ca2c66a66..f2c05d99be 100644 --- a/src/components/interfaces/MOBILE_API.xml +++ b/src/components/interfaces/MOBILE_API.xml @@ -3738,7 +3738,7 @@ ID used to validate app with policy table entries - + ID used to validate app with policy table entries -- cgit v1.2.1 From e8328052350e3feba10b5209cb7553ef4234562a Mon Sep 17 00:00:00 2001 From: JackLivio Date: Thu, 23 Aug 2018 10:48:17 -0400 Subject: Check style --- .../policy/policy_regular/test/policy_manager_impl_test.cc | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/components/policy/policy_regular/test/policy_manager_impl_test.cc b/src/components/policy/policy_regular/test/policy_manager_impl_test.cc index f1bb42c69c..9b38bc3be8 100644 --- a/src/components/policy/policy_regular/test/policy_manager_impl_test.cc +++ b/src/components/policy/policy_regular/test/policy_manager_impl_test.cc @@ -202,8 +202,7 @@ class PolicyManagerImplTest2 : public ::testing::Test { manager = new PolicyManagerImpl(); ON_CALL(policy_settings_, app_storage_folder()) .WillByDefault(ReturnRef(kAppStorageFolder)); - ON_CALL(policy_settings_, use_full_app_id()) - .WillByDefault(Return(true)); + ON_CALL(policy_settings_, use_full_app_id()).WillByDefault(Return(true)); manager->set_listener(&listener); const char* levels[] = {"BACKGROUND", "FULL", "LIMITED", "NONE"}; hmi_level.assign(levels, levels + sizeof(levels) / sizeof(levels[0])); @@ -240,8 +239,7 @@ class PolicyManagerImplTest2 : public ::testing::Test { file_system::remove_directory_content(kAppStorageFolder); ON_CALL(policy_settings_, app_storage_folder()) .WillByDefault(ReturnRef(kAppStorageFolder)); - ON_CALL(policy_settings_, use_full_app_id()) - .WillByDefault(Return(true)); + ON_CALL(policy_settings_, use_full_app_id()).WillByDefault(Return(true)); ASSERT_TRUE(manager->InitPT(file_name, &policy_settings_)); } -- cgit v1.2.1 From 8830f6f03923a7f6d2c31782d66d87e6b16582fc Mon Sep 17 00:00:00 2001 From: Jacob Keeler Date: Thu, 23 Aug 2018 18:28:40 -0400 Subject: Fix style --- .../rc_rpc_plugin/test/commands/on_remote_control_settings_test.cc | 1 - 1 file changed, 1 deletion(-) diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/on_remote_control_settings_test.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/on_remote_control_settings_test.cc index 8a078d4e21..b95725e0b4 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/on_remote_control_settings_test.cc +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/on_remote_control_settings_test.cc @@ -139,7 +139,6 @@ TEST_F(RCOnRemoteControlSettingsNotificationTest, (*mobile_message)[application_manager::strings::msg_params] [message_params::kAllowed] = false; - EXPECT_CALL(mock_allocation_manager_, ResetAllAllocations()); EXPECT_CALL(mock_interior_data_manager_, OnDisablingRC()); -- cgit v1.2.1 From 76908e6f7a387d294d0cc85d131f801b46035a7e Mon Sep 17 00:00:00 2001 From: JackLivio Date: Thu, 23 Aug 2018 20:19:28 -0400 Subject: Add version Logic for play_pause and ok --- .../mobile/on_button_event_notification.cc | 12 ++++- .../mobile/on_button_press_notification.cc | 13 ++++- .../mobile/register_app_interface_response.cc | 40 ++++++++++++-- .../commands/mobile/subscribe_button_request.cc | 18 ++++++- .../commands/mobile/unsubscribe_button_request.cc | 18 ++++++- .../mobile/subscribe_button_request_test.cc | 61 ++++++++++++++++++++++ .../mobile/unsubscribe_button_request_test.cc | 51 ++++++++++++++++++ src/components/include/utils/semantic_version.h | 3 ++ src/components/utils/src/semantic_version.cc | 38 ++++++++++++++ 9 files changed, 242 insertions(+), 12 deletions(-) create mode 100644 src/components/utils/src/semantic_version.cc diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_button_event_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_button_event_notification.cc index 40debbcd4d..aeb53a115e 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_button_event_notification.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_button_event_notification.cc @@ -161,8 +161,16 @@ void OnButtonEventNotification::SendButtonEvent(ApplicationConstSharedPtr app) { (*on_btn_event)[strings::params][strings::function_id] = static_cast(mobile_apis::FunctionID::eType::OnButtonEventID); - (*on_btn_event)[strings::msg_params][strings::button_name] = - (*message_)[strings::msg_params][hmi_response::button_name]; + mobile_apis::ButtonName::eType btn_id = + static_cast( + (*message_)[strings::msg_params][hmi_response::button_name].asInt()); + + if (btn_id == mobile_apis::ButtonName::PLAY_PAUSE && + app->msg_version() <= utils::version_4_5) { + btn_id = mobile_apis::ButtonName::OK; + } + + (*on_btn_event)[strings::msg_params][strings::button_name] = btn_id; (*on_btn_event)[strings::msg_params][strings::button_event_mode] = (*message_)[strings::msg_params][hmi_response::button_mode]; diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_button_press_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_button_press_notification.cc index faf6ffe38b..56a87da305 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_button_press_notification.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_button_press_notification.cc @@ -35,6 +35,7 @@ #include "application_manager/application_impl.h" #include "interfaces/MOBILE_API.h" +#include "utils/semantic_version.h" namespace sdl_rpc_plugin { using namespace application_manager; @@ -168,8 +169,16 @@ void OnButtonPressNotification::SendButtonPress(ApplicationConstSharedPtr app) { (*on_btn_press)[strings::params][strings::function_id] = static_cast(mobile_apis::FunctionID::eType::OnButtonPressID); - (*on_btn_press)[strings::msg_params][strings::button_name] = - (*message_)[strings::msg_params][hmi_response::button_name]; + mobile_apis::ButtonName::eType btn_id = + static_cast( + (*message_)[strings::msg_params][hmi_response::button_name].asInt()); + + if (btn_id == mobile_apis::ButtonName::PLAY_PAUSE && + app->msg_version() <= utils::version_4_5) { + btn_id = mobile_apis::ButtonName::OK; + } + + (*on_btn_press)[strings::msg_params][strings::button_name] = btn_id; (*on_btn_press)[strings::msg_params][strings::button_press_mode] = (*message_)[strings::msg_params][hmi_response::button_mode]; diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/register_app_interface_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/register_app_interface_response.cc index 73b38823d8..31eb738357 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/register_app_interface_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/register_app_interface_response.cc @@ -60,6 +60,40 @@ void RegisterAppInterfaceResponse::Run() { } } + application_manager::ApplicationSharedPtr app = + application_manager_.application(connection_key()); + + if (app && app->msg_version() <= utils::version_4_5 && + app->is_media_application() && + (*message_)[strings::msg_params].keyExists( + hmi_response::button_capabilities)) { + const smart_objects::SmartObject& button_caps = + (*message_)[strings::msg_params][hmi_response::button_capabilities]; + auto it = button_caps.asArray()->begin(); + auto ok_btn_it = it; + bool ok_btn_exists = false; + bool play_pause_btn_exists = false; + for (; it != button_caps.asArray()->end(); ++it) { + smart_objects::SmartObject& so = *it; + int64_t current_id = so[strings::name].asInt(); + if (current_id == -1) { + continue; + } + const mobile_apis::ButtonName::eType current_button = + static_cast(current_id); + if (current_button == mobile_apis::ButtonName::PLAY_PAUSE) { + play_pause_btn_exists = true; + so[strings::name] = mobile_apis::ButtonName::OK; + } else if (current_button == mobile_apis::ButtonName::OK) { + ok_btn_exists = true; + ok_btn_it = it; + } + } + if (ok_btn_exists && play_pause_btn_exists) { + button_caps.asArray()->erase(ok_btn_it); + } + } + SendResponse(success, result_code, last_message); if (mobile_apis::Result::SUCCESS != result_code) { @@ -68,16 +102,14 @@ void RegisterAppInterfaceResponse::Run() { // Add registered application to the policy db right after response sent to // mobile to be able to check all other API according to app permissions - application_manager::ApplicationSharedPtr application = - application_manager_.application(connection_key()); - if (!application) { + if (!app) { LOG4CXX_ERROR(logger_, "Application with connection key " << connection_key() << " is not registered."); return; } - SetHeartBeatTimeout(connection_key(), application->policy_app_id()); + SetHeartBeatTimeout(connection_key(), app->policy_app_id()); } void RegisterAppInterfaceResponse::SetHeartBeatTimeout( diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/subscribe_button_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/subscribe_button_request.cc index 5afa0302b7..85cb26321b 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/subscribe_button_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/subscribe_button_request.cc @@ -32,6 +32,7 @@ */ #include "sdl_rpc_plugin/commands/mobile/subscribe_button_request.h" +#include "utils/semantic_version.h" namespace sdl_rpc_plugin { using namespace application_manager; @@ -65,7 +66,7 @@ void SubscribeButtonRequest::Run() { return; } - const mobile_apis::ButtonName::eType btn_id = + mobile_apis::ButtonName::eType btn_id = static_cast( (*message_)[str::msg_params][str::button_name].asInt()); @@ -76,7 +77,20 @@ void SubscribeButtonRequest::Run() { return; } - if (!CheckHMICapabilities(btn_id)) { + if (app->msg_version() <= utils::version_4_5 && + btn_id == mobile_apis::ButtonName::OK && app->is_media_application()) { + bool ok_supported = CheckHMICapabilities(mobile_apis::ButtonName::OK); + bool play_pause_supported = + CheckHMICapabilities(mobile_apis::ButtonName::PLAY_PAUSE); + if (play_pause_supported) { + LOG4CXX_DEBUG(logger_, "Converting Legacy OK button to PLAY_PAUSE"); + btn_id = mobile_apis::ButtonName::PLAY_PAUSE; + (*message_)[str::msg_params][str::button_name] = btn_id; + } else if (!ok_supported) { + LOG4CXX_ERROR(logger_, "OK button isn't allowed by HMI capabilities"); + SendResponse(false, mobile_apis::Result::UNSUPPORTED_RESOURCE); + } + } else if (!CheckHMICapabilities(btn_id)) { LOG4CXX_ERROR(logger_, "Subscribe on button " << btn_id << " isn't allowed by HMI capabilities"); diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/unsubscribe_button_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/unsubscribe_button_request.cc index 6537f0e7b2..ccfaef54cb 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/unsubscribe_button_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/unsubscribe_button_request.cc @@ -34,6 +34,7 @@ #include "sdl_rpc_plugin/commands/mobile/unsubscribe_button_request.h" #include "application_manager/application_impl.h" +#include "utils/semantic_version.h" namespace sdl_rpc_plugin { using namespace application_manager; @@ -67,11 +68,24 @@ void UnsubscribeButtonRequest::Run() { return; } - const mobile_apis::ButtonName::eType btn_id = + mobile_apis::ButtonName::eType btn_id = static_cast( (*message_)[str::msg_params][str::button_name].asInt()); - if (!CheckHMICapabilities(btn_id)) { + if (app->msg_version() <= utils::version_4_5 && + btn_id == mobile_apis::ButtonName::OK && app->is_media_application()) { + bool ok_supported = CheckHMICapabilities(mobile_apis::ButtonName::OK); + bool play_pause_supported = + CheckHMICapabilities(mobile_apis::ButtonName::PLAY_PAUSE); + if (play_pause_supported) { + LOG4CXX_DEBUG(logger_, "Converting Legacy OK button to PLAY_PAUSE"); + btn_id = mobile_apis::ButtonName::PLAY_PAUSE; + (*message_)[str::msg_params][str::button_name] = btn_id; + } else if (!ok_supported) { + LOG4CXX_ERROR(logger_, "OK button isn't allowed by HMI capabilities"); + SendResponse(false, mobile_apis::Result::UNSUPPORTED_RESOURCE); + } + } else if (!CheckHMICapabilities(btn_id)) { LOG4CXX_ERROR(logger_, "Button " << btn_id << " isn't allowed by HMI capabilities"); SendResponse(false, mobile_apis::Result::UNSUPPORTED_RESOURCE); diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/subscribe_button_request_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/subscribe_button_request_test.cc index bbc18504a6..0196b59b79 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/subscribe_button_request_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/subscribe_button_request_test.cc @@ -73,6 +73,8 @@ class SubscribeButtonRequestTest }; typedef SubscribeButtonRequestTest::MockHMICapabilities MockHMICapabilities; +const utils::SemanticVersion mock_semantic_version(5, 0, 0); +const utils::SemanticVersion mock_semantic_version_4_5(4, 5, 0); TEST_F(SubscribeButtonRequestTest, Run_AppNotRegistered_UNSUCCESS) { CommandPtr command(CreateCommand()); @@ -110,6 +112,9 @@ TEST_F(SubscribeButtonRequestTest, Run_UiIsNotSupported_UNSUCCESS) { MockAppPtr app(CreateMockApp()); ON_CALL(app_mngr_, application(_)).WillByDefault(Return(app)); + ON_CALL(*app, msg_version()).WillByDefault(ReturnRef(mock_semantic_version)); + ON_CALL(*app, is_media_application()).WillByDefault(Return(false)); + ON_CALL(mock_hmi_capabilities_, is_ui_cooperating()) .WillByDefault(Return(false)); @@ -130,6 +135,7 @@ TEST_F(SubscribeButtonRequestTest, Run_IsSubscribedToButton_UNSUCCESS) { MockAppPtr app(CreateMockApp()); ON_CALL(app_mngr_, application(_)).WillByDefault(Return(app)); + ON_CALL(*app, msg_version()).WillByDefault(ReturnRef(mock_semantic_version)); ON_CALL(*app, is_media_application()).WillByDefault(Return(true)); ON_CALL(mock_hmi_capabilities_, is_ui_cooperating()) @@ -160,6 +166,7 @@ TEST_F(SubscribeButtonRequestTest, Run_SUCCESS) { MockAppPtr app(CreateMockApp()); ON_CALL(app_mngr_, application(_)).WillByDefault(Return(app)); + ON_CALL(*app, msg_version()).WillByDefault(ReturnRef(mock_semantic_version)); ON_CALL(*app, is_media_application()).WillByDefault(Return(true)); ON_CALL(mock_hmi_capabilities_, is_ui_cooperating()) @@ -195,6 +202,60 @@ TEST_F(SubscribeButtonRequestTest, Run_SUCCESS) { [am::strings::result_code].asInt())); } +TEST_F(SubscribeButtonRequestTest, Run_SUCCESS_App_Version_4_5) { + const mobile_apis::ButtonName::eType kButtonName = + mobile_apis::ButtonName::OK; + + MessageSharedPtr msg(CreateMessage()); + (*msg)[am::strings::msg_params][am::strings::button_name] = kButtonName; + CommandPtr command(CreateCommand(msg)); + + MockAppPtr app(CreateMockApp()); + ON_CALL(app_mngr_, application(_)).WillByDefault(Return(app)); + ON_CALL(*app, msg_version()) + .WillByDefault(ReturnRef(mock_semantic_version_4_5)); + ON_CALL(*app, is_media_application()).WillByDefault(Return(true)); + + ON_CALL(mock_hmi_capabilities_, is_ui_cooperating()) + .WillByDefault(Return(true)); + + MessageSharedPtr button_caps_ptr(CreateMessage(smart_objects::SmartType_Map)); + (*button_caps_ptr)[0][am::hmi_response::button_name] = kButtonName; + (*button_caps_ptr)[1][am::hmi_response::button_name] = + mobile_apis::ButtonName::PLAY_PAUSE; + + ON_CALL(mock_hmi_capabilities_, button_capabilities()) + .WillByDefault(Return(button_caps_ptr.get())); + + ON_CALL(*app, IsSubscribedToButton(_)).WillByDefault(Return(false)); + + MessageSharedPtr hmi_result_msg; + + EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_)) + .WillOnce(DoAll(SaveArg<0>(&hmi_result_msg), Return(true))); + + MessageSharedPtr mobile_result_msg; + EXPECT_CALL(this->mock_rpc_service_, ManageMobileCommand(_, _)) + .WillOnce(DoAll(SaveArg<0>(&mobile_result_msg), Return(true))); + ASSERT_TRUE(command->Init()); + command->Run(); + + EXPECT_EQ(hmi_apis::FunctionID::Buttons_OnButtonSubscription, + static_cast( + (*hmi_result_msg)[am::strings::params][am::strings::function_id] + .asInt())); + + EXPECT_EQ(hmi_apis::Common_ButtonName::PLAY_PAUSE, + static_cast( + (*hmi_result_msg)[am::strings::msg_params][am::strings::name] + .asInt())); + + EXPECT_EQ(mobile_apis::Result::SUCCESS, + static_cast( + (*mobile_result_msg)[am::strings::msg_params] + [am::strings::result_code].asInt())); +} + } // namespace subscribe_button_request } // namespace mobile_commands_test } // namespace commands_test diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/unsubscribe_button_request_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/unsubscribe_button_request_test.cc index e363567c64..d6bef42794 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/unsubscribe_button_request_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/unsubscribe_button_request_test.cc @@ -28,6 +28,8 @@ typedef std::shared_ptr CommandPtr; namespace { const uint32_t kConnectionKey = 1u; const mobile_apis::ButtonName::eType kButtonId = mobile_apis::ButtonName::OK; +const utils::SemanticVersion mock_semantic_version(5, 0, 0); +const utils::SemanticVersion mock_semantic_version_4_5(4, 5, 0); } // namespace class UnsubscribeButtonRequestTest @@ -73,6 +75,8 @@ TEST_F(UnsubscribeButtonRequestTest, MockAppPtr mock_app(CreateMockApp()); EXPECT_CALL(app_mngr_, application(kConnectionKey)) .WillOnce(Return(mock_app)); + ON_CALL(*mock_app, msg_version()) + .WillByDefault(ReturnRef(mock_semantic_version)); EXPECT_CALL(*mock_app, UnsubscribeFromButton(kButtonId)) .WillOnce(Return(false)); @@ -94,6 +98,8 @@ TEST_F(UnsubscribeButtonRequestTest, MockAppPtr mock_app(CreateMockApp()); EXPECT_CALL(app_mngr_, application(kConnectionKey)) .WillOnce(Return(mock_app)); + ON_CALL(*mock_app, msg_version()) + .WillByDefault(ReturnRef(mock_semantic_version)); EXPECT_CALL(mock_hmi_capabilities_, is_ui_cooperating()) .WillOnce(Return(true)); @@ -128,6 +134,8 @@ TEST_F(UnsubscribeButtonRequestTest, Run_SUCCESS) { MockAppPtr mock_app(CreateMockApp()); EXPECT_CALL(app_mngr_, application(kConnectionKey)) .WillRepeatedly(Return(mock_app)); + ON_CALL(*mock_app, msg_version()) + .WillByDefault(ReturnRef(mock_semantic_version)); EXPECT_CALL(*mock_app, UnsubscribeFromButton(kButtonId)) .WillOnce(Return(true)); @@ -143,6 +151,49 @@ TEST_F(UnsubscribeButtonRequestTest, Run_SUCCESS) { command->Run(); } +TEST_F(UnsubscribeButtonRequestTest, Run_SUCCESS_Version_4_5) { + MessageSharedPtr command_msg(CreateMessage(smart_objects::SmartType_Map)); + (*command_msg)[am::strings::params][am::strings::connection_key] = + kConnectionKey; + (*command_msg)[am::strings::msg_params][am::strings::button_name] = + mobile_apis::ButtonName::OK; + + CommandPtr command(CreateCommand(command_msg)); + + EXPECT_CALL(mock_hmi_capabilities_, is_ui_cooperating()) + .WillRepeatedly(Return(true)); + + MessageSharedPtr button_caps_ptr(CreateMessage(smart_objects::SmartType_Map)); + (*button_caps_ptr)[0][am::hmi_response::button_name] = + mobile_apis::ButtonName::OK; + (*button_caps_ptr)[1][am::hmi_response::button_name] = + mobile_apis::ButtonName::PLAY_PAUSE; + + EXPECT_CALL(mock_hmi_capabilities_, button_capabilities()) + .WillRepeatedly(Return(button_caps_ptr.get())); + + MockAppPtr mock_app(CreateMockApp()); + EXPECT_CALL(app_mngr_, application(kConnectionKey)) + .WillRepeatedly(Return(mock_app)); + ON_CALL(*mock_app, msg_version()) + .WillByDefault(ReturnRef(mock_semantic_version_4_5)); + ON_CALL(*mock_app, is_media_application()).WillByDefault(Return(true)); + + EXPECT_CALL(*mock_app, + UnsubscribeFromButton(mobile_apis::ButtonName::PLAY_PAUSE)) + .WillOnce(Return(true)); + EXPECT_CALL(mock_rpc_service_, + ManageHMICommand(HMIResultCodeIs( + hmi_apis::FunctionID::Buttons_OnButtonSubscription))); + EXPECT_CALL( + mock_rpc_service_, + ManageMobileCommand(MobileResultCodeIs(mobile_result::SUCCESS), _)); + + EXPECT_CALL(*mock_app, UpdateHash()); + command->Init(); + command->Run(); +} + } // namespace unsubscribe_button_request } // namespace mobile_commands_test } // namespace commands_test diff --git a/src/components/include/utils/semantic_version.h b/src/components/include/utils/semantic_version.h index 7b9ec0eb96..244ae82177 100644 --- a/src/components/include/utils/semantic_version.h +++ b/src/components/include/utils/semantic_version.h @@ -33,6 +33,7 @@ #ifndef SRC_COMPONENTS_INCLUDE_UTILS_SEMANTIC_VERSION_H_ #define SRC_COMPONENTS_INCLUDE_UTILS_SEMANTIC_VERSION_H_ +#include namespace utils { struct SemanticVersion { @@ -116,6 +117,8 @@ struct SemanticVersion { uint16_t minor_version_ = 0; uint16_t patch_version_ = 0; }; + +extern const SemanticVersion version_4_5; } #endif // SRC_COMPONENTS_INCLUDE_UTILS_CALLABLE_H \ No newline at end of file diff --git a/src/components/utils/src/semantic_version.cc b/src/components/utils/src/semantic_version.cc new file mode 100644 index 0000000000..4b8d37b913 --- /dev/null +++ b/src/components/utils/src/semantic_version.cc @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2018, 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 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 "utils/semantic_version.h" + +namespace utils { + +const SemanticVersion version_4_5(4, 5, 0); + +} // namespace utils \ No newline at end of file -- cgit v1.2.1 From faab06e696895db3222ad2314ad2640a1ade231c Mon Sep 17 00:00:00 2001 From: JackLivio Date: Fri, 24 Aug 2018 14:35:12 -0400 Subject: Update mobile api to include description --- src/components/interfaces/MOBILE_API.xml | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/components/interfaces/MOBILE_API.xml b/src/components/interfaces/MOBILE_API.xml index de9580e67f..0d04b290b2 100644 --- a/src/components/interfaces/MOBILE_API.xml +++ b/src/components/interfaces/MOBILE_API.xml @@ -562,7 +562,16 @@ Defines the hard (physical) and soft (touchscreen) buttons available from the module - + + + The button name for the physical Play/Pause + toggle that can be used by media apps. + + + Please use the physical OK button in order to + use a Play/Pause toggle for versions < 4.5.0. + + -- cgit v1.2.1 From 3a7369da0bdc28c9d3537582e138bdcb82956f65 Mon Sep 17 00:00:00 2001 From: JackLivio Date: Fri, 24 Aug 2018 15:52:31 -0400 Subject: Revert Cmake Changes --- CMakeLists.txt | 620 +++++++++++++++++++-------------------------------------- 1 file changed, 201 insertions(+), 419 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9b2b200d20..806580030f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -28,14 +28,17 @@ # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # POSSIBILITY OF SUCH DAMAGE. -cmake_minimum_required(VERSION 2.8.0) +cmake_minimum_required(VERSION 2.8.11) set (PROJECT smartDeviceLinkCore) +project (${PROJECT}) +set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/tools/cmake/modules/") + +include(${CMAKE_SOURCE_DIR}/tools/cmake/helpers/platform.cmake) #Jenkins integration section #dont modify this section if you dont know details about integration with Jenkins!!! set (HMI "web" CACHE STRING "HMI type") -option(HMI2 "Use Qt HMI" OFF) option(EXTENDED_MEDIA_MODE "Turn on and off extended Madia Manager features relates to PulseAudio A2DP and GStreamer" OFF) option(BUILD_SHARED_LIBS "Build all libraries as shared (if ON) or static (if OFF)" OFF) option(BUILD_BT_SUPPORT "Bluetooth support" ON) @@ -48,44 +51,49 @@ option(ENABLE_GCOV "gcov code coverage feature" OFF) option(ENABLE_SANITIZE "Sanitize tool" OFF) option(ENABLE_SECURITY "Security Ford protocol protection" ON) option(ENABLE_HMI_PTU_DECRYPTION "Policy table update parsed by hmi" ON) -option(ENABLE_EXTENDED_POLICY "Turns extended flow which requires embedded system interaction" ON) - -set(OS_TYPE_OPTION "$ENV{OS_TYPE}") -set(DEBUG_OPTION "$ENV{DEBUG}") -set(HMI_TYPE_OPTION "$ENV{HMI_TYPE}") -set(TARGET_OPTION "$ENV{TARGET}") -set(MEDIA_MODE_OPTION "$ENV{MEDIA_MODE}") -set(HMI_ADAPTER_OPTION "$ENV{HMI_ADAPTER}") +option(USE_COTIRE "Use Cotire to speed up build (currently only for commands tests)" ON) +option(USE_GOLD_LD "Use gold linker intead of GNU linker" ON) +option(USE_CCACHE "Turn on ccache usage" ON) +option(USE_DISTCC "Turn on distributed build_usage" OFF) + +set (EXTENDED_POLICY "PROPRIETARY" CACHE STRING "Policy mode (PROPRIETARY, HTTP or EXTERNAL_PROPRIETARY)") +set_property(CACHE EXTENDED_POLICY PROPERTY STRINGS PROPRIETARY HTTP EXTERNAL_PROPRIETARY) +if(EXTENDED_POLICY STREQUAL "") + set(EXTENDED_POLICY "PROPRIETARY") +endif() + +set(OS_TYPE_OPTION "$ENV{OS_TYPE}") +set(HMI_TYPE_OPTION "$ENV{HMI_TYPE}") +set(TARGET_OPTION "$ENV{TARGET}") +set(MEDIA_MODE_OPTION "$ENV{MEDIA_MODE}") +set(HMI_ADAPTER_OPTION "$ENV{HMI_ADAPTER}") set(ENABLE_TESTS_OPTION "$ENV{ENABLE_TESTS}") -set(ENABLE_LOG_OPTION "$ENV{ENABLE_LOG}") -set(ARCH_TYPE_OPTION "$ENV{ARCH_TYPE}") -set(POLICY_OPTION "$ENV{POLICY_TYPE}") -set(SECURITY_OPTION "$ENV{SECURITY_MODE}") +set(ENABLE_LOG_OPTION "$ENV{ENABLE_LOG}") +set(ARCH_TYPE_OPTION "$ENV{ARCH_TYPE}") +set(POLICY_OPTION "$ENV{POLICY_TYPE}") +set(SECURITY_OPTION "$ENV{SECURITY_MODE}") set(COMPONENTS_DIR ${CMAKE_SOURCE_DIR}/src/components) -set(SNAPSHOT_TAG "$ENV{SNAPSHOT_TAG}") - +set(SNAPSHOT_TAG "$ENV{SNAPSHOT_TAG}") set(CMAKE_CXX_COMPILER $ENV{CMAKE_CXX_COMPILER}) set(CMAKE_C_COMPILER $ENV{CMAKE_C_COMPILER}) +set(BUILDDIR "$ENV{BUILDDIR}") if (ARCH_TYPE_OPTION) if (NOT (${ARCH_TYPE_OPTION} STREQUAL "x86") AND NOT (${ARCH_TYPE_OPTION} STREQUAL "armv7")) message(AUTHOR_WARNING "HW architecture is not defined, using x86. Allowed values are x86/armv7 (case sensitive)") - set(ARCH_TYPE_OPTION "x86") + set(ARCH_TYPE_OPTION "x86") endif () else () - set(ARCH_TYPE_OPTION "x86") + set(ARCH_TYPE_OPTION "x86") endif() if (HMI_TYPE_OPTION) - if (${HMI_TYPE_OPTION} STREQUAL "HTML5") - message(STATUS "Jenkins integration: select HTML5 HMI") - set (HMI "web") - elseif (${HMI_TYPE_OPTION} STREQUAL "NONE") + if (${HMI_TYPE_OPTION} STREQUAL "NONE") message(STATUS "Jenkins integration: select HMI none") set (HMI "no") else () - message(STATUS "Jenkins integration: select QML HMI none") - set (HMI "qt") + message(STATUS "Jenkins integration: select HTML5 HMI") + set (HMI "web") endif() endif() @@ -96,23 +104,14 @@ if (MEDIA_MODE_OPTION) endif() endif() -if (DEBUG_OPTION) - if (${DEBUG_OPTION} STREQUAL "DBG_OFF") - message(STATUS "Jenkins integration: build release version") - set(CMAKE_BUILD_TYPE "Release" CACHE STRING "" FORCE) - endif() +if( NOT CMAKE_BUILD_TYPE ) + set(CMAKE_BUILD_TYPE Debug CACHE STRING "Choose the type of build. Options are: None, Debug, Release, RelWithDebInfo, MinSizeRel." FORCE) endif() if (HMI_ADAPTER_OPTION) if (${HMI_ADAPTER_OPTION} STREQUAL "MESSAGEBROKER") message(STATUS "Jenkins integration: selected HMI adapter MESSAGEBROKER") set (HMIADAPTER "messagebroker") - elseif (${HMI_ADAPTER_OPTION} STREQUAL "DBUS") - message(STATUS "Jenkins integration: selected HMI adapter DBUS") - set (HMIADAPTER "dbus") - elseif (${HMI_ADAPTER_OPTION} STREQUAL "MQUEUE") - message(STATUS "Jenkins integration: selected HMI adapter MQUEUE") - set (HMIADAPTER "mqueue") endif() endif() @@ -155,6 +154,59 @@ endif() #Jenkins integration section end +#Deliver Build Configuration + +set(build_config_path "src/appMain/build_config.txt") +FILE(WRITE "${build_config_path}" "") + +get_property(cHelpString CACHE EXTENDED_POLICY PROPERTY HELPSTRING) +get_property(cType CACHE EXTENDED_POLICY PROPERTY TYPE) +get_property(cValue CACHE EXTENDED_POLICY PROPERTY VALUE) +file(APPEND "${build_config_path}" "//${cHelpString}\n") +file(APPEND "${build_config_path}" "EXTENDED_POLICY:${cType}=${cValue}\n\n") + +get_property(cHelpString CACHE BUILD_BT_SUPPORT PROPERTY HELPSTRING) +get_property(cType CACHE BUILD_BT_SUPPORT PROPERTY TYPE) +get_property(cValue CACHE BUILD_BT_SUPPORT PROPERTY VALUE) +file(APPEND "${build_config_path}" "//${cHelpString}\n") +file(APPEND "${build_config_path}" "BUILD_BT_SUPPORT:${cType}=${cValue}\n\n") + +get_property(cHelpString CACHE BUILD_USB_SUPPORT PROPERTY HELPSTRING) +get_property(cType CACHE BUILD_USB_SUPPORT PROPERTY TYPE) +get_property(cValue CACHE BUILD_USB_SUPPORT PROPERTY VALUE) +file(APPEND "${build_config_path}" "//${cHelpString}\n") +file(APPEND "${build_config_path}" "BUILD_USB_SUPPORT:${cType}=${cValue}\n\n") + +get_property(cHelpString CACHE ENABLE_SECURITY PROPERTY HELPSTRING) +get_property(cType CACHE ENABLE_SECURITY PROPERTY TYPE) +get_property(cValue CACHE ENABLE_SECURITY PROPERTY VALUE) +file(APPEND "${build_config_path}" "//${cHelpString}\n") +file(APPEND "${build_config_path}" "ENABLE_SECURITY:${cType}=${cValue}\n\n") + +get_property(cHelpString CACHE EXTENDED_MEDIA_MODE PROPERTY HELPSTRING) +get_property(cType CACHE EXTENDED_MEDIA_MODE PROPERTY TYPE) +get_property(cValue CACHE EXTENDED_MEDIA_MODE PROPERTY VALUE) +file(APPEND "${build_config_path}" "//${cHelpString}\n") +file(APPEND "${build_config_path}" "EXTENDED_MEDIA_MODE:${cType}=${cValue}\n\n") + +get_property(cHelpString CACHE TELEMETRY_MONITOR PROPERTY HELPSTRING) +get_property(cType CACHE TELEMETRY_MONITOR PROPERTY TYPE) +get_property(cValue CACHE TELEMETRY_MONITOR PROPERTY VALUE) +file(APPEND "${build_config_path}" "//${cHelpString}\n") +file(APPEND "${build_config_path}" "TELEMETRY_MONITOR:${cType}=${cValue}\n\n") + +get_property(cHelpString CACHE HMI PROPERTY HELPSTRING) +get_property(cType CACHE HMI PROPERTY TYPE) +get_property(cValue CACHE HMI PROPERTY VALUE) +file(APPEND "${build_config_path}" "//${cHelpString}\n") +file(APPEND "${build_config_path}" "HMI:${cType}=${cValue}\n\n") + +get_property(cHelpString CACHE ENABLE_HMI_PTU_DECRYPTION PROPERTY HELPSTRING) +get_property(cType CACHE ENABLE_HMI_PTU_DECRYPTION PROPERTY TYPE) +get_property(cValue CACHE ENABLE_HMI_PTU_DECRYPTION PROPERTY VALUE) +file(APPEND "${build_config_path}" "//${cHelpString}\n") +file(APPEND "${build_config_path}" "ENABLE_HMI_PTU_DECRYPTION:${cType}=${cValue}\n") + add_custom_target(pasa-tarball COMMAND ${CMAKE_SOURCE_DIR}/tools/Utils/export-customer-specific.sh ${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR} pasa COMMAND tar -cz -C /tmp/PASA -f ${CMAKE_BINARY_DIR}/pasa.tar.gz . @@ -172,7 +224,6 @@ add_custom_target(genivi-tarball COMMAND tar -cz -C /tmp/GENIVI -f ${CMAKE_BINARY_DIR}/genivi.tar.gz . ) - project (${PROJECT}) #ADD_DEPENDENCIES(${PROJECT} Policy) @@ -184,15 +235,61 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/") set(CMAKE_INSTALL_PREFIX ${CMAKE_CURRENT_BINARY_DIR}) set(ARCHIVE_OUTPUT_DIRECTORY ./bin) -set(CMAKE_CXX_FLAGS "-fPIC -std=gnu++0x -Wall -Werror -Wno-deprecated-declarations -Wuninitialized -Wvla") +set(CMAKE_CXX_FLAGS "-fPIC -std=gnu++0x -Wall -Werror -Wuninitialized -Wvla") + +if (USE_GOLD_LD) + execute_process(COMMAND ld -v OUTPUT_VARIABLE result) + string(FIND ${result} Binutils GOLD_LD_FOUND) + if (GOLD_LD_FOUND EQUAL -1) + message(SEND_ERROR "Gold linker not found!") + else() + message(INFO " Use gold linker") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fuse-ld=gold") + endif() +endif(USE_GOLD_LD) + +if (USE_CCACHE) +# Configure CCache if available + find_program(CCACHE_FOUND ccache) + if(CCACHE_FOUND) + get_property(RULE_LAUNCH_COMPILE GLOBAL PROPERTY RULE_LAUNCH_COMPILE) + set(RULE_LAUNCH_COMPILE "${RULE_LAUNCH_COMPILE} ccache") + set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ${RULE_LAUNCH_COMPILE}) + + get_property(RULE_LAUNCH_LINK GLOBAL PROPERTY RULE_LAUNCH_LINK) + set(RULE_LAUNCH_LINK "${RULE_LAUNCH_LINK} ccache") + set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK ${RULE_LAUNCH_LINK}) + + message(INFO " Used CCache for compilation.") + else(CCACHE_FOUND) + message(WARNING " CCache was not found.") + endif(CCACHE_FOUND) +endif(USE_CCACHE) + +if (USE_DISTCC) +# Configure distributed compilation if available + find_program(DISTCC_FOUND distcc) + if(DISTCC_FOUND) + get_property(RULE_LAUNCH_COMPILE GLOBAL PROPERTY RULE_LAUNCH_COMPILE) + set(RULE_LAUNCH_COMPILE "${RULE_LAUNCH_COMPILE} distcc") + set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ${RULE_LAUNCH_COMPILE}) + message(INFO " Used distributed build.") + else(CCACHE_FOUND) + message(WARNING " distcc was not found. Distributed compilation is impossible.") + endif(DISTCC_FOUND) +endif(USE_DISTCC) if(ENABLE_SANITIZE) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address") + message(STATUS "Sanitizing enabled") endif() + if(ENABLE_GCOV) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --coverage") add_definitions(-DGCOV_ENABLED) + message(STATUS "GCOV enabled") endif() + set(CMAKE_CXX_FLAGS_RELEASE " -DNDEBUG -s -O2") set(CMAKE_CXX_FLAGS_DEBUG " -DDEBUG -g3 -ggdb3") @@ -209,141 +306,67 @@ endif() if (BUILD_USB_SUPPORT) add_definitions(-DUSB_SUPPORT) find_package(UDev REQUIRED) - message(STATUS "USB support is enabled") + message(STATUS "USB support enabled") endif() if (BUILD_BT_SUPPORT) add_definitions(-DBLUETOOTH_SUPPORT) - message(STATUS "Bluetooth support is enabled") + message(STATUS "Bluetooth support enabled") endif() if (BUILD_BACKTRACE_SUPPORT) add_definitions(-DBACKTRACE_SUPPORT) + message(STATUS "Backtrace support enabled") endif() if(ENABLE_LOG) add_definitions(-DENABLE_LOG) set(install-3rd_party_logger "install-3rd_party_logger") + message(STATUS "Logger enabled") endif() -if (TELEMETRY_MONITOR) - add_definitions(-DTELEMETRY_MONITOR) -endif() +set(install-bson_c_lib "install-bson_c_lib") -if (ENABLE_EXTENDED_POLICY) - add_definitions(-DEXTENDED_POLICY) +if (TELEMETRY_MONITOR) + add_definitions(-DTELEMETRY_MONITOR) + message(STATUS "Telemetry monitor enabled") +endif() + +if (${EXTENDED_POLICY} STREQUAL "EXTERNAL_PROPRIETARY") + add_definitions(-DEXTERNAL_PROPRIETARY_MODE) + set(POLICY_PATH ${COMPONENTS_DIR}/policy/policy_external/) + set(POLICY_GLOBAL_INCLUDE_PATH ${COMPONENTS_DIR}/include/policy/policy_external/) + set(POLICY_MOCK_INCLUDE_PATH ${COMPONENTS_DIR}/include/test/policy/policy_external/) + message(STATUS "EXTERNAL_PROPRIETARY policy enabled") +else() + if (${EXTENDED_POLICY} STREQUAL "PROPRIETARY") + add_definitions(-DPROPRIETARY_MODE) + message(STATUS "PROPRIETARY policy enabled") + else() + message(STATUS "HTTP policy enabled") + endif() + set(POLICY_PATH ${COMPONENTS_DIR}/policy/policy_regular/) + set(POLICY_GLOBAL_INCLUDE_PATH ${COMPONENTS_DIR}/include/policy/policy_regular/) + set(POLICY_MOCK_INCLUDE_PATH ${COMPONENTS_DIR}/include/test/policy/policy_regular/) endif() # TODO(AK): check current OS here add_definitions(-DOS_POSIX) if (EXTENDED_MEDIA_MODE) -add_definitions(-DEXTENDED_MEDIA_MODE) -# required to find 'glibconfig.h' -find_package(PkgConfig) -pkg_check_modules(GLIB2 REQUIRED glib-2.0) -add_definitions(${GLIB2_CFLAGS}) + add_definitions(-DEXTENDED_MEDIA_MODE) + message(STATUS "Extended media mode enabled") + # required to find 'glibconfig.h' + find_package(PkgConfig) + pkg_check_modules(GLIB2 REQUIRED glib-2.0) + add_definitions(${GLIB2_CFLAGS}) endif() - -# --- Interface generator - -find_package(PythonInterp) -if(NOT PYTHONINTERP_FOUND) - message(STATUS "Python interpreter is not found") - message(STATUS "To install it type in the command line:") - message(STATUS "sudo apt-get install python") - message(FATAL_ERROR "Exiting!") -endif(NOT PYTHONINTERP_FOUND) - -if (HMI STREQUAL "qt") - cmake_minimum_required(VERSION 2.8.11) - if (CMAKE_SYSTEM_NAME STREQUAL "QNX") - set(qt_version "4.8.5") - else () - set(qt_version "5.1.0") - endif () - - execute_process( - COMMAND ${CMAKE_SOURCE_DIR}/FindQt.sh -v ${qt_version} - OUTPUT_VARIABLE qt_bin_dir - ) - message(STATUS "Binary directory Qt ${qt_version} is ${qt_bin_dir}") - set(ENV{PATH} ${qt_bin_dir}:$ENV{PATH}) - - if (CMAKE_SYSTEM_NAME STREQUAL "QNX") - find_package(Qt4 ${qt_version} REQUIRED QtCore QtGui QtDBus QtDeclarative) - else () - find_package(Qt5Core REQUIRED) - find_package(Qt5DBus REQUIRED) - find_package(Qt5Qml REQUIRED) - find_package(Qt5Quick REQUIRED) - set(qmlplugindump_binary ${qt_bin_dir}/qmlplugindump) - endif () -endif() - -set(INTEFRACE_GENERATOR "${PROJECT_SOURCE_DIR}/tools/InterfaceGenerator/Generator.py") -set(INTEFRACE_GENERATOR_CMD ${PYTHON_EXECUTABLE} -B ${INTEFRACE_GENERATOR}) -file(GLOB_RECURSE INTERFACE_GENERATOR_DEPENDENCIES "${PROJECT_SOURCE_DIR}/tools/InterfaceGenerator/*.*") - -macro (GenerateInterface arg_xml_name arg_namespace parser_type) - string(REGEX MATCH "^[a-zA-Z_0-9]*[^.]" file_name ${arg_xml_name}) # TODO: make expression more robust - - set(hpp_file - "${CMAKE_CURRENT_BINARY_DIR}/${file_name}.h" - "${CMAKE_CURRENT_BINARY_DIR}/${file_name}_schema.h" - ) - - set(cpp_file "${CMAKE_CURRENT_BINARY_DIR}/${file_name}_schema.cc") - set(full_xml_name "${CMAKE_CURRENT_SOURCE_DIR}/${arg_xml_name}") - - add_custom_command( OUTPUT ${hpp_file} ${cpp_file} - COMMAND ${INTEFRACE_GENERATOR_CMD} ${full_xml_name} ${arg_namespace} ${CMAKE_CURRENT_BINARY_DIR} "--parser-type" "${parser_type}" - DEPENDS ${INTERFACE_GENERATOR_DEPENDENCIES} ${full_xml_name} - COMMENT "Generating files:\n ${hpp_file}\n ${cpp_file}\nfrom:\n ${arg_xml_name} ..." - VERBATIM - ) - - include_directories ( - ${COMPONENTS_DIR}/smart_objects/include - ${COMPONENTS_DIR}/formatters/include/ - ${CMAKE_BINARY_DIR} - ) - - add_library("${file_name}" ${cpp_file}) -endmacro(GenerateInterface) - -# --- Useful macro -macro(create_test NAME SOURCES LIBS) - add_executable("${NAME}" ${CMAKE_SOURCE_DIR}/src/components/test_main.cc ${SOURCES}) - target_link_libraries("${NAME}" ${LIBS}) - target_link_libraries("${NAME}" Utils) - if(CMAKE_SYSTEM_NAME STREQUAL "QNX") - add_test(${NAME} ${CMAKE_SOURCE_DIR}/qnx/remote_run_test.sh ${NAME}) - elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux") - add_test(NAME ${NAME} - COMMAND ${NAME} --gtest_output=xml:${CMAKE_BINARY_DIR}/test_results/) - else() - add_test(${NAME} ${NAME}) - endif() -endmacro(create_test) - -# --replace in list macro -macro(LIST_REPLACE LIST INDEX NEWVALUE) - list(INSERT ${LIST} ${INDEX} ${NEWVALUE}) - MATH(EXPR __INDEX "${INDEX} + 1") - list (REMOVE_AT ${LIST} ${__INDEX}) -endmacro(LIST_REPLACE) - - # Building application # --- Type HMI -if (HMI STREQUAL "qt") - set(QT_HMI ON) - add_definitions(-DQT_HMI) -elseif (HMI STREQUAL "web") +if (HMI STREQUAL "web") set(WEB_HMI ON) add_definitions(-DWEB_HMI) else () @@ -351,273 +374,24 @@ else () add_definitions(-DNO_HMI) endif () -if (HMI STREQUAL "qt" AND NOT DEFINED HMIADAPTER) - set(HMIADAPTER "dbus") -endif() if (HMI STREQUAL "web" AND NOT DEFINED HMIADAPTER) set(HMIADAPTER "messagebroker") endif() -if (HMI STREQUAL "no" AND NOT DEFINED HMIADAPTER) - set(HMIADAPTER "mqueue") -endif() -if (HMIADAPTER STREQUAL "dbus") - set(HMI_DBUS_API ON) - add_definitions(-DDBUS_HMIADAPTER) - add_definitions(-DHMI_DBUS_API) - set(install-3rd_party_dbus "install-3rd_party_dbus") -endif() if (HMIADAPTER STREQUAL "messagebroker") set(HMI_JSON_API ON) add_definitions(-DMESSAGEBROKER_HMIADAPTER) add_definitions(-DHMI_JSON_API) endif() -if (HMIADAPTER STREQUAL "mqueue") - set(HMI_JSON_API ON) - add_definitions(-DMQUEUE_HMIADAPTER) - add_definitions(-DHMI_JSON_API) -endif() # --- Directory with SDL interfaces, global types and ProtocolLib component include_directories( ${COMPONENTS_DIR}/include ${COMPONENTS_DIR}/protocol/include -if (BUILD_TESTS) - ${COMPONENTS_DIR}/include/test -endif () ) # --- 3rd party libs -INCLUDE(${CMAKE_CURRENT_SOURCE_DIR}/src/3rd_party/set_3rd_party_paths.cmake) - -set(3RD_PARTY_SOURCE_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/src/3rd_party) -set(3RD_PARTY_BINARY_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/src/3rd_party) - -set (install-3rd_party_logger_var "") -set (install-3rd_party_dbus_var "") - -if(NO_REBUILD_3RD_PARTY) - set(NO_REBUILD_3RD_PARTY_LOGGER ON) - set(NO_REBUILD_3RD_PARTY_DBUS ON) -endif() - -if(FORCE_3RD_PARTY) - if(NO_REBUILD_3RD_PARTY) - message(FATAL_ERROR "Please don't turn on both FORCE_3RD_PARTY and NO_REBUILD_3RD_PARTY at the same time.") - else() - set(FORCE_3RD_PARTY_LOGGER ON) - set(FORCE_3RD_PARTY_DBUS ON) - endif() -endif() - -if(ENABLE_LOG) - if(NO_REBUILD_3RD_PARTY_LOGGER) - message(STATUS "Not rebuilding logger.") - else() - if(FORCE_3RD_PARTY_LOGGER) - message(STATUS "Force to rebuild logger.") - - #build logger - add_custom_target(3rd_party_logger - make - WORKING_DIRECTORY ${3RD_PARTY_BINARY_DIRECTORY} - ) - - #install logger - #install either to default place with sudo or non-default plase without sudo. - #to install with sudo to non-default place use manual installation - add_custom_target(install-3rd_party_logger - COMMAND /bin/bash -c \"USE_DEFAULT_3RD_PARTY_PATH=${USE_DEFAULT_3RD_PARTY_PATH}\; - if [ \\$$USE_DEFAULT_3RD_PARTY_PATH == "true" ]\; then - sudo -k \; - sudo make install\; - else - make install\; - fi\" - DEPENDS 3rd_party_logger - WORKING_DIRECTORY ${3RD_PARTY_BINARY_DIRECTORY} - ) - else() - #build logger - add_custom_target(3rd_party_logger - COMMAND /bin/bash -c \"cd ${CMAKE_CURRENT_SOURCE_DIR} && - grep .commit_hash ${3RD_PARTY_INSTALL_PREFIX_ARCH}/lib/liblog4cxx.so 1>/dev/null 2>&1\; - if [ \\$$? == 0 ]\; then - VAR1=\\$$\( readelf -p .commit_hash ${3RD_PARTY_INSTALL_PREFIX_ARCH}/lib/liblog4cxx.so 2>/dev/null\)\; - VAR1=\\$$\(echo \\$$VAR1 | awk '{print \\$$NF}'\)\; - VAR2=-1\; - cd ${CMAKE_CURRENT_SOURCE_DIR}\; - git log . 1>/dev/null 2>&1\; - if [ \\$$? == 0 ]; then - VAR2=\\$$\(git log --pretty=\"format:%H\" -1 ${3RD_PARTY_SOURCE_DIRECTORY}/apache-log4cxx-0.10.0\)\; - fi\; - if [ \\$$VAR1 != \\$$VAR2 ]\; then - echo " Need to rebuild logger. " \; - cd ${3RD_PARTY_BINARY_DIRECTORY}\; - make\; - else - echo " Logger is actual. " \; - fi\; - else - echo " Need to build logger. " \; - cd ${3RD_PARTY_BINARY_DIRECTORY}\; - make\; - fi\" - WORKING_DIRECTORY ${3RD_PARTY_BINARY_DIRECTORY} - ) - - #install logger - #install either to default place with sudo or non-default plase without sudo. - #to install with sudo to non-default place use manual installation - add_custom_target(install-3rd_party_logger - COMMAND /bin/bash -c \"cd ${CMAKE_CURRENT_SOURCE_DIR} && - grep .commit_hash ${3RD_PARTY_INSTALL_PREFIX_ARCH}/lib/liblog4cxx.so 1>/dev/null 2>&1\; - if [ \\$$? == 0 ]\; then - VAR1=\\$$\( readelf -p .commit_hash ${3RD_PARTY_INSTALL_PREFIX_ARCH}/lib/liblog4cxx.so 2>/dev/null\)\; - VAR1=\\$$\(echo \\$$VAR1 | awk '{print \\$$NF}'\)\; - VAR2=-1\; - cd ${CMAKE_CURRENT_SOURCE_DIR}\; - git log . 1>/dev/null 2>&1\; - if [ \\$$? == 0 ]; then - VAR2=\\$$\(git log --pretty=\"format:%H\" -1 ${3RD_PARTY_SOURCE_DIRECTORY}/apache-log4cxx-0.10.0\)\; - fi\; - if [ \\$$VAR1 != \\$$VAR2 ]\; then - USE_DEFAULT_3RD_PARTY_PATH=${USE_DEFAULT_3RD_PARTY_PATH}\; - if [ \\$$USE_DEFAULT_3RD_PARTY_PATH == "true" ]\; then - cd ${3RD_PARTY_BINARY_DIRECTORY}\; - sudo -k \; - sudo make install\; - else - cd ${3RD_PARTY_BINARY_DIRECTORY}\; - make install\; - fi\; - fi\; - else - USE_DEFAULT_3RD_PARTY_PATH=${USE_DEFAULT_3RD_PARTY_PATH}\; - if [ \\$$USE_DEFAULT_3RD_PARTY_PATH == "true" ]\; then - cd ${3RD_PARTY_BINARY_DIRECTORY}\; - sudo -k \; - sudo make install\; - else - cd ${3RD_PARTY_BINARY_DIRECTORY}\; - make install\; - fi\; - fi\" - DEPENDS 3rd_party_logger - WORKING_DIRECTORY ${3RD_PARTY_BINARY_DIRECTORY} - ) - endif() - - set (install-3rd_party_logger_var "install-3rd_party_logger") - endif() -endif() - -if (HMIADAPTER STREQUAL "dbus") - if(NO_REBUILD_3RD_PARTY_DBUS) - message(STATUS "Not rebuilding D-Bus.") - else() - if(FORCE_3RD_PARTY_DBUS) - message(STATUS "Force to rebuild D-Bus.") - - #build d-bus - add_custom_target(3rd_party_dbus - make - WORKING_DIRECTORY ${3RD_PARTY_BINARY_DIRECTORY} - ) - - #install d-bus - #install either to default place with sudo or non-default plase without sudo. - #to install with sudo to non-default place use manual installation - add_custom_target(install-3rd_party_dbus - COMMAND /bin/bash -c \"USE_DEFAULT_3RD_PARTY_PATH=${USE_DEFAULT_3RD_PARTY_PATH}\; - if [ \\$$USE_DEFAULT_3RD_PARTY_PATH == "true" ]\; then - sudo -k \; - sudo make install\; - else - make install\; - fi\" - DEPENDS 3rd_party_dbus - WORKING_DIRECTORY ${3RD_PARTY_BINARY_DIRECTORY} - ) - else() - #build d-bus - add_custom_target(3rd_party_dbus - COMMAND /bin/bash -c \"grep .commit_hash ${3RD_PARTY_INSTALL_PREFIX_ARCH}/lib/libdbus-1.so 1>/dev/null 2>&1\; - if [ \\$$? == 0 ]\; then - VAR1=\\$$\(readelf -p .commit_hash ${3RD_PARTY_INSTALL_PREFIX_ARCH}/lib/libdbus-1.so 2>/dev/null\)\; - VAR1=\\$$\(echo \\$$VAR1 | awk '{print \\$$NF}'\)\; - VAR2=-1\; - cd ${CMAKE_CURRENT_SOURCE_DIR}\; - git log . 1>/dev/null 2>&1\; - if [ \\$$? == 0 ]; then - VAR2=\\$$\(git log --pretty=\"format:%H\" -1 ${3RD_PARTY_SOURCE_DIRECTORY}/dbus-1.7.8\)\; - fi\; - if [ \\$$VAR1 != \\$$VAR2 ]\; then - echo " Need to rebuild D-Bus. " \; - cd ${3RD_PARTY_BINARY_DIRECTORY}\; - make\; - else - echo " D-Bus is actual. " \; - fi\; - else - echo " Need to build D-Bus. " \; - cd ${3RD_PARTY_BINARY_DIRECTORY}\; - make\; - fi\" - WORKING_DIRECTORY ${3RD_PARTY_BINARY_DIRECTORY} - ) - - #install d-bus - #install either to default place with sudo or non-default plase without sudo. - #to install with sudo to non-default place use manual installation - add_custom_target(install-3rd_party_dbus - COMMAND /bin/bash -c \"grep .commit_hash ${3RD_PARTY_INSTALL_PREFIX_ARCH}/lib/libdbus-1.so 1>/dev/null 2>&1\; - if [ \\$$? == 0 ]\; then - VAR1=\\$$\(readelf -p .commit_hash ${3RD_PARTY_INSTALL_PREFIX_ARCH}/lib/libdbus-1.so 2>/dev/null\)\; - VAR1=\\$$\(echo \\$$VAR1 | awk '{print \\$$NF}'\)\; - VAR2=-1\; - cd ${CMAKE_CURRENT_SOURCE_DIR}\; - git log . 1>/dev/null 2>&1\; - if [ \\$$? == 0 ]; then - VAR2=\\$$\(git log --pretty=\"format:%H\" -1 ${3RD_PARTY_SOURCE_DIRECTORY}/dbus-1.7.8\)\; - fi\; - if [ \\$$VAR1 != \\$$VAR2 ]\; then - USE_DEFAULT_3RD_PARTY_PATH=${USE_DEFAULT_3RD_PARTY_PATH}\; - if [ \\$$USE_DEFAULT_3RD_PARTY_PATH == "true" ]\; then - cd ${3RD_PARTY_BINARY_DIRECTORY}\; - sudo -k \; - sudo make install\; - else - cd ${3RD_PARTY_BINARY_DIRECTORY}\; - make install\; - fi\; - fi\; - else - USE_DEFAULT_3RD_PARTY_PATH=${USE_DEFAULT_3RD_PARTY_PATH}\; - if [ \\$$USE_DEFAULT_3RD_PARTY_PATH == "true" ]\; then - cd ${3RD_PARTY_BINARY_DIRECTORY}\; - sudo -k \; - sudo make install\; - else - cd ${3RD_PARTY_BINARY_DIRECTORY}\; - make install\; - fi\; - fi\" - DEPENDS 3rd_party_dbus - WORKING_DIRECTORY ${3RD_PARTY_BINARY_DIRECTORY} - ) - endif() - - set (install-3rd_party_dbus_var "install-3rd_party_dbus") - endif() -endif() - -add_subdirectory(${3RD_PARTY_SOURCE_DIRECTORY} ${3RD_PARTY_BINARY_DIRECTORY} EXCLUDE_FROM_ALL) -add_custom_target(install-3rd_party - DEPENDS ${install-3rd_party_logger_var} - DEPENDS ${install-3rd_party_dbus_var} - WORKING_DIRECTORY ${3RD_PARTY_BINARY_DIRECTORY} -) +add_subdirectory(./src/3rd_party EXCLUDE_FROM_ALL) find_package(OpenSSL REQUIRED) if(ENABLE_LOG) @@ -629,25 +403,39 @@ if(ENABLE_SECURITY) set(SecurityManagerLibrary SecurityManager) set(SecurityManagerIncludeDir ${COMPONENTS_DIR}/security_manager/include) #set(SecurityManagerTestIncludeDir ${CMAKE_SOURCE_DIR}/test/components/security_manager/include) + message(STATUS "Security enabled") endif() if(ENABLE_HMI_PTU_DECRYPTION) - MESSAGE("USE DHMI_PTU_PARSER") add_definitions(-DUSE_HMI_PTU_DECRYPTION) + message(STATUS "HMI PTU decription enabled") endif() set(RTLIB rt) if(CMAKE_SYSTEM_NAME STREQUAL "QNX") -set(RTLIB ) + set(RTLIB ) endif() +SET(RPATH_DIRECTORIES + ${CMAKE_INSTALL_PREFIX}/bin/plugins + /usr/local/lib + /usr/local + ${CMAKE_INSTALL_PREFIX}/bin +) +SET(CMAKE_SKIP_BUILD_RPATH FALSE) +SET(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE) +SET(CMAKE_INSTALL_RPATH "${RPATH_DIRECTORIES}") +SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) + + # Building tests if(BUILD_TESTS) enable_testing() add_definitions(-DBUILD_TESTS) - # Framework GoogleTest is also integrated together gmock - # and must not be added separately - add_subdirectory(./src/3rd_party-static/gmock-1.7.0) + include_directories( + ${COMPONENTS_DIR}/include/test + ) + message(STATUS "Tests enabled") endif() # --- 3rd party libs (static) @@ -656,7 +444,6 @@ add_subdirectory(./src/3rd_party-static) # --- Tools add_subdirectory(./tools) - # --- Components add_subdirectory(./src/components) @@ -666,35 +453,30 @@ add_subdirectory(./src/appMain) # --- Plugins add_subdirectory(./src/plugins) - -# Building tests -if(BUILD_TESTS) - # Directory test is deprecated. Use src/components//test - include(Dart) - #add_subdirectory(./test) -endif() +add_dependencies(${PROJECT} Policy) +add_dependencies(${PROJECT} copy_policy_library) # Building documentation # At first creating directory for generated documentation. Unfortunately doxygen # cannot generate it byself -FIND_PACKAGE(Doxygen) - IF(DOXYGEN_FOUND) +find_package(Doxygen) + if(DOXYGEN_FOUND) option(DOXYGEN_ENABLE_DIAGRAMS "Enable graphical diagram generation" ON) + message(STATUS "Doxygen found. Documentation will be generated") if(DOXYGEN_ENABLE_DIAGRAMS) set(DOXYGEN_ENABLE_DIAGRAMS_PARAM "YES") - else(DOXYGEN_ENABLE_DIAGRAMS) + else() set(DOXYGEN_ENABLE_DIAGRAMS_PARAM "NO") endif() configure_file("${PROJECT_SOURCE_DIR}/Doxyfile" "${PROJECT_BINARY_DIR}/Doxyfile") file(MAKE_DIRECTORY "${PROJECT_BINARY_DIR}/doc/doxygen") - ADD_CUSTOM_TARGET(doxygen COMMAND ${DOXYGEN_EXECUTABLE} "${PROJECT_BINARY_DIR}/Doxyfile") - ELSE(DOXYGEN_FOUND) - MESSAGE(STATUS "Doxygen not found. Documentation will not be generated") - MESSAGE(STATUS "To enable documentation generation please install doxygen and graphviz packages") - MESSAGE(STATUS "sudo apt-get install doxygen graphviz") - MESSAGE(STATUS "To enable processing of MscGen comments please install mscgen") - MESSAGE(STATUS "sudo apt-get install mscgen") -ENDIF(DOXYGEN_FOUND) - + add_custom_target(doxygen COMMAND ${DOXYGEN_EXECUTABLE} "${PROJECT_BINARY_DIR}/Doxyfile") + else() + message(STATUS "Doxygen not found. Documentation will not be generated") + message(STATUS "To enable documentation generation please install doxygen and graphviz packages") + message(STATUS "sudo apt-get install doxygen graphviz") + message(STATUS "To enable processing of MscGen comments please install mscgen") + message(STATUS "sudo apt-get install mscgen") +endif() \ No newline at end of file -- cgit v1.2.1 From 20f9f05a54c2cc91fd6f2ca6cc1d17da6bb9a5ce Mon Sep 17 00:00:00 2001 From: Jacob Keeler Date: Fri, 24 Aug 2018 16:04:19 -0400 Subject: Revert CMake changes --- CMakeLists.txt | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 806580030f..1a180b6cf9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -62,18 +62,18 @@ if(EXTENDED_POLICY STREQUAL "") set(EXTENDED_POLICY "PROPRIETARY") endif() -set(OS_TYPE_OPTION "$ENV{OS_TYPE}") -set(HMI_TYPE_OPTION "$ENV{HMI_TYPE}") -set(TARGET_OPTION "$ENV{TARGET}") -set(MEDIA_MODE_OPTION "$ENV{MEDIA_MODE}") -set(HMI_ADAPTER_OPTION "$ENV{HMI_ADAPTER}") +set(OS_TYPE_OPTION "$ENV{OS_TYPE}") +set(HMI_TYPE_OPTION "$ENV{HMI_TYPE}") +set(TARGET_OPTION "$ENV{TARGET}") +set(MEDIA_MODE_OPTION "$ENV{MEDIA_MODE}") +set(HMI_ADAPTER_OPTION "$ENV{HMI_ADAPTER}") set(ENABLE_TESTS_OPTION "$ENV{ENABLE_TESTS}") -set(ENABLE_LOG_OPTION "$ENV{ENABLE_LOG}") -set(ARCH_TYPE_OPTION "$ENV{ARCH_TYPE}") -set(POLICY_OPTION "$ENV{POLICY_TYPE}") -set(SECURITY_OPTION "$ENV{SECURITY_MODE}") +set(ENABLE_LOG_OPTION "$ENV{ENABLE_LOG}") +set(ARCH_TYPE_OPTION "$ENV{ARCH_TYPE}") +set(POLICY_OPTION "$ENV{POLICY_TYPE}") +set(SECURITY_OPTION "$ENV{SECURITY_MODE}") set(COMPONENTS_DIR ${CMAKE_SOURCE_DIR}/src/components) -set(SNAPSHOT_TAG "$ENV{SNAPSHOT_TAG}") +set(SNAPSHOT_TAG "$ENV{SNAPSHOT_TAG}") set(CMAKE_CXX_COMPILER $ENV{CMAKE_CXX_COMPILER}) set(CMAKE_C_COMPILER $ENV{CMAKE_C_COMPILER}) set(BUILDDIR "$ENV{BUILDDIR}") @@ -81,10 +81,10 @@ set(BUILDDIR "$ENV{BUILDDIR}") if (ARCH_TYPE_OPTION) if (NOT (${ARCH_TYPE_OPTION} STREQUAL "x86") AND NOT (${ARCH_TYPE_OPTION} STREQUAL "armv7")) message(AUTHOR_WARNING "HW architecture is not defined, using x86. Allowed values are x86/armv7 (case sensitive)") - set(ARCH_TYPE_OPTION "x86") + set(ARCH_TYPE_OPTION "x86") endif () else () - set(ARCH_TYPE_OPTION "x86") + set(ARCH_TYPE_OPTION "x86") endif() if (HMI_TYPE_OPTION) @@ -479,4 +479,4 @@ find_package(Doxygen) message(STATUS "sudo apt-get install doxygen graphviz") message(STATUS "To enable processing of MscGen comments please install mscgen") message(STATUS "sudo apt-get install mscgen") -endif() \ No newline at end of file +endif() -- cgit v1.2.1 From 82eac1e9627ad2be5c63708103fc5c10852bf14e Mon Sep 17 00:00:00 2001 From: jacobkeeler Date: Fri, 24 Aug 2018 16:24:37 -0400 Subject: Fix transport manager init check --- src/appMain/life_cycle_impl.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/appMain/life_cycle_impl.cc b/src/appMain/life_cycle_impl.cc index 5b319dde48..b87191d937 100644 --- a/src/appMain/life_cycle_impl.cc +++ b/src/appMain/life_cycle_impl.cc @@ -163,7 +163,7 @@ bool LifeCycleImpl::StartComponents() { // It's important to initialise TM after setting up listener chain // [TM -> CH -> AM], otherwise some events from TM could arrive at nowhere app_manager_->set_protocol_handler(protocol_handler_); - if (!transport_manager_->Init(*last_state_)) { + if (transport_manager::E_SUCCESS != transport_manager_->Init(*last_state_)) { LOG4CXX_ERROR(logger_, "Transport manager init failed."); return false; } -- cgit v1.2.1 From 84113996315adc1424199e13b69137fcb269f294 Mon Sep 17 00:00:00 2001 From: jacobkeeler Date: Tue, 28 Aug 2018 13:09:00 -0400 Subject: Reduce date_time boost header scope --- src/components/include/utils/date_time.h | 2 +- src/components/utils/src/date_time.cc | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/components/include/utils/date_time.h b/src/components/include/utils/date_time.h index 3e649cfc28..17b4fafe38 100644 --- a/src/components/include/utils/date_time.h +++ b/src/components/include/utils/date_time.h @@ -33,7 +33,7 @@ #define SRC_COMPONENTS_INCLUDE_UTILS_DATE_TIME_H_ #include -#include "boost/date_time.hpp" +#include "boost/date_time/posix_time/posix_time_duration.hpp" namespace date_time { diff --git a/src/components/utils/src/date_time.cc b/src/components/utils/src/date_time.cc index 2802ed0f91..3ca6050b3f 100644 --- a/src/components/utils/src/date_time.cc +++ b/src/components/utils/src/date_time.cc @@ -30,9 +30,11 @@ * POSSIBILITY OF SUCH DAMAGE. */ +#include "utils/date_time.h" + #include #include -#include "utils/date_time.h" +#include "boost/date_time/posix_time/posix_time.hpp" namespace bpt = boost::posix_time; using namespace boost::date_time; -- cgit v1.2.1 From a34939d71451c2ad859287d46a3950b6249e853b Mon Sep 17 00:00:00 2001 From: JackLivio Date: Tue, 28 Aug 2018 15:16:31 -0400 Subject: Allow empty moduleType array in PT --- .../include/policy/policy_table/enums.h | 3 +- .../policy_external/src/policy_table/enums.cc | 7 +++++ .../policy_external/src/sql_pt_representation.cc | 32 ++++++++++++++++------ .../include/policy/policy_table/enums.h | 3 +- .../policy_regular/src/policy_table/enums.cc | 7 +++++ .../policy_regular/src/sql_pt_representation.cc | 32 ++++++++++++++++------ 6 files changed, 66 insertions(+), 18 deletions(-) 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 5fc43603d8..a31e955d99 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 @@ -173,7 +173,8 @@ enum ModuleType { MT_SEAT, MT_AUDIO, MT_LIGHT, - MT_HMI_SETTINGS + MT_HMI_SETTINGS, + MT_EMPTY }; bool IsValidEnum(ModuleType val); const char* EnumToJsonString(ModuleType val); 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 c2b304df67..31a6fc86e6 100644 --- a/src/components/policy/policy_external/src/policy_table/enums.cc +++ b/src/components/policy/policy_external/src/policy_table/enums.cc @@ -779,6 +779,8 @@ bool IsValidEnum(ModuleType val) { return true; case MT_SEAT: return true; + case MT_EMPTY: + return true; default: return false; } @@ -797,6 +799,8 @@ const char* EnumToJsonString(ModuleType val) { return "HMI_SETTINGS"; case MT_SEAT: return "SEAT"; + case MT_EMPTY: + return "EMPTY"; default: return ""; } @@ -821,6 +825,9 @@ bool EnumFromJsonString(const std::string& literal, ModuleType* result) { } else if ("HMI_SETTINGS" == literal) { *result = MT_HMI_SETTINGS; return true; + } else if ("EMPTY" == literal) { + *result = MT_EMPTY; + return true; } else { return false; } diff --git a/src/components/policy/policy_external/src/sql_pt_representation.cc b/src/components/policy/policy_external/src/sql_pt_representation.cc index b9b0194199..10be5a4626 100644 --- a/src/components/policy/policy_external/src/sql_pt_representation.cc +++ b/src/components/policy/policy_external/src/sql_pt_representation.cc @@ -1740,6 +1740,10 @@ bool SQLPTRepresentation::GatherModuleType( if (!policy_table::EnumFromJsonString(query.GetString(0), &type)) { return false; } + if (policy_table::ModuleType::MT_EMPTY == type) { + app_types->mark_initialized(); + continue; + } app_types->push_back(type); } return true; @@ -1772,18 +1776,30 @@ bool SQLPTRepresentation::SaveModuleType( } policy_table::ModuleTypes::const_iterator it; - for (it = types.begin(); it != types.end(); ++it) { + if (!types.empty()) { + for (it = types.begin(); it != types.end(); ++it) { + query.Bind(0, app_id); + std::string module(policy_table::EnumToJsonString(*it)); + query.Bind(1, module); + LOG4CXX_DEBUG(logger_, + "Module(app: " << app_id << ", type: " << module << ")"); + if (!query.Exec() || !query.Reset()) { + LOG4CXX_WARN(logger_, "Incorrect insert into module type."); + return false; + } + } + } else if (types.is_initialized()) { query.Bind(0, app_id); - std::string module(policy_table::EnumToJsonString(*it)); - query.Bind(1, module); - LOG4CXX_DEBUG(logger_, - "Module(app: " << app_id << ", type: " << module << ")"); + query.Bind(1, + std::string(policy_table::EnumToJsonString( + policy_table::ModuleType::MT_EMPTY))); if (!query.Exec() || !query.Reset()) { - LOG4CXX_WARN(logger_, "Incorrect insert into module type."); + LOG4CXX_WARN(logger_, "Incorrect insert into module types."); return false; - } + } + } else { + LOG4CXX_WARN(logger_, "Module Type omitted."); } - 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 4107fad398..b2acf77ec1 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 @@ -159,7 +159,8 @@ enum ModuleType { MT_SEAT, MT_AUDIO, MT_LIGHT, - MT_HMI_SETTINGS + MT_HMI_SETTINGS, + MT_EMPTY }; bool IsValidEnum(ModuleType val); const char* EnumToJsonString(ModuleType val); 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 83ace2feb2..138d866174 100644 --- a/src/components/policy/policy_regular/src/policy_table/enums.cc +++ b/src/components/policy/policy_regular/src/policy_table/enums.cc @@ -649,6 +649,8 @@ bool IsValidEnum(ModuleType val) { return true; case MT_HMI_SETTINGS: return true; + case MT_EMPTY: + return true; default: return false; } @@ -667,6 +669,8 @@ const char* EnumToJsonString(ModuleType val) { return "LIGHT"; case MT_HMI_SETTINGS: return "HMI_SETTINGS"; + case MT_EMPTY: + return "EMPTY"; default: return ""; } @@ -691,6 +695,9 @@ bool EnumFromJsonString(const std::string& literal, ModuleType* result) { } else if ("HMI_SETTINGS" == literal) { *result = MT_HMI_SETTINGS; return true; + } else if ("EMPTY" == literal) { + *result = MT_EMPTY; + return true; } return false; } diff --git a/src/components/policy/policy_regular/src/sql_pt_representation.cc b/src/components/policy/policy_regular/src/sql_pt_representation.cc index 00f3349050..ee655d624f 100644 --- a/src/components/policy/policy_regular/src/sql_pt_representation.cc +++ b/src/components/policy/policy_regular/src/sql_pt_representation.cc @@ -1696,6 +1696,10 @@ bool SQLPTRepresentation::GatherModuleType( if (!policy_table::EnumFromJsonString(query.GetString(0), &type)) { return false; } + if (policy_table::ModuleType::MT_EMPTY == type) { + app_types->mark_initialized(); + continue; + } app_types->push_back(type); } return true; @@ -1728,18 +1732,30 @@ bool SQLPTRepresentation::SaveModuleType( } policy_table::ModuleTypes::const_iterator it; - for (it = types.begin(); it != types.end(); ++it) { + if (!types.empty()) { + for (it = types.begin(); it != types.end(); ++it) { + query.Bind(0, app_id); + std::string module(policy_table::EnumToJsonString(*it)); + query.Bind(1, module); + LOG4CXX_DEBUG(logger_, + "Module(app: " << app_id << ", type: " << module << ")"); + if (!query.Exec() || !query.Reset()) { + LOG4CXX_WARN(logger_, "Incorrect insert into module type."); + return false; + } + } + } else if (types.is_initialized()) { query.Bind(0, app_id); - std::string module(policy_table::EnumToJsonString(*it)); - query.Bind(1, module); - LOG4CXX_DEBUG(logger_, - "Module(app: " << app_id << ", type: " << module << ")"); + query.Bind(1, + std::string(policy_table::EnumToJsonString( + policy_table::ModuleType::MT_EMPTY))); if (!query.Exec() || !query.Reset()) { - LOG4CXX_WARN(logger_, "Incorrect insert into module type."); + LOG4CXX_WARN(logger_, "Incorrect insert into module types."); return false; - } + } + } else { + LOG4CXX_WARN(logger_, "Module Type omitted."); } - return true; } -- cgit v1.2.1 From ef697bb17ba91dcdc478b66e3e5fe5229e424443 Mon Sep 17 00:00:00 2001 From: JackLivio Date: Tue, 28 Aug 2018 16:04:17 -0400 Subject: Check style --- src/components/policy/policy_external/src/sql_pt_representation.cc | 2 +- src/components/policy/policy_regular/src/sql_pt_representation.cc | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/policy/policy_external/src/sql_pt_representation.cc b/src/components/policy/policy_external/src/sql_pt_representation.cc index 10be5a4626..ae9ba28852 100644 --- a/src/components/policy/policy_external/src/sql_pt_representation.cc +++ b/src/components/policy/policy_external/src/sql_pt_representation.cc @@ -1796,7 +1796,7 @@ bool SQLPTRepresentation::SaveModuleType( if (!query.Exec() || !query.Reset()) { LOG4CXX_WARN(logger_, "Incorrect insert into module types."); return false; - } + } } else { LOG4CXX_WARN(logger_, "Module Type omitted."); } diff --git a/src/components/policy/policy_regular/src/sql_pt_representation.cc b/src/components/policy/policy_regular/src/sql_pt_representation.cc index ee655d624f..81511f277a 100644 --- a/src/components/policy/policy_regular/src/sql_pt_representation.cc +++ b/src/components/policy/policy_regular/src/sql_pt_representation.cc @@ -1752,7 +1752,7 @@ bool SQLPTRepresentation::SaveModuleType( if (!query.Exec() || !query.Reset()) { LOG4CXX_WARN(logger_, "Incorrect insert into module types."); return false; - } + } } else { LOG4CXX_WARN(logger_, "Module Type omitted."); } -- cgit v1.2.1 From be2301cdaca2e4dcf72684d5b4198f10b61d08ff Mon Sep 17 00:00:00 2001 From: JackLivio Date: Tue, 28 Aug 2018 17:16:42 -0400 Subject: Add moduleType functions to sql_pt_ext --- .../policy_external/src/sql_pt_ext_representation.cc | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/components/policy/policy_external/src/sql_pt_ext_representation.cc b/src/components/policy/policy_external/src/sql_pt_ext_representation.cc index 5bb602244e..f26264ddf9 100644 --- a/src/components/policy/policy_external/src/sql_pt_ext_representation.cc +++ b/src/components/policy/policy_external/src/sql_pt_ext_representation.cc @@ -761,6 +761,13 @@ bool SQLPTExtRepresentation::SaveSpecificAppPolicy( if (!SaveAppGroup(app.first, app.second.groups)) { return false; } + + bool denied = !app.second.moduleType->is_initialized(); + if (!SaveRemoteControlDenied(app.first, denied) || + !SaveModuleType(app.first, *app.second.moduleType)) { + return false; + } + if (!SaveNickname(app.first, *app.second.nicknames)) { return false; } @@ -870,6 +877,17 @@ bool SQLPTExtRepresentation::GatherApplicationPoliciesSection( if (!GatherAppGroup(app_id, ¶ms.groups)) { return false; } + + bool denied = false; + if (!GatherRemoteControlDenied(app_id, &denied)) { + return false; + } + if (!denied) { + if (!GatherModuleType(app_id, &*params.moduleType)) { + return false; + } + } + if (!GatherNickName(app_id, &*params.nicknames)) { return false; } -- cgit v1.2.1