diff --git a/.travis.yml b/.travis.yml index 7060f4f33fd..643597354c6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -17,7 +17,7 @@ addons: before_install: - sudo apt-get update - sudo apt-get install libssl-dev libbluetooth3 libbluetooth-dev libudev-dev cmake html2text lcov git cmake automake1.11 build-essential libavahi-client-dev sqlite3 libsqlite3-dev libgtest-dev bluez-tools libpulse-dev libusb-1.0.0-dev cppcheck - - sudo apt-get install -f clang-format-3.6 + - sudo apt-get install -f clang-format-6.0 script: - cppcheck --force -isrc/3rd_party -isrc/3rd_party-static --quiet --error-exitcode=1 src diff --git a/CMakeLists.txt b/CMakeLists.txt index 38bb95c9fa8..351bfb4ab61 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -237,7 +237,7 @@ set(CMAKE_INSTALL_PREFIX ${CMAKE_CURRENT_BINARY_DIR}) set(ARCHIVE_OUTPUT_DIRECTORY ./bin) set(EXCLUDE_ERROR_FLAGS "-Wno-error=unused-variable -Wno-error=unused-but-set-variable -Wno-error=deprecated-declarations") -set(CMAKE_CXX_FLAGS "-fPIC -std=gnu++0x -Wall -Werror ${EXCLUDE_ERROR_FLAGS} -Wuninitialized -Wvla") +set(CMAKE_CXX_FLAGS "-fPIC -std=gnu++0x -Wall -fvisibility=hidden -Werror ${EXCLUDE_ERROR_FLAGS} -Wuninitialized -Wvla") if (USE_GOLD_LD) execute_process(COMMAND ld -v OUTPUT_VARIABLE result) @@ -343,7 +343,9 @@ 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_GLOBAL_INCLUDE_PATH + ${COMPONENTS_DIR}/include/policy/policy_external/ + ${CMAKE_BINARY_DIR}/src/components/policy/policy_external/) set(POLICY_MOCK_INCLUDE_PATH ${COMPONENTS_DIR}/include/test/policy/policy_external/) message(STATUS "EXTERNAL_PROPRIETARY policy enabled") else() @@ -354,7 +356,9 @@ 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_GLOBAL_INCLUDE_PATH + ${COMPONENTS_DIR}/include/policy/policy_regular/ + ${CMAKE_BINARY_DIR}/src/components/policy/policy_regular/) set(POLICY_MOCK_INCLUDE_PATH ${COMPONENTS_DIR}/include/test/policy/policy_regular/) endif() diff --git a/Doxyfile b/Doxyfile index 36155e37a7a..8674bd31144 100644 --- a/Doxyfile +++ b/Doxyfile @@ -899,7 +899,8 @@ EXAMPLE_RECURSIVE = NO # \image command). IMAGE_PATH = \ - src/components/security_manager/docs/assets + src/components/security_manager/docs/assets \ + src/components/protocol_handler/docs/assets # The INPUT_FILTER tag can be used to specify a program that doxygen should # invoke to filter for each input file. Doxygen will invoke the filter program diff --git a/README.md b/README.md index 86d07c3d83d..6166a513444 100644 --- a/README.md +++ b/README.md @@ -97,6 +97,7 @@ There are several RPCs that are "required" to be implemented in order for SDL to * DeleteCommand * AddSubMenu * DeleteSubMenu + * ShowAppMenu * CreateInteractionChoiceSet * PerformInteraction * DeleteInteractionChoiceSet diff --git a/src/appMain/hmi_capabilities.json b/src/appMain/hmi_capabilities.json index 873c80d32e2..91ddaf6d6ce 100755 --- a/src/appMain/hmi_capabilities.json +++ b/src/appMain/hmi_capabilities.json @@ -242,6 +242,16 @@ "resolutionWidth": 35, "resolutionHeight": 35 } + }, + { + "name": "alertIcon", + "imageTypeSupported": [ + "GRAPHIC_PNG" + ], + "imageResolution": { + "resolutionWidth": 225, + "resolutionHeight": 225 + } } ], @@ -249,6 +259,7 @@ "CLOCK1", "CLOCK2", "CLOCK3", "CLOCKTEXT1", "CLOCKTEXT2", "CLOCKTEXT3", "CLOCKTEXT4" ], "graphicSupported": true, + "menuLayoutsAvailable": [ "LIST", "TILES" ], "templatesAvailable": [ "DEFAULT", "MEDIA", "NON-MEDIA", "ONSCREEN_PRESETS", "NAV_FULLSCREEN_MAP", "NAV_KEYBOARD", "GRAPHIC_WITH_TEXT", "TEXT_WITH_GRAPHIC", "TILES_ONLY", "TEXTBUTTONS_ONLY", @@ -274,11 +285,11 @@ "STATIC" ] }, - "audioPassThruCapabilities": { + "audioPassThruCapabilities": [{ "samplingRate": "44KHZ", "bitsPerSample": "RATE_8_BIT", "audioType": "PCM" - }, + }], "pcmStreamCapabilities": { "samplingRate": "16KHZ", "bitsPerSample": "RATE_16_BIT", @@ -309,125 +320,220 @@ "protocol": "RAW", "codec": "H264" }], - "hapticSpatialDataSupported": false + "hapticSpatialDataSupported": false, + "diagonalScreenSize": 8, + "pixelPerInch": 117, + "scale": 1 + }, + "seatLocationCapability": { + "rows": 2, + "columns": 3, + "levels": 1, + "seats": [ + { + "row": 0, + "col": 0, + "level": 0, + "rowspan": 1, + "levelspan": 1, + "colspan": 1 + } + ] }, "remoteControlCapability": { "buttonCapabilities": [ { "longPressAvailable": true, "name": "AC_MAX", + "moduleInfo": { + "moduleId": "34045662-a9dc-4823-8435-91056d4c26cb", + "allowMultipleAccess": false + }, "shortPressAvailable": true, "upDownAvailable": false }, { "longPressAvailable": true, "name": "AC", + "moduleInfo": { + "moduleId": "34045662-a9dc-4823-8435-91056d4c26cb", + "allowMultipleAccess": false + }, "shortPressAvailable": true, "upDownAvailable": false }, { "longPressAvailable": true, "name": "RECIRCULATE", + "moduleInfo": { + "moduleId": "34045662-a9dc-4823-8435-91056d4c26cb", + "allowMultipleAccess": false + }, "shortPressAvailable": true, "upDownAvailable": false }, { "longPressAvailable": true, "name": "FAN_UP", + "moduleInfo": { + "moduleId": "34045662-a9dc-4823-8435-91056d4c26cb", + "allowMultipleAccess": false + }, "shortPressAvailable": true, "upDownAvailable": false }, { "longPressAvailable": true, "name": "FAN_DOWN", + "moduleInfo": { + "moduleId": "34045662-a9dc-4823-8435-91056d4c26cb", + "allowMultipleAccess": false + }, "shortPressAvailable": true, "upDownAvailable": false }, { "longPressAvailable": true, "name": "TEMP_UP", + "moduleInfo": { + "moduleId": "34045662-a9dc-4823-8435-91056d4c26cb", + "allowMultipleAccess": false + }, "shortPressAvailable": true, "upDownAvailable": false }, { "longPressAvailable": true, "name": "TEMP_DOWN", + "moduleInfo": { + "moduleId": "34045662-a9dc-4823-8435-91056d4c26cb", + "allowMultipleAccess": false + }, "shortPressAvailable": true, "upDownAvailable": false }, { "longPressAvailable": true, "name": "DEFROST_MAX", + "moduleInfo": { + "moduleId": "34045662-a9dc-4823-8435-91056d4c26cb", + "allowMultipleAccess": false + }, "shortPressAvailable": true, "upDownAvailable": false }, { "longPressAvailable": true, "name": "DEFROST", + "moduleInfo": { + "moduleId": "34045662-a9dc-4823-8435-91056d4c26cb", + "allowMultipleAccess": false + }, "shortPressAvailable": true, "upDownAvailable": false }, { "longPressAvailable": true, "name": "DEFROST_REAR", + "moduleInfo": { + "moduleId": "34045662-a9dc-4823-8435-91056d4c26cb", + "allowMultipleAccess": false + }, "shortPressAvailable": true, "upDownAvailable": false }, { "longPressAvailable": true, "name": "UPPER_VENT", + "moduleInfo": { + "moduleId": "34045662-a9dc-4823-8435-91056d4c26cb", + "allowMultipleAccess": false + }, "shortPressAvailable": true, "upDownAvailable": false }, { "longPressAvailable": true, "name": "LOWER_VENT", + "moduleInfo": { + "moduleId": "34045662-a9dc-4823-8435-91056d4c26cb", + "allowMultipleAccess": false + }, "shortPressAvailable": true, "upDownAvailable": false }, { "longPressAvailable": true, "name": "VOLUME_UP", + "moduleInfo": { + "moduleId": "eb7739ea-b263-4fe1-af9c-9311d1acac2d", + "allowMultipleAccess": false + }, "shortPressAvailable": true, "upDownAvailable": false }, { "longPressAvailable": true, "name": "VOLUME_DOWN", + "moduleInfo": { + "moduleId": "eb7739ea-b263-4fe1-af9c-9311d1acac2d", + "allowMultipleAccess": false + }, "shortPressAvailable": true, "upDownAvailable": false }, { "longPressAvailable": true, "name": "EJECT", + "moduleInfo": { + "moduleId": "eb7739ea-b263-4fe1-af9c-9311d1acac2d", + "allowMultipleAccess": false + }, "shortPressAvailable": true, "upDownAvailable": false }, { "longPressAvailable": true, "name": "SOURCE", + "moduleInfo": { + "moduleId": "eb7739ea-b263-4fe1-af9c-9311d1acac2d", + "allowMultipleAccess": false + }, "shortPressAvailable": true, "upDownAvailable": false }, { "longPressAvailable": true, "name": "SHUFFLE", + "moduleInfo": { + "moduleId": "eb7739ea-b263-4fe1-af9c-9311d1acac2d", + "allowMultipleAccess": false + }, "shortPressAvailable": true, "upDownAvailable": false }, { "longPressAvailable": true, "name": "REPEAT", + "moduleInfo": { + "moduleId": "eb7739ea-b263-4fe1-af9c-9311d1acac2d", + "allowMultipleAccess": false + }, "shortPressAvailable": true, "upDownAvailable": false } ], "climateControlCapabilities": [ { + "moduleInfo": { + "moduleId": "34045662-a9dc-4823-8435-91056d4c26cb", + "allowMultipleAccess": false + }, "acEnableAvailable": true, "acMaxEnableAvailable": true, "autoModeEnableAvailable": true, "circulateAirEnableAvailable": true, + "climateEnableAvailable": true, "currentTemperatureAvailable": true, "defrostZone": [ "FRONT", @@ -455,7 +561,11 @@ ], "radioControlCapabilities": [ { - "availableHDsAvailable": true, + "moduleInfo": { + "moduleId": "eb7739ea-b263-4fe1-af9c-9311d1acac2d", + "allowMultipleAccess": true + }, + "availableHdChannelsAvailable": true, "hdChannelAvailable": true, "moduleName": "radio", "radioBandAvailable": true, @@ -473,6 +583,10 @@ "audioControlCapabilities": [ { "moduleName": "audio", + "moduleInfo": { + "moduleId": "a279fe12-4587-4d12-8514-50f4ea9e9537", + "allowMultipleAccess": true + }, "sourceAvailable": true, "volumeAvailable": true, "equalizerAvailable": true, @@ -483,6 +597,10 @@ "seatControlCapabilities": [ { "moduleName": "driver_seat", + "moduleInfo": { + "moduleId": "06cdec22-920e-4865-bf2e-9518463edc68", + "allowMultipleAccess": false + }, "heatingEnabledAvailable" : true, "coolingEnabledAvailable": true, "heatingLevelAvailable": true, @@ -502,6 +620,10 @@ ], "lightControlCapabilities": { "moduleName": "light", + "moduleInfo": { + "moduleId": "8d73e369-6a1f-4459-ab5a-6e432631881d", + "allowMultipleAccess": false + }, "supportedLights":[ { "statusAvailable":true, @@ -795,6 +917,10 @@ }, "hmiSettingsControlCapabilities": { "moduleName": "hmiSettings", + "moduleInfo": { + "moduleId": "c8cace3c-d482-4be1-8862-624a21e34563", + "allowMultipleAccess": true + }, "distanceUnitAvailable": true, "temperatureUnitAvailable": true, "displayModeUnitAvailable": true diff --git a/src/appMain/life_cycle.h b/src/appMain/life_cycle.h index ff8fa2cc40a..b2e3c39f376 100644 --- a/src/appMain/life_cycle.h +++ b/src/appMain/life_cycle.h @@ -1,34 +1,34 @@ /* -* 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. -*/ + * 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_H_ #define SRC_APPMAIN_LIFE_CYCLE_H_ diff --git a/src/appMain/life_cycle_impl.cc b/src/appMain/life_cycle_impl.cc index efc627f33a6..146380f9536 100644 --- a/src/appMain/life_cycle_impl.cc +++ b/src/appMain/life_cycle_impl.cc @@ -1,46 +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. -*/ + * 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 "config_profile/profile.h" #include "application_manager/system_time/system_time_handler_impl.h" +#include "config_profile/profile.h" #include "resumption/last_state_impl.h" +#include "utils/signals.h" #ifdef ENABLE_SECURITY -#include "security_manager/security_manager_impl.h" +#include "application_manager/policies/policy_handler.h" #include "security_manager/crypto_manager_impl.h" #include "security_manager/crypto_manager_settings_impl.h" -#include "application_manager/policies/policy_handler.h" +#include "security_manager/security_manager_impl.h" #endif // ENABLE_SECURITY #ifdef ENABLE_LOG @@ -103,6 +103,13 @@ bool LifeCycleImpl::StartComponents() { app_manager_ = new application_manager::ApplicationManagerImpl(profile_, profile_); + auto service_status_update_handler = + std::unique_ptr( + new protocol_handler::ServiceStatusUpdateHandler(app_manager_)); + + protocol_handler_->set_service_status_update_handler( + std::move(service_status_update_handler)); + DCHECK(!hmi_handler_); hmi_handler_ = new hmi_message_handler::HMIMessageHandlerImpl(profile_); @@ -168,7 +175,8 @@ bool LifeCycleImpl::StartComponents() { return false; } // start transport manager - transport_manager_->Visibility(true); + transport_manager_->PerformActionOnClients( + transport_manager::TransportAction::kVisibilityOn); LowVoltageSignalsOffset signals_offset{profile_.low_voltage_signal_offset(), profile_.wake_up_signal_offset(), @@ -182,7 +190,10 @@ bool LifeCycleImpl::StartComponents() { void LifeCycleImpl::LowVoltage() { LOG4CXX_AUTO_TRACE(logger_); - transport_manager_->Visibility(false); + transport_manager_->PerformActionOnClients( + transport_manager::TransportAction::kListeningOff); + transport_manager_->StopEventsProcessing(); + transport_manager_->Deinit(); app_manager_->OnLowVoltage(); } @@ -193,9 +204,11 @@ void LifeCycleImpl::IgnitionOff() { void LifeCycleImpl::WakeUp() { LOG4CXX_AUTO_TRACE(logger_); - app_manager_->OnWakeUp(); transport_manager_->Reinit(); - transport_manager_->Visibility(true); + transport_manager_->PerformActionOnClients( + transport_manager::TransportAction::kListeningOn); + app_manager_->OnWakeUp(); + transport_manager_->StartEventsProcessing(); } #ifdef MESSAGEBROKER_HMIADAPTER @@ -286,7 +299,8 @@ void LifeCycleImpl::StopComponents() { LOG4CXX_INFO(logger_, "Destroying Transport Manager."); DCHECK_OR_RETURN_VOID(transport_manager_); - transport_manager_->Visibility(false); + transport_manager_->PerformActionOnClients( + transport_manager::TransportAction::kVisibilityOff); transport_manager_->Stop(); delete transport_manager_; transport_manager_ = NULL; diff --git a/src/appMain/life_cycle_impl.h b/src/appMain/life_cycle_impl.h index 5dfc4641ab2..5bddf6bff94 100644 --- a/src/appMain/life_cycle_impl.h +++ b/src/appMain/life_cycle_impl.h @@ -1,34 +1,34 @@ /* -* 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. -*/ + * 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_ @@ -36,8 +36,8 @@ #include "appMain/life_cycle.h" #include -#include #include +#include #include "utils/macro.h" #include "config_profile/profile.h" @@ -47,10 +47,10 @@ #endif // #if ( defined (MESSAGEBROKER_HMIADAPTER) || defined(PASA_HMI) ) #include "application_manager/application_manager_impl.h" #include "connection_handler/connection_handler_impl.h" +#include "media_manager/media_manager_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 diff --git a/src/appMain/low_voltage_signals_handler.cc b/src/appMain/low_voltage_signals_handler.cc index 936d91ba18a..bb7bbfbac7c 100644 --- a/src/appMain/low_voltage_signals_handler.cc +++ b/src/appMain/low_voltage_signals_handler.cc @@ -32,17 +32,17 @@ #include "appMain/low_voltage_signals_handler.h" -#include #include +#include #include #include #include #include #include "appMain/life_cycle.h" -#include "utils/signals.h" +#include "config_profile/profile.h" #include "utils/logger.h" +#include "utils/signals.h" #include "utils/typed_enum_print.h" -#include "config_profile/profile.h" namespace main_namespace { diff --git a/src/appMain/low_voltage_signals_handler.h b/src/appMain/low_voltage_signals_handler.h index 8c139c6836f..bedde38c5cd 100644 --- a/src/appMain/low_voltage_signals_handler.h +++ b/src/appMain/low_voltage_signals_handler.h @@ -35,8 +35,8 @@ #include #include -#include "utils/threads/thread_delegate.h" #include "utils/threads/thread.h" +#include "utils/threads/thread_delegate.h" namespace main_namespace { diff --git a/src/appMain/main.cc b/src/appMain/main.cc index 4e91b912161..cb59f63b1d3 100644 --- a/src/appMain/main.cc +++ b/src/appMain/main.cc @@ -30,16 +30,16 @@ * POSSIBILITY OF SUCH DAMAGE. */ +#include #include #include -#include #include #include +#include // cpplint: Streams are highly discouraged. +#include // cpplint: Streams are highly discouraged. #include -#include #include -#include // cpplint: Streams are highly discouraged. -#include // cpplint: Streams are highly discouraged. +#include // ---------------------------------------------------------------------------- @@ -51,10 +51,10 @@ #include "appMain/life_cycle_impl.h" #include "signal_handlers.h" -#include "utils/signals.h" -#include "utils/system.h" #include "config_profile/profile.h" #include "utils/appenders_loader.h" +#include "utils/signals.h" +#include "utils/system.h" #if defined(EXTENDED_MEDIA_MODE) #include @@ -88,7 +88,7 @@ bool InitHmi(std::string hmi_link) { .Execute(); } #endif // WEB_HMI -} +} // namespace /** * \brief Entry point of the program. diff --git a/src/appMain/sdl_preloaded_pt.json b/src/appMain/sdl_preloaded_pt.json index 4e39a735d1b..bdd7b4e8c85 100644 --- a/src/appMain/sdl_preloaded_pt.json +++ b/src/appMain/sdl_preloaded_pt.json @@ -1,2529 +1,4091 @@ -{ - "policy_table": { - "module_config": { - "preloaded_pt": true, - "exchange_after_x_ignition_cycles": 100, - "exchange_after_x_kilometers": 1800, - "exchange_after_x_days": 30, - "timeout_after_x_seconds": 60, - "seconds_between_retries": [1, - 5, - 25, - 125, - 625], - "endpoints": { - "0x07": { - "default": ["http://x.x.x.x:3000/api/1/policies/proprietary"] - }, - "0x04": { - "default": ["http://x.x.x.x:3000/api/1/softwareUpdate"] - }, - "queryAppsUrl": { - "default": ["http://sdl.shaid.server"] - }, - "lock_screen_icon_url": { - "default": ["http://i.imgur.com/TgkvOIZ.png"] - } - }, - "notifications_per_minute_by_priority": { - "EMERGENCY": 60, - "NAVIGATION": 15, - "PROJECTION": 15, - "VOICECOM": 20, - "COMMUNICATION": 6, - "NORMAL": 4, - "NONE": 0 - } - }, - "functional_groupings": { - "Base-4": { - "rpcs": { - "AddCommand": { - "hmi_levels": ["BACKGROUND", - "FULL", - "LIMITED"] - }, - "AddSubMenu": { - "hmi_levels": ["BACKGROUND", - "FULL", - "LIMITED"] - }, - "Alert": { - "hmi_levels": ["FULL", - "LIMITED"] - }, - "ChangeRegistration": { - "hmi_levels": ["BACKGROUND", - "FULL", - "LIMITED", - "NONE"] - }, - "CreateInteractionChoiceSet": { - "hmi_levels": ["BACKGROUND", - "FULL", - "LIMITED"] - }, - "DeleteCommand": { - "hmi_levels": ["BACKGROUND", - "FULL", - "LIMITED"] - }, - "DeleteFile": { - "hmi_levels": ["BACKGROUND", - "FULL", - "LIMITED", - "NONE"] - }, - "DeleteInteractionChoiceSet": { - "hmi_levels": ["BACKGROUND", - "FULL", - "LIMITED"] - }, - "DeleteSubMenu": { - "hmi_levels": ["BACKGROUND", - "FULL", - "LIMITED"] - }, - "EncodedSyncPData": { - "hmi_levels": ["BACKGROUND", - "FULL", - "LIMITED", - "NONE"] - }, - "EndAudioPassThru": { - "hmi_levels": ["BACKGROUND", - "FULL", - "LIMITED"] - }, - "GenericResponse": { - "hmi_levels": ["BACKGROUND", - "FULL", - "LIMITED"] - }, - "GetSystemCapability": { - "hmi_levels": ["BACKGROUND", - "FULL", - "LIMITED", - "NONE"] - }, - "ListFiles": { - "hmi_levels": ["BACKGROUND", - "FULL", - "LIMITED", - "NONE"] - }, - "OnAppInterfaceUnregistered": { - "hmi_levels": ["BACKGROUND", - "FULL", - "LIMITED", - "NONE"] - }, - "OnAudioPassThru": { - "hmi_levels": ["BACKGROUND", - "FULL", - "LIMITED"] - }, - "OnButtonEvent": { - "hmi_levels": ["FULL", - "LIMITED", - "BACKGROUND"] - }, - "OnButtonPress": { - "hmi_levels": ["FULL", - "LIMITED", - "BACKGROUND"] - }, - "OnCommand": { - "hmi_levels": ["BACKGROUND", - "FULL", - "LIMITED"] - }, - "OnDriverDistraction": { - "hmi_levels": ["BACKGROUND", - "FULL", - "LIMITED", - "NONE"] - }, - "OnEncodedSyncPData": { - "hmi_levels": ["BACKGROUND", - "FULL", - "LIMITED", - "NONE"] - }, - "OnHashChange": { - "hmi_levels": ["BACKGROUND", - "FULL", - "LIMITED", - "NONE"] - }, - "OnHMIStatus": { - "hmi_levels": ["BACKGROUND", - "FULL", - "LIMITED", - "NONE"] - }, - "OnLanguageChange": { - "hmi_levels": ["BACKGROUND", - "FULL", - "LIMITED", - "NONE"] - }, - "OnPermissionsChange": { - "hmi_levels": ["BACKGROUND", - "FULL", - "LIMITED", - "NONE"] - }, - "OnSystemRequest": { - "hmi_levels": ["BACKGROUND", - "FULL", - "LIMITED", - "NONE"] - }, - "OnSystemCapabilityUpdated": { - "hmi_levels": ["BACKGROUND", - "FULL", - "LIMITED", - "NONE"] - }, - "PerformAudioPassThru": { - "hmi_levels": ["FULL", - "LIMITED"] - }, - "PerformInteraction": { - "hmi_levels": ["FULL", - "LIMITED"] - }, - "PutFile": { - "hmi_levels": ["BACKGROUND", - "FULL", - "LIMITED", - "NONE"] - }, - "RegisterAppInterface": { - "hmi_levels": ["BACKGROUND", - "FULL", - "LIMITED", - "NONE"] - }, - "ResetGlobalProperties": { - "hmi_levels": ["BACKGROUND", - "FULL", - "LIMITED", - "NONE"] - }, - "ScrollableMessage": { - "hmi_levels": ["FULL"] - }, - "SetAppIcon": { - "hmi_levels": ["BACKGROUND", - "FULL", - "LIMITED", - "NONE"] - }, - "SetDisplayLayout": { - "hmi_levels": ["BACKGROUND", - "FULL", - "LIMITED", - "NONE"] - }, - "SetGlobalProperties": { - "hmi_levels": ["BACKGROUND", - "FULL", - "LIMITED", - "NONE"] - }, - "SetMediaClockTimer": { - "hmi_levels": ["FULL", - "LIMITED", - "BACKGROUND"] - }, - "Show": { - "hmi_levels": ["BACKGROUND", - "FULL", - "LIMITED"] - }, - "Slider": { - "hmi_levels": ["FULL"] - }, - "Speak": { - "hmi_levels": ["FULL", - "LIMITED"] - }, - "SubscribeButton": { - "hmi_levels": ["BACKGROUND", - "FULL", - "LIMITED"] - }, - "SystemRequest": { - "hmi_levels": ["BACKGROUND", - "FULL", - "LIMITED", - "NONE"] - }, - "UnregisterAppInterface": { - "hmi_levels": ["BACKGROUND", - "FULL", - "LIMITED", - "NONE"] - }, - "UnsubscribeButton": { - "hmi_levels": ["BACKGROUND", - "FULL", - "LIMITED"] - } - } - }, - "Location-1": { - "user_consent_prompt": "Location", - "rpcs": { - "GetVehicleData": { - "hmi_levels": ["BACKGROUND", - "FULL", - "LIMITED"], - "parameters": ["gps", - "speed"] - }, - "OnVehicleData": { - "hmi_levels": ["BACKGROUND", - "FULL", - "LIMITED"], - "parameters": ["gps", - "speed"] - }, - "SubscribeVehicleData": { - "hmi_levels": ["BACKGROUND", - "FULL", - "LIMITED"], - "parameters": ["gps", - "speed"] - }, - "UnsubscribeVehicleData": { - "hmi_levels": ["BACKGROUND", - "FULL", - "LIMITED"], - "parameters": ["gps", - "speed"] - } - } - }, - "Notifications": { - "user_consent_prompt": "Notifications", - "rpcs": { - "Alert": { - "hmi_levels": ["BACKGROUND"] - } - } - }, - "Notifications-RC": { - "rpcs": { - "OnHMIStatus": { - "hmi_levels": [ - "BACKGROUND", - "FULL", - "LIMITED", - "NONE" - ] - }, - "OnPermissionsChange": { - "hmi_levels": [ - "BACKGROUND", - "FULL", - "LIMITED", - "NONE" - ] - }, - "OnSystemRequest": { - "hmi_levels": [ - "BACKGROUND", - "FULL", - "LIMITED", - "NONE" - ] - } - } - }, - "DrivingCharacteristics-3": { - "user_consent_prompt": "DrivingCharacteristics", - "rpcs": { - "GetVehicleData": { - "hmi_levels": ["BACKGROUND", - "FULL", - "LIMITED"], - "parameters": ["accPedalPosition", - "beltStatus", - "electronicParkBrakeStatus", - "driverBraking", - "myKey", - "prndl", - "rpm", - "steeringWheelAngle"] - }, - "OnVehicleData": { - "hmi_levels": ["BACKGROUND", - "FULL", - "LIMITED"], - "parameters": ["accPedalPosition", - "beltStatus", - "electronicParkBrakeStatus", - "driverBraking", - "myKey", - "prndl", - "rpm", - "steeringWheelAngle"] - }, - "SubscribeVehicleData": { - "hmi_levels": ["BACKGROUND", - "FULL", - "LIMITED"], - "parameters": ["accPedalPosition", - "beltStatus", - "electronicParkBrakeStatus", - "driverBraking", - "myKey", - "prndl", - "rpm", - "steeringWheelAngle"] - }, - "UnsubscribeVehicleData": { - "hmi_levels": ["BACKGROUND", - "FULL", - "LIMITED"], - "parameters": ["accPedalPosition", - "beltStatus", - "electronicParkBrakeStatus", - "driverBraking", - "myKey", - "prndl", - "rpm", - "steeringWheelAngle"] - } - } - }, - "VehicleInfo-3": { - "user_consent_prompt": "VehicleInfo", - "rpcs": { - "GetVehicleData": { - "hmi_levels": ["BACKGROUND", - "FULL", - "LIMITED"], - "parameters": ["bodyInformation", - "deviceStatus", - "engineOilLife", - "engineTorque", - "externalTemperature", - "turnSignal", - "fuelLevel", - "fuelLevel_State", - "headLampStatus", - "instantFuelConsumption", - "fuelRange", - "cloudAppVehicleID", - "odometer", - "tirePressure", - "vin", - "wiperStatus"] - }, - "OnVehicleData": { - "hmi_levels": ["BACKGROUND", - "FULL", - "LIMITED"], - "parameters": ["bodyInformation", - "deviceStatus", - "engineOilLife", - "engineTorque", - "externalTemperature", - "turnSignal", - "fuelLevel", - "fuelLevel_State", - "headLampStatus", - "instantFuelConsumption", - "fuelRange", - "cloudAppVehicleID", - "odometer", - "tirePressure", - "vin", - "wiperStatus"] - }, - "SubscribeVehicleData": { - "hmi_levels": ["BACKGROUND", - "FULL", - "LIMITED"], - "parameters": ["bodyInformation", - "deviceStatus", - "engineOilLife", - "engineTorque", - "externalTemperature", - "turnSignal", - "fuelLevel", - "fuelLevel_State", - "headLampStatus", - "instantFuelConsumption", - "fuelRange", - "cloudAppVehicleID", - "odometer", - "tirePressure", - "wiperStatus"] - }, - "UnsubscribeVehicleData": { - "hmi_levels": ["BACKGROUND", - "FULL", - "LIMITED"], - "parameters": ["bodyInformation", - "deviceStatus", - "engineOilLife", - "engineTorque", - "externalTemperature", - "turnSignal", - "fuelLevel", - "fuelLevel_State", - "headLampStatus", - "instantFuelConsumption", - "fuelRange", - "cloudAppVehicleID", - "odometer", - "tirePressure", - "wiperStatus"] - } - } - }, - "PropriataryData-1": { - "rpcs": { - "DiagnosticMessage": { - "hmi_levels": ["BACKGROUND", - "FULL", - "LIMITED"] - }, - "GetDTCs": { - "hmi_levels": ["BACKGROUND", - "FULL", - "LIMITED"] - }, - "ReadDID": { - "hmi_levels": ["BACKGROUND", - "FULL", - "LIMITED"] - } - } - }, - "PropriataryData-2": { - "rpcs": { - "DiagnosticMessage": { - "hmi_levels": ["BACKGROUND", - "FULL", - "LIMITED"] - }, - "GetDTCs": { - "hmi_levels": ["BACKGROUND", - "FULL", - "LIMITED"] - }, - "ReadDID": { - "hmi_levels": ["BACKGROUND", - "FULL", - "LIMITED"] - } - } - }, - "ProprietaryData-3": { - "rpcs": { - "GetDTCs": { - "hmi_levels": ["BACKGROUND", - "FULL", - "LIMITED"] - }, - "ReadDID": { - "hmi_levels": ["BACKGROUND", - "FULL", - "LIMITED"] - } - } - }, - "CloudAppStore": { - "rpcs": { - "SetCloudAppProperties":{ - "hmi_levels":["BACKGROUND", - "FULL", - "LIMITED"] - }, - "GetCloudAppProperties":{ - "hmi_levels":["BACKGROUND", - "FULL", - "LIMITED"] - } - } - }, - "CloudApp": { - "rpcs": { - "GetVehicleData": { - "hmi_levels": ["BACKGROUND", - "FULL", - "LIMITED"], - "parameters": [ - "cloudAppVehicleID" - ] - }, - "OnVehicleData": { - "hmi_levels": ["BACKGROUND", - "FULL", - "LIMITED"], - "parameters": [ - "cloudAppVehicleID" - ] - }, - "SubscribeVehicleData": { - "hmi_levels": ["BACKGROUND", - "FULL", - "LIMITED"], - "parameters": [ - "cloudAppVehicleID" - ] - }, - "UnsubscribeVehicleData": { - "hmi_levels": ["BACKGROUND", - "FULL", - "LIMITED"], - "parameters": [ - "cloudAppVehicleID" - ] - } - } - }, - "AppServiceProvider": { - "rpcs": { - "PublishAppService": { - "hmi_levels": [ - "FULL", - "LIMITED", - "BACKGROUND", - "NONE" - ] - }, - "GetAppServiceData": { - "hmi_levels": [ - "FULL", - "LIMITED", - "BACKGROUND", - "NONE" - ] - }, - "OnAppServiceData": { - "hmi_levels": [ - "FULL", - "LIMITED", - "BACKGROUND", - "NONE" - ] - }, - "PerformAppServiceInteraction": { - "hmi_levels": [ - "FULL", - "LIMITED", - "BACKGROUND", - "NONE" - ] - } - } - }, - "AppServiceConsumer": { - "rpcs": { - "GetFile": { - "hmi_levels": [ - "FULL", - "LIMITED", - "BACKGROUND", - "NONE" - ] - }, - "GetAppServiceData": { - "hmi_levels": [ - "FULL", - "LIMITED", - "BACKGROUND", - "NONE" - ] - }, - "OnAppServiceData": { - "hmi_levels": [ - "FULL", - "LIMITED", - "BACKGROUND", - "NONE" - ] - }, - "PerformAppServiceInteraction": { - "hmi_levels": [ - "FULL", - "LIMITED", - "BACKGROUND", - "NONE" - ] - } - } - }, - "RemoteControl": { - "rpcs": { - "ButtonPress": { - "hmi_levels": ["BACKGROUND", - "FULL", - "LIMITED"] - }, - "GetInteriorVehicleData": { - "hmi_levels": ["BACKGROUND", - "FULL", - "LIMITED"] - }, - "SetInteriorVehicleData": { - "hmi_levels": ["BACKGROUND", - "FULL", - "LIMITED"] - }, - "OnInteriorVehicleData": { - "hmi_levels": ["BACKGROUND", - "FULL", - "LIMITED"] - }, - "SystemRequest": { - "hmi_levels": ["BACKGROUND", - "FULL", - "LIMITED", - "NONE"] - }, - "OnRCStatus": { - "hmi_levels": ["BACKGROUND", - "FULL", - "LIMITED", - "NONE"] - } - } - }, - "Emergency-1": { - "rpcs": { - "GetVehicleData": { - "hmi_levels": ["BACKGROUND", - "FULL", - "LIMITED"], - "parameters": ["airbagStatus", - "clusterModeStatus", - "eCallInfo", - "emergencyEvent"] - }, - "OnVehicleData": { - "hmi_levels": ["BACKGROUND", - "FULL", - "LIMITED"], - "parameters": ["airbagStatus", - "clusterModeStatus", - "eCallInfo", - "emergencyEvent"] - }, - "SubscribeVehicleData": { - "hmi_levels": ["BACKGROUND", - "FULL", - "LIMITED"], - "parameters": ["airbagStatus", - "clusterModeStatus", - "eCallInfo", - "emergencyEvent"] - }, - "UnsubscribeVehicleData": { - "hmi_levels": ["BACKGROUND", - "FULL", - "LIMITED"], - "parameters": ["airbagStatus", - "clusterModeStatus", - "eCallInfo", - "emergencyEvent"] - } - } - }, - "Navigation-1": { - "rpcs": { - "AlertManeuver": { - "hmi_levels": ["BACKGROUND", - "FULL", - "LIMITED"] - }, - "ShowConstantTBT": { - "hmi_levels": ["BACKGROUND", - "FULL", - "LIMITED"] - }, - "UpdateTurnList": { - "hmi_levels": ["BACKGROUND", - "FULL", - "LIMITED"] - } - } - }, - "Base-6": { - "rpcs": { - "AddCommand": { - "hmi_levels": ["BACKGROUND", - "FULL", - "LIMITED"] - }, - "AddSubMenu": { - "hmi_levels": ["BACKGROUND", - "FULL", - "LIMITED"] - }, - "Alert": { - "hmi_levels": ["FULL", - "LIMITED"] - }, - "ChangeRegistration": { - "hmi_levels": ["BACKGROUND", - "FULL", - "LIMITED", - "NONE"] - }, - "CreateInteractionChoiceSet": { - "hmi_levels": ["BACKGROUND", - "FULL", - "LIMITED"] - }, - "DeleteCommand": { - "hmi_levels": ["BACKGROUND", - "FULL", - "LIMITED"] - }, - "DeleteFile": { - "hmi_levels": ["BACKGROUND", - "FULL", - "LIMITED", - "NONE"] - }, - "DeleteInteractionChoiceSet": { - "hmi_levels": ["BACKGROUND", - "FULL", - "LIMITED"] - }, - "DeleteSubMenu": { - "hmi_levels": ["BACKGROUND", - "FULL", - "LIMITED"] - }, - "EncodedSyncPData": { - "hmi_levels": ["BACKGROUND", - "FULL", - "LIMITED", - "NONE"] - }, - "EndAudioPassThru": { - "hmi_levels": ["BACKGROUND", - "FULL", - "LIMITED"] - }, - "GenericResponse": { - "hmi_levels": ["BACKGROUND", - "FULL", - "LIMITED"] - }, - "ListFiles": { - "hmi_levels": ["BACKGROUND", - "FULL", - "LIMITED", - "NONE"] - }, - "OnAppInterfaceUnregistered": { - "hmi_levels": ["BACKGROUND", - "FULL", - "LIMITED", - "NONE"] - }, - "OnAudioPassThru": { - "hmi_levels": ["BACKGROUND", - "FULL", - "LIMITED"] - }, - "OnButtonEvent": { - "hmi_levels": ["FULL", - "LIMITED"] - }, - "OnButtonPress": { - "hmi_levels": ["FULL", - "LIMITED"] - }, - "OnCommand": { - "hmi_levels": ["FULL", - "LIMITED"] - }, - "OnDriverDistraction": { - "hmi_levels": ["BACKGROUND", - "FULL", - "LIMITED", - "NONE"] - }, - "OnEncodedSyncPData": { - "hmi_levels": ["BACKGROUND", - "FULL", - "LIMITED", - "NONE"] - }, - "OnHMIStatus": { - "hmi_levels": ["BACKGROUND", - "FULL", - "LIMITED", - "NONE"] - }, - "OnLanguageChange": { - "hmi_levels": ["BACKGROUND", - "FULL", - "LIMITED", - "NONE"] - }, - "OnPermissionsChange": { - "hmi_levels": ["BACKGROUND", - "FULL", - "LIMITED", - "NONE"] - }, - "OnSyncPData": { - "hmi_levels": ["BACKGROUND", - "FULL", - "LIMITED", - "NONE"] - }, - "OnTBTClientState": { - "hmi_levels": ["BACKGROUND", - "FULL", - "LIMITED"] - }, - "PerformAudioPassThru": { - "hmi_levels": ["FULL", - "LIMITED"] - }, - "PerformInteraction": { - "hmi_levels": ["FULL", - "LIMITED"] - }, - "PutFile": { - "hmi_levels": ["BACKGROUND", - "FULL", - "LIMITED", - "NONE"] - }, - "RegisterAppInterface": { - "hmi_levels": ["BACKGROUND", - "FULL", - "LIMITED", - "NONE"] - }, - "ResetGlobalProperties": { - "hmi_levels": ["BACKGROUND", - "FULL", - "LIMITED"] - }, - "ScrollableMessage": { - "hmi_levels": ["FULL"] - }, - "SetAppIcon": { - "hmi_levels": ["BACKGROUND", - "FULL", - "LIMITED", - "NONE"] - }, - "SetDisplayLayout": { - "hmi_levels": ["BACKGROUND", - "FULL", - "LIMITED", - "NONE"] - }, - "SetGlobalProperties": { - "hmi_levels": ["BACKGROUND", - "FULL", - "LIMITED"] - }, - "SetMediaClockTimer": { - "hmi_levels": ["FULL"] - }, - "Show": { - "hmi_levels": ["BACKGROUND", - "FULL", - "LIMITED"] - }, - "Slider": { - "hmi_levels": ["FULL"] - }, - "Speak": { - "hmi_levels": ["FULL", - "LIMITED"] - }, - "SubscribeButton": { - "hmi_levels": ["BACKGROUND", - "FULL", - "LIMITED"] - }, - "SyncPData": { - "hmi_levels": ["BACKGROUND", - "FULL", - "LIMITED", - "NONE"] - }, - "UnregisterAppInterface": { - "hmi_levels": ["BACKGROUND", - "FULL", - "LIMITED", - "NONE"] - }, - "UnsubscribeButton": { - "hmi_levels": ["BACKGROUND", - "FULL", - "LIMITED"] - } - } - }, - "OnKeyboardInputOnlyGroup": { - "rpcs": { - "OnKeyboardInput": { - "hmi_levels": ["FULL"] - } - } - }, - "OnTouchEventOnlyGroup": { - "rpcs": { - "OnTouchEvent": { - "hmi_levels": ["FULL"] - } - } - }, - "DiagnosticMessageOnly": { - "rpcs": { - "DiagnosticMessage": { - "hmi_levels": ["BACKGROUND", - "FULL", - "LIMITED"] - } - } - }, - "DataConsent-2": { - "user_consent_prompt": "DataConsent", - "rpcs": null - }, - "BaseBeforeDataConsent": { - "rpcs": { - "ChangeRegistration": { - "hmi_levels": ["BACKGROUND", - "FULL", - "LIMITED", - "NONE"] - }, - "DeleteFile": { - "hmi_levels": ["BACKGROUND", - "FULL", - "LIMITED", - "NONE"] - }, - "EncodedSyncPData": { - "hmi_levels": ["BACKGROUND", - "FULL", - "LIMITED", - "NONE"] - }, - "ListFiles": { - "hmi_levels": ["BACKGROUND", - "FULL", - "LIMITED", - "NONE"] - }, - "OnAppInterfaceUnregistered": { - "hmi_levels": ["BACKGROUND", - "FULL", - "LIMITED", - "NONE"] - }, - "OnEncodedSyncPData": { - "hmi_levels": ["BACKGROUND", - "FULL", - "LIMITED", - "NONE"] - }, - "OnHashChange": { - "hmi_levels": ["BACKGROUND", - "FULL", - "LIMITED", - "NONE"] - }, - "OnHMIStatus": { - "hmi_levels": ["BACKGROUND", - "FULL", - "LIMITED", - "NONE"] - }, - "OnLanguageChange": { - "hmi_levels": ["BACKGROUND", - "FULL", - "LIMITED", - "NONE"] - }, - "OnPermissionsChange": { - "hmi_levels": ["BACKGROUND", - "FULL", - "LIMITED", - "NONE"] - }, - "OnSystemRequest": { - "hmi_levels": ["BACKGROUND", - "FULL", - "LIMITED", - "NONE"] - }, - "PutFile": { - "hmi_levels": ["BACKGROUND", - "FULL", - "LIMITED", - "NONE"] - }, - "RegisterAppInterface": { - "hmi_levels": ["BACKGROUND", - "FULL", - "LIMITED", - "NONE"] - }, - "ResetGlobalProperties": { - "hmi_levels": ["BACKGROUND", - "FULL", - "LIMITED", - "NONE"] - }, - "SetGlobalProperties": { - "hmi_levels": ["BACKGROUND", - "FULL", - "LIMITED", - "NONE"] - }, - "SetAppIcon": { - "hmi_levels": ["BACKGROUND", - "FULL", - "LIMITED", - "NONE"] - }, - "SetDisplayLayout": { - "hmi_levels": ["BACKGROUND", - "FULL", - "LIMITED", - "NONE"] - }, - "SystemRequest": { - "hmi_levels": ["BACKGROUND", - "FULL", - "LIMITED", - "NONE"] - }, - "UnregisterAppInterface": { - "hmi_levels": ["BACKGROUND", - "FULL", - "LIMITED", - "NONE"] - } - } - }, - "SendLocation": { - "rpcs": { - "SendLocation": { - "hmi_levels": ["BACKGROUND", - "FULL", - "LIMITED"] - } - } - }, - "WayPoints": { - "rpcs": { - "GetWayPoints": { - "hmi_levels": ["BACKGROUND", - "FULL", - "LIMITED"] - }, - "SubscribeWayPoints": { - "hmi_levels": ["BACKGROUND", - "FULL", - "LIMITED"] - }, - "UnsubscribeWayPoints": { - "hmi_levels": ["BACKGROUND", - "FULL", - "LIMITED"] - }, - "OnWayPointChange": { - "hmi_levels": ["BACKGROUND", - "FULL", - "LIMITED"] - } - } - }, - "BackgroundAPT": { - "rpcs": { - "EndAudioPassThru": { - "hmi_levels": ["BACKGROUND"] - }, - "OnAudioPassThru": { - "hmi_levels": ["BACKGROUND"] - }, - "PerformAudioPassThru": { - "hmi_levels": ["BACKGROUND"] - } - } - }, - "HapticGroup": { - "rpcs": { - "OnTouchEvent": { - "hmi_levels": ["FULL"] - }, - "SendHapticData": { - "hmi_levels": ["FULL"] - } - } - } - }, - "consumer_friendly_messages": { - "version": "001.001.021", - "messages": { - "AppPermissions": { - "languages": { - "de-de": { - "tts": "%appName% benötigt die folgenden Fahrzeuginformationen und Zugriffsberechtigungen: %functionalGroupLabels%. Wenn Sie Ja drücken, erklären Sie sich damit einverstanden, dass %vehicleMake% nicht für Schäden oder Verletzungen der Privatsphäre haftet, die im Zusammenhang mit der Nutzung Ihrer Benutzerdaten durch %appName% entstehen. Mit Ja stimmen Sie zu; mit Nein lehnen Sie ab.", - "line1": "Zugriffsanfrage(n)", - "line2": "erlauben?" - }, - "en-au": { - "tts": "%appName% is requesting the use of the following vehicle information and permissions: %functionalGroupLabels%. If you press Yes, you agree that %vehicleMake% will not be liable for any damages or loss of privacy related to %appName%'s use of your data. Please press Yes to allow or No to deny.", - "line1": "Grant requested", - "line2": "permission(s)?" - }, - "en-gb": { - "tts": "%appName% is requesting the use of the following vehicle information and permissions: %functionalGroupLabels%. If you press Yes, you agree that %vehicleMake% will not be liable for any damages or loss of privacy related to %appName%`s use of your data. Please press Yes to allow or No to deny.", - "line1": "Grant requested", - "line2": "permission(s)?", - "textBody": "%appName% is requesting the use of the following vehicle information and permissions: %functionalGroupLabels%. If you press yes, you agree that %vehicleMake% will not be liable for any damages or loss of privacy related to %appName%`s use of your data. You can change these permissions and hear detailed descriptions in the mobile apps settings menu." - }, - "en-ie": { - "tts": "%appName% is requesting the use of the following vehicle information and permissions: %functionalGroupLabels%. If you press Yes, you agree that %vehicleMake% will not be liable for any damages or loss of privacy related to %appName%'s use of your data. Please press Yes to allow or No to deny.", - "line1": "Grant requested", - "line2": "permission(s)?" - }, - "en-us": { - "tts": "%appName% is requesting the use of the following vehicle information and permissions: %functionalGroupLabels%. If you press yes, you agree that %vehicleMake% will not be liable for any damages or loss of privacy related to %appName%’s use of your data. Please press yes to allow or no to deny.", - "line1": "Grant Requested", - "line2": "Permission(s)?", - "textBody": "%appName% is requesting the use of the following vehicle information and permissions: %functionalGroupLabels%. \n\nIf you press yes, you agree that %vehicleMake% will not be liable for any damages or loss of privacy related to %appName%’s use of your data. You can change these permissions and hear detailed descriptions in the mobile apps settings menu." - }, - "es-en": { - "tts": "%appName% solicita el uso de la siguiente información y permisos del vehículo: %functionalGroupLabels%. Si presiona Sí, acepta que %vehicleMake% no se hará responsable por los daños o pérdidas de privacidad relacionados con el uso que %appName% haga de sus datos. Presione Sí para permitir y No para denegar.", - "line1": "¿Otorgar permiso(s)", - "line2": "solicitado(s)?", - "textBody": "%appName% solicita el uso de la siguiente información y permisos del vehículo: %functionalGroupLabels%. Si presiona Sí, acepta que %vehicleMake% no se hará responsable por los daños o pérdidas de privacidad relacionados con el uso que %appName% haga de sus datos. Presione Sí para permitir y No para denegar. \n\n Puede cambiar estos permisos y consultar descripciones detalladas en el menú de configuración de las aplicaciones móviles." - }, - "es-es": { - "tts": "%appName% está solicitando el uso de los siguientes permisos e información del vehículo: %functionalGroupLabels%. Si pulsa sí, acepta que %vehicleMake% no será responsable de los daños o la pérdida de privacidad relacionados con el uso de sus datos por parte de %appName%. Pulse sí para permitir o no para denegar.", - "line1": "¿Conceder permisos", - "line2": "solicitados?" - }, - "es-mx": { - "tts": "%appName% solicita el uso de la siguiente información y permisos del vehículo: %functionalGroupLabels%. Si presiona Sí, acepta que %vehicleMake% no se hará responsable por los daños o pérdidas de privacidad relacionados con el uso que %appName% haga de sus datos. Presione Sí para permitir y No para denegar.", - "line1": "¿Otorgar permiso(s)", - "line2": "solicitado(s)?", - "textBody": "%appName% solicita el uso de la siguiente información y permisos del vehículo: %functionalGroupLabels%. \n\nSi presiona Sí, acepta que %vehicleMake% no se hará responsable por los daños o pérdidas de privacidad relacionados con el uso que %appName% haga de sus datos. Presione Sí para permitir y No para denegar. Puede cambiar estos permisos y consultar descripciones detalladas en el menú de configuración de las aplicaciones móviles." - }, - "fr-ca": { - "tts": "%appName% demande d’utiliser les informations du véhicule et les permissions suivantes : %functionalGroupLabels%. Si vous appuyez sur Oui, vous acceptez que %vehicleMake% ne sera pas responsable des dommages ou des pertes de confidentialité reliées à l’utilisation de vos données par %appName%. Veuillez appuyer sur Oui pour autoriser ou sur Non pour refuser.", - "line1": "Accorder permission(s)", - "line2": "demandée(s)", - "textBody": "%appName% demande d’utiliser les informations du véhicule et les permissions suivantes : %functionalGroupLabels%. Si vous appuyez sur Oui, vous acceptez que %vehicleMake% ne sera pas responsable des dommages ou des pertes de confidentialité reliées à l’utilisation de vos données par %appName%. Vous pouvez modifier ces permissions et entendre les descriptions détaillées dans le menu des réglages des applications mobiles." - }, - "fr-fr": { - "tts": "%appName% demande d’utiliser les informations du véhicule et les permissions suivantes : %functionalGroupLabels%. Si vous appuyez sur Oui, vous acceptez que %vehicleMake% ne sera pas responsable des dommages ou des pertes de confidentialité reliées à l’utilisation de vos données par %appName%. Veuillez appuyer sur Oui pour autoriser ou sur Non pour refuser.", - "line1": "Accorder permission(s)", - "line2": "demandée(s)" - }, - "it-it": { - "tts": "%appName% richiede l'uso delle seguenti informazioni e autorizzazioni sul veicolo: %functionalGroupLabels%. Se si preme Sì, si acconsente che %vehicleMake% non sarà responsabile per danni o perdita di privacy in relazione all'impiego dei dati da parte di %appName%. Premere Sì per consentire e No per negare.", - "line1": "Concedi autorizzaz.", - "line2": "richiesta(e)?" - }, - "nl-nl": { - "tts": "%appName% vraagt gebruikmaking van de volgende voertuiginformatie en toestemmingen aan: %functionalGroupLabels%. Als u op Ja drukt, gaat u ermee akkoord dat %vehicleMake% in geen geval aansprakelijk gesteld kan worden voor schade of verlies van privacy als gevolg van het feit dat %appName% gebruik maakt van uw gegevens. Druk op Ja om dit toe te staan of Nee om te weigeren.", - "line1": "Aangevraagde", - "line2": "permissie(s) verlenen?" - }, - "pl-pl": { - "tts": "%appName% wymaga następujących informacji o pojeździe oraz pozwoleń: %functionalGroupLabels%. Naciśnięcie TAK oznacza zgodę na fakt, iż %vehicleMake% nie będzie ponosić odpowiedzialności za szkody ani utratę prywatności w związku z wykorzystaniem przez %appName% danych, należących do użytkownika. Naciśnij TAK w celu udzielenia zgody lub NIE w celu odrzucenia żądania.", - "line1": "Udzielić żądanych", - "line2": "pozwoleń?" - }, - "pt-br": { - "tts": "%appName% está solicitando o uso das seguintes informações e permissões do veículo: %functionalGroupLabels%. Se pressionar sim, você concorda que a %vehicleMake% não será responsável por danos ou perdas de privacidade relacionados ao uso dos seus dados por %appName%. Pressione sim para permitir ou não para negar.", - "line1": "Conceder permissão", - "line2": "solicitada?" - }, - "pt-pt": { - "tts": "%appName% está a solicitar a utilização das seguintes informações e permissões do veículo: %functionalGroupLabels%. Se premir “Sim”, concorda que %vehicleMake% não será responsável por quaisquer danos ou perda de privacidade relacionada com a utilização dos seus dados por parte de %appName%. Prima “Sim” para permitir ou “Não” para recusar.", - "line1": "Conceder permiss.", - "line2": "solicitada(s)?" - }, - "ru-ru": { - "tts": "%appName% запрашивает следующую информацию об автомобиле и разрешения: %functionalGroupLabels%. Нажатием \"\"да\"\", Вы соглашаетесь, что %vehicleMake% не будет нести ответственность за какие-либо убытки или потерю прайвеси, связанные с использованием Ваших данных компанией %appName%. Нажмите \"\"Да\"\", если Вы согласны, или \"\"Нет\"\" - если не согласны.", - "line1": "Предост. заправш.", - "line2": "разрешения?" - }, - "sv-se": { - "tts": "%appName% begär att få tillgång till följande fordonsinformation och tillstånd: %functionalGroupLabels%. Om du trycker Ja godkänner du att %vehicleMake% ska hållas skadeslös för alla skador som kan uppstå eller eventuella integritetsintrång som uppstår när %appName% använder dina data. Tryck Ja för att godkänna eller Nej för att neka.", - "line1": "Vill du ge", - "line2": "tillstånd?" - }, - "tr-tr": { - "tts": "%appName%, şu araç bilgilerini ve izinleri kullanma isteğinde bulunuyor: %functionalGroupLabels%. Evet'e basarsanız, %appName%'in verilerinizi kullanması sonucunda oluşabilecek hasarlardan veya gizlilik kaybından %vehicleMake%'in sorumlu olmayacağını kabul etmiş olacaksınız. Lütfen kabul etmek için Evet'e veya reddetmek için Hayır'a basın.", - "line1": "İstenen izinler", - "line2": "verilsin mi?" - }, - "zh-cn": { - "tts": "%appName% 正在请求使用下列车辆信息和权限: %functionalGroupLabels%。如果您按“是”,则表示您同意。 %vehicleMake% 将不会对因 %appName% 使用您的数据而引起的任何损毁或隐私损失负责。 请按“是”允许或按“否”拒绝。", - "line1": "是否允许请求的", - "line2": "权限?" - }, - "zh-tw": { - "tts": "%appName% 正請求使用 %functionalGroupLabels% 的車輛資訊和許可。按「是」,表示您同意,如因 %appName% 使用您的資料導致任何損害或損失,%vehicleMake% 將不負賠償責任。同意請按「是」,拒絕請按「否」。", - "line1": "允許", - "line2": "授權請求?" - } - } - }, - "AppPermissionsHelp": { - "languages": { - "de-de": { - "tts": "%appName% fordert folgende Fahrzeuginformationen und Zugriffsberechtigungen: %functionalGroupLabels%. Im Einstellungsmenü der mobilen Apps können Sie diese Berechtigungen ändern und sich detaillierte Beschreibungen anhören. Mit Ja stimmen Sie zu; mit Nein lehnen Sie ab." - }, - "en-au": { - "tts": "%appName% is requesting the following vehicle information and permissions: %functionalGroupLabels%. You can change these permissions and hear detailed descriptions in the mobile apps settings menu. Please press Yes to grant permissions or No to deny." - }, - "en-gb": { - "tts": "%appName% is requesting the following vehicle information and permissions: %functionalGroupLabels%. You can change these permissions and hear detailed descriptions in the mobile apps settings menu. Please press Yes to grant permissions or No to deny." - }, - "en-ie": { - "tts": "%appName% is requesting the following vehicle information and permissions: %functionalGroupLabels%. You can change these permissions and hear detailed descriptions in the mobile apps settings menu. Please press Yes to grant permissions or No to deny." - }, - "en-us": { - "tts": "%appName% is requesting the following vehicle information and permissions: %functionalGroupLabels%. You can change these permissions and hear detailed descriptions in the mobile apps settings menu. Please press yes to grant permissions or no to deny." - }, - "es-en": { - "tts": "%appName% solicita la siguiente información y permisos del vehículo: %functionalGroupLabels%. Puede cambiar estos permisos y consultar descripciones detalladas en el menú de configuración de las aplicaciones móviles. Presione Sí para otorgar permisos y No para denegar." - }, - "es-es": { - "tts": "%appName% está solicitando los siguientes permisos e información del vehículo: %functionalGroupLabels%. Puede cambiar estos permisos y escuchar descripciones detalladas en el menú de configuración de la aplicación móvil. Pulse sí para conceder el permiso o no para denegarlo." - }, - "es-mx": { - "tts": "%appName% solicita la siguiente información y permisos del vehículo: %functionalGroupLabels%. Puede cambiar estos permisos y consultar descripciones detalladas en el menú de configuración de las aplicaciones móviles. Presione Sí para otorgar permisos y No para denegar." - }, - "fr-ca": { - "tts": "%appName% demande d’utiliser les informations du véhicule et les permissions suivantes : %functionalGroupLabels%. Vous pouvez modifier ces permissions et entendre les descriptions détaillées dans le menu des réglages des applications mobiles. Veuillez appuyer sur Oui pour accorder les permissions ou sur Non pour refuser." - }, - "fr-fr": { - "tts": "%appName% demande d’utiliser les informations du véhicule et les permissions suivantes : %functionalGroupLabels%. Vous pouvez modifier ces permissions et entendre les descriptions détaillées dans le menu des réglages des applications mobiles. Veuillez appuyer sur Oui pour accorder les permissions ou sur Non pour refuser." - }, - "it-it": { - "tts": "%appName% richiede le seguenti informazioni e autorizzazioni riguardo il veicolo: %functionalGroupLabels%. È possibile modificare tali autorizzazioni e ascoltare descrizioni dettagliate nel menu impostazioni delle app mobili. Premere Sì per concedere le autorizzazioni e No per negarle." - }, - "nl-nl": { - "tts": "%appName% vraagt gebruikmaking van de volgende voertuiginformatie en toestemmingen aan: %functionalGroupLabels%. U kunt deze toestemmingen wijzigen en gedetailleerde beschrijvingen beluisteren in het instellingenmenu voor mobiele apps. Druk op Ja om permissies te verlenen of op Nee om te weigeren." - }, - "pl-pl": { - "tts": "%appName% wymaga następujących informacji o pojeździe oraz zezwoleń: %functionalGroupLabels%. W menu ustawień aplikacji mobilnych można zmienić owe zezwolenia i usłyszeć ich szczegółowy opis. Naciśnij TAK, aby wyrazić zgodę lub NIE w celu odrzucenia żądania." - }, - "pt-br": { - "tts": "%appName% está solicitando as seguintes informações e permissões do veículo: %functionalGroupLabels%. Você pode alterar estas permissões e ouvir descrições detalhadas no menu de configurações de aplicativos móveis. Pressione sim para conceder as permissões ou não para negar." - }, - "pt-pt": { - "tts": "%appName% está a solicitar as seguintes informações e permissões do veículo: %functionalGroupLabels%. Pode alterar estas permissões e ouvir descrições detalhadas no menu de definições das aplicações móveis. Prima \"\"Sim\"\" para permitir ou \"\"Não\"\" para recusar." - }, - "ru-ru": { - "tts": "%appName% запрашивает следующую информацию об автомобиле и разрешения: %functionalGroupLabels%. Вы можете изменить эти разрешения и прослушать подробные их описания в меню настроек мобильного приложения. Нажмите \"\"да\"\", чтобы предоставить разрешения, или \"\"нет\"\", чтобы не предоставлять." - }, - "sv-se": { - "tts": "%appName% begär tillgång till följande fordonsinformation och tillstånd: %functionalGroupLabels%. Du kan ändra tillstånden och höra detaljerade beskrivningar i menyn för mobilappsinställningar. Tryck Ja för att ge tillstånd eller Nej för att neka." - }, - "tr-tr": { - "tts": "%appName%, şu araç bilgilerini ve izinleri istiyor: %functionalGroupLabels%. Bu izinleri değiştirebilir ve mobil uygulamalar ayarlar menüsünden ayrıntılı açıklamaları dinleyebilirsiniz. Lütfen izin vermek için Evet'e veya reddetmek için Hayır'a basın." - }, - "zh-cn": { - "tts": "%appName% 正在请求下列车辆信息和权限: %functionalGroupLabels%。您可在移动应用程序设置菜单中更改这些权限,并听取详细说明。请按“是”允许权限或按“否”拒绝。" - }, - "zh-tw": { - "tts": "%appName% 正請求使用 %functionalGroupLabels% 的車輛資訊和許可。您可在行動應用程式設定清單中更改這些許可,並聆聽詳細說明。給予許可請按「是」,拒絕請按「否」。" - } - } - }, - "AppPermissionsRevoked": { - "languages": { - "de-de": { - "tts": "Die Autorisierungsdaten der App wurden geändert. %appName% hat keinen Zugriff auf %functionalGroupLabels% mehr. Installieren Sie die neueste Version der App auf Ihrem Gerät.." - }, - "en-au": { - "tts": "App authorizations have changed. %appName% can no longer access %functionalGroupLabels%. Please ensure you have the most recent app version installed on your mobile device." - }, - "en-gb": { - "tts": "App authorizations have changed. %appName% can no longer access %functionalGroupLabels%. Please ensure you have the most recent app version installed on your mobile device." - }, - "en-ie": { - "tts": "App authorizations have changed. %appName% can no longer access %functionalGroupLabels%. Please ensure you have the most recent app version installed on your mobile device." - }, - "en-us": { - "tts": "App authorizations have changed. %appName% can no longer access %functionalGroupLabels%. Please ensure you have the most recent app version installed on your mobile device." - }, - "es-en": { - "tts": "Las autorizaciones de la aplicación han cambiado. %appName% ya no puede acceder a %functionalGroupLabels%. Asegúrese de haber instalado la versión más reciente de la aplicación en su dispositivo móvil." - }, - "es-es": { - "tts": "Las autorizaciones de la aplicación han cambiado. %appName% ya no puede acceder a %functionalGroupLabels%. Asegúrese de que tiene la versión más reciente de la aplicación instalada en su dispositivo móvil." - }, - "es-mx": { - "tts": "Las autorizaciones de la aplicación han cambiado. %appName% ya no puede acceder a %functionalGroupLabels%. Asegúrese de haber instalado la versión más reciente de la aplicación en su dispositivo móvil." - }, - "fr-ca": { - "tts": "Les autorisations pour app ont changé. %appName% ne peut plus accéder à %functionalGroupLabels%. Veuillez vous assurer que la plus récente version de l’application est installée sur votre appareil mobile." - }, - "fr-fr": { - "tts": "Les autorisations pour app ont changé. %appName% ne peut plus accéder à %functionalGroupLabels%. Veuillez vous assurer que la plus récente version de l’application est installée sur votre appareil mobile." - }, - "it-it": { - "tts": "Le autorizzazioni dell'app sono cambiate. %appName% non è più in grado di accedere a %functionalGroupLabels%. Assicurarsi di avere la versione più recente dell'app installata sul dispositivo mobile." - }, - "nl-nl": { - "tts": "De app-autorisaties zijn gewijzigd. %appName% heeft geen toegang meer tot %functionalGroupLabels%. Zorg ervoor dat u de meest recente app-versie op uw mobiele apparaat geïnstalleerd hebt." - }, - "pl-pl": { - "tts": "Dane dostępu aplikacji zostały zmienione. %appName% nie ma już dostępu do %functionalGroupLabels%. Sprawdź, czy na telefonie komórkowym zainstalowano najnowszą wersję aplikacji." - }, - "pt-br": { - "tts": "As autorizações dos aplicativos foram alteradas. %appName% não pode mais acessar %functionalGroupLabels%. Certifique-se de que a versão mais recente do aplicativo está instalada no seu dispositivo móvel." - }, - "pt-pt": { - "tts": "As autorizações das aplicações mudaram. %appName% já não consegue aceder a %functionalGroupLabels%. Certifique-se de que tem a última versão da aplicação no seu dispositivo móvel." - }, - "ru-ru": { - "tts": "Авторизации приложения изменены. %appName% больше не имеет доступа к %functionalGroupLabels%. Убедитесь, что на вашем мобильном устройстве установлена самая новая версия приложения." - }, - "sv-se": { - "tts": "Appens behörigheter har ändrats. %appName% har inte längre åtkomst till %functionalGroupLabels%. Kontrollera att du har installerat den senaste versionen av appen på mobilenheten." - }, - "tr-tr": { - "tts": "Uygulama yetkileri değişti. %appName% artık %functionalGroupLabels%'e erişemeyecek. Lütfen mobil aygıtınızda en son uygulama sürümünün yüklü olduğundan emin olun." - }, - "zh-cn": { - "tts": "应用程序授权已变更。 %appName% 将不能再访问 %functionalGroupLabels%。 请确认您的移动设备上安装的应用程序是最新版本。" - }, - "zh-tw": { - "tts": "應用程式授權已改變。%appName% 已無法進入 %functionalGroupLabels%。請確認您的行動裝置上安裝了最新版應用程式。" - } - } - }, - "AppUnauthorized": { - "languages": { - "de-de": { - "tts": "Diese Version von %appName% ist nicht autorisiert und wird nicht mit SYNC funktionieren.", - "line1": "nicht autorisiert" - }, - "en-au": { - "tts": "This version of %appName% is not authorized and will not work with SYNC.", - "line1": "not authorized" - }, - "en-gb": { - "tts": "This version of %appName% is not authorized and will not work with SYNC.", - "line1": "not authorized", - "textBody": "This version of %appName% is not authorized and will not work with SYNC." - }, - "en-ie": { - "tts": "This version of %appName% is not authorized and will not work with SYNC.", - "line1": "not authorized" - }, - "en-us": { - "tts": "This version of %appName% is not authorized and will not work with SYNC.", - "line1": "Not Authorized", - "textBody": "This version of %appName% is no longer authorized to work with AppLink. Please update to the latest version of %appName%." - }, - "es-en": { - "tts": "Esta versión de %appName% no tiene autorización y no funcionará con SYNC.", - "line1": "no autorizada", - "textBody": "Esta versión de %appName% no tiene autorización y no funcionará con SYNC." - }, - "es-es": { - "tts": "Esta versión de %appName% no está autorizada y no funcionará con SYNC.", - "line1": "No autorizada" - }, - "es-mx": { - "tts": "Esta versión de %appName% no tiene autorización y no funcionará con SYNC.", - "line1": "no autorizada", - "textBody": "Esta versión de %appName% no tiene autorización y no funcionará con SYNC." - }, - "fr-ca": { - "tts": "Cette version de %appName% n’est pas autorisée et ne fonctionnera pas avec SYNC.", - "line1": "non autorisée", - "textBody": "Cette version de %appName% n’est pas autorisée et ne fonctionnera pas avec SYNC." - }, - "fr-fr": { - "tts": "Cette version de %appName% n’est pas autorisée et ne fonctionnera pas avec SYNC.", - "line1": "non autorisée" - }, - "it-it": { - "tts": "Questa versione di %appName% non è autorizzata e non funziona con il SYNC.", - "line1": "non autorizzata" - }, - "nl-nl": { - "tts": "Deze versie van %appName% is niet geautoriseerd en werkt niet met SYNC.", - "line1": "niet geautoriseerd" - }, - "pl-pl": { - "tts": "Niniejsza wersja %appName% nie posiada autoryzacji i nie będzie działać z SYNC.", - "line1": "brak autoryzacji" - }, - "pt-br": { - "tts": "Esta versão do %appName% não tem autorização e não funcionará com o SYNC.", - "line1": "não autorizado" - }, - "pt-pt": { - "tts": "Esta versão de %appName% não está autorizada e não funcionará com o SYNC.", - "line1": "não autorizada" - }, - "ru-ru": { - "tts": "Эта версия %appName% не авторизирована и не будет работать с SYNC.", - "line1": "не авторизировано" - }, - "sv-se": { - "tts": "Den här versionen av %appName% är inte godkänd och fungerar inte med SYNC.", - "line1": "är ej godkänd" - }, - "tr-tr": { - "tts": "Bu %appName% sürümüne izin verilmediğinden SYNC ile çalışamaz.", - "line1": "için izin yok" - }, - "zh-cn": { - "tts": "此版本的%appName% 未得到授权,无法在SYNC上使用。", - "line1": "未得到授权" - }, - "zh-tw": { - "tts": "%appName% 的版本未獲得授權,將無法透過 SYNC 使用。", - "line1": "無授權" - } - } - }, - "AppUnsupported": { - "languages": { - "de-de": { - "tts": "Diese Version von %appName% wird von SYNC nicht unterstützt.", - "line1": "nicht unterstützt" - }, - "en-au": { - "tts": "This version of %appName% is not supported by SYNC.", - "line1": "not supported" - }, - "en-gb": { - "tts": "This version of %appName% is not supported by SYNC.", - "line1": "not supported", - "textBody": "This version of %appName% is not supported by SYNC." - }, - "en-ie": { - "tts": "This version of %appName% is not supported by SYNC.", - "line1": "not supported" - }, - "en-us": { - "tts": "This version of %appName% is not supported by SYNC.", - "line1": "Not Supported", - "textBody": "Your version of %appName% is not supported by SYNC." - }, - "es-en": { - "tts": "Esta versión de %appName% no es compatible con SYNC.", - "line1": "no compatible", - "textBody": "Esta versión de %appName% no es compatible con SYNC." - }, - "es-es": { - "tts": "Esta versión de %appName% no es compatible con SYNC.", - "line1": "No compatible" - }, - "es-mx": { - "tts": "Esta versión de %appName% no es compatible con SYNC.", - "line1": "no compatible", - "textBody": "Esta versión de %appName% no es compatible con SYNC." - }, - "fr-ca": { - "tts": "Cette version de %appName% n’est pas prise en charge par SYNC.", - "line1": "incompatible", - "textBody": "Cette version de %appName% n’est pas prise en charge par SYNC." - }, - "fr-fr": { - "tts": "Cette version de %appName% n’est pas prise en charge par SYNC.", - "line1": "incompatible" - }, - "it-it": { - "tts": "Questa versione di %appName% non è supportata dal SYNC.", - "line1": "non supportata" - }, - "nl-nl": { - "tts": "Deze versie van %appName% wordt niet ondersteund door SYNC.", - "line1": "niet ondersteund" - }, - "pl-pl": { - "tts": "Niniejsza wersja %appName% nie jest obsługiwana przez system SYNC.", - "line1": "aplikacja nie obsług." - }, - "pt-br": { - "tts": "Esta versão do %appName% não é suportada pelo SYNC.", - "line1": "não suportado" - }, - "pt-pt": { - "tts": "Esta versão de %appName% não é suportado pelo SYNC.", - "line1": "não suportada" - }, - "ru-ru": { - "tts": "Эта версия %appName% не поддерживается SYNC.", - "line1": "не поддерживается" - }, - "sv-se": { - "tts": "SYNC har inte stöd för den här versionen av %appName%.", - "line1": "stöds ej" - }, - "tr-tr": { - "tts": "Bu %appName% sürümü SYNC tarafından desteklenmiyor.", - "line1": "desteklenmiyor" - }, - "zh-cn": { - "tts": "SYNC不支持此版本的%appName%。", - "line1": "不受支持" - }, - "zh-tw": { - "tts": "SYNC 不支援此版本的%appName% 。", - "line1": "不支援" - } - } - }, - "DataConsent": { - "languages": { - "en-gb": { - "textBody": "Would you like to enable Mobile Apps on SYNC? To use Mobile Apps with SYNC, SYNC will communicate with Ford at least once per month using your mobile device’s data plan. Standard rates may apply. SYNC will send your VIN and SYNC module number to Ford U.S. \r\n\r\nUpdates are about the size of an email, and the occurrence of updates depends on your vehicle usage and when a new app is found on your device. To turn on or off, visit the SYNC Settings menu. See your Owner Guide for more information." - }, - "en-us": { - "line1": "Enable Mobile Apps", - "line2": "on SYNC? (Uses Data)", - "textBody": "Would you like to enable Mobile Apps on SYNC?\r\n\r\nTo use Mobile Apps with SYNC, SYNC will communicate with Ford at least once per month using your mobile device’s data plan. Standard rates may apply. SYNC will send your VIN and SYNC module number to Ford U.S.\r\n\r\nUpdates are about the size of an email, and the occurrence of updates depends on your vehicle usage and when a new app is found on your device. To turn on or off, visit the SYNC Settings menu. See your Owner Guide for more information." - }, - "es-mx": { - "textBody": "Para usar aplicaciones móviles con SYNC, este debe comunicarse con Ford al menos una vez al mes a través del plan de datos de su dispositivo móvil. Pueden aplicar tarifas normales. SYNC enviará su VIN y el número de módulo de SYNC a Ford de Estados Unidos de América. \n\nLas actualizaciones tienen el tamaño aproximado de un mensaje de correo electrónico, y la frecuencia de las actualizaciones depende del uso de su vehículo y de si se encuentran nuevas aplicaciones en su dispositivo. Para obtener más información, consulte la Guía del propietario. \n\nPresione Sí para permitir y No para denegar." - }, - "fr-ca": { - "textBody": "Pour utiliser AppLink, SYNC devra communiquer avec Ford au moins une fois par mois en utilisant le forfait de données de votre appareil mobile. Les tarifs réguliers peuvent s’appliquer. SYNC enverra votre NIV et le numéro de votre module SYNC à Ford États-Unis. Les mises à jour ont la taille d’un courriel et la fréquence des mises à jour dépend de l’utilisation de votre véhicule et si une nouvelle application se trouve sur votre appareil. Consultez le Guide de l’utilisateur pour obtenir d’autres renseignements.\r\n\r\nVeuillez appuyer sur Oui pour autoriser ou sur Non pour refuser." - } - } - }, - "DataConsentHelp": { - "languages": { - "en-us": { - "textBody": "By enabling mobile apps, you consent to allowing SYNC to communicate with Ford at least once per month using your mobile device’s data plan. Disabling will stop all data usage, but you will not be able to use mobile apps on SYNC. See your Owner Guide for more information." - }, - "es-mx": { - "textBody": "Las actualizaciones tienen el tamaño aproximado de un mensaje de correo electrónico, y la frecuencia de las actualizaciones depende del uso de su vehículo y de si se encuentran nuevas aplicaciones en su dispositivo. Para obtener más información, consulte la Guía del propietario." - }, - "fr-ca": { - "textBody": "Les mises à jour ont la taille d’un courriel et la fréquence des mises à jour dépend de l’utilisation de votre véhicule et si une nouvelle application se trouve sur votre appareil. Consultez le Guide de l’utilisateur pour obtenir d’autres renseignements." - } - } - }, - "DisableApps": { - "languages": { - "de-de": { - "tts": "Ausschalten der automatischen Updates führt zum Ausschalten von SYNC mobile Apps. Sie können Ihre mobilen Apps dann nicht mehr mit SYNC nutzen. Bitte drücken Sie Ja zur Bestätigung oder Nein, um abzubrechen.", - "line1": "Auto-Update", - "line2": "und Mobile Apps deaktivieren" - }, - "en-au": { - "tts": "Disabling automatic updates will also disable SYNC mobile apps. You will not be able to use any mobile apps with SYNC. Please press Yes to confirm or No to cancel.", - "line1": "Disable auto-updates", - "line2": "and Mobile Apps?" - }, - "en-gb": { - "tts": "Disabling automatic updates will also disable SYNC mobile apps. You will not be able to use any mobile apps with SYNC. Please press Yes to confirm or No to cancel.", - "line1": "Disable auto-updates", - "line2": "and Mobile Apps?", - "textBody": "Disabling automatic updates will also disable SYNC mobile apps. You will not be able to use any mobile apps with SYNC. Please press Yes to confirm or No to cancel." - }, - "en-ie": { - "tts": "Disabling automatic updates will also disable SYNC mobile apps. You will not be able to use any mobile apps with SYNC. Please press Yes to confirm or No to cancel.", - "line1": "Disable auto-updates", - "line2": "and Mobile Apps?" - }, - "en-us": { - "tts": "Disabling automatic updates will also disable sync mobile apps. You will not be able to use any mobile apps with SYNC. Please press yes to confirm or no to cancel.", - "line1": "Disable Auto-Updates", - "line2": "and Mobile Apps?", - "textBody": "If you disable, you will not be able to use any mobile apps with SYNC and your vehicle will stop receiving mobile app permission updates via your device`s data plan. Please press yes to disable mobile apps or no to cancel." - }, - "es-en": { - "tts": "Si se desactivan las actualizaciones automáticas, también se desactivarán las aplicaciones móviles de SYNC. No podrá usar ninguna aplicación móvil con SYNC. Presione Sí para confirmar o No para cancelar.", - "line1": "¿Deshab. actualiz.", - "line2": "autom. y aplic. móv.?", - "textBody": "Si se desactivan las actualizaciones automáticas, también se desactivarán las aplicaciones móviles de SYNC. No podrá usar ninguna aplicación móvil con SYNC. Presione Sí para confirmar o No para cancelar." - }, - "es-es": { - "tts": "Si desactiva las actualizaciones automáticas, también se desactivará la sincronización de las aplicaciones móviles. No podrá utilizar ninguna aplicación móvil con SYNC. Pulse sí para confirmar o no para cancelar.", - "line1": "¿Desact. actual. auto", - "line2": "y apl. móviles?" - }, - "es-mx": { - "tts": "Si se desactivan las actualizaciones automáticas, también se desactivarán las aplicaciones móviles de SYNC. No podrá usar ninguna aplicación móvil con SYNC. Presione Sí para confirmar o No para cancelar.", - "line1": "¿Deshab. actualiz.", - "line2": "autom. y aplic. móv.?", - "textBody": "Si se desactivan las actualizaciones automáticas, también se desactivarán las aplicaciones móviles de SYNC. No podrá usar ninguna aplicación móvil con SYNC. Presione Sí para confirmar o No para cancelar." - }, - "fr-ca": { - "tts": "La désactivation des mises à jour automatiques désactivera aussi les applications mobiles SYNC. Vous ne pourrez pas utiliser d’application mobile avec SYNC. Veuillez appuyer sur Oui pour confirmer ou sur Non pour annuler.", - "line1": "Désactiver màj autom.", - "line2": "et app. mobiles?", - "textBody": "La désactivation des mises à jour automatiques désactivera aussi les applications mobiles SYNC. Vous ne pourrez pas utiliser d’application mobile avec SYNC. Veuillez appuyer sur Oui pour confirmer ou sur Non pour annuler." - }, - "fr-fr": { - "tts": "La désactivation des mises à jour automatiques désactivera aussi les applications mobiles SYNC. Vous ne pourrez pas utiliser d’application mobile avec SYNC. Veuillez appuyer sur Oui pour confirmer ou sur Non pour annuler.", - "line1": "Désactiver màj autom.", - "line2": "et app. mobiles?" - }, - "it-it": { - "tts": "Disabilitando gli aggiornamenti automatici si disattiva anche la sincronizzazione delle app mobili. Non sarà possibile usare app mobili con il SYNC. Premere Sì per confermare e No per cancellare.", - "line1": "Disabilitare agg. aut.", - "line2": "e app mobili?" - }, - "nl-nl": { - "tts": "Door automatische updates uit te schakelen, schakelt u ook SYNC-mobiele apps uit. U kunt dan geen mobiele apps meer gebruiken met SYNC. Druk op Ja om te bevestigen of op Nee om te annuleren.", - "line1": "Auto-updates en mob.", - "line2": "apps uitschakelen?" - }, - "pl-pl": { - "tts": "Wyłączenie automatycznych aktualizacji spowoduje także wyłączenie aplikacji mobilnych SYNC. Korzystanie z mobilnych aplikacji za pomocą SYNC będzie niemożliwe. Naciśnij TAK, by potwierdzić lub NIE, by anulować.", - "line1": "Wył. automat. aktual.", - "line2": "i aplikacje mobilne?" - }, - "pt-br": { - "tts": "Se as atualizações automáticas forem desativadas, os aplicativos também serão desativados. Você não poderá usar nenhum aplicativo com o SYNC. Pressione sim para confirmar ou não para cancelar.", - "line1": "Desativar atualizações", - "line2": "autom. e aplicativos?" - }, - "pt-pt": { - "tts": "A desactivação das actualizações automáticas desactiva igualmente as aplicações móveis do SYNC. Não poderá utilizar quaisquer aplicações móveis com o SYNC. Prima \"\"Sim\"\" para confirmar ou \"\"Não\"\" para cancelar.", - "line1": "Desact. actual. autom.", - "line2": "e aplicações móveis?" - }, - "ru-ru": { - "tts": "При отключении автоматических обновлений также будут отключены мобильные приложения sync. Вы не сможете использовать какие-либо мобильные приложения с SYNC. Нажмите \"\"Да\"\" для подтверждения или \"\"Нет\"\" для отмены.", - "line1": "Откл. автообновления", - "line2": "и мобил. прилож.?" - }, - "sv-se": { - "tts": "Om du avaktiverar automatisk uppdatering avaktiverar du även synkning av mobilappar. Du kommer inte längre att kunna använda dina mobilappar med SYNC. Tryck Ja för att bekräfta eller Nej för att avbryta.", - "line1": "Avaktiverar autouppdat.", - "line2": "och mobilappar?" - }, - "tr-tr": { - "tts": "Otomatik güncellemeleri devre dışı bırakırsanız sync mobil uygulamalar da devre dışı kalır. SYNC ile mobil uygulama kullanmanız mümkün olmaz. Lütfen onaylamak için Evet'e veya iptal etmek için Hayır'a basın.", - "line1": "Oto. güncelleme ve", - "line2": "mobil uygul. kapat?" - }, - "zh-cn": { - "tts": "禁用自动更新同时也会禁用SYNC移动应用程序。您将无法在 SYNC 中使用任何移动应用程序。请按“是”确认或按“否”取消。", - "line1": "是否禁用自动更新和", - "line2": "移动应用程序?" - }, - "zh-tw": { - "tts": "停用自動更新也將停用 sync 行動應用程式。您將無法透過 SYNC 使用任何行動應用程式。確認請按「是」,取消請按「否」。", - "line1": "停用自動更新", - "line2": "和行動應用程式?" - } - } - }, - "DrivingCharacteristics": { - "languages": { - "de-de": { - "tts": "Eine App hat Zugriff auf die folgenden Fahreigenschaften: Kraftstoffverbrauch, MyKey, Sicherheitsgurtstatus.", - "label": "Fahreigenschaften" - }, - "en-au": { - "tts": "An app can access the following driving characteristics: Fuel consumption, MyKey, Seat belt status.", - "label": "Driving characteristics" - }, - "en-gb": { - "tts": "An app can access the following driving characteristics: Fuel consumption, MyKey, Seat belt status.", - "label": "Driving characteristics", - "textBody": "An app can access the following driving characteristics: Fuel consumption, MyKey, Seat belt status." - }, - "en-ie": { - "tts": "An app can access the following driving characteristics: Fuel consumption, MyKey, Seat belt status.", - "label": "Driving characteristics" - }, - "en-us": { - "tts": "An app can access the following driving characteristics: Fuel Consumption, MyKey, Seat Belt Status.", - "label": "Driving Characteristics", - "textBody": "An app can access the following driving characteristics: Fuel Consumption, MyKey, Seat Belt Status." - }, - "es-en": { - "tts": "Las aplicaciones pueden acceder a las siguientes características del manejo: Consumo de combustible, MyKey, Estado del cinturón de seguridad.", - "label": "Características del manejo", - "textBody": "Las aplicaciones pueden acceder a las siguientes características del manejo: Consumo de combustible, MyKey, Estado del cinturón de seguridad." - }, - "es-es": { - "tts": "Una aplicación puede acceder a las siguientes características de conducción: Consumo de combustible, MyKey, Estado cinturones de seguridad.", - "label": "Características de conducción" - }, - "es-mx": { - "tts": "Las aplicaciones pueden acceder a las siguientes características del manejo: Consumo de combustible, MyKey, Estado del cinturón de seguridad.", - "label": "Características del manejo", - "textBody": "Las aplicaciones pueden acceder a las siguientes características del manejo: Consumo de combustible, MyKey, Estado del cinturón de seguridad." - }, - "fr-ca": { - "tts": "Une application peut accéder aux caractéristiques de conduite suivantes: Consommation de carburant, MyKey, État des ceintures de sécurité.", - "label": "Caractéristiques de conduite", - "textBody": "Une application peut accéder aux caractéristiques de conduite suivantes: Consommation de carburant, MyKey, État des ceintures de sécurité." - }, - "fr-fr": { - "tts": "Une application peut accéder aux caractéristiques de conduite suivantes: Consommation de carburant, MyKey, État des ceintures de sécurité.", - "label": "Caractéristiques de conduite" - }, - "it-it": { - "tts": "Un'app può avere accesso alle seguenti caratteristiche di guida: Consumo carburante, MyKey, Stato cinture di sicurezza.", - "label": "Caratteristiche di guida" - }, - "nl-nl": { - "tts": "Een app heeft toegang tot de volgende rijkenmerken: Brandstofverbruik, MyKey, Veiligheidsgordelstatus.", - "label": "Rijkenmerken" - }, - "pl-pl": { - "tts": "Aplikacja może uzyskać dostęp do następujących informacji dotyczących jazdy: Zużycie paliwa, MyKey, Stan pasów bezpieczeństwa.", - "label": "Informacje dotyczące stylu jazdy" - }, - "pt-br": { - "tts": "Um aplicativo pode acessar as seguintes características de condução: Consumo de combustível, MyKey, Estado do cinto de segurança.", - "label": "Características de condução" - }, - "pt-pt": { - "tts": "Uma aplicação consegue aceder às seguintes informações de condução: Consumo de combustível, MyKey, Estado dos cintos de segurança.", - "label": "Características de condução" - }, - "ru-ru": { - "tts": "Приложение имеет доступ к следующим характеристикам движения: Расход топлива, MyKey, Состояние ремней безопасности.", - "label": "Характеристики движения" - }, - "sv-se": { - "tts": "Appen kan komma åt följande köregenskaper: Bränsleförbrukning, MyKey, Bältesstatus.", - "label": "Köregenskaper" - }, - "tr-tr": { - "tts": "Bir uygulama şu sürüş karakteristiklerine erişebilir: Yakıt tüketimi, MyKey, Emniyet kemeri durumu.", - "label": "Sürüş karakteristikleri" - }, - "zh-cn": { - "tts": "移动应用程序可访问下列行驶特性: 油耗, MyKey, 安全带状态", - "label": "行驶特性" - }, - "zh-tw": { - "tts": "應用程式可存取以下駕駛特性: 油耗, MyKey, 安全帶狀態", - "label": "駕駛特性" - } - } - }, - "Location": { - "languages": { - "de-de": { - "tts": "Eine App hat Zugriff auf die GPS-Daten und die Geschwindigkeit des Fahrzeugs.", - "label": "GPS und Geschwindigkeit" - }, - "en-au": { - "tts": "An app can access vehicle GPS and speed.", - "label": "GPS and speed" - }, - "en-gb": { - "tts": "An app can access vehicle GPS and speed.", - "label": "GPS and speed", - "textBody": "An app can access vehicle GPS and speed." - }, - "en-ie": { - "tts": "An app can access vehicle GPS and speed.", - "label": "GPS and speed" - }, - "en-us": { - "tts": "An app can access vehicle GPS and speed.", - "label": "GPS and speed", - "textBody": "An app can access vehicle GPS and speed." - }, - "es-en": { - "tts": "Las aplicaciones pueden acceder al GPS y a la velocidad del vehículo.", - "label": "GPS y velocidad", - "textBody": "Las aplicaciones pueden acceder al GPS y a la velocidad del vehículo." - }, - "es-es": { - "tts": "Una aplicación puede acceder al GPS y la velocidad del vehículo.", - "label": "GPS y velocidad" - }, - "es-mx": { - "tts": "Las aplicaciones pueden acceder al GPS y a la velocidad del vehículo.", - "label": "GPS y velocidad", - "textBody": "Las aplicaciones pueden acceder al GPS y a la velocidad del vehículo." - }, - "fr-ca": { - "tts": "Une application peut accéder au GPS et à la vitesse du véhicule.", - "label": "GPS et vitesse", - "textBody": "Une application peut accéder au GPS et à la vitesse du véhicule." - }, - "fr-fr": { - "tts": "Une application peut accéder au GPS et à la vitesse du véhicule.", - "label": "GPS et vitesse" - }, - "it-it": { - "tts": "Un'app può avere accesso a GPS e velocità del veicolo.", - "label": "GPS e velocità" - }, - "nl-nl": { - "tts": "Een app heeft toegang tot gps en de snelheid van het voertuig.", - "label": "Gps en snelheid" - }, - "pl-pl": { - "tts": "Aplikacja może uzyskać dostęp do modułu GPS i prędkości pojazdu.", - "label": "GPS i prędkość" - }, - "pt-br": { - "tts": "Um aplicativo pode acessar o GPS e a velocidade do veículo.", - "label": "GPS e velocidade" - }, - "pt-pt": { - "tts": "Uma aplicação consegue aceder ao GPS e à velocidade do veículo.", - "label": "GPS e velocidade" - }, - "ru-ru": { - "tts": "Приложение имеет доступ к GPS и скорости автомобиля.", - "label": "GPS и скорость" - }, - "sv-se": { - "tts": "Appen kan komma åt fordonets GPS och hastighetsmätare.", - "label": "GPS och hastighet" - }, - "tr-tr": { - "tts": "Bu uygulama aracın GPS ve hız bilgilerine erişebilir.", - "label": "GPS ve hız" - }, - "zh-cn": { - "tts": "移动应用程序可以访问车辆 GPS 和车速信息。", - "label": "GPS 和车速" - }, - "zh-tw": { - "tts": "應用程式可存取車輛的GPS和速度。", - "label": "GPS和車速" - } - } - }, - "Notifications": { - "languages": { - "de-de": { - "tts": "Läuft die App im Hintergrund, kann Sie Benachrichtigungen senden.", - "label": "Push-Benachrichtigungen" - }, - "en-au": { - "tts": "An app can send notifications when running in the background.", - "label": "Push notifications" - }, - "en-gb": { - "tts": "An app can send notifications when running in the background.", - "label": "Push notifications", - "textBody": "An app can send notifications when running in the background." - }, - "en-ie": { - "tts": "An app can send notifications when running in the background.", - "label": "Push notifications" - }, - "en-us": { - "tts": "An app can send notifications when running in the background.", - "label": "Push notifications", - "textBody": "An app can send notifications when running in the background." - }, - "es-en": { - "tts": "Las aplicaciones pueden enviar notificaciones cuando se ejecutan en segundo plano.", - "label": "Notificaciones tipo Push", - "textBody": "Las aplicaciones pueden enviar notificaciones cuando se ejecutan en segundo plano." - }, - "es-es": { - "tts": "Una aplicación puede enviar notificaciones cuando se está ejecutando en segundo plano.", - "label": "Notificaciones push" - }, - "es-mx": { - "tts": "Las aplicaciones pueden enviar notificaciones cuando se ejecutan en segundo plano.", - "label": "Notificaciones tipo Push", - "textBody": "Las aplicaciones pueden enviar notificaciones cuando se ejecutan en segundo plano." - }, - "fr-ca": { - "tts": "Une application peut envoyer des avis lorsqu’elle fonctionne en arrière-plan.", - "label": "Notifications instantanées", - "textBody": "Une application peut envoyer des avis lorsqu’elle fonctionne en arrière-plan." - }, - "fr-fr": { - "tts": "Une application peut envoyer des avis lorsqu’elle fonctionne en arrière-plan.", - "label": "Notifications push" - }, - "it-it": { - "tts": "Un'app può inviare notifiche se eseguita in background.", - "label": "Notifiche push" - }, - "nl-nl": { - "tts": "Een app kan meldingen versturen als deze op de achtergrond actief is.", - "label": "Push-meldingen" - }, - "pl-pl": { - "tts": "Aplikacja może wysyłać powiadomienia, działając w tle.", - "label": "Powiadomienia Push" - }, - "pt-br": { - "tts": "Um aplicativo pode enviar notificações quando estiver sendo executado em segundo plano.", - "label": "Notificações Push" - }, - "pt-pt": { - "tts": "Uma aplicação consegue enviar notificações quando está activa em segundo plano.", - "label": "Notificações push" - }, - "ru-ru": { - "tts": "Если приложение работает в фоновом режиме, оно может отправлять оповещения.", - "label": "Оповещения о пересылке" - }, - "sv-se": { - "tts": "Appen kan skicka meddelanden när den körs i bakgrunden.", - "label": "Push-notiser" - }, - "tr-tr": { - "tts": "Bir uygulama arka planda çalışırken bildirim gönderebilir.", - "label": "Anlık bildirimleri" - }, - "zh-cn": { - "tts": "移动应用程序在后台运行时可推送通知。", - "label": "推送通知" - }, - "zh-tw": { - "tts": "車輛行進時,應用程式可在背景中傳送通知。", - "label": "傳送通知" - } - } - }, - "SettingDisableUpdates": { - "languages": { - "de-de": { - "line1": "Updates deakt." - }, - "en-au": { - "line1": "Disable updates" - }, - "en-gb": { - "line1": "Disable updates" - }, - "en-ie": { - "line1": "Disable updates" - }, - "en-us": { - "line1": "Disable Updates", - "textBody": "Disable Updates" - }, - "es-en": { - "line1": "Deshab. actual.", - "textBody": "Deshab. actual." - }, - "es-es": { - "line1": "Desact. actual." - }, - "es-mx": { - "line1": "Deshab. actual.", - "textBody": "Deshab. actual." - }, - "fr-ca": { - "line1": "Désactiver MAJ", - "textBody": "Désactiver MAJ" - }, - "fr-fr": { - "line1": "Désactiver màj" - }, - "it-it": { - "line1": "Disabilita agg." - }, - "nl-nl": { - "line1": "Upd. uitschak." - }, - "pl-pl": { - "line1": "Wyłącz aktual." - }, - "pt-br": { - "line1": "Desat. atualiz." - }, - "pt-pt": { - "line1": "Desact. actualiz." - }, - "ru-ru": { - "line1": "Откл. обновл." - }, - "sv-se": { - "line1": "Inaktivera uppd." - }, - "tr-tr": { - "line1": "Güncell. Kapat" - }, - "zh-cn": { - "line1": "禁用更新" - }, - "zh-tw": { - "line1": "停用更新" - } - } - }, - "SettingEnableUpdates": { - "languages": { - "de-de": { - "line1": "Apps aktivieren" - }, - "en-au": { - "line1": "Enable Apps" - }, - "en-gb": { - "line1": "Enable Apps" - }, - "en-ie": { - "line1": "Enable Apps" - }, - "en-us": { - "line1": "Enable Apps" - }, - "es-en": { - "line1": "Hab. aplic." - }, - "es-es": { - "line1": "Activar apl." - }, - "es-mx": { - "line1": "Hab. aplic." - }, - "fr-ca": { - "line1": "Activer app.", - "textBody": "Activer app." - }, - "fr-fr": { - "line1": "Activer app." - }, - "it-it": { - "line1": "Abilita app" - }, - "nl-nl": { - "line1": "Apps inschak." - }, - "pl-pl": { - "line1": "Włącz aplikacje" - }, - "pt-br": { - "line1": "Ativar aplic." - }, - "pt-pt": { - "line1": "Activar actualiz." - }, - "ru-ru": { - "line1": "Вкл. прилож." - }, - "sv-se": { - "line1": "Aktivera appar" - }, - "tr-tr": { - "line1": "Uygulamaları aç" - }, - "zh-cn": { - "line1": "启用应用程序" - }, - "zh-tw": { - "line1": "啟用應用程式" - } - } - }, - "SettingUpdateAuto": { - "languages": { - "de-de": { - "line1": "Update anford." - }, - "en-au": { - "line1": "Request update" - }, - "en-gb": { - "line1": "Request update" - }, - "en-ie": { - "line1": "Request update" - }, - "en-us": { - "line1": "Request Update", - "textBody": "Select `Update now` to receive app permissions for your SYNC-enabled mobile apps. This may enable additional functionality depending on the app and your settings. If your phone has a working data connection, an update should complete in less than 1 minute." - }, - "es-en": { - "line1": "Solicit. actualiz.", - "textBody": "Solicit. actualiz." - }, - "es-es": { - "line1": "Solicitar actual." - }, - "es-mx": { - "line1": "Solicit. actualiz.", - "textBody": "Solicit. actualiz." - }, - "fr-ca": { - "line1": "Demander MAJ", - "textBody": "Demander MAJ" - }, - "fr-fr": { - "line1": "Demander màj" - }, - "it-it": { - "line1": "Rich. aggiorn." - }, - "nl-nl": { - "line1": "Upd. aanvragen" - }, - "pl-pl": { - "line1": "Zażądaj aktual." - }, - "pt-br": { - "line1": "Solicitar atualiz." - }, - "pt-pt": { - "line1": "Solicit. actualiz." - }, - "ru-ru": { - "line1": "Запрос на обн." - }, - "sv-se": { - "line1": "Begär uppdat." - }, - "tr-tr": { - "line1": "Güncelleme iste" - }, - "zh-cn": { - "line1": "请求更新" - }, - "zh-tw": { - "line1": "請求更新" - } - } - }, - "StatusNeeded": { - "languages": { - "de-de": { - "line1": "Update benötigt" - }, - "en-au": { - "line1": "Update needed" - }, - "en-gb": { - "line1": "Update needed", - "textBody": "Update needed" - }, - "en-ie": { - "line1": "Update needed" - }, - "en-us": { - "line1": "Update Needed", - "textBody": "Update Needed" - }, - "es-en": { - "line1": "Actualiz. neces.", - "textBody": "Actualiz. neces." - }, - "es-es": { - "line1": "Actu. necesaria" - }, - "es-mx": { - "line1": "Actualiz. neces.", - "textBody": "Actualiz. neces." - }, - "fr-ca": { - "line1": "Màj requise", - "textBody": "Màj requise" - }, - "fr-fr": { - "line1": "Mise à jour requise" - }, - "it-it": { - "line1": "Necess. aggiorn." - }, - "nl-nl": { - "line1": "Update nodig" - }, - "pl-pl": { - "line1": "Potrzeba aktual." - }, - "pt-br": { - "line1": "Atualiz. necess." - }, - "pt-pt": { - "line1": "Actual. necess." - }, - "ru-ru": { - "line1": "Необх. обновл." - }, - "sv-se": { - "line1": "Uppdat. krävs" - }, - "tr-tr": { - "line1": "Güncellenmeli" - }, - "zh-cn": { - "line1": "需要进行更新" - }, - "zh-tw": { - "line1": "需更新" - } - } - }, - "StatusPending": { - "languages": { - "de-de": { - "line1": "Aktualisieren..." - }, - "en-au": { - "line1": "Updating..." - }, - "en-gb": { - "line1": "Updating...", - "textBody": "Updating..." - }, - "en-ie": { - "line1": "Updating..." - }, - "en-us": { - "line1": "Updating...", - "textBody": "Updating..." - }, - "es-en": { - "line1": "Actualizando...", - "textBody": "Actualizando..." - }, - "es-es": { - "line1": "Actualizando..." - }, - "es-mx": { - "line1": "Actualizando...", - "textBody": "Actualizando..." - }, - "fr-ca": { - "line1": "MAJ en cours...", - "textBody": "MAJ en cours..." - }, - "fr-fr": { - "line1": "Màj en cours..." - }, - "it-it": { - "line1": "Aggiornamento" - }, - "nl-nl": { - "line1": "Updaten..." - }, - "pl-pl": { - "line1": "Aktualizowanie" - }, - "pt-br": { - "line1": "Atualizando..." - }, - "pt-pt": { - "line1": "A actualizar..." - }, - "ru-ru": { - "line1": "Обновление..." - }, - "sv-se": { - "line1": "Uppdaterar..." - }, - "tr-tr": { - "line1": "Güncelleniyor..." - }, - "zh-cn": { - "line1": "正在更新......" - }, - "zh-tw": { - "line1": "更新中..." - } - } - }, - "StatusUpToDate": { - "languages": { - "de-de": { - "line1": "Aktuelle Version" - }, - "en-au": { - "line1": "Up-to-date" - }, - "en-gb": { - "line1": "Up-to-date", - "textBody": "Up-to-date" - }, - "en-ie": { - "line1": "Up-to-date" - }, - "en-us": { - "line1": "Up-To-Date", - "textBody": "Up-To-Date" - }, - "es-en": { - "line1": "Actualizado", - "textBody": "Actualizado" - }, - "es-es": { - "line1": "Actualizada" - }, - "es-mx": { - "line1": "Actualizado", - "textBody": "Actualizado" - }, - "fr-ca": { - "line1": "Déjà à jour", - "textBody": "Déjà à jour" - }, - "fr-fr": { - "line1": "Déjà à jour" - }, - "it-it": { - "line1": "più recente" - }, - "nl-nl": { - "line1": "Up-to-date" - }, - "pl-pl": { - "line1": "Aktualne" - }, - "pt-br": { - "line1": "Atualizado" - }, - "pt-pt": { - "line1": "Actualizado" - }, - "ru-ru": { - "line1": "Обновлено" - }, - "sv-se": { - "line1": "Uppdat. krävs ej" - }, - "tr-tr": { - "line1": "Güncel" - }, - "zh-cn": { - "line1": "最新更新" - }, - "zh-tw": { - "line1": "更新最新" - } - } - }, - "VehicleInfo": { - "languages": { - "de-de": { - "tts": "Eine App hat Zugriff auf die folgenden Fahrzeuginformationen: Kraftstoff-Füllstand, Kraftstoffverbrauch, Motordrehzahl, Kilometerzähler, FIN, Außentemperatur, Gangstellung, Reifenluftdruck.", - "label": "Fahrzeuginformationen" - }, - "en-au": { - "tts": "An app can access the following vehicle information: Fuel level, Fuel economy, Engine RPMs, Odometer, VIN, Outside air temperature, Gear position, Tyre pressure.", - "label": "Vehicle information" - }, - "en-gb": { - "tts": "An app can access the following vehicle information: Fuel level, Fuel economy, Engine RPMs, Odometer, VIN, Outside air temperature, Gear position, Tire pressure.", - "label": "Vehicle information", - "textBody": "An app can access the following vehicle information: Fuel level, Fuel economy, Engine RPMs, Odometer, VIN, Outside air temperature, Gear position, Tire pressure." - }, - "en-ie": { - "tts": "An app can access the following vehicle information: Fuel level, Fuel economy, Engine RPMs, Odometer, VIN, Outside air temperature, Gear position, Tyre pressure.", - "label": "Vehicle information" - }, - "en-us": { - "tts": "An app can access the following vehicle information: Fuel Level, Fuel Economy, Engine RPMs, Odometer, VIN, External Temperature, Gear Position, Tire Pressure.", - "label": "Vehicle information", - "textBody": "An app can access the following vehicle information: Fuel Level, Fuel Economy, Engine RPMs, Odometer, VIN, External Temperature, Gear Position, Tire Pressure." - }, - "es-en": { - "tts": "Las aplicaciones pueden acceder a la siguiente información del vehículo: Nivel de combustible, Economía de combustible, RPM del motor, Cuentakilómetros, Número de identificación del vehículo, Temperatura externa, Posición del cambio, Presión de los neumáticos.", - "label": "Información del vehículo", - "textBody": "Las aplicaciones pueden acceder a la siguiente información del vehículo: Nivel de combustible, Economía de combustible, RPM del motor, Cuentakilómetros, Número de identificación del vehículo, Temperatura externa, Posición del cambio, Presión de los neumáticos." - }, - "es-es": { - "tts": "Una aplicación puede acceder a la siguiente información del vehículo: Nivel de combustible, Ahorro de combustible, RPM del motor, Cuentakilómetros, VIN, Temperatura aire exterior, Marcha engranada, Presión de neumáticos.", - "label": "Información del vehículo" - }, - "es-mx": { - "tts": "Las aplicaciones pueden acceder a la siguiente información del vehículo: Nivel de combustible, Economía de combustible, RPM del motor, Cuentakilómetros, Número de identificación del vehículo, Temperatura externa, Posición del cambio, Presión de los neumáticos.", - "label": "Información del vehículo", - "textBody": "Las aplicaciones pueden acceder a la siguiente información del vehículo: Nivel de combustible, Economía de combustible, RPM del motor, Cuentakilómetros, Número de identificación del vehículo, Temperatura externa, Posición del cambio, Presión de los neumáticos." - }, - "fr-ca": { - "tts": "Une application peut accéder aux informations suivantes du véhicule: Niveau de carburant, Économie de carburant, Au régime du moteur, Odomètre, NIV, Température extérieure, Position d’embrayage, Pression des pneus.", - "label": "Renseignements du véhicule", - "textBody": "Une application peut accéder aux informations suivantes du véhicule: Niveau de carburant, Économie de carburant, Au régime du moteur, Odomètre, NIV, Température extérieure, Position d’embrayage, Pression des pneus." - }, - "fr-fr": { - "tts": "Une application peut accéder aux informations suivantes du véhicule: Niveau de carburant, Économie de carburant, Vitesse de moteur, Compteur kilométrique, NIV, Température extérieure, Position de vitesse, Pression des pneus.", - "label": "Renseignements du véhicule" - }, - "it-it": { - "tts": "Un'app può avere accesso alle seguenti informazioni del veicolo: Livello carburante, Consumi carburante, Numero giri motore, Contachilometri, VIN, Temperatura esterna, Posizione marcia, Pressione pneumatici.", - "label": "Informazioni sul veicolo" - }, - "nl-nl": { - "tts": "Een app heeft toegang tot de volgende voertuiginformatie: Brandstofpeil, Brandstofverbruik, Motortoerental, Kilometerteller, VIN, Buitentemperatuur, Versnellingsstand, Bandenspanning.", - "label": "Voertuiginformatie" - }, - "pl-pl": { - "tts": "Aplikacja może uzyskać dostęp do następujących informacji o pojeździe: Poziom paliwa, Zużycie paliwa, Obroty silnika, Licznik przebiegu, Numer VIN, Temperatura zewnętrzna, Aktualny bieg, Ciśnienie opon.", - "label": "Informacje o pojeździe" - }, - "pt-br": { - "tts": "Um aplicativo pode acessar as seguintes informações sobre o veículo: Nível de combustível, Economia de combustível, RPM do motor, Hodômetro, VIN, Temperatura externa, Posição das marchas, Pressão dos pneus.", - "label": "Informações sobre o veículo" - }, - "pt-pt": { - "tts": "Uma aplicação consegue aceder às seguintes informações do veículo: Nível de combustível, Poupança de combustível, RPM do motor, Conta-quilómetros, VIN, Temperatura exterior, Posição da mudança de velocidade, Pressão dos pneus.", - "label": "Informações do veículo" - }, - "ru-ru": { - "tts": "Приложение имеет доступ к следующим данным автомобиля: Уровень топлива, Економия топлива, Число оборотов двигателя, Одометр, Номер VIN, Температура за бортом, Положение передачи, Давление шин.", - "label": "Информация об автомобиле" - }, - "sv-se": { - "tts": "Appen kan komma åt följande fordonsinformation: Bränslenivå, Bränsleekonomi, Motorns varvtal, Vägmätare, VIN, Utetemperatur, Växelläge, Däcktryck.", - "label": "Fordonsinformation" - }, - "tr-tr": { - "tts": "Bir uygulama şu araç bilgilerine erişebilir: Yakıt seviyesi, Yakıt ekonomisi, Motor devirleri, Kilometre sayacı, VIN, Dış sıcaklık, Vites konumu, Lastik basıncı.", - "label": "Araç bilgisi" - }, - "zh-cn": { - "tts": "移动应用程序可访问下列车辆信息 : 燃油量, 燃油经济性, 发动机转速(RPM), 里程表, VIN, 车外温度, 档位, 胎压.", - "label": "车辆信息" - }, - "zh-tw": { - "tts": "一個應用程式可存取以下車輛資訊 : 燃油存量, 燃油經濟性, 引擎轉速, 里程表, 車輛識別號碼, 車外溫度, 檔位, 胎壓.", - "label": "車輛資訊" - } - } - } - } - }, - "app_policies": { - "default": { - "keep_context": false, - "steal_focus": false, - "priority": "NONE", - "default_hmi": "NONE", - "groups": ["Base-4"], - "RequestType": [], - "RequestSubType": [] - }, - "device": { - "keep_context": false, - "steal_focus": false, - "priority": "NONE", - "default_hmi": "NONE", - "groups": ["DataConsent-2"] - }, - "pre_DataConsent": { - "keep_context": false, - "steal_focus": false, - "priority": "NONE", - "default_hmi": "NONE", - "groups": ["BaseBeforeDataConsent"] - } - } - } -} +{ + "policy_table": { + "module_config": { + "preloaded_pt": true, + "exchange_after_x_ignition_cycles": 100, + "exchange_after_x_kilometers": 1800, + "exchange_after_x_days": 30, + "timeout_after_x_seconds": 60, + "seconds_between_retries": [ + 1, + 5, + 25, + 125, + 625 + ], + "endpoints": { + "0x07": { + "default": [ + "http://x.x.x.x:3000/api/1/policies/proprietary" + ] + }, + "0x04": { + "default": [ + "http://x.x.x.x:3000/api/1/softwareUpdate" + ] + }, + "queryAppsUrl": { + "default": [ + "http://sdl.shaid.server" + ] + }, + "lock_screen_icon_url": { + "default": [ + "http://i.imgur.com/TgkvOIZ.png" + ] + }, + "custom_vehicle_data_mapping_url": { + "default": [ + "http://x.x.x.x:3000/api/1/vehicleDataMap" + ] + } + }, + "endpoint_properties": { + "custom_vehicle_data_mapping_url": { + "version": "0.0.0" + } + }, + "notifications_per_minute_by_priority": { + "EMERGENCY": 60, + "NAVIGATION": 15, + "PROJECTION": 15, + "VOICECOM": 20, + "COMMUNICATION": 6, + "NORMAL": 4, + "NONE": 0 + }, + "lock_screen_dismissal_enabled": true + }, + "functional_groupings": { + "Base-4": { + "rpcs": { + "AddCommand": { + "hmi_levels": [ + "BACKGROUND", + "FULL", + "LIMITED" + ] + }, + "AddSubMenu": { + "hmi_levels": [ + "BACKGROUND", + "FULL", + "LIMITED" + ] + }, + "ShowAppMenu": { + "hmi_levels": [ + "FULL" + ] + }, + "Alert": { + "hmi_levels": [ + "FULL", + "LIMITED" + ] + }, + "ChangeRegistration": { + "hmi_levels": [ + "BACKGROUND", + "FULL", + "LIMITED", + "NONE" + ] + }, + "CreateInteractionChoiceSet": { + "hmi_levels": [ + "BACKGROUND", + "FULL", + "LIMITED" + ] + }, + "DeleteCommand": { + "hmi_levels": [ + "BACKGROUND", + "FULL", + "LIMITED" + ] + }, + "DeleteFile": { + "hmi_levels": [ + "BACKGROUND", + "FULL", + "LIMITED", + "NONE" + ] + }, + "DeleteInteractionChoiceSet": { + "hmi_levels": [ + "BACKGROUND", + "FULL", + "LIMITED" + ] + }, + "DeleteSubMenu": { + "hmi_levels": [ + "BACKGROUND", + "FULL", + "LIMITED" + ] + }, + "EncodedSyncPData": { + "hmi_levels": [ + "BACKGROUND", + "FULL", + "LIMITED", + "NONE" + ] + }, + "EndAudioPassThru": { + "hmi_levels": [ + "BACKGROUND", + "FULL", + "LIMITED" + ] + }, + "GenericResponse": { + "hmi_levels": [ + "BACKGROUND", + "FULL", + "LIMITED" + ] + }, + "GetSystemCapability": { + "hmi_levels": [ + "BACKGROUND", + "FULL", + "LIMITED", + "NONE" + ] + }, + "ListFiles": { + "hmi_levels": [ + "BACKGROUND", + "FULL", + "LIMITED", + "NONE" + ] + }, + "OnAppInterfaceUnregistered": { + "hmi_levels": [ + "BACKGROUND", + "FULL", + "LIMITED", + "NONE" + ] + }, + "OnAudioPassThru": { + "hmi_levels": [ + "BACKGROUND", + "FULL", + "LIMITED" + ] + }, + "OnButtonEvent": { + "hmi_levels": [ + "FULL", + "LIMITED", + "BACKGROUND" + ] + }, + "OnButtonPress": { + "hmi_levels": [ + "FULL", + "LIMITED", + "BACKGROUND" + ] + }, + "OnCommand": { + "hmi_levels": [ + "BACKGROUND", + "FULL", + "LIMITED" + ] + }, + "OnDriverDistraction": { + "hmi_levels": [ + "BACKGROUND", + "FULL", + "LIMITED", + "NONE" + ] + }, + "OnEncodedSyncPData": { + "hmi_levels": [ + "BACKGROUND", + "FULL", + "LIMITED", + "NONE" + ] + }, + "OnHashChange": { + "hmi_levels": [ + "BACKGROUND", + "FULL", + "LIMITED", + "NONE" + ] + }, + "OnHMIStatus": { + "hmi_levels": [ + "BACKGROUND", + "FULL", + "LIMITED", + "NONE" + ] + }, + "OnLanguageChange": { + "hmi_levels": [ + "BACKGROUND", + "FULL", + "LIMITED", + "NONE" + ] + }, + "OnPermissionsChange": { + "hmi_levels": [ + "BACKGROUND", + "FULL", + "LIMITED", + "NONE" + ] + }, + "OnSystemRequest": { + "hmi_levels": [ + "BACKGROUND", + "FULL", + "LIMITED", + "NONE" + ] + }, + "OnSystemCapabilityUpdated": { + "hmi_levels": [ + "BACKGROUND", + "FULL", + "LIMITED", + "NONE" + ] + }, + "PerformAudioPassThru": { + "hmi_levels": [ + "FULL", + "LIMITED" + ] + }, + "PerformInteraction": { + "hmi_levels": [ + "FULL", + "LIMITED" + ] + }, + "PutFile": { + "hmi_levels": [ + "BACKGROUND", + "FULL", + "LIMITED", + "NONE" + ] + }, + "RegisterAppInterface": { + "hmi_levels": [ + "BACKGROUND", + "FULL", + "LIMITED", + "NONE" + ] + }, + "ResetGlobalProperties": { + "hmi_levels": [ + "BACKGROUND", + "FULL", + "LIMITED", + "NONE" + ] + }, + "ScrollableMessage": { + "hmi_levels": [ + "FULL" + ] + }, + "SetAppIcon": { + "hmi_levels": [ + "BACKGROUND", + "FULL", + "LIMITED", + "NONE" + ] + }, + "SetDisplayLayout": { + "hmi_levels": [ + "BACKGROUND", + "FULL", + "LIMITED", + "NONE" + ] + }, + "SetGlobalProperties": { + "hmi_levels": [ + "BACKGROUND", + "FULL", + "LIMITED", + "NONE" + ] + }, + "SetMediaClockTimer": { + "hmi_levels": [ + "FULL", + "LIMITED", + "BACKGROUND" + ] + }, + "Show": { + "hmi_levels": [ + "BACKGROUND", + "FULL", + "LIMITED" + ] + }, + "Slider": { + "hmi_levels": [ + "FULL" + ] + }, + "Speak": { + "hmi_levels": [ + "FULL", + "LIMITED" + ] + }, + "SubscribeButton": { + "hmi_levels": [ + "BACKGROUND", + "FULL", + "LIMITED" + ] + }, + "SystemRequest": { + "hmi_levels": [ + "BACKGROUND", + "FULL", + "LIMITED", + "NONE" + ] + }, + "UnregisterAppInterface": { + "hmi_levels": [ + "BACKGROUND", + "FULL", + "LIMITED", + "NONE" + ] + }, + "UnsubscribeButton": { + "hmi_levels": [ + "BACKGROUND", + "FULL", + "LIMITED" + ] + }, + "CancelInteraction": { + "hmi_levels": [ + "BACKGROUND", + "FULL", + "LIMITED" + ] + }, + "CloseApplication": { + "hmi_levels": [ + "FULL", + "LIMITED", + "BACKGROUND" + ] + } + } + }, + "Location-1": { + "user_consent_prompt": "Location", + "rpcs": { + "GetVehicleData": { + "hmi_levels": [ + "BACKGROUND", + "FULL", + "LIMITED" + ], + "parameters": [ + "gps", + "speed" + ] + }, + "OnVehicleData": { + "hmi_levels": [ + "BACKGROUND", + "FULL", + "LIMITED" + ], + "parameters": [ + "gps", + "speed" + ] + }, + "SubscribeVehicleData": { + "hmi_levels": [ + "BACKGROUND", + "FULL", + "LIMITED" + ], + "parameters": [ + "gps", + "speed" + ] + }, + "UnsubscribeVehicleData": { + "hmi_levels": [ + "BACKGROUND", + "FULL", + "LIMITED" + ], + "parameters": [ + "gps", + "speed" + ] + } + } + }, + "Notifications": { + "user_consent_prompt": "Notifications", + "rpcs": { + "Alert": { + "hmi_levels": [ + "BACKGROUND" + ] + } + } + }, + "Notifications-RC": { + "rpcs": { + "OnHMIStatus": { + "hmi_levels": [ + "BACKGROUND", + "FULL", + "LIMITED", + "NONE" + ] + }, + "OnPermissionsChange": { + "hmi_levels": [ + "BACKGROUND", + "FULL", + "LIMITED", + "NONE" + ] + }, + "OnSystemRequest": { + "hmi_levels": [ + "BACKGROUND", + "FULL", + "LIMITED", + "NONE" + ] + } + } + }, + "DrivingCharacteristics-3": { + "user_consent_prompt": "DrivingCharacteristics", + "rpcs": { + "GetVehicleData": { + "hmi_levels": [ + "BACKGROUND", + "FULL", + "LIMITED" + ], + "parameters": [ + "accPedalPosition", + "beltStatus", + "electronicParkBrakeStatus", + "driverBraking", + "myKey", + "prndl", + "rpm", + "steeringWheelAngle" + ] + }, + "OnVehicleData": { + "hmi_levels": [ + "BACKGROUND", + "FULL", + "LIMITED" + ], + "parameters": [ + "accPedalPosition", + "beltStatus", + "electronicParkBrakeStatus", + "driverBraking", + "myKey", + "prndl", + "rpm", + "steeringWheelAngle" + ] + }, + "SubscribeVehicleData": { + "hmi_levels": [ + "BACKGROUND", + "FULL", + "LIMITED" + ], + "parameters": [ + "accPedalPosition", + "beltStatus", + "electronicParkBrakeStatus", + "driverBraking", + "myKey", + "prndl", + "rpm", + "steeringWheelAngle" + ] + }, + "UnsubscribeVehicleData": { + "hmi_levels": [ + "BACKGROUND", + "FULL", + "LIMITED" + ], + "parameters": [ + "accPedalPosition", + "beltStatus", + "electronicParkBrakeStatus", + "driverBraking", + "myKey", + "prndl", + "rpm", + "steeringWheelAngle" + ] + } + } + }, + "VehicleInfo-3": { + "user_consent_prompt": "VehicleInfo", + "rpcs": { + "GetVehicleData": { + "hmi_levels": [ + "BACKGROUND", + "FULL", + "LIMITED" + ], + "parameters": [ + "bodyInformation", + "deviceStatus", + "engineOilLife", + "engineTorque", + "externalTemperature", + "turnSignal", + "fuelLevel", + "fuelLevel_State", + "headLampStatus", + "instantFuelConsumption", + "fuelRange", + "cloudAppVehicleID", + "odometer", + "tirePressure", + "vin", + "wiperStatus" + ] + }, + "OnVehicleData": { + "hmi_levels": [ + "BACKGROUND", + "FULL", + "LIMITED" + ], + "parameters": [ + "bodyInformation", + "deviceStatus", + "engineOilLife", + "engineTorque", + "externalTemperature", + "turnSignal", + "fuelLevel", + "fuelLevel_State", + "headLampStatus", + "instantFuelConsumption", + "fuelRange", + "cloudAppVehicleID", + "odometer", + "tirePressure", + "vin", + "wiperStatus" + ] + }, + "SubscribeVehicleData": { + "hmi_levels": [ + "BACKGROUND", + "FULL", + "LIMITED" + ], + "parameters": [ + "bodyInformation", + "deviceStatus", + "engineOilLife", + "engineTorque", + "externalTemperature", + "turnSignal", + "fuelLevel", + "fuelLevel_State", + "headLampStatus", + "instantFuelConsumption", + "fuelRange", + "cloudAppVehicleID", + "odometer", + "tirePressure", + "wiperStatus" + ] + }, + "UnsubscribeVehicleData": { + "hmi_levels": [ + "BACKGROUND", + "FULL", + "LIMITED" + ], + "parameters": [ + "bodyInformation", + "deviceStatus", + "engineOilLife", + "engineTorque", + "externalTemperature", + "turnSignal", + "fuelLevel", + "fuelLevel_State", + "headLampStatus", + "instantFuelConsumption", + "fuelRange", + "cloudAppVehicleID", + "odometer", + "tirePressure", + "wiperStatus" + ] + } + } + }, + "PropriataryData-1": { + "rpcs": { + "DiagnosticMessage": { + "hmi_levels": [ + "BACKGROUND", + "FULL", + "LIMITED" + ] + }, + "GetDTCs": { + "hmi_levels": [ + "BACKGROUND", + "FULL", + "LIMITED" + ] + }, + "ReadDID": { + "hmi_levels": [ + "BACKGROUND", + "FULL", + "LIMITED" + ] + } + } + }, + "PropriataryData-2": { + "rpcs": { + "DiagnosticMessage": { + "hmi_levels": [ + "BACKGROUND", + "FULL", + "LIMITED" + ] + }, + "GetDTCs": { + "hmi_levels": [ + "BACKGROUND", + "FULL", + "LIMITED" + ] + }, + "ReadDID": { + "hmi_levels": [ + "BACKGROUND", + "FULL", + "LIMITED" + ] + } + } + }, + "ProprietaryData-3": { + "rpcs": { + "GetDTCs": { + "hmi_levels": [ + "BACKGROUND", + "FULL", + "LIMITED" + ] + }, + "ReadDID": { + "hmi_levels": [ + "BACKGROUND", + "FULL", + "LIMITED" + ] + } + } + }, + "CloudAppStore": { + "rpcs": { + "SetCloudAppProperties": { + "hmi_levels": [ + "BACKGROUND", + "FULL", + "LIMITED" + ] + }, + "GetCloudAppProperties": { + "hmi_levels": [ + "BACKGROUND", + "FULL", + "LIMITED" + ] + } + } + }, + "CloudApp": { + "rpcs": { + "GetVehicleData": { + "hmi_levels": [ + "BACKGROUND", + "FULL", + "LIMITED" + ], + "parameters": [ + "cloudAppVehicleID" + ] + }, + "OnVehicleData": { + "hmi_levels": [ + "BACKGROUND", + "FULL", + "LIMITED" + ], + "parameters": [ + "cloudAppVehicleID" + ] + }, + "SubscribeVehicleData": { + "hmi_levels": [ + "BACKGROUND", + "FULL", + "LIMITED" + ], + "parameters": [ + "cloudAppVehicleID" + ] + }, + "UnsubscribeVehicleData": { + "hmi_levels": [ + "BACKGROUND", + "FULL", + "LIMITED" + ], + "parameters": [ + "cloudAppVehicleID" + ] + } + } + }, + "AppServiceProvider": { + "rpcs": { + "PublishAppService": { + "hmi_levels": [ + "FULL", + "LIMITED", + "BACKGROUND", + "NONE" + ] + }, + "UnpublishAppService": { + "hmi_levels": [ + "FULL", + "LIMITED", + "BACKGROUND", + "NONE" + ] + }, + "GetAppServiceData": { + "hmi_levels": [ + "FULL", + "LIMITED", + "BACKGROUND", + "NONE" + ] + }, + "OnAppServiceData": { + "hmi_levels": [ + "FULL", + "LIMITED", + "BACKGROUND", + "NONE" + ] + }, + "PerformAppServiceInteraction": { + "hmi_levels": [ + "FULL", + "LIMITED", + "BACKGROUND", + "NONE" + ] + } + } + }, + "AppServiceConsumer": { + "rpcs": { + "GetFile": { + "hmi_levels": [ + "FULL", + "LIMITED", + "BACKGROUND", + "NONE" + ] + }, + "GetAppServiceData": { + "hmi_levels": [ + "FULL", + "LIMITED", + "BACKGROUND", + "NONE" + ] + }, + "OnAppServiceData": { + "hmi_levels": [ + "FULL", + "LIMITED", + "BACKGROUND", + "NONE" + ] + }, + "PerformAppServiceInteraction": { + "hmi_levels": [ + "FULL", + "LIMITED", + "BACKGROUND", + "NONE" + ] + } + } + }, + "RemoteControl": { + "rpcs": { + "ButtonPress": { + "hmi_levels": [ + "BACKGROUND", + "FULL", + "LIMITED" + ] + }, + "GetInteriorVehicleData": { + "hmi_levels": [ + "BACKGROUND", + "FULL", + "LIMITED" + ] + }, + "SetInteriorVehicleData": { + "hmi_levels": [ + "BACKGROUND", + "FULL", + "LIMITED" + ] + }, + "OnInteriorVehicleData": { + "hmi_levels": [ + "BACKGROUND", + "FULL", + "LIMITED" + ] + }, + "SystemRequest": { + "hmi_levels": [ + "BACKGROUND", + "FULL", + "LIMITED", + "NONE" + ] + }, + "OnRCStatus": { + "hmi_levels": [ + "BACKGROUND", + "FULL", + "LIMITED", + "NONE" + ] + }, + "ReleaseInteriorVehicleDataModule": { + "hmi_levels": [ + "BACKGROUND", + "FULL", + "LIMITED", + "NONE" + ] + }, + "GetInteriorVehicleDataConsent": { + "hmi_levels": [ + "BACKGROUND", + "FULL", + "LIMITED", + "NONE" + ] + } + } + }, + "Emergency-1": { + "rpcs": { + "GetVehicleData": { + "hmi_levels": [ + "BACKGROUND", + "FULL", + "LIMITED" + ], + "parameters": [ + "airbagStatus", + "clusterModeStatus", + "eCallInfo", + "emergencyEvent" + ] + }, + "OnVehicleData": { + "hmi_levels": [ + "BACKGROUND", + "FULL", + "LIMITED" + ], + "parameters": [ + "airbagStatus", + "clusterModeStatus", + "eCallInfo", + "emergencyEvent" + ] + }, + "SubscribeVehicleData": { + "hmi_levels": [ + "BACKGROUND", + "FULL", + "LIMITED" + ], + "parameters": [ + "airbagStatus", + "clusterModeStatus", + "eCallInfo", + "emergencyEvent" + ] + }, + "UnsubscribeVehicleData": { + "hmi_levels": [ + "BACKGROUND", + "FULL", + "LIMITED" + ], + "parameters": [ + "airbagStatus", + "clusterModeStatus", + "eCallInfo", + "emergencyEvent" + ] + } + } + }, + "Navigation-1": { + "rpcs": { + "AlertManeuver": { + "hmi_levels": [ + "BACKGROUND", + "FULL", + "LIMITED" + ] + }, + "ShowConstantTBT": { + "hmi_levels": [ + "BACKGROUND", + "FULL", + "LIMITED" + ] + }, + "UpdateTurnList": { + "hmi_levels": [ + "BACKGROUND", + "FULL", + "LIMITED" + ] + } + } + }, + "Base-6": { + "rpcs": { + "AddCommand": { + "hmi_levels": [ + "BACKGROUND", + "FULL", + "LIMITED" + ] + }, + "AddSubMenu": { + "hmi_levels": [ + "BACKGROUND", + "FULL", + "LIMITED" + ] + }, + "ShowAppMenu": { + "hmi_levels": [ + "FULL" + ] + }, + "Alert": { + "hmi_levels": [ + "FULL", + "LIMITED" + ] + }, + "ChangeRegistration": { + "hmi_levels": [ + "BACKGROUND", + "FULL", + "LIMITED", + "NONE" + ] + }, + "CreateInteractionChoiceSet": { + "hmi_levels": [ + "BACKGROUND", + "FULL", + "LIMITED" + ] + }, + "DeleteCommand": { + "hmi_levels": [ + "BACKGROUND", + "FULL", + "LIMITED" + ] + }, + "DeleteFile": { + "hmi_levels": [ + "BACKGROUND", + "FULL", + "LIMITED", + "NONE" + ] + }, + "DeleteInteractionChoiceSet": { + "hmi_levels": [ + "BACKGROUND", + "FULL", + "LIMITED" + ] + }, + "DeleteSubMenu": { + "hmi_levels": [ + "BACKGROUND", + "FULL", + "LIMITED" + ] + }, + "EncodedSyncPData": { + "hmi_levels": [ + "BACKGROUND", + "FULL", + "LIMITED", + "NONE" + ] + }, + "EndAudioPassThru": { + "hmi_levels": [ + "BACKGROUND", + "FULL", + "LIMITED" + ] + }, + "GenericResponse": { + "hmi_levels": [ + "BACKGROUND", + "FULL", + "LIMITED" + ] + }, + "ListFiles": { + "hmi_levels": [ + "BACKGROUND", + "FULL", + "LIMITED", + "NONE" + ] + }, + "OnAppInterfaceUnregistered": { + "hmi_levels": [ + "BACKGROUND", + "FULL", + "LIMITED", + "NONE" + ] + }, + "OnAudioPassThru": { + "hmi_levels": [ + "BACKGROUND", + "FULL", + "LIMITED" + ] + }, + "OnButtonEvent": { + "hmi_levels": [ + "FULL", + "LIMITED" + ] + }, + "OnButtonPress": { + "hmi_levels": [ + "FULL", + "LIMITED" + ] + }, + "OnCommand": { + "hmi_levels": [ + "FULL", + "LIMITED" + ] + }, + "OnDriverDistraction": { + "hmi_levels": [ + "BACKGROUND", + "FULL", + "LIMITED", + "NONE" + ] + }, + "OnEncodedSyncPData": { + "hmi_levels": [ + "BACKGROUND", + "FULL", + "LIMITED", + "NONE" + ] + }, + "OnHMIStatus": { + "hmi_levels": [ + "BACKGROUND", + "FULL", + "LIMITED", + "NONE" + ] + }, + "OnLanguageChange": { + "hmi_levels": [ + "BACKGROUND", + "FULL", + "LIMITED", + "NONE" + ] + }, + "OnPermissionsChange": { + "hmi_levels": [ + "BACKGROUND", + "FULL", + "LIMITED", + "NONE" + ] + }, + "OnSyncPData": { + "hmi_levels": [ + "BACKGROUND", + "FULL", + "LIMITED", + "NONE" + ] + }, + "OnTBTClientState": { + "hmi_levels": [ + "BACKGROUND", + "FULL", + "LIMITED" + ] + }, + "PerformAudioPassThru": { + "hmi_levels": [ + "FULL", + "LIMITED" + ] + }, + "PerformInteraction": { + "hmi_levels": [ + "FULL", + "LIMITED" + ] + }, + "PutFile": { + "hmi_levels": [ + "BACKGROUND", + "FULL", + "LIMITED", + "NONE" + ] + }, + "RegisterAppInterface": { + "hmi_levels": [ + "BACKGROUND", + "FULL", + "LIMITED", + "NONE" + ] + }, + "ResetGlobalProperties": { + "hmi_levels": [ + "BACKGROUND", + "FULL", + "LIMITED" + ] + }, + "ScrollableMessage": { + "hmi_levels": [ + "FULL" + ] + }, + "SetAppIcon": { + "hmi_levels": [ + "BACKGROUND", + "FULL", + "LIMITED", + "NONE" + ] + }, + "SetDisplayLayout": { + "hmi_levels": [ + "BACKGROUND", + "FULL", + "LIMITED", + "NONE" + ] + }, + "SetGlobalProperties": { + "hmi_levels": [ + "BACKGROUND", + "FULL", + "LIMITED" + ] + }, + "SetMediaClockTimer": { + "hmi_levels": [ + "FULL" + ] + }, + "Show": { + "hmi_levels": [ + "BACKGROUND", + "FULL", + "LIMITED" + ] + }, + "Slider": { + "hmi_levels": [ + "FULL" + ] + }, + "Speak": { + "hmi_levels": [ + "FULL", + "LIMITED" + ] + }, + "SubscribeButton": { + "hmi_levels": [ + "BACKGROUND", + "FULL", + "LIMITED" + ] + }, + "SyncPData": { + "hmi_levels": [ + "BACKGROUND", + "FULL", + "LIMITED", + "NONE" + ] + }, + "UnregisterAppInterface": { + "hmi_levels": [ + "BACKGROUND", + "FULL", + "LIMITED", + "NONE" + ] + }, + "UnsubscribeButton": { + "hmi_levels": [ + "BACKGROUND", + "FULL", + "LIMITED" + ] + } + } + }, + "OnKeyboardInputOnlyGroup": { + "rpcs": { + "OnKeyboardInput": { + "hmi_levels": [ + "FULL" + ] + } + } + }, + "OnTouchEventOnlyGroup": { + "rpcs": { + "OnTouchEvent": { + "hmi_levels": [ + "FULL" + ] + } + } + }, + "DiagnosticMessageOnly": { + "rpcs": { + "DiagnosticMessage": { + "hmi_levels": [ + "BACKGROUND", + "FULL", + "LIMITED" + ] + } + } + }, + "DataConsent-2": { + "user_consent_prompt": "DataConsent", + "rpcs": null + }, + "BaseBeforeDataConsent": { + "rpcs": { + "ChangeRegistration": { + "hmi_levels": [ + "BACKGROUND", + "FULL", + "LIMITED", + "NONE" + ] + }, + "DeleteFile": { + "hmi_levels": [ + "BACKGROUND", + "FULL", + "LIMITED", + "NONE" + ] + }, + "EncodedSyncPData": { + "hmi_levels": [ + "BACKGROUND", + "FULL", + "LIMITED", + "NONE" + ] + }, + "ListFiles": { + "hmi_levels": [ + "BACKGROUND", + "FULL", + "LIMITED", + "NONE" + ] + }, + "OnAppInterfaceUnregistered": { + "hmi_levels": [ + "BACKGROUND", + "FULL", + "LIMITED", + "NONE" + ] + }, + "OnEncodedSyncPData": { + "hmi_levels": [ + "BACKGROUND", + "FULL", + "LIMITED", + "NONE" + ] + }, + "OnHashChange": { + "hmi_levels": [ + "BACKGROUND", + "FULL", + "LIMITED", + "NONE" + ] + }, + "OnHMIStatus": { + "hmi_levels": [ + "BACKGROUND", + "FULL", + "LIMITED", + "NONE" + ] + }, + "OnLanguageChange": { + "hmi_levels": [ + "BACKGROUND", + "FULL", + "LIMITED", + "NONE" + ] + }, + "OnPermissionsChange": { + "hmi_levels": [ + "BACKGROUND", + "FULL", + "LIMITED", + "NONE" + ] + }, + "OnSystemRequest": { + "hmi_levels": [ + "BACKGROUND", + "FULL", + "LIMITED", + "NONE" + ] + }, + "PutFile": { + "hmi_levels": [ + "BACKGROUND", + "FULL", + "LIMITED", + "NONE" + ] + }, + "RegisterAppInterface": { + "hmi_levels": [ + "BACKGROUND", + "FULL", + "LIMITED", + "NONE" + ] + }, + "ResetGlobalProperties": { + "hmi_levels": [ + "BACKGROUND", + "FULL", + "LIMITED", + "NONE" + ] + }, + "SetGlobalProperties": { + "hmi_levels": [ + "BACKGROUND", + "FULL", + "LIMITED", + "NONE" + ] + }, + "SetAppIcon": { + "hmi_levels": [ + "BACKGROUND", + "FULL", + "LIMITED", + "NONE" + ] + }, + "SetDisplayLayout": { + "hmi_levels": [ + "BACKGROUND", + "FULL", + "LIMITED", + "NONE" + ] + }, + "SystemRequest": { + "hmi_levels": [ + "BACKGROUND", + "FULL", + "LIMITED", + "NONE" + ] + }, + "UnregisterAppInterface": { + "hmi_levels": [ + "BACKGROUND", + "FULL", + "LIMITED", + "NONE" + ] + } + } + }, + "SendLocation": { + "rpcs": { + "SendLocation": { + "hmi_levels": [ + "BACKGROUND", + "FULL", + "LIMITED" + ] + } + } + }, + "WayPoints": { + "rpcs": { + "GetWayPoints": { + "hmi_levels": [ + "BACKGROUND", + "FULL", + "LIMITED" + ] + }, + "SubscribeWayPoints": { + "hmi_levels": [ + "BACKGROUND", + "FULL", + "LIMITED" + ] + }, + "UnsubscribeWayPoints": { + "hmi_levels": [ + "BACKGROUND", + "FULL", + "LIMITED" + ] + }, + "OnWayPointChange": { + "hmi_levels": [ + "BACKGROUND", + "FULL", + "LIMITED" + ] + } + } + }, + "BackgroundAPT": { + "rpcs": { + "EndAudioPassThru": { + "hmi_levels": [ + "BACKGROUND" + ] + }, + "OnAudioPassThru": { + "hmi_levels": [ + "BACKGROUND" + ] + }, + "PerformAudioPassThru": { + "hmi_levels": [ + "BACKGROUND" + ] + } + } + }, + "HapticGroup": { + "rpcs": { + "OnTouchEvent": { + "hmi_levels": ["FULL"] + }, + "SendHapticData": { + "hmi_levels": [ + "FULL" + ] + } + } + }, + "WidgetSupport": { + "rpcs": { + "CreateWindow": { + "hmi_levels": [ + "BACKGROUND", + "FULL", + "LIMITED" + ] + }, + "DeleteWindow": { + "hmi_levels": [ + "BACKGROUND", + "FULL", + "LIMITED" + ] + }, + "Show": { + "hmi_levels": [ + "BACKGROUND", + "FULL", + "LIMITED" + ] + }, + "OnSystemCapabilityUpdated": { + "hmi_levels": [ + "BACKGROUND", + "FULL", + "LIMITED", + "NONE" + ] + } + } + } + }, + "consumer_friendly_messages": { + "version": "001.001.021", + "messages": { + "AppPermissions": { + "languages": { + "de-de": { + "tts": "%appName% benötigt die folgenden Fahrzeuginformationen und Zugriffsberechtigungen: %functionalGroupLabels%. Wenn Sie Ja drücken, erklären Sie sich damit einverstanden, dass %vehicleMake% nicht für Schäden oder Verletzungen der Privatsphäre haftet, die im Zusammenhang mit der Nutzung Ihrer Benutzerdaten durch %appName% entstehen. Mit Ja stimmen Sie zu; mit Nein lehnen Sie ab.", + "line1": "Zugriffsanfrage(n)", + "line2": "erlauben?" + }, + "en-au": { + "tts": "%appName% is requesting the use of the following vehicle information and permissions: %functionalGroupLabels%. If you press Yes, you agree that %vehicleMake% will not be liable for any damages or loss of privacy related to %appName%'s use of your data. Please press Yes to allow or No to deny.", + "line1": "Grant requested", + "line2": "permission(s)?" + }, + "en-gb": { + "tts": "%appName% is requesting the use of the following vehicle information and permissions: %functionalGroupLabels%. If you press Yes, you agree that %vehicleMake% will not be liable for any damages or loss of privacy related to %appName%`s use of your data. Please press Yes to allow or No to deny.", + "line1": "Grant requested", + "line2": "permission(s)?", + "textBody": "%appName% is requesting the use of the following vehicle information and permissions: %functionalGroupLabels%. If you press yes, you agree that %vehicleMake% will not be liable for any damages or loss of privacy related to %appName%`s use of your data. You can change these permissions and hear detailed descriptions in the mobile apps settings menu." + }, + "en-ie": { + "tts": "%appName% is requesting the use of the following vehicle information and permissions: %functionalGroupLabels%. If you press Yes, you agree that %vehicleMake% will not be liable for any damages or loss of privacy related to %appName%'s use of your data. Please press Yes to allow or No to deny.", + "line1": "Grant requested", + "line2": "permission(s)?" + }, + "en-us": { + "tts": "%appName% is requesting the use of the following vehicle information and permissions: %functionalGroupLabels%. If you press yes, you agree that %vehicleMake% will not be liable for any damages or loss of privacy related to %appName%’s use of your data. Please press yes to allow or no to deny.", + "line1": "Grant Requested", + "line2": "Permission(s)?", + "textBody": "%appName% is requesting the use of the following vehicle information and permissions: %functionalGroupLabels%. \n\nIf you press yes, you agree that %vehicleMake% will not be liable for any damages or loss of privacy related to %appName%’s use of your data. You can change these permissions and hear detailed descriptions in the mobile apps settings menu." + }, + "es-en": { + "tts": "%appName% solicita el uso de la siguiente información y permisos del vehículo: %functionalGroupLabels%. Si presiona Sí, acepta que %vehicleMake% no se hará responsable por los daños o pérdidas de privacidad relacionados con el uso que %appName% haga de sus datos. Presione Sí para permitir y No para denegar.", + "line1": "¿Otorgar permiso(s)", + "line2": "solicitado(s)?", + "textBody": "%appName% solicita el uso de la siguiente información y permisos del vehículo: %functionalGroupLabels%. Si presiona Sí, acepta que %vehicleMake% no se hará responsable por los daños o pérdidas de privacidad relacionados con el uso que %appName% haga de sus datos. Presione Sí para permitir y No para denegar. \n\n Puede cambiar estos permisos y consultar descripciones detalladas en el menú de configuración de las aplicaciones móviles." + }, + "es-es": { + "tts": "%appName% está solicitando el uso de los siguientes permisos e información del vehículo: %functionalGroupLabels%. Si pulsa sí, acepta que %vehicleMake% no será responsable de los daños o la pérdida de privacidad relacionados con el uso de sus datos por parte de %appName%. Pulse sí para permitir o no para denegar.", + "line1": "¿Conceder permisos", + "line2": "solicitados?" + }, + "es-mx": { + "tts": "%appName% solicita el uso de la siguiente información y permisos del vehículo: %functionalGroupLabels%. Si presiona Sí, acepta que %vehicleMake% no se hará responsable por los daños o pérdidas de privacidad relacionados con el uso que %appName% haga de sus datos. Presione Sí para permitir y No para denegar.", + "line1": "¿Otorgar permiso(s)", + "line2": "solicitado(s)?", + "textBody": "%appName% solicita el uso de la siguiente información y permisos del vehículo: %functionalGroupLabels%. \n\nSi presiona Sí, acepta que %vehicleMake% no se hará responsable por los daños o pérdidas de privacidad relacionados con el uso que %appName% haga de sus datos. Presione Sí para permitir y No para denegar. Puede cambiar estos permisos y consultar descripciones detalladas en el menú de configuración de las aplicaciones móviles." + }, + "fr-ca": { + "tts": "%appName% demande d’utiliser les informations du véhicule et les permissions suivantes : %functionalGroupLabels%. Si vous appuyez sur Oui, vous acceptez que %vehicleMake% ne sera pas responsable des dommages ou des pertes de confidentialité reliées à l’utilisation de vos données par %appName%. Veuillez appuyer sur Oui pour autoriser ou sur Non pour refuser.", + "line1": "Accorder permission(s)", + "line2": "demandée(s)", + "textBody": "%appName% demande d’utiliser les informations du véhicule et les permissions suivantes : %functionalGroupLabels%. Si vous appuyez sur Oui, vous acceptez que %vehicleMake% ne sera pas responsable des dommages ou des pertes de confidentialité reliées à l’utilisation de vos données par %appName%. Vous pouvez modifier ces permissions et entendre les descriptions détaillées dans le menu des réglages des applications mobiles." + }, + "fr-fr": { + "tts": "%appName% demande d’utiliser les informations du véhicule et les permissions suivantes : %functionalGroupLabels%. Si vous appuyez sur Oui, vous acceptez que %vehicleMake% ne sera pas responsable des dommages ou des pertes de confidentialité reliées à l’utilisation de vos données par %appName%. Veuillez appuyer sur Oui pour autoriser ou sur Non pour refuser.", + "line1": "Accorder permission(s)", + "line2": "demandée(s)" + }, + "it-it": { + "tts": "%appName% richiede l'uso delle seguenti informazioni e autorizzazioni sul veicolo: %functionalGroupLabels%. Se si preme Sì, si acconsente che %vehicleMake% non sarà responsabile per danni o perdita di privacy in relazione all'impiego dei dati da parte di %appName%. Premere Sì per consentire e No per negare.", + "line1": "Concedi autorizzaz.", + "line2": "richiesta(e)?" + }, + "nl-nl": { + "tts": "%appName% vraagt gebruikmaking van de volgende voertuiginformatie en toestemmingen aan: %functionalGroupLabels%. Als u op Ja drukt, gaat u ermee akkoord dat %vehicleMake% in geen geval aansprakelijk gesteld kan worden voor schade of verlies van privacy als gevolg van het feit dat %appName% gebruik maakt van uw gegevens. Druk op Ja om dit toe te staan of Nee om te weigeren.", + "line1": "Aangevraagde", + "line2": "permissie(s) verlenen?" + }, + "pl-pl": { + "tts": "%appName% wymaga następujących informacji o pojeździe oraz pozwoleń: %functionalGroupLabels%. Naciśnięcie TAK oznacza zgodę na fakt, iż %vehicleMake% nie będzie ponosić odpowiedzialności za szkody ani utratę prywatności w związku z wykorzystaniem przez %appName% danych, należących do użytkownika. Naciśnij TAK w celu udzielenia zgody lub NIE w celu odrzucenia żądania.", + "line1": "Udzielić żądanych", + "line2": "pozwoleń?" + }, + "pt-br": { + "tts": "%appName% está solicitando o uso das seguintes informações e permissões do veículo: %functionalGroupLabels%. Se pressionar sim, você concorda que a %vehicleMake% não será responsável por danos ou perdas de privacidade relacionados ao uso dos seus dados por %appName%. Pressione sim para permitir ou não para negar.", + "line1": "Conceder permissão", + "line2": "solicitada?" + }, + "pt-pt": { + "tts": "%appName% está a solicitar a utilização das seguintes informações e permissões do veículo: %functionalGroupLabels%. Se premir “Sim”, concorda que %vehicleMake% não será responsável por quaisquer danos ou perda de privacidade relacionada com a utilização dos seus dados por parte de %appName%. Prima “Sim” para permitir ou “Não” para recusar.", + "line1": "Conceder permiss.", + "line2": "solicitada(s)?" + }, + "ru-ru": { + "tts": "%appName% запрашивает следующую информацию об автомобиле и разрешения: %functionalGroupLabels%. Нажатием \"\"да\"\", Вы соглашаетесь, что %vehicleMake% не будет нести ответственность за какие-либо убытки или потерю прайвеси, связанные с использованием Ваших данных компанией %appName%. Нажмите \"\"Да\"\", если Вы согласны, или \"\"Нет\"\" - если не согласны.", + "line1": "Предост. заправш.", + "line2": "разрешения?" + }, + "sv-se": { + "tts": "%appName% begär att få tillgång till följande fordonsinformation och tillstånd: %functionalGroupLabels%. Om du trycker Ja godkänner du att %vehicleMake% ska hållas skadeslös för alla skador som kan uppstå eller eventuella integritetsintrång som uppstår när %appName% använder dina data. Tryck Ja för att godkänna eller Nej för att neka.", + "line1": "Vill du ge", + "line2": "tillstånd?" + }, + "tr-tr": { + "tts": "%appName%, şu araç bilgilerini ve izinleri kullanma isteğinde bulunuyor: %functionalGroupLabels%. Evet'e basarsanız, %appName%'in verilerinizi kullanması sonucunda oluşabilecek hasarlardan veya gizlilik kaybından %vehicleMake%'in sorumlu olmayacağını kabul etmiş olacaksınız. Lütfen kabul etmek için Evet'e veya reddetmek için Hayır'a basın.", + "line1": "İstenen izinler", + "line2": "verilsin mi?" + }, + "zh-cn": { + "tts": "%appName% 正在请求使用下列车辆信息和权限: %functionalGroupLabels%。如果您按“是”,则表示您同意。 %vehicleMake% 将不会对因 %appName% 使用您的数据而引起的任何损毁或隐私损失负责。 请按“是”允许或按“否”拒绝。", + "line1": "是否允许请求的", + "line2": "权限?" + }, + "zh-tw": { + "tts": "%appName% 正請求使用 %functionalGroupLabels% 的車輛資訊和許可。按「是」,表示您同意,如因 %appName% 使用您的資料導致任何損害或損失,%vehicleMake% 將不負賠償責任。同意請按「是」,拒絕請按「否」。", + "line1": "允許", + "line2": "授權請求?" + } + } + }, + "AppPermissionsHelp": { + "languages": { + "de-de": { + "tts": "%appName% fordert folgende Fahrzeuginformationen und Zugriffsberechtigungen: %functionalGroupLabels%. Im Einstellungsmenü der mobilen Apps können Sie diese Berechtigungen ändern und sich detaillierte Beschreibungen anhören. Mit Ja stimmen Sie zu; mit Nein lehnen Sie ab." + }, + "en-au": { + "tts": "%appName% is requesting the following vehicle information and permissions: %functionalGroupLabels%. You can change these permissions and hear detailed descriptions in the mobile apps settings menu. Please press Yes to grant permissions or No to deny." + }, + "en-gb": { + "tts": "%appName% is requesting the following vehicle information and permissions: %functionalGroupLabels%. You can change these permissions and hear detailed descriptions in the mobile apps settings menu. Please press Yes to grant permissions or No to deny." + }, + "en-ie": { + "tts": "%appName% is requesting the following vehicle information and permissions: %functionalGroupLabels%. You can change these permissions and hear detailed descriptions in the mobile apps settings menu. Please press Yes to grant permissions or No to deny." + }, + "en-us": { + "tts": "%appName% is requesting the following vehicle information and permissions: %functionalGroupLabels%. You can change these permissions and hear detailed descriptions in the mobile apps settings menu. Please press yes to grant permissions or no to deny." + }, + "es-en": { + "tts": "%appName% solicita la siguiente información y permisos del vehículo: %functionalGroupLabels%. Puede cambiar estos permisos y consultar descripciones detalladas en el menú de configuración de las aplicaciones móviles. Presione Sí para otorgar permisos y No para denegar." + }, + "es-es": { + "tts": "%appName% está solicitando los siguientes permisos e información del vehículo: %functionalGroupLabels%. Puede cambiar estos permisos y escuchar descripciones detalladas en el menú de configuración de la aplicación móvil. Pulse sí para conceder el permiso o no para denegarlo." + }, + "es-mx": { + "tts": "%appName% solicita la siguiente información y permisos del vehículo: %functionalGroupLabels%. Puede cambiar estos permisos y consultar descripciones detalladas en el menú de configuración de las aplicaciones móviles. Presione Sí para otorgar permisos y No para denegar." + }, + "fr-ca": { + "tts": "%appName% demande d’utiliser les informations du véhicule et les permissions suivantes : %functionalGroupLabels%. Vous pouvez modifier ces permissions et entendre les descriptions détaillées dans le menu des réglages des applications mobiles. Veuillez appuyer sur Oui pour accorder les permissions ou sur Non pour refuser." + }, + "fr-fr": { + "tts": "%appName% demande d’utiliser les informations du véhicule et les permissions suivantes : %functionalGroupLabels%. Vous pouvez modifier ces permissions et entendre les descriptions détaillées dans le menu des réglages des applications mobiles. Veuillez appuyer sur Oui pour accorder les permissions ou sur Non pour refuser." + }, + "it-it": { + "tts": "%appName% richiede le seguenti informazioni e autorizzazioni riguardo il veicolo: %functionalGroupLabels%. È possibile modificare tali autorizzazioni e ascoltare descrizioni dettagliate nel menu impostazioni delle app mobili. Premere Sì per concedere le autorizzazioni e No per negarle." + }, + "nl-nl": { + "tts": "%appName% vraagt gebruikmaking van de volgende voertuiginformatie en toestemmingen aan: %functionalGroupLabels%. U kunt deze toestemmingen wijzigen en gedetailleerde beschrijvingen beluisteren in het instellingenmenu voor mobiele apps. Druk op Ja om permissies te verlenen of op Nee om te weigeren." + }, + "pl-pl": { + "tts": "%appName% wymaga następujących informacji o pojeździe oraz zezwoleń: %functionalGroupLabels%. W menu ustawień aplikacji mobilnych można zmienić owe zezwolenia i usłyszeć ich szczegółowy opis. Naciśnij TAK, aby wyrazić zgodę lub NIE w celu odrzucenia żądania." + }, + "pt-br": { + "tts": "%appName% está solicitando as seguintes informações e permissões do veículo: %functionalGroupLabels%. Você pode alterar estas permissões e ouvir descrições detalhadas no menu de configurações de aplicativos móveis. Pressione sim para conceder as permissões ou não para negar." + }, + "pt-pt": { + "tts": "%appName% está a solicitar as seguintes informações e permissões do veículo: %functionalGroupLabels%. Pode alterar estas permissões e ouvir descrições detalhadas no menu de definições das aplicações móveis. Prima \"\"Sim\"\" para permitir ou \"\"Não\"\" para recusar." + }, + "ru-ru": { + "tts": "%appName% запрашивает следующую информацию об автомобиле и разрешения: %functionalGroupLabels%. Вы можете изменить эти разрешения и прослушать подробные их описания в меню настроек мобильного приложения. Нажмите \"\"да\"\", чтобы предоставить разрешения, или \"\"нет\"\", чтобы не предоставлять." + }, + "sv-se": { + "tts": "%appName% begär tillgång till följande fordonsinformation och tillstånd: %functionalGroupLabels%. Du kan ändra tillstånden och höra detaljerade beskrivningar i menyn för mobilappsinställningar. Tryck Ja för att ge tillstånd eller Nej för att neka." + }, + "tr-tr": { + "tts": "%appName%, şu araç bilgilerini ve izinleri istiyor: %functionalGroupLabels%. Bu izinleri değiştirebilir ve mobil uygulamalar ayarlar menüsünden ayrıntılı açıklamaları dinleyebilirsiniz. Lütfen izin vermek için Evet'e veya reddetmek için Hayır'a basın." + }, + "zh-cn": { + "tts": "%appName% 正在请求下列车辆信息和权限: %functionalGroupLabels%。您可在移动应用程序设置菜单中更改这些权限,并听取详细说明。请按“是”允许权限或按“否”拒绝。" + }, + "zh-tw": { + "tts": "%appName% 正請求使用 %functionalGroupLabels% 的車輛資訊和許可。您可在行動應用程式設定清單中更改這些許可,並聆聽詳細說明。給予許可請按「是」,拒絕請按「否」。" + } + } + }, + "AppPermissionsRevoked": { + "languages": { + "de-de": { + "tts": "Die Autorisierungsdaten der App wurden geändert. %appName% hat keinen Zugriff auf %functionalGroupLabels% mehr. Installieren Sie die neueste Version der App auf Ihrem Gerät.." + }, + "en-au": { + "tts": "App authorizations have changed. %appName% can no longer access %functionalGroupLabels%. Please ensure you have the most recent app version installed on your mobile device." + }, + "en-gb": { + "tts": "App authorizations have changed. %appName% can no longer access %functionalGroupLabels%. Please ensure you have the most recent app version installed on your mobile device." + }, + "en-ie": { + "tts": "App authorizations have changed. %appName% can no longer access %functionalGroupLabels%. Please ensure you have the most recent app version installed on your mobile device." + }, + "en-us": { + "tts": "App authorizations have changed. %appName% can no longer access %functionalGroupLabels%. Please ensure you have the most recent app version installed on your mobile device." + }, + "es-en": { + "tts": "Las autorizaciones de la aplicación han cambiado. %appName% ya no puede acceder a %functionalGroupLabels%. Asegúrese de haber instalado la versión más reciente de la aplicación en su dispositivo móvil." + }, + "es-es": { + "tts": "Las autorizaciones de la aplicación han cambiado. %appName% ya no puede acceder a %functionalGroupLabels%. Asegúrese de que tiene la versión más reciente de la aplicación instalada en su dispositivo móvil." + }, + "es-mx": { + "tts": "Las autorizaciones de la aplicación han cambiado. %appName% ya no puede acceder a %functionalGroupLabels%. Asegúrese de haber instalado la versión más reciente de la aplicación en su dispositivo móvil." + }, + "fr-ca": { + "tts": "Les autorisations pour app ont changé. %appName% ne peut plus accéder à %functionalGroupLabels%. Veuillez vous assurer que la plus récente version de l’application est installée sur votre appareil mobile." + }, + "fr-fr": { + "tts": "Les autorisations pour app ont changé. %appName% ne peut plus accéder à %functionalGroupLabels%. Veuillez vous assurer que la plus récente version de l’application est installée sur votre appareil mobile." + }, + "it-it": { + "tts": "Le autorizzazioni dell'app sono cambiate. %appName% non è più in grado di accedere a %functionalGroupLabels%. Assicurarsi di avere la versione più recente dell'app installata sul dispositivo mobile." + }, + "nl-nl": { + "tts": "De app-autorisaties zijn gewijzigd. %appName% heeft geen toegang meer tot %functionalGroupLabels%. Zorg ervoor dat u de meest recente app-versie op uw mobiele apparaat geïnstalleerd hebt." + }, + "pl-pl": { + "tts": "Dane dostępu aplikacji zostały zmienione. %appName% nie ma już dostępu do %functionalGroupLabels%. Sprawdź, czy na telefonie komórkowym zainstalowano najnowszą wersję aplikacji." + }, + "pt-br": { + "tts": "As autorizações dos aplicativos foram alteradas. %appName% não pode mais acessar %functionalGroupLabels%. Certifique-se de que a versão mais recente do aplicativo está instalada no seu dispositivo móvel." + }, + "pt-pt": { + "tts": "As autorizações das aplicações mudaram. %appName% já não consegue aceder a %functionalGroupLabels%. Certifique-se de que tem a última versão da aplicação no seu dispositivo móvel." + }, + "ru-ru": { + "tts": "Авторизации приложения изменены. %appName% больше не имеет доступа к %functionalGroupLabels%. Убедитесь, что на вашем мобильном устройстве установлена самая новая версия приложения." + }, + "sv-se": { + "tts": "Appens behörigheter har ändrats. %appName% har inte längre åtkomst till %functionalGroupLabels%. Kontrollera att du har installerat den senaste versionen av appen på mobilenheten." + }, + "tr-tr": { + "tts": "Uygulama yetkileri değişti. %appName% artık %functionalGroupLabels%'e erişemeyecek. Lütfen mobil aygıtınızda en son uygulama sürümünün yüklü olduğundan emin olun." + }, + "zh-cn": { + "tts": "应用程序授权已变更。 %appName% 将不能再访问 %functionalGroupLabels%。 请确认您的移动设备上安装的应用程序是最新版本。" + }, + "zh-tw": { + "tts": "應用程式授權已改變。%appName% 已無法進入 %functionalGroupLabels%。請確認您的行動裝置上安裝了最新版應用程式。" + } + } + }, + "AppUnauthorized": { + "languages": { + "de-de": { + "tts": "Diese Version von %appName% ist nicht autorisiert und wird nicht mit SYNC funktionieren.", + "line1": "nicht autorisiert" + }, + "en-au": { + "tts": "This version of %appName% is not authorized and will not work with SYNC.", + "line1": "not authorized" + }, + "en-gb": { + "tts": "This version of %appName% is not authorized and will not work with SYNC.", + "line1": "not authorized", + "textBody": "This version of %appName% is not authorized and will not work with SYNC." + }, + "en-ie": { + "tts": "This version of %appName% is not authorized and will not work with SYNC.", + "line1": "not authorized" + }, + "en-us": { + "tts": "This version of %appName% is not authorized and will not work with SYNC.", + "line1": "Not Authorized", + "textBody": "This version of %appName% is no longer authorized to work with AppLink. Please update to the latest version of %appName%." + }, + "es-en": { + "tts": "Esta versión de %appName% no tiene autorización y no funcionará con SYNC.", + "line1": "no autorizada", + "textBody": "Esta versión de %appName% no tiene autorización y no funcionará con SYNC." + }, + "es-es": { + "tts": "Esta versión de %appName% no está autorizada y no funcionará con SYNC.", + "line1": "No autorizada" + }, + "es-mx": { + "tts": "Esta versión de %appName% no tiene autorización y no funcionará con SYNC.", + "line1": "no autorizada", + "textBody": "Esta versión de %appName% no tiene autorización y no funcionará con SYNC." + }, + "fr-ca": { + "tts": "Cette version de %appName% n’est pas autorisée et ne fonctionnera pas avec SYNC.", + "line1": "non autorisée", + "textBody": "Cette version de %appName% n’est pas autorisée et ne fonctionnera pas avec SYNC." + }, + "fr-fr": { + "tts": "Cette version de %appName% n’est pas autorisée et ne fonctionnera pas avec SYNC.", + "line1": "non autorisée" + }, + "it-it": { + "tts": "Questa versione di %appName% non è autorizzata e non funziona con il SYNC.", + "line1": "non autorizzata" + }, + "nl-nl": { + "tts": "Deze versie van %appName% is niet geautoriseerd en werkt niet met SYNC.", + "line1": "niet geautoriseerd" + }, + "pl-pl": { + "tts": "Niniejsza wersja %appName% nie posiada autoryzacji i nie będzie działać z SYNC.", + "line1": "brak autoryzacji" + }, + "pt-br": { + "tts": "Esta versão do %appName% não tem autorização e não funcionará com o SYNC.", + "line1": "não autorizado" + }, + "pt-pt": { + "tts": "Esta versão de %appName% não está autorizada e não funcionará com o SYNC.", + "line1": "não autorizada" + }, + "ru-ru": { + "tts": "Эта версия %appName% не авторизирована и не будет работать с SYNC.", + "line1": "не авторизировано" + }, + "sv-se": { + "tts": "Den här versionen av %appName% är inte godkänd och fungerar inte med SYNC.", + "line1": "är ej godkänd" + }, + "tr-tr": { + "tts": "Bu %appName% sürümüne izin verilmediğinden SYNC ile çalışamaz.", + "line1": "için izin yok" + }, + "zh-cn": { + "tts": "此版本的%appName% 未得到授权,无法在SYNC上使用。", + "line1": "未得到授权" + }, + "zh-tw": { + "tts": "%appName% 的版本未獲得授權,將無法透過 SYNC 使用。", + "line1": "無授權" + } + } + }, + "AppUnsupported": { + "languages": { + "de-de": { + "tts": "Diese Version von %appName% wird von SYNC nicht unterstützt.", + "line1": "nicht unterstützt" + }, + "en-au": { + "tts": "This version of %appName% is not supported by SYNC.", + "line1": "not supported" + }, + "en-gb": { + "tts": "This version of %appName% is not supported by SYNC.", + "line1": "not supported", + "textBody": "This version of %appName% is not supported by SYNC." + }, + "en-ie": { + "tts": "This version of %appName% is not supported by SYNC.", + "line1": "not supported" + }, + "en-us": { + "tts": "This version of %appName% is not supported by SYNC.", + "line1": "Not Supported", + "textBody": "Your version of %appName% is not supported by SYNC." + }, + "es-en": { + "tts": "Esta versión de %appName% no es compatible con SYNC.", + "line1": "no compatible", + "textBody": "Esta versión de %appName% no es compatible con SYNC." + }, + "es-es": { + "tts": "Esta versión de %appName% no es compatible con SYNC.", + "line1": "No compatible" + }, + "es-mx": { + "tts": "Esta versión de %appName% no es compatible con SYNC.", + "line1": "no compatible", + "textBody": "Esta versión de %appName% no es compatible con SYNC." + }, + "fr-ca": { + "tts": "Cette version de %appName% n’est pas prise en charge par SYNC.", + "line1": "incompatible", + "textBody": "Cette version de %appName% n’est pas prise en charge par SYNC." + }, + "fr-fr": { + "tts": "Cette version de %appName% n’est pas prise en charge par SYNC.", + "line1": "incompatible" + }, + "it-it": { + "tts": "Questa versione di %appName% non è supportata dal SYNC.", + "line1": "non supportata" + }, + "nl-nl": { + "tts": "Deze versie van %appName% wordt niet ondersteund door SYNC.", + "line1": "niet ondersteund" + }, + "pl-pl": { + "tts": "Niniejsza wersja %appName% nie jest obsługiwana przez system SYNC.", + "line1": "aplikacja nie obsług." + }, + "pt-br": { + "tts": "Esta versão do %appName% não é suportada pelo SYNC.", + "line1": "não suportado" + }, + "pt-pt": { + "tts": "Esta versão de %appName% não é suportado pelo SYNC.", + "line1": "não suportada" + }, + "ru-ru": { + "tts": "Эта версия %appName% не поддерживается SYNC.", + "line1": "не поддерживается" + }, + "sv-se": { + "tts": "SYNC har inte stöd för den här versionen av %appName%.", + "line1": "stöds ej" + }, + "tr-tr": { + "tts": "Bu %appName% sürümü SYNC tarafından desteklenmiyor.", + "line1": "desteklenmiyor" + }, + "zh-cn": { + "tts": "SYNC不支持此版本的%appName%。", + "line1": "不受支持" + }, + "zh-tw": { + "tts": "SYNC 不支援此版本的%appName% 。", + "line1": "不支援" + } + } + }, + "DataConsent": { + "languages": { + "en-gb": { + "textBody": "Would you like to enable Mobile Apps on SYNC? To use Mobile Apps with SYNC, SYNC will communicate with Ford at least once per month using your mobile device’s data plan. Standard rates may apply. SYNC will send your VIN and SYNC module number to Ford U.S. \r\n\r\nUpdates are about the size of an email, and the occurrence of updates depends on your vehicle usage and when a new app is found on your device. To turn on or off, visit the SYNC Settings menu. See your Owner Guide for more information." + }, + "en-us": { + "line1": "Enable Mobile Apps", + "line2": "on SYNC? (Uses Data)", + "textBody": "Would you like to enable Mobile Apps on SYNC?\r\n\r\nTo use Mobile Apps with SYNC, SYNC will communicate with Ford at least once per month using your mobile device’s data plan. Standard rates may apply. SYNC will send your VIN and SYNC module number to Ford U.S.\r\n\r\nUpdates are about the size of an email, and the occurrence of updates depends on your vehicle usage and when a new app is found on your device. To turn on or off, visit the SYNC Settings menu. See your Owner Guide for more information." + }, + "es-mx": { + "textBody": "Para usar aplicaciones móviles con SYNC, este debe comunicarse con Ford al menos una vez al mes a través del plan de datos de su dispositivo móvil. Pueden aplicar tarifas normales. SYNC enviará su VIN y el número de módulo de SYNC a Ford de Estados Unidos de América. \n\nLas actualizaciones tienen el tamaño aproximado de un mensaje de correo electrónico, y la frecuencia de las actualizaciones depende del uso de su vehículo y de si se encuentran nuevas aplicaciones en su dispositivo. Para obtener más información, consulte la Guía del propietario. \n\nPresione Sí para permitir y No para denegar." + }, + "fr-ca": { + "textBody": "Pour utiliser AppLink, SYNC devra communiquer avec Ford au moins une fois par mois en utilisant le forfait de données de votre appareil mobile. Les tarifs réguliers peuvent s’appliquer. SYNC enverra votre NIV et le numéro de votre module SYNC à Ford États-Unis. Les mises à jour ont la taille d’un courriel et la fréquence des mises à jour dépend de l’utilisation de votre véhicule et si une nouvelle application se trouve sur votre appareil. Consultez le Guide de l’utilisateur pour obtenir d’autres renseignements.\r\n\r\nVeuillez appuyer sur Oui pour autoriser ou sur Non pour refuser." + } + } + }, + "DataConsentHelp": { + "languages": { + "en-us": { + "textBody": "By enabling mobile apps, you consent to allowing SYNC to communicate with Ford at least once per month using your mobile device’s data plan. Disabling will stop all data usage, but you will not be able to use mobile apps on SYNC. See your Owner Guide for more information." + }, + "es-mx": { + "textBody": "Las actualizaciones tienen el tamaño aproximado de un mensaje de correo electrónico, y la frecuencia de las actualizaciones depende del uso de su vehículo y de si se encuentran nuevas aplicaciones en su dispositivo. Para obtener más información, consulte la Guía del propietario." + }, + "fr-ca": { + "textBody": "Les mises à jour ont la taille d’un courriel et la fréquence des mises à jour dépend de l’utilisation de votre véhicule et si une nouvelle application se trouve sur votre appareil. Consultez le Guide de l’utilisateur pour obtenir d’autres renseignements." + } + } + }, + "DisableApps": { + "languages": { + "de-de": { + "tts": "Ausschalten der automatischen Updates führt zum Ausschalten von SYNC mobile Apps. Sie können Ihre mobilen Apps dann nicht mehr mit SYNC nutzen. Bitte drücken Sie Ja zur Bestätigung oder Nein, um abzubrechen.", + "line1": "Auto-Update", + "line2": "und Mobile Apps deaktivieren" + }, + "en-au": { + "tts": "Disabling automatic updates will also disable SYNC mobile apps. You will not be able to use any mobile apps with SYNC. Please press Yes to confirm or No to cancel.", + "line1": "Disable auto-updates", + "line2": "and Mobile Apps?" + }, + "en-gb": { + "tts": "Disabling automatic updates will also disable SYNC mobile apps. You will not be able to use any mobile apps with SYNC. Please press Yes to confirm or No to cancel.", + "line1": "Disable auto-updates", + "line2": "and Mobile Apps?", + "textBody": "Disabling automatic updates will also disable SYNC mobile apps. You will not be able to use any mobile apps with SYNC. Please press Yes to confirm or No to cancel." + }, + "en-ie": { + "tts": "Disabling automatic updates will also disable SYNC mobile apps. You will not be able to use any mobile apps with SYNC. Please press Yes to confirm or No to cancel.", + "line1": "Disable auto-updates", + "line2": "and Mobile Apps?" + }, + "en-us": { + "tts": "Disabling automatic updates will also disable sync mobile apps. You will not be able to use any mobile apps with SYNC. Please press yes to confirm or no to cancel.", + "line1": "Disable Auto-Updates", + "line2": "and Mobile Apps?", + "textBody": "If you disable, you will not be able to use any mobile apps with SYNC and your vehicle will stop receiving mobile app permission updates via your device`s data plan. Please press yes to disable mobile apps or no to cancel." + }, + "es-en": { + "tts": "Si se desactivan las actualizaciones automáticas, también se desactivarán las aplicaciones móviles de SYNC. No podrá usar ninguna aplicación móvil con SYNC. Presione Sí para confirmar o No para cancelar.", + "line1": "¿Deshab. actualiz.", + "line2": "autom. y aplic. móv.?", + "textBody": "Si se desactivan las actualizaciones automáticas, también se desactivarán las aplicaciones móviles de SYNC. No podrá usar ninguna aplicación móvil con SYNC. Presione Sí para confirmar o No para cancelar." + }, + "es-es": { + "tts": "Si desactiva las actualizaciones automáticas, también se desactivará la sincronización de las aplicaciones móviles. No podrá utilizar ninguna aplicación móvil con SYNC. Pulse sí para confirmar o no para cancelar.", + "line1": "¿Desact. actual. auto", + "line2": "y apl. móviles?" + }, + "es-mx": { + "tts": "Si se desactivan las actualizaciones automáticas, también se desactivarán las aplicaciones móviles de SYNC. No podrá usar ninguna aplicación móvil con SYNC. Presione Sí para confirmar o No para cancelar.", + "line1": "¿Deshab. actualiz.", + "line2": "autom. y aplic. móv.?", + "textBody": "Si se desactivan las actualizaciones automáticas, también se desactivarán las aplicaciones móviles de SYNC. No podrá usar ninguna aplicación móvil con SYNC. Presione Sí para confirmar o No para cancelar." + }, + "fr-ca": { + "tts": "La désactivation des mises à jour automatiques désactivera aussi les applications mobiles SYNC. Vous ne pourrez pas utiliser d’application mobile avec SYNC. Veuillez appuyer sur Oui pour confirmer ou sur Non pour annuler.", + "line1": "Désactiver màj autom.", + "line2": "et app. mobiles?", + "textBody": "La désactivation des mises à jour automatiques désactivera aussi les applications mobiles SYNC. Vous ne pourrez pas utiliser d’application mobile avec SYNC. Veuillez appuyer sur Oui pour confirmer ou sur Non pour annuler." + }, + "fr-fr": { + "tts": "La désactivation des mises à jour automatiques désactivera aussi les applications mobiles SYNC. Vous ne pourrez pas utiliser d’application mobile avec SYNC. Veuillez appuyer sur Oui pour confirmer ou sur Non pour annuler.", + "line1": "Désactiver màj autom.", + "line2": "et app. mobiles?" + }, + "it-it": { + "tts": "Disabilitando gli aggiornamenti automatici si disattiva anche la sincronizzazione delle app mobili. Non sarà possibile usare app mobili con il SYNC. Premere Sì per confermare e No per cancellare.", + "line1": "Disabilitare agg. aut.", + "line2": "e app mobili?" + }, + "nl-nl": { + "tts": "Door automatische updates uit te schakelen, schakelt u ook SYNC-mobiele apps uit. U kunt dan geen mobiele apps meer gebruiken met SYNC. Druk op Ja om te bevestigen of op Nee om te annuleren.", + "line1": "Auto-updates en mob.", + "line2": "apps uitschakelen?" + }, + "pl-pl": { + "tts": "Wyłączenie automatycznych aktualizacji spowoduje także wyłączenie aplikacji mobilnych SYNC. Korzystanie z mobilnych aplikacji za pomocą SYNC będzie niemożliwe. Naciśnij TAK, by potwierdzić lub NIE, by anulować.", + "line1": "Wył. automat. aktual.", + "line2": "i aplikacje mobilne?" + }, + "pt-br": { + "tts": "Se as atualizações automáticas forem desativadas, os aplicativos também serão desativados. Você não poderá usar nenhum aplicativo com o SYNC. Pressione sim para confirmar ou não para cancelar.", + "line1": "Desativar atualizações", + "line2": "autom. e aplicativos?" + }, + "pt-pt": { + "tts": "A desactivação das actualizações automáticas desactiva igualmente as aplicações móveis do SYNC. Não poderá utilizar quaisquer aplicações móveis com o SYNC. Prima \"\"Sim\"\" para confirmar ou \"\"Não\"\" para cancelar.", + "line1": "Desact. actual. autom.", + "line2": "e aplicações móveis?" + }, + "ru-ru": { + "tts": "При отключении автоматических обновлений также будут отключены мобильные приложения sync. Вы не сможете использовать какие-либо мобильные приложения с SYNC. Нажмите \"\"Да\"\" для подтверждения или \"\"Нет\"\" для отмены.", + "line1": "Откл. автообновления", + "line2": "и мобил. прилож.?" + }, + "sv-se": { + "tts": "Om du avaktiverar automatisk uppdatering avaktiverar du även synkning av mobilappar. Du kommer inte längre att kunna använda dina mobilappar med SYNC. Tryck Ja för att bekräfta eller Nej för att avbryta.", + "line1": "Avaktiverar autouppdat.", + "line2": "och mobilappar?" + }, + "tr-tr": { + "tts": "Otomatik güncellemeleri devre dışı bırakırsanız sync mobil uygulamalar da devre dışı kalır. SYNC ile mobil uygulama kullanmanız mümkün olmaz. Lütfen onaylamak için Evet'e veya iptal etmek için Hayır'a basın.", + "line1": "Oto. güncelleme ve", + "line2": "mobil uygul. kapat?" + }, + "zh-cn": { + "tts": "禁用自动更新同时也会禁用SYNC移动应用程序。您将无法在 SYNC 中使用任何移动应用程序。请按“是”确认或按“否”取消。", + "line1": "是否禁用自动更新和", + "line2": "移动应用程序?" + }, + "zh-tw": { + "tts": "停用自動更新也將停用 sync 行動應用程式。您將無法透過 SYNC 使用任何行動應用程式。確認請按「是」,取消請按「否」。", + "line1": "停用自動更新", + "line2": "和行動應用程式?" + } + } + }, + "DrivingCharacteristics": { + "languages": { + "de-de": { + "tts": "Eine App hat Zugriff auf die folgenden Fahreigenschaften: Kraftstoffverbrauch, MyKey, Sicherheitsgurtstatus.", + "label": "Fahreigenschaften" + }, + "en-au": { + "tts": "An app can access the following driving characteristics: Fuel consumption, MyKey, Seat belt status.", + "label": "Driving characteristics" + }, + "en-gb": { + "tts": "An app can access the following driving characteristics: Fuel consumption, MyKey, Seat belt status.", + "label": "Driving characteristics", + "textBody": "An app can access the following driving characteristics: Fuel consumption, MyKey, Seat belt status." + }, + "en-ie": { + "tts": "An app can access the following driving characteristics: Fuel consumption, MyKey, Seat belt status.", + "label": "Driving characteristics" + }, + "en-us": { + "tts": "An app can access the following driving characteristics: Fuel Consumption, MyKey, Seat Belt Status.", + "label": "Driving Characteristics", + "textBody": "An app can access the following driving characteristics: Fuel Consumption, MyKey, Seat Belt Status." + }, + "es-en": { + "tts": "Las aplicaciones pueden acceder a las siguientes características del manejo: Consumo de combustible, MyKey, Estado del cinturón de seguridad.", + "label": "Características del manejo", + "textBody": "Las aplicaciones pueden acceder a las siguientes características del manejo: Consumo de combustible, MyKey, Estado del cinturón de seguridad." + }, + "es-es": { + "tts": "Una aplicación puede acceder a las siguientes características de conducción: Consumo de combustible, MyKey, Estado cinturones de seguridad.", + "label": "Características de conducción" + }, + "es-mx": { + "tts": "Las aplicaciones pueden acceder a las siguientes características del manejo: Consumo de combustible, MyKey, Estado del cinturón de seguridad.", + "label": "Características del manejo", + "textBody": "Las aplicaciones pueden acceder a las siguientes características del manejo: Consumo de combustible, MyKey, Estado del cinturón de seguridad." + }, + "fr-ca": { + "tts": "Une application peut accéder aux caractéristiques de conduite suivantes: Consommation de carburant, MyKey, État des ceintures de sécurité.", + "label": "Caractéristiques de conduite", + "textBody": "Une application peut accéder aux caractéristiques de conduite suivantes: Consommation de carburant, MyKey, État des ceintures de sécurité." + }, + "fr-fr": { + "tts": "Une application peut accéder aux caractéristiques de conduite suivantes: Consommation de carburant, MyKey, État des ceintures de sécurité.", + "label": "Caractéristiques de conduite" + }, + "it-it": { + "tts": "Un'app può avere accesso alle seguenti caratteristiche di guida: Consumo carburante, MyKey, Stato cinture di sicurezza.", + "label": "Caratteristiche di guida" + }, + "nl-nl": { + "tts": "Een app heeft toegang tot de volgende rijkenmerken: Brandstofverbruik, MyKey, Veiligheidsgordelstatus.", + "label": "Rijkenmerken" + }, + "pl-pl": { + "tts": "Aplikacja może uzyskać dostęp do następujących informacji dotyczących jazdy: Zużycie paliwa, MyKey, Stan pasów bezpieczeństwa.", + "label": "Informacje dotyczące stylu jazdy" + }, + "pt-br": { + "tts": "Um aplicativo pode acessar as seguintes características de condução: Consumo de combustível, MyKey, Estado do cinto de segurança.", + "label": "Características de condução" + }, + "pt-pt": { + "tts": "Uma aplicação consegue aceder às seguintes informações de condução: Consumo de combustível, MyKey, Estado dos cintos de segurança.", + "label": "Características de condução" + }, + "ru-ru": { + "tts": "Приложение имеет доступ к следующим характеристикам движения: Расход топлива, MyKey, Состояние ремней безопасности.", + "label": "Характеристики движения" + }, + "sv-se": { + "tts": "Appen kan komma åt följande köregenskaper: Bränsleförbrukning, MyKey, Bältesstatus.", + "label": "Köregenskaper" + }, + "tr-tr": { + "tts": "Bir uygulama şu sürüş karakteristiklerine erişebilir: Yakıt tüketimi, MyKey, Emniyet kemeri durumu.", + "label": "Sürüş karakteristikleri" + }, + "zh-cn": { + "tts": "移动应用程序可访问下列行驶特性: 油耗, MyKey, 安全带状态", + "label": "行驶特性" + }, + "zh-tw": { + "tts": "應用程式可存取以下駕駛特性: 油耗, MyKey, 安全帶狀態", + "label": "駕駛特性" + } + } + }, + "Location": { + "languages": { + "de-de": { + "tts": "Eine App hat Zugriff auf die GPS-Daten und die Geschwindigkeit des Fahrzeugs.", + "label": "GPS und Geschwindigkeit" + }, + "en-au": { + "tts": "An app can access vehicle GPS and speed.", + "label": "GPS and speed" + }, + "en-gb": { + "tts": "An app can access vehicle GPS and speed.", + "label": "GPS and speed", + "textBody": "An app can access vehicle GPS and speed." + }, + "en-ie": { + "tts": "An app can access vehicle GPS and speed.", + "label": "GPS and speed" + }, + "en-us": { + "tts": "An app can access vehicle GPS and speed.", + "label": "GPS and speed", + "textBody": "An app can access vehicle GPS and speed." + }, + "es-en": { + "tts": "Las aplicaciones pueden acceder al GPS y a la velocidad del vehículo.", + "label": "GPS y velocidad", + "textBody": "Las aplicaciones pueden acceder al GPS y a la velocidad del vehículo." + }, + "es-es": { + "tts": "Una aplicación puede acceder al GPS y la velocidad del vehículo.", + "label": "GPS y velocidad" + }, + "es-mx": { + "tts": "Las aplicaciones pueden acceder al GPS y a la velocidad del vehículo.", + "label": "GPS y velocidad", + "textBody": "Las aplicaciones pueden acceder al GPS y a la velocidad del vehículo." + }, + "fr-ca": { + "tts": "Une application peut accéder au GPS et à la vitesse du véhicule.", + "label": "GPS et vitesse", + "textBody": "Une application peut accéder au GPS et à la vitesse du véhicule." + }, + "fr-fr": { + "tts": "Une application peut accéder au GPS et à la vitesse du véhicule.", + "label": "GPS et vitesse" + }, + "it-it": { + "tts": "Un'app può avere accesso a GPS e velocità del veicolo.", + "label": "GPS e velocità" + }, + "nl-nl": { + "tts": "Een app heeft toegang tot gps en de snelheid van het voertuig.", + "label": "Gps en snelheid" + }, + "pl-pl": { + "tts": "Aplikacja może uzyskać dostęp do modułu GPS i prędkości pojazdu.", + "label": "GPS i prędkość" + }, + "pt-br": { + "tts": "Um aplicativo pode acessar o GPS e a velocidade do veículo.", + "label": "GPS e velocidade" + }, + "pt-pt": { + "tts": "Uma aplicação consegue aceder ao GPS e à velocidade do veículo.", + "label": "GPS e velocidade" + }, + "ru-ru": { + "tts": "Приложение имеет доступ к GPS и скорости автомобиля.", + "label": "GPS и скорость" + }, + "sv-se": { + "tts": "Appen kan komma åt fordonets GPS och hastighetsmätare.", + "label": "GPS och hastighet" + }, + "tr-tr": { + "tts": "Bu uygulama aracın GPS ve hız bilgilerine erişebilir.", + "label": "GPS ve hız" + }, + "zh-cn": { + "tts": "移动应用程序可以访问车辆 GPS 和车速信息。", + "label": "GPS 和车速" + }, + "zh-tw": { + "tts": "應用程式可存取車輛的GPS和速度。", + "label": "GPS和車速" + } + } + }, + "LockScreenDismissalWarning": { + "languages": { + "en-us": { + "textBody": "Swipe down to dismiss, acknowledging that you are not the driver" + } + } + }, + "Notifications": { + "languages": { + "de-de": { + "tts": "Läuft die App im Hintergrund, kann Sie Benachrichtigungen senden.", + "label": "Push-Benachrichtigungen" + }, + "en-au": { + "tts": "An app can send notifications when running in the background.", + "label": "Push notifications" + }, + "en-gb": { + "tts": "An app can send notifications when running in the background.", + "label": "Push notifications", + "textBody": "An app can send notifications when running in the background." + }, + "en-ie": { + "tts": "An app can send notifications when running in the background.", + "label": "Push notifications" + }, + "en-us": { + "tts": "An app can send notifications when running in the background.", + "label": "Push notifications", + "textBody": "An app can send notifications when running in the background." + }, + "es-en": { + "tts": "Las aplicaciones pueden enviar notificaciones cuando se ejecutan en segundo plano.", + "label": "Notificaciones tipo Push", + "textBody": "Las aplicaciones pueden enviar notificaciones cuando se ejecutan en segundo plano." + }, + "es-es": { + "tts": "Una aplicación puede enviar notificaciones cuando se está ejecutando en segundo plano.", + "label": "Notificaciones push" + }, + "es-mx": { + "tts": "Las aplicaciones pueden enviar notificaciones cuando se ejecutan en segundo plano.", + "label": "Notificaciones tipo Push", + "textBody": "Las aplicaciones pueden enviar notificaciones cuando se ejecutan en segundo plano." + }, + "fr-ca": { + "tts": "Une application peut envoyer des avis lorsqu’elle fonctionne en arrière-plan.", + "label": "Notifications instantanées", + "textBody": "Une application peut envoyer des avis lorsqu’elle fonctionne en arrière-plan." + }, + "fr-fr": { + "tts": "Une application peut envoyer des avis lorsqu’elle fonctionne en arrière-plan.", + "label": "Notifications push" + }, + "it-it": { + "tts": "Un'app può inviare notifiche se eseguita in background.", + "label": "Notifiche push" + }, + "nl-nl": { + "tts": "Een app kan meldingen versturen als deze op de achtergrond actief is.", + "label": "Push-meldingen" + }, + "pl-pl": { + "tts": "Aplikacja może wysyłać powiadomienia, działając w tle.", + "label": "Powiadomienia Push" + }, + "pt-br": { + "tts": "Um aplicativo pode enviar notificações quando estiver sendo executado em segundo plano.", + "label": "Notificações Push" + }, + "pt-pt": { + "tts": "Uma aplicação consegue enviar notificações quando está activa em segundo plano.", + "label": "Notificações push" + }, + "ru-ru": { + "tts": "Если приложение работает в фоновом режиме, оно может отправлять оповещения.", + "label": "Оповещения о пересылке" + }, + "sv-se": { + "tts": "Appen kan skicka meddelanden när den körs i bakgrunden.", + "label": "Push-notiser" + }, + "tr-tr": { + "tts": "Bir uygulama arka planda çalışırken bildirim gönderebilir.", + "label": "Anlık bildirimleri" + }, + "zh-cn": { + "tts": "移动应用程序在后台运行时可推送通知。", + "label": "推送通知" + }, + "zh-tw": { + "tts": "車輛行進時,應用程式可在背景中傳送通知。", + "label": "傳送通知" + } + } + }, + "SettingDisableUpdates": { + "languages": { + "de-de": { + "line1": "Updates deakt." + }, + "en-au": { + "line1": "Disable updates" + }, + "en-gb": { + "line1": "Disable updates" + }, + "en-ie": { + "line1": "Disable updates" + }, + "en-us": { + "line1": "Disable Updates", + "textBody": "Disable Updates" + }, + "es-en": { + "line1": "Deshab. actual.", + "textBody": "Deshab. actual." + }, + "es-es": { + "line1": "Desact. actual." + }, + "es-mx": { + "line1": "Deshab. actual.", + "textBody": "Deshab. actual." + }, + "fr-ca": { + "line1": "Désactiver MAJ", + "textBody": "Désactiver MAJ" + }, + "fr-fr": { + "line1": "Désactiver màj" + }, + "it-it": { + "line1": "Disabilita agg." + }, + "nl-nl": { + "line1": "Upd. uitschak." + }, + "pl-pl": { + "line1": "Wyłącz aktual." + }, + "pt-br": { + "line1": "Desat. atualiz." + }, + "pt-pt": { + "line1": "Desact. actualiz." + }, + "ru-ru": { + "line1": "Откл. обновл." + }, + "sv-se": { + "line1": "Inaktivera uppd." + }, + "tr-tr": { + "line1": "Güncell. Kapat" + }, + "zh-cn": { + "line1": "禁用更新" + }, + "zh-tw": { + "line1": "停用更新" + } + } + }, + "SettingEnableUpdates": { + "languages": { + "de-de": { + "line1": "Apps aktivieren" + }, + "en-au": { + "line1": "Enable Apps" + }, + "en-gb": { + "line1": "Enable Apps" + }, + "en-ie": { + "line1": "Enable Apps" + }, + "en-us": { + "line1": "Enable Apps" + }, + "es-en": { + "line1": "Hab. aplic." + }, + "es-es": { + "line1": "Activar apl." + }, + "es-mx": { + "line1": "Hab. aplic." + }, + "fr-ca": { + "line1": "Activer app.", + "textBody": "Activer app." + }, + "fr-fr": { + "line1": "Activer app." + }, + "it-it": { + "line1": "Abilita app" + }, + "nl-nl": { + "line1": "Apps inschak." + }, + "pl-pl": { + "line1": "Włącz aplikacje" + }, + "pt-br": { + "line1": "Ativar aplic." + }, + "pt-pt": { + "line1": "Activar actualiz." + }, + "ru-ru": { + "line1": "Вкл. прилож." + }, + "sv-se": { + "line1": "Aktivera appar" + }, + "tr-tr": { + "line1": "Uygulamaları aç" + }, + "zh-cn": { + "line1": "启用应用程序" + }, + "zh-tw": { + "line1": "啟用應用程式" + } + } + }, + "SettingUpdateAuto": { + "languages": { + "de-de": { + "line1": "Update anford." + }, + "en-au": { + "line1": "Request update" + }, + "en-gb": { + "line1": "Request update" + }, + "en-ie": { + "line1": "Request update" + }, + "en-us": { + "line1": "Request Update", + "textBody": "Select `Update now` to receive app permissions for your SYNC-enabled mobile apps. This may enable additional functionality depending on the app and your settings. If your phone has a working data connection, an update should complete in less than 1 minute." + }, + "es-en": { + "line1": "Solicit. actualiz.", + "textBody": "Solicit. actualiz." + }, + "es-es": { + "line1": "Solicitar actual." + }, + "es-mx": { + "line1": "Solicit. actualiz.", + "textBody": "Solicit. actualiz." + }, + "fr-ca": { + "line1": "Demander MAJ", + "textBody": "Demander MAJ" + }, + "fr-fr": { + "line1": "Demander màj" + }, + "it-it": { + "line1": "Rich. aggiorn." + }, + "nl-nl": { + "line1": "Upd. aanvragen" + }, + "pl-pl": { + "line1": "Zażądaj aktual." + }, + "pt-br": { + "line1": "Solicitar atualiz." + }, + "pt-pt": { + "line1": "Solicit. actualiz." + }, + "ru-ru": { + "line1": "Запрос на обн." + }, + "sv-se": { + "line1": "Begär uppdat." + }, + "tr-tr": { + "line1": "Güncelleme iste" + }, + "zh-cn": { + "line1": "请求更新" + }, + "zh-tw": { + "line1": "請求更新" + } + } + }, + "StatusNeeded": { + "languages": { + "de-de": { + "line1": "Update benötigt" + }, + "en-au": { + "line1": "Update needed" + }, + "en-gb": { + "line1": "Update needed", + "textBody": "Update needed" + }, + "en-ie": { + "line1": "Update needed" + }, + "en-us": { + "line1": "Update Needed", + "textBody": "Update Needed" + }, + "es-en": { + "line1": "Actualiz. neces.", + "textBody": "Actualiz. neces." + }, + "es-es": { + "line1": "Actu. necesaria" + }, + "es-mx": { + "line1": "Actualiz. neces.", + "textBody": "Actualiz. neces." + }, + "fr-ca": { + "line1": "Màj requise", + "textBody": "Màj requise" + }, + "fr-fr": { + "line1": "Mise à jour requise" + }, + "it-it": { + "line1": "Necess. aggiorn." + }, + "nl-nl": { + "line1": "Update nodig" + }, + "pl-pl": { + "line1": "Potrzeba aktual." + }, + "pt-br": { + "line1": "Atualiz. necess." + }, + "pt-pt": { + "line1": "Actual. necess." + }, + "ru-ru": { + "line1": "Необх. обновл." + }, + "sv-se": { + "line1": "Uppdat. krävs" + }, + "tr-tr": { + "line1": "Güncellenmeli" + }, + "zh-cn": { + "line1": "需要进行更新" + }, + "zh-tw": { + "line1": "需更新" + } + } + }, + "StatusPending": { + "languages": { + "de-de": { + "line1": "Aktualisieren..." + }, + "en-au": { + "line1": "Updating..." + }, + "en-gb": { + "line1": "Updating...", + "textBody": "Updating..." + }, + "en-ie": { + "line1": "Updating..." + }, + "en-us": { + "line1": "Updating...", + "textBody": "Updating..." + }, + "es-en": { + "line1": "Actualizando...", + "textBody": "Actualizando..." + }, + "es-es": { + "line1": "Actualizando..." + }, + "es-mx": { + "line1": "Actualizando...", + "textBody": "Actualizando..." + }, + "fr-ca": { + "line1": "MAJ en cours...", + "textBody": "MAJ en cours..." + }, + "fr-fr": { + "line1": "Màj en cours..." + }, + "it-it": { + "line1": "Aggiornamento" + }, + "nl-nl": { + "line1": "Updaten..." + }, + "pl-pl": { + "line1": "Aktualizowanie" + }, + "pt-br": { + "line1": "Atualizando..." + }, + "pt-pt": { + "line1": "A actualizar..." + }, + "ru-ru": { + "line1": "Обновление..." + }, + "sv-se": { + "line1": "Uppdaterar..." + }, + "tr-tr": { + "line1": "Güncelleniyor..." + }, + "zh-cn": { + "line1": "正在更新......" + }, + "zh-tw": { + "line1": "更新中..." + } + } + }, + "StatusUpToDate": { + "languages": { + "de-de": { + "line1": "Aktuelle Version" + }, + "en-au": { + "line1": "Up-to-date" + }, + "en-gb": { + "line1": "Up-to-date", + "textBody": "Up-to-date" + }, + "en-ie": { + "line1": "Up-to-date" + }, + "en-us": { + "line1": "Up-To-Date", + "textBody": "Up-To-Date" + }, + "es-en": { + "line1": "Actualizado", + "textBody": "Actualizado" + }, + "es-es": { + "line1": "Actualizada" + }, + "es-mx": { + "line1": "Actualizado", + "textBody": "Actualizado" + }, + "fr-ca": { + "line1": "Déjà à jour", + "textBody": "Déjà à jour" + }, + "fr-fr": { + "line1": "Déjà à jour" + }, + "it-it": { + "line1": "più recente" + }, + "nl-nl": { + "line1": "Up-to-date" + }, + "pl-pl": { + "line1": "Aktualne" + }, + "pt-br": { + "line1": "Atualizado" + }, + "pt-pt": { + "line1": "Actualizado" + }, + "ru-ru": { + "line1": "Обновлено" + }, + "sv-se": { + "line1": "Uppdat. krävs ej" + }, + "tr-tr": { + "line1": "Güncel" + }, + "zh-cn": { + "line1": "最新更新" + }, + "zh-tw": { + "line1": "更新最新" + } + } + }, + "VehicleInfo": { + "languages": { + "de-de": { + "tts": "Eine App hat Zugriff auf die folgenden Fahrzeuginformationen: Kraftstoff-Füllstand, Kraftstoffverbrauch, Motordrehzahl, Kilometerzähler, FIN, Außentemperatur, Gangstellung, Reifenluftdruck.", + "label": "Fahrzeuginformationen" + }, + "en-au": { + "tts": "An app can access the following vehicle information: Fuel level, Fuel economy, Engine RPMs, Odometer, VIN, Outside air temperature, Gear position, Tyre pressure.", + "label": "Vehicle information" + }, + "en-gb": { + "tts": "An app can access the following vehicle information: Fuel level, Fuel economy, Engine RPMs, Odometer, VIN, Outside air temperature, Gear position, Tire pressure.", + "label": "Vehicle information", + "textBody": "An app can access the following vehicle information: Fuel level, Fuel economy, Engine RPMs, Odometer, VIN, Outside air temperature, Gear position, Tire pressure." + }, + "en-ie": { + "tts": "An app can access the following vehicle information: Fuel level, Fuel economy, Engine RPMs, Odometer, VIN, Outside air temperature, Gear position, Tyre pressure.", + "label": "Vehicle information" + }, + "en-us": { + "tts": "An app can access the following vehicle information: Fuel Level, Fuel Economy, Engine RPMs, Odometer, VIN, External Temperature, Gear Position, Tire Pressure.", + "label": "Vehicle information", + "textBody": "An app can access the following vehicle information: Fuel Level, Fuel Economy, Engine RPMs, Odometer, VIN, External Temperature, Gear Position, Tire Pressure." + }, + "es-en": { + "tts": "Las aplicaciones pueden acceder a la siguiente información del vehículo: Nivel de combustible, Economía de combustible, RPM del motor, Cuentakilómetros, Número de identificación del vehículo, Temperatura externa, Posición del cambio, Presión de los neumáticos.", + "label": "Información del vehículo", + "textBody": "Las aplicaciones pueden acceder a la siguiente información del vehículo: Nivel de combustible, Economía de combustible, RPM del motor, Cuentakilómetros, Número de identificación del vehículo, Temperatura externa, Posición del cambio, Presión de los neumáticos." + }, + "es-es": { + "tts": "Una aplicación puede acceder a la siguiente información del vehículo: Nivel de combustible, Ahorro de combustible, RPM del motor, Cuentakilómetros, VIN, Temperatura aire exterior, Marcha engranada, Presión de neumáticos.", + "label": "Información del vehículo" + }, + "es-mx": { + "tts": "Las aplicaciones pueden acceder a la siguiente información del vehículo: Nivel de combustible, Economía de combustible, RPM del motor, Cuentakilómetros, Número de identificación del vehículo, Temperatura externa, Posición del cambio, Presión de los neumáticos.", + "label": "Información del vehículo", + "textBody": "Las aplicaciones pueden acceder a la siguiente información del vehículo: Nivel de combustible, Economía de combustible, RPM del motor, Cuentakilómetros, Número de identificación del vehículo, Temperatura externa, Posición del cambio, Presión de los neumáticos." + }, + "fr-ca": { + "tts": "Une application peut accéder aux informations suivantes du véhicule: Niveau de carburant, Économie de carburant, Au régime du moteur, Odomètre, NIV, Température extérieure, Position d’embrayage, Pression des pneus.", + "label": "Renseignements du véhicule", + "textBody": "Une application peut accéder aux informations suivantes du véhicule: Niveau de carburant, Économie de carburant, Au régime du moteur, Odomètre, NIV, Température extérieure, Position d’embrayage, Pression des pneus." + }, + "fr-fr": { + "tts": "Une application peut accéder aux informations suivantes du véhicule: Niveau de carburant, Économie de carburant, Vitesse de moteur, Compteur kilométrique, NIV, Température extérieure, Position de vitesse, Pression des pneus.", + "label": "Renseignements du véhicule" + }, + "it-it": { + "tts": "Un'app può avere accesso alle seguenti informazioni del veicolo: Livello carburante, Consumi carburante, Numero giri motore, Contachilometri, VIN, Temperatura esterna, Posizione marcia, Pressione pneumatici.", + "label": "Informazioni sul veicolo" + }, + "nl-nl": { + "tts": "Een app heeft toegang tot de volgende voertuiginformatie: Brandstofpeil, Brandstofverbruik, Motortoerental, Kilometerteller, VIN, Buitentemperatuur, Versnellingsstand, Bandenspanning.", + "label": "Voertuiginformatie" + }, + "pl-pl": { + "tts": "Aplikacja może uzyskać dostęp do następujących informacji o pojeździe: Poziom paliwa, Zużycie paliwa, Obroty silnika, Licznik przebiegu, Numer VIN, Temperatura zewnętrzna, Aktualny bieg, Ciśnienie opon.", + "label": "Informacje o pojeździe" + }, + "pt-br": { + "tts": "Um aplicativo pode acessar as seguintes informações sobre o veículo: Nível de combustível, Economia de combustível, RPM do motor, Hodômetro, VIN, Temperatura externa, Posição das marchas, Pressão dos pneus.", + "label": "Informações sobre o veículo" + }, + "pt-pt": { + "tts": "Uma aplicação consegue aceder às seguintes informações do veículo: Nível de combustível, Poupança de combustível, RPM do motor, Conta-quilómetros, VIN, Temperatura exterior, Posição da mudança de velocidade, Pressão dos pneus.", + "label": "Informações do veículo" + }, + "ru-ru": { + "tts": "Приложение имеет доступ к следующим данным автомобиля: Уровень топлива, Економия топлива, Число оборотов двигателя, Одометр, Номер VIN, Температура за бортом, Положение передачи, Давление шин.", + "label": "Информация об автомобиле" + }, + "sv-se": { + "tts": "Appen kan komma åt följande fordonsinformation: Bränslenivå, Bränsleekonomi, Motorns varvtal, Vägmätare, VIN, Utetemperatur, Växelläge, Däcktryck.", + "label": "Fordonsinformation" + }, + "tr-tr": { + "tts": "Bir uygulama şu araç bilgilerine erişebilir: Yakıt seviyesi, Yakıt ekonomisi, Motor devirleri, Kilometre sayacı, VIN, Dış sıcaklık, Vites konumu, Lastik basıncı.", + "label": "Araç bilgisi" + }, + "zh-cn": { + "tts": "移动应用程序可访问下列车辆信息 : 燃油量, 燃油经济性, 发动机转速(RPM), 里程表, VIN, 车外温度, 档位, 胎压.", + "label": "车辆信息" + }, + "zh-tw": { + "tts": "一個應用程式可存取以下車輛資訊 : 燃油存量, 燃油經濟性, 引擎轉速, 里程表, 車輛識別號碼, 車外溫度, 檔位, 胎壓.", + "label": "車輛資訊" + } + } + } + } + }, + "app_policies": { + "default": { + "keep_context": false, + "steal_focus": false, + "priority": "NONE", + "default_hmi": "NONE", + "groups": [ + "Base-4" + ], + "RequestType": [], + "RequestSubType": [] + }, + "device": { + "keep_context": false, + "steal_focus": false, + "priority": "NONE", + "default_hmi": "NONE", + "groups": [ + "DataConsent-2" + ] + }, + "pre_DataConsent": { + "keep_context": false, + "steal_focus": false, + "priority": "NONE", + "default_hmi": "NONE", + "groups": [ + "BaseBeforeDataConsent" + ] + } + }, + "vehicle_data": { + "schema_version": "0.0.0", + "schema_items": [ + { + "name": "gps", + "params": [ + { + "name": "longitudeDegrees", + "key": "OEM_REF_LONG_DEG", + "type": "Float", + "mandatory": true, + "minvalue": -180, + "maxvalue": 180 + }, + { + "name": "latitudeDegrees", + "key": "OEM_REF_LAT_DEG", + "type": "Float", + "mandatory": true, + "minvalue": -90, + "maxvalue": 90 + }, + { + "name": "utcYear", + "key": "OEM_REF_UTC_YEAR", + "type": "Integer", + "mandatory": false, + "minvalue": 2010, + "maxvalue": 2100, + "since": "5.0" + }, + { + "name": "utcYear", + "key": "OEM_REF_UTC_YEAR", + "type": "Integer", + "mandatory": true, + "minvalue": 2010, + "maxvalue": 2100, + "since": "2.0", + "until": "5.0" + }, + { + "name": "utcMonth", + "key": "OEM_REF_UTC_MONTH", + "type": "Integer", + "mandatory": false, + "minvalue": 1, + "maxvalue": 12, + "since": "5.0" + }, + { + "name": "utcMonth", + "key": "OEM_REF_UTC_MONTH", + "type": "Integer", + "mandatory": true, + "minvalue": 1, + "maxvalue": 12, + "since": "2.0", + "until": "5.0" + }, + { + "name": "utcDay", + "key": "OEM_REF_UTC_DAY", + "type": "Integer", + "mandatory": false, + "minvalue": 1, + "maxvalue": 31, + "since": "5.0" + }, + { + "name": "utcDay", + "key": "OEM_REF_UTC_DAY", + "type": "Integer", + "mandatory": true, + "minvalue": 1, + "maxvalue": 31, + "since": "2.0", + "until": "5.0" + }, + { + "name": "utcHours", + "key": "OEM_REF_UTC_HOURS", + "type": "Integer", + "mandatory": false, + "minvalue": 0, + "maxvalue": 23, + "since": "5.0" + }, + { + "name": "utcHours", + "key": "OEM_REF_UTC_HOURS", + "type": "Integer", + "mandatory": true, + "minvalue": 0, + "maxvalue": 23, + "since": "2.0", + "until": "5.0" + }, + { + "name": "utcMinutes", + "key": "OEM_REF_UTC_MIN", + "type": "Integer", + "mandatory": false, + "minvalue": 0, + "maxvalue": 59, + "since": "5.0" + }, + { + "name": "utcMinutes", + "key": "OEM_REF_UTC_MIN", + "type": "Integer", + "mandatory": true, + "minvalue": 0, + "maxvalue": 59, + "since": "2.0", + "until": "5.0" + }, + { + "name": "utcSeconds", + "key": "OEM_REF_UTC_SEC", + "type": "Integer", + "mandatory": false, + "minvalue": 0, + "maxvalue": 59, + "since": "5.0" + }, + { + "name": "utcSeconds", + "key": "OEM_REF_UTC_SEC", + "type": "Integer", + "mandatory": true, + "minvalue": 0, + "maxvalue": 59, + "since": "2.0", + "until": "5.0" + }, + { + "name": "compassDirection", + "key": "OEM_REF_COM_DIR", + "type": "CompassDirection", + "mandatory": false, + "since": "5.0" + }, + { + "name": "compassDirection", + "key": "OEM_REF_COM_DIR", + "type": "CompassDirection", + "mandatory": true, + "since": "2.0", + "until": "5.0" + }, + { + "name": "pdop", + "key": "OEM_REF_PDOP", + "type": "Float", + "mandatory": false, + "minvalue": 0, + "maxvalue": 1000, + "since": "5.0" + }, + { + "name": "pdop", + "key": "OEM_REF_PDOP", + "type": "Float", + "mandatory": true, + "minvalue": 0, + "maxvalue": 10, + "since": "2.0", + "until": "5.0" + }, + { + "name": "hdop", + "key": "OEM_REF_HDOP", + "type": "Float", + "mandatory": true, + "minvalue": 0, + "maxvalue": 1000, + "since": "2.0", + "until": "5.0" + }, + { + "name": "hdop", + "key": "OEM_REF_HDOP", + "type": "Float", + "mandatory": false, + "minvalue": 0, + "maxvalue": 1000, + "since": "5.0" + }, + { + "name": "vdop", + "key": "OEM_REF_VDOP", + "type": "Float", + "mandatory": false, + "minvalue": 0, + "maxvalue": 10, + "since": "5.0" + }, + { + "name": "vdop", + "key": "OEM_REF_VDOP", + "type": "Float", + "mandatory": true, + "minvalue": 0, + "maxvalue": 10, + "since": "2.0", + "until": "5.0" + }, + { + "name": "actual", + "key": "OEM_REF_ACT", + "type": "Boolean", + "mandatory": false, + "since": "5.0" + }, + { + "name": "actual", + "key": "OEM_REF_ACT", + "type": "Boolean", + "mandatory": true, + "since": "2.0", + "until": "5.0" + }, + { + "name": "satellites", + "key": "OEM_REF_SAT", + "type": "Integer", + "mandatory": false, + "minvalue": 0, + "maxvalue": 31, + "until": "5.0" + }, + { + "name": "satellites", + "key": "OEM_REF_SAT", + "type": "Integer", + "mandatory": true, + "minvalue": 0, + "maxvalue": 31, + "since": "2.0", + "until": "5.0" + }, + { + "name": "dimension", + "key": "OEM_REF_DIM", + "type": "Dimension", + "mandatory": false, + "since": "5.0" + }, + { + "name": "dimension", + "key": "OEM_REF_DIM", + "type": "Dimension", + "mandatory": true, + "since": "2.0", + "until": "5.0" + }, + { + "name": "altitude", + "key": "OEM_REF_ALT", + "type": "Float", + "mandatory": false, + "minvalue": -10000, + "maxvalue": 10000, + "since": "5.0" + }, + { + "name": "altitude", + "key": "OEM_REF_ALT", + "type": "Float", + "mandatory": true, + "minvalue": -10000, + "maxvalue": 10000, + "since": "2.0", + "until": "5.0" + }, + { + "name": "heading", + "key": "OEM_REF_HEAD", + "type": "Float", + "mandatory": false, + "minvalue": 0, + "maxvalue": 359.99, + "until": "5.0" + }, + { + "name": "heading", + "key": "OEM_REF_HEAD", + "type": "Float", + "mandatory": true, + "minvalue": 0, + "maxvalue": 359.99, + "since": "2.0", + "until": "5.0" + }, + { + "name": "speed", + "key": "OEM_REF_GPS_SPEED", + "type": "Float", + "mandatory": false, + "minvalue": 0, + "maxvalue": 500, + "until": "5.0" + }, + { + "name": "speed", + "key": "OEM_REF_GPS_SPEED", + "type": "Float", + "mandatory": true, + "minvalue": 0, + "maxvalue": 500, + "since": "2.0", + "until": "5.0" + }, + { + "name": "shifted", + "key": "OEM_REF_SHIFT", + "type": "Boolean", + "mandatory": false, + "minvalue": 0, + "maxvalue": 500, + "since": "6.0" + } + ], + "key": "OEM_REF_GPS", + "type": "Struct", + "mandatory": false + }, + { + "name": "speed", + "key": "OEM_REF_SPEED", + "type": "Float", + "mandatory": false, + "minvalue": 0, + "maxvalue": 700 + }, + { + "name": "rpm", + "key": "OEM_REF_RPM", + "type": "Integer", + "mandatory": false, + "minvalue": 0, + "maxvalue": 20000 + }, + { + "name": "fuelLevel", + "key": "OEM_REF_FUEL_LEV", + "type": "Float", + "mandatory": false, + "minvalue": -6, + "maxvalue": 106 + }, + { + "name": "fuelLevel_State", + "key": "OEM_REF_FUEL_LEV_ST", + "type": "ComponentVolumeStatus", + "mandatory": false + }, + { + "name": "instantFuelConsumption", + "key": "OEM_REF_INS_FUEL_CON", + "type": "Float", + "mandatory": false, + "minvalue": 0, + "maxvalue": 25575 + }, + { + "name": "fuelRange", + "params": [ + { + "name": "type", + "key": "OEM_REF_FUEL_RAN_TYPE", + "type": "Float", + "mandatory": false, + "minvalue": 0, + "maxvalue": 10000 + }, + { + "name": "range", + "key": "OEM_REF_FUEL_RAN_RANG", + "type": "FuelType", + "mandatory": false + } + ], + "key": "OEM_REF_FUEL_RAN", + "array": true, + "type": "Struct", + "mandatory": false, + "minsize": 0, + "maxsize": 100, + "since": "5.0" + }, + { + "name": "externalTemperature", + "key": "OEM_REF_EXT_TEMP", + "type": "Float", + "mandatory": false, + "minvalue": -40, + "maxvalue": 100 + }, + { + "name": "turnSignal", + "key": "OEM_REF_TURN_SIGN", + "type": "TurnSignal", + "mandatory": false, + "since": "5.0" + }, + { + "name": "vin", + "key": "OEM_REF_VIN", + "type": "String", + "mandatory": false, + "maxlength": 17, + "since": "5.0" + }, + { + "name": "prndl", + "key": "OEM_REF_PRNDL", + "type": "PRNDL", + "mandatory": false + }, + { + "name": "tirePressure", + "params": [ + { + "name": "pressureTelltale", + "key": "OEM_REF_PRES_TEL", + "type": "WarningLightStatus", + "mandatory": true + }, + { + "name": "leftFront", + "params": [ + { + "name": "status", + "key": "OEM_REF_LEFT_FR_ST", + "type": "ComponentVolumeStatus", + "mandatory": true + }, + { + "name": "tpms", + "key": "OEM_REF_LEFT_FR_TMPS", + "type": "TPMS", + "mandatory": false, + "since": "5.0" + }, + { + "name": "pressure", + "key": "OEM_REF_LEFT_FR_PRES", + "type": "Float", + "mandatory": false, + "minvalue": 0, + "maxvalue": 2000, + "since": "5.0" + } + ], + "key": "OEM_REF_LEFT_FR", + "type": "Struct", + "mandatory": true + }, + { + "name": "rightFront", + "params": [ + { + "name": "status", + "key": "OEM_REF_RIGHT_FR_ST", + "type": "ComponentVolumeStatus", + "mandatory": true + }, + { + "name": "tpms", + "key": "OEM_REF_RIGHT_FR_TMPS", + "type": "TPMS", + "mandatory": false, + "since": "5.0" + }, + { + "name": "pressure", + "key": "OEM_REF_RIGHT_FR_PRES", + "type": "Float", + "mandatory": false, + "minvalue": 0, + "maxvalue": 2000, + "since": "5.0" + } + ], + "key": "OEM_REF_RIGHT_FR", + "type": "Struct", + "mandatory": true + }, + { + "name": "leftRear", + "params": [ + { + "name": "status", + "key": "OEM_REF_LEFT_REAR_ST", + "type": "ComponentVolumeStatus", + "mandatory": true + }, + { + "name": "tpms", + "key": "OEM_REF_LEFT_REAR_TMPS", + "type": "TPMS", + "mandatory": false, + "since": "5.0" + }, + { + "name": "pressure", + "key": "OEM_REF_LEFT_REAR_PRES", + "type": "Float", + "mandatory": false, + "minvalue": 0, + "maxvalue": 2000, + "since": "5.0" + } + ], + "key": "OEM_REF_LEFT_REAR", + "type": "Struct", + "mandatory": true + }, + { + "name": "rightRear", + "params": [ + { + "name": "status", + "key": "OEM_REF_RIGHT_REAR_ST", + "type": "ComponentVolumeStatus", + "mandatory": true + }, + { + "name": "tpms", + "key": "OEM_REF_RIGHT_REAR_TMPS", + "type": "TPMS", + "mandatory": false, + "since": "5.0" + }, + { + "name": "pressure", + "key": "OEM_REF_RIGHT_REAR_PRES", + "type": "Float", + "mandatory": false, + "minvalue": 0, + "maxvalue": 2000, + "since": "5.0" + } + ], + "key": "OEM_REF_RIGHT_REAR", + "type": "Struct", + "mandatory": true + }, + { + "name": "innerLeftRear", + "params": [ + { + "name": "status", + "key": "OEM_REF_IN_LEFT_REAR_ST", + "type": "ComponentVolumeStatus", + "mandatory": true + }, + { + "name": "tpms", + "key": "OEM_REF_IN_LEFT_REAR_TMPS", + "type": "TPMS", + "mandatory": false, + "since": "5.0" + }, + { + "name": "pressure", + "key": "OEM_REF_IN_LEFT_REAR_PRES", + "type": "Float", + "mandatory": false, + "minvalue": 0, + "maxvalue": 2000, + "since": "5.0" + } + ], + "key": "OEM_REF_IN_LEFT_REAR", + "type": "Struct", + "mandatory": true + }, + { + "name": "innerRightRear", + "params": [ + { + "name": "status", + "key": "OEM_REF_IN_RIGHT_REAR_ST", + "type": "ComponentVolumeStatus", + "mandatory": true + }, + { + "name": "tpms", + "key": "OEM_REF_IN_RIGHT_REAR_TMPS", + "type": "TPMS", + "mandatory": false, + "since": "5.0" + }, + { + "name": "pressure", + "key": "OEM_REF_IN_RIGHT_REAR_PRES", + "type": "Float", + "mandatory": false, + "minvalue": 0, + "maxvalue": 2000, + "since": "5.0" + } + ], + "key": "OEM_REF_IN_RIGHT_REAR", + "type": "Struct", + "mandatory": true + } + ], + "key": "OEM_REF_TIRE_PRES", + "type": "Struct", + "mandatory": false + }, + { + "name": "odometer", + "key": "OEM_REF_ODOM", + "type": "Integer", + "mandatory": false, + "minvalue": 0, + "maxvalue": 17000000 + }, + { + "name": "beltStatus", + "params": [ + { + "name": "driverBeltDeployed", + "key": "OEM_REF_DR_BELT_DEP", + "type": "VehicleDataEventStatus", + "mandatory": true + }, + { + "name": "passengerBeltDeployed", + "key": "OEM_REF_PAS_BELT_DEP", + "type": "VehicleDataEventStatus", + "mandatory": true + }, + { + "name": "passengerBuckleBelted", + "key": "OEM_REF_PAS_BUCK_BELT", + "type": "VehicleDataEventStatus", + "mandatory": true + }, + { + "name": "driverBuckleBelted", + "key": "OEM_REF_DR_BUCK_BELT", + "type": "VehicleDataEventStatus", + "mandatory": true + }, + { + "name": "leftRow2BuckleBelted", + "key": "OEM_REF_LEFT_R2_BUCK_BELT", + "type": "VehicleDataEventStatus", + "mandatory": true + }, + { + "name": "passengerChildDetected", + "key": "OEM_REF_PASS_CH_DET", + "type": "VehicleDataEventStatus", + "mandatory": true + }, + { + "name": "rightRow2BuckleBelted", + "key": "OEM_REF_RIGHT_R2_BUCK_BELT", + "type": "VehicleDataEventStatus", + "mandatory": true + }, + { + "name": "middleRow2BuckleBelted", + "key": "OEM_REF_MID_R2_BUCK_BELT", + "type": "VehicleDataEventStatus", + "mandatory": true + }, + { + "name": "middleRow3BuckleBelted", + "key": "OEM_REF_MID_R3_BUCK_BELT", + "type": "VehicleDataEventStatus", + "mandatory": true + }, + { + "name": "leftRow3BuckleBelted", + "key": "OEM_REF_LEFT_R3_BUCK_BELT", + "type": "VehicleDataEventStatus", + "mandatory": true + }, + { + "name": "rightRow3BuckleBelted", + "key": "OEM_REF_RIGHT_R3_BUCK_BELT", + "type": "VehicleDataEventStatus", + "mandatory": true + }, + { + "name": "leftRearInflatableBelted", + "key": "OEM_REF_LEFT_REAR_INF_BELT", + "type": "VehicleDataEventStatus", + "mandatory": true + }, + { + "name": "rightRearInflatableBelted", + "key": "OEM_REF_RIGHT_REAR_INF_BELT", + "type": "VehicleDataEventStatus", + "mandatory": true + }, + { + "name": "middleRow1BeltDeployed", + "key": "OEM_REF_MID_R1_BELT_DEP", + "type": "VehicleDataEventStatus", + "mandatory": true + }, + { + "name": "middleRow1BuckleBelted", + "key": "OEM_REF_MID_R1_BUCK_BELT", + "type": "VehicleDataEventStatus", + "mandatory": true + } + ], + "key": "OEM_REF_BELT_ST", + "type": "Struct", + "mandatory": false + }, + { + "name": "bodyInformation", + "params": [ + { + "name": "parkBrakeActive", + "key": "OEM_REF_PARK_BR_ACT", + "type": "Boolean", + "mandatory": true + }, + { + "name": "ignitionStableStatus", + "key": "OEM_REF_IGN_STAB_ST", + "type": "IgnitionStableStatus", + "mandatory": true + }, + { + "name": "ignitionStatus", + "key": "OEM_REF_IGN_ST", + "type": "IgnitionStatus", + "mandatory": true + }, + { + "name": "driverDoorAjar", + "key": "OEM_REF_DR_DOOR_AJ", + "type": "Boolean", + "mandatory": false + }, + { + "name": "passengerDoorAjar", + "key": "OEM_REF_PAS_DOOR_AJ", + "type": "Boolean", + "mandatory": false + }, + { + "name": "rearLeftDoorAjar", + "key": "OEM_REF_REAR_LEFT_DOOR_AJ", + "type": "Boolean", + "mandatory": false + }, + { + "name": "rearRightDoorAjar", + "key": "OEM_REF_REAR_RIGHT_DOOR_AJ", + "type": "Boolean", + "mandatory": false + } + ], + "key": "OEM_REF_BODY_INF", + "type": "Struct", + "mandatory": false + }, + { + "name": "deviceStatus", + "params": [ + { + "name": "voiceRecOn", + "key": "OEM_REF_VOICE_REC_ON", + "type": "Boolean", + "mandatory": true + }, + { + "name": "btIconOn", + "key": "OEM_REF_BT_ICO_ON", + "type": "Boolean", + "mandatory": true + }, + { + "name": "callActive", + "key": "OEM_REF_CAL_ACT", + "type": "Boolean", + "mandatory": true + }, + { + "name": "phoneRoaming", + "key": "OEM_REF_PH_ROAM", + "type": "Boolean", + "mandatory": true + }, + { + "name": "textMsgAvailable", + "key": "OEM_REF_TEXT_MSG_AV", + "type": "Boolean", + "mandatory": true + }, + { + "name": "battLevelStatus", + "key": "OEM_REF_BAT_LEV_ST", + "type": "DeviceLevelStatus", + "mandatory": true + }, + { + "name": "stereoAudioOutputMuted", + "key": "OEM_REF_STER_AUD_OUT_MUT", + "type": "Boolean", + "mandatory": true + }, + { + "name": "monoAudioOutputMuted", + "key": "OEM_REF_MONO_AUD_OUT_MUT", + "type": "Boolean", + "mandatory": true + }, + { + "name": "signalLevelStatus", + "key": "OEM_REF_SIG_LEV_ST", + "type": "DeviceLevelStatus", + "mandatory": true + }, + { + "name": "primaryAudioSource", + "key": "OEM_REF_PR_AUD_SOUR", + "type": "PrimaryAudioSource", + "mandatory": true + }, + { + "name": "eCallEventActive", + "key": "OEM_REF_E_CALL_INF_ACT", + "type": "Boolean", + "mandatory": true + } + ], + "key": "OEM_REF_DEV_ST", + "type": "Struct", + "mandatory": false + }, + { + "name": "driverBraking", + "key": "OEM_REF_DR_BRAK", + "type": "VehicleDataEventStatus", + "mandatory": false + }, + { + "name": "wiperStatus", + "key": "OEM_REF_WI_ST", + "type": "WiperStatus", + "mandatory": false + }, + { + "name": "headLampStatus", + "params": [ + { + "name": "ambientLightSensorStatus", + "key": "OEM_REF_AMB_LIGHT", + "type": "AmbientLightStatus", + "mandatory": false + }, + { + "name": "highBeamsOn", + "key": "OEM_REF_HIGH_BEAM", + "type": "Boolean", + "mandatory": true + }, + { + "name": "lowBeamsOn", + "key": "OEM_REF_LOW_BEAM", + "type": "Boolean", + "mandatory": true + } + ], + "key": "OEM_REF_HLSTATUS", + "type": "Struct", + "mandatory": false + }, + { + "name": "engineTorque", + "key": "OEM_REF_ENG_TORQ", + "type": "Float", + "mandatory": false, + "minvalue": -1000, + "maxvalue": 2000 + }, + { + "name": "accPedalPosition", + "key": "OEM_REF_ACC_PED_POS", + "type": "Float", + "mandatory": false, + "minvalue": 0, + "maxvalue": 100 + }, + { + "name": "steeringWheelAngle", + "key": "OEM_REF_STE_WH_ANG", + "type": "Float", + "mandatory": false, + "minvalue": -2000, + "maxvalue": 2000 + }, + { + "name": "engineOilLife", + "key": "OEM_REF_ENG_OIL_LIFE", + "type": "Float", + "mandatory": false, + "minvalue": 0, + "maxvalue": 100, + "since": "5.0" + }, + { + "name": "electronicParkBrakeStatus", + "key": "OEM_REF_EL_PARK_BR_ST", + "type": "ElectronicParkBrakeStatus", + "mandatory": false, + "since": "5.0" + }, + { + "name": "cloudAppVehicleID", + "key": "OEM_REF_CL_APP_VEH_ID", + "type": "String", + "mandatory": false, + "since": "5.1" + }, + { + "name": "eCallInfo", + "params": [ + { + "name": "eCallNotificationStatus", + "key": "OEM_REF_E_CALL_NOT_ST", + "type": "VehicleDataNotificationStatus", + "mandatory": true + }, + { + "name": "auxECallNotificationStatus", + "key": "OEM_REF_AUX_E_CALL_NOT_ST", + "type": "VehicleDataNotificationStatus", + "mandatory": true + }, + { + "name": "eCallConfirmationStatus", + "key": "OEM_REF_E_CALL_CONF_ST", + "type": "ECallConfirmationStatus", + "mandatory": true + } + ], + "key": "OEM_REF_E_CALL_INF", + "type": "Struct", + "mandatory": false + }, + { + "name": "airbagStatus", + "params": [ + { + "name": "driverAirbagDeployed", + "key": "OEM_REF_DR_AIR_DEP", + "type": "VehicleDataEventStatus", + "mandatory": true + }, + { + "name": "driverSideAirbagDeployed", + "key": "OEM_REF_DR_SIDE_AIR_DEP", + "type": "VehicleDataEventStatus", + "mandatory": true + }, + { + "name": "driverCurtainAirbagDeployed", + "key": "OEM_REF_DR_CUR_AIR_DEP", + "type": "VehicleDataEventStatus", + "mandatory": true + }, + { + "name": "passengerAirbagDeployed", + "key": "OEM_REF_PASS_AIR_DEP", + "type": "VehicleDataEventStatus", + "mandatory": true + }, + { + "name": "passengerCurtainAirbagDeployed", + "key": "OEM_REF_PASS_CUR_AIR_DEP", + "type": "VehicleDataEventStatus", + "mandatory": true + }, + { + "name": "driverKneeAirbagDeployed", + "key": "OEM_REF_DR_KNEE_AIR_DEP", + "type": "VehicleDataEventStatus", + "mandatory": true + }, + { + "name": "passengerSideAirbagDeployed", + "key": "OEM_REF_PASS_SIDE_AIR_DEP", + "type": "VehicleDataEventStatus", + "mandatory": true + }, + { + "name": "passengerKneeAirbagDeployed", + "key": "OEM_REF_PASS_KNEE_AIR_DEP", + "type": "VehicleDataEventStatus", + "mandatory": true + } + ], + "key": "OEM_REF_AIR_ST", + "type": "Struct", + "mandatory": false + }, + { + "name": "emergencyEvent", + "params": [ + { + "name": "emergencyEventType", + "key": "OEM_REF_EM_EV_TYPE", + "type": "EmergencyEventType", + "mandatory": true + }, + { + "name": "fuelCutoffStatus", + "key": "OEM_REF_FUEL_CUT_ST", + "type": "FuelCutoffStatus", + "mandatory": true + }, + { + "name": "rolloverEvent", + "key": "OEM_REF_ROL_EV", + "type": "VehicleDataEventStatus", + "mandatory": true + }, + { + "name": "maximumChangeVelocity", + "key": "OEM_REF_MAX_CH_VEL", + "type": "Integer", + "mandatory": true, + "minvalue": 0, + "maxvalue": 255 + }, + { + "name": "multipleEvents", + "key": "OEM_REF_MUL_EV", + "type": "VehicleDataEventStatus", + "mandatory": true + } + ], + "key": "OEM_REF_EM_EV", + "type": "Struct", + "mandatory": false + }, + { + "name": "clusterModeStatus", + "params": [ + { + "name": "powerModeActive", + "key": "OEM_REF_POW_MOD_ACT", + "type": "Boolean", + "mandatory": true + }, + { + "name": "powerModeQualificationStatus", + "key": "OEM_REF_POW_MOD_QU_ST", + "type": "PowerModeQualificationStatus", + "mandatory": true + }, + { + "name": "carModeStatus", + "key": "OEM_REF_CAR_MOD_ST", + "type": "CarModeStatus", + "mandatory": true + }, + { + "name": "powerModeStatus", + "key": "OEM_REF_POW_MOD_ST", + "type": "PowerModeStatus", + "mandatory": true + } + ], + "key": "OEM_REF_CL_MOD_ST", + "type": "Struct", + "mandatory": false + }, + { + "name": "myKey", + "params": [ + { + "name": "e911Override", + "key": "OEM_REF_E_9110_VE", + "type": "VehicleDataStatus", + "mandatory": true, + "since": "2.0" + } + ], + "key": "OEM_REF_MY_KEY", + "type": "Struct", + "mandatory": false + } + ] + } + } +} diff --git a/src/appMain/signal_handlers.cc b/src/appMain/signal_handlers.cc index 649f162ec65..c9c09d10a2b 100644 --- a/src/appMain/signal_handlers.cc +++ b/src/appMain/signal_handlers.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 "appMain/signal_handlers.h" #include "appMain/life_cycle.h" diff --git a/src/appMain/signal_handlers.h b/src/appMain/signal_handlers.h index f3adefb929f..458a121d42e 100644 --- a/src/appMain/signal_handlers.h +++ b/src/appMain/signal_handlers.h @@ -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. + */ #ifndef SRC_APPMAIN_SIGNAL_HANDLERS_H_ #define SRC_APPMAIN_SIGNAL_HANDLERS_H_ diff --git a/src/appMain/smartDeviceLink.ini b/src/appMain/smartDeviceLink.ini index 54c2395c475..baf8cf60730 100644 --- a/src/appMain/smartDeviceLink.ini +++ b/src/appMain/smartDeviceLink.ini @@ -202,6 +202,18 @@ TCPAdapterPort = 12345 ; If the name is omitted, Core will listen on all network interfaces by binding to INADDR_ANY. TCPAdapterNetworkInterface = +; 128 bit uuid for bluetooth device discovery. Please format as 16 seperate bytes. +;BluetoothUUID = 0x93, 0x6D, 0xA0, 0x1F, 0x9A, 0xBD, 0x4D, 0x9D, 0x80, 0xC7, 0x02, 0xAF, 0x85, 0xC8, 0x22, 0xA8 + +; AOA USB Transport Configuration +; USBAccessory Filter Parameters +AOAFilterManufacturer = SDL +AOAFilterModelName = Core +AOAFilterDescription = SmartDeviceLink Core Component USB +AOAFilterVersion = 1.0 +AOAFilterURI = http://www.smartdevicelink.org +AOAFilterSerialNumber = N000000 + [CloudAppConnections] ; Value in milliseconds for time between retry attempts on a failed websocket connection CloudAppRetryTimeout = 1000 @@ -378,4 +390,8 @@ HMIOriginID = "HMI_ID" EmbeddedServices = MEDIA, WEATHER, NAVIGATION ; Additional time added to RPC timeout when passing through to App service -RpcPassThroughTimeout = 10000 \ No newline at end of file +RpcPassThroughTimeout = 10000 + +[RCModuleConsent] +; The period (in days) after which consent for module_id should be removed. +PeriodForConsentExpiration = 30 diff --git a/src/appMain/test/low_voltage_signals_handler_test.cc b/src/appMain/test/low_voltage_signals_handler_test.cc index 2dea9447c68..3dec0cc96dd 100644 --- a/src/appMain/test/low_voltage_signals_handler_test.cc +++ b/src/appMain/test/low_voltage_signals_handler_test.cc @@ -1,48 +1,48 @@ /* -* 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. -*/ + * 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 "gtest/gtest.h" #include "utils/macro.h" +#include "utils/mock_signals_posix.h" namespace test { using ::testing::_; -using ::testing::Return; using ::testing::InSequence; +using ::testing::Return; const int kLowVoltageSignalOffset = 1; const int kWakeUpSignalOffset = 2; diff --git a/src/appMain/test/mock_life_cycle.h b/src/appMain/test/mock_life_cycle.h index fc24b26080b..98973bd153e 100644 --- a/src/appMain/test/mock_life_cycle.h +++ b/src/appMain/test/mock_life_cycle.h @@ -1,34 +1,34 @@ /* -* 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. -*/ + * 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_ diff --git a/src/components/application_manager/CMakeLists.txt b/src/components/application_manager/CMakeLists.txt index 625e1192706..c7f2aede9a8 100644 --- a/src/components/application_manager/CMakeLists.txt +++ b/src/components/application_manager/CMakeLists.txt @@ -142,6 +142,7 @@ set(LIBRARIES formatters dbms Utils + policy_struct bson -L${BSON_LIBS_DIRECTORY} emhashmap -L${EMHASHMAP_LIBS_DIRECTORY} ) @@ -159,7 +160,7 @@ add_library("AMEventEngine" ${EVENT_ENGINE_SOURCES}) target_link_libraries("AMEventEngine" ${LIBRARIES}) add_library("AMPolicyLibrary" ${POLICIES_MANAGER_SOURCES} ) -target_link_libraries("AMPolicyLibrary" ${LIBRARIES} AMEventEngine) +target_link_libraries("AMPolicyLibrary" ${LIBRARIES} AMEventEngine policy_struct) add_library("SystemTimeLibrary" ${SYSTEM_TIME_SOURCES}) target_link_libraries("SystemTimeLibrary" ${LIBRARIES} AMEventEngine) diff --git a/src/components/application_manager/include/application_manager/app_extension.h b/src/components/application_manager/include/application_manager/app_extension.h index e3231de3471..5167aa88c0e 100644 --- a/src/components/application_manager/include/application_manager/app_extension.h +++ b/src/components/application_manager/include/application_manager/app_extension.h @@ -33,11 +33,13 @@ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_APP_EXTENSION_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_APP_EXTENSION_H_ +#include + namespace ns_smart_device_link { namespace ns_smart_objects { class SmartObject; } -} +} // namespace ns_smart_device_link namespace application_manager { diff --git a/src/components/application_manager/include/application_manager/app_launch/app_launch_ctrl.h b/src/components/application_manager/include/application_manager/app_launch/app_launch_ctrl.h index a10963ad820..2dd64a2941f 100644 --- a/src/components/application_manager/include/application_manager/app_launch/app_launch_ctrl.h +++ b/src/components/application_manager/include/application_manager/app_launch/app_launch_ctrl.h @@ -32,8 +32,8 @@ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_APP_LAUNCH_APP_LAUNCH_CTRL_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_APP_LAUNCH_APP_LAUNCH_CTRL_H_ -#include #include +#include namespace application_manager { class Application; @@ -49,22 +49,22 @@ namespace app_launch { class AppLaunchCtrl { public: /** - * @brief OnAppRegistered should be called when application registered - * Save application parameters to database - * @param app application to save - */ + * @brief OnAppRegistered should be called when application registered + * Save application parameters to database + * @param app application to save + */ virtual void OnAppRegistered(const application_manager::Application& app) = 0; /** - * @brief OnDeviceConnected shoudl be called on device connected event - * Start launching saaved applications on ios device - * @param device_mac - */ + * @brief OnDeviceConnected shoudl be called on device connected event + * Start launching saaved applications on ios device + * @param device_mac + */ virtual void OnDeviceConnected(const std::string& device_mac) = 0; /** - * @brief OnMasterReset clear database of saved applications - */ + * @brief OnMasterReset clear database of saved applications + */ virtual void OnMasterReset() = 0; virtual ~AppLaunchCtrl() {} }; diff --git a/src/components/application_manager/include/application_manager/app_launch/app_launch_ctrl_impl.h b/src/components/application_manager/include/application_manager/app_launch/app_launch_ctrl_impl.h index 61f3480f77d..986f4ad4ff0 100644 --- a/src/components/application_manager/include/application_manager/app_launch/app_launch_ctrl_impl.h +++ b/src/components/application_manager/include/application_manager/app_launch/app_launch_ctrl_impl.h @@ -41,11 +41,11 @@ namespace connection_handler { class ConnectionHandler; -} // connection_handler +} // namespace connection_handler namespace resumption { class ResumeCtrl; -} // resumption +} // namespace resumption namespace app_launch { // TODO(AK) Use unique pointer diff --git a/src/components/application_manager/include/application_manager/app_launch/app_launch_data.h b/src/components/application_manager/include/application_manager/app_launch/app_launch_data.h index 73e9623b627..c1ad8d4003d 100644 --- a/src/components/application_manager/include/application_manager/app_launch/app_launch_data.h +++ b/src/components/application_manager/include/application_manager/app_launch/app_launch_data.h @@ -34,9 +34,9 @@ #define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_APP_LAUNCH_APP_LAUNCH_DATA_H_ #include -#include -#include #include +#include +#include namespace app_launch { diff --git a/src/components/application_manager/include/application_manager/app_launch/app_launch_data_db.h b/src/components/application_manager/include/application_manager/app_launch/app_launch_data_db.h index ccbf4c7c01e..b232d1874ce 100644 --- a/src/components/application_manager/include/application_manager/app_launch/app_launch_data_db.h +++ b/src/components/application_manager/include/application_manager/app_launch/app_launch_data_db.h @@ -104,8 +104,8 @@ class AppLaunchDataDB : public AppLaunchDataImpl { bool IsAppDataAlreadyExisted(const ApplicationData& app_data) const OVERRIDE; /** - * @brief returns pointer to data base - */ + * @brief returns pointer to data base + */ utils::dbms::SQLDatabase* db() const; enum ApplicationDataDBIndexes { @@ -151,13 +151,13 @@ class AppLaunchDataDB : public AppLaunchDataImpl { bool WriteDb(); /** - * @brief returns pointer to data base - */ + * @brief returns pointer to data base + */ std::unique_ptr db_; /** - * @brief indicate initializing status of DB - */ + * @brief indicate initializing status of DB + */ bool init_successeful_; DISALLOW_COPY_AND_ASSIGN(AppLaunchDataDB); diff --git a/src/components/application_manager/include/application_manager/app_launch/app_launch_data_impl.h b/src/components/application_manager/include/application_manager/app_launch/app_launch_data_impl.h index a2b8630bccc..b28c7fdd3d3 100644 --- a/src/components/application_manager/include/application_manager/app_launch/app_launch_data_impl.h +++ b/src/components/application_manager/include/application_manager/app_launch/app_launch_data_impl.h @@ -33,10 +33,10 @@ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_APP_LAUNCH_APP_LAUNCH_DATA_IMPL_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_APP_LAUNCH_APP_LAUNCH_DATA_IMPL_H_ +#include #include "application_manager/app_launch/app_launch_data.h" #include "application_manager/app_launch_settings.h" #include "utils/macro.h" -#include namespace app_launch { diff --git a/src/components/application_manager/include/application_manager/app_launch/app_launch_data_json.h b/src/components/application_manager/include/application_manager/app_launch/app_launch_data_json.h index a292b84fc05..9463a349d97 100644 --- a/src/components/application_manager/include/application_manager/app_launch/app_launch_data_json.h +++ b/src/components/application_manager/include/application_manager/app_launch/app_launch_data_json.h @@ -33,12 +33,12 @@ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_APP_LAUNCH_APP_LAUNCH_DATA_JSON_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_APP_LAUNCH_APP_LAUNCH_DATA_JSON_H_ +#include #include "application_manager/app_launch/app_launch_data_impl.h" -#include "smart_objects/smart_object.h" #include "resumption/last_state.h" +#include "smart_objects/smart_object.h" #include "utils/lock.h" #include "utils/macro.h" -#include namespace app_launch { diff --git a/src/components/application_manager/include/application_manager/app_launch/apps_launcher.h b/src/components/application_manager/include/application_manager/app_launch/apps_launcher.h index 6285514be97..7e360aa4600 100644 --- a/src/components/application_manager/include/application_manager/app_launch/apps_launcher.h +++ b/src/components/application_manager/include/application_manager/app_launch/apps_launcher.h @@ -1,9 +1,9 @@ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_APP_LAUNCH_APPS_LAUNCHER_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_APP_LAUNCH_APPS_LAUNCHER_H_ +#include #include "application_manager/app_launch/app_launch_data.h" #include "connection_handler/connection_handler.h" #include "utils/timer.h" -#include namespace app_launch { class AppLaunchCtrlImpl; diff --git a/src/components/application_manager/include/application_manager/app_launch/device_apps_launcher.h b/src/components/application_manager/include/application_manager/app_launch/device_apps_launcher.h index f1566542152..f27e4569fc6 100644 --- a/src/components/application_manager/include/application_manager/app_launch/device_apps_launcher.h +++ b/src/components/application_manager/include/application_manager/app_launch/device_apps_launcher.h @@ -1,12 +1,12 @@ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_APP_LAUNCH_DEVICE_APPS_LAUNCHER_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_APP_LAUNCH_DEVICE_APPS_LAUNCHER_H_ #include -#include -#include #include +#include +#include #include "application_manager/app_launch/app_launch_data.h" -#include "application_manager/application_manager.h" #include "application_manager/app_launch_settings.h" +#include "application_manager/application_manager.h" namespace app_launch { class AppLaunchCtrlImpl; diff --git a/src/components/application_manager/include/application_manager/application.h b/src/components/application_manager/include/application_manager/application.h index b4d8ca857e4..e9dcf2bcb05 100644 --- a/src/components/application_manager/include/application_manager/application.h +++ b/src/components/application_manager/include/application_manager/application.h @@ -33,23 +33,23 @@ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_APPLICATION_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_APPLICATION_H_ -#include +#include #include +#include #include -#include +#include #include -#include -#include "utils/data_accessor.h" -#include "interfaces/MOBILE_API.h" -#include "connection_handler/device.h" #include "application_manager/app_extension.h" -#include "application_manager/message.h" -#include "application_manager/hmi_state.h" #include "application_manager/application_state.h" #include "application_manager/help_prompt_manager.h" +#include "application_manager/hmi_state.h" +#include "application_manager/message.h" +#include "connection_handler/device.h" +#include "interfaces/MOBILE_API.h" #include "protocol_handler/protocol_handler.h" #include "smart_objects/smart_object.h" +#include "utils/data_accessor.h" #include "utils/macro.h" #include "utils/semantic_version.h" @@ -62,13 +62,17 @@ typedef int32_t ErrorCode; class UsageStatistics; +class DisplayCapabilitiesBuilder; + enum APIVersion { kUnknownAPI = -1, kAPIV0 = 0, kAPIV1 = 1, kAPIV2 = 2, kAPIV3 = 3, - kAPIV4 = 4 + kAPIV4 = 4, + kAPIV5 = 5, + kAPIV6 = 6 }; enum TLimitSource { POLICY_TABLE = 0, CONFIG_FILE }; @@ -145,6 +149,12 @@ typedef std::map SubMenuMap; */ typedef std::map ChoiceSetMap; +/* + * @brief Typedef for map of window ids to data used as parameters + * to CreateWindow request. + */ +typedef std::map WindowParamsMap; + /* * @brief Typedef for perform interaction choice * @param choice id @@ -162,7 +172,7 @@ typedef std::map PerformChoiceSetMap; /** * @brief Defines id of SoftButton */ -typedef std::set SoftButtonID; +typedef std::set > SoftButtonID; /** * @brief Defines set of buttons subscription @@ -188,9 +198,25 @@ class DynamicApplicationData { virtual const smart_objects::SmartObject* keyboard_props() const = 0; virtual const smart_objects::SmartObject* menu_title() const = 0; virtual const smart_objects::SmartObject* menu_icon() const = 0; - virtual const smart_objects::SmartObject* day_color_scheme() const = 0; - virtual const smart_objects::SmartObject* night_color_scheme() const = 0; - virtual const std::string& display_layout() const = 0; + virtual smart_objects::SmartObject day_color_scheme() const = 0; + virtual smart_objects::SmartObject night_color_scheme() const = 0; + virtual std::string display_layout() const = 0; + + /** + * @brief Specific display capabilities of application + * @return display capabilities of application or NULL-initialized pointer if + * not specified + */ + virtual smart_objects::SmartObjectSPtr display_capabilities() const = 0; + + /** + * @brief Specific display capabilities of application + * @param window id - id of an affected widget + * @return display capabilities of application or NULL-initialized pointer if + * not specified + */ + virtual smart_objects::SmartObjectSPtr display_capabilities( + const WindowID window_id) const = 0; virtual void load_global_properties(const smart_objects::SmartObject& so) = 0; virtual void set_help_prompt( @@ -222,12 +248,84 @@ class DynamicApplicationData { virtual void set_video_stream_retry_number( const uint32_t& video_stream_retry_number) = 0; + virtual void set_display_layout(const std::string& layout) = 0; virtual void set_day_color_scheme( const smart_objects::SmartObject& color_scheme) = 0; virtual void set_night_color_scheme( const smart_objects::SmartObject& color_scheme) = 0; - virtual void set_display_layout(const std::string& layout) = 0; + /** + * @brief Set specific application display capabilities + * @param display_capabilities new display capabilities of application + */ + virtual void set_display_capabilities( + const smart_objects::SmartObject& display_capabilities) = 0; + + /** + * @brief deletes stored window capability for given window id + * @param window id of capability to remove + */ + virtual void remove_window_capability(const WindowID window_id) = 0; + + /** + * @brief checks whether a specific menu layout is supported + * @param menu layout to check + */ + virtual bool menu_layout_supported( + const mobile_apis::MenuLayout::eType layout) const = 0; + + /** + * @brief Sets layout for application's specific window + * @param window_id window id for which layout should be set + * @param layout - layout to be set + */ + virtual void set_window_layout(const WindowID window_id, + const std::string& layout) = 0; + + /** + * @brief Sets day color scheme for application's specific window + * @param window_id window id for which day color scheme should be set + * @param color_scheme - color scheme to be set + */ + virtual void set_day_color_scheme( + const WindowID window_id, + const smart_objects::SmartObject& color_scheme) = 0; + + /** + * @brief Sets night color scheme for application's specific window + * @param window_id window id for which night color scheme should be set + * @param color_scheme - color scheme to be set + */ + virtual void set_night_color_scheme( + const WindowID window_id, + const smart_objects::SmartObject& color_scheme) = 0; + + /** + * @brief Gets window layout for application's specific window_id + * @param window_id window id for which display layout should be returned + * @return string containing set display layout, + * if no display layout is set - empty string is returned + */ + virtual std::string window_layout(const WindowID window_id) const = 0; + + /** + * @brief Gets day color scheme for application's specific window_id + * @param window_id window id for which color scheme should be returned + * @return day color scheme which is set for specified app window, + * if no day color scheme is set - Smart object with NullType is returned + */ + virtual smart_objects::SmartObject day_color_scheme( + const WindowID window_id) const = 0; + + /** + * @brief Gets night color scheme for application's specific window_id + * @param window_id window id for which color scheme should be returned + * @return night color scheme which is set for specified app window + * if no night color scheme is set - Smart object with NullType is returned + */ + virtual smart_objects::SmartObject night_color_scheme( + const WindowID window_id) const = 0; + /** * @brief Checks if application is media, voice communication or navigation * @return true if application is media, voice communication or navigation, @@ -236,8 +334,8 @@ class DynamicApplicationData { virtual bool is_audio() const = 0; /* - * @brief Adds a command to the in application menu - */ + * @brief Adds a command to the in application menu + */ virtual void AddCommand(uint32_t cmd_id, const smart_objects::SmartObject& command) = 0; @@ -289,6 +387,20 @@ class DynamicApplicationData { */ virtual void RemoveChoiceSet(uint32_t choice_set_id) = 0; + /* + * @brief Adds window info + * @param window_id unique id of a window + * @param window_info SmartObject that represent window info + */ + virtual void SetWindowInfo(const WindowID window_id, + const smart_objects::SmartObject& window_info) = 0; + + /* + * @brief Removes window info + * @param window_id unique id of a window + */ + virtual void RemoveWindowInfo(const WindowID window_id) = 0; + /* * @brief Finds choice set with the specified choice_set_id id * @@ -323,6 +435,16 @@ class DynamicApplicationData { virtual DataAccessor performinteraction_choice_set_map() const = 0; + /* + * @brief Retrieves window info map + */ + virtual DataAccessor window_optional_params_map() const = 0; + + /* + * @brief Retrieves display capabilities builder + */ + virtual DisplayCapabilitiesBuilder& display_capabilities_builder() = 0; + /* * @brief Retrieve application commands */ @@ -353,10 +475,10 @@ class DynamicApplicationData { virtual uint32_t is_perform_interaction_active() const = 0; /* - * @brief Set perform interaction layout - * - * @param Current Interaction layout of the perform interaction - */ + * @brief Set perform interaction layout + * + * @param Current Interaction layout of the perform interaction + */ virtual void set_perform_interaction_layout( mobile_api::LayoutMode::eType layout) = 0; @@ -366,10 +488,10 @@ class DynamicApplicationData { virtual mobile_api::LayoutMode::eType perform_interaction_layout() const = 0; /* - * @brief Sets the mode for perform interaction: UI/VR/BOTH - * - * @param mode Mode that was selected (MENU; VR; BOTH) - */ + * @brief Sets the mode for perform interaction: UI/VR/BOTH + * + * @param mode Mode that was selected (MENU; VR; BOTH) + */ virtual void set_perform_interaction_mode(int32_t mode) = 0; /* @@ -449,6 +571,20 @@ class Application : public virtual InitialApplicationData, */ virtual void set_is_application_data_changed(bool state_application_data) = 0; + /** + * @brief Checks if application data is allowed to be resumed + * @return TRUE if data of application is allowed to be resumed, otherwise + * return FALSE + */ + virtual bool is_app_data_resumption_allowed() const = 0; + + /** + * @brief Sets resumption allowance for application data + * @param allowed - true if app data allowed to be resumed, + * false value means that app data is disallowed for resumption + */ + virtual void set_app_data_resumption_allowance(const bool allowed) = 0; + virtual void CloseActiveMessage() = 0; virtual bool IsFullscreen() const = 0; virtual void ChangeSupportingAppHMIType() = 0; @@ -520,8 +656,10 @@ class Application : public virtual InitialApplicationData, /** * @brief Wakes up streaming process for application * @param service_type Type of streaming service + * @param timer_len The amount of time in ms the timer will wait */ - virtual void WakeUpStreaming(protocol_handler::ServiceType service_type) = 0; + virtual void WakeUpStreaming(protocol_handler::ServiceType service_type, + uint32_t timer_len = 0) = 0; virtual bool is_voice_communication_supported() const = 0; virtual void set_voice_communication_supported( @@ -545,11 +683,26 @@ class Application : public virtual InitialApplicationData, virtual bool is_media_application() const = 0; virtual bool is_foreground() const = 0; virtual void set_foreground(const bool is_foreground) = 0; - virtual const mobile_api::HMILevel::eType hmi_level() const = 0; + + /** + * @brief hmi_level current HMI level of application's window + * @param window_id id of application's window to get + * @return HMI level of application's window + */ + virtual const mobile_api::HMILevel::eType hmi_level( + const WindowID window_id) const = 0; + virtual const uint32_t put_file_in_none_count() const = 0; virtual const uint32_t delete_file_in_none_count() const = 0; virtual const uint32_t list_files_in_none_count() const = 0; - virtual const mobile_api::SystemContext::eType system_context() const = 0; + + /** + * @brief system_context current system context of application's window + * @param window_id id of application's window to get + * @return system context of application's window + */ + virtual const mobile_api::SystemContext::eType system_context( + const WindowID window_id) const = 0; virtual const mobile_api::AudioStreamingState::eType audio_streaming_state() const = 0; virtual const mobile_api::VideoStreamingState::eType video_streaming_state() @@ -694,58 +847,91 @@ class Application : public virtual InitialApplicationData, /** * @brief SetInitialState sets initial HMI state for application on * registration + * @param window_id window id for HMI state + * @param window_name name of inited window * @param state Hmi state value */ - virtual void SetInitialState(HmiStatePtr state) = 0; + virtual void SetInitialState(const WindowID window_id, + const std::string& window_name, + HmiStatePtr state) = 0; /** * @brief SetRegularState set permanent state of application - * + * @param window_id window id for HMI state * @param state state to setup */ - virtual void SetRegularState(HmiStatePtr state) = 0; + virtual void SetRegularState(const WindowID window_id, HmiStatePtr state) = 0; /** - * @brief SetPostponedState sets postponed state to application. - * This state could be set as regular later - * - * @param state state to setup - */ - virtual void SetPostponedState(HmiStatePtr state) = 0; + * @brief SetPostponedState sets postponed state to application. + * This state could be set as regular later + * @param window_id window id for HMI state + * @param state state to setup + */ + virtual void SetPostponedState(const WindowID window_id, + HmiStatePtr state) = 0; - virtual void RemovePostponedState() = 0; + /** + * @brief RemovePostponedState removes postponed state for application + * After removal, this state will not be set as regular later + * @param window_id window id for HMI state + */ + virtual void RemovePostponedState(const WindowID window_id) = 0; /** * @brief AddHMIState the function that will change application's * hmi state. * - * @param app_id id of the application whose hmi level should be changed. + * @param window_id window id for HMI state * * @param state new hmi state for certain application. */ - virtual void AddHMIState(HmiStatePtr state) = 0; + virtual void AddHMIState(const WindowID window_id, HmiStatePtr state) = 0; /** * @brief RemoveHMIState the function that will turn back hmi_level after end * of some event * - * @param app_id id of the application whose hmi level should be changed. + * @param window_id window id for HMI state * * @param state_id that should be removed */ - virtual void RemoveHMIState(HmiState::StateID state_id) = 0; + virtual void RemoveHMIState(const WindowID window_id, + HmiState::StateID state_id) = 0; /** * @brief HmiState of application within active events PhoneCall, TTS< etc ... + * @param window_id window id for HMI state * @return Active HmiState of application */ - virtual const HmiStatePtr CurrentHmiState() const = 0; + virtual const HmiStatePtr CurrentHmiState(const WindowID window_id) const = 0; + + /** + * @brief Getter for a list of available application windows including the + * main + * @return list of available window IDs created by application + */ + virtual WindowIds GetWindowIds() const = 0; + + /** + * @brief Getter for a list of all existing window names + * @return list of available window names created by application + */ + virtual WindowNames GetWindowNames() const = 0; + + /** + * @brief Check if application has specified window + * @param window_id - id of window to check + * @return true if app has specified window , otherwise false + */ + virtual bool WindowIdExists(const WindowID window_id) const = 0; /** * @brief RegularHmiState of application without active events VR, TTS etc ... + * @param window_id window id for HMI state * @return HmiState of application */ - virtual const HmiStatePtr RegularHmiState() const = 0; + virtual const HmiStatePtr RegularHmiState(const WindowID window_id) const = 0; /** * @brief Checks if app is allowed to change audio source @@ -756,10 +942,11 @@ class Application : public virtual InitialApplicationData, /** * @brief PostponedHmiState returns postponed hmi state of application * if it's present - * + * @param window_id window id for HMI state * @return Postponed hmi state of application */ - virtual const HmiStatePtr PostponedHmiState() const = 0; + virtual const HmiStatePtr PostponedHmiState( + const WindowID window_id) const = 0; /** * @brief Keeps id of softbuttons which is created in commands: @@ -771,6 +958,13 @@ class Application : public virtual InitialApplicationData, virtual void SubscribeToSoftButtons(int32_t cmd_id, const SoftButtonID& softbuttons_id) = 0; + /** + * @brief Retreives window id on which given button is created + * @param button_id identifier of a button + * @param window id of a widget containing button + */ + virtual WindowID GetSoftButtonWindowID(const uint32_t button_id) = 0; + /** * @brief Determine the existence of softbutton * @param Softbutton_id contains id of softbutton @@ -901,9 +1095,11 @@ class Application : public virtual InitialApplicationData, /** * @brief set_system_context Set system context for application + * @param window_id window id for HMI state * @param system_context Current context */ virtual void set_system_context( + const WindowID window_id, const mobile_api::SystemContext::eType& system_context) = 0; /** @@ -915,9 +1111,11 @@ class Application : public virtual InitialApplicationData, /** * @brief set_hmi_level Set HMI level for application + * @param window_id window id for HMI state * @param hmi_level Current HMI level */ - virtual void set_hmi_level(const mobile_api::HMILevel::eType& hmi_level) = 0; + virtual void set_hmi_level(const WindowID window_id, + const mobile_api::HMILevel::eType& hmi_level) = 0; /** * @brief Return pointer to extension by uid @@ -1013,6 +1211,19 @@ class Application : public virtual InitialApplicationData, */ virtual void set_cloud_app_certificate(const std::string& certificate) = 0; + /** + * @brief Set user location + * @param smart object of user location + */ + virtual void set_user_location( + const smart_objects::SmartObject& user_location) = 0; + + /** + * @brief Get user location + * @return smart object of user location + */ + virtual const smart_objects::SmartObject& get_user_location() const = 0; + protected: mutable sync_primitives::Lock hmi_states_lock_; diff --git a/src/components/application_manager/include/application_manager/application_data_impl.h b/src/components/application_manager/include/application_manager/application_data_impl.h index 8f24f124f98..5c4f868fc9c 100644 --- a/src/components/application_manager/include/application_manager/application_data_impl.h +++ b/src/components/application_manager/include/application_manager/application_data_impl.h @@ -34,11 +34,12 @@ #define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_APPLICATION_DATA_IMPL_H_ #include -#include "utils/lock.h" -#include "utils/semantic_version.h" -#include "smart_objects/smart_object.h" #include "application_manager/application.h" +#include "application_manager/display_capabilities_builder.h" #include "interfaces/MOBILE_API.h" +#include "smart_objects/smart_object.h" +#include "utils/lock.h" +#include "utils/semantic_version.h" namespace application_manager { @@ -88,6 +89,7 @@ class InitialApplicationDataImpl : public virtual Application { class DynamicApplicationDataImpl : public virtual Application { public: + typedef std::map AppWindowsTemplates; DynamicApplicationDataImpl(); ~DynamicApplicationDataImpl(); const smart_objects::SmartObject* help_prompt() const; @@ -100,9 +102,31 @@ class DynamicApplicationDataImpl : public virtual Application { const smart_objects::SmartObject* keyboard_props() const; const smart_objects::SmartObject* menu_title() const; const smart_objects::SmartObject* menu_icon() const; - const smart_objects::SmartObject* day_color_scheme() const; - const smart_objects::SmartObject* night_color_scheme() const; - const std::string& display_layout() const; + + smart_objects::SmartObject day_color_scheme() const OVERRIDE; + smart_objects::SmartObject night_color_scheme() const OVERRIDE; + std::string display_layout() const OVERRIDE; + smart_objects::SmartObjectSPtr display_capabilities() const OVERRIDE; + smart_objects::SmartObjectSPtr display_capabilities( + const WindowID window_id) const OVERRIDE; + + void set_window_layout(const WindowID window_id, + const std::string& layout) OVERRIDE; + + void set_day_color_scheme( + const WindowID window_id, + const smart_objects::SmartObject& color_scheme) OVERRIDE; + void set_night_color_scheme( + const WindowID window_id, + const smart_objects::SmartObject& color_scheme) OVERRIDE; + + std::string window_layout(const WindowID window_id) const OVERRIDE; + + smart_objects::SmartObject day_color_scheme( + const WindowID window_id) const OVERRIDE; + + smart_objects::SmartObject night_color_scheme( + const WindowID window_id) const OVERRIDE; void load_global_properties(const smart_objects::SmartObject& properties_so); void set_help_prompt(const smart_objects::SmartObject& help_prompt); @@ -120,6 +144,17 @@ class DynamicApplicationDataImpl : public virtual Application { void set_day_color_scheme(const smart_objects::SmartObject& color_scheme); void set_night_color_scheme(const smart_objects::SmartObject& color_scheme); void set_display_layout(const std::string& layout); + void set_display_capabilities( + const smart_objects::SmartObject& display_capabilities) OVERRIDE; + void remove_window_capability(const WindowID window_id) OVERRIDE; + + /** + * @brief checks whether a specific menu layout is supported + * @param menu layout to check + */ + bool menu_layout_supported( + const mobile_apis::MenuLayout::eType layout) const OVERRIDE; + /* * @brief Adds a command to the in application menu */ @@ -156,6 +191,11 @@ class DynamicApplicationDataImpl : public virtual Application { */ bool IsSubMenuNameAlreadyExist(const std::string& name); + void SetWindowInfo(const WindowID window_id, + const smart_objects::SmartObject& window_info) OVERRIDE; + + void RemoveWindowInfo(const WindowID window_id) OVERRIDE; + /* * @brief Adds a interaction choice set to the application * @@ -221,6 +261,10 @@ class DynamicApplicationDataImpl : public virtual Application { */ inline DataAccessor choice_set_map() const; + DataAccessor window_optional_params_map() const; + + DisplayCapabilitiesBuilder& display_capabilities_builder(); + /* * @brief Sets perform interaction state * @@ -274,9 +318,8 @@ class DynamicApplicationDataImpl : public virtual Application { smart_objects::SmartObject* menu_title_; smart_objects::SmartObject* menu_icon_; smart_objects::SmartObject* tbt_show_command_; - smart_objects::SmartObject* day_color_scheme_; - smart_objects::SmartObject* night_color_scheme_; - std::string display_layout_; + smart_objects::SmartObjectSPtr display_capabilities_; + AppWindowsTemplates window_templates_; CommandsMap commands_; mutable std::shared_ptr commands_lock_ptr_; @@ -287,9 +330,12 @@ class DynamicApplicationDataImpl : public virtual Application { PerformChoiceSetMap performinteraction_choice_set_map_; mutable std::shared_ptr performinteraction_choice_set_lock_ptr_; + WindowParamsMap window_params_map_; + mutable std::shared_ptr window_params_map_lock_ptr_; uint32_t is_perform_interaction_active_; bool is_reset_global_properties_active_; int32_t perform_interaction_mode_; + DisplayCapabilitiesBuilder display_capabilities_builder_; private: void SetGlobalProperties( 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 ff34d2a96a4..27b6c8123ee 100644 --- a/src/components/application_manager/include/application_manager/application_impl.h +++ b/src/components/application_manager/include/application_manager/application_impl.h @@ -33,28 +33,28 @@ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_APPLICATION_IMPL_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_APPLICATION_IMPL_H_ +#include +#include +#include #include #include -#include #include -#include -#include -#include +#include #include "application_manager/application.h" #include "application_manager/application_data_impl.h" -#include "application_manager/usage_statistics.h" #include "application_manager/help_prompt_manager_impl.h" #include "application_manager/hmi_state.h" +#include "application_manager/usage_statistics.h" #include "protocol_handler/protocol_handler.h" -#include "connection_handler/device.h" -#include "utils/lock.h" #include +#include "connection_handler/device.h" #include "utils/custom_string.h" -#include "utils/timer.h" -#include "utils/macro.h" #include "utils/date_time.h" +#include "utils/lock.h" +#include "utils/macro.h" +#include "utils/timer.h" namespace usage_statistics { @@ -139,7 +139,8 @@ class ApplicationImpl : public virtual Application, void StopStreamingForce(protocol_handler::ServiceType service_type); void StopStreaming(protocol_handler::ServiceType service_type); void SuspendStreaming(protocol_handler::ServiceType service_type); - void WakeUpStreaming(protocol_handler::ServiceType service_type); + void WakeUpStreaming(protocol_handler::ServiceType service_type, + uint32_t timer_len = 0); virtual bool is_voice_communication_supported() const; virtual void set_voice_communication_supported( @@ -158,11 +159,13 @@ class ApplicationImpl : public virtual Application, bool is_media_application() const; bool is_foreground() const OVERRIDE; void set_foreground(const bool is_foreground) OVERRIDE; - const mobile_apis::HMILevel::eType hmi_level() const; + const mobile_apis::HMILevel::eType hmi_level( + const WindowID window_id) const OVERRIDE; const uint32_t put_file_in_none_count() const; const uint32_t delete_file_in_none_count() const; const uint32_t list_files_in_none_count() const; - const mobile_api::SystemContext::eType system_context() const; + const mobile_api::SystemContext::eType system_context( + const WindowID window_id) const OVERRIDE; inline const mobile_apis::AudioStreamingState::eType audio_streaming_state() const; inline const mobile_apis::VideoStreamingState::eType video_streaming_state() @@ -229,6 +232,8 @@ class ApplicationImpl : public virtual Application, bool IsSubscribedToButton(mobile_apis::ButtonName::eType btn_name); bool UnsubscribeFromButton(mobile_apis::ButtonName::eType btn_name); + WindowID GetSoftButtonWindowID(const uint32_t button_id) OVERRIDE; + inline bool IsRegistered() const OVERRIDE; /** @@ -279,6 +284,9 @@ class ApplicationImpl : public virtual Application, virtual bool is_application_data_changed() const; + bool is_app_data_resumption_allowed() const OVERRIDE; + void set_app_data_resumption_allowance(const bool allowed) OVERRIDE; + virtual void set_is_application_data_changed(bool state_application_data); /** @@ -299,26 +307,35 @@ class ApplicationImpl : public virtual Application, /** * @brief SetInitialState sets initial HMI state for application on * registration + * @param window_id window id for HMI state + * @param window_name name of inited window * @param state Hmi state value */ - void SetInitialState(HmiStatePtr state) FINAL; + void SetInitialState(const WindowID window_id, + const std::string& window_name, + HmiStatePtr state) FINAL; /** - * @brief SetRegularState set permanent state of application - * - * @param state state to setup - */ - virtual void SetRegularState(HmiStatePtr state); + * @brief SetRegularState set permanent state of application + * @param window_id window id for HMI state + * @param state state to setup + */ + void SetRegularState(const WindowID window_id, HmiStatePtr state) FINAL; /** - * @brief SetPostponedState sets postponed state to application. - * This state could be set as regular later - * - * @param state state to setup - */ - virtual void SetPostponedState(HmiStatePtr state); + * @brief SetPostponedState sets postponed state to application. + * This state could be set as regular later + * @param window_id window id for HMI state + * @param state state to setup + */ + void SetPostponedState(const WindowID window_id, HmiStatePtr state) FINAL; - virtual void RemovePostponedState(); + /** + * @brief RemovePostponedState removes postponed state for application + * After removal, this state will not be set as regular later + * @param window_id window id for HMI state + */ + void RemovePostponedState(const WindowID window_id) FINAL; /** * @brief AddHMIState the function that will change application's @@ -328,7 +345,7 @@ class ApplicationImpl : public virtual Application, * * @param state new hmi state for certain application. */ - virtual void AddHMIState(HmiStatePtr state); + void AddHMIState(const WindowID window_id, HmiStatePtr state) FINAL; /** * @brief RemoveHMIState the function that will turn back hmi_level after end @@ -338,13 +355,20 @@ class ApplicationImpl : public virtual Application, * * @param state_id that should be removed */ - virtual void RemoveHMIState(HmiState::StateID state_id); + void RemoveHMIState(const WindowID window_id, + HmiState::StateID state_id) FINAL; /** * @brief HmiState of application within active events PhoneCall, TTS< etc ... * @return Active HmiState of application */ - virtual const HmiStatePtr CurrentHmiState() const; + const HmiStatePtr CurrentHmiState(const WindowID window_i) const FINAL; + + WindowNames GetWindowNames() const FINAL; + + WindowIds GetWindowIds() const FINAL; + + bool WindowIdExists(const WindowID window_id) const FINAL; /** * @brief Checks if app is allowed to change audio source @@ -356,7 +380,7 @@ class ApplicationImpl : public virtual Application, * @brief RegularHmiState of application without active events VR, TTS etc ... * @return HmiState of application */ - virtual const HmiStatePtr RegularHmiState() const; + const HmiStatePtr RegularHmiState(const WindowID window_id) const FINAL; /** * @brief PostponedHmiState returns postponed hmi state of application @@ -364,7 +388,7 @@ class ApplicationImpl : public virtual Application, * * @return Postponed hmi state of application */ - virtual const HmiStatePtr PostponedHmiState() const; + const HmiStatePtr PostponedHmiState(const WindowID window_id) const FINAL; uint32_t audio_stream_retry_number() const; @@ -391,6 +415,7 @@ class ApplicationImpl : public virtual Application, * @param system_context new system context */ void set_system_context( + const WindowID window_id, const mobile_api::SystemContext::eType& system_context) OVERRIDE; /** * @brief Sets current audio streaming state @@ -402,7 +427,8 @@ class ApplicationImpl : public virtual Application, * @brief Sets current HMI level * @param hmi_level new HMI level */ - void set_hmi_level(const mobile_api::HMILevel::eType& hmi_level) OVERRIDE; + void set_hmi_level(const WindowID window_id, + const mobile_api::HMILevel::eType& hmi_level) OVERRIDE; void PushMobileMessage( smart_objects::SmartObjectSPtr mobile_message) OVERRIDE; @@ -475,6 +501,11 @@ class ApplicationImpl : public virtual Application, */ void set_cloud_app_certificate(const std::string& certificate) OVERRIDE; + void set_user_location( + const smart_objects::SmartObject& user_location) OVERRIDE; + + const smart_objects::SmartObject& get_user_location() const OVERRIDE; + protected: /** * @brief Clean up application folder. Persistent files will stay @@ -546,6 +577,7 @@ class ApplicationImpl : public virtual Application, sync_primitives::Lock streaming_stop_lock_; bool is_app_allowed_; + bool is_app_data_resumption_allowed_; bool has_been_activated_; bool tts_properties_in_none_; bool tts_properties_in_full_; @@ -585,6 +617,7 @@ class ApplicationImpl : public virtual Application, std::string cloud_transport_type_; mobile_apis::HybridAppPreference::eType hybrid_app_preference_; std::string certificate_; + smart_objects::SmartObject user_location_; /** * @brief Defines number per time in seconds limits @@ -632,7 +665,8 @@ uint32_t ApplicationImpl::app_id() const { const mobile_api::AudioStreamingState::eType ApplicationImpl::audio_streaming_state() const { using namespace mobile_apis; - const HmiStatePtr hmi_state = CurrentHmiState(); + const HmiStatePtr hmi_state = + CurrentHmiState(mobile_apis::PredefinedWindows::DEFAULT_WINDOW); return hmi_state ? hmi_state->audio_streaming_state() : AudioStreamingState::INVALID_ENUM; } @@ -640,7 +674,8 @@ ApplicationImpl::audio_streaming_state() const { const mobile_api::VideoStreamingState::eType ApplicationImpl::video_streaming_state() const { using namespace mobile_apis; - const HmiStatePtr hmi_state = CurrentHmiState(); + const HmiStatePtr hmi_state = + CurrentHmiState(mobile_apis::PredefinedWindows::DEFAULT_WINDOW); return hmi_state ? hmi_state->video_streaming_state() : VideoStreamingState::INVALID_ENUM; } 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 738458ef267..e88c954c189 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 @@ -34,41 +34,44 @@ #define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_APPLICATION_MANAGER_IMPL_H_ #include -#include -#include -#include -#include #include +#include +#include #include +#include +#include -#include "application_manager/application_manager.h" +#include "application_manager/app_launch/app_launch_data.h" #include "application_manager/app_service_manager.h" +#include "application_manager/application_manager.h" +#include "application_manager/application_manager_settings.h" +#include "application_manager/command_factory.h" +#include "application_manager/command_holder.h" +#include "application_manager/event_engine/event_dispatcher_impl.h" #include "application_manager/hmi_capabilities.h" +#include "application_manager/hmi_interfaces_impl.h" #include "application_manager/message.h" #include "application_manager/message_helper.h" #include "application_manager/request_controller.h" #include "application_manager/resumption/resume_ctrl.h" -#include "application_manager/state_controller_impl.h" -#include "application_manager/app_launch/app_launch_data.h" -#include "application_manager/application_manager_settings.h" -#include "application_manager/event_engine/event_dispatcher_impl.h" -#include "application_manager/hmi_interfaces_impl.h" -#include "application_manager/command_holder.h" -#include "application_manager/command_factory.h" +#include "application_manager/rpc_handler.h" #include "application_manager/rpc_service.h" +#include "application_manager/state_controller_impl.h" + #include "application_manager/rpc_handler.h" -#include "protocol_handler/protocol_observer.h" -#include "protocol_handler/protocol_handler.h" -#include "hmi_message_handler/hmi_message_observer.h" -#include "hmi_message_handler/hmi_message_sender.h" #include "application_manager/policies/policy_handler_interface.h" #include "application_manager/policies/policy_handler_observer.h" #include "connection_handler/connection_handler.h" #include "connection_handler/connection_handler_observer.h" #include "connection_handler/device.h" #include "formatters/CSmartFactory.h" +#include "hmi_message_handler/hmi_message_observer.h" +#include "hmi_message_handler/hmi_message_sender.h" #include "policies/policy_handler.h" +#include "protocol_handler/protocol_handler.h" +#include "protocol_handler/protocol_observer.h" +#include "protocol_handler/service_status_update_handler_listener.h" #include "interfaces/HMI_API.h" #include "interfaces/HMI_API_schema.h" @@ -88,14 +91,14 @@ #include "utils/macro.h" +#include "smart_objects/smart_object.h" +#include "utils/data_accessor.h" +#include "utils/lock.h" #include "utils/message_queue.h" #include "utils/prioritized_queue.h" -#include "utils/threads/thread.h" #include "utils/threads/message_loop_thread.h" -#include "utils/lock.h" -#include "utils/data_accessor.h" +#include "utils/threads/thread.h" #include "utils/timer.h" -#include "smart_objects/smart_object.h" struct BsonObject; @@ -132,16 +135,17 @@ typedef std::shared_ptr TimerSPtr; class ApplicationManagerImpl : public ApplicationManager, public connection_handler::ConnectionHandlerObserver, - public policy::PolicyHandlerObserver + public policy::PolicyHandlerObserver, + public protocol_handler::ServiceStatusUpdateHandlerListener #ifdef ENABLE_SECURITY - , + , public security_manager::SecurityManagerListener #endif // ENABLE_SECURITY #ifdef TELEMETRY_MONITOR - , + , public telemetry_monitor::TelemetryObservable #endif // TELEMETRY_MONITOR - { +{ friend class ResumeCtrl; friend class CommandImpl; @@ -166,6 +170,7 @@ class ApplicationManagerImpl DataAccessor applications() const OVERRIDE; DataAccessor pending_applications() const OVERRIDE; + DataAccessor reregister_applications() const OVERRIDE; ApplicationSharedPtr application(uint32_t app_id) const OVERRIDE; ApplicationSharedPtr active_application() const OVERRIDE; @@ -178,6 +183,8 @@ class ApplicationManagerImpl const std::string& app_name) const OVERRIDE; ApplicationSharedPtr pending_application_by_policy_id( const std::string& policy_app_id) const OVERRIDE; + ApplicationSharedPtr reregister_application_by_policy_id( + const std::string& policy_app_id) const OVERRIDE; std::vector applications_by_button( uint32_t button) OVERRIDE; @@ -203,9 +210,6 @@ class ApplicationManagerImpl mobile_apis::HMILevel::eType from, mobile_apis::HMILevel::eType to) OVERRIDE; - void SendHMIStatusNotification( - const std::shared_ptr app) OVERRIDE; - void SendDriverDistractionState(ApplicationSharedPtr application); void SendGetIconUrlNotifications(const uint32_t connection_key, @@ -288,8 +292,7 @@ class ApplicationManagerImpl * @param vehicle_info Enum value of type of vehicle data * @param new value (for integer values currently) of vehicle data */ - void IviInfoUpdated(mobile_apis::VehicleDataType::eType vehicle_info, - int value) OVERRIDE; + void IviInfoUpdated(const std::string& vehicle_info, int value) OVERRIDE; void OnApplicationRegistered(ApplicationSharedPtr app) OVERRIDE; @@ -324,8 +327,9 @@ class ApplicationManagerImpl void SetTelemetryObserver(AMTelemetryObserver* observer) OVERRIDE; #endif // TELEMETRY_MONITOR - ApplicationSharedPtr RegisterApplication(const std::shared_ptr< - smart_objects::SmartObject>& request_for_registration) OVERRIDE; + ApplicationSharedPtr RegisterApplication( + const std::shared_ptr& + request_for_registration) OVERRIDE; /* * @brief Closes application by id * @@ -342,9 +346,9 @@ class ApplicationManagerImpl bool is_unexpected_disconnect = false) OVERRIDE; /** - * @brief Handle sequence for unauthorized application - * @param app_id Application id - */ + * @brief Handle sequence for unauthorized application + * @param app_id Application id + */ void OnAppUnauthorized(const uint32_t& app_id) OVERRIDE; /* @@ -475,6 +479,7 @@ class ApplicationManagerImpl /** * @brief CreateRegularState create regular HMI state for application * @param app Application + * @param window_type type of window * @param hmi_level of returned state * @param audio_state of returned state * @param system_context of returned state @@ -482,16 +487,17 @@ class ApplicationManagerImpl */ HmiStatePtr CreateRegularState( std::shared_ptr app, - mobile_apis::HMILevel::eType hmi_level, - mobile_apis::AudioStreamingState::eType audio_state, - mobile_apis::VideoStreamingState::eType video_state, - mobile_apis::SystemContext::eType system_context) const OVERRIDE; + const mobile_apis::WindowType::eType window_type, + const mobile_apis::HMILevel::eType hmi_level, + const mobile_apis::AudioStreamingState::eType audio_state, + const mobile_apis::VideoStreamingState::eType video_state, + const 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 * @param app Application - * @param hmi_level Current HMI level of application + * @param window_id id of application's window * @param function_id FunctionID of RPC * @param params_permissions Permissions for RPC parameters (e.g. * SubscribeVehicleData) defined in policy table @@ -499,6 +505,7 @@ class ApplicationManagerImpl */ mobile_apis::Result::eType CheckPolicyPermissions( const ApplicationSharedPtr app, + const WindowID window_id, const std::string& function_id, const RPCParams& rpc_params, CommandParametersPermissions* params_permissions = NULL) OVERRIDE; @@ -516,32 +523,6 @@ class ApplicationManagerImpl bool IsApplicationForbidden(uint32_t connection_key, const std::string& mobile_app_id); - struct ApplicationsAppIdSorter { - bool operator()(const ApplicationSharedPtr lhs, - const ApplicationSharedPtr rhs) { - return lhs->app_id() < rhs->app_id(); - } - }; - - struct ApplicationsMobileAppIdSorter { - bool operator()(const ApplicationSharedPtr lhs, - const ApplicationSharedPtr rhs) { - if (lhs->policy_app_id() == rhs->policy_app_id()) { - return lhs->device() < rhs->device(); - } - return lhs->policy_app_id() < rhs->policy_app_id(); - } - }; - - // typedef for Applications list - typedef std::set ApplictionSet; - - // typedef for Applications list iterator - typedef ApplictionSet::iterator ApplictionSetIt; - - // typedef for Applications list const iterator - typedef ApplictionSet::const_iterator ApplictionSetConstIt; - /** * @brief Notification from PolicyHandler about PTU. * Compares AppHMIType between saved in app and received from PTU. If they are @@ -563,6 +544,52 @@ class ApplicationManagerImpl */ void OnPTUFinished(const bool ptu_result) FINAL; +#if defined(EXTERNAL_PROPRIETARY_MODE) && defined(ENABLE_SECURITY) + /** + * @brief OnCertDecryptFailed is called when certificate decryption fails in + * external flow + * @return since this callback is a part of SecurityManagerListener, bool + * return value is used to indicate whether listener instance can be deleted + * by calling entity. if true - listener can be deleted and removed from + * listeners by SecurityManager, false - listener retains its place within + * SecurityManager. + */ + bool OnCertDecryptFailed() FINAL; + + /** + * @brief OnCertDecryptFinished is called when certificate decryption is + * finished in the external flow + * @param decrypt_result bool value indicating whether decryption was + * successful + */ + void OnCertDecryptFinished(const bool decrypt_result) FINAL; +#endif + + /** + * @brief OnPTUTimeoutExceeded is called on policy table update timed out + */ + void OnPTUTimeoutExceeded() FINAL; + + /** + *@brief ProcessServiceStatusUpdate callback that is invoked in case of + *service status update + *@param connection_key - connection key + *@param service_type enum value containing type of service. + *@param service_event enum value containing event that occured during service + *start. + *@param service_update_reason enum value containing reason why service_event + *occured. + **/ + void ProcessServiceStatusUpdate( + const uint32_t connection_key, + hmi_apis::Common_ServiceType::eType service_type, + hmi_apis::Common_ServiceEvent::eType service_event, + utils::Optional + service_update_reason) FINAL; + +#ifdef ENABLE_SECURITY + bool OnPTUFailed() FINAL; +#endif // ENABLE_SECURITY /* * @brief Starts audio pass thru thread * @@ -682,7 +709,7 @@ class ApplicationManagerImpl * @brief Notification about handshake failure * @return true on success notification handling or false otherwise */ - bool OnHandshakeFailed() OVERRIDE; + bool OnGetSystemTimeFailed() OVERRIDE; /** * @brief Notification that certificate update is required. @@ -827,9 +854,9 @@ class ApplicationManagerImpl ApplicationConstSharedPtr application) const; /** - * Getter for resume_controller - * @return Resume Controller - */ + * Getter for resume_controller + * @return Resume Controller + */ resumption::ResumeCtrl& resume_controller() OVERRIDE { return *resume_ctrl_.get(); } @@ -998,8 +1025,7 @@ class ApplicationManagerImpl AppV4DevicePredicate(const connection_handler::DeviceHandle handle) : handle_(handle) {} bool operator()(const ApplicationSharedPtr app) const { - return app - ? handle_ == app->device() && + return app ? handle_ == app->device() && Message::is_sufficient_version( protocol_handler::MajorProtocolVersion:: PROTOCOL_VERSION_4, @@ -1065,24 +1091,26 @@ class ApplicationManagerImpl * @brief IsAppInReconnectMode check if application belongs to session * affected by transport switching at the moment by checking internal * waiting list prepared on switching start + * @param device_id device identifier * @param policy_app_id Application id * @return True if application is in the waiting list, otherwise - false */ - bool IsAppInReconnectMode(const std::string& policy_app_id) const FINAL; + bool IsAppInReconnectMode(const connection_handler::DeviceHandle& device_id, + const std::string& policy_app_id) const FINAL; bool IsStopping() const OVERRIDE { return is_stopping_; } /** - * @brief ProcessReconnection handles reconnection flow for application on - * transport switch - * @param application Pointer to switched application, must be validated - * before passing - * @param connection_key Connection key from registration request of - * switched - * application - */ + * @brief ProcessReconnection handles reconnection flow for application on + * transport switch + * @param application Pointer to switched application, must be validated + * before passing + * @param connection_key Connection key from registration request of + * switched + * application + */ void ProcessReconnection(ApplicationSharedPtr application, const uint32_t connection_key) FINAL; @@ -1109,6 +1137,14 @@ class ApplicationManagerImpl protocol_handler::MajorProtocolVersion SupportedSDLVersion() const OVERRIDE; private: + /** + * @brief Removes service status record for service that failed to start + * @param app Application whose service status record should be removed + * @param Service type which status record should be removed + */ + bool HandleRejectedServiceStatus( + ApplicationSharedPtr app, + const hmi_apis::Common_ServiceType::eType service_type); /** * @brief PullLanguagesInfo allows to pull information about languages. * @@ -1411,12 +1447,14 @@ class ApplicationManagerImpl ApplicationSet applications_; AppsWaitRegistrationSet apps_to_register_; ForbiddenApps forbidden_applications; + ReregisterWaitList reregister_wait_list_; // Lock for applications list mutable std::shared_ptr applications_list_lock_ptr_; mutable std::shared_ptr apps_to_register_list_lock_ptr_; + mutable std::shared_ptr reregister_wait_list_lock_ptr_; mutable sync_primitives::Lock subscribed_way_points_apps_lock_; /** @@ -1452,8 +1490,8 @@ class ApplicationManagerImpl connection_handler::ConnectionHandler* connection_handler_; std::unique_ptr policy_handler_; protocol_handler::ProtocolHandler* protocol_handler_; - request_controller::RequestController request_ctrl_; std::unique_ptr plugin_manager_; + request_controller::RequestController request_ctrl_; std::unique_ptr app_service_manager_; /** @@ -1508,15 +1546,6 @@ class ApplicationManagerImpl std::unique_ptr app_launch_dto_; std::unique_ptr app_launch_ctrl_; - /** - * @brief ReregisterWaitList is list of applications expected to be - * re-registered after transport switching is complete - */ - typedef std::vector ReregisterWaitList; - ReregisterWaitList reregister_wait_list_; - - mutable sync_primitives::Lock reregister_wait_list_lock_; - // This is a cache to remember DeviceHandle of secondary transports. Only used // during RegisterApplication(). typedef std::map DeviceMap; diff --git a/src/components/application_manager/include/application_manager/application_state.h b/src/components/application_manager/include/application_manager/application_state.h index bf894eaf943..8c4d2d49d67 100644 --- a/src/components/application_manager/include/application_manager/application_state.h +++ b/src/components/application_manager/include/application_manager/application_state.h @@ -32,14 +32,21 @@ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_APPLICATION_STATE_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_APPLICATION_STATE_H_ + +#include #include + +#include "application_manager/hmi_state.h" #include "utils/lock.h" #include "utils/macro.h" -#include "application_manager/hmi_state.h" namespace application_manager { +typedef std::vector WindowIds; typedef std::vector HmiStates; +typedef std::map HmiStatesMap; +typedef std::vector WindowNames; +typedef std::map WindowNamesMap; /* * Class represents application state, i.e. current HMI level, audio streaming @@ -63,97 +70,140 @@ class ApplicationState { /** * @brief Init state + * @param window_id window id for HMI state + * @param window_name name of inited window * @param state Initial state */ - void InitState(HmiStatePtr state); + void InitState(const WindowID window_id, + const std::string& window_name, + HmiStatePtr state); /** * @brief Adds state to states storage + * @param window_id window id for HMI state * @param state State of application */ - void AddState(HmiStatePtr state); + void AddState(const WindowID window_id, HmiStatePtr state); /** * @brief Removes state from states storage + * @param window_id window id for HMI state * @param state State of application */ - void RemoveState(HmiState::StateID state); + void RemoveState(const WindowID window_id, HmiState::StateID state); /** * @brief Gets state by state id + * @param window_id window id for HMI state * @param state_id State id * @return Pointer to application state */ - HmiStatePtr GetState(HmiState::StateID state_id) const; + HmiStatePtr GetState(const WindowID window_id, + HmiState::StateID state_id) const; + + /** + * @brief Gets the list of all states matches provided state id + * @param state_id state id to get + * @return list of all states matches provided state id + */ + HmiStates GetStates(const HmiState::StateID state_id) const; + + /** + * @brief Getter for a list of available application windows including the + * main + * @return list of available window ids + */ + WindowIds GetWindowIds() const; + + /** + * @brief Getter f0r a list of all existing window names + * @return list of available window names + */ + WindowNames GetWindowNames() const; private: /** * @brief AddHMIState the function that will change application's * hmi state. * - * @param app_id id of the application whose hmi level should be changed. + * @param window_id window id for HMI state * * @param state new hmi state for certain application. */ - void AddHMIState(HmiStatePtr state); + void AddHMIState(const WindowID window_id, HmiStatePtr state); /** * @brief RemoveHMIState the function that will turn back hmi_level after end * of some event * - * @param app_id id of the application whose hmi level should be changed. + * @param window_id window id for HMI state. * * @param state_id that should be removed */ - void RemoveHMIState(HmiState::StateID state_id); + void RemoveHMIState(const WindowID window_id, HmiState::StateID state_id); + + /** + * @brief RemoveWindowHMIStates removes all HMI states related to specified + * window + * @param window_id window ID to remove + */ + void RemoveWindowHMIStates(const WindowID window_id); /** * @brief Removes postponed state + * @param window_id window id for HMI state */ - void RemovePostponedState(); + void RemovePostponedState(const WindowID window_id); /** * @brief Sets regular state of application + * @param window_id window id for HMI state * @param state State of application */ - void SetRegularState(HmiStatePtr state); + void SetRegularState(const WindowID window_id, HmiStatePtr state); /** - * @brief Sets postponed state of application. - * This state could be set as regular later on - * - * @param state state to setup - */ - void SetPostponedState(HmiStatePtr state); + * @brief Sets postponed state of application. + * This state could be set as regular later on + * @param window_id window id for HMI state + * @param state state to setup + */ + void SetPostponedState(const WindowID window_id, HmiStatePtr state); /** * @brief HmiState of application within active events PhoneCall, TTS< etc ... + * @param window_id window id for HMI state * @return Active HmiState of application */ - HmiStatePtr CurrentHmiState() const; + HmiStatePtr CurrentHmiState(const WindowID window_id) const; /** * @brief RegularHmiState of application without active events VR, TTS etc ... + * @param window_id window id for HMI state * @return HmiState of application */ - HmiStatePtr RegularHmiState() const; + HmiStatePtr RegularHmiState(const WindowID window_id) const; /** * @brief PostponedHmiState returns postponed hmi state of application * if it's present - * + * @param window_id window id for HMI state * @return Postponed hmi state of application */ - HmiStatePtr PostponedHmiState() const; + HmiStatePtr PostponedHmiState(const WindowID window_id) const; /** * @brief Active states of application */ - HmiStates hmi_states_; - mutable sync_primitives::Lock hmi_states_lock_; + HmiStatesMap hmi_states_map_; + + /** + * @brief hmi_states_map_lock_ + */ + mutable sync_primitives::Lock hmi_states_map_lock_; DISALLOW_COPY_AND_ASSIGN(ApplicationState); }; -} +} // namespace application_manager #endif // SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_APPLICATION_STATE_H_ 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 7dc8a0cfc1e..f479ee7f370 100644 --- a/src/components/application_manager/include/application_manager/command_factory.h +++ b/src/components/application_manager/include/application_manager/command_factory.h @@ -33,10 +33,11 @@ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_COMMAND_FACTORY_H #define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_COMMAND_FACTORY_H -#include "application_manager/commands/command.h" #include "application_manager/application_manager.h" -#include "application_manager/rpc_service.h" +#include "application_manager/commands/command.h" +#include "application_manager/hmi_capabilities.h" #include "application_manager/policies/policy_handler_interface.h" +#include "application_manager/rpc_service.h" #include "utils/macro.h" namespace application_manager { @@ -63,10 +64,10 @@ class CommandFactory { const commands::MessageSharedPtr& message, commands::Command::CommandSource source) = 0; /** - * @param int32_t command id - * @param CommandSource source - * @return return true if command can be create, else return false - **/ + * @param int32_t command id + * @param CommandSource source + * @return return true if command can be create, else return false + **/ virtual bool IsAbleToProcess( const int32_t, const application_manager::commands::Command::CommandSource source) diff --git a/src/components/application_manager/include/application_manager/command_holder.h b/src/components/application_manager/include/application_manager/command_holder.h index 8cfe5f0889f..3f5f657a0e0 100644 --- a/src/components/application_manager/include/application_manager/command_holder.h +++ b/src/components/application_manager/include/application_manager/command_holder.h @@ -35,6 +35,7 @@ #include #include "application_manager/application.h" +#include "application_manager/commands/command.h" #include "smart_objects/smart_object.h" namespace application_manager { @@ -59,10 +60,12 @@ class CommandHolder { * internally * @param application Application pointer * @param type Command type + * @param source The source of suspended command * @param command Command */ virtual void Suspend(ApplicationSharedPtr application, CommandType type, + commands::Command::CommandSource source, smart_objects::SmartObjectSPtr command) = 0; /** diff --git a/src/components/application_manager/include/application_manager/command_holder_impl.h b/src/components/application_manager/include/application_manager/command_holder_impl.h index 18a1de7526c..530aae47d28 100644 --- a/src/components/application_manager/include/application_manager/command_holder_impl.h +++ b/src/components/application_manager/include/application_manager/command_holder_impl.h @@ -35,9 +35,9 @@ #include "application_manager/command_holder.h" +#include #include #include -#include #include "application_manager/application.h" #include "application_manager/rpc_service.h" #include "smart_objects/smart_object.h" @@ -64,10 +64,12 @@ class CommandHolderImpl : public CommandHolder { * @brief Suspend collects command for specific application id internally * @param application Application pointer * @param type Command type + * @param source The source of suspended command * @param command Command */ void Suspend(ApplicationSharedPtr application, CommandType type, + commands::Command::CommandSource source, smart_objects::SmartObjectSPtr command) FINAL; /** @@ -97,9 +99,17 @@ class CommandHolderImpl : public CommandHolder { */ void ResumeMobileCommand(ApplicationSharedPtr application); + /** + * @brief Descriptor of each suspended command containing all necessary + * command info + */ + struct AppCommandInfo { + std::shared_ptr command_ptr_; + commands::Command::CommandSource command_source_; + }; + using AppCommands = - std::map > >; + std::map >; ApplicationManager& app_manager_; sync_primitives::Lock commands_lock_; diff --git a/src/components/application_manager/include/application_manager/commands/command.h b/src/components/application_manager/include/application_manager/commands/command.h index d832995b8da..0536c7aee1f 100644 --- a/src/components/application_manager/include/application_manager/commands/command.h +++ b/src/components/application_manager/include/application_manager/commands/command.h @@ -33,6 +33,7 @@ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_COMMANDS_COMMAND_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_COMMANDS_COMMAND_H_ #include +#include "application_manager/hmi_state.h" #include "smart_objects/smart_object.h" namespace application_manager { @@ -92,6 +93,11 @@ class Command { */ virtual int32_t function_id() const = 0; + /* + * @brief Retrieves Window ID + */ + virtual WindowID window_id() const = 0; + /* * @brief Function is called by RequestController when request execution time * has exceed it's limit @@ -100,16 +106,16 @@ class Command { virtual void onTimeOut() = 0; /** - * @brief AllowedToTerminate tells if request controller is allowed - * to terminate this command - * @return - */ + * @brief AllowedToTerminate tells if request controller is allowed + * to terminate this command + * @return + */ virtual bool AllowedToTerminate() = 0; /** - * @brief SetAllowedToTerminate set up allowed to terminate flag. - * If true, request controller will terminate request on response - */ + * @brief SetAllowedToTerminate set up allowed to terminate flag. + * If true, request controller will terminate request on response + */ virtual void SetAllowedToTerminate(const bool allowed) = 0; enum CommandSource { 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 dd1592c4aaf..a526fede6e5 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 @@ -33,9 +33,9 @@ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_COMMANDS_COMMAND_IMPL_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_COMMANDS_COMMAND_IMPL_H_ +#include "application_manager/application_manager.h" #include "application_manager/commands/command.h" #include "application_manager/event_engine/event_observer.h" -#include "application_manager/application_manager.h" #include "application_manager/smart_object_keys.h" #include "policy/policy_types.h" #include "utils/logger.h" @@ -117,6 +117,11 @@ class CommandImpl : public Command { */ int32_t function_id() const OVERRIDE; + /* + * @brief Retrieves Window ID + */ + WindowID window_id() const OVERRIDE; + /* * @brief Function is called by RequestController when request execution time * has exceed it's limit @@ -125,18 +130,19 @@ class CommandImpl : public Command { void onTimeOut() OVERRIDE; /** - * @brief AllowedToTerminate tells request Controller if it can terminate this - * request by response. - * By default, RequestCtrl should terminate all requests by their responses. - * If request need to terminate itself, it should override this function false - * @return allowed_to_terminate_ value - */ + * @brief AllowedToTerminate tells request Controller if it can terminate this + * request by response. + * By default, RequestCtrl should terminate all requests by their responses. + * If request need to terminate itself, it should override this function + * false + * @return allowed_to_terminate_ value + */ bool AllowedToTerminate() OVERRIDE; /** - * @brief SetAllowedToTerminate set up allowed to terminate flag. - * If true, request controller will terminate request on response - */ + * @brief SetAllowedToTerminate set up allowed to terminate flag. + * If true, request controller will terminate request on response + */ void SetAllowedToTerminate(const bool allowed) OVERRIDE; // members 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 e12c6de3abe..293366f91a0 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 @@ -34,10 +34,10 @@ #define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_COMMANDS_COMMAND_REQUEST_IMPL_H_ #include "application_manager/commands/command_impl.h" -#include "interfaces/MOBILE_API.h" #include "interfaces/HMI_API.h" -#include "utils/lock.h" +#include "interfaces/MOBILE_API.h" #include "smart_objects/smart_object.h" +#include "utils/lock.h" namespace application_manager { namespace commands { @@ -214,6 +214,24 @@ class CommandRequestImpl : public CommandImpl, mobile_apis::Result::eType GetMobileResultCode( const hmi_apis::Common_Result::eType& hmi_code) const; + /** + * @brief Checks Mobile result code for single RPC + * @param result_code contains result code from response to Mobile + * @return true if result code complies to successful result codes, + * false otherwise. + */ + static bool IsMobileResultSuccess( + const mobile_apis::Result::eType result_code); + + /** + * @brief Checks HMI result code for single RPC + * @param result_code contains result code from HMI response + * @return true if result code complies to successful result codes, + * false otherwise. + */ + static bool IsHMIResultSuccess( + const hmi_apis::Common_Result::eType result_code); + protected: /** * @brief Checks message permissions and parameters according to policy table @@ -248,14 +266,6 @@ class CommandRequestImpl : public CommandImpl, */ bool HasDisallowedParams() const; - /** - * @brief Checks result code from Mobile for single RPC - * @param result_code contains result code from Mobile response - * @return true if result code complies successful result codes, - * false otherwise. - */ - bool IsMobileResultSuccess(mobile_apis::Result::eType result_code) const; - /** * @brief Checks result code from HMI for single RPC * and returns parameter for sending to mobile app. @@ -317,6 +327,16 @@ class CommandRequestImpl : public CommandImpl, bool IsResultCodeUnsupported(const ResponseInfo& first, const ResponseInfo& second) const; + /** + * @brief CheckResult checks whether the overall result + * of the responses is successful + * @param first response + * @param second response + * @return true if the overall result is successful + * otherwise - false + */ + bool CheckResult(const ResponseInfo& first, const ResponseInfo& second) const; + protected: /** * @brief Returns policy parameters permissions @@ -335,7 +355,7 @@ class CommandRequestImpl : public CommandImpl, * @param interface_id interface which SDL awaits for response in given time * @return true if SDL awaits for response from given interface in * interface_id - */ + */ bool IsInterfaceAwaited(const HmiInterfaces::InterfaceID& interface_id) const; /** @@ -346,7 +366,7 @@ class CommandRequestImpl : public CommandImpl, void EndAwaitForInterface(const HmiInterfaces::InterfaceID& interface_id); /** - * @brief This set stores all the interfaces which are awaited by SDL to + * @brief This set stores all the interfaces which are awaited by SDL to * return a response on some request */ std::set awaiting_response_interfaces_; @@ -387,10 +407,10 @@ class CommandRequestImpl : public CommandImpl, const hmi_apis::FunctionID::eType& function_id); /** - * @brief UpdateHash updates hash field for application and sends - * OnHashChanged notification to mobile side in case of approriate hash mode - * is set - */ + * @brief UpdateHash updates hash field for application and sends + * OnHashChanged notification to mobile side in case of approriate hash mode + * is set + */ void UpdateHash(); /** diff --git a/src/components/application_manager/include/application_manager/commands/command_request_to_mobile.h b/src/components/application_manager/include/application_manager/commands/command_request_to_mobile.h index a1e63561bf4..430e5495234 100644 --- a/src/components/application_manager/include/application_manager/commands/command_request_to_mobile.h +++ b/src/components/application_manager/include/application_manager/commands/command_request_to_mobile.h @@ -33,8 +33,8 @@ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_COMMANDS_COMMAND_REQUEST_TO_MOBILE_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_COMMANDS_COMMAND_REQUEST_TO_MOBILE_H_ -#include "application_manager/commands/command_impl.h" #include "application_manager/application_manager.h" +#include "application_manager/commands/command_impl.h" #include "interfaces/MOBILE_API.h" #include "smart_objects/smart_object.h" diff --git a/src/components/application_manager/include/application_manager/commands/command_response_from_mobile.h b/src/components/application_manager/include/application_manager/commands/command_response_from_mobile.h index 65983d82f81..1401888890d 100644 --- a/src/components/application_manager/include/application_manager/commands/command_response_from_mobile.h +++ b/src/components/application_manager/include/application_manager/commands/command_response_from_mobile.h @@ -33,8 +33,8 @@ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_COMMANDS_COMMAND_RESPONSE_TO_MOBILE_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_COMMANDS_COMMAND_RESPONSE_TO_MOBILE_H_ -#include "application_manager/commands/command_impl.h" #include "application_manager/application_manager.h" +#include "application_manager/commands/command_impl.h" #include "interfaces/MOBILE_API.h" #include "smart_objects/smart_object.h" diff --git a/src/components/application_manager/include/application_manager/commands/pending.h b/src/components/application_manager/include/application_manager/commands/pending.h index bbfc2466592..9083d81d733 100644 --- a/src/components/application_manager/include/application_manager/commands/pending.h +++ b/src/components/application_manager/include/application_manager/commands/pending.h @@ -35,9 +35,9 @@ #define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_COMMANDS_PENDING_H_ #include -#include "utils/macro.h" -#include "utils/lock.h" #include "interfaces/HMI_API.h" +#include "utils/lock.h" +#include "utils/macro.h" namespace application_manager { diff --git a/src/components/application_manager/include/application_manager/commands/request_to_hmi.h b/src/components/application_manager/include/application_manager/commands/request_to_hmi.h index 91586a74cef..e8850fbe8d6 100644 --- a/src/components/application_manager/include/application_manager/commands/request_to_hmi.h +++ b/src/components/application_manager/include/application_manager/commands/request_to_hmi.h @@ -33,8 +33,8 @@ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_COMMANDS_REQUEST_TO_HMI_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_COMMANDS_REQUEST_TO_HMI_H_ -#include "application_manager/commands/command_impl.h" #include "application_manager/application_manager.h" +#include "application_manager/commands/command_impl.h" namespace application_manager { diff --git a/src/components/application_manager/include/application_manager/commands/response_from_hmi.h b/src/components/application_manager/include/application_manager/commands/response_from_hmi.h index 605d04067e2..6c00957d3f6 100644 --- a/src/components/application_manager/include/application_manager/commands/response_from_hmi.h +++ b/src/components/application_manager/include/application_manager/commands/response_from_hmi.h @@ -1,40 +1,40 @@ /* -* 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. -*/ + * Copyright (c) 2018, Ford Motor Company + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following + * disclaimer in the documentation and/or other materials provided with the + * distribution. + * + * Neither the name of the Ford Motor Company nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_COMMANDS_RESPONSE_FROM_HMI_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_COMMANDS_RESPONSE_FROM_HMI_H_ -#include "application_manager/commands/command_impl.h" #include "application_manager/application_manager.h" +#include "application_manager/commands/command_impl.h" #include "interfaces/HMI_API.h" namespace application_manager { diff --git a/src/components/application_manager/include/application_manager/display_capabilities_builder.h b/src/components/application_manager/include/application_manager/display_capabilities_builder.h new file mode 100644 index 00000000000..529c9a32c16 --- /dev/null +++ b/src/components/application_manager/include/application_manager/display_capabilities_builder.h @@ -0,0 +1,96 @@ +/* + * Copyright (c) 2019, 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_DISPLAY_CAPABILITIES_BUILDER_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_DISPLAY_CAPABILITIES_BUILDER_H_ +#include "application_manager/application.h" + +namespace application_manager { +/** + * @brief DisplayCapabilitiesBuilder utility class used for building cached + * notification, which is sent to mobile on resumption finish + */ +class DisplayCapabilitiesBuilder { + typedef std::function + ResumeCallback; + + public: + /** + * @brief DisplayCapabilitiesBuilder class constructor + * @param Application reference to application owner + */ + DisplayCapabilitiesBuilder(Application& application); + + /** + * @brief InitBuilder initialize builder with callback and windows to be + * restored + * @param resume_callback callback to be called when notifications for all + * windows have been received + * @param windows_info SO containing data of windows to be restored + */ + void InitBuilder(ResumeCallback resume_callback, + const smart_objects::SmartObject& windows_info); + + /** + * @brief UpdateDisplayCapabilities update cached notification + * @param display_capabilities to update cached notification with + */ + void UpdateDisplayCapabilities( + const smart_objects::SmartObject& display_capabilities); + + /** + * @brief ResetDisplayCapabilities resets stored notification + */ + void ResetDisplayCapabilities(); + + /** + * @brief StopWaitingForWindow stop waiting for window resumption by removing + * window_id from windows pending resumption + * @param window_id window id to be removed + */ + void StopWaitingForWindow(const WindowID window_id); + + /** + * @brief retreives stored notification data + */ + const smart_objects::SmartObjectSPtr display_capabilities() const; + + private: + smart_objects::SmartObjectSPtr display_capabilities_; + typedef std::set WindowIDsToResume; + WindowIDsToResume window_ids_to_resume_; + Application& owner_; + ResumeCallback resume_callback_; + sync_primitives::Lock display_capabilities_lock_; +}; +} // namespace application_manager +#endif diff --git a/src/components/application_manager/include/application_manager/event_engine/event.h b/src/components/application_manager/include/application_manager/event_engine/event.h index 14595cd293c..e7382e01a40 100644 --- a/src/components/application_manager/include/application_manager/event_engine/event.h +++ b/src/components/application_manager/include/application_manager/event_engine/event.h @@ -36,8 +36,8 @@ #include #include -#include "smart_objects/smart_object.h" #include "application_manager/smart_object_keys.h" +#include "smart_objects/smart_object.h" namespace application_manager { namespace event_engine { diff --git a/src/components/application_manager/include/application_manager/event_engine/event_dispatcher_impl.h b/src/components/application_manager/include/application_manager/event_engine/event_dispatcher_impl.h index 75e77e603cc..36442994993 100644 --- a/src/components/application_manager/include/application_manager/event_engine/event_dispatcher_impl.h +++ b/src/components/application_manager/include/application_manager/event_engine/event_dispatcher_impl.h @@ -33,8 +33,8 @@ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_EVENT_ENGINE_EVENT_DISPATCHER_IMPL_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_EVENT_ENGINE_EVENT_DISPATCHER_IMPL_H_ -#include #include +#include #include "utils/lock.h" diff --git a/src/components/application_manager/include/application_manager/event_engine/event_observer.h b/src/components/application_manager/include/application_manager/event_engine/event_observer.h index 7a7fe7c2ec3..1f4eccaf464 100644 --- a/src/components/application_manager/include/application_manager/event_engine/event_observer.h +++ b/src/components/application_manager/include/application_manager/event_engine/event_observer.h @@ -92,12 +92,6 @@ class EventObserver { */ void unsubscribe_from_event(const Event::EventID& event_id); - /* - * @brief Unsubscribes the observer from all events - * - */ - DEPRECATED void unsubscribe_from_all_events(); - /* * @brief Unsubscribes the observer from all events * diff --git a/src/components/application_manager/include/application_manager/help_prompt_manager.h b/src/components/application_manager/include/application_manager/help_prompt_manager.h index a0c34e77d79..eb45705d9fc 100644 --- a/src/components/application_manager/include/application_manager/help_prompt_manager.h +++ b/src/components/application_manager/include/application_manager/help_prompt_manager.h @@ -28,7 +28,7 @@ * 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_HELP_PROMPT_MANAGER_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_HELP_PROMPT_MANAGER_H_ diff --git a/src/components/application_manager/include/application_manager/help_prompt_manager_impl.h b/src/components/application_manager/include/application_manager/help_prompt_manager_impl.h index 81754a60b0a..3cd22a6afcc 100644 --- a/src/components/application_manager/include/application_manager/help_prompt_manager_impl.h +++ b/src/components/application_manager/include/application_manager/help_prompt_manager_impl.h @@ -28,7 +28,7 @@ * 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_HELP_PROMPT_MANAGER_IMPL_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_HELP_PROMPT_MANAGER_IMPL_H_ @@ -56,7 +56,7 @@ class HelpPromptManagerImpl : public HelpPromptManager { public: /** * @brief Container for buffering VR help commands - */ + */ typedef std::pair VRCommandPair; typedef std::vector VRCommandPairs; @@ -94,12 +94,12 @@ class HelpPromptManagerImpl : public HelpPromptManager { const bool is_resumption) OVERRIDE; /** - * @brief Stop constructing vrHelp and/or helpPrompt if they are present in - * message - * @param msg containing GlobalProperties - * @param is_response determines is the request or response for the for - * the SetGlobalPropertiesRequest - */ + * @brief Stop constructing vrHelp and/or helpPrompt if they are present in + * message + * @param msg containing GlobalProperties + * @param is_response determines is the request or response for the for + * the SetGlobalPropertiesRequest + */ void OnSetGlobalPropertiesReceived(const smart_objects::SmartObject& msg, const bool is_response) OVERRIDE; diff --git a/src/components/application_manager/include/application_manager/helpers/application_helper.h b/src/components/application_manager/include/application_manager/helpers/application_helper.h index 18267c9e7f3..a7933c2451e 100644 --- a/src/components/application_manager/include/application_manager/helpers/application_helper.h +++ b/src/components/application_manager/include/application_manager/helpers/application_helper.h @@ -69,6 +69,19 @@ ApplicationSharedPtr FindPendingApp( return app; } +template +ApplicationSharedPtr FindReregisterApp( + DataAccessor accessor, UnaryPredicate finder) { + ReregisterWaitList::const_iterator begin = accessor.GetData().begin(); + ReregisterWaitList::const_iterator end = accessor.GetData().end(); + ReregisterWaitList::const_iterator it = std::find_if(begin, end, finder); + if (accessor.GetData().end() == it) { + return ApplicationSharedPtr(); + } + ApplicationSharedPtr app = *it; + return app; +} + /** * Helper function for lookup through applications list and returning all * applications satisfying predicate logic diff --git a/src/components/application_manager/include/application_manager/hmi_capabilities_impl.h b/src/components/application_manager/include/application_manager/hmi_capabilities_impl.h index 9380fb41ac0..b4610f0375f 100644 --- a/src/components/application_manager/include/application_manager/hmi_capabilities_impl.h +++ b/src/components/application_manager/include/application_manager/hmi_capabilities_impl.h @@ -28,18 +28,18 @@ * 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_HMI_CAPABILITIES_IMPL_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_HMI_CAPABILITIES_IMPL_H_ #include "application_manager/hmi_capabilities.h" +#include "application_manager/hmi_language_handler.h" #include "interfaces/HMI_API.h" #include "interfaces/MOBILE_API.h" #include "json/json.h" -#include "utils/macro.h" -#include "application_manager/hmi_language_handler.h" #include "smart_objects/smart_object.h" +#include "utils/macro.h" namespace resumption { class LastState; @@ -229,6 +229,20 @@ class HMICapabilitiesImpl : public HMICapabilities { void set_display_capabilities( const smart_objects::SmartObject& display_capabilities) OVERRIDE; + /* + * @brief Retrieves information about the display capability + * @return Currently supported display capability + */ + const smart_objects::SmartObjectSPtr system_display_capabilities() + const OVERRIDE; + + /* + * @brief Sets supported display capability + * @param display_capabilities supported display capability + */ + void set_system_display_capabilities( + const smart_objects::SmartObject& display_capabilities); + /* * @brief Retrieves information about the HMI zone capabilities * @@ -493,6 +507,11 @@ class HMICapabilitiesImpl : public HMICapabilities { const smart_objects::SmartObject* rc_capability() const OVERRIDE; + void set_seat_location_capability( + const smart_objects::SmartObject& seat_location_capability) OVERRIDE; + + const smart_objects::SmartObject* seat_location_capability() const OVERRIDE; + void Init(resumption::LastState* last_state) OVERRIDE; /* @@ -542,6 +561,18 @@ class HMICapabilitiesImpl : public HMICapabilities { const Json::Value& json_languages, smart_objects::SmartObject& languages) const OVERRIDE; + /* + * @brief function that converts a single entry of audio pass thru capability + * to smart object + * + * @param capability json object that represents a single entry of audio pass + * thru capability + * @param output_so the converted object + */ + void convert_audio_capability_to_obj( + const Json::Value& capability, + smart_objects::SmartObject& output_so) const OVERRIDE; + private: bool is_vr_cooperating_; bool is_tts_cooperating_; @@ -558,7 +589,13 @@ class HMICapabilitiesImpl : public HMICapabilities { smart_objects::SmartObject* ui_supported_languages_; smart_objects::SmartObject* tts_supported_languages_; smart_objects::SmartObject* vr_supported_languages_; + /* + * display_capabilities_ is deprecated and replaced by + * system_display_capabilities_. For backward compatibility + * display_capabilities_ is not removed. + */ smart_objects::SmartObject* display_capabilities_; + smart_objects::SmartObjectSPtr system_display_capabilities_; smart_objects::SmartObject* hmi_zone_capabilities_; smart_objects::SmartObject* soft_buttons_capabilities_; smart_objects::SmartObject* button_capabilities_; @@ -577,6 +614,7 @@ class HMICapabilitiesImpl : public HMICapabilities { smart_objects::SmartObject* phone_capability_; smart_objects::SmartObject* video_streaming_capability_; smart_objects::SmartObject* rc_capability_; + smart_objects::SmartObject* seat_location_capability_; ApplicationManager& app_mngr_; HMILanguageHandler hmi_language_handler_; diff --git a/src/components/application_manager/include/application_manager/hmi_interfaces_impl.h b/src/components/application_manager/include/application_manager/hmi_interfaces_impl.h index 2b2d1e1361d..3202d44e1e8 100644 --- a/src/components/application_manager/include/application_manager/hmi_interfaces_impl.h +++ b/src/components/application_manager/include/application_manager/hmi_interfaces_impl.h @@ -34,8 +34,8 @@ #define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_HMI_INTERFACES_IMPL_H_ #include #include "application_manager/hmi_interfaces.h" -#include "utils/macro.h" #include "utils/lock.h" +#include "utils/macro.h" /** * @brief The HmiInterfacesImpl class handles * hmi interfaces states diff --git a/src/components/application_manager/include/application_manager/hmi_language_handler.h b/src/components/application_manager/include/application_manager/hmi_language_handler.h index 6158cb4585f..edf07591149 100644 --- a/src/components/application_manager/include/application_manager/hmi_language_handler.h +++ b/src/components/application_manager/include/application_manager/hmi_language_handler.h @@ -28,15 +28,15 @@ * 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_HMI_LANGUAGE_HANDLER_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_HMI_LANGUAGE_HANDLER_H_ #include "application_manager/event_engine/event_observer.h" -#include "utils/lock.h" #include "interfaces/HMI_API.h" #include "smart_objects/smart_object.h" +#include "utils/lock.h" namespace resumption { class LastState; @@ -56,8 +56,8 @@ class HMILanguageHandler : public event_engine::EventObserver { typedef std::map Apps; /** - * @brief System interfaces - */ + * @brief System interfaces + */ enum Interface { INTERFACE_UI, INTERFACE_VR, INTERFACE_TTS }; /** 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 774376b2495..5b9e2013919 100644 --- a/src/components/application_manager/include/application_manager/hmi_state.h +++ b/src/components/application_manager/include/application_manager/hmi_state.h @@ -46,13 +46,14 @@ class ApplicationManager; class Application; typedef std::shared_ptr HmiStatePtr; +typedef int32_t WindowID; /** -* @brief The HmiState class -* Handle Hmi state of application (hmi level, -* audio streaming state, system context) -* -*/ + * @brief The HmiState class + * Handle Hmi state of application (hmi level, + * audio streaming state, system context) + * + */ class HmiState { friend std::ostream& operator<<(std::ostream& os, const HmiState& src); @@ -62,18 +63,18 @@ class HmiState { * If no events occurred STATE_ID_DEFAULT should be presented */ enum StateID { - STATE_ID_CURRENT, - STATE_ID_REGULAR, - STATE_ID_POSTPONED, - STATE_ID_PHONE_CALL, - STATE_ID_SAFETY_MODE, - STATE_ID_VR_SESSION, - STATE_ID_TTS_SESSION, - STATE_ID_VIDEO_STREAMING, - STATE_ID_NAVI_STREAMING, - STATE_ID_DEACTIVATE_HMI, - STATE_ID_AUDIO_SOURCE, - STATE_ID_EMBEDDED_NAVI + STATE_ID_CURRENT = 1, + STATE_ID_REGULAR = 2, + STATE_ID_POSTPONED = 3, + STATE_ID_PHONE_CALL = 4, + STATE_ID_SAFETY_MODE = 5, + STATE_ID_VR_SESSION = 6, + STATE_ID_TTS_SESSION = 7, + STATE_ID_VIDEO_STREAMING = 8, + STATE_ID_NAVI_STREAMING = 9, + STATE_ID_DEACTIVATE_HMI = 10, + STATE_ID_AUDIO_SOURCE = 11, + STATE_ID_EMBEDDED_NAVI = 12 }; /** @@ -206,11 +207,24 @@ class HmiState { state_id_ = state_id; } + /** + * @brief window_type getter for a window type for this type + * @return current state window type + */ + mobile_apis::WindowType::eType window_type() const; + + /** + * @brief set_window_type sets current state window type + * @param window_type new window type + */ + void set_window_type(const mobile_apis::WindowType::eType window_type); + protected: uint32_t hmi_app_id_; StateID state_id_; const ApplicationManager& app_mngr_; HmiStatePtr parent_; + mobile_apis::WindowType::eType window_type_; mobile_apis::HMILevel::eType hmi_level_; mobile_apis::AudioStreamingState::eType audio_streaming_state_; mobile_apis::VideoStreamingState::eType video_streaming_state_; diff --git a/src/components/application_manager/include/application_manager/message.h b/src/components/application_manager/include/application_manager/message.h index 1c319cf204c..1ce7596bf25 100644 --- a/src/components/application_manager/include/application_manager/message.h +++ b/src/components/application_manager/include/application_manager/message.h @@ -36,9 +36,9 @@ #include #include +#include "protocol/common.h" #include "protocol/message_priority.h" #include "protocol/rpc_type.h" -#include "protocol/common.h" #include "smart_objects/smart_object.h" namespace application_manager { @@ -71,6 +71,12 @@ class Message { int32_t correlation_id() const; int32_t connection_key() const; + /** + * @brief retreives message's protection flag + * @return true if message is encrypted, otherwise returns false + */ + bool is_message_encrypted() const; + MessageType type() const; protocol_handler::MajorProtocolVersion protocol_version() const; @@ -95,6 +101,13 @@ class Message { void set_data_size(size_t data_size); void set_payload_size(size_t payload_size); + /** + * @brief sets message's protection flag + * @param protection - bool value, if message is encrypted - true, otherwise + * - false + */ + void set_message_encryption(const bool protection); + static bool is_sufficient_version( protocol_handler::MajorProtocolVersion minVersion, protocol_handler::MajorProtocolVersion version); @@ -122,6 +135,8 @@ class Message { size_t data_size_; size_t payload_size_; protocol_handler::MajorProtocolVersion version_; + + bool is_message_encrypted_; }; typedef std::shared_ptr MobileMessage; 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 ac84bcfaa5b..aff46593237 100644 --- a/src/components/application_manager/include/application_manager/message_helper.h +++ b/src/components/application_manager/include/application_manager/message_helper.h @@ -37,20 +37,21 @@ #define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_MESSAGE_HELPER_H_ #include -#include #include +#include -#include "interfaces/MOBILE_API.h" -#include "interfaces/HMI_API.h" -#include "utils/macro.h" -#include "connection_handler/device.h" +#include #include "application_manager/application.h" +#include "application_manager/hmi_capabilities.h" +#include "application_manager/policies/policy_handler_interface.h" +#include "connection_handler/device.h" +#include "interfaces/HMI_API.h" +#include "interfaces/MOBILE_API.h" #include "policy/policy_types.h" #include "protocol_handler/session_observer.h" -#include "application_manager/policies/policy_handler_interface.h" #include "smart_objects/smart_object.h" #include "transport_manager/common.h" -#include +#include "utils/macro.h" namespace policy { class PolicyHandlerInterface; @@ -73,25 +74,33 @@ typedef std::map VehicleData; class MessageHelper { public: /** - * @brief CreateNotification creates basic mobile notification smart object - * @param function_id Notification function ID - * @param app_id application to send notification - * @return basic mobile notification smart object - */ + * @brief CreateNotification creates basic mobile notification smart object + * @param function_id Notification function ID + * @param app_id application to send notification + * @return basic mobile notification smart object + */ static smart_objects::SmartObjectSPtr CreateNotification( mobile_apis::FunctionID::eType function_id, uint32_t app_id); /** - * @brief CreateHMINotification creates basic hmi notification smart object - * @param function_id Notification function ID - * @return basic hmi notification smart object - */ + * @brief CreateHMINotification creates basic hmi notification smart object + * @param function_id Notification function ID + * @return basic hmi notification smart object + */ static smart_objects::SmartObjectSPtr CreateHMINotification( hmi_apis::FunctionID::eType function_id); + static smart_objects::SmartObjectSPtr CreateOnServiceUpdateNotification( + const hmi_apis::Common_ServiceType::eType type, + const hmi_apis::Common_ServiceEvent::eType event, + const hmi_apis::Common_ServiceStatusUpdateReason::eType reason = + hmi_apis::Common_ServiceStatusUpdateReason::INVALID_ENUM, + const uint32_t app_id = 0); + /** * @brief Creates request for different interfaces(JSON) * @param correlation_id unique ID - * @param params Vector of arguments that we need in GetVehicleData request + * @param params Vector of arguments that we need in GetVehicleData + * request * (e.g. gps, odometer, fuel_level) */ static void CreateGetVehicleDataRequest( @@ -118,18 +127,18 @@ class MessageHelper { static void SendOnLanguageChangeToMobile(uint32_t connection_key); /** - * @brief Sends DecryptCertificate request to HMI - * @param file_name path to file containing encrypted certificate - */ + * @brief Sends DecryptCertificate request to HMI + * @param file_name path to file containing encrypted certificate + */ static void SendDecryptCertificateToHMI(const std::string& file_name, ApplicationManager& app_mngr); /** - * @brief SendGetSystemTimeRequest sends mentioned request to HMI. - * @param correlation_id the message correlation id, required for proper - * response processing. - * @param app_mngr - */ + * @brief SendGetSystemTimeRequest sends mentioned request to HMI. + * @param correlation_id the message correlation id, required for proper + * response processing. + * @param app_mngr + */ static void SendGetSystemTimeRequest(const uint32_t correlation_id, ApplicationManager& app_mngr); @@ -205,17 +214,17 @@ class MessageHelper { const std::string& hmi_level); /* - * @brief Used to obtain string representation of app's - * HMI Level. - * @param hmi_level Desired HMI Level - */ + * @brief Used to obtain string representation of app's + * HMI Level. + * @param hmi_level Desired HMI Level + */ static std::string StringifiedHMILevel( const mobile_apis::HMILevel::eType hmi_level); /* - * @brief Used to obtain function name by its id - * @param function_id Function ID - */ + * @brief Used to obtain function name by its id + * @param function_id Function ID + */ static std::string StringifiedFunctionID( mobile_apis::FunctionID::eType function_id); @@ -302,6 +311,30 @@ class MessageHelper { const uint32_t app_id, ApplicationManager& app_mngr); + /** + * @brief Creates UI.CreateWindow request + * @param application application instance + * @param app_mngr reference to application manager + * @param windows_info smart object containing saved windows info + * @return smart object with UI.CreateWindow request + */ + static smart_objects::SmartObjectSPtr CreateUICreateWindowRequestToHMI( + ApplicationSharedPtr application, + ApplicationManager& app_mngr, + const smart_objects::SmartObject& window_info); + + /** + * @brief Creates UI.CreateWindow requests + * @param application application instance + * @param app_mngr reference to application manager + * @param windows_info smart object containing saved windows info + * @return list of smart objects with UI.CreateWindow requests + */ + static smart_objects::SmartObjectList CreateUICreateWindowRequestsToHMI( + application_manager::ApplicationSharedPtr application, + ApplicationManager& app_mngr, + const smart_objects::SmartObject& windows_info); + /* * @brief Create Common.DeviceInfo struct from device handle * @param device_handle device handle of the app @@ -348,40 +381,41 @@ class MessageHelper { bool is_unexpected_disconnect, ApplicationManager& app_mngr); - static ns_smart_device_link::ns_smart_objects::SmartObjectSPtr - GetBCActivateAppRequestToHMI( + static smart_objects::SmartObjectSPtr GetBCActivateAppRequestToHMI( ApplicationConstSharedPtr app, - const protocol_handler::SessionObserver& session_observer, const policy::PolicyHandlerInterface& policy_handler, hmi_apis::Common_HMILevel::eType level, bool send_policy_priority, ApplicationManager& app_mngr); + static smart_objects::SmartObjectSPtr GetBCCloseApplicationRequestToHMI( + ApplicationConstSharedPtr app, ApplicationManager& app_mngr); + static void SendOnResumeAudioSourceToHMI(const uint32_t app_id, ApplicationManager& app_mngr); /** - * @brief Send SDL_ActivateApp response to HMI - * @param permissions response parameters - */ + * @brief Send SDL_ActivateApp response to HMI + * @param permissions response parameters + */ static void SendSDLActivateAppResponse(policy::AppPermissions& permissions, uint32_t correlation_id, ApplicationManager& app_mngr); /** - * @brief Send OnSDLConsentNeeded to HMI for device data consent by user - * @param device_info Device info, e.g. mac, handle, name - */ + * @brief Send OnSDLConsentNeeded to HMI for device data consent by user + * @param device_info Device info, e.g. mac, handle, name + */ static void SendOnSDLConsentNeeded(const policy::DeviceParams& device_info, ApplicationManager& app_man); /** - * @brief Send request to SyncP process to read file and send - * Policy Table Snapshot using Retry Strategy - * @param file_path Path to file with PTS - * @param timeout Timeout to wait for PTU in seconds - * @param retries Seconds between retries - */ + * @brief Send request to SyncP process to read file and send + * Policy Table Snapshot using Retry Strategy + * @param file_path Path to file with PTS + * @param timeout Timeout to wait for PTU in seconds + * @param retries Seconds between retries + */ static void SendPolicyUpdate(const std::string& file_path, const uint32_t timeout, const std::vector& retries, @@ -445,13 +479,13 @@ class MessageHelper { static void SendNaviStopStream(int32_t app_id, ApplicationManager& app_mngr); /* - * @brief Send notification for Update of Policy Table - * with PT Snapshot. - * @param connection_key Id of application to send message to - * @param policy_data PT Snapshot - * @param url If empty string, no URL is provided - * @param timeout If -1 no timeout is provdied - */ + * @brief Send notification for Update of Policy Table + * with PT Snapshot. + * @param connection_key Id of application to send message to + * @param policy_data PT Snapshot + * @param url If empty string, no URL is provided + * @param timeout If -1 no timeout is provdied + */ static void SendPolicySnapshotNotification( uint32_t connection_key, const std::vector& policy_data, @@ -485,20 +519,23 @@ class MessageHelper { ApplicationManager& app_man); /* - * @brief Send notification to mobile on application permissions update - * @param connection_key Id of application to send message to - * @param permissions updated permissions for application - */ + * @brief Send notification to mobile on application permissions update + * @param connection_key Id of application to send message to + * @param permissions updated permissions for application + * @param app_mngr reference to application manager + * @param require_encryption require encryption flag + */ static void SendOnPermissionsChangeNotification( uint32_t connection_key, const policy::Permissions& permissions, - ApplicationManager& app_mngr); + ApplicationManager& app_mngr, + const policy::EncryptionRequired encryprion_required); /* - * @brief Send notification to HMI on application permissions update - * @param connection_key Id of application to send message to - * @param permissions updated permissions for application - */ + * @brief Send notification to HMI on application permissions update + * @param connection_key Id of application to send message to + * @param permissions updated permissions for application + */ static void SendOnAppPermissionsChangedNotification( uint32_t connection_key, const policy::AppPermissions& permissions, @@ -610,12 +647,12 @@ class MessageHelper { ApplicationManager& app_mngr); /** - * @brief Verify image and add image file full path - * and add path, although the image doesn't exist - * @param SmartObject with image - * @param app current application - * @return verification result - */ + * @brief Verify image and add image file full path + * and add path, although the image doesn't exist + * @param SmartObject with image + * @param app current application + * @return verification result + */ static void ApplyImagePath(smart_objects::SmartObject& image, ApplicationConstSharedPtr app, ApplicationManager& app_mngr); @@ -636,10 +673,10 @@ class MessageHelper { ApplicationManager& app_mngr); /** - * @brief Stores whether each choice in a set has the vrCommands parameter - * MIXED means some choices have vrCommands and others don't - * ALL means all do, NONE means none do - */ + * @brief Stores whether each choice in a set has the vrCommands parameter + * MIXED means some choices have vrCommands and others don't + * ALL means all do, NONE means none do + */ enum ChoiceSetVRCommandsStatus { MIXED, ALL, NONE }; /** @@ -686,6 +723,23 @@ class MessageHelper { const policy::PolicyHandlerInterface& policy_handler, ApplicationManager& app_mngr); + /* + * @brief subscribe application to softbutton + * + * @param message_params contains data of request + * + * @param app current application + * + * @param function_id Unique command id from mobile API + * + * @param window_id window id containing soft buttons + */ + static void SubscribeApplicationToSoftButton( + smart_objects::SmartObject& message_params, + ApplicationSharedPtr app, + int32_t function_id, + const WindowID window_id); + /* * @brief subscribe application to softbutton * @@ -710,6 +764,15 @@ class MessageHelper { */ static bool PrintSmartObject(const smart_objects::SmartObject& object); + /** + * @brief Extract window unique ID from message, this id is used for identify + * the window + * @param s_map contains application's window id + * @return window id from current message + */ + static WindowID ExtractWindowIdFromSmartObject( + const smart_objects::SmartObject& s_map); + template static To ConvertEnumAPINoCheck(const From& input) { return static_cast(input); @@ -724,6 +787,14 @@ class MessageHelper { static std::string CommonLanguageToString( hmi_apis::Common_Language::eType language); + /** + * @brief Converts mobile language to string representation + * @param language Mobile UI language + * @return Mobile language string representation + */ + static std::string MobileLanguageToString( + mobile_apis::Language::eType language); + /** * @brief Converts string to mobile language enum value * @param language language as string @@ -855,10 +926,13 @@ class MessageHelper { /** * @brief Sends HMI status notification to mobile - * @param application_impl application with changed HMI status + * @param application application with changed HMI status + * @param window_id id of affected window + * @param application_manager reference to application manager **/ static void SendHMIStatusNotification( - const Application& application_impl, + ApplicationSharedPtr application, + const WindowID window_id, ApplicationManager& application_manager); /** @@ -892,6 +966,16 @@ class MessageHelper { static void BroadcastCapabilityUpdate(smart_objects::SmartObject& msg_params, ApplicationManager& app_mngr); + /** + * @brief CreateDisplayCapabilityUpdateToMobile creates notification with + * updated display capabilities acccoring to message type + * @param system_capabilities SO containing notification data + * @param app reference to application + * @return shared ptr to notification SO + */ + static smart_objects::SmartObjectSPtr CreateDisplayCapabilityUpdateToMobile( + const smart_objects::SmartObject& system_capabilities, Application& app); + private: /** * @brief Allows to fill SO according to the current permissions. diff --git a/src/components/application_manager/include/application_manager/mobile_message_handler.h b/src/components/application_manager/include/application_manager/mobile_message_handler.h index b2ad963f46d..3b02424e1f8 100644 --- a/src/components/application_manager/include/application_manager/mobile_message_handler.h +++ b/src/components/application_manager/include/application_manager/mobile_message_handler.h @@ -33,9 +33,9 @@ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_MOBILE_MESSAGE_HANDLER_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_MOBILE_MESSAGE_HANDLER_H_ -#include "utils/macro.h" -#include "protocol/common.h" #include "application_manager/message.h" +#include "protocol/common.h" +#include "utils/macro.h" namespace application_manager { typedef std::shared_ptr MobileMessage; diff --git a/src/components/application_manager/include/application_manager/plugin_manager/plugin_keys.h b/src/components/application_manager/include/application_manager/plugin_manager/plugin_keys.h index 11a7d353f6d..96a7f270646 100644 --- a/src/components/application_manager/include/application_manager/plugin_manager/plugin_keys.h +++ b/src/components/application_manager/include/application_manager/plugin_manager/plugin_keys.h @@ -41,7 +41,7 @@ extern const char* vehicle_info_rpc_plugin; extern const char* app_service_rpc_plugin; extern const char* rc_rpc_plugin; extern const char* sdl_rpc_plugin; -} +} // namespace plugin_names } // namespace plugin_manager } // namespace application_manager diff --git a/src/components/application_manager/include/application_manager/plugin_manager/rpc_plugin.h b/src/components/application_manager/include/application_manager/plugin_manager/rpc_plugin.h index 09a412b2ac3..61b146f0242 100644 --- a/src/components/application_manager/include/application_manager/plugin_manager/rpc_plugin.h +++ b/src/components/application_manager/include/application_manager/plugin_manager/rpc_plugin.h @@ -33,12 +33,19 @@ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_PLUGIN_MANAGER_RPC_PLUGIN_H #define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_PLUGIN_MANAGER_RPC_PLUGIN_H #include -#include "utils/macro.h" -#include "application_manager/commands/command.h" #include "application_manager/application.h" -#include "application_manager/rpc_service.h" +#include "application_manager/commands/command.h" #include "application_manager/hmi_capabilities.h" -#include "application_manager/policies/policy_handler_interface.h" +#include "application_manager/rpc_service.h" +#include "utils/macro.h" + +namespace policy { +class PolicyHandlerInterface; +} + +namespace resumption { +class LastState; +} namespace application_manager { class CommandFactory; @@ -57,7 +64,8 @@ enum ApplicationEvent { kApplicationExit = 0, kApplicationRegistered, kApplicationUnregistered, - kDeleteApplicationData + kDeleteApplicationData, + kGlobalPropertiesUpdated }; class RPCPlugin { @@ -68,17 +76,18 @@ class RPCPlugin { virtual ~RPCPlugin() {} /** - * @brief Command initialization function - * @param app_manager ApplicationManager - * @param rpc_service RPCService - * @param hmi_capabilities HMICapabilities - * @param policy_handler PolicyHandlerInterface - * @return true in case initialization was succesful, false otherwise. - **/ + * @brief Command initialization function + * @param app_manager ApplicationManager + * @param rpc_service RPCService + * @param hmi_capabilities HMICapabilities + * @param policy_handler PolicyHandlerInterface + * @return true in case initialization was succesful, false otherwise. + **/ virtual bool Init(ApplicationManager& app_manager, rpc_service::RPCService& rpc_service, HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handler) = 0; + policy::PolicyHandlerInterface& policy_handler, + resumption::LastState& last_state) = 0; /** * @brief IsAbleToProcess check if plugin is able to process function * @param function_id RPC identifier @@ -117,7 +126,6 @@ class RPCPlugin { ApplicationEvent event, application_manager::ApplicationSharedPtr application) = 0; }; -typedef std::unique_ptr RPCPluginPtr; } // namespace plugin_manager } // namespace application_manager diff --git a/src/components/application_manager/include/application_manager/plugin_manager/rpc_plugin_manager.h b/src/components/application_manager/include/application_manager/plugin_manager/rpc_plugin_manager.h index 692d296607b..eb14f26ae68 100644 --- a/src/components/application_manager/include/application_manager/plugin_manager/rpc_plugin_manager.h +++ b/src/components/application_manager/include/application_manager/plugin_manager/rpc_plugin_manager.h @@ -33,10 +33,10 @@ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_PLUGIN_MANAGER_RPC_PLUGIN_MANAGER_H #define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_PLUGIN_MANAGER_RPC_PLUGIN_MANAGER_H #include -#include +#include #include +#include #include -#include #include "application_manager/plugin_manager/rpc_plugin.h" #include "utils/optional.h" @@ -44,6 +44,10 @@ namespace application_manager { namespace plugin_manager { class RPCPluginManager { + protected: + typedef std::unique_ptr > + RPCPluginPtr; + public: virtual ~RPCPluginManager() {} /** @@ -55,12 +59,6 @@ class RPCPluginManager { */ virtual uint32_t LoadPlugins(const std::string& plugins_path) = 0; - /** - * @brief GetPlugins get list of plugins - * @return list of loaded plugins - */ - virtual std::vector& GetPlugins() = 0; - /** * @brief FindPluginToProcess find plugin to process message * @param function_id RPC identifier to process diff --git a/src/components/application_manager/include/application_manager/plugin_manager/rpc_plugin_manager_impl.h b/src/components/application_manager/include/application_manager/plugin_manager/rpc_plugin_manager_impl.h index 5f85d45b6e7..5495c44e05d 100644 --- a/src/components/application_manager/include/application_manager/plugin_manager/rpc_plugin_manager_impl.h +++ b/src/components/application_manager/include/application_manager/plugin_manager/rpc_plugin_manager_impl.h @@ -32,13 +32,17 @@ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_PLUGIN_MANAGER_RPC_PLUGIN_MANAGER_IMPL_H #define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_PLUGIN_MANAGER_RPC_PLUGIN_MANAGER_IMPL_H -#include "application_manager/plugin_manager/rpc_plugin_manager.h" #include "application_manager/application_manager.h" -#include "application_manager/rpc_service.h" #include "application_manager/hmi_capabilities.h" +#include "application_manager/plugin_manager/rpc_plugin_manager.h" #include "application_manager/policies/policy_handler_interface.h" +#include "application_manager/rpc_service.h" #include "utils/optional.h" +namespace resumption { +class LastState; +} + namespace application_manager { namespace plugin_manager { @@ -55,20 +59,24 @@ class RPCPluginManagerImpl : public RPCPluginManager { RPCPluginManagerImpl(ApplicationManager& app_manager, rpc_service::RPCService& rpc_service, HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handler); + policy::PolicyHandlerInterface& policy_handler, + resumption::LastState& last_state); uint32_t LoadPlugins(const std::string& plugins_path) OVERRIDE; - std::vector& GetPlugins() OVERRIDE; + utils::Optional FindPluginToProcess( const int32_t function_id, const commands::Command::CommandSource message_source) OVERRIDE; private: + RPCPluginPtr LoadPlugin(const std::string& full_plugin_path) const; + std::vector loaded_plugins_; ApplicationManager& app_manager_; rpc_service::RPCService& rpc_service_; HMICapabilities& hmi_capabilities_; policy::PolicyHandlerInterface& policy_handler_; + resumption::LastState& last_state_; // RPCPluginManager interface public: diff --git a/src/components/application_manager/include/application_manager/policies/custom_vehicle_data_provider.h b/src/components/application_manager/include/application_manager/policies/custom_vehicle_data_provider.h new file mode 100644 index 00000000000..307f0b93dfd --- /dev/null +++ b/src/components/application_manager/include/application_manager/policies/custom_vehicle_data_provider.h @@ -0,0 +1,32 @@ +#ifndef CUSTOM_VEHICLE_DATA_PROVIDER_H +#define CUSTOM_VEHICLE_DATA_PROVIDER_H + +#include + +namespace rpc { +namespace policy_table_interface_base { +struct VehicleDataItem; +} +} // namespace rpc + +namespace policy { + +class VehicleDataItemProvider { + public: + /** + * @brief Gets vehicle data items + * @return Structure with vehicle data items + */ + virtual const std::vector + GetVehicleDataItems() const = 0; + + /** + * @brief Gets vehicle data items removed by policies + * @return Structure with vehicle data items + */ + virtual std::vector + GetRemovedVehicleDataItems() const = 0; +}; +} // namespace policy + +#endif // CUSTOM_VEHICLE_DATA_PROVIDER_H diff --git a/src/components/application_manager/include/application_manager/policies/external/delegates/app_permission_delegate.h b/src/components/application_manager/include/application_manager/policies/external/delegates/app_permission_delegate.h index f501598e0fc..114b4e2d77e 100644 --- a/src/components/application_manager/include/application_manager/policies/external/delegates/app_permission_delegate.h +++ b/src/components/application_manager/include/application_manager/policies/external/delegates/app_permission_delegate.h @@ -33,19 +33,19 @@ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_POLICIES_DELEGATES_APP_PERMISSION_DELEGATE_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_POLICIES_DELEGATES_APP_PERMISSION_DELEGATE_H_ +#include "utils/conditional_variable.h" #include "utils/threads/thread.h" #include "utils/threads/thread_delegate.h" -#include "utils/conditional_variable.h" -#include "policy/policy_types.h" #include "application_manager/policies/policy_handler_interface.h" +#include "policy/policy_types.h" namespace policy { class PolicyHandler; /** -*@brief The AppPermissionDelegate class allows to call OnAppPermissionConsent -*in async way. -*/ + *@brief The AppPermissionDelegate class allows to call OnAppPermissionConsent + *in async way. + */ class AppPermissionDelegate : public threads::ThreadDelegate { public: /** diff --git a/src/components/application_manager/include/application_manager/policies/external/delegates/statistics_delegate.h b/src/components/application_manager/include/application_manager/policies/external/delegates/statistics_delegate.h index 2fe4265f547..38a60b29c4a 100644 --- a/src/components/application_manager/include/application_manager/policies/external/delegates/statistics_delegate.h +++ b/src/components/application_manager/include/application_manager/policies/external/delegates/statistics_delegate.h @@ -35,10 +35,10 @@ #include +#include "application_manager/usage_statistics.h" +#include "utils/conditional_variable.h" #include "utils/threads/thread.h" #include "utils/threads/thread_delegate.h" -#include "utils/conditional_variable.h" -#include "application_manager/usage_statistics.h" namespace policy { diff --git a/src/components/application_manager/include/application_manager/policies/external/policy_event_observer.h b/src/components/application_manager/include/application_manager/policies/external/policy_event_observer.h index 3168b80b5ad..7d71611a3c2 100644 --- a/src/components/application_manager/include/application_manager/policies/external/policy_event_observer.h +++ b/src/components/application_manager/include/application_manager/policies/external/policy_event_observer.h @@ -33,8 +33,8 @@ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_POLICIES_POLICY_EVENT_OBSERVER_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_POLICIES_POLICY_EVENT_OBSERVER_H_ -#include "smart_objects/smart_object.h" #include "application_manager/event_engine/event_observer.h" +#include "smart_objects/smart_object.h" #include "utils/lock.h" namespace policy { diff --git a/src/components/application_manager/include/application_manager/policies/policy_handler.h b/src/components/application_manager/include/application_manager/policies/policy_handler.h index a33bb640adb..e4d4cd7fa25 100644 --- a/src/components/application_manager/include/application_manager/policies/policy_handler.h +++ b/src/components/application_manager/include/application_manager/policies/policy_handler.h @@ -33,28 +33,30 @@ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_POLICIES_POLICY_HANDLER_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_POLICIES_POLICY_HANDLER_H_ -#include +#include +#include #include #include +#include #include -#include -#include -#include "policy/policy_manager.h" #include "application_manager/application.h" -#include "application_manager/policies/policy_handler_interface.h" -#include "application_manager/policies/policy_event_observer.h" #include "application_manager/policies/delegates/statistics_delegate.h" +#include "application_manager/policies/policy_event_observer.h" +#include "application_manager/policies/policy_handler_interface.h" #include "application_manager/policies/policy_handler_observer.h" -#include "utils/logger.h" -#include "utils/threads/thread.h" -#include "utils/threads/thread_delegate.h" + +#include "application_manager/policies/custom_vehicle_data_provider.h" +#include "policy/policy_manager.h" +#include "policy/policy_settings.h" +#include "policy/usage_statistics/statistics_manager.h" #include "utils/conditional_variable.h" -#include "utils/rwlock.h" #include "utils/custom_string.h" -#include "policy/usage_statistics/statistics_manager.h" +#include "utils/logger.h" +#include "utils/rwlock.h" #include "utils/threads/async_runner.h" -#include "policy/policy_settings.h" +#include "utils/threads/thread.h" +#include "utils/threads/thread_delegate.h" namespace Json { class Value; @@ -77,6 +79,8 @@ class PolicyHandler : public PolicyHandlerInterface, PolicyHandler(const policy::PolicySettings& get_settings, application_manager::ApplicationManager& application_manager); virtual ~PolicyHandler(); + PolicyEncryptionFlagGetterInterfaceSPtr PolicyEncryptionFlagGetter() + const OVERRIDE; bool LoadPolicyLibrary() OVERRIDE; bool PolicyEnabled() const OVERRIDE; bool InitPolicyTable() OVERRIDE; @@ -87,24 +91,31 @@ class PolicyHandler : public PolicyHandlerInterface, bool ReceiveMessageFromSDK(const std::string& file, const BinaryMessage& pt_string) OVERRIDE; bool UnloadPolicyLibrary() OVERRIDE; - virtual void OnPermissionsUpdated(const std::string& policy_app_id, + + virtual void OnPermissionsUpdated(const std::string& device_id, + const std::string& policy_app_id, const Permissions& permissions, const HMILevel& default_hmi) OVERRIDE; - virtual void OnPermissionsUpdated(const std::string& policy_app_id, + virtual void OnPermissionsUpdated(const std::string& device_id, + const std::string& policy_app_id, const Permissions& permissions) OVERRIDE; #ifdef EXTERNAL_PROPRIETARY_MODE void OnSnapshotCreated(const BinaryMessage& pt_string, const std::vector& retry_delay_seconds, uint32_t timeout_exchange) OVERRIDE; + + PTURetryHandler& ptu_retry_handler() const OVERRIDE; #else // EXTERNAL_PROPRIETARY_MODE - void OnSnapshotCreated(const BinaryMessage& pt_string) OVERRIDE; + void OnSnapshotCreated(const BinaryMessage& pt_string, + const PTUIterationType iteration_type) OVERRIDE; #endif // EXTERNAL_PROPRIETARY_MODE virtual bool GetPriority(const std::string& policy_app_id, std::string* priority) const OVERRIDE; virtual void CheckPermissions( const application_manager::ApplicationSharedPtr app, + const application_manager::WindowID window_id, const PTString& rpc, const RPCParams& rpc_params, CheckPermissionResult& result) OVERRIDE; @@ -113,12 +124,16 @@ class PolicyHandler : public PolicyHandlerInterface, virtual DeviceConsent GetUserConsentForDevice( const std::string& device_id) const OVERRIDE; + Json::Value GetPolicyTableData() const OVERRIDE; + /** * @brief Sets HMI default type for specified application + * @param device_handle device identifier * @param application_id ID application * @param app_types list of HMI types */ - void SetDefaultHmiTypes(const std::string& application_id, + void SetDefaultHmiTypes(const transport_manager::DeviceHandle& device_handle, + const std::string& application_id, const smart_objects::SmartObject* app_types) OVERRIDE; /** @@ -168,6 +183,9 @@ class PolicyHandler : public PolicyHandlerInterface, const std::string& policy_app_id, const std::string& hmi_level) OVERRIDE; +#ifndef EXTERNAL_PROPRIETARY_MODE + void OnPTUTimeOut() OVERRIDE; +#endif /** * Gets all allowed module types * @param app_id unique identifier of application @@ -177,7 +195,8 @@ class PolicyHandler : public PolicyHandlerInterface, bool GetModuleTypes(const std::string& policy_app_id, std::vector* modules) const OVERRIDE; - bool GetDefaultHmi(const std::string& policy_app_id, + bool GetDefaultHmi(const std::string& device_id, + const std::string& policy_app_id, std::string* default_hmi) const OVERRIDE; bool GetInitialAppData(const std::string& application_id, StringArray* nicknames = NULL, @@ -204,6 +223,9 @@ class PolicyHandler : public PolicyHandlerInterface, uint32_t TimeoutExchangeMSec() const OVERRIDE; void OnExceededTimeout() OVERRIDE; void OnSystemReady() OVERRIDE; + const boost::optional LockScreenDismissalEnabledState() const OVERRIDE; + const boost::optional LockScreenDismissalWarningMessage( + const std::string& language) const OVERRIDE; void PTUpdatedAt(Counters counter, int value) OVERRIDE; void add_listener(PolicyHandlerObserver* listener) OVERRIDE; void remove_listener(PolicyHandlerObserver* listener) OVERRIDE; @@ -247,7 +269,8 @@ class PolicyHandler : public PolicyHandlerInterface, */ void OnIgnitionCycleOver() OVERRIDE; - void OnPendingPermissionChange(const std::string& policy_app_id) OVERRIDE; + void OnPendingPermissionChange(const std::string& device_id, + const std::string& policy_app_id) OVERRIDE; /** * Initializes PT exchange at user request @@ -334,9 +357,11 @@ class PolicyHandler : public PolicyHandlerInterface, /** * @brief Update currently used device id in policies manager for given * application + * @param device_handle device identifier * @param policy_app_id Application id */ std::string OnCurrentDeviceIdUpdateRequired( + const transport_manager::DeviceHandle& device_handle, const std::string& policy_app_id) OVERRIDE; /** @@ -441,9 +466,12 @@ class PolicyHandler : public PolicyHandlerInterface, std::string& cloud_transport_type, std::string& hybrid_app_preference) const OVERRIDE; + void OnAuthTokenUpdated(const std::string& policy_app_id, + const std::string& auth_token) OVERRIDE; + /** - * @brief Callback for when a SetCloudAppProperties message is received from a - * mobile app + * @brief Callback for when a SetCloudAppProperties message is received + * from a mobile app * @param message The SetCloudAppProperties message */ void OnSetCloudAppProperties( @@ -478,7 +506,7 @@ class PolicyHandler : public PolicyHandlerInterface, * @brief Check if an app can send unknown rpc requests to an app service * provider * @param policy_app_id Unique application id - */ + */ bool UnknownRPCPassthroughAllowed( const std::string& policy_app_id) const OVERRIDE; @@ -487,11 +515,11 @@ class PolicyHandler : public PolicyHandlerInterface, virtual void OnCertificateUpdated( const std::string& certificate_data) OVERRIDE; + #ifdef EXTERNAL_PROPRIETARY_MODE void OnCertificateDecrypted(bool is_succeeded) OVERRIDE; + void ProcessCertDecryptFailed(); #endif // EXTERNAL_PROPRIETARY_MODE - void OnAuthTokenUpdated(const std::string& policy_app_id, - const std::string& auth_token); virtual bool CanUpdate() OVERRIDE; @@ -500,6 +528,7 @@ class PolicyHandler : public PolicyHandlerInterface, virtual void SendOnAppPermissionsChanged( const AppPermissions& permissions, + const std::string& device_id, const std::string& policy_app_id) const OVERRIDE; virtual void OnPTExchangeNeeded() OVERRIDE; @@ -509,11 +538,13 @@ class PolicyHandler : public PolicyHandlerInterface, /** * @brief Allows to add new or update existed application during * registration process + * @param device_id device identifier * @param application_id The policy aplication id. * @param hmi_types list of hmi types * @return function that will notify update manager about new application */ StatusNotifier AddApplication( + const std::string& device_id, const std::string& application_id, const rpc::policy_table_interface_base::AppHmiTypes& hmi_types) OVERRIDE; @@ -557,17 +588,21 @@ class PolicyHandler : public PolicyHandlerInterface, * succesfully registered on mobile device. * It will send OnAppPermissionSend notification and will try to start PTU. * + * @param device_id device identifier * @param application_id registered application. */ - void OnAppRegisteredOnMobile(const std::string& application_id) OVERRIDE; + void OnAppRegisteredOnMobile(const std::string& device_id, + const std::string& application_id) OVERRIDE; /** * @brief Checks if certain request type is allowed for application + * @param device_handle device identifier * @param policy_app_id Unique applicaion id * @param type Request type * @return true, if allowed, otherwise - false */ bool IsRequestTypeAllowed( + const transport_manager::DeviceHandle& device_handle, const std::string& policy_app_id, mobile_apis::RequestType::eType type) const OVERRIDE; @@ -599,10 +634,12 @@ class PolicyHandler : public PolicyHandlerInterface, /** * @brief Gets application request types + * @param device_id device identifier * @param policy_app_id Unique application id * @return request types */ const std::vector GetAppRequestTypes( + const transport_manager::DeviceHandle& device_id, const std::string& policy_app_id) const OVERRIDE; /** @@ -613,12 +650,6 @@ class PolicyHandler : public PolicyHandlerInterface, const std::vector GetAppRequestSubTypes( const std::string& policy_app_id) const OVERRIDE; - /** - * @brief Gets vehicle information - * @return Structure with vehicle information - */ - const VehicleInfo GetVehicleInfo() const OVERRIDE; - #ifdef EXTERNAL_PROPRIETARY_MODE /** * @brief Gets meta information @@ -652,6 +683,10 @@ class PolicyHandler : public PolicyHandlerInterface, virtual void OnPTUFinished(const bool ptu_result) OVERRIDE; + virtual void OnPTInited() OVERRIDE; + + void StopRetrySequence() OVERRIDE; + /** * @brief OnDeviceSwitching Notifies policy manager on device switch event so * policy permissions should be processed accordingly @@ -661,6 +696,19 @@ class PolicyHandler : public PolicyHandlerInterface, void OnDeviceSwitching(const std::string& device_id_from, const std::string& device_id_to) FINAL; + // VehicleDataItemProvider interface : + /** + * @brief Gets vehicle data items + * @return Structure with vehicle data items + */ + const std::vector + GetVehicleDataItems() const OVERRIDE; + + std::vector + GetRemovedVehicleDataItems() const OVERRIDE; + + void OnLockScreenDismissalStateChanged() FINAL; + protected: /** * Starts next retry exchange policy table @@ -720,7 +768,7 @@ class PolicyHandler : public PolicyHandlerInterface, void UpdateHMILevel(application_manager::ApplicationSharedPtr app, mobile_apis::HMILevel::eType level); std::vector GetDevicesIds( - const std::string& policy_app_id) OVERRIDE; + const std::string& policy_app_id) const OVERRIDE; /** * @brief Sets days after epoch on successful policy update @@ -811,16 +859,14 @@ class PolicyHandler : public PolicyHandlerInterface, static const std::string kLibrary; /** - * @brief Collects currently registered applications ids linked to their - * device id - * @param out_links Collection of device_id-to-app_id links - */ + * @brief Collects currently registered applications ids linked to their + * device id + * @param out_links Collection of device_id-to-app_id links + */ void GetRegisteredLinks(std::map& out_links) const; - private: mutable sync_primitives::RWLock policy_manager_lock_; std::shared_ptr policy_manager_; - void* dl_handle_; std::shared_ptr event_observer_; uint32_t last_activated_app_id_; diff --git a/src/components/application_manager/include/application_manager/policies/regular/delegates/app_permission_delegate.h b/src/components/application_manager/include/application_manager/policies/regular/delegates/app_permission_delegate.h index 6913f5038e6..7e83aefe815 100644 --- a/src/components/application_manager/include/application_manager/policies/regular/delegates/app_permission_delegate.h +++ b/src/components/application_manager/include/application_manager/policies/regular/delegates/app_permission_delegate.h @@ -33,18 +33,18 @@ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_DELEGATES_APP_PERMISSION_DELEGATE_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_DELEGATES_APP_PERMISSION_DELEGATE_H_ +#include "utils/conditional_variable.h" #include "utils/threads/thread.h" #include "utils/threads/thread_delegate.h" -#include "utils/conditional_variable.h" -#include "policy/policy_types.h" #include "application_manager/policies/policy_handler_interface.h" +#include "policy/policy_types.h" namespace policy { /** -*@brief The AppPermissionDelegate class allows to call OnAppPermissionConsent -*in async way. -*/ + *@brief The AppPermissionDelegate class allows to call OnAppPermissionConsent + *in async way. + */ class AppPermissionDelegate : public threads::ThreadDelegate { public: /** diff --git a/src/components/application_manager/include/application_manager/policies/regular/delegates/statistics_delegate.h b/src/components/application_manager/include/application_manager/policies/regular/delegates/statistics_delegate.h index 3dc9ad925c3..74d88fac693 100644 --- a/src/components/application_manager/include/application_manager/policies/regular/delegates/statistics_delegate.h +++ b/src/components/application_manager/include/application_manager/policies/regular/delegates/statistics_delegate.h @@ -35,10 +35,10 @@ #include +#include "application_manager/usage_statistics.h" +#include "utils/conditional_variable.h" #include "utils/threads/thread.h" #include "utils/threads/thread_delegate.h" -#include "utils/conditional_variable.h" -#include "application_manager/usage_statistics.h" namespace policy { diff --git a/src/components/application_manager/include/application_manager/policies/regular/policy_handler_observer.h b/src/components/application_manager/include/application_manager/policies/regular/policy_handler_observer.h index 68e7511b43c..fdfed698c4d 100644 --- a/src/components/application_manager/include/application_manager/policies/regular/policy_handler_observer.h +++ b/src/components/application_manager/include/application_manager/policies/regular/policy_handler_observer.h @@ -33,9 +33,9 @@ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_POLICY_HANDLER_OBSERVER_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_POLICY_HANDLER_OBSERVER_H_ -#include -#include #include +#include +#include namespace policy { @@ -53,6 +53,8 @@ class PolicyHandlerObserver { virtual void OnPTUFinished(const bool ptu_result) {} + virtual void OnPTUTimeoutExceeded() {} + virtual ~PolicyHandlerObserver() {} }; } // namespace policy diff --git a/src/components/application_manager/include/application_manager/request_controller.h b/src/components/application_manager/include/application_manager/request_controller.h index ea8d95a92ae..8a3c90061ee 100644 --- a/src/components/application_manager/include/application_manager/request_controller.h +++ b/src/components/application_manager/include/application_manager/request_controller.h @@ -34,21 +34,21 @@ #define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_REQUEST_CONTROLLER_H_ #include -#include #include +#include #include "utils/lock.h" -#include "utils/threads/thread.h" #include "utils/conditional_variable.h" +#include "utils/threads/thread.h" #include "utils/threads/thread_delegate.h" #include "utils/timer.h" -#include "interfaces/MOBILE_API.h" #include "interfaces/HMI_API.h" +#include "interfaces/MOBILE_API.h" -#include "application_manager/request_info.h" #include "application_manager/request_controller_settings.h" +#include "application_manager/request_info.h" #include "application_manager/request_tracker.h" namespace application_manager { @@ -56,14 +56,14 @@ namespace application_manager { namespace request_controller { /** -* @brief RequestController class is used to control currently active mobile -* requests. -*/ + * @brief RequestController class is used to control currently active mobile + * requests. + */ class RequestController { public: /** - * @brief Result code for addRequest - */ + * @brief Result code for addRequest + */ enum TResult { SUCCESS = 0, TOO_MANY_REQUESTS, @@ -73,8 +73,8 @@ class RequestController { }; /** - * @brief Thread pool state - */ + * @brief Thread pool state + */ enum TPoolState { UNDEFINED = 0, STARTED, @@ -84,121 +84,121 @@ class RequestController { // Methods /** - * @brief Class constructor - * - */ + * @brief Class constructor + * + */ RequestController(const RequestControlerSettings& settings); /** - * @brief Class destructor - * - */ + * @brief Class destructor + * + */ virtual ~RequestController(); /** - * @brief Initialize thread pool - * - */ + * @brief Initialize thread pool + * + */ void InitializeThreadpool(); /** - * @brief Destroy thread pool - * - */ + * @brief Destroy thread pool + * + */ void DestroyThreadpool(); /** - * @brief Check if max request amount wasn't exceed and adds request to queue. - * - * @param request Active mobile request - * @param hmi_level Current application hmi_level - * - * @return Result code - * - */ + * @brief Check if max request amount wasn't exceed and adds request to queue. + * + * @param request Active mobile request + * @param hmi_level Current application hmi_level + * + * @return Result code + * + */ TResult addMobileRequest(const RequestPtr request, const mobile_apis::HMILevel::eType& hmi_level); /** - * @brief Store HMI request until response or timeout won't remove it - * - * @param request Active hmi request - * @return Result code - * - */ + * @brief Store HMI request until response or timeout won't remove it + * + * @param request Active hmi request + * @return Result code + * + */ TResult addHMIRequest(const RequestPtr request); /** - * @ Add notification to collection - * - * @param ptr Reference to shared pointer that point on hmi notification - */ + * @ Add notification to collection + * + * @param ptr Reference to shared pointer that point on hmi notification + */ void addNotification(const RequestPtr ptr); /** - * @brief Removes request from queue - * - * @param correlation_id Active request correlation ID, - * @param connection_key Active request connection key (0 for HMI requersts) - * @param function_id Active request function id - * @param force_terminate if true, request controller will terminate - * even if not allowed by request - */ + * @brief Removes request from queue + * + * @param correlation_id Active request correlation ID, + * @param connection_key Active request connection key (0 for HMI requersts) + * @param function_id Active request function id + * @param force_terminate if true, request controller will terminate + * even if not allowed by request + */ void TerminateRequest(const uint32_t correlation_id, const uint32_t connection_key, const int32_t function_id, bool force_terminate = false); /** - * @brief Removes request from queue - * - * @param mobile_correlation_id Active mobile request correlation ID - * - */ + * @brief Removes request from queue + * + * @param mobile_correlation_id Active mobile request correlation ID + * + */ void OnMobileResponse(const uint32_t mobile_correlation_id, const uint32_t connection_key, const int32_t function_id); /** - * @brief Removes request from queue - * - * @param mobile_correlation_id Active mobile request correlation ID - * - */ + * @brief Removes request from queue + * + * @param mobile_correlation_id Active mobile request correlation ID + * + */ void OnHMIResponse(const uint32_t correlation_id, const int32_t function_id); /** - * @ Add notification to collection - * - * @param ptr Reference to shared pointer that point on hmi notification - */ + * @ Add notification to collection + * + * @param ptr Reference to shared pointer that point on hmi notification + */ void removeNotification(const commands::Command* notification); /** - * @brief Removes all requests from queue for specified application - * - * @param app_id Mobile application ID (app_id) - * - */ + * @brief Removes all requests from queue for specified application + * + * @param app_id Mobile application ID (app_id) + * + */ void terminateAppRequests(const uint32_t& app_id); /** - * @brief Terminates all requests from HMI - */ + * @brief Terminates all requests from HMI + */ void terminateAllHMIRequests(); /** - * @brief Terminates all requests from Mobile - */ + * @brief Terminates all requests from Mobile + */ void terminateAllMobileRequests(); /** - * @brief Updates request timeout - * - * @param app_id Connection key of application - * @param mobile_correlation_id Correlation ID of the mobile request - * @param new_timeout_value New timeout to be set in milliseconds - */ + * @brief Updates request timeout + * + * @param app_id Connection key of application + * @param mobile_correlation_id Correlation ID of the mobile request + * @param new_timeout_value New timeout to be set in milliseconds + */ void updateRequestTimeout(const uint32_t& app_id, const uint32_t& mobile_correlation_id, const uint32_t& new_timeout); @@ -217,13 +217,13 @@ class RequestController { protected: /** - * @brief Timer callback which handles all request timeouts - */ + * @brief Timer callback which handles all request timeouts + */ void TimeoutThread(); /** - * @brief Signal timer condition variable - */ + * @brief Signal timer condition variable + */ void NotifyTimer(); void terminateWaitingForExecutionAppRequests(const uint32_t& app_id); @@ -285,8 +285,8 @@ class RequestController { RequestTracker request_tracker_; /** - * @brief Set of HMI notifications with timeout. - */ + * @brief Set of HMI notifications with timeout. + */ std::list notification_list_; /** 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 be28bad63cf..6900a50926e 100644 --- a/src/components/application_manager/include/application_manager/request_info.h +++ b/src/components/application_manager/include/application_manager/request_info.h @@ -29,9 +29,9 @@ * 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. -*/ + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_REQUEST_INFO_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_REQUEST_INFO_H_ @@ -127,7 +127,7 @@ struct RequestInfo { } uint64_t hash(); static uint64_t GenerateHash(uint32_t var1, uint32_t var2); - static uint32_t HmiConnectoinKey; + static uint32_t HmiConnectionKey; protected: RequestPtr request_; @@ -268,9 +268,9 @@ class RequestInfoSet { }; /** -* @brief Structure used in std algorithms to determine amount of request -* during time scale -*/ + * @brief Structure used in std algorithms to determine amount of request + * during time scale + */ struct TimeScale { TimeScale(const date_time::TimeDuration& start, const date_time::TimeDuration& end, 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 b351e716a79..72d04abf4a9 100644 --- a/src/components/application_manager/include/application_manager/request_tracker.h +++ b/src/components/application_manager/include/application_manager/request_tracker.h @@ -1,39 +1,39 @@ /* - * 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) + * 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. */ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_REQUEST_TRACKER_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_REQUEST_TRACKER_H_ -#include #include +#include #include #include "application_manager/request_controller_settings.h" #include "interfaces/MOBILE_API.h" 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 f9a60c862bb..11b1bcf9262 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 @@ -42,7 +42,7 @@ class ApplicationManager; class Application; typedef std::shared_ptr ApplicationSharedPtr; typedef std::shared_ptr ApplicationConstSharedPtr; -} +} // namespace application_manager namespace app_mngr = application_manager; namespace resumption { @@ -80,6 +80,13 @@ class ResumeCtrl { virtual bool RestoreAppHMIState( application_manager::ApplicationSharedPtr application) = 0; + /** + * @brief Restore widgets HMI level on the resumption response from HMI + * @param response_message smart_object with HMI message + */ + virtual void RestoreWidgetsHMIState( + const smart_objects::SmartObject& response_message) = 0; + /** * @brief Set application HMI Level as stored in policy * @param application is application witch HMI Level is need to setup @@ -102,6 +109,16 @@ class ResumeCtrl { const mobile_apis::HMILevel::eType hmi_level, bool check_policy = true) = 0; + /** + * @brief RestoreAppWidgets add widgets for the application + * @param application application which will be resumed + * @param saved_app application specific section from backup file + * @return true if widgets resumed successfully otherwise - false + */ + virtual void RestoreAppWidgets( + application_manager::ApplicationSharedPtr application, + const smart_objects::SmartObject& saved_app) = 0; + /** * @brief Remove application from list of saved applications * @param application is application which need to be removed @@ -233,7 +250,7 @@ class ResumeCtrl { * @param application - application to restore hmi level * and audio streaming state */ - virtual void StartAppHmiStateResumption( + virtual bool StartAppHmiStateResumption( application_manager::ApplicationSharedPtr application) = 0; /** @@ -282,6 +299,9 @@ class ResumeCtrl { virtual int32_t GetSavedAppHmiLevel(const std::string& app_id, const std::string& device_id) const = 0; + virtual void StartWaitingForDisplayCapabilitiesUpdate( + app_mngr::ApplicationSharedPtr application) = 0; + virtual time_t LaunchTime() const = 0; #ifdef BUILD_TESTS 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 e7491181406..5e6fb586717 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 @@ -36,18 +36,18 @@ #include "application_manager/resumption/resume_ctrl.h" #include -#include +#include #include #include -#include +#include +#include "application_manager/application.h" +#include "application_manager/event_engine/event_observer.h" +#include "application_manager/resumption/resumption_data.h" #include "interfaces/HMI_API.h" #include "interfaces/HMI_API_schema.h" #include "interfaces/MOBILE_API_schema.h" -#include "application_manager/event_engine/event_observer.h" #include "smart_objects/smart_object.h" -#include "application_manager/application.h" -#include "application_manager/resumption/resumption_data.h" #include "utils/timer.h" namespace resumption { @@ -95,6 +95,9 @@ class ResumeCtrlImpl : public ResumeCtrl, */ bool RestoreAppHMIState(app_mngr::ApplicationSharedPtr application) OVERRIDE; + void RestoreWidgetsHMIState( + const smart_objects::SmartObject& response_message) OVERRIDE; + /** * @brief Set application HMI Level as stored in policy * @param application is application witch HMI Level is need to setup @@ -116,6 +119,14 @@ class ResumeCtrlImpl : public ResumeCtrl, const mobile_apis::HMILevel::eType hmi_level, bool check_policy = true) OVERRIDE; + /** + * @brief RestoreAppWidgets add widgets for the application + * @param application application which will be resumed + * @param saved_app application specific section from backup file + */ + void RestoreAppWidgets(application_manager::ApplicationSharedPtr application, + const smart_objects::SmartObject& saved_app) OVERRIDE; + /** * @brief Remove application from list of saved applications * @param application is application which need to be removed @@ -250,8 +261,9 @@ class ResumeCtrlImpl : public ResumeCtrl, * @brief Resume HMI Level and audio streaming state if needed * @param application - application to restore hmi level * and audio streaming state + * @return true if success otherwise false */ - void StartAppHmiStateResumption( + bool StartAppHmiStateResumption( app_mngr::ApplicationSharedPtr application) OVERRIDE; /** @@ -296,6 +308,9 @@ class ResumeCtrlImpl : public ResumeCtrl, int32_t GetSavedAppHmiLevel(const std::string& app_id, const std::string& device_id) const OVERRIDE; + void StartWaitingForDisplayCapabilitiesUpdate( + app_mngr::ApplicationSharedPtr application) OVERRIDE; + /** * @brief geter for launch_time_ * @return value of launch_time_ @@ -322,10 +337,10 @@ class ResumeCtrlImpl : public ResumeCtrl, #endif // BUILD_TESTS private: /** - * @brief Returns Low Voltage signal timestamp - * @return Low Voltage event timestamp if event LOW VOLTAGE event occures - * otherwise 0 - */ + * @brief Returns Low Voltage signal timestamp + * @return Low Voltage event timestamp if event LOW VOLTAGE event occures + * otherwise 0 + */ time_t LowVoltageTime() const; /** @@ -591,6 +606,16 @@ class ResumeCtrlImpl : public ResumeCtrl, mobile_apis::HMILevel::eType GetHmiLevelOnLowBandwidthTransport( app_mngr::ApplicationConstSharedPtr application) const; + /** + * @brief Constructs and sends system capability mobile notification + * + * @param app to send display capabilities updated + * @param display_capabilities SO containing notification data + */ + void ProcessSystemCapabilityUpdated( + app_mngr::Application& app, + const smart_objects::SmartObject& display_capabilities); + /** *@brief Mapping applications to time_stamps * wait for timer to resume HMI Level @@ -609,6 +634,13 @@ class ResumeCtrlImpl : public ResumeCtrl, time_t wake_up_time_; std::shared_ptr resumption_storage_; application_manager::ApplicationManager& application_manager_; + /** + *@brief Mapping correlation id to request + *wait for on event response from HMI to resume HMI Level + */ + typedef std::map + WaitingResponseToRequest; + WaitingResponseToRequest requests_msg_; }; } // namespace resumption 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 c2634173a50..d1dada345ce 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 @@ -1,5 +1,5 @@ -/* - * Copyright (c) 2015, Ford Motor Company +/* + * Copyright (c) 2019, Ford Motor Company * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -33,9 +33,9 @@ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_RESUMPTION_RESUMPTION_DATA_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_RESUMPTION_RESUMPTION_DATA_H_ -#include "smart_objects/smart_object.h" #include "application_manager/application.h" #include "application_manager/application_manager.h" +#include "smart_objects/smart_object.h" #include "utils/macro.h" namespace application_manager { @@ -255,6 +255,14 @@ class ResumptionData { smart_objects::SmartObject GetApplicationFiles( app_mngr::ApplicationConstSharedPtr application) const; + /** + * @brief Retrieves of windows info from list of available window + * @param application contains list of available windows + * @return windows info from list of available window + */ + smart_objects::SmartObject GetApplicationWidgetsInfo( + app_mngr::ApplicationConstSharedPtr application) const; + /** * @brief checks pointer that it is not equal NULL * @param ptr - contains pointer which need to check @@ -263,6 +271,21 @@ class ResumptionData { smart_objects::SmartObject PointerToSmartObj( const smart_objects::SmartObject* ptr) const; + /** + * @brief creates smart object containing window info + * @param window_id window id + * @param window_type window type + * @param window_name window name + * @param window_optional_params_map collection containing optional params for + * creating window + * @return smart object with window data + */ + smart_objects::SmartObject CreateWindowInfoSO( + const application_manager::WindowID window_id, + const mobile_apis::WindowType::eType window_type, + const application_manager::WindowParamsMap& window_optional_params_map) + const; + /** * @brief Creates smart array from received data * @param first - iterator points to beginning of the data diff --git a/src/components/application_manager/include/application_manager/rpc_handler_impl.h b/src/components/application_manager/include/application_manager/rpc_handler_impl.h index e1dc9e6c5d3..b1e94ab3319 100644 --- a/src/components/application_manager/include/application_manager/rpc_handler_impl.h +++ b/src/components/application_manager/include/application_manager/rpc_handler_impl.h @@ -35,18 +35,18 @@ #include "application_manager/application_manager.h" #include "application_manager/message_helper.h" -#include "application_manager/rpc_handler.h" -#include "application_manager/rpc_service.h" #include "application_manager/mobile_message_handler.h" #include "application_manager/policies/policy_handler_observer.h" +#include "application_manager/rpc_handler.h" +#include "application_manager/rpc_service.h" -#include "protocol_handler/protocol_observer.h" #include "hmi_message_handler/hmi_message_observer.h" #include "hmi_message_handler/hmi_message_sender.h" +#include "protocol_handler/protocol_observer.h" -#include "formatters/formatter_json_rpc.h" -#include "formatters/CFormatterJsonSDLRPCv2.h" #include "formatters/CFormatterJsonSDLRPCv1.h" +#include "formatters/CFormatterJsonSDLRPCv2.h" +#include "formatters/formatter_json_rpc.h" #include "interfaces/HMI_API_schema.h" #include "interfaces/MOBILE_API_schema.h" #ifdef TELEMETRY_MONITOR @@ -56,8 +56,8 @@ #include "interfaces/v4_protocol_v1_2_no_extra.h" #include "interfaces/v4_protocol_v1_2_no_extra_schema.h" -#include "utils/threads/message_loop_thread.h" #include "utils/semantic_version.h" +#include "utils/threads/message_loop_thread.h" namespace application_manager { namespace rpc_handler { @@ -87,13 +87,15 @@ typedef threads::MessageLoopThread > FromMobileQueue; typedef threads::MessageLoopThread > FromHmiQueue; -} +} // namespace impl class RPCHandlerImpl : public RPCHandler, public impl::FromMobileQueue::Handler, public impl::FromHmiQueue::Handler { public: - RPCHandlerImpl(ApplicationManager& app_manager); + RPCHandlerImpl(ApplicationManager& app_manager, + hmi_apis::HMI_API& hmi_so_factory, + mobile_apis::MOBILE_API& mobile_so_factory); ~RPCHandlerImpl(); // CALLED ON messages_from_mobile_ thread! @@ -177,8 +179,8 @@ class RPCHandlerImpl : public RPCHandler, // Thread that pumps messages coming from HMI. impl::FromHmiQueue messages_from_hmi_; - hmi_apis::HMI_API hmi_so_factory_; - mobile_apis::MOBILE_API mobile_so_factory_; + hmi_apis::HMI_API& hmi_so_factory_; + mobile_apis::MOBILE_API& mobile_so_factory_; #ifdef TELEMETRY_MONITOR AMTelemetryObserver* metric_observer_; #endif // TELEMETRY_MONITOR diff --git a/src/components/application_manager/include/application_manager/rpc_protection_manager.h b/src/components/application_manager/include/application_manager/rpc_protection_manager.h new file mode 100644 index 00000000000..34188da4e9e --- /dev/null +++ b/src/components/application_manager/include/application_manager/rpc_protection_manager.h @@ -0,0 +1,111 @@ +/* + * Copyright (c) 2019, 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_PROTOCOL_HANDLER_RPC_PROTECTION_MANAGER_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_PROTOCOL_HANDLER_RPC_PROTECTION_MANAGER_H_ + +#include +#include + +#include "application_manager/application.h" +#include "application_manager/policies/policy_handler_observer.h" +#include "smart_objects/smart_object.h" + +namespace ns_smart_device_link { +namespace ns_smart_objects { +class SmartObject; +} // namespace ns_smart_objects +} // namespace ns_smart_device_link +namespace smart_objects = ns_smart_device_link::ns_smart_objects; + +namespace application_manager { +class Application; +} // namespace application_manager + +namespace application_manager { +/** + * @brief RPCProtectionManager interface + * This entity exists to get info from policy table regarding encryption on + * application and function group level, as well as make decisions whether + * certain RPC should be encrypted or not. + * It mediates communication between PRCService and + * PolicyEncryptionFlagGetterInterface which is implemented by PolicyManager, + * providing adequate level of abstraction. + */ +class RPCProtectionManager : public policy::PolicyHandlerObserver { + public: + /* + * @brief virtual destructor RPCProtectionManager + */ + virtual ~RPCProtectionManager() {} + + /* + * @brief checks whether given rpc requires encryption by policy + * @param function_id function id + * @param app ref to Application + * @param is_rpc_service_secure the flag the secure service started + * @return true if function need encryption for current app, else false + */ + virtual bool CheckPolicyEncryptionFlag( + const uint32_t function_id, + const ApplicationSharedPtr app, + const bool is_rpc_service_secure) const = 0; + /* + * @brief check whether given rpc is saved to internal cache and needs to be + * encrypted before sending to mobile + * @param app_id application id + * @param correlation_id correlation id + * @return true if the message with correlation id correlation_id needed e + * ncryption else false + */ + virtual bool IsInEncryptionNeededCache( + const uint32_t app_id, const uint32_t conrrelation_id) const = 0; + + /* + * @brief Adds app id and correlation id of a message to internal cache + * @param app_id application if + * @param correlation_id correlation id + */ + virtual void AddToEncryptionNeededCache(const uint32_t app_id, + const uint32_t correlation_id) = 0; + + /* + * @brief Removes app id and correlation id of a message from internal cache + * @param app_id application if + * @param correlation_id correlation id + */ + virtual void RemoveFromEncryptionNeededCache( + const uint32_t app_id, const uint32_t correlation_id) = 0; +}; +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_PROTOCOL_HANDLER_RPC_PROTECTION_MANAGER_H_ diff --git a/src/components/application_manager/include/application_manager/rpc_protection_manager_impl.h b/src/components/application_manager/include/application_manager/rpc_protection_manager_impl.h new file mode 100644 index 00000000000..b971ace480d --- /dev/null +++ b/src/components/application_manager/include/application_manager/rpc_protection_manager_impl.h @@ -0,0 +1,116 @@ +/* + * Copyright (c) 2019, 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_PROTOCOL_HANDLER_RPC_PROTECTION_MANAGER_IMPL_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_PROTOCOL_HANDLER_RPC_PROTECTION_MANAGER_IMPL_H_ + +#include +#include +#include "application_manager/policies/policy_handler.h" +#include "application_manager/rpc_protection_manager.h" + +namespace application_manager { +/* + * @brief RPCProtectionManager implementation + */ +class RPCProtectionManagerImpl : public RPCProtectionManager { + public: + typedef std::pair AppIdCorrIdPair; + typedef std::set FunctionNames; + typedef std::map AppEncryptedRpcMap; + + RPCProtectionManagerImpl(policy::PolicyHandlerInterface& policy_handler); + + ~RPCProtectionManagerImpl() OVERRIDE {} + + bool CheckPolicyEncryptionFlag( + const uint32_t function_id, + const ApplicationSharedPtr app, + const bool is_rpc_service_secure) const OVERRIDE; + + bool IsInEncryptionNeededCache(const uint32_t app_id, + const uint32_t conrrelation_id) const OVERRIDE; + + void AddToEncryptionNeededCache(const uint32_t app_id, + const uint32_t correlation_id) OVERRIDE; + + void RemoveFromEncryptionNeededCache(const uint32_t app_id, + const uint32_t correlation_id) OVERRIDE; + + // PolicyHandlerObserver interface + void OnPTUFinished(const bool ptu_result) OVERRIDE; + + void OnPTInited() OVERRIDE; + + private: + /* + * @brief check whether given rpc is an exception + * @param function_id function id + * @return true if function_id is an exception (rpc that can be sent before + * app is registered, hence before secure rpc service is established) + */ + bool IsExceptionRPC(const uint32_t function_id) const; + + /* + * @brief retreives list of rpcs that require encryption by policy + * @param policy_app_id policy application name + * @return container with function names that require encryption by policy + */ + FunctionNames GetEncryptedRPCsForApp(const std::string& policy_app_id); + + /* + * @brief checks whether given function name is in saved encrypted rpc list + * @param policy_app_id policy application name + * @param function_name policy function name + * @return true if function_name for this policy_app_id is saved, otherwise - + * false + */ + bool IsEncryptionRequiredByPolicy(const std::string& policy_app_id, + const std::string& function_name) const; + + /* + * @brief saves rpcs that have encryption_required flag in policy table to + * internal container + */ + void SaveEncryptedRPC(); + + policy::PolicyHandlerInterface& policy_handler_; + + AppEncryptedRpcMap encrypted_rpcs_; + sync_primitives::Lock encrypted_rpcs_lock_; + + std::set encryption_needed_cache_; + sync_primitives::Lock message_needed_encryption_lock_; +}; +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_PROTOCOL_HANDLER_RPC_PROTECTION_MANAGER_IMPL_H_ diff --git a/src/components/application_manager/include/application_manager/rpc_service_impl.h b/src/components/application_manager/include/application_manager/rpc_service_impl.h index 98aad1a90e7..3e3d83a5195 100644 --- a/src/components/application_manager/include/application_manager/rpc_service_impl.h +++ b/src/components/application_manager/include/application_manager/rpc_service_impl.h @@ -34,24 +34,25 @@ #define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_RPC_SERVICE_IMPL_H #include "application_manager/application_manager.h" -#include "application_manager/rpc_service.h" -#include "application_manager/request_controller.h" +#include "application_manager/command_holder_impl.h" #include "application_manager/message_helper.h" -#include "application_manager/usage_statistics.h" #include "application_manager/mobile_message_handler.h" -#include "application_manager/command_holder_impl.h" +#include "application_manager/request_controller.h" +#include "application_manager/rpc_protection_manager.h" +#include "application_manager/rpc_service.h" +#include "application_manager/usage_statistics.h" -#include "formatters/formatter_json_rpc.h" -#include "formatters/CFormatterJsonSDLRPCv2.h" #include "formatters/CFormatterJsonSDLRPCv1.h" +#include "formatters/CFormatterJsonSDLRPCv2.h" +#include "formatters/formatter_json_rpc.h" #include "interfaces/HMI_API_schema.h" #include "interfaces/MOBILE_API_schema.h" #include "interfaces/v4_protocol_v1_2_no_extra.h" #include "interfaces/v4_protocol_v1_2_no_extra_schema.h" -#include "utils/threads/message_loop_thread.h" #include "utils/logger.h" +#include "utils/threads/message_loop_thread.h" namespace application_manager { namespace rpc_service { @@ -85,7 +86,15 @@ typedef threads::MessageLoopThread > ToMobileQueue; typedef threads::MessageLoopThread > ToHmiQueue; -} +} // namespace impl + +typedef std::shared_ptr RPCProtectionManagerSPtr; + +enum class EncryptionFlagCheckResult { + kSuccess_Protected, + kSuccess_NotProtected, + kError_EncryptionNeeded +}; class RPCServiceImpl : public RPCService, public impl::ToMobileQueue::Handler, @@ -103,9 +112,14 @@ class RPCServiceImpl : public RPCService, request_controller::RequestController& request_ctrl, protocol_handler::ProtocolHandler* protocol_handler, hmi_message_handler::HMIMessageHandler* hmi_handler, - CommandHolder& commands_holder); + CommandHolder& commands_holder, + RPCProtectionManagerSPtr rpc_protection_manager, + hmi_apis::HMI_API& hmi_so_factory_, + mobile_apis::MOBILE_API& mobile_so_factory_); ~RPCServiceImpl(); + void Stop() OVERRIDE; + bool ManageMobileCommand(const commands::MessageSharedPtr message, commands::Command::CommandSource source) OVERRIDE; bool ManageHMICommand(const commands::MessageSharedPtr message, @@ -122,17 +136,31 @@ class RPCServiceImpl : public RPCService, void SendMessageToHMI(const commands::MessageSharedPtr message) OVERRIDE; bool IsAppServiceRPC(int32_t function_id, - commands::Command::CommandSource source); + commands::Command::CommandSource source) OVERRIDE; void set_protocol_handler( protocol_handler::ProtocolHandler* handler) OVERRIDE; void set_hmi_message_handler( hmi_message_handler::HMIMessageHandler* handler) OVERRIDE; + void UpdateMobileRPCParams( + const mobile_apis::FunctionID::eType& function_id, + const mobile_apis::messageType::eType& message_type, + const std::map& members) OVERRIDE; + void UpdateHMIRPCParams( + const hmi_apis::FunctionID::eType& function_id, + const hmi_apis::messageType::eType& message_type, + const std::map& members) OVERRIDE; + private: bool ConvertSOtoMessage(const smart_objects::SmartObject& message, Message& output, const bool allow_unknown_parameters = false); + + EncryptionFlagCheckResult IsEncryptionRequired( + const smart_objects::SmartObject& message, + ApplicationSharedPtr app, + const bool is_rpc_service_secure) const; hmi_apis::HMI_API& hmi_so_factory(); mobile_apis::MOBILE_API& mobile_so_factory(); void CheckSourceForUnsupportedRequest( @@ -143,14 +171,15 @@ class RPCServiceImpl : public RPCService, request_controller::RequestController& request_ctrl_; protocol_handler::ProtocolHandler* protocol_handler_; hmi_message_handler::HMIMessageHandler* hmi_handler_; + RPCProtectionManagerSPtr rpc_protection_manager_; CommandHolder& commands_holder_; // Thread that pumps messages being passed to mobile side. impl::ToMobileQueue messages_to_mobile_; // Thread that pumps messages being passed to HMI. impl::ToHmiQueue messages_to_hmi_; - hmi_apis::HMI_API hmi_so_factory_; - mobile_apis::MOBILE_API mobile_so_factory_; + hmi_apis::HMI_API& hmi_so_factory_; + mobile_apis::MOBILE_API& mobile_so_factory_; }; } // namespace rpc_service } // namespace application_manager 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 5d04207200f..19dd6fbe3b7 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 @@ -1,5 +1,5 @@ /* - Copyright (c) 2013, Ford Motor Company + Copyright (c) 2019, Ford Motor Company All rights reserved. Redistribution and use in source and binary forms, with or without @@ -38,6 +38,8 @@ namespace application_manager { namespace strings { extern const char* params; +extern const char* require_encryption; +extern const char* protection; extern const char* message_type; extern const char* correlation_id; extern const char* function_id; @@ -53,6 +55,7 @@ extern const char* info; extern const char* app_id; extern const char* full_app_id; extern const char* bundle_id; +extern const char* window_id; extern const char* app_info; extern const char* app_launch; extern const char* app_launch_list; @@ -92,6 +95,7 @@ extern const char* main_field_1; extern const char* main_field_2; extern const char* main_field_3; extern const char* main_field_4; +extern const char* template_title; extern const char* metadata_tags; extern const char* eta; extern const char* time_to_destination; @@ -110,10 +114,13 @@ extern const char* menu_icon; extern const char* keyboard_properties; extern const char* vr_commands; extern const char* position; +extern const char* user_location; extern const char* num_ticks; extern const char* slider_footer; extern const char* menu_id; extern const char* menu_name; +extern const char* menu_layout; +extern const char* menu_layouts_available; extern const char* interaction_choice_set_id; extern const char* interaction_choice_set_id_list; extern const char* choice_set; @@ -129,7 +136,10 @@ extern const char* initial_prompt; extern const char* initial_text; extern const char* duration; extern const char* progress_indicator; +extern const char* func_id; +extern const char* cancel_id; extern const char* alert_type; +extern const char* alert_icon; extern const char* play_tone; extern const char* soft_buttons; extern const char* soft_button_id; @@ -166,9 +176,17 @@ extern const char* activate_app_hmi_level; extern const char* audio_streaming_state; extern const char* video_streaming_state; extern const char* system_context; +extern const char* window_name; +extern const char* window_type; +extern const char* window_type_supported; +extern const char* maximum_number_of_windows; +extern const char* window_capabilities; +extern const char* associated_service_type; +extern const char* duplicate_updates_from_window_id; extern const char* speech_capabilities; extern const char* vr_capabilities; extern const char* audio_pass_thru_capabilities; +extern const char* audio_pass_thru_capabilities_list; extern const char* pcm_stream_capabilities; extern const char* audio_pass_thru_icon; extern const char* way_points; @@ -179,6 +197,7 @@ extern const char* navigation_capability; extern const char* phone_capability; extern const char* video_streaming_capability; extern const char* rc_capability; +extern const char* seat_location_capability; extern const char* app_services_capabilities; extern const char* day_color_scheme; extern const char* night_color_scheme; @@ -189,6 +208,8 @@ extern const char* red; extern const char* green; extern const char* blue; extern const char* display_layout; +extern const char* template_configuration; +extern const char* template_layout; extern const char* icon_resumed; extern const char* nicknames; extern const char* enabled; @@ -198,6 +219,11 @@ extern const char* hybrid_app_preference; extern const char* is_cloud_application; extern const char* cloud_connection_status; extern const char* endpoint; +extern const char* display_capabilities; +extern const char* policy_type; +extern const char* property; +extern const char* displays; +extern const char* seat_location; // PutFile extern const char* sync_file_name; @@ -216,6 +242,7 @@ extern const char* is_template; extern const char* image; extern const char* type; extern const char* system_file; +extern const char* is_system_file; extern const char* offset; extern const char* length; extern const char* secondary_image; @@ -254,6 +281,7 @@ extern const char* key_press_mode; // duplicate names from hmi_request extern const char* limited_character_list; extern const char* auto_complete_text; +extern const char* auto_complete_list; extern const char* navigation_text; // vehicle info @@ -285,6 +313,7 @@ extern const char* e_call_info; extern const char* airbag_status; extern const char* emergency_event; extern const char* cluster_mode_status; +extern const char* cluster_modes; extern const char* my_key; extern const char* help_prompt; extern const char* scroll_message_body; @@ -304,6 +333,7 @@ extern const char* sdl_version; extern const char* system_software_version; extern const char* priority; extern const char* engine_oil_life; +extern const char* oem_custom_data_type; // app services extern const char* app_service_manifest; @@ -322,6 +352,7 @@ extern const char* service_active; extern const char* app_service_id; extern const char* service_data; extern const char* media_service_data; +extern const char* media_image; extern const char* weather_service_data; extern const char* location; extern const char* current_forecast; @@ -343,6 +374,10 @@ extern const char* activate; extern const char* set_as_default; extern const char* origin_app; +// sis data +extern const char* station_short_name; +extern const char* station_location; + // resuming extern const char* application_commands; extern const char* application_submenus; @@ -363,11 +398,16 @@ extern const char* ign_off_count; extern const char* global_ign_on_counter; +extern const char* suspend_count; + extern const char* connection_info; extern const char* is_download_complete; +extern const char* shifted; +extern const char* altitude; extern const char* longitude_degrees; extern const char* latitude_degrees; + extern const char* address; extern const char* country_name; extern const char* country_code; @@ -396,6 +436,8 @@ extern const char* delivery_mode; extern const char* audio_streaming_indicator; +extern const char* windows_info; + // keys for default parameters loaded from hmi_capabilities.json: extern const char* const keyboard_properties_default; extern const char* const language_default; @@ -408,7 +450,6 @@ extern const char* const language_supported; extern const char* const keyboard_layout_supported; extern const char* const keypress_mode_supported; extern const char* const limited_characters_list_supported; -extern const char* const auto_complete_text_supported; extern const char* const send_location_enabled; extern const char* const get_way_points_enabled; extern const char* const entity_type; @@ -429,6 +470,9 @@ extern const char* const resolution_height; extern const char* const max_bitrate; extern const char* const supported_formats; extern const char* const haptic_spatial_data_supported; +extern const char* const diagonal_screen_size; +extern const char* const pixel_per_inch; +extern const char* const scale; extern const char* const haptic_rect_data; extern const char* const rect; extern const char* const x; @@ -465,12 +509,14 @@ extern const char* instance_follow_redirect; extern const char* charset; extern const char* content_lenght; extern const char* GET; -} // http_request +} // namespace http_request namespace mobile_notification { extern const char* state; extern const char* syncp_timeout; extern const char* syncp_url; +extern const char* lock_screen_dismissal_enabled; +extern const char* lock_screen_dismissal_warning; } // namespace mobile_notification namespace hmi_levels { @@ -517,7 +563,7 @@ extern const char* keyboard_properties; extern const char* method_name; extern const char* keyboard_layout; extern const char* limited_character_list; -extern const char* auto_complete_text; +extern const char* auto_complete_list; extern const char* file; extern const char* file_name; extern const char* retry; @@ -578,6 +624,9 @@ extern const char* policyfile; extern const char* is_active; extern const char* is_deactivated; extern const char* event_name; +extern const char* service_type; +extern const char* service_event; +extern const char* reason; } // namespace hmi_notification diff --git a/src/components/application_manager/include/application_manager/state_controller_impl.h b/src/components/application_manager/include/application_manager/state_controller_impl.h index 8270e9b807e..000569e450a 100644 --- a/src/components/application_manager/include/application_manager/state_controller_impl.h +++ b/src/components/application_manager/include/application_manager/state_controller_impl.h @@ -35,15 +35,15 @@ #include #include -#include "application_manager/hmi_state.h" #include "application_manager/application.h" #include "application_manager/application_manager.h" -#include "event_engine/event_observer.h" -#include "application_manager/state_controller.h" +#include "application_manager/hmi_state.h" #include "application_manager/message_helper.h" +#include "application_manager/state_controller.h" +#include "event_engine/event_observer.h" #include "interfaces/MOBILE_API.h" -#include "utils/lock.h" #include "utils/helpers.h" +#include "utils/lock.h" namespace application_manager { @@ -52,155 +52,101 @@ class StateControllerImpl : public event_engine::EventObserver, public: explicit StateControllerImpl(ApplicationManager& app_mngr); - /** - * @brief SetRegularState setup regular hmi state, that will appear if - * no specific events are active - * @param app appication to setup regular State - * @param state state of new regular state - */ - - virtual void SetRegularState(ApplicationSharedPtr app, - HmiStatePtr state, - const bool SendActivateApp); - - /** - * @brief SetRegularState Change regular hmi level and audio state - * @param app appication to setup regular State - * @param hmi_level of new regular state - * @param audio_state of new regular state - * @paran video_state of new regular state - * @param SendActivateApp: if true, ActivateAppRequest will be sent on HMI */ + void SetRegularState(ApplicationSharedPtr app, + const WindowID window_id, + HmiStatePtr state, + const bool SendActivateApp) OVERRIDE; - virtual void SetRegularState( + void SetRegularState( ApplicationSharedPtr app, + const WindowID window_id, const mobile_apis::HMILevel::eType hmi_level, const mobile_apis::AudioStreamingState::eType audio_state, const mobile_apis::VideoStreamingState::eType video_state, - const bool SendActivateApp); + const bool SendActivateApp) OVERRIDE; - /** - * @brief SetRegularState Change regular hmi level - * @param app appication to setup regular State - * @param hmi_level of new regular state - * @param SendActivateApp: if true, ActivateAppRequest will be sent on HMI - */ - virtual void SetRegularState(ApplicationSharedPtr app, - const mobile_apis::HMILevel::eType hmi_level, - const bool SendActivateApp); - - /** - * @brief SetRegularState Change regular hmi level, audio state and system - * context - * @param app appication to setup regular State - * @param hmi_level of new regular state - * @param audio_state of new regular state - * @param video_state of new regular state - * @param system_context of new regular state - * @param SendActivateApp: if true, ActivateAppRequest will be sent on HMI */ + void SetRegularState(ApplicationSharedPtr app, + const WindowID window_id, + const mobile_apis::HMILevel::eType hmi_level, + const bool SendActivateApp) OVERRIDE; - virtual void SetRegularState( + void SetRegularState( ApplicationSharedPtr app, + const WindowID window_id, const mobile_apis::HMILevel::eType hmi_level, const mobile_apis::AudioStreamingState::eType audio_state, const mobile_apis::VideoStreamingState::eType video_state, const mobile_apis::SystemContext::eType system_context, - const bool SendActivateApp); + const bool SendActivateApp) OVERRIDE; - /** - * @brief SetRegularState Sets regular state with new hmi level - * to application - * @param app appication to setup regular state - * @param hmi_level new hmi level for application - */ - virtual void SetRegularState(ApplicationSharedPtr app, - const mobile_apis::HMILevel::eType hmi_level); + void SetRegularState(ApplicationSharedPtr app, + const WindowID window_id, + const mobile_apis::HMILevel::eType hmi_level) OVERRIDE; - /** - * @brief SetRegularState Change regular audio state - * @param app appication to setup regular State - * @param audio_state of new regular state - * @param video_state of new regular state - */ - virtual void SetRegularState( + void SetRegularState( ApplicationSharedPtr app, + const WindowID window_id, const mobile_apis::AudioStreamingState::eType audio_state, - const mobile_apis::VideoStreamingState::eType video_state); + const mobile_apis::VideoStreamingState::eType video_state) OVERRIDE; - /** - * @brief SetRegularState Change regular system context - * @param app appication to setup regular State - * @param system_context of new regular state - */ - virtual void SetRegularState( + void SetRegularState( ApplicationSharedPtr app, - const mobile_apis::SystemContext::eType system_context); + const WindowID window_id, + const mobile_apis::SystemContext::eType system_context) OVERRIDE; - /** - * @brief SetRegularState Sets new regular state to application - * @param app appication to setup regular state - * @param state new hmi state for application - */ - virtual void SetRegularState(ApplicationSharedPtr app, HmiStatePtr state); + void SetRegularState(ApplicationSharedPtr app, + const WindowID window_id, + HmiStatePtr state) OVERRIDE; - // EventObserver interface - void on_event(const event_engine::Event& event); - void on_event(const event_engine::MobileEvent& event); + void OnApplicationRegistered( + ApplicationSharedPtr app, + const mobile_apis::HMILevel::eType default_level) OVERRIDE; - /** - * @brief Sets default application state and apply currently active HMI states - * on application registration - * @param app application to apply states - * @param default_level default HMI level - */ - virtual void OnApplicationRegistered( + void OnAppWindowAdded( ApplicationSharedPtr app, - const mobile_apis::HMILevel::eType default_level); + const WindowID window_id, + const mobile_apis::WindowType::eType window_type, + const mobile_apis::HMILevel::eType default_level) OVERRIDE; - /** - * @brief OnVideoStreamingStarted process video streaming started - * @param app projection or navigation application starting streaming - */ - virtual void OnVideoStreamingStarted(ApplicationConstSharedPtr app); + void OnVideoStreamingStarted(ApplicationConstSharedPtr app) OVERRIDE; - /** - * @brief OnVideoStreamingStopped process video streaming stopped - * @param app projection or navigation application stopping streaming - */ - virtual void OnVideoStreamingStopped(ApplicationConstSharedPtr app); + void OnVideoStreamingStopped(ApplicationConstSharedPtr app) OVERRIDE; - /** - * @brief OnStateChanged send HMIStatusNotification if needed - * @param app application - * @param old_state state before change - * @param new_state state after change - */ - virtual void OnStateChanged(ApplicationSharedPtr app, - HmiStatePtr old_state, - HmiStatePtr new_state); + void OnStateChanged(ApplicationSharedPtr app, + const WindowID window_id, + HmiStatePtr old_state, + HmiStatePtr new_state) OVERRIDE; - /** - * @brief Checks activity of Deactivate HMI state. - * @return Returns TRUE if deactivate HMI state is active, otherwise returns - * FALSE. - */ - virtual bool IsStateActive(HmiState::StateID state_id) const; + bool IsStateActive(HmiState::StateID state_id) const OVERRIDE; + + // EventObserver interface + void on_event(const event_engine::Event& event) OVERRIDE; + void on_event(const event_engine::MobileEvent& event) OVERRIDE; + + void ActivateDefaultWindow(ApplicationSharedPtr app) OVERRIDE; + void ExitDefaultWindow(ApplicationSharedPtr app) OVERRIDE; private: - int64_t SendBCActivateApp(ApplicationConstSharedPtr app, - hmi_apis::Common_HMILevel::eType level, - bool send_policy_priority); + int64_t RequestHMIStateChange(ApplicationConstSharedPtr app, + hmi_apis::Common_HMILevel::eType level, + bool send_policy_priority); /** * @brief The HmiLevelConflictResolver struct * Move other application to HmiStates if applied moved to FULL or LIMITED */ struct HmiLevelConflictResolver { const ApplicationSharedPtr applied_; + const WindowID window_id_; const HmiStatePtr state_; StateControllerImpl* state_ctrl_; HmiLevelConflictResolver(const ApplicationSharedPtr app, + const WindowID window_id, const HmiStatePtr state, StateControllerImpl* state_ctrl) - : applied_(app), state_(state), state_ctrl_(state_ctrl) {} + : applied_(app) + , window_id_(window_id) + , state_(state) + , state_ctrl_(state_ctrl) {} void operator()(ApplicationSharedPtr to_resolve); }; @@ -298,14 +244,19 @@ class StateControllerImpl : public event_engine::EventObserver, template void HMIStateStarted(ApplicationSharedPtr app) { DCHECK_OR_RETURN_VOID(app); - HmiStatePtr old_hmi_state = app->CurrentHmiState(); - HmiStatePtr new_hmi_state = CreateHmiState(app, ID); - DCHECK_OR_RETURN_VOID(new_hmi_state); - DCHECK_OR_RETURN_VOID(new_hmi_state->state_id() != - HmiState::STATE_ID_REGULAR); - new_hmi_state->set_parent(old_hmi_state); - app->AddHMIState(new_hmi_state); - OnStateChanged(app, old_hmi_state, new_hmi_state); + const WindowIds window_ids = app->GetWindowIds(); + + for (auto window_id : window_ids) { + HmiStatePtr old_hmi_state = app->CurrentHmiState(window_id); + HmiStatePtr new_hmi_state = CreateHmiState(app, ID); + DCHECK_OR_RETURN_VOID(new_hmi_state); + DCHECK_OR_RETURN_VOID(new_hmi_state->state_id() != + HmiState::STATE_ID_REGULAR); + new_hmi_state->set_parent(old_hmi_state); + new_hmi_state->set_window_type(old_hmi_state->window_type()); + app->AddHMIState(window_id, new_hmi_state); + OnStateChanged(app, window_id, old_hmi_state, new_hmi_state); + } } /** @@ -326,7 +277,7 @@ class StateControllerImpl : public event_engine::EventObserver, * depends on application type * @param app Application to deactivate */ - void DeactivateApp(ApplicationSharedPtr app); + void DeactivateApp(ApplicationSharedPtr app, const WindowID window_id); /** * Function to remove temporary HmiState for application @@ -334,54 +285,78 @@ class StateControllerImpl : public event_engine::EventObserver, template void HMIStateStopped(ApplicationSharedPtr app) { DCHECK_OR_RETURN_VOID(app); - HmiStatePtr cur = app->CurrentHmiState(); - HmiStatePtr old_hmi_state = - CreateHmiState(app, HmiState::StateID::STATE_ID_REGULAR); - DCHECK_OR_RETURN_VOID(old_hmi_state); - old_hmi_state->set_hmi_level(cur->hmi_level()); - old_hmi_state->set_audio_streaming_state(cur->audio_streaming_state()); - old_hmi_state->set_video_streaming_state(cur->video_streaming_state()); - old_hmi_state->set_system_context(cur->system_context()); - app->RemoveHMIState(ID); - HmiStatePtr new_hmi_state = app->CurrentHmiState(); - OnStateChanged(app, old_hmi_state, new_hmi_state); + const WindowIds window_ids = app->GetWindowIds(); + + for (auto window_id : window_ids) { + HmiStatePtr cur = app->CurrentHmiState(window_id); + HmiStatePtr old_hmi_state = + CreateHmiState(app, HmiState::StateID::STATE_ID_REGULAR); + DCHECK_OR_RETURN_VOID(old_hmi_state); + old_hmi_state->set_hmi_level(cur->hmi_level()); + old_hmi_state->set_window_type(cur->window_type()); + old_hmi_state->set_audio_streaming_state(cur->audio_streaming_state()); + old_hmi_state->set_video_streaming_state(cur->video_streaming_state()); + old_hmi_state->set_system_context(cur->system_context()); + app->RemoveHMIState(window_id, ID); + HmiStatePtr new_hmi_state = app->CurrentHmiState(window_id); + OnStateChanged(app, window_id, old_hmi_state, new_hmi_state); + } } /** * @brief ApplyRegularState setup regular hmi state, that will appear if no * specific events are active, without sending ActivateApp * @param app appication to setup default State + * @param window_id id of applicaion's window to apply HMI state * @param state state of new defailt state */ - void ApplyRegularState(ApplicationSharedPtr app, HmiStatePtr state); + void ApplyRegularState(ApplicationSharedPtr app, + const WindowID window_id, + HmiStatePtr state); + + /** + * @brief UpdateAppWindowsStreamingState updates all application windows + * audio/video streaming state according to a new HMI state of the main window + * @param app pointer to affected application + * @param state pointer to state with the new streaming state of the main + * window + */ + void UpdateAppWindowsStreamingState(ApplicationSharedPtr app, + HmiStatePtr state); /** * @brief SetupRegularHmiState set regular HMI State without * resolving conflicts and ActivateApp request * @param app application + * @param window_id id of applicaion's window to apply HMI state * @param state hmi_state to setup */ - void SetupRegularHmiState(ApplicationSharedPtr app, HmiStatePtr state); + void SetupRegularHmiState(ApplicationSharedPtr app, + const WindowID window_id, + HmiStatePtr state); /** * @brief SetupRegularHmiState set regular HMI State without * resolving conflicts and ActivateApp request * @param app application + * @param window_id id of applicaion's window to apply HMI state * @param hmi_level of new regular state * @param audio_state of new regular state * @param video_state of new regular state */ void SetupRegularHmiState( ApplicationSharedPtr app, + const WindowID window_id, const mobile_apis::HMILevel::eType hmi_level, const mobile_apis::AudioStreamingState::eType audio_state, const mobile_apis::VideoStreamingState::eType video_state); /** - * @brief OnActivateAppResponse calback for activate app response + * @brief OnHMIResponse callback for activate app or close application + * response * @param message Smart Object */ - void OnActivateAppResponse(const smart_objects::SmartObject& message); + void OnHMIResponse(const smart_objects::SmartObject& message); /** * @brief OnAppDeactivated callback for OnAppDeactivated notification @@ -449,9 +424,9 @@ class StateControllerImpl : public event_engine::EventObserver, typedef std::list StateIDList; StateIDList active_states_; mutable sync_primitives::Lock active_states_lock_; - std::map waiting_for_activate_; + std::map waiting_for_response_; ApplicationManager& app_mngr_; }; -} +} // namespace application_manager #endif // SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_STATE_CONTROLLER_IMPL_H_ diff --git a/src/components/application_manager/include/application_manager/system_time/system_time_handler_impl.h b/src/components/application_manager/include/application_manager/system_time/system_time_handler_impl.h index 05565861f6f..a8ba796a1bc 100644 --- a/src/components/application_manager/include/application_manager/system_time/system_time_handler_impl.h +++ b/src/components/application_manager/include/application_manager/system_time/system_time_handler_impl.h @@ -36,11 +36,11 @@ #include #include +#include "application_manager/application_manager.h" +#include "application_manager/event_engine/event_observer.h" #include "utils/lock.h" #include "utils/macro.h" #include "utils/system_time_handler.h" -#include "application_manager/application_manager.h" -#include "application_manager/event_engine/event_observer.h" namespace application_manager { @@ -129,6 +129,12 @@ class SystemTimeHandlerImpl : public utils::SystemTimeHandler, */ void ProcessSystemTimeReadyNotification(); + /** + * @brief ResetPendingSystemTimeRequests resets waiting for system time + * requests flag + */ + void ResetPendingSystemTimeRequests() OVERRIDE; + /** * @brief Checks if UTC time is ready to provided by HMI * and can be requested by GetSystemTime request 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 49f15165db7..afd5397db99 100644 --- a/src/components/application_manager/include/application_manager/telemetry_observer.h +++ b/src/components/application_manager/include/application_manager/telemetry_observer.h @@ -33,9 +33,9 @@ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_TELEMETRY_OBSERVER_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_TELEMETRY_OBSERVER_H_ -#include "smart_objects/smart_object.h" #include "application_manager/smart_object_keys.h" #include "json/json.h" +#include "smart_objects/smart_object.h" #include "utils/date_time.h" @@ -53,5 +53,5 @@ class AMTelemetryObserver { virtual void OnMessage(MessageMetricSharedPtr) = 0; virtual ~AMTelemetryObserver() {} }; -} // application_manager +} // namespace application_manager #endif // SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_TELEMETRY_OBSERVER_H_ diff --git a/src/components/application_manager/include/application_manager/usage_statistics.h b/src/components/application_manager/include/application_manager/usage_statistics.h index 6d0b5cd6bdb..ebd8e4729b0 100644 --- a/src/components/application_manager/include/application_manager/usage_statistics.h +++ b/src/components/application_manager/include/application_manager/usage_statistics.h @@ -33,10 +33,10 @@ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_USAGE_STATISTICS_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_USAGE_STATISTICS_H_ -#include #include -#include "policy/usage_statistics/counter.h" +#include #include "policy/usage_statistics/app_stopwatch.h" +#include "policy/usage_statistics/counter.h" #include "utils/macro.h" #include "interfaces/MOBILE_API.h" diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/CMakeLists.txt b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/CMakeLists.txt index 1e23aac8ee4..ef215cdd5a5 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/CMakeLists.txt +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/CMakeLists.txt @@ -53,22 +53,25 @@ collect_sources(COMMANDS_SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/src/commands") set(LIBRARIES HMI_API MOBILE_API + MessageHelper ApplicationManager + Resumption v4_protocol_v1_2_no_extra SmartObjects Utils - sdl_rpc_plugin + sdl_rpc_plugin_static ) if(ENABLE_LOG) list(APPEND LIBRARIES log4cxx -L${LOG4CXX_LIBS_DIRECTORY}) endif() -add_library("app_service_rpc_plugin" SHARED ${PLUGIN_SOURCES} ${MOBILE_COMMANDS} ${HMI_COMMANDS} ${COMMANDS_SOURCES}) -target_link_libraries("app_service_rpc_plugin" ${LIBRARIES}) +add_library("app_service_rpc_plugin_static" ${PLUGIN_SOURCES} ${MOBILE_COMMANDS} ${HMI_COMMANDS}) +target_link_libraries("app_service_rpc_plugin_static" ${LIBRARIES}) + +add_library("app_service_rpc_plugin" SHARED "src/app_service_rpc_plugin.cc") +target_link_libraries("app_service_rpc_plugin" app_service_rpc_plugin_static) -add_library("AppServiceRpcPluginStaticLib" ${PLUGIN_SOURCES} ${MOBILE_COMMANDS} ${HMI_COMMANDS}) -target_link_libraries("AppServiceRpcPluginStaticLib" ${LIBRARIES}) set(INSTALL_DESTINATION bin) diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/app_service_app_extension.h b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/app_service_app_extension.h index 9be93f5c9e6..b04edbe2f40 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/app_service_app_extension.h +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/app_service_app_extension.h @@ -126,6 +126,6 @@ class AppServiceAppExtension : public app_mngr::AppExtension { AppServiceRpcPlugin& plugin_; app_mngr::Application& app_; }; -} +} // namespace app_service_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_APP_SERVICE_PLUGIN_INCLUDE_APP_SERVICE_PLUGIN_APP_SERVICE_APP_EXTENSION_H diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/app_service_hmi_command_factory.h b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/app_service_hmi_command_factory.h index c42b64f559d..fd96bf0fb63 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/app_service_hmi_command_factory.h +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/app_service_hmi_command_factory.h @@ -34,6 +34,7 @@ #define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_APP_SERVICE_RPC_PLUGIN_INCLUDE_APP_SERVICE_RPC_PLUGIN_APP_SERVICE_RPC_HMI_COMMAND_FACTORY_H #include "application_manager/application_manager.h" +#include "application_manager/command_factory.h" namespace app_service_rpc_plugin { namespace app_mngr = application_manager; diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/app_service_mobile_command_factory.h b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/app_service_mobile_command_factory.h index bd1e10f267a..a6300dbb3d2 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/app_service_mobile_command_factory.h +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/app_service_mobile_command_factory.h @@ -34,6 +34,7 @@ #define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_APP_SERVICE_RPC_PLUGIN_INCLUDE_APP_SERVICE_RPC_PLUGIN_APP_SERVICE_RPC_MOBILE_COMMAND_FACTORY_H #include "application_manager/application_manager.h" +#include "application_manager/command_factory.h" namespace app_service_rpc_plugin { namespace app_mngr = application_manager; diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/app_service_rpc_plugin.h b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/app_service_rpc_plugin.h index c9cb98cdfbe..1765c1e7fac 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/app_service_rpc_plugin.h +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/app_service_rpc_plugin.h @@ -47,7 +47,8 @@ class AppServiceRpcPlugin : public plugins::RPCPlugin { bool Init(app_mngr::ApplicationManager& application_manager, app_mngr::rpc_service::RPCService& rpc_service, app_mngr::HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handler) OVERRIDE; + policy::PolicyHandlerInterface& policy_handler, + resumption::LastState& last_state) OVERRIDE; bool IsAbleToProcess( const int32_t function_id, @@ -69,5 +70,6 @@ class AppServiceRpcPlugin : public plugins::RPCPlugin { } // namespace app_service_rpc_plugin extern "C" application_manager::plugin_manager::RPCPlugin* Create(); +extern "C" void Delete(application_manager::plugin_manager::RPCPlugin* data); #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_APP_SERVICE_PLUGIN_INCLUDE_APP_SERVICE_PLUGIN_APP_SERVICE_PLUGIN_H diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/hmi/as_get_app_service_data_request_from_hmi.h b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/hmi/as_get_app_service_data_request_from_hmi.h index 531d1816e9a..d9eb7528e42 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/hmi/as_get_app_service_data_request_from_hmi.h +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/hmi/as_get_app_service_data_request_from_hmi.h @@ -92,6 +92,8 @@ class ASGetAppServiceDataRequestFromHMI application_manager::ApplicationSharedPtr app); void GetNavigationImagePaths(smart_objects::SmartObject& data, application_manager::ApplicationSharedPtr app); + void GetMediaImagePaths(smart_objects::SmartObject& data, + application_manager::ApplicationSharedPtr app); bool ValidateResponse(smart_objects::SmartObject& message_params); DISALLOW_COPY_AND_ASSIGN(ASGetAppServiceDataRequestFromHMI); diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/hmi/as_unpublish_app_service_request.h b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/hmi/as_unpublish_app_service_request.h new file mode 100644 index 00000000000..fdeadfa7c02 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/hmi/as_unpublish_app_service_request.h @@ -0,0 +1,78 @@ +/* + Copyright (c) 2019, Ford Motor Company, Livio + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + + Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following + disclaimer in the documentation and/or other materials provided with the + distribution. + + Neither the name of the the copyright holders nor the names of their + contributors may be used to endorse or promote products derived from this + software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_APP_SERVICE_RPC_PLUGIN_INCLUDE_APP_SERVICE_RPC_PLUGIN_COMMANDS_HMI_AS_UNPUBLISH_APP_SERVICE_REQUEST_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_APP_SERVICE_RPC_PLUGIN_INCLUDE_APP_SERVICE_RPC_PLUGIN_COMMANDS_HMI_AS_UNPUBLISH_APP_SERVICE_REQUEST_H_ + +#include "application_manager/commands/request_from_hmi.h" + +namespace app_service_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief ASUnpublishAppServiceRequest command class + **/ +class ASUnpublishAppServiceRequest : public app_mngr::commands::RequestFromHMI { + public: + /** + * @brief ASUnpublishAppServiceRequest class constructor + * + * @param message Incoming SmartObject message + **/ + ASUnpublishAppServiceRequest( + const app_mngr::commands::MessageSharedPtr& message, + app_mngr::ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle); + + /** + * @brief ASUnpublishAppServiceRequest class destructor + **/ + virtual ~ASUnpublishAppServiceRequest(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(ASUnpublishAppServiceRequest); +}; + +} // namespace commands + +} // namespace app_service_rpc_plugin + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_APP_SERVICE_RPC_PLUGIN_INCLUDE_APP_SERVICE_RPC_PLUGIN_COMMANDS_HMI_AS_UNPUBLISH_APP_SERVICE_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/hmi/as_unpublish_app_service_response.h b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/hmi/as_unpublish_app_service_response.h new file mode 100644 index 00000000000..51edd2dadb6 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/hmi/as_unpublish_app_service_response.h @@ -0,0 +1,78 @@ +/* + Copyright (c) 2019, Ford Motor Company, Livio + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + + Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following + disclaimer in the documentation and/or other materials provided with the + distribution. + + Neither the name of the the copyright holders nor the names of their + contributors may be used to endorse or promote products derived from this + software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_APP_SERVICE_RPC_PLUGIN_INCLUDE_APP_SERVICE_RPC_PLUGIN_COMMANDS_HMI_AS_UNPUBLISH_APP_SERVICE_RESPONSE_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_APP_SERVICE_RPC_PLUGIN_INCLUDE_APP_SERVICE_RPC_PLUGIN_COMMANDS_HMI_AS_UNPUBLISH_APP_SERVICE_RESPONSE_H_ + +#include "application_manager/commands/response_to_hmi.h" + +namespace app_service_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief ASUnpublishAppServiceResponse command class + **/ +class ASUnpublishAppServiceResponse : public app_mngr::commands::ResponseToHMI { + public: + /** + * @brief ASUnpublishAppServiceResponse class constructor + * + * @param message Incoming SmartObject message + **/ + ASUnpublishAppServiceResponse( + const app_mngr::commands::MessageSharedPtr& message, + app_mngr::ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle); + + /** + * @brief ASUnpublishAppServiceResponse class destructor + **/ + virtual ~ASUnpublishAppServiceResponse(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(ASUnpublishAppServiceResponse); +}; + +} // namespace commands + +} // namespace app_service_rpc_plugin + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_APP_SERVICE_RPC_PLUGIN_INCLUDE_APP_SERVICE_RPC_PLUGIN_COMMANDS_HMI_AS_UNPUBLISH_APP_SERVICE_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/hmi/on_as_app_service_data_notification.h b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/hmi/on_as_app_service_data_notification.h index cff7c8e5b8d..2dcd5ec2515 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/hmi/on_as_app_service_data_notification.h +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/hmi/on_as_app_service_data_notification.h @@ -70,6 +70,8 @@ class OnASAppServiceDataNotification virtual void Run(); private: + void GetMediaImagePaths(smart_objects::SmartObject& data, + application_manager::ApplicationSharedPtr app); void GetWeatherImagePaths(smart_objects::SmartObject& data, application_manager::ApplicationSharedPtr app); void GetNavigationImagePaths(smart_objects::SmartObject& data, diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/mobile/get_app_service_data_request.h b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/mobile/get_app_service_data_request.h index 7c80ec5e03a..69713548066 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/mobile/get_app_service_data_request.h +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/mobile/get_app_service_data_request.h @@ -67,6 +67,11 @@ class GetAppServiceDataRequest : public app_mngr::commands::CommandRequestImpl { **/ virtual void Run(); + /** + * @brief Init sets hash update mode for request + **/ + bool Init() FINAL; + /** * @brief Interface method that is called whenever new event received * diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/mobile/unpublish_app_service_request.h b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/mobile/unpublish_app_service_request.h new file mode 100644 index 00000000000..4a883b92ee7 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/mobile/unpublish_app_service_request.h @@ -0,0 +1,79 @@ +/* + Copyright (c) 2019, Ford Motor Company, Livio + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + + Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following + disclaimer in the documentation and/or other materials provided with the + distribution. + + Neither the name of the the copyright holders nor the names of their + contributors may be used to endorse or promote products derived from this + software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_APP_SERVICE_RPC_PLUGIN_INCLUDE_APP_SERVICE_RPC_PLUGIN_COMMANDS_MOBILE_UNPUBLISH_APP_SERVICE_REQUEST_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_APP_SERVICE_RPC_PLUGIN_INCLUDE_APP_SERVICE_RPC_PLUGIN_COMMANDS_MOBILE_UNPUBLISH_APP_SERVICE_REQUEST_H_ + +#include "application_manager/commands/command_request_impl.h" + +namespace app_service_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief UnpublishAppServiceRequest command class + **/ +class UnpublishAppServiceRequest + : public app_mngr::commands::CommandRequestImpl { + public: + /** + * @brief UnpublishAppServiceRequest class constructor + * + * @param message Incoming SmartObject message + **/ + UnpublishAppServiceRequest( + const app_mngr::commands::MessageSharedPtr& message, + app_mngr::ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle); + + /** + * @brief UnpublishAppServiceRequest class destructor + **/ + virtual ~UnpublishAppServiceRequest(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(UnpublishAppServiceRequest); +}; + +} // namespace commands + +} // namespace app_service_rpc_plugin + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_APP_SERVICE_RPC_PLUGIN_INCLUDE_APP_SERVICE_RPC_PLUGIN_COMMANDS_MOBILE_UNPUBLISH_APP_SERVICE_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/mobile/unpublish_app_service_response.h b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/mobile/unpublish_app_service_response.h new file mode 100644 index 00000000000..512e39eea08 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/mobile/unpublish_app_service_response.h @@ -0,0 +1,79 @@ +/* + Copyright (c) 2019, Ford Motor Company, Livio + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + + Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following + disclaimer in the documentation and/or other materials provided with the + distribution. + + Neither the name of the the copyright holders nor the names of their + contributors may be used to endorse or promote products derived from this + software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_APP_SERVICE_RPC_PLUGIN_INCLUDE_APP_SERVICE_RPC_PLUGIN_COMMANDS_MOBILE_UNPUBLISH_APP_SERVICE_RESPONSE_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_APP_SERVICE_RPC_PLUGIN_INCLUDE_APP_SERVICE_RPC_PLUGIN_COMMANDS_MOBILE_UNPUBLISH_APP_SERVICE_RESPONSE_H_ + +#include "application_manager/commands/command_response_impl.h" + +namespace app_service_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief UnpublishAppServiceResponse command class + **/ +class UnpublishAppServiceResponse + : public app_mngr::commands::CommandResponseImpl { + public: + /** + * @brief UnpublishAppServiceResponse class constructor + * + * @param message Incoming SmartObject message + **/ + UnpublishAppServiceResponse( + const app_mngr::commands::MessageSharedPtr& message, + app_mngr::ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle); + + /** + * @brief UnpublishAppServiceResponse class destructor + **/ + virtual ~UnpublishAppServiceResponse(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(UnpublishAppServiceResponse); +}; + +} // namespace commands + +} // namespace app_service_rpc_plugin + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_APP_SERVICE_RPC_PLUGIN_INCLUDE_APP_SERVICE_RPC_PLUGIN_COMMANDS_MOBILE_UNPUBLISH_APP_SERVICE_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/app_service_app_extension.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/app_service_app_extension.cc index 6d8b0c08ccd..87f947d2508 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/app_service_app_extension.cc +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/app_service_app_extension.cc @@ -103,7 +103,7 @@ void AppServiceAppExtension::ProcessResumption( const smart_objects::SmartObject& subscriptions_app_services = resumption_data[app_service_info]; for (size_t i = 0; i < subscriptions_app_services.length(); ++i) { - std::string service_type = resumption_data[i].asString(); + std::string service_type = subscriptions_app_services[i].asString(); SubscribeToAppService(service_type); } } @@ -119,4 +119,4 @@ AppServiceAppExtension& AppServiceAppExtension::ExtractASExtension( DCHECK(vi_app_extension); return *vi_app_extension; } -} +} // namespace app_service_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/app_service_command_factory.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/app_service_command_factory.cc index f0a0698bb79..8ce4d10b6e1 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/app_service_command_factory.cc +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/app_service_command_factory.cc @@ -74,4 +74,4 @@ bool AppServiceCommandFactory::IsAbleToProcess( ? hmi_command_factory_->IsAbleToProcess(function_id, source) : mobile_command_factory_->IsAbleToProcess(function_id, source); } -} // namespace service_plugin +} // namespace app_service_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/app_service_hmi_command_factory.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/app_service_hmi_command_factory.cc index 7cfbdd22d09..3090ea8ced8 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/app_service_hmi_command_factory.cc +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/app_service_hmi_command_factory.cc @@ -50,6 +50,8 @@ #include "app_service_rpc_plugin/commands/hmi/as_perform_app_service_interaction_response_to_hmi.h" #include "app_service_rpc_plugin/commands/hmi/as_publish_app_service_request.h" #include "app_service_rpc_plugin/commands/hmi/as_publish_app_service_response.h" +#include "app_service_rpc_plugin/commands/hmi/as_unpublish_app_service_request.h" +#include "app_service_rpc_plugin/commands/hmi/as_unpublish_app_service_response.h" #include "app_service_rpc_plugin/commands/hmi/on_as_app_service_data_notification.h" #include "app_service_rpc_plugin/commands/hmi/on_as_app_service_data_notification_from_hmi.h" @@ -106,9 +108,9 @@ bool AppServiceHmiCommandFactory::IsAbleToProcess( LOG4CXX_DEBUG(logger_, "HMI App Service Plugin IsAbleToProcess: " << function_id); UNUSED(source); - return buildCommandCreator(function_id, - hmi_apis::messageType::INVALID_ENUM, - source).CanBeCreated(); + return buildCommandCreator( + function_id, hmi_apis::messageType::INVALID_ENUM, source) + .CanBeCreated(); } app_mngr::CommandCreator& AppServiceHmiCommandFactory::buildCommandCreator( @@ -126,6 +128,11 @@ app_mngr::CommandCreator& AppServiceHmiCommandFactory::buildCommandCreator( return hmi_apis::messageType::request == message_type ? factory.GetCreator() : factory.GetCreator(); + case hmi_apis::FunctionID::AppService_UnpublishAppService: + return hmi_apis::messageType::request == message_type + ? factory.GetCreator() + : factory + .GetCreator(); case hmi_apis::FunctionID::AppService_OnAppServiceData: return app_mngr::commands::Command::CommandSource::SOURCE_HMI == source ? factory.GetCreator< @@ -188,4 +195,4 @@ app_mngr::CommandCreator& AppServiceHmiCommandFactory::buildCommandCreator( } return factory.GetCreator(); } -} +} // namespace app_service_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/app_service_mobile_command_factory.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/app_service_mobile_command_factory.cc index e8db20bdeaf..5c44fb5faea 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/app_service_mobile_command_factory.cc +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/app_service_mobile_command_factory.cc @@ -47,6 +47,8 @@ #include "app_service_rpc_plugin/commands/mobile/perform_app_service_interaction_response_from_mobile.h" #include "app_service_rpc_plugin/commands/mobile/publish_app_service_request.h" #include "app_service_rpc_plugin/commands/mobile/publish_app_service_response.h" +#include "app_service_rpc_plugin/commands/mobile/unpublish_app_service_request.h" +#include "app_service_rpc_plugin/commands/mobile/unpublish_app_service_response.h" CREATE_LOGGERPTR_GLOBAL(logger_, "AppServiceRpcPlugin") @@ -97,9 +99,9 @@ bool AppServiceMobileCommandFactory::IsAbleToProcess( const int32_t function_id, const app_mngr::commands::Command::CommandSource source) const { UNUSED(source); - return buildCommandCreator(function_id, - mobile_apis::messageType::INVALID_ENUM, - source).CanBeCreated(); + return buildCommandCreator( + function_id, mobile_apis::messageType::INVALID_ENUM, source) + .CanBeCreated(); } app_mngr::CommandCreator& AppServiceMobileCommandFactory::buildCommandCreator( @@ -120,6 +122,16 @@ app_mngr::CommandCreator& AppServiceMobileCommandFactory::buildCommandCreator( return factory.GetCreator(); } break; + case mobile_apis::FunctionID::UnpublishAppServiceID: + if (app_mngr::commands::Command::CommandSource::SOURCE_MOBILE == source && + mobile_apis::messageType::response != message_type) { + return factory.GetCreator(); + } else if (app_mngr::commands::Command::CommandSource::SOURCE_SDL == + source && + mobile_apis::messageType::request != message_type) { + return factory.GetCreator(); + } + break; case mobile_apis::FunctionID::OnAppServiceDataID: return app_mngr::commands::Command::CommandSource::SOURCE_MOBILE == source ? factory.GetCreator< @@ -162,4 +174,4 @@ app_mngr::CommandCreator& AppServiceMobileCommandFactory::buildCommandCreator( } return factory.GetCreator(); } -} // namespace vehicle_info_plugin +} // namespace app_service_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/app_service_rpc_plugin.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/app_service_rpc_plugin.cc index b96e5c199d0..0e739522d95 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/app_service_rpc_plugin.cc +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/app_service_rpc_plugin.cc @@ -30,12 +30,12 @@ POSSIBILITY OF SUCH DAMAGE. */ -#include "application_manager/message_helper.h" -#include "application_manager/smart_object_keys.h" +#include "app_service_rpc_plugin/app_service_rpc_plugin.h" #include "app_service_rpc_plugin/app_service_app_extension.h" #include "app_service_rpc_plugin/app_service_command_factory.h" -#include "app_service_rpc_plugin/app_service_rpc_plugin.h" +#include "application_manager/message_helper.h" #include "application_manager/plugin_manager/plugin_keys.h" +#include "application_manager/smart_object_keys.h" namespace app_service_rpc_plugin { CREATE_LOGGERPTR_GLOBAL(logger_, "AppServiceRpcPlugin") @@ -49,7 +49,9 @@ bool AppServiceRpcPlugin::Init( application_manager::ApplicationManager& app_manager, application_manager::rpc_service::RPCService& rpc_service, application_manager::HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handler) { + policy::PolicyHandlerInterface& policy_handler, + resumption::LastState& last_state) { + UNUSED(last_state); application_manager_ = &app_manager; command_factory_.reset(new app_service_rpc_plugin::AppServiceCommandFactory( app_manager, rpc_service, hmi_capabilities, policy_handler)); @@ -93,6 +95,14 @@ void AppServiceRpcPlugin::DeleteSubscriptions( } // namespace app_service_rpc_plugin -extern "C" application_manager::plugin_manager::RPCPlugin* Create() { +extern "C" __attribute__((visibility("default"))) +application_manager::plugin_manager::RPCPlugin* +Create() { return new app_service_rpc_plugin::AppServiceRpcPlugin(); } + +extern "C" __attribute__((visibility("default"))) void Delete( + application_manager::plugin_manager::RPCPlugin* data) { + delete data; + DELETE_THREAD_LOGGER(app_service_rpc_plugin::logger_); +} diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_get_app_service_data_request_from_hmi.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_get_app_service_data_request_from_hmi.cc index 2da8834b962..e03c0ad15a9 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_get_app_service_data_request_from_hmi.cc +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_get_app_service_data_request_from_hmi.cc @@ -161,6 +161,14 @@ void ASGetAppServiceDataRequestFromHMI::GetNavigationImagePaths( } } +void ASGetAppServiceDataRequestFromHMI::GetMediaImagePaths( + smart_objects::SmartObject& data, ApplicationSharedPtr app) { + if (data.keyExists(strings::media_image)) { + MessageHelper::VerifyImage( + data[strings::media_image], app, application_manager_); + } +} + bool ASGetAppServiceDataRequestFromHMI::ValidateResponse( smart_objects::SmartObject& message_params) { if (!message_params.keyExists(strings::service_data)) { @@ -215,6 +223,11 @@ bool ASGetAppServiceDataRequestFromHMI::ValidateResponse( GetNavigationImagePaths(service_data[strings::navigation_service_data], app); } + + if (service_type_value == mobile_apis::AppServiceType::MEDIA && + service_data.keyExists(strings::media_service_data)) { + GetMediaImagePaths(service_data[strings::media_service_data], app); + } } return true; } diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_unpublish_app_service_request.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_unpublish_app_service_request.cc new file mode 100644 index 00000000000..30905b5fa22 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_unpublish_app_service_request.cc @@ -0,0 +1,97 @@ +/* + Copyright (c) 2019, Ford Motor Company, Livio + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + + Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following + disclaimer in the documentation and/or other materials provided with the + distribution. + + Neither the name of the the copyright holders nor the names of their + contributors may be used to endorse or promote products derived from this + software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + */ + +#include "app_service_rpc_plugin/commands/hmi/as_unpublish_app_service_request.h" +#include "application_manager/app_service_manager.h" +#include "application_manager/application_impl.h" +#include "application_manager/rpc_service.h" +#include "interfaces/MOBILE_API.h" + +namespace app_service_rpc_plugin { +using namespace application_manager; +namespace commands { + +ASUnpublishAppServiceRequest::ASUnpublishAppServiceRequest( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handler) + : RequestFromHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handler) {} + +ASUnpublishAppServiceRequest::~ASUnpublishAppServiceRequest() {} + +void ASUnpublishAppServiceRequest::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + std::string service_id = + (*message_)[strings::msg_params][strings::service_id].asString(); + + auto service = + application_manager_.GetAppServiceManager().FindServiceByID(service_id); + if (!service || service->mobile_service) { + SendErrorResponse( + (*message_)[strings::params][strings::correlation_id].asUInt(), + hmi_apis::FunctionID::AppService_UnpublishAppService, + hmi_apis::Common_Result::INVALID_ID, + "Invalid Service ID", + application_manager::commands::Command::SOURCE_SDL_TO_HMI); + return; + } + + bool ret = application_manager_.GetAppServiceManager().UnpublishAppService( + service_id); + + if (!ret) { + SendErrorResponse( + (*message_)[strings::params][strings::correlation_id].asUInt(), + hmi_apis::FunctionID::AppService_UnpublishAppService, + hmi_apis::Common_Result::REJECTED, + "The app service with that requested service ID does not exist", + application_manager::commands::Command::SOURCE_SDL_TO_HMI); + return; + } + + SendResponse(true, + (*message_)[strings::params][strings::correlation_id].asUInt(), + hmi_apis::FunctionID::AppService_UnpublishAppService, + hmi_apis::Common_Result::SUCCESS, + NULL, + application_manager::commands::Command::SOURCE_SDL_TO_HMI); +} + +} // namespace commands +} // namespace app_service_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_unpublish_app_service_response.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_unpublish_app_service_response.cc new file mode 100644 index 00000000000..0c8b479da83 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_unpublish_app_service_response.cc @@ -0,0 +1,62 @@ +/* + Copyright (c) 2019, Ford Motor Company, Livio + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + + Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following + disclaimer in the documentation and/or other materials provided with the + distribution. + + Neither the name of the the copyright holders nor the names of their + contributors may be used to endorse or promote products derived from this + software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + */ + +#include "app_service_rpc_plugin/commands/hmi/as_unpublish_app_service_response.h" +#include "application_manager/application_impl.h" +#include "application_manager/rpc_service.h" +#include "interfaces/MOBILE_API.h" + +namespace app_service_rpc_plugin { +using namespace application_manager; +namespace commands { + +ASUnpublishAppServiceResponse::ASUnpublishAppServiceResponse( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handler) + : ResponseToHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handler) {} + +ASUnpublishAppServiceResponse::~ASUnpublishAppServiceResponse() {} + +void ASUnpublishAppServiceResponse::Run() { + LOG4CXX_AUTO_TRACE(logger_); + rpc_service_.SendMessageToHMI(message_); +} + +} // namespace commands +} // namespace app_service_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/on_as_app_service_data_notification.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/on_as_app_service_data_notification.cc index e90de23837e..db1716ecb82 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/on_as_app_service_data_notification.cc +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/on_as_app_service_data_notification.cc @@ -55,6 +55,14 @@ OnASAppServiceDataNotification::OnASAppServiceDataNotification( OnASAppServiceDataNotification::~OnASAppServiceDataNotification() {} +void OnASAppServiceDataNotification::GetMediaImagePaths( + smart_objects::SmartObject& data, ApplicationSharedPtr app) { + if (data.keyExists(strings::media_image)) { + MessageHelper::VerifyImage( + data[strings::media_image], app, application_manager_); + } +} + void OnASAppServiceDataNotification::GetWeatherImagePaths( smart_objects::SmartObject& data, ApplicationSharedPtr app) { if (data[strings::location].keyExists(strings::location_image)) { @@ -186,6 +194,11 @@ bool OnASAppServiceDataNotification::ValidateParams( GetNavigationImagePaths(service_data[strings::navigation_service_data], app); } + + if (service_type_value == mobile_apis::AppServiceType::MEDIA && + service_data.keyExists(strings::media_service_data)) { + GetMediaImagePaths(service_data[strings::media_service_data], app); + } } return true; } diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/on_as_app_service_data_notification_from_hmi.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/on_as_app_service_data_notification_from_hmi.cc index 575aa5ca288..1c73fc73f40 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/on_as_app_service_data_notification_from_hmi.cc +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/on_as_app_service_data_notification_from_hmi.cc @@ -59,7 +59,8 @@ void OnASAppServiceDataNotificationFromHMI::Run() { std::string service_id = (*message_)[strings::msg_params][strings::service_data] - [strings::service_id].asString(); + [strings::service_id] + .asString(); AppService* service = application_manager_.GetAppServiceManager().FindServiceByID(service_id); if (!service) { @@ -76,7 +77,8 @@ void OnASAppServiceDataNotificationFromHMI::Run() { std::string service_type = (*message_)[strings::msg_params][strings::service_data] - [strings::service_type].asString(); + [strings::service_type] + .asString(); std::string published_service_type = service->record[strings::service_manifest][strings::service_type] .asString(); diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/get_app_service_data_request.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/get_app_service_data_request.cc index 7c2e62abe20..e3bf40308d2 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/get_app_service_data_request.cc +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/get_app_service_data_request.cc @@ -65,6 +65,11 @@ void GetAppServiceDataRequest::Run() { true); } +bool GetAppServiceDataRequest::Init() { + hash_update_mode_ = HashUpdateMode::kDoHashUpdate; + return true; +} + void GetAppServiceDataRequest::HandleSubscribe() { std::string service_type = (*message_)[strings::msg_params][strings::service_type].asString(); diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/on_app_service_data_notification.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/on_app_service_data_notification.cc index fd3891e0e81..1ffe99462d0 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/on_app_service_data_notification.cc +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/on_app_service_data_notification.cc @@ -66,15 +66,18 @@ void OnAppServiceDataNotification::Run() { std::string service_id = (*message_)[strings::msg_params][strings::service_data] - [strings::service_id].asString(); + [strings::service_id] + .asString(); auto service = application_manager_.GetAppServiceManager().FindServiceByID(service_id); if (!service) { LOG4CXX_ERROR(logger_, "Service sending OnAppServiceData is not published"); return; - } else if (!service->record[strings::service_manifest] - [strings::allow_app_consumers].asBool()) { + } else if (!service + ->record[strings::service_manifest] + [strings::allow_app_consumers] + .asBool()) { LOG4CXX_ERROR(logger_, "Service does not allow for app consumers, skipping mobile " "OnAppServiceData notification"); @@ -83,7 +86,8 @@ void OnAppServiceDataNotification::Run() { std::string service_type = (*message_)[strings::msg_params][strings::service_data] - [strings::service_type].asString(); + [strings::service_type] + .asString(); auto subscribed_to_app_service_predicate = [service_type](const ApplicationSharedPtr app) { diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/on_app_service_data_notification_from_mobile.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/on_app_service_data_notification_from_mobile.cc index 2e92bd19bb1..5caacc98011 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/on_app_service_data_notification_from_mobile.cc +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/on_app_service_data_notification_from_mobile.cc @@ -64,7 +64,8 @@ void OnAppServiceDataNotificationFromMobile::Run() { uint32_t app_connection_key = connection_key(); std::string service_type = (*message_)[strings::msg_params][strings::service_data] - [strings::service_type].asString(); + [strings::service_type] + .asString(); ApplicationSharedPtr app = application_manager_.application(app_connection_key); @@ -81,7 +82,8 @@ void OnAppServiceDataNotificationFromMobile::Run() { std::string service_id = (*message_)[strings::msg_params][strings::service_data] - [strings::service_id].asString(); + [strings::service_id] + .asString(); AppService* service = application_manager_.GetAppServiceManager().FindServiceByID(service_id); if (!service) { diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/publish_app_service_request.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/publish_app_service_request.cc index 86819b44ad2..53d1bf82fad 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/publish_app_service_request.cc +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/publish_app_service_request.cc @@ -75,19 +75,22 @@ void PublishAppServiceRequest::Run() { strings::service_name)) { requested_service_name = (*message_)[strings::msg_params][strings::app_service_manifest] - [strings::service_name].asString(); + [strings::service_name] + .asString(); } std::string requested_service_type = (*message_)[strings::msg_params][strings::app_service_manifest] - [strings::service_type].asString(); + [strings::service_type] + .asString(); smart_objects::SmartArray* requested_handled_rpcs = NULL; if ((*message_)[strings::msg_params][strings::app_service_manifest].keyExists( strings::handled_rpcs)) { requested_handled_rpcs = (*message_)[strings::msg_params][strings::app_service_manifest] - [strings::handled_rpcs].asArray(); + [strings::handled_rpcs] + .asArray(); } bool result = @@ -117,12 +120,6 @@ void PublishAppServiceRequest::Run() { return; } - if (app->IsFullscreen()) { - // Service should be activated if app is in the foreground - application_manager_.GetAppServiceManager().ActivateAppService( - service_record[strings::service_id].asString()); - } - response_params[strings::app_service_record] = service_record; SendResponse(true, mobile_apis::Result::SUCCESS, NULL, &response_params); diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/unpublish_app_service_request.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/unpublish_app_service_request.cc new file mode 100644 index 00000000000..2cb43bce073 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/unpublish_app_service_request.cc @@ -0,0 +1,90 @@ +/* + Copyright (c) 2019, Ford Motor Company, Livio + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + + Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following + disclaimer in the documentation and/or other materials provided with the + distribution. + + Neither the name of the the copyright holders nor the names of their + contributors may be used to endorse or promote products derived from this + software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + */ + +#include "app_service_rpc_plugin/commands/mobile/unpublish_app_service_request.h" + +#include "application_manager/app_service_manager.h" +#include "application_manager/application_impl.h" +#include "application_manager/rpc_service.h" +#include "interfaces/MOBILE_API.h" + +namespace app_service_rpc_plugin { +using namespace application_manager; +namespace commands { + +UnpublishAppServiceRequest::UnpublishAppServiceRequest( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handler) + : CommandRequestImpl(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handler) {} + +UnpublishAppServiceRequest::~UnpublishAppServiceRequest() {} + +void UnpublishAppServiceRequest::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + std::string service_id = + (*message_)[strings::msg_params][strings::service_id].asString(); + + auto service = + application_manager_.GetAppServiceManager().FindServiceByID(service_id); + + if (!service || service->connection_key != connection_key()) { + SendResponse(false, + mobile_apis::Result::INVALID_ID, + "No app service with the requested service ID was published " + "by this application"); + return; + } + + bool ret = application_manager_.GetAppServiceManager().UnpublishAppService( + service_id); + + if (!ret) { + SendResponse( + false, + mobile_apis::Result::INVALID_ID, + "The app service with that requested service ID does not exist"); + return; + } + + SendResponse(true, mobile_apis::Result::SUCCESS, NULL, NULL); +} + +} // namespace commands +} // namespace app_service_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/unpublish_app_service_response.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/unpublish_app_service_response.cc new file mode 100644 index 00000000000..22450ecc4ca --- /dev/null +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/unpublish_app_service_response.cc @@ -0,0 +1,62 @@ +/* + Copyright (c) 2019, Ford Motor Company, Livio + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + + Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following + disclaimer in the documentation and/or other materials provided with the + distribution. + + Neither the name of the the copyright holders nor the names of their + contributors may be used to endorse or promote products derived from this + software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + */ + +#include "app_service_rpc_plugin/commands/mobile/unpublish_app_service_response.h" +#include "application_manager/application_impl.h" +#include "application_manager/rpc_service.h" +#include "interfaces/MOBILE_API.h" + +namespace app_service_rpc_plugin { +using namespace application_manager; +namespace commands { + +UnpublishAppServiceResponse::UnpublishAppServiceResponse( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handler) + : CommandResponseImpl(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handler) {} + +UnpublishAppServiceResponse::~UnpublishAppServiceResponse() {} + +void UnpublishAppServiceResponse::Run() { + LOG4CXX_AUTO_TRACE(logger_); + rpc_service_.SendMessageToMobile(message_); +} + +} // namespace commands +} // namespace app_service_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/test/CMakeLists.txt b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/test/CMakeLists.txt index 0b56ddb7e97..1670ba5c22b 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/test/CMakeLists.txt +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/test/CMakeLists.txt @@ -25,16 +25,10 @@ file(GLOB SOURCES set(LIBRARIES gmock - Utils - SmartObjects - HMI_API - MOBILE_API - connectionHandler - app_service_rpc_plugin - sdl_rpc_plugin - jsoncpp - Policy - Resumption + sdl_rpc_plugin_static + app_service_rpc_plugin_static ) create_cotired_test("app_services_commands_test" "${SOURCES}" "${LIBRARIES}" ) + +add_subdirectory("app_service_plugin") diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/test/app_service_plugin/CMakeLists.txt b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/test/app_service_plugin/CMakeLists.txt new file mode 100644 index 00000000000..9abe2512046 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/test/app_service_plugin/CMakeLists.txt @@ -0,0 +1,54 @@ +# Copyright (c) 2019, Ford Motor Company, Livio +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# Redistributions of source code must retain the above copyright notice, this +# list of conditions and the following disclaimer. +# +# Redistributions in binary form must reproduce the above copyright notice, +# this list of conditions and the following +# disclaimer in the documentation and/or other materials provided with the +# distribution. +# +# Neither the name of the copyright holders nor the names of their contributors +# may be used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. + +include(${CMAKE_SOURCE_DIR}/tools/cmake/helpers/sources.cmake) + + +set(APP_SERVICE_DIR "${COMPONENTS_DIR}/application_manager/rpc_plugins/app_service_rpc_plugin") +set(APP_SERVICE_SRC_DIR "${APP_SERVICE_DIR}/src") +set(APP_SERVICE_INCLUDE_DIR "${APP_SERVICE_DIR}/include/app_service_rpc_plugin") +set(APP_SERVICE_TEST_DIR "${APP_SERVICE_DIR}/test") + +include_directories( + ${GMOCK_INCLUDE_DIRECTORY} + ${APP_SERVICE_INCLUDE_DIR} +) + +set(SOURCES ${APP_SERVICE_TEST_DIR}/app_service_plugin/app_service_app_extension_test.cc + ${COMPONENTS_DIR}/application_manager/test/mock_message_helper.cc +) + +set(LIBRARIES + gmock + sdl_rpc_plugin_static + app_service_rpc_plugin_static +) + +create_test("app_service_plugin_test" "${SOURCES}" "${LIBRARIES}" ) diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/test/app_service_plugin/app_service_app_extension_test.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/test/app_service_plugin/app_service_app_extension_test.cc new file mode 100644 index 00000000000..785cdd5200e --- /dev/null +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/test/app_service_plugin/app_service_app_extension_test.cc @@ -0,0 +1,211 @@ +/* + * Copyright (c) 2019, 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 "app_service_rpc_plugin/app_service_app_extension.h" +#include +#include "app_service_rpc_plugin/app_service_rpc_plugin.h" +#include "application_manager/mock_application.h" +#include "gtest/gtest.h" + +namespace { +const std::string kAppServiceType1 = "AppServiceType1"; +const std::string kAppServiceType2 = "AppServiceType2"; +const std::string kResumptionDataKey = "kResumptionDataKey"; +const std::string kAppServiceInfoKey = "appService"; +} // namespace + +namespace test { +namespace components { +namespace app_service_plugin_test { + +using test::components::application_manager_test::MockApplication; +using ::testing::_; +using ::testing::Mock; +using ::testing::NiceMock; +using ::testing::Return; +using ::testing::ReturnNull; +using ::testing::ReturnRef; +using ::testing::SaveArg; + +using namespace app_service_rpc_plugin; +namespace strings = application_manager::strings; +namespace plugins = application_manager::plugin_manager; + +class AppServiceAppExtensionTest : public ::testing::Test { + public: + AppServiceAppExtensionTest() : mock_app_(new NiceMock()) {} + + protected: + void SetUp() OVERRIDE { + app_service_app_extension_.reset( + new AppServiceAppExtension(app_service_plugin_, *mock_app_)); + } + + void TearDown() OVERRIDE { + app_service_app_extension_.reset(); + } + + app_service_rpc_plugin::AppServiceRpcPlugin app_service_plugin_; + std::unique_ptr mock_app_; + std::unique_ptr app_service_app_extension_; +}; + +TEST_F(AppServiceAppExtensionTest, SubscribeToAppService_SUCCESS) { + EXPECT_TRUE( + app_service_app_extension_->SubscribeToAppService(kAppServiceType1)); + const auto& subs = app_service_app_extension_->Subscriptions(); + EXPECT_EQ(1u, subs.size()); + EXPECT_TRUE( + app_service_app_extension_->IsSubscribedToAppService(kAppServiceType1)); +} + +TEST_F(AppServiceAppExtensionTest, + SubscribeToAppService_SubscribeOneAppServiceType_Twice_FAIL) { + ASSERT_TRUE( + app_service_app_extension_->SubscribeToAppService(kAppServiceType1)); + ASSERT_TRUE( + app_service_app_extension_->IsSubscribedToAppService(kAppServiceType1)); + + EXPECT_FALSE( + app_service_app_extension_->SubscribeToAppService(kAppServiceType1)); + EXPECT_TRUE( + app_service_app_extension_->IsSubscribedToAppService(kAppServiceType1)); + const auto& subs = app_service_app_extension_->Subscriptions(); + EXPECT_EQ(1u, subs.size()); +} + +TEST_F( + AppServiceAppExtensionTest, + UnsubscribeFromAppService_AppServiceType1Unsubscribed_AppServiceType2Remains_SUCCESS) { + // Subscribe + ASSERT_TRUE( + app_service_app_extension_->SubscribeToAppService(kAppServiceType1)); + ASSERT_TRUE( + app_service_app_extension_->SubscribeToAppService(kAppServiceType2)); + auto subs = app_service_app_extension_->Subscriptions(); + ASSERT_EQ(2u, subs.size()); + ASSERT_TRUE( + app_service_app_extension_->IsSubscribedToAppService(kAppServiceType1)); + ASSERT_TRUE( + app_service_app_extension_->IsSubscribedToAppService(kAppServiceType2)); + + // Unsubscribe + EXPECT_TRUE( + app_service_app_extension_->UnsubscribeFromAppService(kAppServiceType1)); + EXPECT_FALSE( + app_service_app_extension_->IsSubscribedToAppService(kAppServiceType1)); + EXPECT_TRUE( + app_service_app_extension_->IsSubscribedToAppService(kAppServiceType2)); + subs = app_service_app_extension_->Subscriptions(); + EXPECT_EQ(1u, subs.size()); +} + +TEST_F(AppServiceAppExtensionTest, + UnsubscribeFromAppService_UnsubscribeNotSubscribedAppServiceType_FAIL) { + ASSERT_TRUE( + app_service_app_extension_->SubscribeToAppService(kAppServiceType1)); + ASSERT_EQ(1u, app_service_app_extension_->Subscriptions().size()); + ASSERT_TRUE( + app_service_app_extension_->IsSubscribedToAppService(kAppServiceType1)); + + EXPECT_FALSE( + app_service_app_extension_->UnsubscribeFromAppService(kAppServiceType2)); + EXPECT_TRUE( + app_service_app_extension_->IsSubscribedToAppService(kAppServiceType1)); + EXPECT_EQ(1u, app_service_app_extension_->Subscriptions().size()); +} + +TEST_F(AppServiceAppExtensionTest, + UnsubscribeFromAppService_UnsubscribeAll_SUCCESS) { + auto app_service_types = {kAppServiceType1, kAppServiceType2}; + + for (const auto& app_service_type : app_service_types) { + ASSERT_TRUE( + app_service_app_extension_->SubscribeToAppService(app_service_type)); + ASSERT_TRUE( + app_service_app_extension_->IsSubscribedToAppService(app_service_type)); + } + ASSERT_EQ(2u, app_service_app_extension_->Subscriptions().size()); + + app_service_app_extension_->UnsubscribeFromAppService(); + + for (const auto& app_service_type : app_service_types) { + EXPECT_FALSE( + app_service_app_extension_->IsSubscribedToAppService(app_service_type)); + } + EXPECT_EQ(0u, app_service_app_extension_->Subscriptions().size()); +} + +TEST_F(AppServiceAppExtensionTest, SaveResumptionData_SUCCESS) { + ASSERT_TRUE( + app_service_app_extension_->SubscribeToAppService(kAppServiceType1)); + ASSERT_EQ(1u, app_service_app_extension_->Subscriptions().size()); + ASSERT_TRUE( + app_service_app_extension_->IsSubscribedToAppService(kAppServiceType1)); + + smart_objects::SmartObject resumption_data; + resumption_data[kResumptionDataKey] = "some resumption data"; + + app_service_app_extension_->SaveResumptionData(resumption_data); + + EXPECT_TRUE(resumption_data.keyExists(kResumptionDataKey)); + EXPECT_TRUE(resumption_data.keyExists(kAppServiceInfoKey)); + EXPECT_EQ(kAppServiceType1, + resumption_data[kAppServiceInfoKey][0].asString()); +} + +TEST_F(AppServiceAppExtensionTest, ProcessResumption_SUCCESS) { + app_service_app_extension_->UnsubscribeFromAppService(); + ASSERT_EQ(0u, app_service_app_extension_->Subscriptions().size()); + + smart_objects::SmartObject app_service_data = + smart_objects::SmartObject(smart_objects::SmartType_Array); + app_service_data.asArray()->push_back( + smart_objects::SmartObject(kAppServiceType1)); + app_service_data.asArray()->push_back( + smart_objects::SmartObject(kAppServiceType2)); + + smart_objects::SmartObject resumption_data; + resumption_data[kAppServiceInfoKey] = app_service_data; + + app_service_app_extension_->ProcessResumption(resumption_data); + + for (const auto& app_service_type : {kAppServiceType1, kAppServiceType2}) { + EXPECT_TRUE( + app_service_app_extension_->IsSubscribedToAppService(app_service_type)); + } + EXPECT_EQ(2u, app_service_app_extension_->Subscriptions().size()); +} + +} // namespace app_service_plugin_test +} // namespace components +} // namespace test diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/test/commands/hmi/dummy_hmi_commands_test.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/test/commands/hmi/dummy_hmi_commands_test.cc index 8ef87b6de9f..4236ac23f93 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/test/commands/hmi/dummy_hmi_commands_test.cc +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/test/commands/hmi/dummy_hmi_commands_test.cc @@ -53,6 +53,8 @@ #include "hmi/as_perform_app_service_interaction_response_to_hmi.h" #include "hmi/as_publish_app_service_request.h" #include "hmi/as_publish_app_service_response.h" +#include "hmi/as_unpublish_app_service_request.h" +#include "hmi/as_unpublish_app_service_response.h" #include "hmi/on_as_app_service_data_notification.h" #include "hmi/on_as_app_service_data_notification_from_hmi.h" @@ -72,16 +74,16 @@ namespace dummy_hmi_commands_test { namespace commands = app_service_rpc_plugin::commands; -using ::testing::_; -using ::testing::NotNull; -using ::testing::Types; +using ::application_manager::ApplicationSharedPtr; using application_manager::commands::MessageSharedPtr; -using ::test::components::event_engine_test::MockEventDispatcher; +using ::test::components::application_manager_test::MockApplication; using ::test::components::application_manager_test::MockApplicationManager; using ::test::components::application_manager_test:: MockApplicationManagerSettings; -using ::application_manager::ApplicationSharedPtr; -using ::test::components::application_manager_test::MockApplication; +using ::test::components::event_engine_test::MockEventDispatcher; +using ::testing::_; +using ::testing::NotNull; +using ::testing::Types; template class HMICommandsTest : public components::commands_test::CommandRequestTest< @@ -132,6 +134,8 @@ typedef Types HMICommandsListFirst; diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/test/commands/mobile/dummy_mobile_commands_test.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/test/commands/mobile/dummy_mobile_commands_test.cc index 3c8a7801282..69bff3ad762 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/test/commands/mobile/dummy_mobile_commands_test.cc +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/test/commands/mobile/dummy_mobile_commands_test.cc @@ -49,11 +49,13 @@ #include "mobile/perform_app_service_interaction_response_from_mobile.h" #include "mobile/publish_app_service_request.h" #include "mobile/publish_app_service_response.h" +#include "mobile/unpublish_app_service_request.h" +#include "mobile/unpublish_app_service_response.h" #include "application_manager/mock_application.h" #include "application_manager/mock_application_manager.h" -#include "test/application_manager/mock_application_manager_settings.h" #include "application_manager/mock_event_dispatcher.h" +#include "test/application_manager/mock_application_manager_settings.h" namespace am = application_manager; @@ -64,16 +66,16 @@ namespace mobile_commands_test { namespace dummy_mobile_commands_test { namespace commands = app_service_rpc_plugin::commands; -using ::testing::_; -using ::testing::NotNull; -using ::testing::Types; using am::commands::MessageSharedPtr; -using ::test::components::event_engine_test::MockEventDispatcher; +using ::application_manager::ApplicationSharedPtr; +using ::test::components::application_manager_test::MockApplication; using ::test::components::application_manager_test::MockApplicationManager; using ::test::components::application_manager_test:: MockApplicationManagerSettings; -using ::application_manager::ApplicationSharedPtr; -using ::test::components::application_manager_test::MockApplication; +using ::test::components::event_engine_test::MockEventDispatcher; +using ::testing::_; +using ::testing::NotNull; +using ::testing::Types; namespace { const std::string kEmptyString_ = ""; @@ -118,7 +120,10 @@ typedef Types MobileCommandsListFirst; + commands::PublishAppServiceResponse, + commands::UnpublishAppServiceRequest, + commands::UnpublishAppServiceResponse> + MobileCommandsListFirst; TYPED_TEST_CASE(MobileCommandsTestFirst, MobileCommandsListFirst); diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/test/commands/mobile/on_app_service_data_notification_test.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/test/commands/mobile/on_app_service_data_notification_test.cc index 47358ef6310..3e88d4eaf3d 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/test/commands/mobile/on_app_service_data_notification_test.cc +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/test/commands/mobile/on_app_service_data_notification_test.cc @@ -30,41 +30,41 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include "application_manager/application.h" -#include "application_manager/mock_application.h" -#include "application_manager/mock_app_service_manager.h" -#include "application_manager/commands/commands_test.h" #include "app_service_rpc_plugin/commands/mobile/on_app_service_data_notification.h" -#include "app_service_rpc_plugin/app_service_rpc_plugin.h" #include "app_service_rpc_plugin/app_service_app_extension.h" +#include "app_service_rpc_plugin/app_service_rpc_plugin.h" +#include "application_manager/application.h" +#include "application_manager/commands/command_impl.h" +#include "application_manager/commands/commands_test.h" +#include "application_manager/mock_app_service_manager.h" +#include "application_manager/mock_application.h" #include "gtest/gtest.h" #include "interfaces/MOBILE_API.h" -#include "application_manager/commands/command_impl.h" #include "resumption/last_state_impl.h" namespace am = application_manager; -using ::testing::_; -using ::testing::Return; -using ::testing::ReturnRef; -using ::testing::ReturnNull; -using ::testing::NiceMock; -using ::testing::SaveArg; -using ::testing::Mock; using am::ApplicationSet; using am::commands::MessageSharedPtr; +using app_service_rpc_plugin::commands::OnAppServiceDataNotification; using test::components::application_manager_test::MockApplication; using test::components::application_manager_test::MockApplicationManager; using test::components::application_manager_test::MockAppServiceManager; using test::components::commands_test::CommandsTest; using test::components::commands_test::CommandsTestMocks; -using app_service_rpc_plugin::commands::OnAppServiceDataNotification; +using ::testing::_; +using ::testing::Mock; +using ::testing::NiceMock; +using ::testing::Return; +using ::testing::ReturnNull; +using ::testing::ReturnRef; +using ::testing::SaveArg; namespace { const uint32_t kAppId = 0u; const uint32_t kConnectionKey = 1u; const std::string kPolicyAppId = "Test"; const int kModuleId = 153u; -} +} // namespace namespace app_service_plugin_test { using namespace app_service_rpc_plugin; @@ -214,4 +214,4 @@ TEST_F(OnAppServiceDataNotificationTest, Run_NoSubscribedApps) { Mock::VerifyAndClearExpectations(&app_mngr_); } -} // namespace rc_rpc_plugin_test +} // namespace app_service_plugin_test diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/CMakeLists.txt b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/CMakeLists.txt index 00de927b6e6..8129e1240d4 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/CMakeLists.txt +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/CMakeLists.txt @@ -50,7 +50,10 @@ collect_sources(COMMANDS_SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/src/commands") set(LIBRARIES HMI_API MOBILE_API + MessageHelper ApplicationManager + ProtocolHandler + connectionHandler v4_protocol_v1_2_no_extra SmartObjects Utils @@ -60,11 +63,12 @@ if(ENABLE_LOG) list(APPEND LIBRARIES log4cxx -L${LOG4CXX_LIBS_DIRECTORY}) endif() -add_library("rc_rpc_plugin" SHARED ${PLUGIN_SOURCES} ${MOBILE_COMMANDS} ${HMI_COMMANDS} ${COMMANDS_SOURCES}) -target_link_libraries("rc_rpc_plugin" ${LIBRARIES}) +add_library("rc_rpc_plugin_static" ${PLUGIN_SOURCES} ${MOBILE_COMMANDS} ${HMI_COMMANDS}) +target_link_libraries("rc_rpc_plugin_static" ${LIBRARIES}) + +add_library("rc_rpc_plugin" SHARED "src/rc_rpc_plugin.cc") +target_link_libraries("rc_rpc_plugin" rc_rpc_plugin_static) -add_library("RCRpcPluginStaticLib" ${PLUGIN_SOURCES} ${MOBILE_COMMANDS} ${HMI_COMMANDS}) -target_link_libraries("RCRpcPluginStaticLib" ${LIBRARIES}) set(INSTALL_DESTINATION bin) 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 3bc34be8d19..08082d98bb7 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 @@ -35,8 +35,8 @@ #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 "rc_rpc_plugin/resource_allocation_manager.h" #include "utils/macro.h" namespace rc_rpc_plugin { 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 939d5fa4684..5ed2236d9c5 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 @@ -35,8 +35,8 @@ #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 "rc_rpc_plugin/resource_allocation_manager.h" #include "utils/macro.h" namespace rc_rpc_plugin { 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 97df5e8390e..9a6cf9e2905 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 @@ -1,42 +1,42 @@ /* -* 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. -*/ + * 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_HMI_RC_GET_INTERIOR_VEHICLE_DATA_CONSENT_REQUEST_H_ #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 "rc_rpc_plugin/resource_allocation_manager.h" #include "utils/macro.h" namespace rc_rpc_plugin { 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 46232987a5e..677e3ad1f09 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 @@ -35,8 +35,8 @@ #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 "rc_rpc_plugin/resource_allocation_manager.h" #include "utils/macro.h" namespace rc_rpc_plugin { 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 a88a39aa7a5..a75020956c6 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 @@ -35,8 +35,8 @@ #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 "rc_rpc_plugin/resource_allocation_manager.h" #include "utils/macro.h" namespace rc_rpc_plugin { 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 c9e5d39d1df..059164dc9f7 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 @@ -35,8 +35,8 @@ #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 "rc_rpc_plugin/resource_allocation_manager.h" #include "utils/macro.h" namespace rc_rpc_plugin { 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 aeb0a06d229..2a15f3816a8 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 @@ -35,8 +35,8 @@ #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 "rc_rpc_plugin/resource_allocation_manager.h" #include "utils/macro.h" namespace rc_rpc_plugin { 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 7aa1aa3dba3..82e0a8c13b2 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 @@ -69,6 +69,7 @@ class RCOnRemoteControlSettingsNotification private: ResourceAllocationManager& resource_allocation_manager_; InteriorDataManager& interior_data_manager_; + RCConsentManager& rc_consent_manager_; /** * @brief Disalows RC functionality for all RC apps * All registered apps will be unsubsribed from OnInteriorVehicleData diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/hmi/rc_set_global_properties_request.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/hmi/rc_set_global_properties_request.h new file mode 100644 index 00000000000..64b11c3d7b9 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/hmi/rc_set_global_properties_request.h @@ -0,0 +1,66 @@ +/* + * Copyright (c) 2019, Ford Motor Company + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following + * disclaimer in the documentation and/or other materials provided with the + * distribution. + * + * Neither the name of the Ford Motor Company nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_RC_SET_GLOBAL_PROPERTIES_REQUEST_H +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_RC_SET_GLOBAL_PROPERTIES_REQUEST_H + +#include "application_manager/commands/request_to_hmi.h" +#include "rc_rpc_plugin/commands/rc_command_request.h" + +namespace rc_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +class RCSetGlobalPropertiesRequest : public app_mngr::commands::RequestToHMI { + public: + /** + * @brief RCSetGlobalPropertiesRequest class constructor + * + * @param message Command message as smart pointer to SmartObject + * @param params structure that contains references to + * parameters used in remote сontrol commands + */ + RCSetGlobalPropertiesRequest( + const app_mngr::commands::MessageSharedPtr& message, + const RCCommandParams& params); + /** + * @brief Execute command + */ + void Run() OVERRIDE; + + ~RCSetGlobalPropertiesRequest(); +}; +} // namespace commands +} // namespace rc_rpc_plugin + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_RC_SET_GLOBAL_PROPERTIES_REQUEST_H diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/hmi/rc_set_global_properties_response.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/hmi/rc_set_global_properties_response.h new file mode 100644 index 00000000000..2e1494364cf --- /dev/null +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/hmi/rc_set_global_properties_response.h @@ -0,0 +1,68 @@ +/* + Copyright (c) 2019, Ford Motor Company + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + + Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following + disclaimer in the documentation and/or other materials provided with the + distribution. + + Neither the name of the Ford Motor Company nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_RC_SET_GLOBAL_PROPERTIES_RESPONSE_H +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_RC_SET_GLOBAL_PROPERTIES_RESPONSE_H + +#include "application_manager/commands/response_from_hmi.h" +#include "rc_rpc_plugin/commands/rc_command_request.h" + +namespace rc_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { +class RCSetGlobalPropertiesResponse + : public application_manager::commands::ResponseFromHMI { + public: + /** + * @brief RCSetGlobalPropertiesResponse class constructor + * + * @param message Command message as smart pointer to SmartObject + * @param params Structure that contains references to + * parameters used in remote сontrol commands + */ + RCSetGlobalPropertiesResponse( + const application_manager::commands::MessageSharedPtr& message, + const RCCommandParams& params); + + /** + * @brief Execute command + */ + void Run() OVERRIDE; + + ~RCSetGlobalPropertiesResponse(); +}; + +} // namespace commands +} // namespace rc_rpc_plugin + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_RC_SET_GLOBAL_PROPERTIES_RESPONSE_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 69b48bfecff..aeba2f14404 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 @@ -35,8 +35,8 @@ #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 "rc_rpc_plugin/resource_allocation_manager.h" #include "utils/macro.h" namespace rc_rpc_plugin { 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 8a635032202..8369941c307 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 @@ -35,8 +35,8 @@ #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 "rc_rpc_plugin/resource_allocation_manager.h" #include "utils/macro.h" namespace rc_rpc_plugin { 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 d6ecfd01284..3946d805088 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 @@ -64,9 +64,11 @@ class ButtonPressRequest : public RCCommandRequest { /** * @brief IsResourceFree check resource state * @param module_type Resource name + * @param module_id Resource id * @return True if free, otherwise - false */ - bool IsResourceFree(const std::string& module_type) const FINAL; + bool IsResourceFree(const std::string& module_type, + const std::string& module_id) const FINAL; /** * @brief SetResourceState changes state of resource @@ -82,12 +84,18 @@ class ButtonPressRequest : public RCCommandRequest { */ void on_event(const app_mngr::event_engine::Event& event) FINAL; - std::string ModuleType() FINAL; + std::string ModuleType() const FINAL; + + std::string ModuleId() const FINAL; /** * @brief ButtonPressRequest class destructor */ ~ButtonPressRequest(); + + private: + const mobile_apis::ButtonName::eType GetButtonId() const; + std::string GetButtonName() const; }; } // namespace commands 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 0f3964494e9..69122c19f3e 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 @@ -34,9 +34,9 @@ #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 "rc_rpc_plugin/resource_allocation_manager.h" #include "utils/macro.h" namespace rc_rpc_plugin { diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/get_interior_vehicle_data_consent_request.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/get_interior_vehicle_data_consent_request.h new file mode 100644 index 00000000000..c41169d0273 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/get_interior_vehicle_data_consent_request.h @@ -0,0 +1,123 @@ +/* + * Copyright (c) 2019, 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_MOBILE_RC_GET_INTERIOR_VEHICLE_DATA_CONSENT_REQUEST_H +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_COMMANDS_MOBILE_RC_GET_INTERIOR_VEHICLE_DATA_CONSENT_REQUEST_H + +#include + +#include "rc_rpc_plugin/commands/rc_command_params.h" +#include "rc_rpc_plugin/commands/rc_command_request.h" +#include "utils/macro.h" + +namespace rc_rpc_plugin { +namespace commands { + +class GetInteriorVehicleDataConsentRequest + : public rc_rpc_plugin::commands::RCCommandRequest { + public: + /** + * @brief GetInteriorVehicleDataConsentRequest constructor + * @param message smart pointer with SmartObject + * @param params structure that contains references to + * parameters used in remote сontrol commands + */ + GetInteriorVehicleDataConsentRequest( + const application_manager::commands::MessageSharedPtr& message, + const RCCommandParams& params); + + /** + * @brief Execute command + */ + void Execute() FINAL; + + void on_event(const app_mngr::event_engine::Event& event) FINAL; + + std::string ModuleType() const FINAL; + + /** + * @brief For this RPC this method isn't correct, because SDL receives array + * of module_ids instead of only one module_id. This method returns empty + * string. + */ + std::string ModuleId() const FINAL; + + ~GetInteriorVehicleDataConsentRequest(); + + private: + /** + * @brief Saves ModuleId consents (saved before moduleids + received moduleId + * consents + date_of_consent) to file. + * + * @param msg_params Message params from response message as SmartObject. + */ + bool SaveModuleIdConsents(std::string& info_out, + const smart_objects::SmartObject& msg_params); + + /** + * @brief Gets calculated vehicle data consent and puts it into provided smart + * object + * @param out_response output smart object + * @return true in case all required consent information was provided in + * output smart object, otherwise returns false + */ + bool GetCalculatedVehicleDataConsent( + smart_objects::SmartObject& out_response) const; + + /** + * @brief Checks whether the user_location is covered by the module's + * serviceArea + * @param module_uid module key(module_type + module_id) + * @return true if the user_location is covered by the module's serviceArea or + * the user is the driver (or if seatLocationCapabilities don't exists) + * otherwise false + */ + bool IsUserLocationValid(const ModuleUid& module_uid) const; + + /** + * @brief Checks whether user should have access to module using the specific + * accessMode's rules + * @param module_uid module key(moudle_type + module_id) + * @param access_mode current HMI accessMode + * @return consent enum value + */ + rc_rpc_types::ModuleConsent GetModuleConsentByAccessMode( + const ModuleUid& module_uid, + const hmi_apis::Common_RCAccessMode::eType access_mode) const; + + smart_objects::SmartObject hmi_request_consents_; +}; + +} // namespace commands +} // namespace rc_rpc_plugin + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_COMMANDS_MOBILE_RC_GET_INTERIOR_VEHICLE_DATA_CONSENT_REQUEST_H diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/get_interior_vehicle_data_consent_response.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/get_interior_vehicle_data_consent_response.h new file mode 100644 index 00000000000..c163b02a80e --- /dev/null +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/get_interior_vehicle_data_consent_response.h @@ -0,0 +1,68 @@ +/* + * Copyright (c) 2019, 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_MOBILE_RC_GET_INTERIOR_VEHICLE_DATA_CONSENT_RESPONSE_H +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_COMMANDS_MOBILE_RC_GET_INTERIOR_VEHICLE_DATA_CONSENT_RESPONSE_H + +#include "application_manager/commands/command_response_impl.h" +#include "rc_rpc_plugin/commands/rc_command_params.h" +#include "utils/macro.h" + +namespace rc_rpc_plugin { + +namespace commands { + +class GetInteriorVehicleDataConsentResponse + : public application_manager::commands::CommandResponseImpl { + public: + /** + * @brief GetInteriorVehicleDataConsentResponse constructor + * + * @param message smart pointer with SmartObject + * @param params structure which contains references for next + * entities: ApplicationManager, RPCService, HMICapabilities, + * PolicyHandlerInterface, ResourceAllocationManager, InteriorDataCache, + * InteriorDataManager. + */ + GetInteriorVehicleDataConsentResponse( + const application_manager::commands::MessageSharedPtr& message, + const RCCommandParams& params); + + void Run() OVERRIDE; + + ~GetInteriorVehicleDataConsentResponse(); +}; + +} // namespace commands +} // namespace rc_rpc_plugin + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_COMMANDS_MOBILE_RC_GET_INTERIOR_VEHICLE_DATA_CONSENT_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 01588cc6b7e..7be37f0756d 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 @@ -33,8 +33,8 @@ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_COMMANDS_MOBILE_GET_INTERIOR_VEHICLE_DATA_REQUEST_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_COMMANDS_MOBILE_GET_INTERIOR_VEHICLE_DATA_REQUEST_H_ -#include "rc_rpc_plugin/commands/rc_command_request.h" #include +#include "rc_rpc_plugin/commands/rc_command_request.h" namespace rc_rpc_plugin { namespace app_mngr = application_manager; @@ -63,8 +63,8 @@ class GetInteriorVehicleDataRequest : public RCCommandRequest { ~GetInteriorVehicleDataRequest(); private: - std::vector - AppsSubscribedToModuleType(const std::string& module_type); + std::vector AppsSubscribedToModule( + const ModuleUid& module); /** * @brief Check if app wants to proceed with already setup subscription @@ -76,9 +76,9 @@ class GetInteriorVehicleDataRequest : public RCCommandRequest { bool HasRequestExcessiveSubscription(); /** - * @brief Handle subscription to vehicle data - * @param hmi_response json message with response from HMI - */ + * @brief Handle subscription to vehicle data + * @param hmi_response json message with response from HMI + */ void ProccessSubscription(const smart_objects::SmartObject& hmi_response); /** @@ -87,7 +87,8 @@ class GetInteriorVehicleDataRequest : public RCCommandRequest { */ void RemoveExcessiveSubscription(); - std::string ModuleType() FINAL; + std::string ModuleType() const FINAL; + std::string ModuleId() const FINAL; bool excessive_subscription_occured_; bool ProcessCapabilities(); void ProcessResponseToMobileFromCache(app_mngr::ApplicationSharedPtr app); 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 bf8208edc2e..58dac85633b 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 @@ -35,8 +35,8 @@ #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 "rc_rpc_plugin/resource_allocation_manager.h" #include "utils/macro.h" namespace rc_rpc_plugin { 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 931e79366cd..4663b4b371a 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 @@ -35,9 +35,9 @@ #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 "rc_rpc_plugin/interior_data_cache.h" +#include "rc_rpc_plugin/resource_allocation_manager.h" #include "utils/macro.h" namespace rc_rpc_plugin { @@ -53,13 +53,16 @@ class OnInteriorVehicleDataNotification void Run() OVERRIDE; - std::string ModuleType(); + std::string ModuleType() const; + + std::string ModuleId() const; ~OnInteriorVehicleDataNotification(); private: InteriorDataCache& interior_data_cache_; - void AddDataToCache(const std::string& module_type); + RCCapabilitiesManager& rc_capabilities_manager_; + void AddDataToCache(const ModuleUid& module); }; } // namespace commands } // namespace rc_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/release_interior_vehicle_data_module_request.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/release_interior_vehicle_data_module_request.h new file mode 100644 index 00000000000..316dc29a1d2 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/release_interior_vehicle_data_module_request.h @@ -0,0 +1,71 @@ +/* + * Copyright (c) 2019, 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_MOBILE_RELEASE_INTERIOR_VEHICLE_DATA_MODULE_REQUEST_H +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_COMMANDS_MOBILE_RELEASE_INTERIOR_VEHICLE_DATA_MODULE_REQUEST_H + +#include "rc_rpc_plugin/commands/rc_command_params.h" +#include "rc_rpc_plugin/commands/rc_command_request.h" +#include "utils/macro.h" + +namespace rc_rpc_plugin { +namespace commands { + +class ReleaseInteriorVehicleDataModuleRequest + : public rc_rpc_plugin::commands::RCCommandRequest { + public: + /** + * @brief ReleaseInteriorVehicleDataModule constructor + * @param message smart pointer with SmartObject + * @param params structure that contains references to + * parameters used in remote сontrol commands + */ + ReleaseInteriorVehicleDataModuleRequest( + const application_manager::commands::MessageSharedPtr& message, + const RCCommandParams& params); + + void Execute() FINAL; + + std::string ModuleType() const FINAL; + + std::string ModuleId() const FINAL; + + ~ReleaseInteriorVehicleDataModuleRequest(); + + private: + bool ProcessCapabilities(); +}; + +} // namespace commands +} // namespace rc_rpc_plugin + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_COMMANDS_MOBILE_RELEASE_INTERIOR_VEHICLE_DATA_MODULE_REQUEST_H diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/release_interior_vehicle_data_module_response.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/release_interior_vehicle_data_module_response.h new file mode 100644 index 00000000000..42e0775a835 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/release_interior_vehicle_data_module_response.h @@ -0,0 +1,67 @@ +/* + * Copyright (c) 2019, 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_MOBILE_RELEASE_INTERIOR_VEHICLE_DATA_MODULE_RESPONSE_H +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_COMMANDS_MOBILE_RELEASE_INTERIOR_VEHICLE_DATA_MODULE_RESPONSE_H + +#include "application_manager/commands/command_response_impl.h" +#include "rc_rpc_plugin/commands/rc_command_params.h" +#include "utils/macro.h" + +namespace rc_rpc_plugin { +namespace commands { + +class ReleaseInteriorVehicleDataModuleResponse + : public application_manager::commands::CommandResponseImpl { + public: + /** + * @brief ReleaseInteriorVehicleDataModuleResponse constructor + * + * @param message smart pointer with SmartObject + * @param params structure which contains references for next + * entities: ApplicationManager, RPCService, HMICapabilities, + * PolicyHandlerInterface, ResourceAllocationManager, InteriorDataCache, + * InteriorDataManager. + */ + ReleaseInteriorVehicleDataModuleResponse( + const application_manager::commands::MessageSharedPtr& message, + const RCCommandParams& params); + + void Run() OVERRIDE; + + ~ReleaseInteriorVehicleDataModuleResponse(); +}; + +} // namespace commands +} // namespace rc_rpc_plugin + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_COMMANDS_MOBILE_RELEASE_INTERIOR_VEHICLE_DATA_MODULE_RESPONSE_H 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 128c668ee9e..bb152a52f88 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 @@ -40,10 +40,6 @@ namespace app_mngr = application_manager; namespace commands { -enum capabilitiesStatus { success, missedLightName, missedParam, readOnly }; - -typedef std::pair ModuleCapability; - class SetInteriorVehicleDataRequest : public RCCommandRequest { public: SetInteriorVehicleDataRequest( @@ -66,9 +62,11 @@ class SetInteriorVehicleDataRequest : public RCCommandRequest { /** * @brief IsResourceFree check resource state * @param module_type Resource name + * @param module_id Resource id * @return True if free, otherwise - false */ - bool IsResourceFree(const std::string& module_type) const FINAL; + bool IsResourceFree(const std::string& module_type, + const std::string& module_id) const FINAL; /** * @brief SetResourceState changes state of resource @@ -84,29 +82,15 @@ class SetInteriorVehicleDataRequest : public RCCommandRequest { */ void on_event(const app_mngr::event_engine::Event& event) FINAL; - /** - * @brief Method that check if READ_ONLY parameters present - * @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, - ModuleCapability& module_data_capabilities); - - /** - * @brief Method that check if all request parameters are READ_ONLY - * @param request_params params from received message - * @return true if all are read only , false - otherwise - */ - bool AreAllParamsReadOnly(const smart_objects::SmartObject& module_data); - /** * @brief Method that cuts-off READ_ONLY parameters * @param module_data params to handle */ void CutOffReadOnlyParams(smart_objects::SmartObject& module_data); - std::string ModuleType() FINAL; + std::string ModuleType() const FINAL; + + std::string ModuleId() const FINAL; /** * @brief SetInteriorVehicleDataRequest class destructor @@ -114,14 +98,6 @@ class SetInteriorVehicleDataRequest : public RCCommandRequest { ~SetInteriorVehicleDataRequest(); private: - /** - * @brief ControlData - * @param module_data received params - * @return value of module data depending on module type - */ - 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 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 1ab5ccc6bce..f54418fc089 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 @@ -34,9 +34,9 @@ #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 "rc_rpc_plugin/interior_data_cache.h" +#include "rc_rpc_plugin/resource_allocation_manager.h" #include "utils/macro.h" namespace rc_rpc_plugin { 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 index 8e7ed9c667d..3b46b7ea303 100644 --- 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 @@ -39,7 +39,7 @@ namespace rpc_service { class RPCService; } class HMICapabilities; -} +} // namespace application_manager namespace policy { class PolicyHandlerInterface; @@ -50,6 +50,8 @@ namespace rc_rpc_plugin { class ResourceAllocationManager; class InteriorDataCache; class InteriorDataManager; +class RCCapabilitiesManager; +class RCConsentManager; struct RCCommandParams { application_manager::ApplicationManager& application_manager_; @@ -59,6 +61,8 @@ struct RCCommandParams { rc_rpc_plugin::ResourceAllocationManager& resource_allocation_manager_; rc_rpc_plugin::InteriorDataCache& interior_data_cache_; rc_rpc_plugin::InteriorDataManager& interior_data_manager_; + rc_rpc_plugin::RCCapabilitiesManager& rc_capabilities_manager_; + rc_rpc_plugin::RCConsentManager& rc_consent_manager_; }; -} +} // namespace rc_rpc_plugin #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 ce95617b6cc..6bca1017e0d 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 @@ -33,11 +33,13 @@ #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" +#include "rc_rpc_plugin/interior_data_cache.h" +#include "rc_rpc_plugin/rc_app_extension.h" +#include "rc_rpc_plugin/rc_capabilities_manager.h" +#include "rc_rpc_plugin/rc_consent_manager.h" +#include "rc_rpc_plugin/resource_allocation_manager.h" namespace rc_rpc_plugin { namespace app_mngr = application_manager; @@ -76,6 +78,8 @@ class RCCommandRequest : public app_mngr::commands::CommandRequestImpl { ResourceAllocationManager& resource_allocation_manager_; InteriorDataCache& interior_data_cache_; InteriorDataManager& interior_data_manager_; + RCCapabilitiesManager& rc_capabilities_manager_; + RCConsentManager& rc_consent_manager_; /** * @brief AcquireResource try to allocate resource for application * In case if allocation of resource is not required, return ALLOWED by @@ -94,10 +98,13 @@ class RCCommandRequest : public app_mngr::commands::CommandRequestImpl { * This is default implementation which has to be redefined for RPCs which * need to manage the resources * @param module_type Resource name + * @param module_id Resource id * @return True if free, otherwise - false */ - virtual bool IsResourceFree(const std::string& module_type) const { + virtual bool IsResourceFree(const std::string& module_type, + const std::string& module_id) const { UNUSED(module_type); + UNUSED(module_id); return true; } /** @@ -136,7 +143,24 @@ class RCCommandRequest : public app_mngr::commands::CommandRequestImpl { disallowed_info_ = info; } - virtual std::string ModuleType() = 0; + virtual std::string ModuleType() const = 0; + + /** + * @brief Extracts ModuleId from command message. Each inherited class should + * implement its own functionality + * + * @return ModuleId as string. + */ + virtual std::string ModuleId() const = 0; + + /** + * @brief IsModuleIdProvided checks if moduleId parameter + * is provided in the hmi response + * @param hmi_response response from hmi + * @return true if provided, otherwise - false + */ + + bool IsModuleIdProvided(const smart_objects::SmartObject& hmi_response) const; private: /** @@ -158,15 +182,44 @@ class RCCommandRequest : public app_mngr::commands::CommandRequestImpl { /** * @brief SendGetUserConsent sends consent request to HMI * @param module_type Resource name + * @param module_ids Array of module IDs of the module type that needed user + * consent for acquiring their resources */ - void SendGetUserConsent(const std::string& module_type); + void SendGetUserConsent(const std::string& module_type, + const smart_objects::SmartObject& module_ids); + void ProcessAccessResponse(const app_mngr::event_engine::Event& event); + + /** + * @brief Precesses consents result which has been received from HMI + * If module resource consented, resource state will be switched to state BUSY + * and called method Execute. Otherwise will be sent response to Mobile with + * result code REJECTED. + * @param is_allowed consent result + * @param module_type Module type + * @param module_id Module ID + * @param app_id Application, which has asked for module resource consent. + */ + void ProcessConsentResult(const bool is_allowed, + const std::string& module_type, + const std::string& module_id, + const uint32_t app_id); + /** + * @brief Processes ASK_DRIVE Mode. Tries to retrieve module consents from + * LastState. If consent is absent in LastState, will send + * GetInteriorVehicleDataConsent to HMI. Otherwise will start to process + * consent result. + * @param module_type Module type + * @param module_id Module ID + */ + void ProcessAskDriverMode(const std::string& module_type, + const std::string& module_id); bool IsInterfaceAvailable( const app_mngr::HmiInterfaces::InterfaceID interface) const; std::string disallowed_info_; }; -} -} +} // namespace commands +} // namespace rc_rpc_plugin #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/interior_data_cache.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/interior_data_cache.h index bb45247fae8..dad37edd1bc 100644 --- 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 @@ -36,9 +36,16 @@ namespace rc_rpc_plugin { +/** + * @brief ModuleUid uniquely identify a module + * moduleType + moduleID + */ +typedef std::pair ModuleUid; + /** * @brief The InteriorDataCache interface for caching data class - * Provide ability to cache module data by module type name and clear cache + * Provide ability to cache module data by module type name and module id + * and clear cache */ class InteriorDataCache { public: @@ -49,38 +56,41 @@ class InteriorDataCache { /** * @brief Add module data to cache - * @param module_type module type name + * @param module module type + module id * @param module_data data to be cached */ - virtual void Add(const std::string& module_type, + virtual void Add(const ModuleUid& module, const smart_objects::SmartObject& module_data) = 0; /** * @brief Retrieve Get cached data - * @param module_type data type to get from cache + * @param module data type to get from cache * @return smart object with cached data, or nulll smart object */ virtual smart_objects::SmartObject Retrieve( + const ModuleUid& module) const = 0; + + virtual std::vector GetCachedModulesByType( 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 + * @param module module name + module id to check in cache * @return true if cached, false otherwize */ - virtual bool Contains(const std::string& module_type) const = 0; + virtual bool Contains(const ModuleUid& module) const = 0; /** * @brief Remove cached data - * @param module_type data type to remove from cache + * @param module data type to remove from cache */ - virtual void Remove(const std::string& module_type) = 0; + virtual void Remove(const ModuleUid& module) = 0; /** * @brief Clear clear all cached data */ virtual void Clear() = 0; }; -} // rc_rpc_plugin +} // namespace 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 index f2971e3d727..d21b0e41626 100644 --- 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 @@ -35,9 +35,9 @@ #include -#include "utils/macro.h" -#include "utils/lock.h" #include "rc_rpc_plugin/interior_data_cache.h" +#include "utils/lock.h" +#include "utils/macro.h" namespace rc_rpc_plugin { class InteriorDataCacheImpl : public InteriorDataCache { @@ -46,19 +46,22 @@ class InteriorDataCacheImpl : public InteriorDataCache { ~InteriorDataCacheImpl(); - void Add(const std::string& module_type, + void Add(const ModuleUid& module, const smart_objects::SmartObject& module_data) OVERRIDE; - smart_objects::SmartObject Retrieve( + smart_objects::SmartObject Retrieve(const ModuleUid& module) const OVERRIDE; + + std::vector GetCachedModulesByType( const std::string& module_type) const OVERRIDE; - bool Contains(const std::string& module_type) const OVERRIDE; - void Remove(const std::string& module_type) OVERRIDE; + + bool Contains(const ModuleUid& module) const OVERRIDE; + void Remove(const ModuleUid& module) OVERRIDE; void Clear() OVERRIDE; private: - std::map cached_data_; + std::map cached_data_; mutable sync_primitives::Lock cached_data_lock_; }; -} // rc_rpc_plugin +} // namespace 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 index f28c3880550..c1fe30fa4dc 100644 --- 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 @@ -41,8 +41,15 @@ namespace rc_rpc_plugin { namespace app_mngr = application_manager; namespace plugins = application_manager::plugin_manager; +/** + * @brief ModuleUid uniquely identify a module + * moduleType + moduleID + */ +typedef std::pair ModuleUid; + class InteriorDataManager { public: + virtual ~InteriorDataManager() {} /** * @brief OnPolicyEvent Processes policy related events * @param event Policy event @@ -50,10 +57,10 @@ class InteriorDataManager { 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 - */ + * @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; @@ -67,18 +74,19 @@ class InteriorDataManager { /** * @brief StoreRequestToHMITime save information and time stamp of * current interior data subscriptions + * @param module Module resource (module_type + module_id) */ - virtual void StoreRequestToHMITime(const std::string& module_type) = 0; + virtual void StoreRequestToHMITime(const ModuleUid& module) = 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; + * @brief CheckRequestsToHMIFrequency check that rate limits are not allowed + * of bounce during current time frame. calculate amount of requests per + * module in time frame and checks if it bigger then allowed by ini file + * @param module module to calculate frequency on + * @return true if amount of requests was not exceeded, otherwise return + * false. + */ + virtual bool CheckRequestsToHMIFrequency(const ModuleUid& module) = 0; }; } // namespace rc_rpc_plugin 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 9b16a2c4da6..791016cdcd0 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 @@ -40,7 +40,7 @@ class ApplicationManager; namespace rpc_service { class RPCService; } -} +} // namespace application_manager namespace rc_rpc_plugin { class InteriorDataCache; @@ -61,9 +61,9 @@ class InteriorDataManagerImpl : public InteriorDataManager { void OnDisablingRC() OVERRIDE; - void StoreRequestToHMITime(const std::string& module_type) OVERRIDE; + void StoreRequestToHMITime(const ModuleUid& module) OVERRIDE; - bool CheckRequestsToHMIFrequency(const std::string& module_type) OVERRIDE; + bool CheckRequestsToHMIFrequency(const ModuleUid& module) OVERRIDE; private: /** @@ -83,18 +83,21 @@ class InteriorDataManagerImpl : public InteriorDataManager { application_manager::Application& app); /** - * @brief UnsubscribeFromInteriorVehicleData remove module_type from cache and + * @brief UnsubscribeFromInteriorVehicleData remove module from cache and * send RC.GetInteriorVehicleData(subscribe=false) to HMI - * @param module_type module type that need to be unsubscribed + * @param module module that needs to be unsubscribed */ - void UnsubscribeFromInteriorVehicleData(const std::string& module_type); + void UnsubscribeFromInteriorVehicleData(const ModuleUid& module); + + void UnsubscribeFromInteriorVehicleDataOfType(const std::string& module_type); void ClearOldRequestsToHMIHistory(); /** * @brief AppsModules mapping from applications to list of modules */ typedef std::map > AppsModules; + std::vector > + AppsModules; /** * @brief AppsSubscribedModules get mapping of application to list of @@ -103,11 +106,16 @@ class InteriorDataManagerImpl : public InteriorDataManager { */ AppsModules AppsSubscribedModules(); + typedef std::map > + AppsModuleTypes; + AppsModuleTypes AppsSubscribedModuleTypes(); + /** * @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/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 e36968fc4b6..33271e64fd9 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 @@ -33,13 +33,110 @@ #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 #include -#include "utils/macro.h" +#include +#include #include "application_manager/app_extension.h" +#include "utils/macro.h" namespace rc_rpc_plugin { + +typedef std::pair ModuleUid; + +struct Grid { + int32_t col_; + int32_t row_; + int32_t level_; + int32_t colspan_; + int32_t rowspan_; + int32_t levelspan_; + + Grid() + : col_(0), row_(0), level_(0), colspan_(0), rowspan_(0), levelspan_(0) {} + + Grid(int32_t col, + int32_t row, + int32_t level, + int32_t colspan, + int32_t rowspan, + int32_t levelspan) + : col_(col) + , row_(row) + , level_(level) + , colspan_(colspan) + , rowspan_(rowspan) + , levelspan_(levelspan) {} + + Grid& operator=(const Grid& grid) { + col_ = grid.col_; + row_ = grid.row_; + level_ = grid.level_; + colspan_ = grid.colspan_; + rowspan_ = grid.rowspan_; + levelspan_ = grid.levelspan_; + + return *this; + } + + bool operator==(const Grid& grid) const { + return col_ == grid.col_ && row_ == grid.row_ && level_ == grid.level_ && + colspan_ == grid.colspan_ && rowspan_ == grid.rowspan_ && + levelspan_ == grid.levelspan_; + } + + /** + * @brief LevelIntersectionExists checks if the grids have an + * intersection by levels. + * @param grid with which to check intersection + * @return true if intersection exists, otherwise - false + */ + bool LevelIntersectionExists(const Grid& grid) const { + const int32_t top_level = (level_ + levelspan_) - 1; + const int32_t grid_top_level = (grid.level_ + grid.levelspan_) - 1; + + const int32_t min_level = std::max(level_, grid.level_); + const int32_t max_level = std::min(top_level, grid_top_level); + if ((max_level - min_level) < 0) { + return false; + } + return true; + } + + /** + * @brief IntersectionExists checks if the grids have an + * intersection. Grid can be represented by its bottom-left + * and top-right coordinates like a rectangle. First, the + * coordinates of the intersection are calculated, then checked + * that the rectangle which is formed by the intersections of two + * grids has non-zero width and height. + * @param grid with which to check intersection + * @return true if intersection exists, otherwise - false + */ + bool IntersectionExists(const Grid& grid) const { + if (!LevelIntersectionExists(grid)) { + return false; + } + + const int32_t right_top_col = (col_ + colspan_) - 1; + const int32_t right_top_row = (row_ + rowspan_) - 1; + const int32_t grid_right_top_col = (grid.col_ + grid.colspan_) - 1; + const int32_t grid_right_top_row = (grid.row_ + grid.rowspan_) - 1; + + const int32_t left = std::max(col_, grid.col_); + const int32_t bottom = std::max(row_, grid.row_); + const int32_t right = std::min(right_top_col, grid_right_top_col); + const int32_t top = std::min(right_top_row, grid_right_top_row); + + const int32_t width = right - left; + const int32_t height = top - bottom; + + if ((width < 0) || (height < 0)) { + return false; + } + return true; + } +}; + class RCAppExtension : public application_manager::AppExtension { public: explicit RCAppExtension(application_manager::AppExtensionUID uid); @@ -49,13 +146,15 @@ class RCAppExtension : public application_manager::AppExtension { * @brief Subscribe to OnInteriorVehicleDataNotification * @param module interior data specification(zone, data type) */ - void SubscribeToInteriorVehicleData(const std::string& module_type); + void SubscribeToInteriorVehicleData(const ModuleUid& module); /** * @brief Unsubscribe from OnInteriorVehicleDataNotification * @param module interior data specification(zone, data type) */ - void UnsubscribeFromInteriorVehicleData(const std::string& module_type); + void UnsubscribeFromInteriorVehicleData(const ModuleUid& module); + + void UnsubscribeFromInteriorVehicleDataOfType(const std::string& module_type); /** * @brief UnsubscribeFromInteriorVehicleData removes all subscriptions for @@ -67,16 +166,40 @@ class RCAppExtension : public application_manager::AppExtension { * @brief Check if application subscribed to OnInteriorVehicleDataNotification * @param module interior data specification(zone, data type) */ - bool IsSubscibedToInteriorVehicleData(const std::string& module_type); + bool IsSubscribedToInteriorVehicleData(const ModuleUid& module); + + bool IsSubscribedToInteriorVehicleDataOfType(const std::string& module_type); /** * @brief get list of subscriptions of application * @return list of subscriptions of application */ - std::set InteriorVehicleDataSubscriptions() const; + std::set InteriorVehicleDataSubscriptions() const; + + /** + * @brief GetUserLocation + * @return grid of user location + */ + Grid GetUserLocation() const; + + /** + * @brief SetUserLocation sets user location + * from object to the grid + * @param user_location smart object for user_location + */ + void SetUserLocation( + const ns_smart_device_link::ns_smart_objects::SmartObject& user_location); + + /** + * @brief SetUserLocation sets user location from grid + * @param grid grid of user_location + */ + void SetUserLocation(const Grid& grid); private: - std::set subscribed_interior_vehicle_data_; + std::set subscribed_interior_vehicle_data_; + + Grid user_location_; // AppExtension interface public: diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_capabilities_manager.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_capabilities_manager.h new file mode 100644 index 00000000000..36fd8bbbf93 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_capabilities_manager.h @@ -0,0 +1,184 @@ +/* + Copyright (c) 2019, 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_CAPABILITIES_MANAGER_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_RC_CAPABILITIES_MANAGER_H_ +#include "application_manager/application_manager.h" +#include "rc_rpc_plugin/resource_allocation_manager.h" + +namespace rc_rpc_plugin { + +enum capabilitiesStatus { success, missedLightName, missedParam, readOnly }; +typedef std::pair ModuleTypeCapability; + +class RCCapabilitiesManager { + public: + /** + * @brief CheckIfButtonExistInRCCaps checks if the + * specified button exists in rc_capabilities + * @param button button name + * @return true if present, otherwise - false + */ + virtual bool CheckIfButtonExistInRCCaps( + const mobile_apis::ButtonName::eType button) const = 0; + + /** + * @brief CheckButtonName checks if the button + * corresponds to the module_type + * @param module_type resource name + * @param button_name button name + * @return true if they match, otherwise - false + */ + virtual bool CheckButtonName(const std::string& module_type, + const std::string& button_name) const = 0; + + /** + * @brief CheckIfModuleExistsInCapabilities checks + * if the specified module exists in rc_capabilities + * @param module moduleType + moduleId + * @return true if exists, otherwise - false + */ + virtual bool CheckIfModuleExistsInCapabilities( + const ModuleUid& module) const = 0; + + /** + * @brief GetModuleDataCapabilities checks whether rc module data + * capabilities are presented + * @param module_data smart object of module_data + * @param module_id module id + * @return pair of state and capability status - ModuleCapability + */ + virtual ModuleTypeCapability GetModuleDataCapabilities( + const smart_objects::SmartObject& module_data, + const std::string& module_id) const = 0; + + /** + * @brief ControlData retrieves control data + * for specified module type + * @param module_data smart object of module_data + * @param module_type resource name + * @return smart object of control data + */ + virtual const smart_objects::SmartObject& ControlDataForType( + const smart_objects::SmartObject& module_data, + const std::string& module_type) const = 0; + + /** + * @brief AreReadOnlyParamsPresent checks if there are + * any read only params in the module data + * @param module_data smart object of module_data + * @param module_type resource name + * @param module_data_capabilities smart object of capabilities + * @return true if read only params exist, otherwise - false + */ + virtual bool AreReadOnlyParamsPresent( + const smart_objects::SmartObject& module_data, + const std::string& module_type, + ModuleTypeCapability& module_data_capabilities) const = 0; + + /** + * @brief AreAllParamsReadOnly checks that all params from module + * data are read only + * @param module_data smart object of module_data + * @param module_type resource name + * @return true if all params are read only, otherwise - false + */ + virtual bool AreAllParamsReadOnly( + const smart_objects::SmartObject& module_data, + const std::string& module_type) const = 0; + + /** + * @brief GetDefaultModuleIdFromCapabilities returns the moduleId + * from the first item published by xyz-ControlCapabilities + * @param module_type resource name + * @return default module id from HMI capabilities + */ + virtual const std::string GetDefaultModuleIdFromCapabilities( + const std::string& module_type) const = 0; + + /** + * @brief GetResources get list of ModuleUids(moduleType + moduleId) + * of all known resources + * @return vector contains all known moduleUids + */ + virtual const std::vector GetResources() const = 0; + + /** + * @brief GetModuleServiceArea retrieves service area of module, + * if module serviceArea is missed in capabilities, serviceArea is + * assumed to be the same as location, if location + * is missed in capabilities, it is assumed that serviceArea covers + * the whole area of vehicle + * @param module module type + module id + * @return Grid of module service area + */ + virtual Grid GetModuleServiceArea(const ModuleUid& module) const = 0; + + /** + * @brief IsMultipleAccessAllowed checks if multiple access allowed + * for requested module + * @param module module type + module id + * @return true if allowed, otherwise - false + */ + virtual bool IsMultipleAccessAllowed(const ModuleUid& module) const = 0; + + /** + * @brief GetDriverLocationFromSeatLocationCapability retrieves the driver's + * location from seat location capabilities + * @return Grid of driver's location + */ + virtual const Grid GetDriverLocationFromSeatLocationCapability() const = 0; + + /** + * @brief IsSeatLocationCapabilityProvided checks whether all necessary + * parameters are provided in seat location capabilities + * @return true if provided, otherwise - false + */ + virtual bool IsSeatLocationCapabilityProvided() const = 0; + + /** + * @brief GetModuleIdForSeatLocation returns the moduleId if request from + * mobile contains the id parameter and doesn't contain the moduleId + * parameter. If the vehicle support at least one seat control, seat control + * capability includes at least two items. SupportedSeat id shall be converted + * to the moduleId according to capabilities: 1st item from capabilities for + * driver’s seat. 2nd item for front passenger’s seat. + * @param id supported seat id + */ + virtual const std::string GetModuleIdForSeatLocation( + mobile_apis::SupportedSeat::eType id) const = 0; + + virtual ~RCCapabilitiesManager() {} +}; + +} // namespace rc_rpc_plugin +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_RC_CAPABILITIES_MANAGER_H_ diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_capabilities_manager_impl.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_capabilities_manager_impl.h new file mode 100644 index 00000000000..844647940f0 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_capabilities_manager_impl.h @@ -0,0 +1,200 @@ +/* + Copyright (c) 2019, 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_CAPABILITIES_MANAGER_IMPL_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_RC_CAPABILITIES_MANAGER_IMPL_H_ +#include "application_manager/application_manager.h" +#include "rc_rpc_plugin/rc_capabilities_manager.h" + +namespace rc_rpc_plugin { +class RCCapabilitiesManagerImpl : public RCCapabilitiesManager { + public: + RCCapabilitiesManagerImpl( + application_manager::HMICapabilities& hmi_capabilities); + + bool CheckIfButtonExistInRCCaps( + const mobile_apis::ButtonName::eType button) const FINAL; + + bool CheckButtonName(const std::string& module_type, + const std::string& button_name) const FINAL; + + bool CheckIfModuleExistsInCapabilities(const ModuleUid& module) const FINAL; + + ModuleTypeCapability GetModuleDataCapabilities( + const smart_objects::SmartObject& module_data, + const std::string& module_id) const FINAL; + + const smart_objects::SmartObject& ControlDataForType( + const smart_objects::SmartObject& module_data, + const std::string& module_type) const FINAL; + + bool AreReadOnlyParamsPresent( + const smart_objects::SmartObject& module_data, + const std::string& module_type, + ModuleTypeCapability& module_data_capabilities) const FINAL; + + bool AreAllParamsReadOnly(const smart_objects::SmartObject& module_data, + const std::string& module_type) const FINAL; + + const std::string GetDefaultModuleIdFromCapabilities( + const std::string& module_type) const FINAL; + + const std::vector GetResources() const FINAL; + + Grid GetModuleServiceArea(const ModuleUid& module) const FINAL; + + bool IsMultipleAccessAllowed(const ModuleUid& module) const FINAL; + + const Grid GetDriverLocationFromSeatLocationCapability() const FINAL; + + bool IsSeatLocationCapabilityProvided() const FINAL; + + const std::string GetModuleIdForSeatLocation( + mobile_apis::SupportedSeat::eType id) const FINAL; + + private: + const std::map GetLightCapabilitiesMapping() const; + + const std::map GetModuleDataToCapabilitiesMapping() + const; + + /** + * @brief Check whether the exists light data related to correspondent + * capabilities + * @param capabilities smart object of capabilities + * @param control_data smart object of control_data + * @return pair of state and capability status - ModuleTypeCapability + */ + ModuleTypeCapability GetControlDataCapabilities( + const smart_objects::SmartObject& capabilities, + const smart_objects::SmartObject& control_data) const; + + /** + * @brief Check whether the parameter exist in capabilities + * @param capabilities 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 the parameter exists in capabilities, + * otherwise - missedParam + */ + capabilitiesStatus GetItemCapability( + const smart_objects::SmartObject& capabilities, + const std::map& mapping, + const std::string& request_parameter, + const mobile_apis::Result::eType& switched_off_result) const; + + /** + * @brief Check whether the capabilities for light are allowed + * @param capabilities smart object of capabilities + * @param control_data smart object of control_data + * @return pair of state and capability status - ModuleTypeCapability + */ + ModuleTypeCapability GetLightDataCapabilities( + const smart_objects::SmartObject& capabilities, + const smart_objects::SmartObject& control_data) const; + + /** + * @brief Check whether the light name exists in capabilities + * @param capabilities_status smart object of capabilities_status + * @param light_data smart object of light_data + * @return pair of state and capability status - ModuleTypeCapability + */ + ModuleTypeCapability GetLightNameCapabilities( + const smart_objects::SmartObject& capabilities_status, + const smart_objects::SmartObject& light_data) const; + + ModuleTypeCapability GetRadioBandByCapabilities( + const smart_objects::SmartObject& capabilities_status, + const smart_objects::SmartObject& request_parameter) const; + + bool CheckReadOnlyParamsForAudio( + const smart_objects::SmartObject& module_type_params) const; + + bool CheckReadOnlyParamsForLight( + const smart_objects::SmartObject& module_type_params) const; + + smart_objects::SmartObject GetCapabilitiesByModuleIdFromArray( + const smart_objects::SmartObject& module_data_capabilities, + const std::string& module_id) const; + + const bool CheckModuleIdWithCapabilities( + const smart_objects::SmartObject& rc_capabilities, + const ModuleUid& module) const; + + const bool CheckModuleIdWithCapabilitiesArrays( + const smart_objects::SmartObject& control_capabilities, + const std::string& module_id) const; + + const bool CheckModuleIdWithCapabilitiesStructure( + const smart_objects::SmartObject& control_capabilities, + const std::string& module_id) const; + + const std::string GetDefaultModuleIdFromCapabilitiesStructure( + const smart_objects::SmartObject& control_capabilities, + const std::string& module_type) const; + + const std::string GetDefaultModuleIdFromCapabilitiesArray( + const smart_objects::SmartObject& control_capabilities, + const std::string& module_type) const; + + const std::vector GetCapabilitiesList() const; + + const std::function + GetCapabilitiesToModuleTypeMapping() const; + + void GetResourcesFromCapabilitiesStructure( + const smart_objects::SmartObject& control_capabilities, + const std::string& capabitity_key, + std::vector& out_resources) const; + + void GetResourcesFromCapabilitiesArray( + const smart_objects::SmartObject& control_capabilities, + const std::string& capability_key, + std::vector& out_resources) const; + + Grid GetModuleServiceAreaFromControlCapability( + const smart_objects::SmartObject& control_capabilities) const; + + Grid GetModuleLocationFromControlCapability( + const smart_objects::SmartObject& control_capabilities) const; + + bool IsMultipleAccessAllowedInControlCaps( + const smart_objects::SmartObject& control_capabilities) const; + + Grid GetWholeVehicleArea() const; + + application_manager::HMICapabilities& hmi_capabilities_; +}; + +} // namespace rc_rpc_plugin +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_RC_CAPABILITIES_MANAGER_IMPL_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 a9cf0e2a218..aa01b608b40 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 @@ -34,15 +34,14 @@ #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" #include "application_manager/application_manager.h" #include "application_manager/command_factory.h" -#include "application_manager/rpc_service.h" #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 "application_manager/rpc_service.h" #include "rc_rpc_plugin/commands/rc_command_params.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 { @@ -64,10 +63,10 @@ class RCCommandFactory : public application_manager::CommandFactory { app_mngr::commands::Command::CommandSource source) OVERRIDE; /** - * @param int32_t command id - * @param CommandSource source - * @return return true if command can be create, else return false - **/ + * @param int32_t command id + * @param CommandSource source + * @return return true if command can be create, else return false + **/ virtual bool IsAbleToProcess( const int32_t, const application_manager::commands::Command::CommandSource) diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_consent_manager.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_consent_manager.h new file mode 100644 index 00000000000..cde7928a144 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_consent_manager.h @@ -0,0 +1,91 @@ +/* + * Copyright (c) 2019, 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_CONSENT_MANAGER_H +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_CONSENT_MANAGER_H + +#include + +#include "rc_rpc_types.h" + +namespace ns_smart_device_link { +namespace ns_smart_objects { +class SmartObject; +} // namespace ns_smart_objects +} // namespace ns_smart_device_link + +namespace rc_rpc_plugin { + +class RCConsentManager { + public: + /** + * @brief Saves consents (is_consented + date_of_consent) for module resources + * (module_type + module_id) for specified application + * @param policy_app_id Application id which module consents should be saved + * @param mac_address Device mac address + * @param module_consents - Module resources consents + */ + virtual void SaveModuleConsents( + const std::string& policy_app_id, + const std::string& mac_address, + const rc_rpc_types::ModuleIdConsentVector& module_consents) = 0; + + /** + * @brief Retrieves saved consent for specified module resource (module_type + * + module_id) + * @param app_id Application which related to specified module resource + * @param mac_address Device mac address + * @param module_id Module resource (module_type + module_id) + * @return Module consent state + */ + virtual rc_rpc_plugin::rc_rpc_types::ModuleConsent GetModuleConsent( + const std::string& app_id, + const std::string& mac_address, + const rc_rpc_types::ModuleUid& module_id) const = 0; + + /** + * @brief Remove modules consents from LastState if they exist + */ + virtual void RemoveAllConsents() = 0; + + /** + * @brief Remove all expired module consents from LastState + * if they exist + */ + virtual void RemoveExpiredConsents() = 0; + + virtual ~RCConsentManager() {} +}; + +} // namespace rc_rpc_plugin + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_CONSENT_MANAGER_H diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_consent_manager_impl.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_consent_manager_impl.h new file mode 100644 index 00000000000..b3c6a0b129c --- /dev/null +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_consent_manager_impl.h @@ -0,0 +1,171 @@ +/* + * Copyright (c) 2019, 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_CONSENT_MANAGER_IMPL_H +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_CONSENT_MANAGER_IMPL_H + +#include "rc_consent_manager.h" +#include "resumption/last_state.h" +#include "utils/lock.h" + +namespace Json { +class Value; +} // namespace Json + +namespace rc_rpc_plugin { + +class RCConsentManagerImpl : public RCConsentManager { + public: + RCConsentManagerImpl( + resumption::LastState& last_state, + application_manager::ApplicationManager& application_manager, + const uint32_t period_of_consent_expired); + + void SaveModuleConsents( + const std::string& policy_app_id, + const std::string& mac_address, + const rc_rpc_types::ModuleIdConsentVector& module_consents) OVERRIDE; + + rc_rpc_types::ModuleConsent GetModuleConsent( + const std::string& app_id, + const std::string& mac_address, + const rc_rpc_types::ModuleUid& module_id) const OVERRIDE; + + void RemoveExpiredConsents() OVERRIDE; + + void RemoveAllConsents() OVERRIDE; + + ~RCConsentManagerImpl() OVERRIDE; + + private: + /** + * @brief Saves module consents for specified application + * @param app_module_consents Application consents for which new + * consents should be added or existing ones should be overwritten + * @param consent_to_save module consents which should be saved + */ + void SaveAppModuleConsent( + Json::Value& app_module_consents, + const rc_rpc_types::ModuleIdConsent& consent_to_save); + + /** + * @brief Checks if module consent is expired + * @param module_consent Module consent + * @return ModuleConsentState + */ + rc_rpc_types::ModuleConsentState CheckModuleConsentState( + const Json::Value& module_consent) const; + + /** + * @brief Removes devices expired consents + * @param device Device section in AppConsensts section of LastState in Json + */ + void RemoveDeviceExpiredConsents(Json::Value& device); + + /** + * @brief Remove expired module consents which are related to specified + * application + * @param app_consents Application consents + */ + void RemoveAppExpiredConsents(Json::Value& app_consents); + + /** + * @brief Remove expired module consents which are related to specified + * module type + * @param module_consents Module consents wich should be checked for expired + * consents + */ + void RemoveModuleExpiredConsents(Json::Value& module_consents); + + /** + * @brief Get Remote Control section of LastState. + * In case the section is absent, will be appended a new empty section. + * @return Remote Control section of LastState in Json + */ + Json::Value& GetRemoteControlDataOrAppend() const; + + /** + * @brief Gets Device applications section for specified device mac adress + * In case the section is absent, will be appended a new empty section. + * @param mac_aress Device MAC adress + * @return Device applications section of LastState in Json + */ + Json::Value& GetDeviceApplicationsOrAppend( + const std::string& mac_address) const; + + /** + * @brief Get AppConsentsList section of LastState for specified application. + * In case the consent list is absent, will be appended a new empty section. + * @param policy_app_id Application policy ID + * @param mac_address Device MAC address + * @return AppConsentsList of LastState in Json + */ + Json::Value& GetAppConsentsListOrAppend(const std::string& policy_app_id, + const std::string& mac_address) const; + + /** + * @brief Get Application consents section of Remote Control section of + * LastState with all consents for all applications. In case if this section + * is absent, will be created a new empty section + * @return AppConsents section of RemoteControl section of LastState in Jason + */ + Json::Value& GetAppsConsentsOrAppend() const; + + /** + * @brief Get all module resource consents for specified application and + * module type. In case if section with specified module type consents is + * absent, will be created a new empty section + * @param policy_app_id Application id which contains specified module type + * @param mac_adress MAC address of mobile device that needs user consent for + * acquiring resource + * @param module_type Module type with consents + */ + Json::Value& GetModuleTypeConsentsOrAppend( + const std::string& policy_app_id, + const std::string& mac_address, + const std::string& module_type) const; + + private: + application_manager::ApplicationManager& app_manager_; + resumption::LastState& last_state_; + const uint32_t period_of_consent_expired_; + mutable sync_primitives::Lock dictionary_control_lock_; + mutable sync_primitives::Lock remote_control_lock_; + mutable sync_primitives::Lock device_applications_lock_; + mutable sync_primitives::Lock applications_lock_; + mutable sync_primitives::Lock app_consents_lock_; + mutable sync_primitives::Lock module_consents_lock_; +}; + +} // namespace rc_rpc_plugin + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_CONSENT_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 index cf3c6cd5e44..eed860fc7fb 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 @@ -37,6 +37,7 @@ #include #include "application_manager/application.h" #include "rc_rpc_plugin/rc_app_extension.h" +#include "rc_rpc_plugin/rc_rpc_types.h" namespace rc_rpc_plugin { class RCRPCPlugin; @@ -49,26 +50,26 @@ class RCRPCPlugin; 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 - */ + * @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 GetModuleTypeToDataMapping get mapping of module type enum naming to - * actual module capabilities key - * @return module mapping from enum naming to capabilities key - */ + * @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 + * @brief GetModuleTypesList get list of all known module types + * @return vector contains all known module types */ - static const std::vector GetModulesList(); + static const std::vector GetModuleTypesList(); /** * @brief GetRCExtension extract RC extension from application @@ -80,17 +81,95 @@ class RCHelpers { application_manager::Application& app); static smart_objects::SmartObjectSPtr CreateUnsubscribeRequestToHMI( - const std::string& module_type, const uint32_t correlation_id); + const ModuleUid& module, const uint32_t correlation_id); + + static std::vector + AppsSubscribedToModule(application_manager::ApplicationManager& app_mngr, + const ModuleUid& module); static std::vector AppsSubscribedToModuleType(application_manager::ApplicationManager& app_mngr, const std::string& module_type); typedef std::map > AppsModules; - static AppsModules GetApplicationsAllowedModules( + std::vector > + AppsModuleTypes; + + static AppsModuleTypes GetApplicationsAllowedModuleTypes( application_manager::ApplicationManager& app_mngr); + + typedef std::map ButtonsMap; + + static const std::vector buttons_climate(); + + static const std::vector buttons_radio(); + + static const ButtonsMap buttons_map(); + + static std::vector GetModuleReadOnlyParams( + const std::string& module_type); + + /** + * @brief Combines module ids and alloweds for these ids and fills vector with + * ModuleConsents + * @param module_type Module type as string + * @param module_ids Modules ids which needed consents from driver + * @param allowed Consents for modules + */ + static rc_rpc_types::ModuleIdConsentVector FillModuleConsents( + const std::string& module_type, + const std::vector& module_ids, + const std::vector allowed); + + /** + * @brief Retrieves module ids from SmartObject. + * @param moduleIds Smartobject which contains collection of module ids + * @return Collection of module ids + */ + static std::vector RetrieveModuleIds( + const smart_objects::SmartObject& moduleIds); + + /** + * @brief Retrieves module ids consents from SmartObject. + * @param moduleIds Smartobject which contains collection of module ids + * consents + * @return Collection of module ids consents. + */ + static std::vector RetrieveModuleConsents( + const smart_objects::SmartObject& consents); + + /** + * @brief RemoveRedundantGPSDataFromVIDataMsg removes redundant GPS data + * params from interior vehicle data response message if one contains radio + * station location data + * @param msg_params Params of the interior vehicle data response message + */ + static void RemoveRedundantGPSDataFromIVDataMsg( + smart_objects::SmartObject& msg_params); + + /** + * @brief MergeModuleData 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 + */ + static smart_objects::SmartObject MergeModuleData( + const smart_objects::SmartObject& data1, + const smart_objects::SmartObject& data2); + + /** + * @brief MergeArray merge two arrays if their elements contain an `id` + * parameter + * @param data1 - initial data + * @param data2 - updated data + * @return updated data1 with any values in data2 if the arrays can be merged, + * otherwise data2 + */ + static smart_objects::SmartObject MergeArray( + const smart_objects::SmartObject& data1, + const smart_objects::SmartObject& data2); }; -} // rc_rpc_plugin +} // namespace 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/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 18014e6270f..5ee2e0725c6 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 @@ -46,10 +46,43 @@ const char khmiSettingsControlCapabilities[] = "hmiSettingsControlCapabilities"; const char kseatControlCapabilities[] = "seatControlCapabilities"; // RemoteControlCapabilities constants -const char kRadioControlData[] = "radioControlData"; -const char kClimateControlData[] = "climateControlData"; +const char kServiceArea[] = "serviceArea"; +const char kLocation[] = "location"; +const char kCol[] = "col"; +const char kRow[] = "row"; +const char kLevel[] = "level"; +const char kColspan[] = "colspan"; +const char kRowspan[] = "rowspan"; +const char kLevelspan[] = "levelspan"; + +// SeatLocationCapability constants +const char kCols[] = "columns"; +const char kRows[] = "rows"; +const char kLevels[] = "levels"; +const char kSeats[] = "seats"; +const char kGrid[] = "grid"; +// SeatLocationCapability constants + +const char kAllowMultipleAccess[] = "allowMultipleAccess"; + const char kSupportedLights[] = "supportedLights"; +// ClimateControlCapabilities +const char kFanSpeedAvailable[] = "fanSpeedAvailable"; +const char kCurrentTemperatureAvailable[] = "currentTemperatureAvailable"; +const char kDesiredTemperatureAvailable[] = "desiredTemperatureAvailable"; +const char kAcEnableAvailable[] = "acEnableAvailable"; +const char kCirculateAirEnableAvailable[] = "circulateAirEnableAvailable"; +const char kAutoModeEnableAvailable[] = "autoModeEnableAvailable"; +const char kDefrostZoneAvailable[] = "defrostZoneAvailable"; +const char kDualModeEnableAvailable[] = "dualModeEnableAvailable"; +const char kAcMaxEnableAvailable[] = "acMaxEnableAvailable"; +const char kVentilationModeAvailable[] = "ventilationModeAvailable"; +const char kHeatedSteeringWheelAvailable[] = "heatedSteeringWheelAvailable"; +const char kHeatedWindshieldAvailable[] = "heatedWindshieldAvailable"; +const char kHeatedMirrorsAvailable[] = "heatedMirrorsAvailable"; +const char kHeatedRearWindowAvailable[] = "heatedRearWindowAvailable"; + // LightControlCapabilities const char kName[] = "name"; const char kStatusAvailable[] = "statusAvailable"; @@ -57,8 +90,51 @@ const char kDensityAvailable[] = "densityAvailable"; const char kRGBColorSpaceAvailable[] = "rgbColorSpaceAvailable"; // RadioControlCapabilities +const char kRadioBandAvailable[] = "radioBandAvailable"; +const char kRadioFrequencyAvailable[] = "radioFrequencyAvailable"; +const char kRdsDataAvailable[] = "rdsDataAvailable"; +const char kAvailableHDsAvailable[] = "availableHDsAvailable"; +const char kHdRadioEnableAvailable[] = "hdRadioEnableAvailable"; +const char kSignalStrengthAvailable[] = "signalStrengthAvailable"; +const char kSignalChangeThresholdAvailable[] = "signalChangeThresholdAvailable"; +const char kRadioEnableAvailable[] = "radioEnableAvailable"; +const char kStateAvailable[] = "stateAvailable"; +const char kSisDataAvailable[] = "sisDataAvailable"; + const char kSiriusxmRadioAvailable[] = "siriusxmRadioAvailable"; -} // strings + +// SeatControlCapabilities +const char kHeatingEnabledAvailable[] = "heatingEnabledAvailable"; +const char kCoolingEnabledAvailable[] = "coolingEnabledAvailable"; +const char kHeatingLevelAvailable[] = "heatingLevelAvailable"; +const char kCoolingLevelAvailable[] = "coolingLevelAvailable"; +const char kHorizontalPositionAvailable[] = "horizontalPositionAvailable"; +const char kVerticalPositionAvailable[] = "verticalPositionAvailable"; +const char kFrontVerticalPositionAvailable[] = "frontVerticalPositionAvailable"; +const char kBackVerticalPositionAvailable[] = "backVerticalPositionAvailable"; +const char kBackTiltAngleAvailable[] = "backTiltAngleAvailable"; +const char kHeadSupportHorizontalPositionAvailable[] = + "headSupportHorizontalPositionAvailable"; +const char kHeadSupportVerticalPositionAvailable[] = + "headSupportVerticalPositionAvailable"; +const char kMassageEnabledAvailable[] = "massageEnabledAvailable"; +const char kMassageModeAvailable[] = "massageModeAvailable"; +const char kMassageCushionFirmnessAvailable[] = + "massageCushionFirmnessAvailable"; +const char kMemoryAvailable[] = "memoryAvailable"; + +// AudioControlCapabilities +const char kSourceAvailable[] = "sourceAvailable"; +const char kKeepContextAvailable[] = "keepContextAvailable"; +const char kVolumeAvailable[] = "volumeAvailable"; +const char kEqualizerAvailable[] = "equalizerAvailable"; + +// HmiSettingsCapabilities +const char kDistanceUnitAvailable[] = "distanceUnitAvailable"; +const char kTemperatureUnitAvailable[] = "temperatureUnitAvailable"; +const char kDisplayModeUnitAvailable[] = "displayModeUnitAvailable"; + +} // namespace strings namespace result_codes { const char kSuccess[] = "SUCCESS"; @@ -84,7 +160,7 @@ const char kWrongLanguage[] = "WRONG_LANGUAGE"; const char kGenericError[] = "GENERIC_ERROR"; const char kUserDisallowed[] = "USER_DISALLOWED"; const char kReadOnly[] = "READ_ONLY"; -} // result_codes +} // namespace result_codes namespace json_keys { const char kParams[] = "params"; @@ -100,12 +176,26 @@ const char kMessage[] = "message"; const char kData[] = "data"; const char kAppId[] = "appID"; const char kCode[] = "code"; -} // json_keys +} // namespace json_keys namespace message_params { const char kName[] = "name"; const char kId[] = "id"; +// RCConsentManager, ResumptionCtrl, GetInteriorVehicleDataConsent request +const char kModuleId[] = "moduleId"; +const char kModuleInfo[] = "moduleInfo"; +const char kAppConsents[] = "appConsents"; +const char kAppConsentList[] = "appConsentsList"; +const char kConsent[] = "consent"; +const char kConsentDate[] = "consentDate"; +const char kModuleConsents[] = "moduleConsents"; +const char kAppId[] = "appId"; +const char kModuleIds[] = "moduleIds"; +const char kMacAddress[] = "macAddress"; +const char kApplications[] = "applications"; +// RCConsentManager, ResumptionCtrl, GetInteriorVehicleDataConsent request + // SetInteriorVehicleData request const char kModuleData[] = "moduleData"; // SetInteriorVehicleData request @@ -152,6 +242,8 @@ const char kBand[] = "band"; const char kRdsData[] = "rdsData"; const char kHdRadioEnable[] = "hdRadioEnable"; const char kAvailableHDs[] = "availableHDs"; +const char kAvailableHdChannels[] = "availableHdChannels"; +const char kAvailableHdChannelsAvailable[] = "availableHdChannelsAvailable"; const char kHdChannel[] = "hdChannel"; const char kSignalStrength[] = "signalStrength"; const char kSignalChangeThreshold[] = "signalChangeThreshold"; @@ -176,8 +268,27 @@ const char kHeatedSteeringWheelEnable[] = "heatedSteeringWheelEnable"; const char kHeatedWindshieldEnable[] = "heatedWindshieldEnable"; const char kHeatedRearWindowEnable[] = "heatedRearWindowEnable"; const char kHeatedMirrorsEnable[] = "heatedMirrorsEnable"; +const char kClimateEnable[] = "climateEnable"; +const char kClimateEnableAvailable[] = "climateEnableAvailable"; // ClimateControlData struct +// SeatControlData +const char kHeatingEnabled[] = "heatingEnabled"; +const char kCoolingEnabled[] = "coolingEnabled"; +const char kHeatingLevele[] = "heatingLevel"; +const char kCoolingLevel[] = "coolingLevel"; +const char kHorizontalPosition[] = "horizontalPosition"; +const char kVerticalPosition[] = "verticalPosition"; +const char kFrontVerticalPosition[] = "frontVerticalPosition"; +const char kBackVerticalPosition[] = "backVerticalPosition"; +const char kBackTiltAngle[] = "backTiltAngle"; +const char kHeadSupportHorizontalPosition[] = "headSupportHorizontalPosition"; +const char kHeadSupportVerticalPosition[] = "headSupportVerticalPosition"; +const char kMassageEnabled[] = "massageEnabled"; +const char kMassageMode[] = "massageMode"; +const char kMassageCushionFirmness[] = "massageCushionFirmness"; +const char kMemory[] = "memory"; + // LightControlData const char kLightState[] = "lightState"; const char kLightStatus[] = "status"; @@ -186,10 +297,15 @@ const char kLightColor[] = "color"; // AudioControlData const char kSource[] = "source"; +const char kVolume[] = "volume"; const char kKeepContext[] = "keepContext"; const char kEqualizerSettings[] = "equalizerSettings"; const char kChannelName[] = "channelName"; +// HmiSettingsControlData +const char kDistanceUnit[] = "distanceUnit"; +const char kDisplayMode[] = "displayMode"; + // ModuleData struct const char kRadioControlData[] = "radioControlData"; const char kClimateControlData[] = "climateControlData"; @@ -203,6 +319,15 @@ const char kHMIAppID[] = "appID"; const char kHmiLevel[] = "hmiLevel"; const char kSysContext[] = "systemContext"; const char kAudioState[] = "audioStreamingState"; + +// Grid struct +const char kCol[] = "col"; +const char kRow[] = "row"; +const char kLevel[] = "level"; +const char kColspan[] = "colspan"; +const char kRowspan[] = "rowspan"; +const char kLevelspan[] = "levelspan"; + } // namespace message_params namespace enums_value { @@ -274,6 +399,6 @@ const char kAskDriver[] = "ASK_DRIVER"; } // namespace enums_value -} // namespace remote_control +} // namespace rc_rpc_plugin #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 ae88ed9cc03..1225feb67f8 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 @@ -35,11 +35,17 @@ #include -#include "application_manager/plugin_manager/rpc_plugin.h" #include "application_manager/command_factory.h" -#include "rc_rpc_plugin/resource_allocation_manager.h" +#include "application_manager/plugin_manager/rpc_plugin.h" #include "rc_rpc_plugin/interior_data_cache.h" #include "rc_rpc_plugin/interior_data_manager.h" +#include "rc_rpc_plugin/rc_capabilities_manager.h" +#include "rc_rpc_plugin/rc_consent_manager.h" +#include "rc_rpc_plugin/resource_allocation_manager.h" + +namespace resumption { +class LastState; +} namespace rc_rpc_plugin { namespace plugins = application_manager::plugin_manager; @@ -48,22 +54,23 @@ namespace app_mngr = application_manager; class RCRPCPlugin : public plugins::RPCPlugin { public: /** - * @brief Command initialization function - * @param app_manager ApplicationManager - * @param rpc_service RPCService - * @param hmi_capabilities HMICapabilities - * @param policy_handler PolicyHandlerInterface - * @return true in case initialization was succesful, false otherwise. - **/ + * @brief Command initialization function + * @param app_manager ApplicationManager + * @param rpc_service RPCService + * @param hmi_capabilities HMICapabilities + * @param policy_handler PolicyHandlerInterface + * @return true in case initialization was succesful, false otherwise. + **/ bool Init(app_mngr::ApplicationManager& app_manager, app_mngr::rpc_service::RPCService& rpc_service, app_mngr::HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handler) OVERRIDE; + policy::PolicyHandlerInterface& policy_handler, + resumption::LastState& last_state) OVERRIDE; /** - * @param int32_t command id - * @param CommandSource source - * @return return true if command can be create, else return false - **/ + * @param int32_t command id + * @param CommandSource source + * @return return true if command can be create, else return false + **/ bool IsAbleToProcess( const int32_t function_id, const app_mngr::commands::Command::CommandSource message_source) OVERRIDE; @@ -85,10 +92,10 @@ class RCRPCPlugin : public plugins::RPCPlugin { */ void OnPolicyEvent(app_mngr::plugin_manager::PolicyEvent event) OVERRIDE; /** - * @brief OnApplicationEvent Notifies modules on certain application events - * @param event Event - * @param application Pointer to application struct - */ + * @brief OnApplicationEvent Notifies modules on certain application events + * @param event Event + * @param application Pointer to application struct + */ void OnApplicationEvent(plugins::ApplicationEvent event, app_mngr::ApplicationSharedPtr application) OVERRIDE; @@ -101,13 +108,16 @@ class RCRPCPlugin : public plugins::RPCPlugin { private: application_manager::rpc_service::RPCService* rpc_service_; application_manager::ApplicationManager* app_mngr_; + std::unique_ptr rc_consent_manager_; std::unique_ptr command_factory_; std::unique_ptr resource_allocation_manager_; std::unique_ptr interior_data_cache_; std::unique_ptr interior_data_manager_; + std::unique_ptr rc_capabilities_manager_; }; } // namespace rc_rpc_plugin extern "C" application_manager::plugin_manager::RPCPlugin* Create(); +extern "C" void Delete(application_manager::plugin_manager::RPCPlugin* data); #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/rc_rpc_types.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_rpc_types.h new file mode 100644 index 00000000000..3698728aa60 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_rpc_types.h @@ -0,0 +1,91 @@ +/* + * Copyright (c) 2019, 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_TYPES_H +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_TYPES_H + +#include +#include +#include +#include + +namespace resumption { +class LastState; +} // namespace resumption + +namespace application_manager { +class ApplicationManager; +} // namespace application_manager + +namespace rc_rpc_plugin { +namespace rc_rpc_types { +/** + * @brief Module resource (module_type(first) + module_id(second)) + */ +typedef std::pair ModuleUid; + +/** + * @brief Module consent enum. + */ +enum class ModuleConsent { + NOT_EXISTS = 0, /**< Consent is absent for specified module resource */ + CONSENTED, /**< Module resource is consented */ + NOT_CONSENTED /**< Module resource isn't consented */ +}; + +enum class ModuleConsentState { + NOT_EXISTS = 0, /**< Consent is absent for specified module resource */ + EXPIRED, /**< Module resource is expired */ + ACTIVE /**< Module resource isn't expired */ +}; + +/** + * @brief Module consent + * @param module_id - Module resource for consent + * @param consent - Is module resource consented by driver + * @param date_of_consent - Date, when module resource has been consented (in + * seconds [UNIX time]) + */ +struct ModuleIdConsent { + ModuleUid module_id; + ModuleConsent consent; + std::time_t date_of_consent; +}; + +/** + * @brief ModuleIdConsent collection + */ +typedef std::vector ModuleIdConsentVector; +} // namespace rc_rpc_types +} // namespace rc_rpc_plugin + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_TYPES_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 67598b667b2..ee0bd118858 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 @@ -35,8 +35,8 @@ #include #include "utils/macro.h" -#include "interfaces/HMI_API.h" #include "application_manager/plugin_manager/rpc_plugin.h" +#include "interfaces/HMI_API.h" #include "rc_rpc_plugin/rc_app_extension.h" namespace rc_rpc_plugin { @@ -66,58 +66,87 @@ namespace NotificationTrigger { * MODULE_ALLOCATION module allocation/deallocation event */ enum eType { APP_REGISTRATION = 0, MODULE_ALLOCATION, RC_STATE_CHANGING }; -} +} // namespace NotificationTrigger + +/** + * Defines result of releasing specified module type resource. + */ +namespace ResourceReleasedState { +/** + * NOT_ALLOCATED Module's resource is not allocated + * IS_ALLOCATED Module's resource is already allocated by + * different application + * IS_RELEASED Module's resource is released. + */ +enum eType { NOT_ALLOCATED = 0, IS_ALLOCATED, IS_RELEASED }; +} // namespace ResourceReleasedState + +/** + * @brief ModuleUid uniquely identify a module + * moduleType + moduleID + */ +typedef std::pair ModuleUid; /** * @brief Resources defines list of resources */ -typedef std::vector Resources; +typedef std::vector Resources; class ResourceAllocationManager { public: /** * @brief AcquireResource acquires resource by application * @param module_type resource to acquire + * @param module_id uuid of a resource * @param app_id application that acquire resource * @return ALLOWED if resource acquired \ * IN_USE if resource already acquired * ASK_DRIVER if driver confirmation is required */ virtual AcquireResult::eType AcquireResource(const std::string& module_type, + const std::string& module_id, const uint32_t app_id) = 0; /** * @brief SetResourceState changes resource state. Resource must be acquired * beforehand. * @param module_type Resource to change its state + * @param module_id uuid of a resource * @param app_id Application aquired resource before * @param state State to set for resource */ virtual void SetResourceState(const std::string& module_type, + const std::string& module_id, const uint32_t app_id, const ResourceState::eType state) = 0; /** * @brief IsResourceFree check resource state * @param module_type Resource name + * @param module_id uuid of a resource * @return True if free, otherwise - false */ - virtual bool IsResourceFree(const std::string& module_type) const = 0; + virtual bool IsResourceFree(const std::string& module_type, + const std::string& module_id) const = 0; /** * @brief AcquireResource forces acquiring resource by application * @param module_type resource to acquire + * @param module_id uuid of a resource * @param app_id application that acquire resource */ virtual void ForceAcquireResource(const std::string& module_type, + const std::string& module_id, const uint32_t app_id) = 0; /** * @brief OnDriverDisallowed callback for rejecting acquiring resource * @param module_type resource type + * @param module_id uuid of a resource * @param app_id application id */ virtual void OnDriverDisallowed(const std::string& module_type, + const std::string& module_id, const uint32_t app_id) = 0; /** @@ -171,6 +200,42 @@ class ResourceAllocationManager { virtual void set_rc_enabled(const bool value) = 0; + /** + * @brief ReleaseResource Releases resource acquired by application + * @param module_type Module name + * @param module_id uuid of a module + * @param application_id Application id + */ + virtual ResourceReleasedState::eType ReleaseResource( + const std::string& module_type, + const std::string& module_id, + const uint32_t application_id) = 0; + + /** + * @brief SetResourceAquired mark resourse as aquired and process logic of + * changing state of aquired resources + * @param module_type resource name + * @param module_id uuid of a resource + * @param app applicastion that aquire resource + */ + virtual void SetResourceAcquired(const std::string& module_type, + const std::string& module_id, + const uint32_t app_id) = 0; + + /** + * @brief Checks if specific resource is already aquired by specific + * application + * @param moduleUid Module resurce (module type + module ID) + * @param app_id Application ID which try to aquire resource + * @return true In case when resource is already aquired by specific + * application + * @return false In case when isn't aquired by specific + * application + */ + virtual bool IsResourceAlreadyAcquiredByApp( + const rc_rpc_plugin::ModuleUid& moduleUid, + const uint32_t app_id) const = 0; + virtual ~ResourceAllocationManager() {} }; 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 b359ee4d29d..0fd54499125 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 @@ -32,11 +32,12 @@ #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" -#include "utils/macro.h" +#include "rc_rpc_plugin/rc_capabilities_manager.h" +#include "rc_rpc_plugin/resource_allocation_manager.h" #include "utils/lock.h" +#include "utils/macro.h" namespace rc_rpc_plugin { @@ -46,43 +47,52 @@ class ResourceAllocationManagerImpl : public ResourceAllocationManager { public: ResourceAllocationManagerImpl( application_manager::ApplicationManager& app_mngr, - application_manager::rpc_service::RPCService& rpc_service); + application_manager::rpc_service::RPCService& rpc_service, + rc_rpc_plugin::RCCapabilitiesManager& rc_capabilities_manager); ~ResourceAllocationManagerImpl(); /** * @brief AcquireResource forces acquiring resource by application * @param module_type resource to acquire + * @param module_id uuid of a resource * @param app_id application that acquire resourc * @return result of acauiring resources */ AcquireResult::eType AcquireResource(const std::string& module_type, + const std::string& module_id, const uint32_t app_id) OVERRIDE FINAL; /** * @brief ForceAcquireResource forces acquiring resource by application * @param module_type resource to acquire + * @param module_id uuid of a resource * @param app_id application that acquire resource */ void ForceAcquireResource(const std::string& module_type, + const std::string& module_id, const uint32_t app_id) FINAL; /** - * @brief SetResourceState changes resource state. Resource must be acquired - * beforehand. - * @param module_type Resource to change its state - * @param app_id Application aquired resource before - * @param state State to set for resource - */ + * @brief SetResourceState changes resource state. Resource must be acquired + * beforehand. + * @param module_type Resource to change its state + * @param module_id uuid of a resource + * @param app_id Application aquired resource before + * @param state State to set for resource + */ void SetResourceState(const std::string& module_type, + const std::string& module_id, const uint32_t app_id, const ResourceState::eType state) FINAL; /** * @brief IsResourceFree check resource state * @param module_type Resource name + * @param module_id uuid of a resource * @return True if free, otherwise - false */ - bool IsResourceFree(const std::string& module_type) const FINAL; + bool IsResourceFree(const std::string& module_type, + const std::string& module_id) const FINAL; void SetAccessMode( const hmi_apis::Common_RCAccessMode::eType access_mode) FINAL; @@ -90,6 +100,7 @@ class ResourceAllocationManagerImpl : public ResourceAllocationManager { hmi_apis::Common_RCAccessMode::eType GetAccessMode() const FINAL; void OnDriverDisallowed(const std::string& module_type, + const std::string& module_id, const uint32_t app_id) FINAL; /** @@ -118,6 +129,18 @@ class ResourceAllocationManagerImpl : public ResourceAllocationManager { void set_rc_enabled(const bool value) FINAL; + ResourceReleasedState::eType ReleaseResource( + const std::string& module_type, + const std::string& module_id, + const uint32_t application_id) FINAL; + + void SetResourceAcquired(const std::string& module_type, + const std::string& module_id, + const uint32_t app_id) FINAL; + + bool IsResourceAlreadyAcquiredByApp(const rc_rpc_plugin::ModuleUid& moduleUid, + const uint32_t app_id) const FINAL; + private: typedef std::vector Apps; @@ -137,20 +160,23 @@ class ResourceAllocationManagerImpl : public ResourceAllocationManager { * @brief IsModuleTypeRejected check if current resource was rejected by * driver for current application * @param module_type resource to check + * @param module_id uuid of a resource * @param app_id application id * @return true if current resource was rejected by driver for current * application, otherwise - false */ bool IsModuleTypeRejected(const std::string& module_type, + const std::string& module_id, const uint32_t app_id); /** - * @brief ReleaseResource Releases resource acquired by application + * @brief ReleaseModuleType Releases all resources related to + * the corresponding module type acquired by application * @param module_type Module name * @param application_id Application id */ - void ReleaseResource(const std::string& module_type, - const uint32_t application_id); + void ReleaseModuleType(const std::string& module_type, + const uint32_t application_id); /** * @brief GetAcquiredResources Provides resources acquired by particular @@ -160,6 +186,15 @@ class ResourceAllocationManagerImpl : public ResourceAllocationManager { */ Resources GetAcquiredResources(const uint32_t application_id) const; + /** + * @brief GetAcquiredModuleTypes Provides module types acquired by particular + * application currently + * @param application_id Application id + * @return List of acquired module types by specific application + */ + std::set GetAcquiredModuleTypes( + const uint32_t application_id) const; + /** * @brief ProcessApplicationPolicyUpdate Checks if allowed modules list is * changed for registered RC applications and releases in case some modules @@ -175,33 +210,38 @@ class ResourceAllocationManagerImpl : public ResourceAllocationManager { void RemoveAppsSubscriptions(const Apps& apps); /** - * @brief SetResourceAquired mark resourse as aquired and process logic of + * @brief SetResourceFree mark resourse as free and process logic of * changing state of aquired resources * @param module_type resource name + * @param module_id uuid of a resource * @param app applicastion that aquire resource */ - void SetResourceAquired(const std::string& module_type, - const uint32_t app_id); + ResourceReleasedState::eType SetResourceFree(const std::string& module_type, + const std::string& module_id, + const uint32_t app_id); /** - * @brief SetResourceFree mark resourse as free and process logic of - * changing state of aquired resources - * @param module_type resource name - * @param app applicastion that aquire resource + * @brief CheckLocation checks if the user's grid is equal to or is within the + * service area of the module, or user location is driver's seat + * @param module module type + module id + * @return true if the user's grid equals to or is within module service + * area or user location is driver's seat, otherwise - false */ - void SetResourceFree(const std::string& module_type, const uint32_t app_id); + bool IsUserLocationValid(ModuleUid& module, + application_manager::ApplicationSharedPtr app); /** * @brief AllocatedResources contains link between resource and application * owning that resource */ - typedef std::map AllocatedResources; + + typedef std::map AllocatedResources; AllocatedResources allocated_resources_; mutable sync_primitives::Lock allocated_resources_lock_; /** * @brief ResourcesState contains states of ALLOCATED resources */ - typedef std::map ResourcesState; + typedef std::map ResourcesState; ResourcesState resources_state_; mutable sync_primitives::Lock resources_state_lock_; @@ -210,15 +250,16 @@ class ResourceAllocationManagerImpl : public ResourceAllocationManager { * driver for application * application_id : [vector of rejected resources] */ - typedef std::map > RejectedResources; + typedef std::map > RejectedResources; RejectedResources rejected_resources_for_application_; mutable sync_primitives::Lock rejected_resources_for_application_lock_; hmi_apis::Common_RCAccessMode::eType current_access_mode_; application_manager::ApplicationManager& app_mngr_; application_manager::rpc_service::RPCService& rpc_service_; + rc_rpc_plugin::RCCapabilitiesManager& rc_capabilities_manager_; bool is_rc_enabled_; }; -} // rc_rpc_plugin +} // namespace rc_rpc_plugin #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_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 e56f9088bc6..a366aa65fae 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,8 +31,8 @@ */ #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" +#include "rc_rpc_plugin/rc_module_constants.h" namespace rc_rpc_plugin { namespace commands { @@ -53,8 +53,9 @@ 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]; + 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]; 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 0117003f113..c6cf1b0d5a4 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,8 +30,8 @@ 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 "rc_rpc_plugin/rc_module_constants.h" #include "utils/macro.h" namespace rc_rpc_plugin { @@ -54,8 +54,9 @@ void RCOnInteriorVehicleDataNotification::Run() { (*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]; + 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]; 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 91cb6cb7ee7..45b0d135820 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 @@ -31,10 +31,10 @@ */ #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 "rc_rpc_plugin/rc_module_constants.h" +#include "rc_rpc_plugin/rc_rpc_plugin.h" #include "utils/macro.h" namespace rc_rpc_plugin { @@ -59,7 +59,8 @@ RCOnRemoteControlSettingsNotification::RCOnRemoteControlSettingsNotification( params.hmi_capabilities_, params.policy_handler_) , resource_allocation_manager_(params.resource_allocation_manager_) - , interior_data_manager_(params.interior_data_manager_) {} + , interior_data_manager_(params.interior_data_manager_) + , rc_consent_manager_(params.rc_consent_manager_) {} RCOnRemoteControlSettingsNotification:: ~RCOnRemoteControlSettingsNotification() {} @@ -115,7 +116,8 @@ void RCOnRemoteControlSettingsNotification::Run() { message_params::kAccessMode)) { access_mode = static_cast( (*message_)[app_mngr::strings::msg_params] - [message_params::kAccessMode].asUInt()); + [message_params::kAccessMode] + .asUInt()); LOG4CXX_DEBUG( logger_, "Setting up access mode : " << AccessModeToString(access_mode)); @@ -131,6 +133,7 @@ void RCOnRemoteControlSettingsNotification::Run() { DisallowRCFunctionality(); resource_allocation_manager_.ResetAllAllocations(); resource_allocation_manager_.set_rc_enabled(false); + rc_consent_manager_.RemoveAllConsents(); } } diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_set_global_properties_request.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_set_global_properties_request.cc new file mode 100644 index 00000000000..2f203afc2d2 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_set_global_properties_request.cc @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2019, 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 "rc_rpc_plugin/commands/hmi/rc_set_global_properties_request.h" + +namespace rc_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +RCSetGlobalPropertiesRequest::RCSetGlobalPropertiesRequest( + const app_mngr::commands::MessageSharedPtr& message, + const RCCommandParams& params) + : app_mngr::commands::RequestToHMI(message, + params.application_manager_, + params.rpc_service_, + params.hmi_capabilities_, + params.policy_handler_) {} + +void RCSetGlobalPropertiesRequest::Run() { + LOG4CXX_AUTO_TRACE(logger_); + SendRequest(); +} + +RCSetGlobalPropertiesRequest::~RCSetGlobalPropertiesRequest() {} + +} // namespace commands +} // namespace rc_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_set_global_properties_response.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_set_global_properties_response.cc new file mode 100644 index 00000000000..c31314ec210 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_set_global_properties_response.cc @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2019, 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 "rc_rpc_plugin/commands/hmi/rc_set_global_properties_response.h" + +namespace rc_rpc_plugin { +namespace commands { + +RCSetGlobalPropertiesResponse::RCSetGlobalPropertiesResponse( + const app_mngr::commands::MessageSharedPtr& message, + const RCCommandParams& params) + : application_manager::commands::ResponseFromHMI( + message, + params.application_manager_, + params.rpc_service_, + params.hmi_capabilities_, + params.policy_handler_) {} + +void RCSetGlobalPropertiesResponse::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + app_mngr::event_engine::Event event( + hmi_apis::FunctionID::RC_SetGlobalProperties); + event.set_smart_object(*message_); + event.raise(application_manager_.event_dispatcher()); +} + +RCSetGlobalPropertiesResponse::~RCSetGlobalPropertiesResponse() {} +} // namespace commands +} // namespace rc_rpc_plugin 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 5ce047071ce..3adc48dfbfd 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 @@ -31,12 +31,13 @@ */ #include "rc_rpc_plugin/commands/mobile/button_press_request.h" +#include "interfaces/MOBILE_API.h" +#include "json/json.h" +#include "rc_rpc_plugin/rc_helpers.h" #include "rc_rpc_plugin/rc_module_constants.h" #include "smart_objects/enum_schema_item.h" -#include "utils/macro.h" -#include "json/json.h" #include "utils/helpers.h" -#include "interfaces/MOBILE_API.h" +#include "utils/macro.h" namespace rc_rpc_plugin { namespace commands { @@ -46,8 +47,6 @@ using namespace message_params; CREATE_LOGGERPTR_GLOBAL(logger_, "RemoteControlModule") -typedef std::map ButtonsMap; - ButtonPressRequest::ButtonPressRequest( const app_mngr::commands::MessageSharedPtr& message, const RCCommandParams& params) @@ -55,146 +54,44 @@ ButtonPressRequest::ButtonPressRequest( ButtonPressRequest::~ButtonPressRequest() {} -const std::vector buttons_climate() { - std::vector data; - data.push_back(enums_value::kACMax); - data.push_back(enums_value::kAC); - data.push_back(enums_value::kRecirculate); - data.push_back(enums_value::kFanUp); - data.push_back(enums_value::kFanDown); - data.push_back(enums_value::kTempUp); - data.push_back(enums_value::kTempDown); - data.push_back(enums_value::kDefrostMax); - data.push_back(enums_value::kDefrost); - data.push_back(enums_value::kDefrostRear); - data.push_back(enums_value::kUpperVent); - data.push_back(enums_value::kLowerVent); - return data; -} - -const std::vector buttons_radio() { - std::vector data; - data.push_back(enums_value::kVolumeUp); - data.push_back(enums_value::kVolumeDown); - data.push_back(enums_value::kEject); - data.push_back(enums_value::kSource); - data.push_back(enums_value::kShuffle); - data.push_back(enums_value::kRepeat); - return data; -} - -const ButtonsMap buttons_map() { - using namespace mobile_apis; - - ButtonsMap buttons_map; - buttons_map[enums_value::kACMax] = ButtonName::AC_MAX; - buttons_map[enums_value::kAC] = ButtonName::AC; - buttons_map[enums_value::kRecirculate] = ButtonName::RECIRCULATE; - buttons_map[enums_value::kFanUp] = ButtonName::FAN_UP; - buttons_map[enums_value::kFanDown] = ButtonName::FAN_DOWN; - buttons_map[enums_value::kTempUp] = ButtonName::TEMP_UP; - buttons_map[enums_value::kTempDown] = ButtonName::TEMP_DOWN; - buttons_map[enums_value::kDefrostMax] = ButtonName::DEFROST_MAX; - buttons_map[enums_value::kDefrost] = ButtonName::DEFROST; - buttons_map[enums_value::kDefrostRear] = ButtonName::DEFROST_REAR; - buttons_map[enums_value::kUpperVent] = ButtonName::UPPER_VENT; - buttons_map[enums_value::kLowerVent] = ButtonName::LOWER_VENT; - buttons_map[enums_value::kVolumeUp] = ButtonName::VOLUME_UP; - buttons_map[enums_value::kVolumeDown] = ButtonName::VOLUME_DOWN; - buttons_map[enums_value::kEject] = ButtonName::EJECT; - buttons_map[enums_value::kSource] = ButtonName::SOURCE; - buttons_map[enums_value::kShuffle] = ButtonName::SHUFFLE; - buttons_map[enums_value::kRepeat] = ButtonName::REPEAT; - - return buttons_map; -} - -bool CheckIfButtonExistInRCCaps( - const smart_objects::SmartObject& rc_capabilities, - const mobile_apis::ButtonName::eType button) { - if (rc_capabilities.keyExists(strings::kbuttonCapabilities)) { - const smart_objects::SmartObject& button_caps = - rc_capabilities[strings::kbuttonCapabilities]; - auto it = button_caps.asArray()->begin(); - for (; it != button_caps.asArray()->end(); ++it) { - smart_objects::SmartObject& so = *it; - int64_t current_id = so[message_params::kName].asInt(); - if (-1 == current_id) { - // capabilities received from HMI contains enum values - // capabilities loaded from file contains string values - // TODO : unificate capabilities storing - const std::string& bt_name = so[message_params::kName].asString(); - static ButtonsMap btn_map = buttons_map(); - current_id = btn_map[bt_name]; - } - const mobile_apis::ButtonName::eType current_button = - static_cast(current_id); - if (current_button == button) { - LOG4CXX_TRACE(logger_, - "Button id " << current_button - << " exist in capabilities"); - return true; - } - } - } - LOG4CXX_TRACE(logger_, - "Button id " << button << " do not exist in capabilities"); - return false; +std::string ButtonPressRequest::GetButtonName() const { + mobile_apis::ButtonName::eType button_name = + static_cast( + (*message_)[app_mngr::strings::msg_params] + [message_params::kButtonName] + .asUInt()); + const char* str; + const bool ok = ns_smart_device_link::ns_smart_objects::EnumConversionHelper< + mobile_apis::ButtonName::eType>::EnumToCString(button_name, &str); + return ok ? str : "unknown"; } -bool CheckButtonName(const std::string& module_type, - const std::string& button_name, - const smart_objects::SmartObject* rc_capabilities) { - LOG4CXX_AUTO_TRACE(logger_); - if (rc_capabilities == NULL) { - LOG4CXX_ERROR(logger_, "No remote controll capabilities available"); - return false; - } - - if (enums_value::kRadio == module_type) { - if (!helpers::in_range(buttons_radio(), button_name)) { - LOG4CXX_WARN(logger_, - "Trying to acceess climate button with module type radio"); - return false; - } - } - - if (enums_value::kClimate == module_type) { - if (!helpers::in_range(buttons_climate(), button_name)) { - LOG4CXX_WARN(logger_, - "Trying to acceess radio button with module type climate"); - return false; - } +const mobile_apis::ButtonName::eType ButtonPressRequest::GetButtonId() const { + const auto button_name = GetButtonName(); + static RCHelpers::ButtonsMap btn_map = RCHelpers::buttons_map(); + mobile_apis::ButtonName::eType button_id = + mobile_apis::ButtonName::INVALID_ENUM; + if (btn_map.end() != btn_map.find(button_name)) { + button_id = btn_map[button_name]; } - return true; + return button_id; } void ButtonPressRequest::Execute() { LOG4CXX_AUTO_TRACE(logger_); - - const char* button_name; - ns_smart_device_link::ns_smart_objects:: - EnumConversionHelper::EnumToCString( - static_cast( - (*message_)[app_mngr::strings::msg_params] - [message_params::kButtonName].asUInt()), - &button_name); - const std::string module_type = ModuleType(); - static ButtonsMap btn_map = buttons_map(); - mobile_apis::ButtonName::eType button_id = - mobile_apis::ButtonName::INVALID_ENUM; - if (btn_map.end() != btn_map.find(button_name)) { - button_id = btn_map[button_name]; - } - const smart_objects::SmartObject* rc_capabilities = - hmi_capabilities_.rc_capability(); const bool button_name_matches_module_type = - CheckButtonName(module_type, button_name, rc_capabilities); - const bool button_id_exist_in_caps = - rc_capabilities && - CheckIfButtonExistInRCCaps(*rc_capabilities, button_id); + rc_capabilities_manager_.CheckButtonName(module_type, GetButtonName()); + + const std::string module_id = ModuleId(); + const ModuleUid module(module_type, module_id); + const bool is_module_exists = + rc_capabilities_manager_.CheckIfModuleExistsInCapabilities(module); + + const bool button_valid_by_caps = + is_module_exists && + rc_capabilities_manager_.CheckIfButtonExistInRCCaps(GetButtonId()); app_mngr::ApplicationSharedPtr app = application_manager_.application(connection_key()); @@ -202,7 +99,9 @@ void ButtonPressRequest::Execute() { (*message_)[app_mngr::strings::msg_params][app_mngr::strings::app_id] = app->app_id(); - if (button_name_matches_module_type && button_id_exist_in_caps) { + if (button_name_matches_module_type && button_valid_by_caps) { + (*message_)[app_mngr::strings::msg_params][message_params::kModuleId] = + module_id; SendHMIRequest(hmi_apis::FunctionID::Buttons_ButtonPress, &(*message_)[app_mngr::strings::msg_params], true); @@ -213,11 +112,12 @@ void ButtonPressRequest::Execute() { mobile_apis::Result::INVALID_DATA, "Request module type and button name mismatch!"); } else { - LOG4CXX_WARN(logger_, "Requested button is not exists in capabilities!"); + LOG4CXX_WARN(logger_, + "Requested button or module does not exist in capabilities!"); SetResourceState(module_type, ResourceState::FREE); SendResponse(false, mobile_apis::Result::UNSUPPORTED_RESOURCE, - "Requested button is not exists in capabilities!"); + "Requested button or module does not exist in capabilities!"); } } @@ -227,13 +127,15 @@ AcquireResult::eType ButtonPressRequest::AcquireResource( const std::string module_type = ModuleType(); app_mngr::ApplicationSharedPtr app = application_manager_.application(CommandRequestImpl::connection_key()); - return resource_allocation_manager_.AcquireResource(module_type, - app->app_id()); + + return resource_allocation_manager_.AcquireResource( + module_type, ModuleId(), app->app_id()); } -bool ButtonPressRequest::IsResourceFree(const std::string& module_type) const { +bool ButtonPressRequest::IsResourceFree(const std::string& module_type, + const std::string& module_id) const { LOG4CXX_AUTO_TRACE(logger_); - return resource_allocation_manager_.IsResourceFree(module_type); + return resource_allocation_manager_.IsResourceFree(module_type, module_id); } void ButtonPressRequest::SetResourceState(const std::string& module_type, @@ -241,8 +143,9 @@ void ButtonPressRequest::SetResourceState(const std::string& module_type, LOG4CXX_AUTO_TRACE(logger_); app_mngr::ApplicationSharedPtr app = application_manager_.application(CommandRequestImpl::connection_key()); + resource_allocation_manager_.SetResourceState( - module_type, app->app_id(), state); + module_type, ModuleId(), app->app_id(), state); } void ButtonPressRequest::on_event(const app_mngr::event_engine::Event& event) { @@ -269,22 +172,64 @@ void ButtonPressRequest::on_event(const app_mngr::event_engine::Event& event) { result = false; result_code = mobile_apis::Result::GENERIC_ERROR; } + + const std::string module_type = ModuleType(); + const std::string module_id = ModuleId(); + + const rc_rpc_types::ModuleUid resource{module_type, module_id}; + auto app = application_manager_.application(connection_key()); + + if (!app) { + LOG4CXX_ERROR(logger_, "NULL pointer."); + SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED, ""); + return; + } + + const auto app_id = app->app_id(); + + bool is_resource_acquired = false; + + if (result && !resource_allocation_manager_.IsResourceAlreadyAcquiredByApp( + resource, app_id)) { + resource_allocation_manager_.SetResourceAcquired( + module_type, module_id, app_id); + + is_resource_acquired = true; + } + std::string response_info; GetInfo(message, response_info); - SetResourceState(ModuleType(), ResourceState::FREE); SendResponse(result, result_code, response_info.c_str()); + + if (is_resource_acquired) { + resource_allocation_manager_.SendOnRCStatusNotifications( + NotificationTrigger::MODULE_ALLOCATION, + std::shared_ptr()); + } } -std::string ButtonPressRequest::ModuleType() { - mobile_apis::ModuleType::eType module_type = static_cast< - mobile_apis::ModuleType::eType>( - (*message_)[app_mngr::strings::msg_params][message_params::kModuleType] - .asUInt()); +std::string ButtonPressRequest::ModuleType() const { + mobile_apis::ModuleType::eType module_type = + static_cast( + (*message_)[app_mngr::strings::msg_params] + [message_params::kModuleType] + .asUInt()); const char* str; const bool ok = ns_smart_device_link::ns_smart_objects::EnumConversionHelper< mobile_apis::ModuleType::eType>::EnumToCString(module_type, &str); return ok ? str : "unknown"; } +std::string ButtonPressRequest::ModuleId() const { + LOG4CXX_AUTO_TRACE(logger_); + auto msg_params = (*message_)[app_mngr::strings::msg_params]; + if (msg_params.keyExists(message_params::kModuleId)) { + return msg_params[message_params::kModuleId].asString(); + } + const std::string module_id = + rc_capabilities_manager_.GetDefaultModuleIdFromCapabilities(ModuleType()); + return module_id; +} + } // namespace commands } // namespace rc_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/get_interior_vehicle_data_consent_request.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/get_interior_vehicle_data_consent_request.cc new file mode 100644 index 00000000000..fd661afd5f6 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/get_interior_vehicle_data_consent_request.cc @@ -0,0 +1,472 @@ +/* + * Copyright (c) 2019, 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 + +#include "rc_rpc_plugin/commands/mobile/get_interior_vehicle_data_consent_request.h" +#include "rc_rpc_plugin/rc_helpers.h" +#include "rc_rpc_plugin/rc_module_constants.h" +#include "rc_rpc_plugin/rc_rpc_types.h" +#include "smart_objects/enum_schema_item.h" + +namespace rc_rpc_plugin { +namespace app_mngr = application_manager; +namespace commands { + +GetInteriorVehicleDataConsentRequest::GetInteriorVehicleDataConsentRequest( + const application_manager::commands::MessageSharedPtr& message, + const RCCommandParams& params) + : RCCommandRequest(message, params) {} + +void GetInteriorVehicleDataConsentRequest::Execute() { + LOG4CXX_AUTO_TRACE(logger_); + + auto& msg_params = (*message_)[app_mngr::strings::msg_params]; + + const bool module_ids_exists = + msg_params.keyExists(message_params::kModuleIds); + if (!module_ids_exists) { + SendResponse(false, + mobile_apis::Result::INVALID_DATA, + "ModuleIds collection is absent in request message"); + return; + } + + if (msg_params[message_params::kModuleIds].empty()) { + LOG4CXX_DEBUG(logger_, + "ModuleIds collection is empty. Will be add default " + "module_id from capabilities"); + + const auto module_id = + rc_capabilities_manager_.GetDefaultModuleIdFromCapabilities( + ModuleType()); + + msg_params[message_params::kModuleIds][0] = module_id; + } + + const std::string module_type = ModuleType(); + for (const auto module_id : + *(msg_params[message_params::kModuleIds].asArray())) { + const ModuleUid module(module_type, module_id.asString()); + if (!rc_capabilities_manager_.CheckIfModuleExistsInCapabilities(module)) { + LOG4CXX_WARN(logger_, + "Accessing not supported module: " << module_type << " " + << module_id.asString()); + SetResourceState(module_type, ResourceState::FREE); + SendResponse(false, + mobile_apis::Result::UNSUPPORTED_RESOURCE, + "Accessing not supported module data"); + return; + } + } + + smart_objects::SmartObject response_params; + if (GetCalculatedVehicleDataConsent(response_params)) { + LOG4CXX_DEBUG( + logger_, + "No need to send request to HMI. Sending cached consents to mobile"); + SendResponse(true, mobile_apis::Result::SUCCESS, nullptr, &response_params); + return; + } + + (*message_)[application_manager::strings::msg_params] + [application_manager::strings::app_id] = connection_key(); + + hmi_request_consents_ = + smart_objects::SmartObject(response_params[message_params::kAllowed]); + + LOG4CXX_DEBUG( + logger_, "Filtering out module ids with successfully calculated consent"); + + smart_objects::SmartObject hmi_msg_params(msg_params); + auto module_ids_for_consent = + hmi_msg_params[message_params::kModuleIds].asArray(); + module_ids_for_consent->clear(); + + auto module_ids = msg_params[message_params::kModuleIds].asArray(); + for (uint32_t i = 0; i < module_ids->size(); i++) { + // Only add modules whose consent is unknown(needs to be sent to the hmi) + bool is_consent_undefined = + (*hmi_request_consents_.asArray())[i].getType() == + smart_objects::SmartType::SmartType_Null; + if (is_consent_undefined) { + module_ids_for_consent->push_back((*module_ids)[i]); + } + } + + LOG4CXX_DEBUG(logger_, + "Forwarding request to HMI with moduleIds for modules with " + "unknown consent"); + SendHMIRequest(hmi_apis::FunctionID::RC_GetInteriorVehicleDataConsent, + (&hmi_msg_params), + true); +} + +void GetInteriorVehicleDataConsentRequest::on_event( + const app_mngr::event_engine::Event& event) { + LOG4CXX_AUTO_TRACE(logger_); + + if (event.id() != hmi_apis::FunctionID::RC_GetInteriorVehicleDataConsent) { + LOG4CXX_ERROR(logger_, "Received wrong event. FunctionID: " << event.id()); + return; + } + + auto temp_response = event.smart_object(); + + auto result_code = + GetMobileResultCode(static_cast( + temp_response[app_mngr::strings::params][app_mngr::hmi_response::code] + .asUInt())); + + const bool success_result = + helpers::Compare( + result_code, + mobile_apis::Result::SUCCESS, + mobile_apis::Result::WARNINGS); + + if (!success_result) { + std::string info; + GetInfo(temp_response, info); + SendResponse(false, result_code, info.c_str(), nullptr); + return; + } + + if (!temp_response[app_mngr::strings::msg_params].keyExists( + message_params::kAllowed) || + temp_response[app_mngr::strings::msg_params][message_params::kAllowed] + .empty()) { + std::string info_out = + "Collection of consents is absent in HMI response or empty"; + LOG4CXX_ERROR(logger_, info_out); + SendResponse(false, mobile_apis::Result::GENERIC_ERROR, info_out.c_str()); + return; + } + + uint32_t number_of_expected_response_consents = std::accumulate( + hmi_request_consents_.asArray()->begin(), + hmi_request_consents_.asArray()->end(), + uint32_t(0), + [](uint32_t num_consents, smart_objects::SmartObject& consent) { + // Only module ids with valid location consents were sent to the hmi + bool is_consent_undefined = + consent.getType() == smart_objects::SmartType::SmartType_Null; + return (is_consent_undefined) ? num_consents + 1 : num_consents; + }); + + const auto response_consents = + temp_response[app_mngr::strings::msg_params][message_params::kAllowed] + .asArray(); + + if (number_of_expected_response_consents != response_consents->size()) { + std::string info_out = + "HMI response has incorrect number of consents expected: " + + std::to_string(number_of_expected_response_consents) + + ", actual: " + std::to_string(response_consents->size()); + LOG4CXX_ERROR(logger_, info_out); + SendResponse(false, mobile_apis::Result::GENERIC_ERROR, info_out.c_str()); + return; + } + + LOG4CXX_DEBUG(logger_, + "Adding back filtered out module ids for response to mobile"); + uint32_t response_consents_counter = 0; + for (auto& consent : *(hmi_request_consents_.asArray())) { + // Only modify consent for moduleIds allowed by location constraints + bool is_consent_undefined = + consent.getType() == smart_objects::SmartType::SmartType_Null; + if (is_consent_undefined) { + consent = (*response_consents)[response_consents_counter]; + response_consents_counter++; + } + } + + temp_response[app_mngr::strings::msg_params][message_params::kAllowed] = + hmi_request_consents_; + + const auto hmi_response = temp_response; + std::string response_info; + const bool result_of_saving = SaveModuleIdConsents( + response_info, hmi_response[app_mngr::strings::msg_params]); + + if (!result_of_saving) { + LOG4CXX_DEBUG(logger_, "Consent saving failed"); + SendResponse( + false, mobile_apis::Result::GENERIC_ERROR, response_info.c_str()); + return; + } + + smart_objects::SmartObject response_params = + hmi_response[app_mngr::strings::msg_params]; + std::string info; + GetInfo(hmi_response, info); + SendResponse(success_result, result_code, info.c_str(), &response_params); +} + +std::string GetInteriorVehicleDataConsentRequest::ModuleType() const { + mobile_apis::ModuleType::eType module_type = + static_cast( + (*message_)[app_mngr::strings::msg_params] + [message_params::kModuleType] + .asUInt()); + + const char* str; + const bool ok = smart_objects::EnumConversionHelper< + mobile_apis::ModuleType::eType>::EnumToCString(module_type, &str); + return ok ? str : "unknown"; +} + +std::string GetInteriorVehicleDataConsentRequest::ModuleId() const { + return std::string(); +} + +GetInteriorVehicleDataConsentRequest::~GetInteriorVehicleDataConsentRequest() {} + +bool GetInteriorVehicleDataConsentRequest::IsUserLocationValid( + const ModuleUid& module_uid) const { + LOG4CXX_AUTO_TRACE(logger_); + + if (!rc_capabilities_manager_.IsSeatLocationCapabilityProvided()) { + return true; + } + const auto app_ptr = application_manager_.application(connection_key()); + const auto extension = RCHelpers::GetRCExtension(*app_ptr); + const auto module_service_area = + rc_capabilities_manager_.GetModuleServiceArea(module_uid); + const auto user_location = extension->GetUserLocation(); + const auto driver = + rc_capabilities_manager_.GetDriverLocationFromSeatLocationCapability(); + const bool is_driver = (user_location == driver); + if (is_driver || user_location.IntersectionExists(module_service_area)) { + return true; + } + return false; +} + +rc_rpc_types::ModuleConsent +GetInteriorVehicleDataConsentRequest::GetModuleConsentByAccessMode( + const ModuleUid& module_uid, + const hmi_apis::Common_RCAccessMode::eType access_mode) const { + LOG4CXX_AUTO_TRACE(logger_); + + auto get_auto_allow_consent = [](const ModuleUid& module_uid) { + return rc_rpc_types::ModuleConsent::CONSENTED; + }; + + auto get_auto_deny_consent = [this](const ModuleUid& module_uid) { + auto app = application_manager_.application(connection_key()); + const uint32_t app_id = app->app_id(); + const bool is_resource_available = + (resource_allocation_manager_.AcquireResource( + module_uid.first, module_uid.second, app_id) == + AcquireResult::ALLOWED); + return (is_resource_available) ? rc_rpc_types::ModuleConsent::CONSENTED + : rc_rpc_types::ModuleConsent::NOT_CONSENTED; + }; + + auto get_ask_driver_consent = [this](const ModuleUid& module_uid) { + auto app = application_manager_.application(connection_key()); + const std::string policy_app_id = app->policy_app_id(); + const std::string mac_address = app->mac_address(); + + auto consent = rc_consent_manager_.GetModuleConsent( + policy_app_id, mac_address, module_uid); + + if (rc_rpc_types::ModuleConsent::NOT_EXISTS == consent) { + auto acquire_result = resource_allocation_manager_.AcquireResource( + module_uid.first, module_uid.second, app->app_id()); + const bool is_resource_available = + (acquire_result == AcquireResult::ALLOWED); + const bool is_resource_rejected = + (acquire_result == AcquireResult::REJECTED); + + if (!is_resource_available && !is_resource_rejected) { + return rc_rpc_types::ModuleConsent::NOT_EXISTS; + } + + return (is_resource_available) + ? rc_rpc_types::ModuleConsent::CONSENTED + : rc_rpc_types::ModuleConsent::NOT_CONSENTED; + } + + const bool is_consent_allowed = + (rc_rpc_types::ModuleConsent::CONSENTED == consent); + return (is_consent_allowed) ? rc_rpc_types::ModuleConsent::CONSENTED + : rc_rpc_types::ModuleConsent::NOT_CONSENTED; + }; + + switch (access_mode) { + case hmi_apis::Common_RCAccessMode::AUTO_ALLOW: { + LOG4CXX_DEBUG(logger_, + "Calculating consent for module(" + << module_uid.first << ", " << module_uid.second + << ") in accessMode: AUTO_ALLOW"); + return get_auto_allow_consent(module_uid); + } + case hmi_apis::Common_RCAccessMode::AUTO_DENY: { + LOG4CXX_DEBUG(logger_, + "Calculating consent for module(" + << module_uid.first << ", " << module_uid.second + << ") in accessMode: AUTO_DENY"); + return get_auto_deny_consent(module_uid); + } + case hmi_apis::Common_RCAccessMode::ASK_DRIVER: { + LOG4CXX_DEBUG(logger_, + "Calculating consent for module(" + << module_uid.first << ", " << module_uid.second + << ") in accessMode: ASK_DRIVER"); + return get_ask_driver_consent(module_uid); + } + default: { + LOG4CXX_DEBUG(logger_, + "Unknown accessMode specified. Denying consent for module(" + << module_uid.first << ", " << module_uid.second + << ")"); + return rc_rpc_types::ModuleConsent::NOT_CONSENTED; + } + } +} + +bool GetInteriorVehicleDataConsentRequest::GetCalculatedVehicleDataConsent( + smart_objects::SmartObject& out_response) const { + LOG4CXX_AUTO_TRACE(logger_); + + out_response = + smart_objects::SmartObject(smart_objects::SmartType::SmartType_Map); + out_response[message_params::kAllowed] = + smart_objects::SmartObject(smart_objects::SmartType::SmartType_Array); + + auto modules_consent_array = out_response[message_params::kAllowed].asArray(); + const auto module_ids = + (*message_)[app_mngr::strings::msg_params][message_params::kModuleIds] + .asArray(); + const std::string module_type = ModuleType(); + bool can_handle_internally = true; + + auto get_disallowed_multiple_access_consent = + [this](const ModuleUid& module_uid) { + auto app = application_manager_.application(connection_key()); + const uint32_t app_id = app->app_id(); + const bool is_resource_available = + (resource_allocation_manager_.AcquireResource( + module_uid.first, module_uid.second, app_id) == + AcquireResult::ALLOWED); + return (is_resource_available) + ? rc_rpc_types::ModuleConsent::CONSENTED + : rc_rpc_types::ModuleConsent::NOT_CONSENTED; + }; + + for (const auto module_id : *(module_ids)) { + const ModuleUid module_uid(module_type, module_id.asString()); + // Check if the user_location is covered by the module's serviceArea + if (!IsUserLocationValid(module_uid)) { + LOG4CXX_DEBUG(logger_, + "User is outside the serviceArea for module(" + << module_uid.first << ", " << module_uid.second + << "). Denying consent"); + modules_consent_array->push_back(smart_objects::SmartObject(false)); + continue; + } + + rc_rpc_types::ModuleConsent module_consent; + + const bool is_multiple_access_allowed = + rc_capabilities_manager_.IsMultipleAccessAllowed(module_uid); + if (!is_multiple_access_allowed) { + LOG4CXX_DEBUG(logger_, + "multipleAccess disallowed for module(" + << module_uid.first << ", " << module_uid.second + << ")"); + module_consent = get_disallowed_multiple_access_consent(module_uid); + modules_consent_array->push_back(smart_objects::SmartObject( + module_consent == rc_rpc_types::ModuleConsent::CONSENTED)); + continue; + } + + const auto access_mode = resource_allocation_manager_.GetAccessMode(); + + module_consent = GetModuleConsentByAccessMode(module_uid, access_mode); + if (module_consent == rc_rpc_types::ModuleConsent::NOT_EXISTS) { + LOG4CXX_DEBUG(logger_, + "Unable to calculate consent for module(" + << module_uid.first << ", " << module_uid.second + << "), should send moduleId to HMI for consent"); + modules_consent_array->push_back(smart_objects::SmartObject()); + can_handle_internally = false; + continue; + } + modules_consent_array->push_back(smart_objects::SmartObject( + module_consent == rc_rpc_types::ModuleConsent::CONSENTED)); + } + return can_handle_internally; +} + +bool GetInteriorVehicleDataConsentRequest::SaveModuleIdConsents( + std::string& info_out, const smart_objects::SmartObject& msg_params) { + LOG4CXX_AUTO_TRACE(logger_); + + const auto& allowed = msg_params[message_params::kAllowed]; + const auto& moduleIds = + (*message_)[app_mngr::strings::msg_params][message_params::kModuleIds]; + + if (allowed.length() != moduleIds.length()) { + info_out = + "The received module_id collection from mobile and received consent " + "collection from HMI are not equal by size."; + LOG4CXX_ERROR(logger_, info_out); + return false; + } + std::string module_type = ModuleType(); + auto module_ids = RCHelpers::RetrieveModuleIds(moduleIds); + auto module_allowed = RCHelpers::RetrieveModuleConsents(allowed); + + auto module_consents = + RCHelpers::FillModuleConsents(module_type, module_ids, module_allowed); + + auto application = application_manager_.application(connection_key()); + if (!application) { + LOG4CXX_ERROR(logger_, + "Application with connection key:" << connection_key() + << " isn't registered"); + return false; + } + std::string policy_app_id = application->policy_app_id(); + const auto mac_address = application->mac_address(); + rc_consent_manager_.SaveModuleConsents( + policy_app_id, mac_address, module_consents); + return true; +} + +} // namespace commands +} // namespace rc_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/get_interior_vehicle_data_consent_response.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/get_interior_vehicle_data_consent_response.cc new file mode 100644 index 00000000000..3e197fbdea0 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/get_interior_vehicle_data_consent_response.cc @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2019, 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 "rc_rpc_plugin/commands/mobile/get_interior_vehicle_data_consent_response.h" + +namespace rc_rpc_plugin { +namespace commands { + +GetInteriorVehicleDataConsentResponse::GetInteriorVehicleDataConsentResponse( + const application_manager::commands::MessageSharedPtr& message, + const RCCommandParams& params) + : application_manager::commands::CommandResponseImpl( + message, + params.application_manager_, + params.rpc_service_, + params.hmi_capabilities_, + params.policy_handler_) {} + +void GetInteriorVehicleDataConsentResponse::Run() { + LOG4CXX_AUTO_TRACE(logger_); + application_manager_.GetRPCService().SendMessageToMobile(message_); +} + +GetInteriorVehicleDataConsentResponse:: + ~GetInteriorVehicleDataConsentResponse() {} + +} // namespace commands +} // namespace rc_rpc_plugin 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 4d12b4f3756..10f6303ac98 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 @@ -31,12 +31,12 @@ */ #include "rc_rpc_plugin/commands/mobile/get_interior_vehicle_data_request.h" -#include "rc_rpc_plugin/rc_module_constants.h" +#include "interfaces/MOBILE_API.h" #include "rc_rpc_plugin/rc_helpers.h" +#include "rc_rpc_plugin/rc_module_constants.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" namespace rc_rpc_plugin { namespace commands { @@ -50,36 +50,21 @@ GetInteriorVehicleDataRequest::GetInteriorVehicleDataRequest( const app_mngr::commands::MessageSharedPtr& message, const RCCommandParams& params) : RCCommandRequest(message, params) - , excessive_subscription_occured_(false) {} -bool CheckIfModuleTypeExistInCapabilities( - const smart_objects::SmartObject& rc_capabilities, - const std::string& module_type) { - LOG4CXX_AUTO_TRACE(logger_); - const auto& mapping = RCHelpers::GetModuleTypeToCapabilitiesMapping(); - const auto& module_list = RCHelpers::GetModulesList(); - bool is_module_type_valid = false; - for (const auto& module : module_list) { - if (module == module_type) { - if (rc_capabilities.keyExists(mapping(module))) { - is_module_type_valid = true; - break; - } - } - } - return is_module_type_valid; -} - bool GetInteriorVehicleDataRequest::ProcessCapabilities() { LOG4CXX_AUTO_TRACE(logger_); const smart_objects::SmartObject* rc_capabilities = hmi_capabilities_.rc_capability(); const std::string module_type = ModuleType(); + const std::string module_id = ModuleId(); + const ModuleUid module(module_type, module_id); if (rc_capabilities && - !CheckIfModuleTypeExistInCapabilities(*rc_capabilities, module_type)) { - LOG4CXX_WARN(logger_, "Accessing not supported module data"); + !rc_capabilities_manager_.CheckIfModuleExistsInCapabilities(module)) { + LOG4CXX_WARN( + logger_, + "Accessing not supported module: " << module_type << " " << module_id); SetResourceState(ModuleType(), ResourceState::FREE); SendResponse(false, mobile_apis::Result::UNSUPPORTED_RESOURCE, @@ -109,6 +94,7 @@ void GetInteriorVehicleDataRequest::FilterDisabledModuleData( module_data[message_params::kHdRadioEnable].asBool() == false) { module_data.erase(message_params::kHdChannel); module_data.erase(message_params::kAvailableHDs); + module_data.erase(message_params::kAvailableHdChannels); module_data.erase(message_params::kSisData); } } @@ -117,14 +103,20 @@ void GetInteriorVehicleDataRequest::ProcessResponseToMobileFromCache( app_mngr::ApplicationSharedPtr app) { LOG4CXX_AUTO_TRACE(logger_); const auto& data_mapping = RCHelpers::GetModuleTypeToDataMapping(); - auto data = interior_data_cache_.Retrieve(ModuleType()); + const std::string module_type = ModuleType(); + const std::string module_id = ModuleId(); + const ModuleUid module(module_type, module_id); + auto data = interior_data_cache_.Retrieve(module); FilterDisabledModuleData(data); auto response_msg_params = smart_objects::SmartObject(smart_objects::SmartType_Map); - response_msg_params[message_params::kModuleData][data_mapping(ModuleType())] = + response_msg_params[message_params::kModuleData][data_mapping(module_type)] = data; response_msg_params[message_params::kModuleData] - [message_params::kModuleType] = ModuleType(); + [message_params::kModuleType] = module_type; + + response_msg_params[message_params::kModuleData][message_params::kModuleId] = + module_id; const auto& request_msg_params = (*message_)[app_mngr::strings::msg_params]; LOG4CXX_DEBUG(logger_, @@ -136,7 +128,7 @@ void GetInteriorVehicleDataRequest::ProcessResponseToMobileFromCache( if (request_msg_params[message_params::kSubscribe].asBool()) { auto extension = RCHelpers::GetRCExtension(*app); DCHECK(extension); - extension->SubscribeToInteriorVehicleData(ModuleType()); + extension->SubscribeToInteriorVehicleData(module); } } SendResponse( @@ -144,13 +136,16 @@ void GetInteriorVehicleDataRequest::ProcessResponseToMobileFromCache( if (AppShouldBeUnsubscribed()) { auto extension = RCHelpers::GetRCExtension(*app); DCHECK(extension); - extension->UnsubscribeFromInteriorVehicleData(ModuleType()); + extension->UnsubscribeFromInteriorVehicleData(module); } } bool GetInteriorVehicleDataRequest::CheckRateLimits() { LOG4CXX_AUTO_TRACE(logger_); - return interior_data_manager_.CheckRequestsToHMIFrequency(ModuleType()); + const std::string module_type = ModuleType(); + const std::string module_id = ModuleId(); + const ModuleUid module(module_type, module_id); + return interior_data_manager_.CheckRequestsToHMIFrequency(module); } bool GetInteriorVehicleDataRequest::AppShouldBeUnsubscribed() { @@ -166,13 +161,16 @@ bool GetInteriorVehicleDataRequest::TheLastAppShouldBeUnsubscribed( app_mngr::ApplicationSharedPtr app) { LOG4CXX_AUTO_TRACE(logger_); if (AppShouldBeUnsubscribed()) { + const std::string module_type = ModuleType(); + const std::string module_id = ModuleId(); + const ModuleUid module(module_type, module_id); const auto subscribed_to_module_type = - RCHelpers::AppsSubscribedToModuleType(application_manager_, - ModuleType()); + RCHelpers::AppsSubscribedToModule(application_manager_, module); if (subscribed_to_module_type.size() == 1 && subscribed_to_module_type.front() == app) { LOG4CXX_DEBUG(logger_, - "The last application unsubscribes from " << ModuleType()); + "The last application unsubscribes from " + << module_type << " " << module_id); return true; } } @@ -188,9 +186,12 @@ void GetInteriorVehicleDataRequest::Execute() { app_mngr::ApplicationSharedPtr app = application_manager_.application(connection_key()); + const std::string module_type = ModuleType(); + const std::string module_id = ModuleId(); + const ModuleUid module(module_type, module_id); if (TheLastAppShouldBeUnsubscribed(app) || - !interior_data_cache_.Contains(ModuleType())) { + !interior_data_cache_.Contains(module)) { if (HasRequestExcessiveSubscription()) { excessive_subscription_occured_ = true; is_subscribed = @@ -203,7 +204,9 @@ void GetInteriorVehicleDataRequest::Execute() { SendResponse(false, mobile_apis::Result::REJECTED); return; } - interior_data_manager_.StoreRequestToHMITime(ModuleType()); + interior_data_manager_.StoreRequestToHMITime(module); + (*message_)[app_mngr::strings::msg_params][message_params::kModuleId] = + ModuleId(); SendHMIRequest(hmi_apis::FunctionID::RC_GetInteriorVehicleData, &(*message_)[app_mngr::strings::msg_params], true); @@ -241,20 +244,32 @@ void GetInteriorVehicleDataRequest::on_event( } if (result) { + if (!IsModuleIdProvided(hmi_response)) { + LOG4CXX_WARN(logger_, + "conditional mandatory parameter " + << message_params::kModuleId + << " missed in hmi response"); + result = false; + result_code = mobile_apis::Result::GENERIC_ERROR; + } app_mngr::ApplicationSharedPtr app = application_manager_.application(connection_key()); DCHECK_OR_RETURN_VOID(app); + const std::string module_type = ModuleType(); + const std::string module_id = ModuleId(); + const ModuleUid module(module_type, module_id); + if (TheLastAppShouldBeUnsubscribed(app)) { - interior_data_cache_.Remove(ModuleType()); + interior_data_cache_.Remove(module); } 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); + [message_params::kModuleData][data_mapping(module_type)]; + interior_data_cache_.Add(module, module_data); } } else { hmi_response[app_mngr::strings::msg_params].erase( @@ -297,10 +312,18 @@ void GetInteriorVehicleDataRequest::ProccessSubscription( static_cast( hmi_response[app_mngr::strings::msg_params] [message_params::kModuleData] - [message_params::kModuleType].asUInt()), + [message_params::kModuleType] + .asUInt()), &module_type); + + const std::string module_id = + hmi_response[app_mngr::strings::msg_params][message_params::kModuleData] + [message_params::kModuleId] + .asString(); + const ModuleUid module(module_type, module_id); + if (excessive_subscription_occured_) { - is_subscribed = extension->IsSubscibedToInteriorVehicleData(module_type); + is_subscribed = extension->IsSubscribedToInteriorVehicleData(module); temp_hmi_response[app_mngr::strings::msg_params] [message_params::kIsSubscribed] = is_subscribed; return; @@ -315,7 +338,7 @@ void GetInteriorVehicleDataRequest::ProccessSubscription( << message_params::kIsSubscribed << " missed in hmi response"); - is_subscribed = extension->IsSubscibedToInteriorVehicleData(module_type); + is_subscribed = extension->IsSubscribedToInteriorVehicleData(module); temp_hmi_response[app_mngr::strings::msg_params] [message_params::kIsSubscribed] = is_subscribed; return; @@ -346,16 +369,21 @@ void GetInteriorVehicleDataRequest::ProccessSubscription( LOG4CXX_TRACE(logger_, "response_subscribe = " << response_subscribe); if (request_subscribe == response_subscribe) { const std::string module_type = ModuleType(); + const std::string module_id = ModuleId(); + const ModuleUid module(module_type, module_id); + if (response_subscribe) { LOG4CXX_DEBUG(logger_, "SubscribeToInteriorVehicleData " << app->app_id() << " " - << module_type); - extension->SubscribeToInteriorVehicleData(module_type); + << module_type << " " + << module_id); + extension->SubscribeToInteriorVehicleData(module); } else { LOG4CXX_DEBUG(logger_, "UnsubscribeFromInteriorVehicleData " - << app->app_id() << " " << module_type); - extension->UnsubscribeFromInteriorVehicleData(module_type); + << app->app_id() << " " << module_type << " " + << module_id); + extension->UnsubscribeFromInteriorVehicleData(module); } } } @@ -371,8 +399,12 @@ bool GetInteriorVehicleDataRequest::HasRequestExcessiveSubscription() { application_manager_.application(CommandRequestImpl::connection_key()); const auto extension = RCHelpers::GetRCExtension(*app); + const std::string module_type = ModuleType(); + const std::string module_id = ModuleId(); + const ModuleUid module(module_type, module_id); + const bool is_app_already_subscribed = - extension->IsSubscibedToInteriorVehicleData(ModuleType()); + extension->IsSubscribedToInteriorVehicleData(module); const bool app_wants_to_subscribe = (*message_)[app_mngr::strings::msg_params][message_params::kSubscribe] .asBool(); @@ -389,16 +421,29 @@ void GetInteriorVehicleDataRequest::RemoveExcessiveSubscription() { (*message_)[app_mngr::strings::msg_params].erase(message_params::kSubscribe); } -std::string GetInteriorVehicleDataRequest::ModuleType() { - mobile_apis::ModuleType::eType module_type = static_cast< - mobile_apis::ModuleType::eType>( - (*message_)[app_mngr::strings::msg_params][message_params::kModuleType] - .asUInt()); +std::string GetInteriorVehicleDataRequest::ModuleType() const { + LOG4CXX_AUTO_TRACE(logger_); + mobile_apis::ModuleType::eType module_type = + static_cast( + (*message_)[app_mngr::strings::msg_params] + [message_params::kModuleType] + .asUInt()); const char* str; const bool ok = ns_smart_device_link::ns_smart_objects::EnumConversionHelper< mobile_apis::ModuleType::eType>::EnumToCString(module_type, &str); return ok ? str : "unknown"; } +std::string GetInteriorVehicleDataRequest::ModuleId() const { + LOG4CXX_AUTO_TRACE(logger_); + auto msg_params = (*message_)[app_mngr::strings::msg_params]; + if (msg_params.keyExists(message_params::kModuleId)) { + return msg_params[message_params::kModuleId].asString(); + } + const std::string module_id = + rc_capabilities_manager_.GetDefaultModuleIdFromCapabilities(ModuleType()); + return module_id; +} + } // namespace commands } // namespace rc_rpc_plugin 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 a7572f1d627..b1fa8d6ea0a 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 @@ -31,6 +31,7 @@ */ #include "rc_rpc_plugin/commands/mobile/get_interior_vehicle_data_response.h" +#include "rc_rpc_plugin/rc_helpers.h" #include "utils/macro.h" namespace rc_rpc_plugin { @@ -49,6 +50,9 @@ GetInteriorVehicleDataResponse::~GetInteriorVehicleDataResponse() {} void GetInteriorVehicleDataResponse::Run() { LOG4CXX_AUTO_TRACE(logger_); + + RCHelpers::RemoveRedundantGPSDataFromIVDataMsg( + (*message_)[app_mngr::strings::msg_params]); application_manager_.GetRPCService().SendMessageToMobile(message_); } 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 37890b79795..91ecbe77ebf 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 @@ -31,9 +31,9 @@ */ #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 "rc_rpc_plugin/rc_module_constants.h" +#include "rc_rpc_plugin/rc_rpc_plugin.h" #include "smart_objects/enum_schema_item.h" #include "utils/macro.h" @@ -50,31 +50,37 @@ OnInteriorVehicleDataNotification::OnInteriorVehicleDataNotification( params.rpc_service_, params.hmi_capabilities_, params.policy_handler_) - , interior_data_cache_(params.interior_data_cache_) {} + , interior_data_cache_(params.interior_data_cache_) + , rc_capabilities_manager_(params.rc_capabilities_manager_) {} OnInteriorVehicleDataNotification::~OnInteriorVehicleDataNotification() {} void OnInteriorVehicleDataNotification::AddDataToCache( - const std::string& module_type) { + const ModuleUid& module) { 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); + [data_mapping(module.first)]; + interior_data_cache_.Add(module, module_data); } void OnInteriorVehicleDataNotification::Run() { LOG4CXX_AUTO_TRACE(logger_); const std::string module_type = ModuleType(); + const std::string module_id = ModuleId(); + const ModuleUid module(module_type, module_id); + auto apps_subscribed = - RCHelpers::AppsSubscribedToModuleType(application_manager_, module_type); + RCHelpers::AppsSubscribedToModule(application_manager_, module); if (!apps_subscribed.empty()) { - AddDataToCache(module_type); + AddDataToCache(module); } typedef std::vector AppPtrs; AppPtrs apps = RCRPCPlugin::GetRCApplications(application_manager_); + RCHelpers::RemoveRedundantGPSDataFromIVDataMsg( + (*message_)[app_mngr::strings::msg_params]); for (AppPtrs::iterator it = apps.begin(); it != apps.end(); ++it) { DCHECK(*it); application_manager::Application& app = **it; @@ -82,17 +88,36 @@ void OnInteriorVehicleDataNotification::Run() { const auto extension = RCHelpers::GetRCExtension(app); DCHECK(extension); LOG4CXX_TRACE(logger_, - "Check subscription for " - << app.app_id() << "and module type " << module_type); - if (extension->IsSubscibedToInteriorVehicleData(module_type)) { + "Check subscription for " << app.app_id() + << "and module type " << module_type + << " " << module_id); + + if (extension->IsSubscribedToInteriorVehicleData(module)) { (*message_)[app_mngr::strings::params] [app_mngr::strings::connection_key] = app.app_id(); + + (*message_)[app_mngr::strings::msg_params][message_params::kModuleData] + [message_params::kModuleId] = module_id; + SendNotification(); } } } -std::string OnInteriorVehicleDataNotification::ModuleType() { +std::string OnInteriorVehicleDataNotification::ModuleId() const { + LOG4CXX_AUTO_TRACE(logger_); + auto msg_params = (*message_)[app_mngr::strings::msg_params]; + if (msg_params[message_params::kModuleData].keyExists( + message_params::kModuleId)) { + return msg_params[message_params::kModuleData][message_params::kModuleId] + .asString(); + } + const std::string module_id = + rc_capabilities_manager_.GetDefaultModuleIdFromCapabilities(ModuleType()); + return module_id; +} + +std::string OnInteriorVehicleDataNotification::ModuleType() const { mobile_apis::ModuleType::eType module_type = static_cast( (*message_)[app_mngr::strings::msg_params] diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/release_interior_vehicle_data_module_request.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/release_interior_vehicle_data_module_request.cc new file mode 100644 index 00000000000..e30d7869bda --- /dev/null +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/release_interior_vehicle_data_module_request.cc @@ -0,0 +1,194 @@ +/* + * Copyright (c) 2019, 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 "application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/resource_allocation_manager.h" +#include "rc_rpc_plugin/commands/mobile/release_interior_vehicle_data_module_request.h" +#include "rc_rpc_plugin/rc_module_constants.h" +#include "smart_objects/enum_schema_item.h" + +namespace rc_rpc_plugin { +using namespace application_manager; +namespace commands { + +namespace { +struct ResponseParams { + std::string response_info; + std::string module_type; + std::string module_id; + mobile_apis::Result::eType result_code; + uint32_t app_id; + bool success_result; +}; + +void PrepareResponseResult( + ResponseParams& response_params_out, + rc_rpc_plugin::ResourceReleasedState::eType& released_result) { + std::stringstream ss; + auto info_inserter = [&ss, response_params_out](std::string info) { + ss << "Module [" << response_params_out.module_type << ":" + << response_params_out.module_id << "] " << info; + }; + switch (released_result) { + case rc_rpc_plugin::ResourceReleasedState::eType::IS_RELEASED: { + response_params_out.success_result = true; + response_params_out.result_code = mobile_apis::Result::eType::SUCCESS; + info_inserter("is released successfully."); + break; + } + case rc_rpc_plugin::ResourceReleasedState::eType::IS_ALLOCATED: { + response_params_out.success_result = false; + response_params_out.result_code = mobile_apis::Result::eType::REJECTED; + info_inserter("is allocated to a different application."); + break; + } + case rc_rpc_plugin::ResourceReleasedState::eType::NOT_ALLOCATED: { + response_params_out.success_result = false; + response_params_out.result_code = mobile_apis::Result::eType::IGNORED; + info_inserter("is not allocated to any application."); + break; + } + } + response_params_out.response_info = ss.str(); +} +} // namespace + +ReleaseInteriorVehicleDataModuleRequest:: + ReleaseInteriorVehicleDataModuleRequest( + const application_manager::commands::MessageSharedPtr& message, + const RCCommandParams& params) + : RCCommandRequest(message, params) {} + +bool ReleaseInteriorVehicleDataModuleRequest::ProcessCapabilities() { + LOG4CXX_AUTO_TRACE(logger_); + const smart_objects::SmartObject* rc_capabilities = + hmi_capabilities_.rc_capability(); + + const std::string module_type = ModuleType(); + const std::string module_id = ModuleId(); + const ModuleUid module(module_type, module_id); + if (rc_capabilities && + !rc_capabilities_manager_.CheckIfModuleExistsInCapabilities(module)) { + LOG4CXX_WARN( + logger_, + "Accessing not supported module: " << module_type << " " << module_id); + SendResponse(false, + mobile_apis::Result::UNSUPPORTED_RESOURCE, + "Accessing not supported module"); + return false; + } + return true; +} + +void ReleaseInteriorVehicleDataModuleRequest::Execute() { + LOG4CXX_AUTO_TRACE(logger_); + + if (!ProcessCapabilities()) { + return; + } + + const std::string module_type = ModuleType(); + const std::string module_id = ModuleId(); + + 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 uint32_t app_id = app->app_id(); + + ResourceReleasedState::eType released_result = + resource_allocation_manager_.ReleaseResource( + module_type, module_id, app_id); + + bool success_result = true; + mobile_apis::Result::eType result_code = mobile_apis::Result::eType::SUCCESS; + std::string response_info; + ResponseParams response_params{response_info, + ModuleType(), + module_id, + result_code, + app_id, + success_result}; + PrepareResponseResult(response_params, released_result); + + if (response_params.success_result) { + resource_allocation_manager_.SendOnRCStatusNotifications( + NotificationTrigger::MODULE_ALLOCATION, app); + } + + LOG4CXX_DEBUG(logger_, + "Resource for module: " + << ModuleType() << " with id: " << module_id + << " was released with result " << std::boolalpha + << response_params.success_result + << " and result_code: " << response_params.result_code); + + SendResponse(response_params.success_result, + response_params.result_code, + response_params.response_info.c_str()); +} + +std::string ReleaseInteriorVehicleDataModuleRequest::ModuleType() const { + LOG4CXX_AUTO_TRACE(logger_); + mobile_apis::ModuleType::eType module_type = + static_cast( + (*message_)[app_mngr::strings::msg_params] + [message_params::kModuleType] + .asUInt()); + + const char* str; + const bool ok = ns_smart_device_link::ns_smart_objects::EnumConversionHelper< + mobile_apis::ModuleType::eType>::EnumToCString(module_type, &str); + return ok ? str : "unknown"; +} + +std::string ReleaseInteriorVehicleDataModuleRequest::ModuleId() const { + LOG4CXX_AUTO_TRACE(logger_); + auto msg_params = (*message_)[app_mngr::strings::msg_params]; + if (msg_params.keyExists(message_params::kModuleId)) { + return msg_params[message_params::kModuleId].asString(); + } + const std::string module_id = + rc_capabilities_manager_.GetDefaultModuleIdFromCapabilities(ModuleType()); + return module_id; +} + +ReleaseInteriorVehicleDataModuleRequest:: + ~ReleaseInteriorVehicleDataModuleRequest() {} + +} // namespace commands +} // namespace rc_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/release_interior_vehicle_data_module_response.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/release_interior_vehicle_data_module_response.cc new file mode 100644 index 00000000000..fae792f1434 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/release_interior_vehicle_data_module_response.cc @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2019, 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 "rc_rpc_plugin/commands/mobile/release_interior_vehicle_data_module_response.h" + +namespace rc_rpc_plugin { +namespace commands { + +ReleaseInteriorVehicleDataModuleResponse:: + ReleaseInteriorVehicleDataModuleResponse( + const application_manager::commands::MessageSharedPtr& message, + const RCCommandParams& params) + : application_manager::commands::CommandResponseImpl( + message, + params.application_manager_, + params.rpc_service_, + params.hmi_capabilities_, + params.policy_handler_) {} + +void ReleaseInteriorVehicleDataModuleResponse::Run() { + LOG4CXX_AUTO_TRACE(logger_); + application_manager_.GetRPCService().SendMessageToMobile(message_); +} + +ReleaseInteriorVehicleDataModuleResponse:: + ~ReleaseInteriorVehicleDataModuleResponse() {} + +} // namespace commands +} // namespace rc_rpc_plugin 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 edc45670cec..c3e5e807d7b 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 @@ -31,116 +31,20 @@ */ #include "rc_rpc_plugin/commands/mobile/set_interior_vehicle_data_request.h" +#include "interfaces/MOBILE_API.h" +#include "json/json.h" +#include "rc_rpc_plugin/rc_helpers.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" #include "utils/helpers.h" -#include "interfaces/MOBILE_API.h" +#include "utils/macro.h" namespace rc_rpc_plugin { namespace commands { using namespace json_keys; using namespace message_params; - -namespace { -std::vector GetModuleReadOnlyParams( - const std::string& module_type) { - std::vector module_ro_params; - if (enums_value::kClimate == module_type) { - module_ro_params.push_back(kCurrentTemperature); - } else if (enums_value::kRadio == module_type) { - module_ro_params.push_back(kRdsData); - module_ro_params.push_back(kAvailableHDs); - module_ro_params.push_back(kSignalStrength); - 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 - mapping["fanSpeed"] = "fanSpeedAvailable"; - mapping["currentTemperature"] = "currentTemperatureAvailable"; - mapping["desiredTemperature"] = "desiredTemperatureAvailable"; - mapping["acEnable"] = "acEnableAvailable"; - mapping["circulateAirEnable"] = "circulateAirEnableAvailable"; - mapping["autoModeEnable"] = "autoModeEnableAvailable"; - mapping["defrostZone"] = "defrostZoneAvailable"; - 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"; - mapping["frequencyInteger"] = "radioFrequencyAvailable"; - mapping["frequencyFraction"] = "radioFrequencyAvailable"; - mapping["rdsData"] = "rdsDataAvailable"; - mapping["availableHDs"] = "availableHDsAvailable"; - mapping["hdChannel"] = "availableHDsAvailable"; - mapping["hdRadioEnable"] = "hdRadioEnableAvailable"; - mapping["signalStrength"] = "signalStrengthAvailable"; - mapping["signalChangeThreshold"] = "signalChangeThresholdAvailable"; - mapping["radioEnable"] = "radioEnableAvailable"; - mapping["state"] = "stateAvailable"; - mapping["sisData"] = "sisDataAvailable"; - - // seat - mapping["heatingEnabled"] = "heatingEnabledAvailable"; - mapping["coolingEnabled"] = "coolingEnabledAvailable"; - mapping["heatingLevel"] = "heatingLevelAvailable"; - mapping["coolingLevel"] = "coolingLevelAvailable"; - mapping["horizontalPosition"] = "horizontalPositionAvailable"; - mapping["verticalPosition"] = "verticalPositionAvailable"; - mapping["frontVerticalPosition"] = "frontVerticalPositionAvailable"; - mapping["backVerticalPosition"] = "backVerticalPositionAvailable"; - mapping["backTiltAngle"] = "backTiltAngleAvailable"; - mapping["headSupportHorizontalPosition"] = - "headSupportHorizontalPositionAvailable"; - mapping["headSupportVerticalPosition"] = - "headSupportVerticalPositionAvailable"; - mapping["massageEnabled"] = "massageEnabledAvailable"; - mapping["massageMode"] = "massageModeAvailable"; - mapping["massageCushionFirmness"] = "massageCushionFirmnessAvailable"; - mapping["memory"] = "memoryAvailable"; - - // audio - mapping["source"] = "sourceAvailable"; - mapping["keepContext"] = "keepContextAvailable"; - mapping["volume"] = "volumeAvailable"; - mapping["equalizerSettings"] = "equalizerAvailable"; - - // hmi settings - mapping["distanceUnit"] = "distanceUnitAvailable"; - mapping["temperatureUnit"] = "temperatureUnitAvailable"; - mapping["displayMode"] = "displayModeUnitAvailable"; - - return mapping; -} -} // namespace - CREATE_LOGGERPTR_GLOBAL(logger_, "RemoteControlModule") SetInteriorVehicleDataRequest::SetInteriorVehicleDataRequest( @@ -150,250 +54,6 @@ SetInteriorVehicleDataRequest::SetInteriorVehicleDataRequest( SetInteriorVehicleDataRequest::~SetInteriorVehicleDataRequest() {} -const std::string LightName(const smart_objects::SmartObject& light_name) { - const char* name; - const bool ok = ns_smart_device_link::ns_smart_objects:: - EnumConversionHelper::EnumToCString( - static_cast(light_name.asUInt()), - &name); - return ok ? name : "unknown"; -} - -/** - * @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 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 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 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 std::make_pair("", capabilitiesStatus::success); -} - -/** - * @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_); - 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 GetLightDataCapabilities(so, light_data); - } - } - LOG4CXX_DEBUG(logger_, "There is no such light name in capabilities"); - return std::make_pair(message_params::kLightState, - capabilitiesStatus::missedLightName); -} - -ModuleCapability GetRadioBandByCapabilities( - 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 std::make_pair(strings::kSiriusxmRadioAvailable, - capabilitiesStatus::missedParam); - } - if (!capabilities_status[strings::kSiriusxmRadioAvailable].asBool()) { - LOG4CXX_DEBUG(logger_, - "Capability " - << strings::kSiriusxmRadioAvailable - << " is switched off in RemoteControl capabilities"); - return std::make_pair(strings::kSiriusxmRadioAvailable, - capabilitiesStatus::missedParam); - } - } - return std::make_pair("", capabilitiesStatus::success); -} - -/** - * @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(); - - 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) { - light_capability = GetLightNameCapabilities( - capabilities[strings::kSupportedLights], *light_data); - - if (capabilitiesStatus::success != light_capability.second) { - return light_capability; - } - } - - return light_capability; - } - if (message_params::kBand == request_parameter) { - ModuleCapability radio_capability = GetRadioBandByCapabilities( - capabilities, control_data[request_parameter]); - if (capabilitiesStatus::success != radio_capability.second) { - return radio_capability; - } - } - - const capabilitiesStatus status_item_capability = - GetItemCapability(capabilities, - mapping, - request_parameter, - mobile_apis::Result::UNSUPPORTED_RESOURCE); - - if (capabilitiesStatus::success != status_item_capability) { - return std::make_pair("", status_item_capability); - } - } - - return std::make_pair("", capabilitiesStatus::success); -} - -/** - * @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_); - - const auto& all_module_types = RCHelpers::GetModulesList(); - const auto& get_module_data_key = RCHelpers::GetModuleTypeToDataMapping(); - const auto& get_capabilities_key = - RCHelpers::GetModuleTypeToCapabilitiesMapping(); - ModuleCapability module_data_capabilities = - std::make_pair("", capabilitiesStatus::missedParam); - - 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 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) { - module_data_capabilities = - GetControlDataCapabilities(caps, module_data[module_data_key]); - } else { - module_data_capabilities = - GetControlDataCapabilities(caps[0], module_data[module_data_key]); - } - } - } - - return module_data_capabilities; -} - /** * @brief Clears unrelated module data parameters * @param module type in request @@ -403,7 +63,7 @@ ModuleCapability GetModuleDataCapabilities( bool ClearUnrelatedModuleData(const std::string& module_type, smart_objects::SmartObject& module_data) { LOG4CXX_AUTO_TRACE(logger_); - const auto& all_module_types = RCHelpers::GetModulesList(); + const auto& all_module_types = RCHelpers::GetModuleTypesList(); const auto& data_mapping = RCHelpers::GetModuleTypeToDataMapping(); bool module_type_and_data_match = false; for (const auto& type : all_module_types) { @@ -419,7 +79,7 @@ bool ClearUnrelatedModuleData(const std::string& module_type, } mobile_apis::Result::eType PrepareResultCodeAndInfo( - const ModuleCapability module_data_capabilities, std::string& info) { + const ModuleTypeCapability 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) { @@ -455,25 +115,35 @@ void SetInteriorVehicleDataRequest::Execute() { const std::string module_type = ModuleType(); if (ClearUnrelatedModuleData(module_type, module_data)) { - const smart_objects::SmartObject* rc_capabilities = - hmi_capabilities_.rc_capability(); - ModuleCapability module_data_capabilities; + const std::string module_id = ModuleId(); + const ModuleUid module(module_type, module_id); + if (!rc_capabilities_manager_.CheckIfModuleExistsInCapabilities(module)) { + LOG4CXX_WARN(logger_, + "Accessing not supported module: " << module_type << " " + << module_id); + SetResourceState(ModuleType(), ResourceState::FREE); + SendResponse(false, + mobile_apis::Result::UNSUPPORTED_RESOURCE, + "Accessing not supported module data"); + return; + } - if (rc_capabilities) { - module_data_capabilities = - GetModuleDataCapabilities(*rc_capabilities, module_data); + ModuleTypeCapability module_data_capabilities; + module_data_capabilities = + rc_capabilities_manager_.GetModuleDataCapabilities(module_data, + module_id); - 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 (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)) { + if (rc_capabilities_manager_.AreAllParamsReadOnly(module_data, + module_type)) { LOG4CXX_WARN(logger_, "All request params in module type are READ ONLY!"); SetResourceState(ModuleType(), ResourceState::FREE); SendResponse(false, @@ -484,7 +154,8 @@ void SetInteriorVehicleDataRequest::Execute() { module_data_capabilities = std::make_pair("", capabilitiesStatus::success); - if (AreReadOnlyParamsPresent(module_data, module_data_capabilities)) { + if (rc_capabilities_manager_.AreReadOnlyParamsPresent( + module_data, module_type, module_data_capabilities)) { LOG4CXX_DEBUG(logger_, "Request module type has READ ONLY parameters"); if (enums_value::kLight == module_data_capabilities.first && @@ -525,17 +196,20 @@ void SetInteriorVehicleDataRequest::Execute() { return; } else if (module_data[message_params::kAudioControlData].keyExists( message_params::kKeepContext)) { - app->set_keep_context( - module_data[message_params::kAudioControlData] - [message_params::kKeepContext].asBool()); + app->set_keep_context(module_data[message_params::kAudioControlData] + [message_params::kKeepContext] + .asBool()); } } + (*message_)[app_mngr::strings::msg_params][message_params::kModuleData] + [message_params::kModuleId] = module_id; SendHMIRequest(hmi_apis::FunctionID::RC_SetInteriorVehicleData, &(*message_)[app_mngr::strings::msg_params], true); } else { LOG4CXX_WARN(logger_, "Request module type & data mismatch!"); + SetResourceState(ModuleType(), ResourceState::FREE); SendResponse(false, mobile_apis::Result::INVALID_DATA, "Request module type & data mismatch!"); @@ -564,13 +238,45 @@ void SetInteriorVehicleDataRequest::on_event( mobile_apis::Result::WARNINGS); smart_objects::SmartObject response_params; + bool is_resource_acquired = false; + if (result) { + if (!IsModuleIdProvided(hmi_response)) { + LOG4CXX_WARN(logger_, + "conditional mandatory parameter " + << message_params::kModuleId + << " missed in hmi response"); + result = false; + result_code = mobile_apis::Result::GENERIC_ERROR; + } 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]); } + + const std::string module_type = ModuleType(); + const std::string module_id = ModuleId(); + + const rc_rpc_types::ModuleUid resource{module_type, module_id}; + auto app = application_manager_.application(connection_key()); + + if (!app) { + LOG4CXX_ERROR(logger_, "NULL pointer."); + SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED, ""); + return; + } + + const auto app_id = app->app_id(); + + if (!resource_allocation_manager_.IsResourceAlreadyAcquiredByApp(resource, + app_id)) { + resource_allocation_manager_.SetResourceAcquired( + module_type, module_id, app_id); + is_resource_acquired = true; + } + } else { app_mngr::ApplicationSharedPtr app = application_manager_.application(connection_key()); @@ -580,21 +286,12 @@ void SetInteriorVehicleDataRequest::on_event( GetInfo(hmi_response, info); SendResponse( result, result_code, info.c_str(), result ? &response_params : nullptr); -} - -const smart_objects::SmartObject& SetInteriorVehicleDataRequest::ControlData( - const smart_objects::SmartObject& module_data) { - const std::string module_type = ModuleType(); - 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)]; - } + if (is_resource_acquired) { + resource_allocation_manager_.SendOnRCStatusNotifications( + NotificationTrigger::MODULE_ALLOCATION, + std::shared_ptr()); } - NOTREACHED(); - return module_data[0]; } void SetInteriorVehicleDataRequest::CheckAudioSource( @@ -606,131 +303,12 @@ void SetInteriorVehicleDataRequest::CheckAudioSource( } } -bool SetInteriorVehicleDataRequest::AreAllParamsReadOnly( - 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()); - for (; it != module_type_params.map_end(); ++it) { - if (!helpers::in_range(ro_params, it->first)) { - return false; - } - } - - LOG4CXX_DEBUG(logger_, "All params are ReadOnly"); - 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. 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, - ModuleCapability& module_data_capabilities) { - LOG4CXX_AUTO_TRACE(logger_); - const smart_objects::SmartObject& module_type_params = - ControlData(module_data); - const std::string module_type = ModuleType(); - - 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; -} - void SetInteriorVehicleDataRequest::CutOffReadOnlyParams( smart_objects::SmartObject& module_data) { LOG4CXX_AUTO_TRACE(logger_); - const smart_objects::SmartObject& module_type_params = - ControlData(module_data); const std::string module_type = ModuleType(); - std::vector ro_params = GetModuleReadOnlyParams(module_type); - - for (auto& it : ro_params) { - if (module_type_params.keyExists(it)) { - if (enums_value::kClimate == module_type) { - module_data[message_params::kClimateControlData].erase(it); - } else if (enums_value::kRadio == module_type) { - module_data[message_params::kRadioControlData].erase(it); - } else { - continue; - } - - LOG4CXX_DEBUG(logger_, "Cutting-off READ ONLY parameter: " << it); - } - } + const auto& module_type_params = + rc_capabilities_manager_.ControlDataForType(module_data, module_type); if (enums_value::kAudio == module_type) { auto& equalizer_settings = module_data[message_params::kAudioControlData] @@ -745,9 +323,20 @@ void SetInteriorVehicleDataRequest::CutOffReadOnlyParams( } } } + + std::vector ro_params = + RCHelpers::GetModuleReadOnlyParams(module_type); + const auto& data_mapping = RCHelpers::GetModuleTypeToDataMapping(); + for (const auto& param : ro_params) { + if (module_type_params.keyExists(param)) { + module_data[data_mapping(module_type)].erase(param); + LOG4CXX_DEBUG(logger_, "Cutting-off READ ONLY parameter: " << param); + } + } } -std::string SetInteriorVehicleDataRequest::ModuleType() { +std::string SetInteriorVehicleDataRequest::ModuleType() const { + LOG4CXX_AUTO_TRACE(logger_); mobile_apis::ModuleType::eType module_type = static_cast( (*message_)[app_mngr::strings::msg_params] @@ -759,19 +348,40 @@ std::string SetInteriorVehicleDataRequest::ModuleType() { return ok ? str : "unknown"; } +std::string SetInteriorVehicleDataRequest::ModuleId() const { + LOG4CXX_AUTO_TRACE(logger_); + auto msg_params = (*message_)[app_mngr::strings::msg_params]; + if (msg_params[message_params::kModuleData].keyExists( + message_params::kModuleId)) { + return msg_params[message_params::kModuleData][message_params::kModuleId] + .asString(); + } + if (enums_value::kSeat == ModuleType()) { + const auto id = static_cast( + msg_params[message_params::kModuleData] + [message_params::kSeatControlData][message_params::kId] + .asUInt()); + return rc_capabilities_manager_.GetModuleIdForSeatLocation(id); + } + const std::string module_id = + rc_capabilities_manager_.GetDefaultModuleIdFromCapabilities(ModuleType()); + return module_id; +} + AcquireResult::eType SetInteriorVehicleDataRequest::AcquireResource( const app_mngr::commands::MessageSharedPtr& message) { LOG4CXX_AUTO_TRACE(logger_); const std::string module_type = ModuleType(); app_mngr::ApplicationSharedPtr app = application_manager_.application(CommandRequestImpl::connection_key()); - return resource_allocation_manager_.AcquireResource(module_type, - app->app_id()); + + return resource_allocation_manager_.AcquireResource( + module_type, ModuleId(), app->app_id()); } bool SetInteriorVehicleDataRequest::IsResourceFree( - const std::string& module_type) const { - return resource_allocation_manager_.IsResourceFree(module_type); + const std::string& module_type, const std::string& module_id) const { + return resource_allocation_manager_.IsResourceFree(module_type, module_id); } void SetInteriorVehicleDataRequest::SetResourceState( @@ -780,7 +390,7 @@ void SetInteriorVehicleDataRequest::SetResourceState( app_mngr::ApplicationSharedPtr app = application_manager_.application(CommandRequestImpl::connection_key()); resource_allocation_manager_.SetResourceState( - module_type, app->app_id(), state); + module_type, ModuleId(), app->app_id(), state); } } // namespace commands 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 c24529d7200..885c5ac0ddd 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 @@ -31,11 +31,15 @@ */ #include "rc_rpc_plugin/commands/rc_command_request.h" -#include "rc_rpc_plugin/rc_module_constants.h" -#include "application_manager/message_helper.h" +#include #include "application_manager/hmi_interfaces.h" -#include "smart_objects/enum_schema_item.h" +#include "application_manager/message_helper.h" +#include "application_manager/policies/policy_handler_interface.h" +#include "rc_rpc_plugin/commands/rc_command_request.h" #include "rc_rpc_plugin/interior_data_cache.h" +#include "rc_rpc_plugin/rc_helpers.h" +#include "rc_rpc_plugin/rc_module_constants.h" +#include "smart_objects/enum_schema_item.h" CREATE_LOGGERPTR_GLOBAL(logger_, "RemoteControlModule") @@ -55,7 +59,9 @@ RCCommandRequest::RCCommandRequest( , auto_allowed_(false) , resource_allocation_manager_(params.resource_allocation_manager_) , interior_data_cache_(params.interior_data_cache_) - , interior_data_manager_(params.interior_data_manager_) {} + , interior_data_manager_(params.interior_data_manager_) + , rc_capabilities_manager_(params.rc_capabilities_manager_) + , rc_consent_manager_(params.rc_consent_manager_) {} RCCommandRequest::~RCCommandRequest() {} @@ -100,6 +106,14 @@ rc_rpc_plugin::TypeAccess RCCommandRequest::CheckModule( : rc_rpc_plugin::TypeAccess::kDisallowed; } +bool RCCommandRequest::IsModuleIdProvided( + const smart_objects::SmartObject& hmi_response) const { + LOG4CXX_AUTO_TRACE(logger_); + return hmi_response[app_mngr::strings::msg_params] + [message_params::kModuleData] + .keyExists(message_params::kModuleId); +} + void RCCommandRequest::SendDisallowed(rc_rpc_plugin::TypeAccess access) { LOG4CXX_AUTO_TRACE(logger_); std::string info; @@ -143,6 +157,15 @@ void RCCommandRequest::Run() { "Remote control is disabled by user"); return; } + auto rc_capabilities = hmi_capabilities_.rc_capability(); + if (!rc_capabilities || rc_capabilities->empty()) { + LOG4CXX_WARN(logger_, "Accessing not supported module: " << ModuleType()); + SetResourceState(ModuleType(), ResourceState::FREE); + SendResponse(false, + mobile_apis::Result::UNSUPPORTED_RESOURCE, + "Accessing not supported module"); + return; + } if (CheckDriverConsent()) { if (AcquireResources()) { @@ -157,8 +180,9 @@ void RCCommandRequest::Run() { bool RCCommandRequest::AcquireResources() { LOG4CXX_AUTO_TRACE(logger_); const std::string module_type = ModuleType(); + const std::string module_id = ModuleId(); - if (!IsResourceFree(module_type)) { + if (!IsResourceFree(module_type, module_id)) { LOG4CXX_WARN(logger_, "Resource is busy."); SendResponse(false, mobile_apis::Result::IN_USE, ""); return false; @@ -175,7 +199,7 @@ bool RCCommandRequest::AcquireResources() { return false; } case AcquireResult::ASK_DRIVER: { - SendGetUserConsent(module_type); + ProcessAskDriverMode(module_type, module_id); return false; } case AcquireResult::REJECTED: { @@ -203,6 +227,7 @@ void RCCommandRequest::ProcessAccessResponse( app_mngr::ApplicationSharedPtr app = application_manager_.application(CommandRequestImpl::connection_key()); const std::string module_type = ModuleType(); + const std::string module_id = ModuleId(); if (!app) { LOG4CXX_ERROR(logger_, "NULL pointer."); SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED, ""); @@ -227,23 +252,18 @@ void RCCommandRequest::ProcessAccessResponse( if (message[app_mngr::strings::msg_params].keyExists( message_params::kAllowed)) { is_allowed = - message[app_mngr::strings::msg_params][message_params::kAllowed] + message[app_mngr::strings::msg_params][message_params::kAllowed][0] .asBool(); } - if (is_allowed) { - resource_allocation_manager_.ForceAcquireResource(module_type, - app->app_id()); - SetResourceState(module_type, ResourceState::BUSY); - Execute(); // run child's logic - } else { - resource_allocation_manager_.OnDriverDisallowed(module_type, - app->app_id()); - SendResponse( - false, - mobile_apis::Result::REJECTED, - "The resource is in use and the driver disallows this remote " - "control RPC"); - } + std::string policy_app_id = app->policy_app_id(); + const auto mac_address = app->mac_address(); + std::vector module_ids{module_id}; + std::vector module_allowed{is_allowed}; + auto module_consents = + RCHelpers::FillModuleConsents(module_type, module_ids, module_allowed); + rc_consent_manager_.SaveModuleConsents( + policy_app_id, mac_address, module_consents); + ProcessConsentResult(is_allowed, module_type, module_id, app->app_id()); } else { std::string response_info; GetInfo(message, response_info); @@ -251,7 +271,56 @@ void RCCommandRequest::ProcessAccessResponse( } } -void RCCommandRequest::SendGetUserConsent(const std::string& module_type) { +void RCCommandRequest::ProcessConsentResult(const bool is_allowed, + const std::string& module_type, + const std::string& module_id, + const uint32_t app_id) { + LOG4CXX_AUTO_TRACE(logger_); + if (is_allowed) { + SetResourceState(module_type, ResourceState::BUSY); + Execute(); // run child's logic + } else { + resource_allocation_manager_.OnDriverDisallowed( + module_type, module_id, app_id); + + std::stringstream ss; + ss << "The resource [" << module_type << ":" << module_id + << "] is in use and the driver disallows this remote " + "control RPC"; + SendResponse(false, mobile_apis::Result::REJECTED, ss.str().c_str()); + } +} + +void RCCommandRequest::ProcessAskDriverMode(const std::string& module_type, + const std::string& module_id) { + LOG4CXX_AUTO_TRACE(logger_); + auto app = + application_manager_.application(CommandRequestImpl::connection_key()); + const std::string policy_app_id = app->policy_app_id(); + const std::string mac_address = app->mac_address(); + + auto consent = rc_consent_manager_.GetModuleConsent( + policy_app_id, mac_address, {module_type, module_id}); + switch (consent) { + case rc_rpc_types::ModuleConsent::NOT_EXISTS: { + smart_objects::SmartObject module_ids( + smart_objects::SmartType::SmartType_Array); + module_ids[0] = module_id; + SendGetUserConsent(module_type, module_ids); + break; + } + case rc_rpc_types::ModuleConsent::NOT_CONSENTED: + case rc_rpc_types::ModuleConsent::CONSENTED: { + const bool is_allowed = rc_rpc_types::ModuleConsent::CONSENTED == consent; + ProcessConsentResult(is_allowed, module_type, module_id, app->app_id()); + break; + } + }; +} + +void RCCommandRequest::SendGetUserConsent( + const std::string& module_type, + const smart_objects::SmartObject& module_ids) { LOG4CXX_AUTO_TRACE(logger_); app_mngr::ApplicationSharedPtr app = application_manager_.application(CommandRequestImpl::connection_key()); @@ -260,9 +329,11 @@ void RCCommandRequest::SendGetUserConsent(const std::string& module_type) { smart_objects::SmartObject(smart_objects::SmartType_Map); msg_params[app_mngr::strings::app_id] = app->app_id(); msg_params[message_params::kModuleType] = module_type; + msg_params[message_params::kModuleIds] = module_ids; + SendHMIRequest(hmi_apis::FunctionID::RC_GetInteriorVehicleDataConsent, &msg_params, true); } -} -} +} // namespace commands +} // namespace rc_rpc_plugin 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 index 780aab537b3..3e50818210e 100644 --- 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 @@ -30,11 +30,12 @@ * POSSIBILITY OF SUCH DAMAGE. */ +#include "rc_rpc_plugin/interior_data_cache_impl.h" +#include #include #include -#include -#include "rc_rpc_plugin/interior_data_cache_impl.h" #include "application_manager/smart_object_keys.h" +#include "rc_rpc_plugin/rc_helpers.h" #include "utils/date_time.h" #include "utils/logger.h" @@ -46,139 +47,72 @@ InteriorDataCacheImpl::InteriorDataCacheImpl() {} InteriorDataCacheImpl::~InteriorDataCacheImpl() {} -/** - * @brief MergeModuleData 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); - -/** - * @brief MergeArray merge two arrays if their elements contain an `id` - * parameter - * @param data1 - initial data - * @param data2 - updated data - * @return updated data1 with any values in data2 if the arrays can be merged, - * otherwise data2 - */ -smart_objects::SmartObject MergeArray(const smart_objects::SmartObject& data1, - const smart_objects::SmartObject& data2); - -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; - smart_objects::SmartObject& value = it->second; - if (!result.keyExists(key) || value.getType() != result[key].getType()) { - result[key] = value; - continue; - } - - // Merge maps and arrays with `id` param included, replace other types - if (value.getType() == smart_objects::SmartType::SmartType_Map) { - value = MergeModuleData(result[key], value); - } else if (value.getType() == smart_objects::SmartType::SmartType_Array) { - value = MergeArray(result[key], value); - } - result[key] = value; - } - return result; -} - -smart_objects::SmartObject MergeArray(const smart_objects::SmartObject& data1, - const smart_objects::SmartObject& data2) { - // Merge data only in the case where each value in the array is an Object with - // an ID included, otherwise replace - bool array_contains_objects = - !data2.empty() && - data2.getElement(0).getType() != smart_objects::SmartType::SmartType_Map; - bool can_merge_arrays = - array_contains_objects && - data2.getElement(0).keyExists(application_manager::strings::id); - if (!can_merge_arrays) { - return data2; - } - - smart_objects::SmartObject result = data1; - smart_objects::SmartArray* result_array = result.asArray(); - smart_objects::SmartArray* data_array = data2.asArray(); - auto data_it = data_array->begin(); - auto find_by_id = - [](smart_objects::SmartArray* array, const smart_objects::SmartObject& id) - -> smart_objects::SmartArray::iterator { - auto it = std::find_if( - array->begin(), - array->end(), - [&id](smart_objects::SmartObject& obj) -> bool { - return obj[application_manager::strings::id] == id; - }); - return it; - }; - - for (; data_it != data_array->end(); ++data_it) { - const smart_objects::SmartObject element_id = - (*data_it)[application_manager::strings::id]; - auto result_it = find_by_id(result_array, element_id); - - if (result_it != result_array->end()) { - *result_it = MergeModuleData(*result_it, *data_it); - } else { - result_array->push_back(*data_it); - } - } - return result; -} - -void InteriorDataCacheImpl::Add(const std::string& module_type, +void InteriorDataCacheImpl::Add(const ModuleUid& module, const smart_objects::SmartObject& module_data) { - LOG4CXX_TRACE(logger_, "module_type : " << module_type); + LOG4CXX_TRACE( + logger_, + "module_type : " << module.first << " module_id : " << module.second); sync_primitives::AutoLock autolock(cached_data_lock_); - auto it = cached_data_.find(module_type); + auto it = cached_data_.find(module); if (cached_data_.end() == it) { - cached_data_[module_type] = module_data; + cached_data_[module] = module_data; return; } - cached_data_[module_type] = MergeModuleData(it->second, module_data); + cached_data_[module] = RCHelpers::MergeModuleData(it->second, module_data); } smart_objects::SmartObject InteriorDataCacheImpl::Retrieve( - const std::string& module_type) const { + const ModuleUid& module) const { LOG4CXX_AUTO_TRACE(logger_); sync_primitives::AutoLock autolock(cached_data_lock_); - auto it = cached_data_.find(module_type); + auto it = cached_data_.find(module); if (it == cached_data_.end()) { LOG4CXX_WARN(logger_, - "Module type " << module_type << " was not found in cache"); + "Module with type: " << module.first + << " and id: " << module.second + << " was not found in cache"); return smart_objects::SmartObject(smart_objects::SmartType_Null); } - LOG4CXX_TRACE(logger_, "module_type : " << module_type); + LOG4CXX_TRACE( + logger_, + "module_type : " << module.first << " module_id : " << module.second); return it->second; } -bool InteriorDataCacheImpl::Contains(const std::string& module_type) const { +std::vector InteriorDataCacheImpl::GetCachedModulesByType( + const std::string& module_type) const { + std::vector modules; + for (auto& item : cached_data_) { + auto& module = item.first; + if (module_type == module.first) { + modules.push_back(module); + } + } + return modules; +} + +bool InteriorDataCacheImpl::Contains(const ModuleUid& module) const { LOG4CXX_AUTO_TRACE(logger_); sync_primitives::AutoLock autolock(cached_data_lock_); - auto it = cached_data_.find(module_type); + auto it = cached_data_.find(module); const bool contains = it != cached_data_.end(); LOG4CXX_TRACE(logger_, - "module_type : " << module_type << " " + "module_type : " << module.first + << " module_id : " << module.second << " " << (contains ? "true" : "false")); return contains; } -void InteriorDataCacheImpl::Remove(const std::string& module_type) { - LOG4CXX_TRACE(logger_, "module_type : " << module_type); +void InteriorDataCacheImpl::Remove(const ModuleUid& module) { + LOG4CXX_TRACE( + logger_, + "module_type : " << module.first << " module_id : " << module.second); sync_primitives::AutoLock autolock(cached_data_lock_); - auto it = cached_data_.find(module_type); + auto it = cached_data_.find(module); if (cached_data_.end() == it) { - LOG4CXX_TRACE(logger_, "Not existing module_type : " << module_type); + LOG4CXX_TRACE( + logger_, + "Not existing module : " << module.first << " " << module.second); return; } cached_data_.erase(it); @@ -189,4 +123,4 @@ void InteriorDataCacheImpl::Clear() { sync_primitives::AutoLock autolock(cached_data_lock_); cached_data_.clear(); } -} +} // namespace rc_rpc_plugin 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 0c42f6e3de4..50568de63a3 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 @@ -1,8 +1,8 @@ #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" +#include "rc_rpc_plugin/rc_helpers.h" +#include "rc_rpc_plugin/rc_rpc_plugin.h" namespace rc_rpc_plugin { CREATE_LOGGERPTR_GLOBAL(logger_, "RemoteControlModule"); @@ -33,7 +33,7 @@ void InteriorDataManagerImpl::OnApplicationEvent( void InteriorDataManagerImpl::OnDisablingRC() { LOG4CXX_AUTO_TRACE(logger_); auto existing_subscription = AppsSubscribedModules(); - std::set subscribed_modules; + std::set subscribed_modules; for (auto& pair : existing_subscription) { auto& app = pair.first; auto rc_extension = RCHelpers::GetRCExtension(*app); @@ -43,36 +43,37 @@ void InteriorDataManagerImpl::OnDisablingRC() { } } for (auto& module : subscribed_modules) { - LOG4CXX_TRACE(logger_, "unsubscribe " << module); + LOG4CXX_TRACE(logger_, + "unsubscribe from module type: " << module.first + << " id: " << module.second); UnsubscribeFromInteriorVehicleData(module); } } -void InteriorDataManagerImpl::StoreRequestToHMITime( - const std::string& module_type) { +void InteriorDataManagerImpl::StoreRequestToHMITime(const ModuleUid& module) { LOG4CXX_AUTO_TRACE(logger_); sync_primitives::AutoLock autolock(requests_to_hmi_history_lock_); - requests_to_hmi_history_[module_type].push_back(date_time::getCurrentTime()); + requests_to_hmi_history_[module].push_back(date_time::getCurrentTime()); } bool InteriorDataManagerImpl::CheckRequestsToHMIFrequency( - const std::string& module_type) { + const ModuleUid& module) { 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& history = requests_to_hmi_history_[module]; 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::GetApplicationsAllowedModules(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 apps_allowed_module_types = + RCHelpers::GetApplicationsAllowedModuleTypes(app_mngr_); + auto apps_subscribed_module_types = AppsSubscribedModuleTypes(); + InteriorDataManagerImpl::AppsModuleTypes apps_disallowed_modules; + for (auto& pair : apps_subscribed_module_types) { + auto& allowed = apps_allowed_module_types[pair.first]; auto& subscribed = pair.second; std::vector disallowed_modules; std::set_difference(subscribed.begin(), @@ -80,18 +81,25 @@ void InteriorDataManagerImpl::UpdateHMISubscriptionsOnPolicyUpdated() { allowed.begin(), allowed.end(), std::back_inserter(disallowed_modules)); + + std::sort(disallowed_modules.begin(), disallowed_modules.end()); + + auto unique_result = + std::unique(disallowed_modules.begin(), disallowed_modules.end()); + + disallowed_modules.erase(unique_result, disallowed_modules.end()); 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); + for (const auto& module_type : pair.second) { + rc_extension->UnsubscribeFromInteriorVehicleDataOfType(module_type); auto apps_subscribed = - RCHelpers::AppsSubscribedToModuleType(app_mngr_, module); + RCHelpers::AppsSubscribedToModuleType(app_mngr_, module_type); if (apps_subscribed.empty()) { - UnsubscribeFromInteriorVehicleData(module); + UnsubscribeFromInteriorVehicleDataOfType(module_type); } } } @@ -104,8 +112,7 @@ void InteriorDataManagerImpl::UpdateHMISubscriptionsOnAppUnregistered( auto subscribed_data = rc_extension->InteriorVehicleDataSubscriptions(); rc_extension->UnsubscribeFromInteriorVehicleData(); for (auto& data : subscribed_data) { - auto apps_subscribed = - RCHelpers::AppsSubscribedToModuleType(app_mngr_, data); + auto apps_subscribed = RCHelpers::AppsSubscribedToModule(app_mngr_, data); if (apps_subscribed.empty()) { UnsubscribeFromInteriorVehicleData(data); } @@ -117,14 +124,31 @@ void InteriorDataManagerImpl::UpdateHMISubscriptionsOnAppUnregistered( } void InteriorDataManagerImpl::UnsubscribeFromInteriorVehicleData( - const std::string& module_type) { - cache_.Remove(module_type); + const ModuleUid& module) { + cache_.Remove(module); auto unsubscribe_request = RCHelpers::CreateUnsubscribeRequestToHMI( - module_type, app_mngr_.GetNextHMICorrelationID()); - LOG4CXX_DEBUG(logger_, "Send Unsubscribe from " << module_type); + module, app_mngr_.GetNextHMICorrelationID()); + LOG4CXX_DEBUG(logger_, + "Send Unsubscribe from module type: " << module.first << " id: " + << module.second); rpc_service_.ManageHMICommand(unsubscribe_request); } +void InteriorDataManagerImpl::UnsubscribeFromInteriorVehicleDataOfType( + const std::string& module_type) { + const auto& modules = cache_.GetCachedModulesByType(module_type); + + for (const auto& module : modules) { + cache_.Remove(module); + auto unsubscribe_request = RCHelpers::CreateUnsubscribeRequestToHMI( + module, app_mngr_.GetNextHMICorrelationID()); + LOG4CXX_DEBUG(logger_, + "Send Unsubscribe from module type: " + << module.first << " id: " << module.second); + rpc_service_.ManageHMICommand(unsubscribe_request); + } +} + void InteriorDataManagerImpl::ClearOldRequestsToHMIHistory() { auto limit = app_mngr_.get_settings().get_interior_vehicle_data_frequency().second; @@ -148,11 +172,30 @@ InteriorDataManagerImpl::AppsSubscribedModules() { 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()); + result[app_ptr] = std::vector(app_subscriptions.size()); std::copy(app_subscriptions.begin(), app_subscriptions.end(), result[app_ptr].begin()); } return result; } + +InteriorDataManagerImpl::AppsModuleTypes +InteriorDataManagerImpl::AppsSubscribedModuleTypes() { + auto apps_list = RCRPCPlugin::GetRCApplications(app_mngr_); + RCHelpers::AppsModuleTypes result; + for (auto& app_ptr : apps_list) { + const auto rc_extension = RCHelpers::GetRCExtension(*app_ptr); + auto app_subscriptions = rc_extension->InteriorVehicleDataSubscriptions(); + std::vector app_module_types; + + for (auto& app_subscription : app_subscriptions) { + app_module_types.push_back(app_subscription.first); + } + + std::sort(app_module_types.begin(), app_module_types.end()); + result[app_ptr] = app_module_types; + } + return result; +} } // namespace rc_rpc_plugin 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 5282da8d839..ea9c13113c1 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 @@ -31,29 +31,51 @@ */ #include "rc_rpc_plugin/rc_app_extension.h" +#include +#include "rc_rpc_plugin/rc_module_constants.h" +#include "smart_objects/smart_object.h" namespace rc_rpc_plugin { RCAppExtension::RCAppExtension(application_manager::AppExtensionUID uid) : AppExtension(uid) {} -void RCAppExtension::SubscribeToInteriorVehicleData( - const std::string& module_type) { - subscribed_interior_vehicle_data_.insert(module_type); +void RCAppExtension::SubscribeToInteriorVehicleData(const ModuleUid& module) { + subscribed_interior_vehicle_data_.insert(module); } void RCAppExtension::UnsubscribeFromInteriorVehicleData( + const ModuleUid& module) { + subscribed_interior_vehicle_data_.erase(module); +} + +void RCAppExtension::UnsubscribeFromInteriorVehicleDataOfType( const std::string& module_type) { - subscribed_interior_vehicle_data_.erase(module_type); + for (auto& item : subscribed_interior_vehicle_data_) { + if (module_type == item.first) { + subscribed_interior_vehicle_data_.erase(item); + } + } } void RCAppExtension::UnsubscribeFromInteriorVehicleData() { subscribed_interior_vehicle_data_.clear(); } -bool RCAppExtension::IsSubscibedToInteriorVehicleData( +bool RCAppExtension::IsSubscribedToInteriorVehicleDataOfType( const std::string& module_type) { - std::set::iterator it = - subscribed_interior_vehicle_data_.find(module_type); + auto it = std::find_if(subscribed_interior_vehicle_data_.begin(), + subscribed_interior_vehicle_data_.end(), + [&module_type](ModuleUid module) -> bool { + return module_type == module.first; + }); + + return (it != subscribed_interior_vehicle_data_.end()); +} + +bool RCAppExtension::IsSubscribedToInteriorVehicleData( + const ModuleUid& module) { + std::set::iterator it = + subscribed_interior_vehicle_data_.find(module); return (it != subscribed_interior_vehicle_data_.end()); } @@ -65,9 +87,29 @@ void RCAppExtension::ProcessResumption( const ns_smart_device_link::ns_smart_objects::SmartObject& resumption_data) {} -std::set RCAppExtension::InteriorVehicleDataSubscriptions() const { +std::set RCAppExtension::InteriorVehicleDataSubscriptions() const { return subscribed_interior_vehicle_data_; } +Grid RCAppExtension::GetUserLocation() const { + return user_location_; +} + +void RCAppExtension::SetUserLocation( + const ns_smart_device_link::ns_smart_objects::SmartObject& user_location) { + const auto grid = user_location[strings::kGrid]; + const int32_t col = grid[strings::kCol].asInt(); + const int32_t row = grid[strings::kRow].asInt(); + const int32_t level = grid[strings::kLevel].asInt(); + const int32_t colspan = grid[strings::kColspan].asInt(); + const int32_t rowspan = grid[strings::kRowspan].asInt(); + const int32_t levelspan = grid[strings::kLevelspan].asInt(); + user_location_ = Grid(col, row, level, colspan, rowspan, levelspan); +} + +void RCAppExtension::SetUserLocation(const Grid& grid) { + user_location_ = grid; +} + RCAppExtension::~RCAppExtension() {} } // namespace rc_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/rc_capabilities_manager_impl.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/rc_capabilities_manager_impl.cc new file mode 100644 index 00000000000..dbedd0167fa --- /dev/null +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/rc_capabilities_manager_impl.cc @@ -0,0 +1,925 @@ +/* + Copyright (c) 2019, 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 copyright holders nor the names of their contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + */ + +#include "rc_rpc_plugin/rc_capabilities_manager_impl.h" +#include "rc_rpc_plugin/rc_helpers.h" +#include "rc_rpc_plugin/rc_module_constants.h" + +namespace rc_rpc_plugin { +CREATE_LOGGERPTR_GLOBAL(logger_, "RemoteControlModule") + +RCCapabilitiesManagerImpl::RCCapabilitiesManagerImpl( + application_manager::HMICapabilities& hmi_capabilities) + : hmi_capabilities_(hmi_capabilities) {} + +const std::string +RCCapabilitiesManagerImpl::GetDefaultModuleIdFromCapabilitiesStructure( + const smart_objects::SmartObject& control_capabilities, + const std::string& module_type) const { + LOG4CXX_AUTO_TRACE(logger_); + if (control_capabilities.keyExists(message_params::kModuleInfo)) { + // moduleId - mandatory param for ModuleInfo structure + const auto module_id = control_capabilities[message_params::kModuleInfo] + [message_params::kModuleId] + .asString(); + LOG4CXX_WARN(logger_, + "Use default moduleId from hmi capabilities: " + << module_id + << " for requested moduleType: " << module_type); + return module_id; + } + LOG4CXX_WARN(logger_, + "There are no moduleInfo in hmi capabilities for requested " + "moduleType " + << module_type); + return ""; +} + +const std::string +RCCapabilitiesManagerImpl::GetDefaultModuleIdFromCapabilitiesArray( + const smart_objects::SmartObject& control_capabilities, + const std::string& module_type) const { + LOG4CXX_AUTO_TRACE(logger_); + for (auto& cap_item : *(control_capabilities.asArray())) { + if (cap_item.keyExists(message_params::kModuleInfo)) { + // moduleId - mandatory param for ModuleInfo structure + const auto module_id = + cap_item[message_params::kModuleInfo][message_params::kModuleId] + .asString(); + LOG4CXX_WARN(logger_, + "Use default moduleId from hmi capabilities: " + << module_id + << " for requested moduleType: " << module_type); + return module_id; + } + } + LOG4CXX_WARN(logger_, + "There are no moduleInfo in hmi capabilities for requested " + "moduleType " + << module_type); + return ""; +} + +const std::string RCCapabilitiesManagerImpl::GetDefaultModuleIdFromCapabilities( + const std::string& module_type) const { + LOG4CXX_AUTO_TRACE(logger_); + auto rc_capabilities = *(hmi_capabilities_.rc_capability()); + const auto& mapping = RCHelpers::GetModuleTypeToCapabilitiesMapping(); + if (!rc_capabilities.keyExists(mapping(module_type))) { + LOG4CXX_WARN( + logger_, + "There is no RC capability for requested module_type " << module_type); + return ""; + } + if (enums_value::kHmiSettings == module_type || + enums_value::kLight == module_type) { + return GetDefaultModuleIdFromCapabilitiesStructure( + rc_capabilities[mapping(module_type)], module_type); + } + return GetDefaultModuleIdFromCapabilitiesArray( + rc_capabilities[mapping(module_type)], module_type); +} + +const bool RCCapabilitiesManagerImpl::CheckModuleIdWithCapabilitiesStructure( + const smart_objects::SmartObject& control_capabilities, + const std::string& module_id) const { + LOG4CXX_AUTO_TRACE(logger_); + if (control_capabilities.keyExists(message_params::kModuleInfo) && + (module_id == control_capabilities[message_params::kModuleInfo] + [message_params::kModuleId] + .asString())) { + return true; + } + LOG4CXX_WARN(logger_, + "There are no moduleInfo in hmi capabilities for requested " + "moduleId " + << module_id); + return false; +} + +const bool RCCapabilitiesManagerImpl::CheckModuleIdWithCapabilitiesArrays( + const smart_objects::SmartObject& control_capabilities, + const std::string& module_id) const { + LOG4CXX_AUTO_TRACE(logger_); + for (auto& cap_item : *(control_capabilities.asArray())) { + if (cap_item.keyExists(message_params::kModuleInfo) && + (module_id == + cap_item[message_params::kModuleInfo][message_params::kModuleId] + .asString())) { + return true; + } + } + LOG4CXX_WARN(logger_, + "There are no moduleInfo in hmi capabilities for requested " + "moduleId " + << module_id); + return false; +} + +const bool RCCapabilitiesManagerImpl::CheckModuleIdWithCapabilities( + const smart_objects::SmartObject& rc_capabilities, + const ModuleUid& module) const { + LOG4CXX_AUTO_TRACE(logger_); + if (module.second.empty()) { + return true; + } + const auto& mapping = RCHelpers::GetModuleTypeToCapabilitiesMapping(); + if (enums_value::kHmiSettings == module.first || + enums_value::kLight == module.first) { + return CheckModuleIdWithCapabilitiesStructure( + rc_capabilities[mapping(module.first)], module.second); + } + return CheckModuleIdWithCapabilitiesArrays( + rc_capabilities[mapping(module.first)], module.second); +} + +bool RCCapabilitiesManagerImpl::CheckIfModuleExistsInCapabilities( + const ModuleUid& module) const { + LOG4CXX_AUTO_TRACE(logger_); + auto rc_capabilities = *(hmi_capabilities_.rc_capability()); + const auto& mapping = RCHelpers::GetModuleTypeToCapabilitiesMapping(); + const auto& resource_list = GetResources(); + bool is_module_type_valid = false; + for (const auto& resource : resource_list) { + if (resource.first == module.first) { + if (rc_capabilities.keyExists(mapping(module.first)) && + CheckModuleIdWithCapabilities(rc_capabilities, module)) { + is_module_type_valid = true; + break; + } + } + } + return is_module_type_valid; +} + +const std::vector RCCapabilitiesManagerImpl::GetCapabilitiesList() + const { + using namespace enums_value; + return {strings::kclimateControlCapabilities, + strings::kradioControlCapabilities, + strings::kseatControlCapabilities, + strings::kaudioControlCapabilities, + strings::klightControlCapabilities, + strings::khmiSettingsControlCapabilities}; +} + +const std::function +RCCapabilitiesManagerImpl::GetCapabilitiesToModuleTypeMapping() const { + auto mapping_lambda = [](const std::string& control_cap) -> std::string { + static std::map mapping = { + {strings::kclimateControlCapabilities, enums_value::kClimate}, + {strings::kradioControlCapabilities, enums_value::kRadio}, + {strings::kseatControlCapabilities, enums_value::kSeat}, + {strings::kaudioControlCapabilities, enums_value::kAudio}, + {strings::klightControlCapabilities, enums_value::kLight}, + {strings::khmiSettingsControlCapabilities, enums_value::kHmiSettings}}; + auto it = mapping.find(control_cap); + if (mapping.end() == it) { + LOG4CXX_ERROR(logger_, "Unknown control capability " << control_cap); + return std::string(); + } + return it->second; + }; + + return mapping_lambda; +} + +void RCCapabilitiesManagerImpl::GetResourcesFromCapabilitiesStructure( + const smart_objects::SmartObject& control_capabilities, + const std::string& capability_key, + std::vector& out_resources) const { + const auto& mapping = GetCapabilitiesToModuleTypeMapping(); + if (control_capabilities.keyExists(message_params::kModuleInfo)) { + std::string module_id = control_capabilities[message_params::kModuleInfo] + [message_params::kModuleId] + .asString(); + out_resources.push_back(std::make_pair(mapping(capability_key), module_id)); + } else { + LOG4CXX_WARN(logger_, "There are no moduleId in " << capability_key); + out_resources.push_back(std::make_pair(mapping(capability_key), "")); + } +} + +void RCCapabilitiesManagerImpl::GetResourcesFromCapabilitiesArray( + const smart_objects::SmartObject& control_capabilities, + const std::string& capability_key, + std::vector& out_resources) const { + const auto& mapping = GetCapabilitiesToModuleTypeMapping(); + for (auto cap_item : *(control_capabilities.asArray())) { + if (cap_item.keyExists(message_params::kModuleInfo)) { + std::string module_id = + cap_item[message_params::kModuleInfo][message_params::kModuleId] + .asString(); + out_resources.push_back( + std::make_pair(mapping(capability_key), module_id)); + } else { + LOG4CXX_WARN(logger_, + "There are no moduleId for item from " << capability_key); + out_resources.push_back(std::make_pair(mapping(capability_key), "")); + } + } +} + +const std::vector RCCapabilitiesManagerImpl::GetResources() const { + LOG4CXX_AUTO_TRACE(logger_); + std::vector resources; + auto rc_capabilities = *(hmi_capabilities_.rc_capability()); + const auto& control_caps_list = GetCapabilitiesList(); + for (const auto& capability_key : control_caps_list) { + if (rc_capabilities.keyExists(capability_key)) { + if (strings::khmiSettingsControlCapabilities == capability_key || + strings::klightControlCapabilities == capability_key) { + GetResourcesFromCapabilitiesStructure( + rc_capabilities[capability_key], capability_key, resources); + } else { + GetResourcesFromCapabilitiesArray( + rc_capabilities[capability_key], capability_key, resources); + } + } + } + return resources; +} + +const std::string RCCapabilitiesManagerImpl::GetModuleIdForSeatLocation( + const mobile_apis::SupportedSeat::eType id) const { + LOG4CXX_AUTO_TRACE(logger_); + auto rc_capabilities = *(hmi_capabilities_.rc_capability()); + const auto seat_capabilities = + rc_capabilities[strings::kseatControlCapabilities]; + if (seat_capabilities.length() > 0) { + if (mobile_apis::SupportedSeat::DRIVER == id) { + return seat_capabilities[0][message_params::kModuleInfo] + [message_params::kModuleId] + .asString(); + } + if ((seat_capabilities.length() > 1) && + mobile_apis::SupportedSeat::FRONT_PASSENGER == id) { + return seat_capabilities[1][message_params::kModuleInfo] + [message_params::kModuleId] + .asString(); + } + } + LOG4CXX_DEBUG(logger_, "There are no capabitities for requested id: " << id); + return ""; +} + +bool RCCapabilitiesManagerImpl::CheckIfButtonExistInRCCaps( + const mobile_apis::ButtonName::eType button) const { + auto rc_capabilities = *(hmi_capabilities_.rc_capability()); + if (rc_capabilities.keyExists(strings::kbuttonCapabilities)) { + const smart_objects::SmartObject& button_caps = + rc_capabilities[strings::kbuttonCapabilities]; + for (auto& button_cap : *(button_caps.asArray())) { + int64_t current_id = button_cap[message_params::kName].asInt(); + if (-1 == current_id) { + // capabilities received from HMI contains enum values + // capabilities loaded from file contains string values + // TODO : unificate capabilities storing + const std::string& bt_name = + button_cap[message_params::kName].asString(); + static RCHelpers::ButtonsMap btn_map = RCHelpers::buttons_map(); + current_id = btn_map[bt_name]; + } + const mobile_apis::ButtonName::eType current_button = + static_cast(current_id); + if (current_button == button) { + LOG4CXX_TRACE( + logger_, + "Button id " << current_button << " exist in capabilities"); + return true; + } + } + } + LOG4CXX_TRACE(logger_, + "Button id " << button << " do not exist in capabilities"); + return false; +} + +smart_objects::SmartObject +RCCapabilitiesManagerImpl::GetCapabilitiesByModuleIdFromArray( + const smart_objects::SmartObject& module_data_capabilities, + const std::string& module_id) const { + for (auto& cap_item : *(module_data_capabilities.asArray())) { + std::string current_id = + cap_item[message_params::kModuleInfo][message_params::kModuleId] + .asString(); + if (module_id == current_id) { + return cap_item; + } + } + LOG4CXX_WARN(logger_, + "Capabilities for moduleId " << module_id + << " do not exist in capabilities"); + return smart_objects::SmartObject(smart_objects::SmartType_Null); +} + +bool RCCapabilitiesManagerImpl::CheckButtonName( + const std::string& module_type, const std::string& button_name) const { + LOG4CXX_AUTO_TRACE(logger_); + auto rc_capabilities = hmi_capabilities_.rc_capability(); + if (!rc_capabilities) { + LOG4CXX_ERROR(logger_, "No remote controll capabilities available"); + return false; + } + + if (enums_value::kRadio == module_type) { + if (!helpers::in_range(RCHelpers::buttons_radio(), button_name)) { + LOG4CXX_WARN(logger_, + "Trying to acceess climate button with module type radio"); + return false; + } + } + + if (enums_value::kClimate == module_type) { + if (!helpers::in_range(RCHelpers::buttons_climate(), button_name)) { + LOG4CXX_WARN(logger_, + "Trying to acceess radio button with module type climate"); + return false; + } + } + return true; +} + +const std::map +RCCapabilitiesManagerImpl::GetLightCapabilitiesMapping() const { + 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 +RCCapabilitiesManagerImpl::GetModuleDataToCapabilitiesMapping() const { + std::map mapping; + using namespace message_params; + using namespace rc_rpc_plugin::strings; + // climate + mapping[kFanSpeed] = kFanSpeedAvailable; + mapping[kCurrentTemperature] = kCurrentTemperatureAvailable; + mapping[kDesiredTemperature] = kDesiredTemperatureAvailable; + mapping[kACEnable] = kAcEnableAvailable; + mapping[kCirculateAirEnable] = kCirculateAirEnableAvailable; + mapping[kAutoModeEnable] = kAutoModeEnableAvailable; + mapping[kDefrostZone] = kDefrostZoneAvailable; + mapping[kDualModeEnable] = kDualModeEnableAvailable; + mapping[kACMaxEnable] = kAcMaxEnableAvailable; + mapping[kVentilationMode] = kVentilationModeAvailable; + mapping[kHeatedSteeringWheelEnable] = kHeatedSteeringWheelAvailable; + mapping[kHeatedWindshieldEnable] = kHeatedWindshieldAvailable; + mapping[kHeatedMirrorsEnable] = kHeatedMirrorsAvailable; + mapping[kHeatedRearWindowEnable] = kHeatedRearWindowAvailable; + mapping[kClimateEnable] = kClimateEnableAvailable; + mapping[kClimateEnableAvailable] = kClimateEnableAvailable; + + // radio + mapping[kBand] = kRadioBandAvailable; + mapping[kFrequencyInteger] = kRadioFrequencyAvailable; + mapping[kFrequencyFraction] = kRadioFrequencyAvailable; + mapping[kRdsData] = kRdsDataAvailable; + mapping[kAvailableHDs] = kAvailableHDsAvailable; + mapping[kAvailableHdChannels] = kAvailableHdChannelsAvailable; + mapping[kHdChannel] = kAvailableHdChannelsAvailable; + mapping[kHdRadioEnable] = kHdRadioEnableAvailable; + mapping[kSignalStrength] = kSignalStrengthAvailable; + mapping[kSignalChangeThreshold] = kSignalChangeThresholdAvailable; + mapping[kRadioEnable] = kRadioEnableAvailable; + mapping[kState] = kStateAvailable; + mapping[kSisData] = kSisDataAvailable; + + // seat + mapping[kHeatingEnabled] = kHeatingEnabledAvailable; + mapping[kCoolingEnabled] = kCoolingEnabledAvailable; + mapping[kHeatingLevele] = kHeatingLevelAvailable; + mapping[kCoolingLevel] = kCoolingLevelAvailable; + mapping[kHorizontalPosition] = kHorizontalPositionAvailable; + mapping[kVerticalPosition] = kVerticalPositionAvailable; + mapping[kFrontVerticalPosition] = kFrontVerticalPositionAvailable; + mapping[kBackVerticalPosition] = kBackVerticalPositionAvailable; + mapping[kBackTiltAngle] = kBackTiltAngleAvailable; + mapping[kHeadSupportHorizontalPosition] = + kHeadSupportHorizontalPositionAvailable; + mapping[kHeadSupportVerticalPosition] = kHeadSupportVerticalPositionAvailable; + mapping[kMassageEnabled] = kMassageEnabledAvailable; + mapping[kMassageMode] = kMassageModeAvailable; + mapping[kMassageCushionFirmness] = kMassageCushionFirmnessAvailable; + mapping[kMemory] = kMemoryAvailable; + + // audio + mapping[kSource] = kSourceAvailable; + mapping[kKeepContext] = kKeepContextAvailable; + mapping[kVolume] = kVolumeAvailable; + mapping[kEqualizerSettings] = kEqualizerAvailable; + + // hmi settings + mapping[kDistanceUnit] = kDistanceUnitAvailable; + mapping[kTemperatureUnit] = kTemperatureUnitAvailable; + mapping[kDisplayMode] = kDisplayModeUnitAvailable; + + return mapping; +} + +ModuleTypeCapability RCCapabilitiesManagerImpl::GetModuleDataCapabilities( + const smart_objects::SmartObject& module_data, + const std::string& module_id) const { + LOG4CXX_AUTO_TRACE(logger_); + auto rc_capabilities = *(hmi_capabilities_.rc_capability()); + + const auto& all_module_types = RCHelpers::GetModuleTypesList(); + const auto& get_module_data_key = RCHelpers::GetModuleTypeToDataMapping(); + const auto& get_capabilities_key = + RCHelpers::GetModuleTypeToCapabilitiesMapping(); + ModuleTypeCapability module_data_capabilities = + std::make_pair("", capabilitiesStatus::missedParam); + + 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 module_data_capabilities; + } + const auto& caps = rc_capabilities[capabilities_key]; + + if (message_params::kHmiSettingsControlData == module_data_key || + message_params::kLightControlData == module_data_key) { + module_data_capabilities = + GetControlDataCapabilities(caps, module_data[module_data_key]); + } else { + module_data_capabilities = GetControlDataCapabilities( + GetCapabilitiesByModuleIdFromArray(caps, module_id), + module_data[module_data_key]); + } + } + } + + return module_data_capabilities; +} + +ModuleTypeCapability RCCapabilitiesManagerImpl::GetControlDataCapabilities( + const smart_objects::SmartObject& capabilities, + const smart_objects::SmartObject& control_data) const { + LOG4CXX_AUTO_TRACE(logger_); + std::map mapping = + GetModuleDataToCapabilitiesMapping(); + + 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) { + ModuleTypeCapability light_capability = + std::make_pair("", capabilitiesStatus::success); + + for (auto& light_data : *(control_data[request_parameter].asArray())) { + light_capability = GetLightNameCapabilities( + capabilities[strings::kSupportedLights], light_data); + + if (capabilitiesStatus::success != light_capability.second) { + return light_capability; + } + } + + return light_capability; + } + if (message_params::kBand == request_parameter) { + ModuleTypeCapability radio_capability = GetRadioBandByCapabilities( + capabilities, control_data[request_parameter]); + if (capabilitiesStatus::success != radio_capability.second) { + return radio_capability; + } + } + + const capabilitiesStatus status_item_capability = + GetItemCapability(capabilities, + mapping, + request_parameter, + mobile_apis::Result::UNSUPPORTED_RESOURCE); + + if (capabilitiesStatus::success != status_item_capability) { + return std::make_pair("", status_item_capability); + } + } + + return std::make_pair("", capabilitiesStatus::success); +} + +capabilitiesStatus RCCapabilitiesManagerImpl::GetItemCapability( + const smart_objects::SmartObject& capabilities, + const std::map& mapping, + const std::string& request_parameter, + const mobile_apis::Result::eType& switched_off_result) const { + 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; +} + +ModuleTypeCapability RCCapabilitiesManagerImpl::GetLightDataCapabilities( + const smart_objects::SmartObject& capabilities, + const smart_objects::SmartObject& control_data) const { + LOG4CXX_AUTO_TRACE(logger_); + 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 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 std::make_pair("", capabilitiesStatus::success); +} + +ModuleTypeCapability RCCapabilitiesManagerImpl::GetLightNameCapabilities( + const smart_objects::SmartObject& capabilities_status, + const smart_objects::SmartObject& light_data) const { + LOG4CXX_AUTO_TRACE(logger_); + for (auto& so : *(capabilities_status.asArray())) { + const int64_t current_id = so[message_params::kName].asInt(); + if (current_id == light_data[message_params::kId].asInt()) { + return GetLightDataCapabilities(so, light_data); + } + } + LOG4CXX_DEBUG(logger_, "There is no such light name in capabilities"); + return std::make_pair(message_params::kLightState, + capabilitiesStatus::missedLightName); +} + +ModuleTypeCapability RCCapabilitiesManagerImpl::GetRadioBandByCapabilities( + const smart_objects::SmartObject& capabilities_status, + const smart_objects::SmartObject& request_parameter) const { + 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 std::make_pair(strings::kSiriusxmRadioAvailable, + capabilitiesStatus::missedParam); + } + if (!capabilities_status[strings::kSiriusxmRadioAvailable].asBool()) { + LOG4CXX_DEBUG(logger_, + "Capability " + << strings::kSiriusxmRadioAvailable + << " is switched off in RemoteControl capabilities"); + return std::make_pair(strings::kSiriusxmRadioAvailable, + capabilitiesStatus::missedParam); + } + } + return std::make_pair("", capabilitiesStatus::success); +} + +const smart_objects::SmartObject& RCCapabilitiesManagerImpl::ControlDataForType( + const smart_objects::SmartObject& module_data, + const std::string& module_type) const { + const auto& all_module_types = RCHelpers::GetModuleTypesList(); + const auto& data_mapping = RCHelpers::GetModuleTypeToDataMapping(); + for (const auto& type : all_module_types) { + if (type == module_type) { + return module_data[data_mapping(type)]; + } + } + NOTREACHED(); + return module_data[0]; +} + +bool RCCapabilitiesManagerImpl::CheckReadOnlyParamsForAudio( + const smart_objects::SmartObject& module_type_params) const { + if (module_type_params.keyExists(message_params::kEqualizerSettings)) { + const auto& equalizer_settings = + module_type_params[message_params::kEqualizerSettings]; + + for (auto& so : *(equalizer_settings.asArray())) { + if (so.keyExists(message_params::kChannelName)) { + LOG4CXX_DEBUG(logger_, + "READ ONLY parameter. ChannelName = " + << so[message_params::kChannelName].asString()); + return true; + } + } + } + + return false; +} + +bool RCCapabilitiesManagerImpl::CheckReadOnlyParamsForLight( + const smart_objects::SmartObject& module_type_params) const { + if (module_type_params.keyExists(message_params::kLightState)) { + const auto& light_state = module_type_params[message_params::kLightState]; + + for (auto& light_data : *(light_state.asArray())) { + if (light_data.keyExists(message_params::kLightStatus)) { + const mobile_apis::LightStatus::eType light_status = + static_cast( + light_data[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 = " + << light_data[message_params::kLightStatus].asInt()); + return true; + } + } + } + } + + return false; +} + +bool RCCapabilitiesManagerImpl::AreReadOnlyParamsPresent( + const smart_objects::SmartObject& module_data, + const std::string& module_type, + ModuleTypeCapability& module_data_capabilities) const { + LOG4CXX_AUTO_TRACE(logger_); + const smart_objects::SmartObject& module_type_params = + ControlDataForType(module_data, 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 = + RCHelpers::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; +} + +bool RCCapabilitiesManagerImpl::AreAllParamsReadOnly( + const smart_objects::SmartObject& module_data, + const std::string& module_type) const { + LOG4CXX_AUTO_TRACE(logger_); + const smart_objects::SmartObject& module_type_params = + ControlDataForType(module_data, module_type); + auto it = module_type_params.map_begin(); + std::vector ro_params = + RCHelpers::GetModuleReadOnlyParams(module_type); + for (; it != module_type_params.map_end(); ++it) { + if (!helpers::in_range(ro_params, it->first)) { + return false; + } + } + + LOG4CXX_DEBUG(logger_, "All params are ReadOnly"); + return true; +} + +bool RCCapabilitiesManagerImpl::IsSeatLocationCapabilityProvided() const { + LOG4CXX_AUTO_TRACE(logger_); + auto seat_location_capability = hmi_capabilities_.seat_location_capability(); + if (!seat_location_capability || seat_location_capability->empty()) { + LOG4CXX_DEBUG(logger_, "Seat Location capability is not provided by HMI"); + return false; + } + + if (seat_location_capability->keyExists(strings::kRows) && + seat_location_capability->keyExists(strings::kCols) && + seat_location_capability->keyExists(strings::kLevels) && + seat_location_capability->keyExists(strings::kSeats)) { + const auto* seats = (*seat_location_capability)[strings::kSeats].asArray(); + if (!seats->empty()) { + return true; + } + } + + LOG4CXX_DEBUG( + logger_, + "Seat Location capability doesn't contain all necessary parameters"); + return false; +} + +const Grid +RCCapabilitiesManagerImpl::GetDriverLocationFromSeatLocationCapability() const { + LOG4CXX_AUTO_TRACE(logger_); + Grid grid; + if (IsSeatLocationCapabilityProvided()) { + auto seat_location_capability = + hmi_capabilities_.seat_location_capability(); + const auto* seats = (*seat_location_capability)[strings::kSeats].asArray(); + const auto& driver_seat = (*seats)[0]; + if (driver_seat.keyExists(strings::kGrid)) { + const auto& driver_location = driver_seat[strings::kGrid]; + grid = Grid(driver_location[strings::kCol].asInt(), + driver_location[strings::kRow].asInt(), + driver_location[strings::kLevel].asInt(), + driver_location[strings::kColspan].asInt(), + driver_location[strings::kRowspan].asInt(), + driver_location[strings::kLevelspan].asInt()); + } else { + LOG4CXX_DEBUG(logger_, "Driver's location doesn't provided"); + } + } + return grid; +} + +Grid RCCapabilitiesManagerImpl::GetWholeVehicleArea() const { + auto seat_location_capability = + *(hmi_capabilities_.seat_location_capability()); + int32_t colspan = seat_location_capability.keyExists(strings::kCols) + ? seat_location_capability[strings::kCols].asInt() + : 0; + + int32_t rowspan = seat_location_capability.keyExists(strings::kRows) + ? seat_location_capability[strings::kRows].asInt() + : 0; + + int32_t levelspan = seat_location_capability.keyExists(strings::kLevels) + ? seat_location_capability[strings::kLevels].asInt() + : 0; + return Grid(0, 0, 0, colspan, rowspan, levelspan); +} + +Grid RCCapabilitiesManagerImpl::GetModuleLocationFromControlCapability( + const smart_objects::SmartObject& control_capabilities) const { + if (control_capabilities[message_params::kModuleInfo].keyExists( + strings::kLocation)) { + const auto& location = + control_capabilities[message_params::kModuleInfo][strings::kLocation]; + + return Grid(location[strings::kCol].asInt(), + location[strings::kRow].asInt(), + location[strings::kLevel].asInt(), + location[strings::kColspan].asInt(), + location[strings::kRowspan].asInt(), + location[strings::kLevelspan].asInt()); + } + return GetWholeVehicleArea(); +} + +Grid RCCapabilitiesManagerImpl::GetModuleServiceAreaFromControlCapability( + const smart_objects::SmartObject& control_capabilities) const { + if (control_capabilities.keyExists(message_params::kModuleInfo)) { + if (control_capabilities[message_params::kModuleInfo].keyExists( + strings::kServiceArea)) { + const auto& serviceArea = + control_capabilities[message_params::kModuleInfo] + [strings::kServiceArea]; + + return Grid(serviceArea[strings::kCol].asInt(), + serviceArea[strings::kRow].asInt(), + serviceArea[strings::kLevel].asInt(), + serviceArea[strings::kColspan].asInt(), + serviceArea[strings::kRowspan].asInt(), + serviceArea[strings::kLevelspan].asInt()); + } + } + return GetModuleLocationFromControlCapability(control_capabilities); +} + +Grid RCCapabilitiesManagerImpl::GetModuleServiceArea( + const ModuleUid& module) const { + auto rc_capabilities = *(hmi_capabilities_.rc_capability()); + const auto& mapping = RCHelpers::GetModuleTypeToCapabilitiesMapping(); + const auto& module_type = module.first; + const auto& capabilities_key = mapping(module_type); + if (!rc_capabilities.keyExists(capabilities_key)) { + LOG4CXX_DEBUG(logger_, module_type << "control capabilities not present"); + return Grid(); + } + const auto& caps = rc_capabilities[capabilities_key]; + + if (strings::khmiSettingsControlCapabilities == capabilities_key || + strings::klightControlCapabilities == capabilities_key) { + return GetModuleServiceAreaFromControlCapability(caps); + } else { + const auto& capability_item = + GetCapabilitiesByModuleIdFromArray(caps, module.second); + return GetModuleServiceAreaFromControlCapability(capability_item); + } +} + +bool RCCapabilitiesManagerImpl::IsMultipleAccessAllowedInControlCaps( + const smart_objects::SmartObject& control_capabilities) const { + if (control_capabilities.keyExists(message_params::kModuleInfo) && + control_capabilities[message_params::kModuleInfo].keyExists( + strings::kAllowMultipleAccess)) { + return control_capabilities[message_params::kModuleInfo] + [strings::kAllowMultipleAccess] + .asBool(); + } + return true; +} + +bool RCCapabilitiesManagerImpl::IsMultipleAccessAllowed( + const ModuleUid& module) const { + auto rc_capabilities = *(hmi_capabilities_.rc_capability()); + const auto& mapping = RCHelpers::GetModuleTypeToCapabilitiesMapping(); + const auto& module_type = module.first; + const auto& capabilities_key = mapping(module_type); + if (!rc_capabilities.keyExists(capabilities_key)) { + LOG4CXX_DEBUG(logger_, module_type << "control capabilities not present"); + return false; + } + const auto& caps = rc_capabilities[capabilities_key]; + + if (strings::khmiSettingsControlCapabilities == capabilities_key || + strings::klightControlCapabilities == capabilities_key) { + return IsMultipleAccessAllowedInControlCaps(caps); + } else { + return IsMultipleAccessAllowedInControlCaps( + GetCapabilitiesByModuleIdFromArray(caps, module.second)); + } +} + +} // namespace rc_rpc_plugin 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 acfc75a3898..4ca2cf51824 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 @@ -31,36 +31,42 @@ */ #include -#include "rc_rpc_plugin/rc_command_factory.h" -#include "rc_rpc_plugin/commands/mobile/button_press_request.h" -#include "rc_rpc_plugin/commands/mobile/button_press_response.h" -#include "rc_rpc_plugin/commands/mobile/get_interior_vehicle_data_request.h" -#include "rc_rpc_plugin/commands/mobile/get_interior_vehicle_data_response.h" -#include "rc_rpc_plugin/commands/hmi/rc_get_interior_vehicle_data_consent_request.h" -#include "rc_rpc_plugin/commands/hmi/rc_get_interior_vehicle_data_consent_response.h" -#include "rc_rpc_plugin/commands/mobile/set_interior_vehicle_data_request.h" -#include "rc_rpc_plugin/commands/mobile/set_interior_vehicle_data_response.h" -#include "rc_rpc_plugin/commands/mobile/on_interior_vehicle_data_notification.h" #include "rc_rpc_plugin/commands/hmi/rc_button_press_request.h" #include "rc_rpc_plugin/commands/hmi/rc_button_press_response.h" +#include "rc_rpc_plugin/commands/hmi/rc_get_interior_vehicle_data_consent_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_request.h" #include "rc_rpc_plugin/commands/hmi/rc_get_interior_vehicle_data_response.h" #include "rc_rpc_plugin/commands/hmi/rc_on_interior_vehicle_data_notification.h" #include "rc_rpc_plugin/commands/hmi/rc_on_remote_control_settings_notification.h" +#include "rc_rpc_plugin/commands/hmi/rc_set_global_properties_request.h" +#include "rc_rpc_plugin/commands/hmi/rc_set_global_properties_response.h" #include "rc_rpc_plugin/commands/hmi/rc_set_interior_vehicle_data_request.h" #include "rc_rpc_plugin/commands/hmi/rc_set_interior_vehicle_data_response.h" +#include "rc_rpc_plugin/commands/mobile/button_press_request.h" +#include "rc_rpc_plugin/commands/mobile/button_press_response.h" +#include "rc_rpc_plugin/commands/mobile/get_interior_vehicle_data_consent_request.h" +#include "rc_rpc_plugin/commands/mobile/get_interior_vehicle_data_consent_response.h" +#include "rc_rpc_plugin/commands/mobile/get_interior_vehicle_data_request.h" +#include "rc_rpc_plugin/commands/mobile/get_interior_vehicle_data_response.h" +#include "rc_rpc_plugin/commands/mobile/on_interior_vehicle_data_notification.h" +#include "rc_rpc_plugin/commands/mobile/release_interior_vehicle_data_module_request.h" +#include "rc_rpc_plugin/commands/mobile/release_interior_vehicle_data_module_response.h" +#include "rc_rpc_plugin/commands/mobile/set_interior_vehicle_data_request.h" +#include "rc_rpc_plugin/commands/mobile/set_interior_vehicle_data_response.h" +#include "rc_rpc_plugin/rc_command_factory.h" -#include "interfaces/MOBILE_API.h" #include "interfaces/HMI_API.h" +#include "interfaces/MOBILE_API.h" -#include "rc_rpc_plugin/resource_allocation_manager.h" #include "rc_rpc_plugin/interior_data_cache.h" +#include "rc_rpc_plugin/resource_allocation_manager.h" CREATE_LOGGERPTR_GLOBAL(logger_, "RemoteControlModule") namespace application_manager { -using rc_rpc_plugin::ResourceAllocationManager; using rc_rpc_plugin::InteriorDataCache; using rc_rpc_plugin::RCCommandParams; +using rc_rpc_plugin::ResourceAllocationManager; template class RCCommandCreator : public CommandCreator { @@ -113,7 +119,7 @@ struct RCCommandCreatorFactory { } const RCCommandParams params_; }; -} +} // namespace application_manager namespace rc_rpc_plugin { using namespace application_manager; @@ -158,11 +164,13 @@ bool RCCommandFactory::IsAbleToProcess( Command::SOURCE_SDL_TO_HMI == message_source) { return get_hmi_creator_factory( static_cast(function_id), - hmi_apis::messageType::INVALID_ENUM).CanBeCreated(); + hmi_apis::messageType::INVALID_ENUM) + .CanBeCreated(); } else { auto id = static_cast(function_id); - return get_mobile_command_creator( - id, mobile_apis::messageType::INVALID_ENUM).CanBeCreated() || + return get_mobile_command_creator(id, + mobile_apis::messageType::INVALID_ENUM) + .CanBeCreated() || get_mobile_notification_creator(id).CanBeCreated(); } } @@ -194,6 +202,20 @@ CommandCreator& RCCommandFactory::get_mobile_command_creator( : rc_factory .GetCreator(); } + case mobile_apis::FunctionID::ReleaseInteriorVehicleDataModuleID: { + return mobile_apis::messageType::request == message_type + ? rc_factory.GetCreator< + commands::ReleaseInteriorVehicleDataModuleRequest>() + : rc_factory.GetCreator< + commands::ReleaseInteriorVehicleDataModuleResponse>(); + } + case mobile_apis::FunctionID::GetInteriorVehicleDataConsentID: { + return mobile_apis::messageType::request == message_type + ? rc_factory.GetCreator< + commands::GetInteriorVehicleDataConsentRequest>() + : rc_factory.GetCreator< + commands::GetInteriorVehicleDataConsentResponse>(); + } default: {} } return rc_factory.GetCreator(); @@ -285,7 +307,14 @@ CommandCreator& RCCommandFactory::get_hmi_creator_factory( return rc_factory .GetCreator(); } + case hmi_apis::FunctionID::RC_SetGlobalProperties: { + return hmi_apis::messageType::request == message_type + ? rc_factory + .GetCreator() + : rc_factory + .GetCreator(); + } default: { return rc_factory.GetCreator(); } } } -} +} // namespace rc_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/rc_consent_manager_impl.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/rc_consent_manager_impl.cc new file mode 100644 index 00000000000..acaa6ce86c7 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/rc_consent_manager_impl.cc @@ -0,0 +1,388 @@ +/* + Copyright (c) 2019, 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 "application_manager/application_manager.h" +#include "application_manager/smart_object_keys.h" +#include "json/json.h" +#include "rc_rpc_plugin/rc_consent_manager_impl.h" +#include "rc_rpc_plugin/rc_module_constants.h" +#include "resumption/last_state.h" +#include "smart_objects/smart_object.h" +#include "utils/date_time.h" +#include "utils/logger.h" + +namespace rc_rpc_plugin { +namespace app_mngr = application_manager; + +CREATE_LOGGERPTR_GLOBAL(logger_, "RCConsentManager") + +RCConsentManagerImpl::RCConsentManagerImpl( + resumption::LastState& last_state, + application_manager::ApplicationManager& application_manager, + const uint32_t period_of_consent_expired) + : app_manager_(application_manager) + , last_state_(last_state) + , period_of_consent_expired_(period_of_consent_expired) {} + +void RCConsentManagerImpl::SaveModuleConsents( + const std::string& policy_app_id, + const std::string& mac_address, + const rc_rpc_types::ModuleIdConsentVector& module_consents) { + LOG4CXX_AUTO_TRACE(logger_); + + for (const auto& consent : module_consents) { + std::string module_type = consent.module_id.first; + + auto& app_module_consents = + GetModuleTypeConsentsOrAppend(policy_app_id, mac_address, module_type); + SaveAppModuleConsent(app_module_consents, consent); + } +} + +rc_rpc_types::ModuleConsent RCConsentManagerImpl::GetModuleConsent( + const std::string& app_id, + const std::string& mac_address, + const rc_rpc_types::ModuleUid& module_id) const { + sync_primitives::AutoLock autolock(module_consents_lock_); + + auto& module_consents = + GetModuleTypeConsentsOrAppend(app_id, mac_address, module_id.first); + if (module_consents.empty()) { + LOG4CXX_DEBUG( + logger_, + "For app: " << app_id << " module type doesn't have any consents"); + return rc_rpc_types::ModuleConsent::NOT_EXISTS; + } + + for (const auto& conset_item : module_consents) { + if (conset_item[message_params::kModuleId].asString() == module_id.second) { + return static_cast( + conset_item[message_params::kConsent].asUInt()); + } + } + + LOG4CXX_DEBUG(logger_, + "For app: " << app_id << " and module resource [" + << module_id.first << ":" << module_id.second + << "] consent is absent"); + + return rc_rpc_types::ModuleConsent::NOT_EXISTS; +} + +void RCConsentManagerImpl::RemoveExpiredConsents() { + LOG4CXX_AUTO_TRACE(logger_); + auto& remote_control = GetRemoteControlDataOrAppend(); + if (remote_control.empty()) { + return; + } + + auto& devices = GetAppsConsentsOrAppend(); + + sync_primitives::AutoLock autolock(device_applications_lock_); + + for (auto& device_item : devices) { + RemoveDeviceExpiredConsents(device_item); + } +} + +void RCConsentManagerImpl::RemoveAllConsents() { + auto& remote_control = GetRemoteControlDataOrAppend(); + remote_control.removeMember(message_params::kAppConsents); +} + +rc_rpc_types::ModuleConsentState RCConsentManagerImpl::CheckModuleConsentState( + const Json::Value& module_consent) const { + if (!module_consent.isMember(message_params::kConsentDate)) { + LOG4CXX_DEBUG(logger_, "Date of consent is absent"); + return rc_rpc_types::ModuleConsentState::NOT_EXISTS; + } + + const uint32_t period_for_expiring = + app_manager_.get_settings().period_for_consent_expiration(); + + const time_t consent_date = static_cast( + module_consent[message_params::kConsentDate].asUInt()); + + const auto past_period_in_days = + date_time::calculateAmountDaysFromDate(consent_date); + + LOG4CXX_DEBUG( + logger_, + "Keeping time of consent is: " << past_period_in_days << " days"); + LOG4CXX_DEBUG(logger_, "Period for expired: " << period_for_expiring); + + return (past_period_in_days >= period_for_expiring) + ? rc_rpc_types::ModuleConsentState::EXPIRED + : rc_rpc_types::ModuleConsentState::ACTIVE; +} + +void RCConsentManagerImpl::RemoveDeviceExpiredConsents(Json::Value& device) { + sync_primitives::AutoLock autolock(applications_lock_); + + if (device.isMember(message_params::kApplications)) { + auto& applications = device[message_params::kApplications]; + + for (auto& app : applications) { + if (app.isMember(message_params::kAppConsentList)) { + RemoveAppExpiredConsents(app[message_params::kAppConsentList]); + } + } + } +} + +void RCConsentManagerImpl::RemoveAppExpiredConsents(Json::Value& app_consents) { + for (auto& module : app_consents) { + if (module.isMember(message_params::kModuleConsents)) { + auto& module_consents = module[message_params::kModuleConsents]; + RemoveModuleExpiredConsents(module_consents); + } + } +} + +void RCConsentManagerImpl::RemoveModuleExpiredConsents( + Json::Value& module_consents) { + sync_primitives::AutoLock autolock(module_consents_lock_); + Json::Value temp_consents; + + for (auto& consent : module_consents) { + const bool is_module_id_exists = + consent.isMember(message_params::kModuleId); + + const bool is_expired = rc_rpc_types::ModuleConsentState::EXPIRED == + CheckModuleConsentState(consent); + if (is_expired) { + LOG4CXX_DEBUG(logger_, + "Consent for module resource [" + << consent[message_params::kModuleId].asString() + << "] is expired and will be removed"); + } + + if (is_module_id_exists && !is_expired) { + LOG4CXX_DEBUG(logger_, + "Consent for module resource [" + << consent[message_params::kModuleId].asString() + << "] is actual."); + temp_consents.append(consent); + } + } + + module_consents.clear(); + if (!temp_consents.empty()) { + std::swap(module_consents, temp_consents); + } +} + +Json::Value& RCConsentManagerImpl::GetRemoteControlDataOrAppend() const { + Json::Value& dictionary = last_state_.get_dictionary(); + + sync_primitives::AutoLock autolock(dictionary_control_lock_); + if (!dictionary.isMember(app_mngr::strings::remote_control)) { + dictionary[app_mngr::strings::remote_control] = + Json::Value(Json::objectValue); + LOG4CXX_DEBUG(logger_, "remote_control section is missed"); + } + + Json::Value& remote_control = dictionary[app_mngr::strings::remote_control]; + + if (!remote_control.isObject()) { + LOG4CXX_ERROR(logger_, "remote_control type INVALID rewrite"); + remote_control = Json::Value(Json::objectValue); + } + return remote_control; +} + +Json::Value& RCConsentManagerImpl::GetDeviceApplicationsOrAppend( + const std::string& mac_address) const { + sync_primitives::AutoLock autolock(device_applications_lock_); + + auto& apps_consents = GetAppsConsentsOrAppend(); + + if (!apps_consents.isArray()) { + LOG4CXX_DEBUG(logger_, "applications_consents type INVALID rewrite"); + apps_consents = Json::Value(Json::arrayValue); + } + + for (auto& device_applications_item : apps_consents) { + const bool is_device_section_exists = + device_applications_item.isMember(message_params::kMacAddress); + + if (is_device_section_exists) { + auto saved_mac_adress = + device_applications_item[message_params::kMacAddress].asString(); + + if (saved_mac_adress == mac_address) { + return device_applications_item[message_params::kApplications]; + } + } + } + + auto device_applications = Json::Value(Json::objectValue); + device_applications[message_params::kMacAddress] = Json::Value(mac_address); + device_applications[message_params::kApplications] = + Json::Value(Json::arrayValue); + + apps_consents.append(device_applications); + return apps_consents[apps_consents.size() - 1][message_params::kApplications]; +} + +Json::Value& RCConsentManagerImpl::GetAppConsentsListOrAppend( + const std::string& policy_app_id, const std::string& mac_address) const { + auto& device_applications = GetDeviceApplicationsOrAppend(mac_address); + + sync_primitives::AutoLock autolock(applications_lock_); + if (!device_applications.isArray()) { + LOG4CXX_DEBUG(logger_, "applications_consents type INVALID rewrite"); + device_applications = Json::Value(Json::arrayValue); + } + + for (auto& application : device_applications) { + const bool is_app_id_section_exists = + application.isMember(message_params::kAppId); + + if (is_app_id_section_exists) { + auto saved_app_id = application[message_params::kAppId].asString(); + + if (saved_app_id == policy_app_id) { + return application[message_params::kAppConsentList]; + } + } + } + + // In case when specified application section is absent in json file, + // will be created new section and added to dictionary. + auto application = Json::Value(Json::objectValue); + application[message_params::kAppId] = Json::Value(policy_app_id); + application[message_params::kAppConsentList] = Json::Value(Json::arrayValue); + device_applications.append(application); + + // Returns last appended object + return device_applications[device_applications.size() - 1] + [message_params::kAppConsentList]; +} + +Json::Value& RCConsentManagerImpl::GetAppsConsentsOrAppend() const { + Json::Value& remote_control = GetRemoteControlDataOrAppend(); + sync_primitives::AutoLock autolock(remote_control_lock_); + + if (!remote_control.isMember(message_params::kAppConsents)) { + LOG4CXX_DEBUG(logger_, "app_consents section is missed"); + remote_control[message_params::kAppConsents] = + Json::Value(Json::arrayValue); + } + + auto& app_consents = remote_control[message_params::kAppConsents]; + if (!app_consents.isArray()) { + LOG4CXX_DEBUG(logger_, "applications_consents type INVALID rewrite"); + app_consents = Json::Value(Json::arrayValue); + } + return app_consents; +} + +Json::Value& RCConsentManagerImpl::GetModuleTypeConsentsOrAppend( + const std::string& policy_app_id, + const std::string& mac_address, + const std::string& module_type) const { + auto& app_consnets_list = + GetAppConsentsListOrAppend(policy_app_id, mac_address); + + sync_primitives::AutoLock autolock(app_consents_lock_); + for (auto& module_consents : app_consnets_list) { + const bool module_exists = + module_consents.isMember(message_params::kModuleType); + + if (module_exists && + (module_consents[message_params::kModuleType].asString() == + module_type)) { + return module_consents[message_params::kModuleConsents]; + } + } + + // In case of absent specified module_type in section of specified + // application, will be added empty section with this module type. + LOG4CXX_DEBUG( + logger_, + "Section module_type: " << module_type + << " is missed for app_id:" << policy_app_id); + auto consent_item = Json::Value(Json::objectValue); + consent_item[message_params::kModuleType] = module_type; + consent_item[message_params::kModuleConsents] = Json::Value(Json::arrayValue); + + app_consnets_list.append(consent_item); + + // Returns last (appended) object + return app_consnets_list[app_consnets_list.size() - 1] + [message_params::kModuleConsents]; +} + +RCConsentManagerImpl::~RCConsentManagerImpl() {} + +void RCConsentManagerImpl::SaveAppModuleConsent( + Json::Value& app_module_consents, + const rc_rpc_types::ModuleIdConsent& consent_to_save) { + bool is_found = false; + + sync_primitives::AutoLock autolock(app_consents_lock_); + for (auto& consent : app_module_consents) { + const bool is_module_id_exists = + consent.isMember(message_params::kModuleId); + + // In case existing consent of specified ModuelResource (module_type + + // module_id), old value will be rewritten by new value. + + if (is_module_id_exists && (consent[message_params::kModuleId].asString() == + consent_to_save.module_id.second)) { + is_found = true; + consent[message_params::kConsent] = + Json::Value(static_cast(consent_to_save.consent)); + consent[message_params::kConsentDate] = Json::Value( + static_cast(consent_to_save.date_of_consent)); + } + } + + // Otherwise, new item will be added to the "consents" collection + + if (!is_found) { + auto new_consent = Json::Value(Json::objectValue); + new_consent[message_params::kModuleId] = + Json::Value(consent_to_save.module_id.second); + new_consent[message_params::kConsent] = + Json::Value(static_cast(consent_to_save.consent)); + new_consent[message_params::kConsentDate] = + Json::Value(static_cast(consent_to_save.date_of_consent)); + + app_module_consents.append(new_consent); + } +} + +} // 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 index 0bdec557330..ca0edc90b1d 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 @@ -1,13 +1,131 @@ #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" +#include "application_manager/smart_object_keys.h" +#include "rc_rpc_plugin/rc_module_constants.h" +#include "rc_rpc_plugin/rc_rpc_plugin.h" namespace rc_rpc_plugin { CREATE_LOGGERPTR_GLOBAL(logger_, "RemoteControlModule"); +const std::vector RCHelpers::buttons_climate() { + std::vector data; + data.push_back(enums_value::kACMax); + data.push_back(enums_value::kAC); + data.push_back(enums_value::kRecirculate); + data.push_back(enums_value::kFanUp); + data.push_back(enums_value::kFanDown); + data.push_back(enums_value::kTempUp); + data.push_back(enums_value::kTempDown); + data.push_back(enums_value::kDefrostMax); + data.push_back(enums_value::kDefrost); + data.push_back(enums_value::kDefrostRear); + data.push_back(enums_value::kUpperVent); + data.push_back(enums_value::kLowerVent); + return data; +} + +const std::vector RCHelpers::buttons_radio() { + std::vector data; + data.push_back(enums_value::kVolumeUp); + data.push_back(enums_value::kVolumeDown); + data.push_back(enums_value::kEject); + data.push_back(enums_value::kSource); + data.push_back(enums_value::kShuffle); + data.push_back(enums_value::kRepeat); + return data; +} + +const RCHelpers::ButtonsMap RCHelpers::buttons_map() { + using namespace mobile_apis; + + ButtonsMap buttons_map; + buttons_map[enums_value::kACMax] = ButtonName::AC_MAX; + buttons_map[enums_value::kAC] = ButtonName::AC; + buttons_map[enums_value::kRecirculate] = ButtonName::RECIRCULATE; + buttons_map[enums_value::kFanUp] = ButtonName::FAN_UP; + buttons_map[enums_value::kFanDown] = ButtonName::FAN_DOWN; + buttons_map[enums_value::kTempUp] = ButtonName::TEMP_UP; + buttons_map[enums_value::kTempDown] = ButtonName::TEMP_DOWN; + buttons_map[enums_value::kDefrostMax] = ButtonName::DEFROST_MAX; + buttons_map[enums_value::kDefrost] = ButtonName::DEFROST; + buttons_map[enums_value::kDefrostRear] = ButtonName::DEFROST_REAR; + buttons_map[enums_value::kUpperVent] = ButtonName::UPPER_VENT; + buttons_map[enums_value::kLowerVent] = ButtonName::LOWER_VENT; + buttons_map[enums_value::kVolumeUp] = ButtonName::VOLUME_UP; + buttons_map[enums_value::kVolumeDown] = ButtonName::VOLUME_DOWN; + buttons_map[enums_value::kEject] = ButtonName::EJECT; + buttons_map[enums_value::kSource] = ButtonName::SOURCE; + buttons_map[enums_value::kShuffle] = ButtonName::SHUFFLE; + buttons_map[enums_value::kRepeat] = ButtonName::REPEAT; + + return buttons_map; +} + +std::vector RCHelpers::GetModuleReadOnlyParams( + const std::string& module_type) { + using namespace message_params; + std::vector module_ro_params; + if (enums_value::kClimate == module_type) { + module_ro_params.push_back(kCurrentTemperature); + } else if (enums_value::kRadio == module_type) { + module_ro_params.push_back(kRdsData); + module_ro_params.push_back(kAvailableHDs); + module_ro_params.push_back(kAvailableHdChannels); + module_ro_params.push_back(kSignalStrength); + 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; +} + +rc_rpc_types::ModuleIdConsentVector RCHelpers::FillModuleConsents( + const std::string& module_type, + const std::vector& module_ids, + const std::vector allowed) { + using namespace rc_rpc_types; + if (module_ids.size() != allowed.size()) { + return rc_rpc_types::ModuleIdConsentVector(); + } + + rc_rpc_types::ModuleIdConsentVector module_consents; + std::time_t current_date = std::time(0); + size_t array_size = module_ids.size(); + + for (size_t i = 0; i < array_size; ++i) { + rc_rpc_types::ModuleIdConsent module_consent; + module_consent.module_id = {module_type, module_ids[i]}; + module_consent.consent = + allowed[i] ? ModuleConsent::CONSENTED : ModuleConsent::NOT_CONSENTED; + module_consent.date_of_consent = current_date; + + module_consents.push_back(module_consent); + } + return module_consents; +} + +std::vector RCHelpers::RetrieveModuleIds( + const ns_smart_device_link::ns_smart_objects::SmartObject& moduleIds) { + std::vector module_ids; + for (const auto& module_id : (*moduleIds.asArray())) { + module_ids.push_back(module_id.asString()); + } + return module_ids; +} + +std::vector RCHelpers::RetrieveModuleConsents( + const ns_smart_device_link::ns_smart_objects::SmartObject& consents) { + std::vector module_consents; + for (const auto& allowed_item : (*consents.asArray())) { + module_consents.push_back(allowed_item.asBool()); + } + return module_consents; +} + const std::function RCHelpers::GetModuleTypeToDataMapping() { auto mapping_lambda = [](const std::string& module_type) -> std::string { @@ -50,7 +168,7 @@ RCHelpers::GetModuleTypeToCapabilitiesMapping() { return mapping_lambda; } -const std::vector RCHelpers::GetModulesList() { +const std::vector RCHelpers::GetModuleTypesList() { using namespace enums_value; return {kClimate, kRadio, kSeat, kAudio, kLight, kHmiSettings}; } @@ -64,7 +182,7 @@ RCAppExtensionPtr RCHelpers::GetRCExtension( } smart_objects::SmartObjectSPtr RCHelpers::CreateUnsubscribeRequestToHMI( - const std::string& module_type, const uint32_t correlation_id) { + const ModuleUid& module, const uint32_t correlation_id) { using namespace smart_objects; namespace commands = application_manager::commands; namespace am_strings = application_manager::strings; @@ -82,10 +200,27 @@ smart_objects::SmartObjectSPtr RCHelpers::CreateUnsubscribeRequestToHMI( params[am_strings::function_id] = hmi_apis::FunctionID::RC_GetInteriorVehicleData; msg_params[message_params::kSubscribe] = false; - msg_params[message_params::kModuleType] = module_type; + msg_params[message_params::kModuleType] = module.first; + msg_params[message_params::kModuleId] = module.second; return message; } +std::vector +RCHelpers::AppsSubscribedToModule( + application_manager::ApplicationManager& app_mngr, + const ModuleUid& module) { + 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->IsSubscribedToInteriorVehicleData(module)) { + result.push_back(app); + } + } + return result; +} + std::vector RCHelpers::AppsSubscribedToModuleType( application_manager::ApplicationManager& app_mngr, @@ -95,17 +230,17 @@ RCHelpers::AppsSubscribedToModuleType( for (auto& app : rc_apps) { auto rc_ext = RCHelpers::GetRCExtension(*app); DCHECK_OR_RETURN(rc_ext, result); - if (rc_ext->IsSubscibedToInteriorVehicleData(module_type)) { + if (rc_ext->IsSubscribedToInteriorVehicleDataOfType(module_type)) { result.push_back(app); } } return result; } -RCHelpers::AppsModules RCHelpers::GetApplicationsAllowedModules( +RCHelpers::AppsModuleTypes RCHelpers::GetApplicationsAllowedModuleTypes( app_mngr::ApplicationManager& app_mngr) { auto apps_list = RCRPCPlugin::GetRCApplications(app_mngr); - RCHelpers::AppsModules result; + RCHelpers::AppsModuleTypes result; for (auto& app_ptr : apps_list) { std::vector allowed_modules; app_mngr.GetPolicyHandler().GetModuleTypes(app_ptr->policy_app_id(), @@ -115,4 +250,115 @@ RCHelpers::AppsModules RCHelpers::GetApplicationsAllowedModules( } return result; } + +void RCHelpers::RemoveRedundantGPSDataFromIVDataMsg( + smart_objects::SmartObject& msg_params) { + using namespace message_params; + using namespace application_manager::strings; + + LOG4CXX_AUTO_TRACE(logger_); + if (!msg_params.keyExists(kModuleData)) { + return; + } + auto& module_data = msg_params[kModuleData]; + if (!module_data.keyExists(kRadioControlData) || + !module_data[kRadioControlData].keyExists(kSisData) || + !module_data[kRadioControlData][kSisData].keyExists(station_location)) { + return; + } + + auto& location_data = + module_data[kRadioControlData][kSisData][station_location]; + auto new_location_data = + smart_objects::SmartObject(smart_objects::SmartType_Map); + new_location_data[latitude_degrees] = location_data[latitude_degrees]; + new_location_data[longitude_degrees] = location_data[longitude_degrees]; + if (location_data.keyExists(altitude)) { + new_location_data[altitude] = location_data[altitude]; + + location_data = new_location_data; + } +} + +smart_objects::SmartObject RCHelpers::MergeModuleData( + const smart_objects::SmartObject& data1, + const smart_objects::SmartObject& data2) { + if (data1.getType() != smart_objects::SmartType::SmartType_Map || + data2.getType() != smart_objects::SmartType::SmartType_Map) { + return data2; + } + + smart_objects::SmartObject result = data1; + + for (auto it = data2.map_begin(); it != data2.map_end(); ++it) { + const std::string& key = it->first; + smart_objects::SmartObject& value = it->second; + if (!result.keyExists(key) || value.getType() != result[key].getType()) { + result[key] = value; + continue; + } + + // Merge maps and arrays with `id` param included, replace other types + if (value.getType() == smart_objects::SmartType::SmartType_Map) { + value = MergeModuleData(result[key], value); + } else if (value.getType() == smart_objects::SmartType::SmartType_Array) { + value = MergeArray(result[key], value); + } + result[key] = value; + } + return result; +} + +smart_objects::SmartObject RCHelpers::MergeArray( + const smart_objects::SmartObject& data1, + const smart_objects::SmartObject& data2) { + // Merge data only in the case where each value in the array is an Object with + // an ID included, otherwise replace + + if (data1.getType() != smart_objects::SmartType::SmartType_Array || + data2.getType() != smart_objects::SmartType::SmartType_Array || + data2.empty()) { + return data2; + } + + auto& data2_array = *data2.asArray(); + for (const auto& data_item : data2_array) { + if (data_item.getType() != smart_objects::SmartType_Map || + !data_item.keyExists(application_manager::strings::id)) { + return data2; + } + } + + smart_objects::SmartObject result = data1; + smart_objects::SmartArray* result_array = result.asArray(); + + auto find_by_id = [](smart_objects::SmartArray* array, + const smart_objects::SmartObject& id) + -> smart_objects::SmartArray::iterator { + return std::find_if(array->begin(), + array->end(), + [&id](const smart_objects::SmartObject& obj) -> bool { + return id == obj[application_manager::strings::id]; + }); + }; + + auto merge = [&result_array, + &find_by_id](const smart_objects::SmartObject& data) -> void { + auto element_id = data[application_manager::strings::id]; + auto result_it = find_by_id(result_array, element_id); + + if (result_array->end() != result_it) { + *result_it = RCHelpers::MergeModuleData(*result_it, data); + } else { + result_array->push_back(data); + } + }; + + for (const auto& data : data2_array) { + merge(data); + } + + return result; } + +} // namespace rc_rpc_plugin 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 3bc11065739..9005eb7fd03 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 @@ -29,16 +29,18 @@ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include "application_manager/plugin_manager/plugin_keys.h" #include "rc_rpc_plugin/rc_rpc_plugin.h" -#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 +#include "application_manager/plugin_manager/plugin_keys.h" #include "rc_rpc_plugin/interior_data_cache_impl.h" #include "rc_rpc_plugin/interior_data_manager_impl.h" +#include "rc_rpc_plugin/rc_app_extension.h" +#include "rc_rpc_plugin/rc_capabilities_manager_impl.h" +#include "rc_rpc_plugin/rc_command_factory.h" +#include "rc_rpc_plugin/rc_consent_manager_impl.h" #include "rc_rpc_plugin/rc_helpers.h" +#include "rc_rpc_plugin/resource_allocation_manager_impl.h" #include "utils/helpers.h" -#include namespace rc_rpc_plugin { CREATE_LOGGERPTR_GLOBAL(logger_, "RemoteControlModule"); @@ -49,23 +51,35 @@ bool RCRPCPlugin::Init( application_manager::ApplicationManager& app_manager, application_manager::rpc_service::RPCService& rpc_service, application_manager::HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handler) { + policy::PolicyHandlerInterface& policy_handler, + resumption::LastState& last_state) { + rc_consent_manager_.reset(new rc_rpc_plugin::RCConsentManagerImpl( + last_state, + app_manager, + app_manager.get_settings().period_for_consent_expiration())); 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)); + rc_capabilities_manager_.reset( + new RCCapabilitiesManagerImpl(hmi_capabilities)); + resource_allocation_manager_.reset(new ResourceAllocationManagerImpl( + app_manager, rpc_service, *(rc_capabilities_manager_.get()))); RCCommandParams params{app_manager, rpc_service, hmi_capabilities, policy_handler, *(resource_allocation_manager_.get()), *(interior_data_cache_.get()), - *(interior_data_manager_.get())}; + *(interior_data_manager_.get()), + *(rc_capabilities_manager_.get()), + *(rc_consent_manager_.get())}; command_factory_.reset(new rc_rpc_plugin::RCCommandFactory(params)); rpc_service_ = &rpc_service; app_mngr_ = &app_manager; + + // Check all saved consents and remove expired + rc_consent_manager_->RemoveExpiredConsents(); + return true; } @@ -98,8 +112,13 @@ void RCRPCPlugin::OnApplicationEvent( } switch (event) { case plugins::kApplicationRegistered: { - application->AddExtension( - std::shared_ptr(new RCAppExtension(kRCPluginID))); + auto extension = + std::shared_ptr(new RCAppExtension(kRCPluginID)); + application->AddExtension(extension); + const auto driver_location = + rc_capabilities_manager_ + ->GetDriverLocationFromSeatLocationCapability(); + extension->SetUserLocation(driver_location); resource_allocation_manager_->SendOnRCStatusNotifications( NotificationTrigger::APP_REGISTRATION, application); break; @@ -114,6 +133,12 @@ void RCRPCPlugin::OnApplicationEvent( interior_data_manager_->OnApplicationEvent(event, application); break; } + case plugins::kGlobalPropertiesUpdated: { + const auto user_location = application->get_user_location(); + auto extension = RCHelpers::GetRCExtension(*application); + extension->SetUserLocation(user_location); + break; + } default: break; } @@ -121,8 +146,8 @@ void RCRPCPlugin::OnApplicationEvent( RCRPCPlugin::Apps RCRPCPlugin::GetRCApplications( application_manager::ApplicationManager& app_mngr) { - using application_manager::ApplicationSharedPtr; using application_manager::ApplicationSet; + using application_manager::ApplicationSharedPtr; ApplicationSet accessor = app_mngr.applications().GetData(); std::vector result; @@ -136,6 +161,14 @@ RCRPCPlugin::Apps RCRPCPlugin::GetRCApplications( } // namespace rc_rpc_plugin -extern "C" application_manager::plugin_manager::RPCPlugin* Create() { +extern "C" __attribute__((visibility("default"))) +application_manager::plugin_manager::RPCPlugin* +Create() { return new rc_rpc_plugin::RCRPCPlugin(); } // namespace rc_rpc_plugin + +extern "C" __attribute__((visibility("default"))) void Delete( + application_manager::plugin_manager::RPCPlugin* data) { + delete data; + DELETE_THREAD_LOGGER(rc_rpc_plugin::logger_); +} 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 ecd263b77ab..97ff2b23dad 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 @@ -33,14 +33,14 @@ #include "rc_rpc_plugin/resource_allocation_manager_impl.h" #include "application_manager/application.h" #include "application_manager/application_manager.h" +#include "application_manager/message_helper.h" #include "interfaces/HMI_API.h" #include "interfaces/MOBILE_API.h" -#include "smart_objects/enum_schema_item.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 "rc_rpc_plugin/rc_helpers.h" +#include "rc_rpc_plugin/rc_module_constants.h" +#include "rc_rpc_plugin/rc_rpc_plugin.h" +#include "smart_objects/enum_schema_item.h" #include "utils/helpers.h" namespace rc_rpc_plugin { @@ -49,16 +49,20 @@ CREATE_LOGGERPTR_GLOBAL(logger_, "RemoteControlModule") ResourceAllocationManagerImpl::ResourceAllocationManagerImpl( application_manager::ApplicationManager& app_mngr, - application_manager::rpc_service::RPCService& rpc_service) + application_manager::rpc_service::RPCService& rpc_service, + RCCapabilitiesManager& rc_capabilities_manager) : current_access_mode_(hmi_apis::Common_RCAccessMode::AUTO_ALLOW) , app_mngr_(app_mngr) , rpc_service_(rpc_service) + , rc_capabilities_manager_(rc_capabilities_manager) , is_rc_enabled_(true) {} ResourceAllocationManagerImpl::~ResourceAllocationManagerImpl() {} AcquireResult::eType ResourceAllocationManagerImpl::AcquireResource( - const std::string& module_type, const uint32_t app_id) { + const std::string& module_type, + const std::string& module_id, + const uint32_t app_id) { LOG4CXX_AUTO_TRACE(logger_); const application_manager::ApplicationSharedPtr acquiring_app = app_mngr_.application(app_id); @@ -67,40 +71,57 @@ AcquireResult::eType ResourceAllocationManagerImpl::AcquireResource( return AcquireResult::IN_USE; } + ModuleUid module(module_type, module_id); + + if (rc_capabilities_manager_.IsSeatLocationCapabilityProvided() && + !IsUserLocationValid(module, acquiring_app)) { + LOG4CXX_WARN(logger_, + "Resource acquisition is not allowed " + "according to location verification."); + return AcquireResult::REJECTED; + } + sync_primitives::AutoLock lock(allocated_resources_lock_); const AllocatedResources::const_iterator allocated_it = - allocated_resources_.find(module_type); + allocated_resources_.find(module); if (allocated_resources_.end() == allocated_it) { - SetResourceAquired(module_type, app_id); LOG4CXX_DEBUG(logger_, "Resource is not acquired yet. " << "App: " << app_id << " is allowed to acquire " - << module_type); + << module_type << " " << module_id); return AcquireResult::ALLOWED; } - if (app_id == allocated_resources_[module_type]) { + if (app_id == allocated_resources_[module]) { LOG4CXX_DEBUG(logger_, "App: " << app_id << " is already acquired resource " - << module_type); + << module_type << " " << module_id); return AcquireResult::ALLOWED; } - if (IsModuleTypeRejected(module_type, app_id)) { + if (IsModuleTypeRejected(module_type, module_id, app_id)) { LOG4CXX_DEBUG(logger_, "Driver disallowed app: " << app_id << " to acquire " - << module_type); + << module_type << " " << module_id); return AcquireResult::REJECTED; } const mobile_apis::HMILevel::eType acquiring_app_hmi_level = - acquiring_app->hmi_level(); + acquiring_app->hmi_level(mobile_apis::PredefinedWindows::DEFAULT_WINDOW); if (mobile_apis::HMILevel::HMI_FULL != acquiring_app_hmi_level) { LOG4CXX_DEBUG(logger_, "Aquiring resources is not allowed in HMI level: " << acquiring_app_hmi_level << ". App: " << app_id - << " is disallowed to acquire " << module_type); + << " is disallowed to acquire " << module_type << " " + << module_id); + return AcquireResult::REJECTED; + } + + if (!rc_capabilities_manager_.IsMultipleAccessAllowed(module)) { + LOG4CXX_DEBUG(logger_, + "Multiple access for the: " << module_type << " " << module_id + << " isn't allowed"); return AcquireResult::REJECTED; } @@ -109,34 +130,57 @@ AcquireResult::eType ResourceAllocationManagerImpl::AcquireResource( LOG4CXX_DEBUG(logger_, "Current access_mode is AUTO_DENY. " << "App: " << app_id << " is disallowed to acquire " - << module_type); + << module_type << " " << module_id); return AcquireResult::IN_USE; } case hmi_apis::Common_RCAccessMode::ASK_DRIVER: { LOG4CXX_DEBUG(logger_, "Current access_mode is ASK_DRIVER. " "Driver confirmation is required for app: " - << app_id << " to acquire " << module_type); + << app_id << " to acquire " << module_type << " " + << module_id); return AcquireResult::ASK_DRIVER; } case hmi_apis::Common_RCAccessMode::AUTO_ALLOW: { LOG4CXX_DEBUG(logger_, "Current access_mode is AUTO_ALLOW. " << "App: " << app_id << " is allowed to acquire " - << module_type); - - SetResourceAquired(module_type, app_id); + << module_type << " " << module_id); return AcquireResult::ALLOWED; } default: { DCHECK_OR_RETURN(false, AcquireResult::IN_USE); } } } -void ResourceAllocationManagerImpl::ReleaseResource( +bool ResourceAllocationManagerImpl::IsUserLocationValid( + ModuleUid& module, application_manager::ApplicationSharedPtr app) { + LOG4CXX_AUTO_TRACE(logger_); + const auto extension = RCHelpers::GetRCExtension(*app); + const auto user_location = extension->GetUserLocation(); + const auto module_service_area = + rc_capabilities_manager_.GetModuleServiceArea(module); + const auto driver = + rc_capabilities_manager_.GetDriverLocationFromSeatLocationCapability(); + const bool is_driver = user_location == driver; + if (is_driver || user_location.IntersectionExists(module_service_area)) { + return true; + } + LOG4CXX_DEBUG(logger_, "User location is not valid"); + return false; +} + +void ResourceAllocationManagerImpl::ReleaseModuleType( const std::string& module_type, const uint32_t application_id) { LOG4CXX_AUTO_TRACE(logger_); - LOG4CXX_DEBUG(logger_, "Release " << module_type << " by " << application_id); - SetResourceFree(module_type, application_id); + LOG4CXX_DEBUG(logger_, + "Release " << module_type << " " + << " by " << application_id); + Resources allocated_resources = GetAcquiredResources(application_id); + for (const auto& resource : allocated_resources) { + if (module_type == resource.first) { + SetResourceFree(module_type, resource.second, application_id); + } + } } void ResourceAllocationManagerImpl::ProcessApplicationPolicyUpdate() { @@ -147,10 +191,10 @@ void ResourceAllocationManagerImpl::ProcessApplicationPolicyUpdate() { for (; app_list.end() != app; ++app) { application_manager::ApplicationSharedPtr app_ptr = *app; const uint32_t application_id = app_ptr->app_id(); - Resources acquired_modules = GetAcquiredResources(application_id); - std::sort(acquired_modules.begin(), acquired_modules.end()); + std::set acquired_modules = + GetAcquiredModuleTypes(application_id); - Resources allowed_modules; + std::vector allowed_modules; app_mngr_.GetPolicyHandler().GetModuleTypes((*app)->policy_app_id(), &allowed_modules); std::sort(allowed_modules.begin(), allowed_modules.end()); @@ -160,17 +204,16 @@ void ResourceAllocationManagerImpl::ProcessApplicationPolicyUpdate() { << " , allowed modules: " << allowed_modules.size()); - Resources disallowed_modules; + std::vector disallowed_modules; std::set_difference(acquired_modules.begin(), acquired_modules.end(), allowed_modules.begin(), allowed_modules.end(), std::back_inserter(disallowed_modules)); - auto rc_extention = RCHelpers::GetRCExtension(**app); - Resources::const_iterator module = disallowed_modules.begin(); + auto module = disallowed_modules.begin(); for (; disallowed_modules.end() != module; ++module) { - ReleaseResource(*module, application_id); + ReleaseModuleType(*module, application_id); } if (!disallowed_modules.empty()) { SendOnRCStatusNotifications( @@ -190,23 +233,24 @@ EnumType StringToEnum(const std::string& str) { void ConstructOnRCStatusNotificationParams( smart_objects::SmartObject& msg_params, - const std::map& allocated_resources, - const std::vector& supported_resources, + const std::map& allocated_resources, + const std::vector& supported_resources, const uint32_t app_id) { namespace strings = application_manager::strings; namespace message_params = rc_rpc_plugin::message_params; using smart_objects::SmartObject; - using smart_objects::SmartType_Map; using smart_objects::SmartType_Array; + using smart_objects::SmartType_Map; LOG4CXX_AUTO_TRACE(logger_); auto modules_inserter = [](SmartObject& result_modules) { - return [&result_modules](const std::string& module_name) { + return [&result_modules](const ModuleUid& module) { smart_objects::SmartObject module_data = SmartObject(smart_objects::SmartType_Map); auto module_type = - StringToEnum(module_name); + StringToEnum(module.first); module_data[message_params::kModuleType] = module_type; + module_data[message_params::kModuleId] = module.second; result_modules.asArray()->push_back(module_data); }; }; @@ -236,10 +280,11 @@ ResourceAllocationManagerImpl::CreateOnRCStatusNotificationToMobile( mobile_apis::FunctionID::OnRCStatusID, app->app_id()); auto& msg_params = (*msg_to_mobile)[application_manager::strings::msg_params]; if (is_rc_enabled()) { - ConstructOnRCStatusNotificationParams(msg_params, - allocated_resources_, - RCHelpers::GetModulesList(), - app->app_id()); + ConstructOnRCStatusNotificationParams( + msg_params, + allocated_resources_, + rc_capabilities_manager_.GetResources(), + app->app_id()); } else { msg_params[message_params::kAllocatedModules] = smart_objects::SmartObject(smart_objects::SmartType_Array); @@ -259,21 +304,12 @@ ResourceAllocationManagerImpl::CreateOnRCStatusNotificationToHmi( auto& msg_params = (*msg_to_hmi)[application_manager::strings::msg_params]; ConstructOnRCStatusNotificationParams(msg_params, allocated_resources_, - RCHelpers::GetModulesList(), + rc_capabilities_manager_.GetResources(), app->app_id()); msg_params[application_manager::strings::app_id] = app->hmi_app_id(); return msg_to_hmi; } -void ResourceAllocationManagerImpl::SetResourceAquired( - const std::string& module_type, const uint32_t app_id) { - LOG4CXX_AUTO_TRACE(logger_); - allocated_resources_[module_type] = app_id; - SendOnRCStatusNotifications( - NotificationTrigger::MODULE_ALLOCATION, - std::shared_ptr()); -} - void ResourceAllocationManagerImpl::SendOnRCStatusNotifications( NotificationTrigger::eType event, application_manager::ApplicationSharedPtr application) { @@ -310,25 +346,81 @@ void ResourceAllocationManagerImpl::set_rc_enabled(const bool value) { std::shared_ptr()); } -void ResourceAllocationManagerImpl::SetResourceFree( - const std::string& module_type, const uint32_t app_id) { +ResourceReleasedState::eType ResourceAllocationManagerImpl::ReleaseResource( + const std::string& module_type, + const std::string& module_id, + const uint32_t application_id) { + LOG4CXX_AUTO_TRACE(logger_); + LOG4CXX_DEBUG(logger_, + "Release " << module_type << " " << module_id << " by " + << application_id); + return SetResourceFree(module_type, module_id, application_id); +} + +void ResourceAllocationManagerImpl::SetResourceAcquired( + const std::string& module_type, + const std::string& module_id, + const uint32_t app_id) { + LOG4CXX_AUTO_TRACE(logger_); + ModuleUid module(module_type, module_id); + allocated_resources_[module] = app_id; +} + +bool ResourceAllocationManagerImpl::IsResourceAlreadyAcquiredByApp( + const ModuleUid& moduleUid, const uint32_t app_id) const { + LOG4CXX_AUTO_TRACE(logger_); + + auto allocation = allocated_resources_.find(moduleUid); + + if (allocated_resources_.end() == allocation) { + LOG4CXX_DEBUG(logger_, + "Resource " << moduleUid.first + << " is not allocated for any application."); + return false; + } + + if (allocation->second != app_id) { + LOG4CXX_DEBUG(logger_, + "Resource " + << moduleUid.first + << " is already allocated by app:" << allocation->second + << ". Asquire has been asked for app:" << app_id); + return false; + } + + LOG4CXX_DEBUG(logger_, + "Resource " << moduleUid.first + << " is allocated by app:" << allocation->second); + + return true; +} + +ResourceReleasedState::eType ResourceAllocationManagerImpl::SetResourceFree( + const std::string& module_type, + const std::string& module_id, + const uint32_t app_id) { + ModuleUid module(module_type, module_id); AllocatedResources::const_iterator allocation = - allocated_resources_.find(module_type); + allocated_resources_.find(module); if (allocated_resources_.end() == allocation) { LOG4CXX_DEBUG(logger_, "Resource " << module_type << " is not allocated."); - return; + return ResourceReleasedState::NOT_ALLOCATED; } if (app_id != allocation->second) { LOG4CXX_ERROR(logger_, "Resource " << module_type << " is allocated by different application " << allocation->second); + return ResourceReleasedState::IS_ALLOCATED; } allocated_resources_.erase(allocation); - LOG4CXX_DEBUG(logger_, "Resource " << module_type << " is released."); + LOG4CXX_DEBUG( + logger_, + "Resource " << module_type << ":" << module_id << " is released."); + return ResourceReleasedState::IS_RELEASED; } -std::vector ResourceAllocationManagerImpl::GetAcquiredResources( +std::vector ResourceAllocationManagerImpl::GetAcquiredResources( const uint32_t application_id) const { LOG4CXX_AUTO_TRACE(logger_); Resources allocated_resources; @@ -347,18 +439,37 @@ std::vector ResourceAllocationManagerImpl::GetAcquiredResources( return allocated_resources; } +std::set ResourceAllocationManagerImpl::GetAcquiredModuleTypes( + const uint32_t application_id) const { + LOG4CXX_AUTO_TRACE(logger_); + Resources allocated_resources = GetAcquiredResources(application_id); + std::set acquired_module_types; + for (const auto& resource : allocated_resources) { + acquired_module_types.insert(resource.first); + } + + LOG4CXX_DEBUG(logger_, + "Application " << application_id << " acquired " + << acquired_module_types.size() + << " module type(s)."); + + return acquired_module_types; +} + void ResourceAllocationManagerImpl::SetResourceState( const std::string& module_type, + const std::string& module_id, const uint32_t app_id, const ResourceState::eType state) { LOG4CXX_AUTO_TRACE(logger_); LOG4CXX_DEBUG(logger_, "Setting state for " << module_type << " by app_id " << app_id << " to state " << state); + ModuleUid module(module_type, module_id); { sync_primitives::AutoLock lock(allocated_resources_lock_); const AllocatedResources::const_iterator allocated_it = - allocated_resources_.find(module_type); + allocated_resources_.find(module); const bool acquired = allocated_resources_.end() != allocated_it; if (acquired) { @@ -374,16 +485,16 @@ void ResourceAllocationManagerImpl::SetResourceState( } sync_primitives::AutoLock lock(resources_state_lock_); - resources_state_[module_type] = state; + resources_state_[module] = state; LOG4CXX_DEBUG(logger_, "Resource " << module_type << " got state " << state); } bool ResourceAllocationManagerImpl::IsResourceFree( - const std::string& module_type) const { + const std::string& module_type, const std::string& module_id) const { LOG4CXX_AUTO_TRACE(logger_); + ModuleUid module(module_type, module_id); sync_primitives::AutoLock lock(resources_state_lock_); - const ResourcesState::const_iterator resource = - resources_state_.find(module_type); + const ResourcesState::const_iterator resource = resources_state_.find(module); if (resources_state_.end() == resource) { LOG4CXX_DEBUG(logger_, "Resource " << module_type << " is free."); @@ -411,15 +522,20 @@ ResourceAllocationManagerImpl::GetAccessMode() const { } void ResourceAllocationManagerImpl::ForceAcquireResource( - const std::string& module_type, const uint32_t app_id) { + const std::string& module_type, + const std::string& module_id, + const uint32_t app_id) { LOG4CXX_DEBUG(logger_, "Force " << app_id << " acquiring " << module_type); sync_primitives::AutoLock lock(allocated_resources_lock_); - SetResourceAquired(module_type, app_id); + SetResourceAcquired(module_type, module_id, app_id); } bool ResourceAllocationManagerImpl::IsModuleTypeRejected( - const std::string& module_type, const uint32_t app_id) { + const std::string& module_type, + const std::string& module_id, + const uint32_t app_id) { LOG4CXX_AUTO_TRACE(logger_); + ModuleUid module(module_type, module_id); sync_primitives::AutoLock lock(rejected_resources_for_application_lock_); RejectedResources::iterator it = rejected_resources_for_application_.find(app_id); @@ -428,24 +544,27 @@ bool ResourceAllocationManagerImpl::IsModuleTypeRejected( return false; } - const std::vector& list_of_rejected_resources = + const std::vector& list_of_rejected_resources = rejected_resources_for_application_[app_id]; - return helpers::in_range(list_of_rejected_resources, module_type); + return helpers::in_range(list_of_rejected_resources, module); } void ResourceAllocationManagerImpl::OnDriverDisallowed( - const std::string& module_type, const uint32_t app_id) { + const std::string& module_type, + const std::string& module_id, + const uint32_t app_id) { LOG4CXX_AUTO_TRACE(logger_); + ModuleUid module(module_type, module_id); sync_primitives::AutoLock lock(rejected_resources_for_application_lock_); auto it = rejected_resources_for_application_.find(app_id); if (rejected_resources_for_application_.end() == it) { - rejected_resources_for_application_[app_id] = std::vector(); + rejected_resources_for_application_[app_id] = std::vector(); } - std::vector& list_of_rejected_resources = + std::vector& list_of_rejected_resources = rejected_resources_for_application_[app_id]; - list_of_rejected_resources.push_back(module_type); + list_of_rejected_resources.push_back(module); } void ResourceAllocationManagerImpl::OnApplicationEvent( @@ -458,10 +577,10 @@ void ResourceAllocationManagerImpl::OnApplicationEvent( if (ApplicationEvent::kApplicationExit == event || ApplicationEvent::kApplicationUnregistered == event) { - Resources acquired_modules = GetAcquiredResources(application->app_id()); - Resources::const_iterator module = acquired_modules.begin(); + auto acquired_modules = GetAcquiredModuleTypes(application->app_id()); + auto module = acquired_modules.begin(); for (; acquired_modules.end() != module; ++module) { - ReleaseResource(*module, application->app_id()); + ReleaseModuleType(*module, application->app_id()); } if (!acquired_modules.empty()) { SendOnRCStatusNotifications( 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 c1c59d7e787..bd46bdf11ff 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 @@ -37,11 +37,14 @@ include_directories ( ${COMPONENTS_DIR}/application_manager/rpc_plugins/rc_rpc_plugin/test/include/ ${COMPONENTS_DIR}/include/test/application_manager/ ${COMPONENTS_DIR}/rc_rpc_plugin/test/include + ${COMPONENTS_DIR}/resumption/include ) set (RC_TEST_SOURCES -${CMAKE_CURRENT_SOURCE_DIR}/resource_allocation_manager_impl_test.cc ${CMAKE_CURRENT_SOURCE_DIR}/interior_data_cache_test.cc +${CMAKE_CURRENT_SOURCE_DIR}/rc_consent_manager_impl_test.cc +${CMAKE_CURRENT_SOURCE_DIR}/grid_test.cc +${CMAKE_CURRENT_SOURCE_DIR}/rc_helpers_test.cc ) set(RC_COMMANDS_TEST_DIR ${CMAKE_CURRENT_SOURCE_DIR}/commands) @@ -52,17 +55,9 @@ file(GLOB SOURCES ) set(LIBRARIES - RCRpcPluginStaticLib - ApplicationManager - connectionHandler - SmartObjects - ProtocolHandler - MessageHelper - connectionHandler - Utils - jsoncpp + rc_rpc_plugin_static + Resumption gmock_main - dl ) if(ENABLE_LOG) @@ -75,3 +70,4 @@ endif() create_test("rc_commands_test" "${SOURCES}" "${LIBRARIES}" ) create_test("rc_plugin_test" "${RC_TEST_SOURCES}" "${LIBRARIES}") +add_subdirectory(resource_allocation_manager) 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 e9d10636486..fb8de0bb9c0 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 @@ -30,22 +30,28 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include "gtest/gtest.h" #include "rc_rpc_plugin/commands/mobile/button_press_request.h" -#include "rc_rpc_plugin/rc_command_factory.h" -#include "rc_rpc_plugin/rc_app_extension.h" -#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/commands/command_request_test.h" #include "application_manager/mock_application.h" #include "application_manager/mock_application_manager.h" -#include "application_manager/commands/command_request_test.h" #include "application_manager/policies/mock_policy_handler_interface.h" +#include "gtest/gtest.h" #include "interfaces/HMI_API.h" #include "interfaces/MOBILE_API.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/mock/mock_rc_capabilities_manager.h" +#include "rc_rpc_plugin/mock/mock_rc_consent_manager.h" +#include "rc_rpc_plugin/mock/mock_resource_allocation_manager.h" +#include "rc_rpc_plugin/rc_app_extension.h" +#include "rc_rpc_plugin/rc_command_factory.h" +#include "rc_rpc_plugin/rc_module_constants.h" +#include "rc_rpc_plugin/rc_rpc_plugin.h" +using ::application_manager::Message; +using ::application_manager::MessageType; +using application_manager::commands::MessageSharedPtr; +using ::protocol_handler::MessagePriority; using test::components::application_manager_test::MockApplication; using test::components::commands_test::CommandRequestTest; using test::components::commands_test::CommandsTestMocks; @@ -57,17 +63,13 @@ using ::testing::NiceMock; using ::testing::Return; using ::testing::ReturnRef; using ::testing::SaveArg; -using ::application_manager::Message; -using ::application_manager::MessageType; -using application_manager::commands::MessageSharedPtr; -using ::protocol_handler::MessagePriority; namespace { const int kModuleId = 153u; const uint32_t kConnectionKey = 1u; const uint32_t kAppId = 0u; const std::string kPolicyAppId = "Test"; -} +} // namespace namespace rc_rpc_plugin_test { @@ -82,40 +84,9 @@ class ButtonPressRequestTest , rc_app_extention_( std::make_shared(kModuleId)) {} - smart_objects::SmartObject ButtonCapability( - const mobile_apis::ButtonName::eType button_name) { - smart_objects::SmartObject button(smart_objects::SmartType_Map); - button["name"] = button_name; - return button; - } - void SetUp() OVERRIDE { - using namespace mobile_apis; - - std::vector button_names = {ButtonName::AC_MAX, - ButtonName::AC, - ButtonName::RECIRCULATE, - ButtonName::FAN_UP, - ButtonName::FAN_DOWN, - ButtonName::TEMP_UP, - ButtonName::TEMP_DOWN, - ButtonName::DEFROST_MAX, - ButtonName::DEFROST, - ButtonName::DEFROST_REAR, - ButtonName::UPPER_VENT, - ButtonName::LOWER_VENT, - ButtonName::VOLUME_UP, - ButtonName::VOLUME_DOWN, - ButtonName::EJECT, - ButtonName::SOURCE, - ButtonName::SHUFFLE, - ButtonName::REPEAT}; - - smart_objects::SmartObject button_caps(smart_objects::SmartType_Array); - for (size_t i = 0; i < button_names.size(); i++) { - button_caps[i] = ButtonCapability(button_names[i]); - } - rc_capabilities_[strings::kbuttonCapabilities] = button_caps; + smart_objects::SmartObject control_caps((smart_objects::SmartType_Array)); + rc_capabilities_[strings::kradioControlCapabilities] = control_caps; ON_CALL(app_mngr_, application(_)).WillByDefault(Return(mock_app_)); ON_CALL(*mock_app_, QueryInterface(RCRPCPlugin::kRCPluginID)) .WillByDefault(Return(rc_app_extention_)); @@ -129,9 +100,16 @@ class ButtonPressRequestTest ON_CALL(mock_policy_handler_, CheckHMIType(kPolicyAppId, mobile_apis::AppHMIType::eType::REMOTE_CONTROL, - nullptr)).WillByDefault(Return(true)); + nullptr)) + .WillByDefault(Return(true)); ON_CALL(mock_allocation_manager_, is_rc_enabled()) .WillByDefault(Return(true)); + ON_CALL(mock_rc_capabilities_manager_, CheckButtonName(_, _)) + .WillByDefault(Return(true)); + ON_CALL(mock_rc_capabilities_manager_, CheckIfModuleExistsInCapabilities(_)) + .WillByDefault(Return(true)); + ON_CALL(mock_rc_capabilities_manager_, CheckIfButtonExistInRCCaps(_)) + .WillByDefault(Return(true)); } MessageSharedPtr CreateBasicMessage() { @@ -155,7 +133,9 @@ class ButtonPressRequestTest mock_policy_handler_, mock_allocation_manager_, mock_interior_data_cache_, - mock_interior_data_manager_}; + mock_interior_data_manager_, + mock_rc_capabilities_manager_, + mock_rc_consent_manger_}; return std::make_shared(msg ? msg : msg = CreateMessage(), params); } @@ -171,33 +151,41 @@ class ButtonPressRequestTest mock_interior_data_cache_; testing::NiceMock mock_interior_data_manager_; + testing::NiceMock + mock_rc_capabilities_manager_; + testing::NiceMock mock_rc_consent_manger_; }; TEST_F(ButtonPressRequestTest, Execute_ButtonNameMatchesModuleType_ExpectCorrectMessageSentToHMI) { // Arrange + const std::string resource = "CLIMATE"; + const std::string resource_id = "id1"; MessageSharedPtr mobile_message = CreateBasicMessage(); ns_smart_device_link::ns_smart_objects::SmartObject& msg_params = (*mobile_message)[application_manager::strings::msg_params]; msg_params[message_params::kModuleType] = mobile_apis::ModuleType::CLIMATE; + msg_params[message_params::kModuleId] = resource_id; msg_params[message_params::kButtonName] = mobile_apis::ButtonName::AC; msg_params[message_params::kButtonPressMode] = mobile_apis::ButtonPressMode::SHORT; // Expectations - const std::string resource = "CLIMATE"; ON_CALL(mock_policy_handler_, CheckModule(_, _)).WillByDefault(Return(true)); - EXPECT_CALL(mock_allocation_manager_, IsResourceFree(resource)) + + EXPECT_CALL(mock_allocation_manager_, IsResourceFree(resource, resource_id)) .WillOnce(Return(true)); - EXPECT_CALL(mock_allocation_manager_, AcquireResource(resource, _)) + EXPECT_CALL(mock_allocation_manager_, AcquireResource(resource, _, _)) .WillOnce(Return(rc_rpc_plugin::AcquireResult::ALLOWED)); EXPECT_CALL( mock_allocation_manager_, - SetResourceState(resource, kAppId, rc_rpc_plugin::ResourceState::BUSY)); - EXPECT_CALL(mock_rpc_service_, - ManageHMICommand( - HMIResultCodeIs(hmi_apis::FunctionID::Buttons_ButtonPress), - _)).WillOnce(Return(true)); + SetResourceState( + resource, resource_id, kAppId, rc_rpc_plugin::ResourceState::BUSY)); + EXPECT_CALL( + mock_rpc_service_, + ManageHMICommand( + HMIResultCodeIs(hmi_apis::FunctionID::Buttons_ButtonPress), _)) + .WillOnce(Return(true)); // Act std::shared_ptr command = @@ -211,28 +199,34 @@ TEST_F( ButtonPressRequestTest, Execute_ButtonNameDoesNotMatchModuleType_ExpectMessageNotSentToHMI_AndFalseSentToMobile) { // Arrange + const std::string resource = "RADIO"; + const std::string resource_id = "id1"; MessageSharedPtr mobile_message = CreateBasicMessage(); ns_smart_device_link::ns_smart_objects::SmartObject& msg_params = (*mobile_message)[application_manager::strings::msg_params]; msg_params[message_params::kModuleType] = mobile_apis::ModuleType::RADIO; + msg_params[message_params::kModuleId] = resource_id; msg_params[message_params::kButtonName] = mobile_apis::ButtonName::AC; msg_params[message_params::kButtonPressMode] = mobile_apis::ButtonPressMode::SHORT; // Expectations - const std::string resource = "RADIO"; + EXPECT_CALL(mock_rc_capabilities_manager_, CheckButtonName(_, _)) + .WillOnce(Return(false)); ON_CALL(mock_policy_handler_, CheckModule(_, _)).WillByDefault(Return(true)); - EXPECT_CALL(mock_allocation_manager_, IsResourceFree(resource)) + EXPECT_CALL(mock_allocation_manager_, IsResourceFree(resource, resource_id)) .WillOnce(Return(true)); - EXPECT_CALL(mock_allocation_manager_, AcquireResource(resource, _)) + EXPECT_CALL(mock_allocation_manager_, AcquireResource(resource, _, _)) .WillOnce(Return(rc_rpc_plugin::AcquireResult::ALLOWED)); - EXPECT_CALL(mock_allocation_manager_, SetResourceState(resource, kAppId, _)) + EXPECT_CALL(mock_allocation_manager_, + SetResourceState(resource, resource_id, kAppId, _)) .Times(2); - EXPECT_CALL(mock_rpc_service_, - ManageHMICommand( - HMIResultCodeIs(hmi_apis::FunctionID::Buttons_ButtonPress), - _)).Times(0); + EXPECT_CALL( + mock_rpc_service_, + ManageHMICommand( + HMIResultCodeIs(hmi_apis::FunctionID::Buttons_ButtonPress), _)) + .Times(0); MessageSharedPtr command_result; EXPECT_CALL(mock_rpc_service_, ManageMobileCommand( @@ -266,9 +260,10 @@ TEST_F(ButtonPressRequestTest, OnEvent_ExpectSuccessfullResponseSentToMobile) { hmi_msg_params[application_manager::strings::connection_key] = kConnectionKey; // Expectations - EXPECT_CALL(mock_allocation_manager_, - SetResourceState(_, kAppId, rc_rpc_plugin::ResourceState::FREE)) - .Times(2); + EXPECT_CALL( + mock_allocation_manager_, + SetResourceState(_, _, kAppId, rc_rpc_plugin::ResourceState::FREE)) + .Times(1); EXPECT_CALL( mock_rpc_service_, @@ -305,9 +300,10 @@ TEST_F(ButtonPressRequestTest, hmi_msg_params[application_manager::strings::connection_key] = kConnectionKey; // Expectations - EXPECT_CALL(mock_allocation_manager_, - SetResourceState(_, kAppId, rc_rpc_plugin::ResourceState::FREE)) - .Times(2); + EXPECT_CALL( + mock_allocation_manager_, + SetResourceState(_, _, kAppId, rc_rpc_plugin::ResourceState::FREE)) + .Times(1); EXPECT_CALL(mock_rpc_service_, ManageMobileCommand( diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/get_interior_vehicle_data_consent_request_test.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/get_interior_vehicle_data_consent_request_test.cc new file mode 100644 index 00000000000..29708d05bda --- /dev/null +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/get_interior_vehicle_data_consent_request_test.cc @@ -0,0 +1,402 @@ +/* + * Copyright (c) 2019, 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 "gmock/gmock.h" +#include "gtest/gtest.h" + +#include "rc_rpc_plugin/commands/mobile/get_interior_vehicle_data_consent_request.h" + +#include "application_manager/commands/command_request_test.h" +#include "application_manager/mock_application.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/mock/mock_rc_capabilities_manager.h" +#include "rc_rpc_plugin/mock/mock_rc_consent_manager.h" +#include "rc_rpc_plugin/mock/mock_resource_allocation_manager.h" +#include "rc_rpc_plugin/rc_module_constants.h" + +using application_manager::commands::MessageSharedPtr; +using rc_rpc_plugin_test::MockInteriorDataCache; +using rc_rpc_plugin_test::MockInteriorDataManager; +using rc_rpc_plugin_test::MockRCCapabilitiesManager; +using rc_rpc_plugin_test::MockRCConsentManager; +using rc_rpc_plugin_test::MockResourceAllocationManager; +using test::components::application_manager_test::MockApplication; +using test::components::commands_test::CommandRequestTest; +using test::components::commands_test::CommandsTestMocks; + +using ::testing::_; +using ::testing::DoAll; +using ::testing::NiceMock; +using ::testing::Return; +using ::testing::ReturnRef; +using ::testing::SaveArg; + +typedef std::shared_ptr< + rc_rpc_plugin::commands::GetInteriorVehicleDataConsentRequest> + GIVDConsentPtr; + +namespace { +const uint32_t kConnectionKey = 1u; +const uint32_t kAppId = 2u; +const std::string kPolicyAppId = "policy_app_id"; +const std::string kMacAddress = "device1"; +const std::string kModuleId_1 = "34045662-a9dc-4823-8435-91056d4c26cb"; +const std::string kModuleId_2 = "eb7739ea-b263-4fe1-af9c-9311d1acac2d"; +const std::string kModuleId_3 = "06cdec22-920e-4865-bf2e-9518463edc68"; +const mobile_apis::ModuleType::eType kModule_Type = + mobile_apis::ModuleType::eType::RADIO; +} // namespace + +namespace rc_rpc_plugin_test { +namespace get_interior_vehicle_data_consent_request_test { +using namespace rc_rpc_plugin; + +class GetInteriorVehicleDataConsentRequestTest + : public CommandRequestTest { + public: + GetInteriorVehicleDataConsentRequestTest() : mock_app_(CreateMockApp()) {} + + void SetUp() OVERRIDE { + TestPrecondition(); + } + + void TestPrecondition() { + message_ = CreateBasicMessage(); + ON_CALL(mock_rc_capabilities_manager_, CheckIfModuleExistsInCapabilities(_)) + .WillByDefault(Return(true)); + ON_CALL(mock_rc_capabilities_manager_, IsMultipleAccessAllowed(_)) + .WillByDefault(Return(true)); + } + + void PrepareNoConsentExistInCache() { + ON_CALL(mock_allocation_manager_, GetAccessMode()) + .WillByDefault(Return(hmi_apis::Common_RCAccessMode::ASK_DRIVER)); + ON_CALL(app_mngr_, application(_)).WillByDefault(Return(mock_app_)); + ON_CALL(*mock_app_, app_id()).WillByDefault(Return(kAppId)); + ON_CALL(*mock_app_, policy_app_id()).WillByDefault(Return(kPolicyAppId)); + ON_CALL(*mock_app_, mac_address()).WillByDefault(ReturnRef(kMacAddress)); + ON_CALL(mock_rc_consent_manger_, + GetModuleConsent(kPolicyAppId, kMacAddress, _)) + .WillByDefault(Return(rc_rpc_types::ModuleConsent::NOT_EXISTS)); + ON_CALL(mock_allocation_manager_, + AcquireResource(_, _, mock_app_->app_id())) + .WillByDefault(Return(AcquireResult::IN_USE)); + } + + void PrepareMobileMessage() { + auto& msg_params = (*message_)[application_manager::strings::msg_params]; + msg_params[message_params::kModuleType] = kModule_Type; + + msg_params[message_params::kModuleIds][0] = kModuleId_1; + msg_params[message_params::kModuleIds][1] = kModuleId_2; + msg_params[message_params::kModuleIds][2] = kModuleId_3; + } + + /** + * @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::app_id] = kAppId; + return message; + } + + template + std::shared_ptr CreateRCCommand(MessageSharedPtr& msg) { + InitCommand(kDefaultTimeout_); + RCCommandParams params{app_mngr_, + mock_rpc_service_, + mock_hmi_capabilities_, + mock_policy_handler_, + mock_allocation_manager_, + mock_interior_data_cache_, + mock_interior_data_manager_, + mock_rc_capabilities_manager_, + mock_rc_consent_manger_}; + return std::make_shared(msg ? msg : msg = CreateMessage(), params); + } + + protected: + GIVDConsentPtr command_; + MessageSharedPtr message_; + + MockAppPtr mock_app_; + NiceMock mock_allocation_manager_; + NiceMock mock_interior_data_cache_; + NiceMock mock_interior_data_manager_; + NiceMock mock_rc_capabilities_manager_; + NiceMock mock_rc_consent_manger_; +}; + +TEST_F(GetInteriorVehicleDataConsentRequestTest, + ModuleIDReturnsEmptyString_SUCCESS) { + std::string empty_str; + command_ = + CreateRCCommand(message_); + + EXPECT_EQ(empty_str, command_->ModuleId()); +} + +TEST_F(GetInteriorVehicleDataConsentRequestTest, + Execute_ModuleIdsIsAbsentInMessage_Response_INVALID_DATA) { + command_ = + CreateRCCommand(message_); + + auto response_to_mobile = CreateMessage(); + + EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_, _)).Times(0); + + EXPECT_CALL(mock_rpc_service_, ManageMobileCommand(_, _)) + .WillOnce(DoAll(SaveArg<0>(&response_to_mobile), Return(true))); + + command_->Execute(); + + const bool result = + (*response_to_mobile)[application_manager::strings::msg_params] + [application_manager::strings::success] + .asBool(); + const auto result_code = static_cast( + (*response_to_mobile)[application_manager::strings::msg_params] + [application_manager::strings::result_code] + .asUInt()); + EXPECT_FALSE(result); + EXPECT_EQ(mobile_apis::Result::INVALID_DATA, result_code); +} + +TEST_F(GetInteriorVehicleDataConsentRequestTest, + Execute_ModuleIdsIsEmpty_AddDefaultModuleID) { + (*message_)[application_manager::strings::msg_params] + [message_params::kModuleIds] = smart_objects::SmartObject( + smart_objects::SmartType::SmartType_Array); + (*message_)[application_manager::strings::msg_params] + [message_params::kModuleType] = kModule_Type; + command_ = + CreateRCCommand(message_); + + auto message_to_hmi = CreateMessage(); + + const std::string module_type = "RADIO"; + const std::string default_module_id = "34045662-a9dc-4823-8435-91056d4c26cb"; + ON_CALL(mock_rc_capabilities_manager_, + GetDefaultModuleIdFromCapabilities(module_type)) + .WillByDefault(Return(default_module_id)); + + PrepareNoConsentExistInCache(); + + EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_, _)) + .WillOnce(DoAll(SaveArg<0>(&message_to_hmi), Return(true))); + + command_->Execute(); + + ASSERT_FALSE((*message_to_hmi)[application_manager::strings::msg_params] + [message_params::kModuleIds] + .empty()); + const auto sent_module_id = + (*message_to_hmi)[application_manager::strings::msg_params] + [message_params::kModuleIds][0] + .asString(); + EXPECT_EQ(sent_module_id, default_module_id); +} + +TEST_F(GetInteriorVehicleDataConsentRequestTest, + Execute_SDLForwardsMobileMessageToHMI_SUCCESS) { + auto message_to_hmi = CreateMessage(); + + PrepareMobileMessage(); + PrepareNoConsentExistInCache(); + + command_ = + CreateRCCommand(message_); + + EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_, _)) + .WillOnce(DoAll(SaveArg<0>(&message_to_hmi), Return(true))); + + command_->Execute(); + + auto outgoing_msg_params = + (*message_to_hmi)[application_manager::strings::msg_params]; + + auto module_type = static_cast( + outgoing_msg_params[message_params::kModuleType].asUInt()); + + EXPECT_EQ(kModule_Type, module_type); + EXPECT_EQ(kModuleId_1, + outgoing_msg_params[message_params::kModuleIds][0].asString()); + EXPECT_EQ(kModuleId_2, + outgoing_msg_params[message_params::kModuleIds][1].asString()); + EXPECT_EQ(kModuleId_3, + outgoing_msg_params[message_params::kModuleIds][2].asString()); +} + +TEST_F(GetInteriorVehicleDataConsentRequestTest, + On_Event_ConsentCollectionIsAbsentOrEmpty_Response_GENERIC_ERROR) { + PrepareMobileMessage(); + + command_ = + CreateRCCommand(message_); + + // Consent collection in HMI response is absent + auto event_message = CreateMessage(); + application_manager::event_engine::Event event_collection_is_absent( + hmi_apis::FunctionID::RC_GetInteriorVehicleDataConsent); + event_collection_is_absent.set_smart_object(*event_message); + + auto response_to_mobile = CreateMessage(); + + EXPECT_CALL(mock_rpc_service_, ManageMobileCommand(_, _)) + .WillOnce(DoAll(SaveArg<0>(&response_to_mobile), Return(true))); + + command_->on_event(event_collection_is_absent); + + const auto result_code_is_absent = static_cast( + (*response_to_mobile)[application_manager::strings::msg_params] + [application_manager::strings::result_code] + .asUInt()); + EXPECT_EQ(mobile_apis::Result::GENERIC_ERROR, result_code_is_absent); + + // Consent coolection in HMI response isn't absent but is empty + event_message = CreateMessage(); + application_manager::event_engine::MobileEvent event_collection_is_empty( + mobile_apis::FunctionID::GetInteriorVehicleDataConsentID); + (*event_message)[application_manager::strings::msg_params] + [message_params::kAllowed] = smart_objects::SmartObject( + smart_objects::SmartType::SmartType_Array); + event_collection_is_empty.set_smart_object(*event_message); + + response_to_mobile = CreateMessage(); + + EXPECT_CALL(mock_rpc_service_, ManageMobileCommand(_, _)) + .WillOnce(DoAll(SaveArg<0>(&response_to_mobile), Return(true))); + + command_->on_event(event_collection_is_absent); + + const auto result_code_is_empty = static_cast( + (*response_to_mobile)[application_manager::strings::msg_params] + [application_manager::strings::result_code] + .asUInt()); + EXPECT_EQ(mobile_apis::Result::GENERIC_ERROR, result_code_is_empty); +} + +TEST_F(GetInteriorVehicleDataConsentRequestTest, + On_Event_ConsentsSizeIsNotEqualModuleIdsSize_Response_GENERIC_ERROR) { + PrepareMobileMessage(); + PrepareNoConsentExistInCache(); + + // ModuleIds collection will be saved + command_ = + CreateRCCommand(message_); + command_->Execute(); + + auto event_message = CreateMessage(); + (*event_message)[application_manager::strings::msg_params] + [message_params::kAllowed] = smart_objects::SmartObject( + smart_objects::SmartType::SmartType_Array); + + // Consent collection will contain only two items in collection + (*event_message)[application_manager::strings::msg_params] + [message_params::kAllowed][0] = true; + (*event_message)[application_manager::strings::msg_params] + [message_params::kAllowed][1] = false; + + application_manager::event_engine::Event event( + hmi_apis::FunctionID::RC_GetInteriorVehicleDataConsent); + event.set_smart_object(*event_message); + + auto response_to_mobile = CreateMessage(); + EXPECT_CALL(mock_rpc_service_, ManageMobileCommand(_, _)) + .WillOnce(DoAll(SaveArg<0>(&response_to_mobile), Return(true))); + + command_->on_event(event); + + const auto result_code_is_empty = static_cast( + (*response_to_mobile)[application_manager::strings::msg_params] + [application_manager::strings::result_code] + .asUInt()); + EXPECT_EQ(mobile_apis::Result::GENERIC_ERROR, result_code_is_empty); +} + +TEST_F(GetInteriorVehicleDataConsentRequestTest, + On_Event_SaveModuleConsentsToLastState_Response_SUCCESS) { + PrepareMobileMessage(); + PrepareNoConsentExistInCache(); + + // ModuleIds collection will be saved + command_ = + CreateRCCommand(message_); + command_->Execute(); + + // Consent collection will have same size as moduelIds collection + auto event_message = CreateMessage(); + (*event_message)[application_manager::strings::msg_params] + [message_params::kAllowed][0] = true; + (*event_message)[application_manager::strings::msg_params] + [message_params::kAllowed][1] = false; + (*event_message)[application_manager::strings::msg_params] + [message_params::kAllowed][2] = false; + + application_manager::event_engine::Event event( + hmi_apis::FunctionID::RC_GetInteriorVehicleDataConsent); + event.set_smart_object(*event_message); + + ON_CALL(app_mngr_, application(_)).WillByDefault(Return(mock_app_)); + ON_CALL(*mock_app_, policy_app_id()).WillByDefault(Return(kPolicyAppId)); + ON_CALL(*mock_app_, mac_address()).WillByDefault(ReturnRef(kMacAddress)); + + EXPECT_CALL(mock_rc_consent_manger_, SaveModuleConsents(kPolicyAppId, _, _)); + + auto response_to_mobile = CreateMessage(); + EXPECT_CALL(mock_rpc_service_, ManageMobileCommand(_, _)) + .WillOnce(DoAll(SaveArg<0>(&response_to_mobile), Return(true))); + + command_->on_event(event); + + const auto result_code_is_empty = static_cast( + (*response_to_mobile)[application_manager::strings::msg_params] + [application_manager::strings::result_code] + .asUInt()); + EXPECT_EQ(mobile_apis::Result::SUCCESS, result_code_is_empty); +} + +} // namespace get_interior_vehicle_data_consent_request_test +} // namespace rc_rpc_plugin_test 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 4e74e74ef8a..532a62df3bf 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 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Ford Motor Company + * Copyright (c) 2019, Ford Motor Company * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -31,52 +31,57 @@ */ #include "rc_rpc_plugin/commands/mobile/get_interior_vehicle_data_request.h" -#include "gtest/gtest.h" +#include "application_manager/commands/command_request_test.h" +#include "application_manager/event_engine/event_dispatcher.h" +#include "application_manager/message_helper.h" #include "application_manager/mock_application.h" +#include "gtest/gtest.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/mock/mock_rc_capabilities_manager.h" +#include "rc_rpc_plugin/mock/mock_rc_consent_manager.h" +#include "rc_rpc_plugin/mock/mock_resource_allocation_manager.h" #include "rc_rpc_plugin/rc_app_extension.h" +#include "rc_rpc_plugin/rc_command_factory.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 #include +#include -using ::testing::_; -using ::testing::Mock; -using ::testing::NiceMock; -using ::testing::StrictMock; -using ::testing::Return; -using ::testing::ReturnRef; -using ::testing::SaveArg; +using application_manager::ApplicationSet; +using ::application_manager::ApplicationSharedPtr; 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; using test::components::application_manager_test::MockApplication; using test::components::application_manager_test::MockApplicationManager; -using test::components::commands_test::MockApplicationManager; using test::components::commands_test::CommandRequestTest; using test::components::commands_test::CommandsTestMocks; using test::components::commands_test::HMIResultCodeIs; using test::components::commands_test::MobileResultCodeIs; +using test::components::commands_test::MockApplicationManager; +using ::testing::_; +using ::testing::Mock; +using ::testing::NiceMock; +using ::testing::Return; +using ::testing::ReturnRef; +using ::testing::SaveArg; +using ::testing::StrictMock; 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 auto module_eType = mobile_apis::ModuleType::RADIO; +const auto module_type = "RADIO"; +const auto module_id = "eb7739ea-b263-4fe1-af9c-9311d1acac2d"; const int32_t time_frame_of_allowed_requests = 1; const uint32_t max_request_in_time_frame = 5u; -} +} // namespace namespace rc_rpc_plugin_test { @@ -90,7 +95,8 @@ class GetInteriorVehicleDataRequestTest , rc_app_extention_(std::make_shared(kModuleId)) , rc_app_extention2_(std::make_shared(kModuleId)) , apps_lock_(std::make_shared()) - , apps_da_(apps_, apps_lock_) { + , apps_da_(apps_, apps_lock_) + , rc_capabilities_(smart_objects::SmartType::SmartType_Array) { 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()) @@ -124,6 +130,8 @@ class GetInteriorVehicleDataRequestTest std::pair frequency; frequency.first = max_request_in_time_frame; frequency.second = time_frame_of_allowed_requests; + smart_objects::SmartObject control_caps((smart_objects::SmartType_Array)); + rc_capabilities_[strings::kradioControlCapabilities] = control_caps; ON_CALL(app_mngr_, get_settings()) .WillByDefault(ReturnRef(app_mngr_settings_)); ON_CALL(app_mngr_settings_, get_interior_vehicle_data_frequency()) @@ -143,7 +151,7 @@ class GetInteriorVehicleDataRequestTest ON_CALL(app_mngr_, hmi_capabilities()) .WillByDefault(ReturnRef(mock_hmi_capabilities_)); ON_CALL(mock_hmi_capabilities_, rc_capability()) - .WillByDefault(Return(nullptr)); + .WillByDefault(Return(&rc_capabilities_)); ON_CALL(mock_policy_handler_, CheckHMIType( _, mobile_apis::AppHMIType::eType::REMOTE_CONTROL, nullptr)) @@ -152,6 +160,8 @@ class GetInteriorVehicleDataRequestTest .WillByDefault(Return(true)); ON_CALL(mock_allocation_manager_, is_rc_enabled()) .WillByDefault(Return(true)); + ON_CALL(mock_rc_capabilities_manager_, CheckIfModuleExistsInCapabilities(_)) + .WillByDefault(Return(true)); } template @@ -163,7 +173,9 @@ class GetInteriorVehicleDataRequestTest mock_policy_handler_, mock_allocation_manager_, mock_interior_data_cache_, - mock_interior_data_manager_}; + mock_interior_data_manager_, + mock_rc_capabilities_manager_, + mock_rc_consent_manger_}; return std::make_shared(msg ? msg : msg = CreateMessage(), params); } @@ -181,6 +193,10 @@ class GetInteriorVehicleDataRequestTest application_manager::ApplicationSet apps_; const std::shared_ptr apps_lock_; DataAccessor apps_da_; + testing::NiceMock + mock_rc_capabilities_manager_; + smart_objects::SmartObject rc_capabilities_; + testing::NiceMock mock_rc_consent_manger_; }; TEST_F(GetInteriorVehicleDataRequestTest, @@ -188,13 +204,15 @@ TEST_F(GetInteriorVehicleDataRequestTest, // Arrange 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)) + [message_params::kModuleType] = module_eType; + (*mobile_message)[application_manager::strings::msg_params] + [message_params::kModuleType] = module_id; + const ModuleUid module(module_type, module_id); + ON_CALL(mock_interior_data_cache_, Contains(module)) .WillByDefault(Return(false)); ON_CALL(mock_interior_data_manager_, CheckRequestsToHMIFrequency(_)) .WillByDefault(Return(true)); - std::shared_ptr< - rc_rpc_plugin::commands::GetInteriorVehicleDataRequest> command = + auto command = CreateRCCommand( mobile_message); @@ -205,6 +223,8 @@ TEST_F(GetInteriorVehicleDataRequestTest, HMIResultCodeIs(hmi_apis::FunctionID::RC_GetInteriorVehicleData), _)) .WillOnce(Return(true)); // Act + + ASSERT_TRUE(command->Init()); command->Run(); } @@ -213,15 +233,17 @@ TEST_F(GetInteriorVehicleDataRequestTest, // Arrange MessageSharedPtr mobile_message = CreateBasicMessage(); (*mobile_message)[application_manager::strings::msg_params] - [message_params::kModuleType] = module_type; + [message_params::kModuleType] = module_eType; + (*mobile_message)[application_manager::strings::msg_params] + [message_params::kModuleId] = module_id; (*mobile_message)[application_manager::strings::msg_params] [message_params::kSubscribe] = true; - ON_CALL(mock_interior_data_cache_, Contains(enums_value::kRadio)) + const ModuleUid module(module_type, module_id); + ON_CALL(mock_interior_data_cache_, Contains(module)) .WillByDefault(Return(false)); ON_CALL(mock_interior_data_manager_, CheckRequestsToHMIFrequency(_)) .WillByDefault(Return(true)); - std::shared_ptr< - rc_rpc_plugin::commands::GetInteriorVehicleDataRequest> command = + auto command = CreateRCCommand( mobile_message); @@ -232,6 +254,7 @@ TEST_F(GetInteriorVehicleDataRequestTest, HMIResultCodeIs(hmi_apis::FunctionID::RC_GetInteriorVehicleData), _)) .WillOnce(Return(true)); // Act + ASSERT_TRUE(command->Init()); command->Run(); } @@ -239,21 +262,35 @@ TEST_F( GetInteriorVehicleDataRequestTest, Execute_ExpectMessageNotSentToHMI_SuccessSentToMobile_AppSubscribed_DataFromCache) { // Arrange - rc_app_extention_->SubscribeToInteriorVehicleData(enums_value::kRadio); + const ModuleUid module(module_type, module_id); + rc_app_extention_->SubscribeToInteriorVehicleData(module); MessageSharedPtr mobile_message = CreateBasicMessage(); (*mobile_message)[application_manager::strings::msg_params] - [message_params::kModuleType] = module_type; + [message_params::kModuleType] = module_eType; + (*mobile_message)[application_manager::strings::msg_params] + [message_params::kModuleId] = module_id; smart_objects::SmartObject radio_data; + smart_objects::SmartObject sis_data; + smart_objects::SmartObject gps_data; + + gps_data[application_manager::strings::longitude_degrees] = 1.0; + gps_data[application_manager::strings::latitude_degrees] = 1.0; + + sis_data[application_manager::strings::station_short_name] = + "dummy_short_name"; + sis_data[application_manager::strings::station_location] = gps_data; + radio_data[message_params::kBand] = enums_value::kAM; - std::shared_ptr< - rc_rpc_plugin::commands::GetInteriorVehicleDataRequest> command = + radio_data[message_params::kSisData] = sis_data; + + auto command = CreateRCCommand( mobile_message); // Expectations - EXPECT_CALL(mock_interior_data_cache_, Contains(enums_value::kRadio)) + EXPECT_CALL(mock_interior_data_cache_, Contains(module)) .WillOnce(Return(true)); - EXPECT_CALL(mock_interior_data_cache_, Retrieve(enums_value::kRadio)) + EXPECT_CALL(mock_interior_data_cache_, Retrieve(module)) .WillOnce(Return(radio_data)); EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_, _)).Times(0); MessageSharedPtr command_result; @@ -263,6 +300,7 @@ TEST_F( .WillOnce(DoAll(SaveArg<0>(&command_result), Return(true))); // Act + ASSERT_TRUE(command->Init()); command->Run(); // Assert @@ -274,13 +312,16 @@ TEST_F( TEST_F( GetInteriorVehicleDataRequestTest, - Execute_ExpectCorrectMessageSentToHMI_LastAppSubscribedUnsubscibe_ClearCache) { + Execute_ExpectCorrectMessageSentToHMI_LastAppSubscribedUnsubscribe_ClearCache) { // Arrange MessageSharedPtr mobile_message = CreateBasicMessage(); (*mobile_message)[application_manager::strings::msg_params] - [message_params::kModuleType] = module_type; + [message_params::kModuleType] = module_eType; (*mobile_message)[application_manager::strings::msg_params] [message_params::kSubscribe] = false; + (*mobile_message)[application_manager::strings::msg_params] + [message_params::kModuleId] = module_id; + const ModuleUid module(module_type, module_id); MessageSharedPtr hmi_response = CreateBasicMessage(); ns_smart_device_link::ns_smart_objects::SmartObject& hmi_msg_params = @@ -289,9 +330,11 @@ TEST_F( hmi_apis::Common_Result::SUCCESS; hmi_msg_params[application_manager::hmi_response::code] = response_code; hmi_msg_params[application_manager::strings::connection_key] = kConnectionKey; + hmi_msg_params[message_params::kModuleData][message_params::kModuleId] = + module_id; apps_.insert(mock_app_); - rc_app_extention_->SubscribeToInteriorVehicleData(enums_value::kRadio); + rc_app_extention_->SubscribeToInteriorVehicleData(module); ON_CALL(app_mngr_, applications()).WillByDefault(Return(apps_da_)); ON_CALL(mock_interior_data_manager_, CheckRequestsToHMIFrequency(_)) .WillByDefault(Return(true)); @@ -307,13 +350,13 @@ TEST_F( ManageMobileCommand(MobileResultCodeIs(mobile_apis::Result::SUCCESS), _)) .WillOnce(Return(true)); - EXPECT_CALL(mock_interior_data_cache_, Remove(enums_value::kRadio)); + EXPECT_CALL(mock_interior_data_cache_, Remove(module)); // Act - std::shared_ptr< - rc_rpc_plugin::commands::GetInteriorVehicleDataRequest> command = + auto command = CreateRCCommand( mobile_message); + ASSERT_TRUE(command->Init()); command->Run(); application_manager::event_engine::Event event( hmi_apis::FunctionID::RC_GetInteriorVehicleData); @@ -326,28 +369,30 @@ TEST_F(GetInteriorVehicleDataRequestTest, // Arrange MessageSharedPtr mobile_message = CreateBasicMessage(); (*mobile_message)[application_manager::strings::msg_params] - [message_params::kModuleType] = module_type; + [message_params::kModuleType] = module_eType; (*mobile_message)[application_manager::strings::msg_params] [message_params::kSubscribe] = false; + (*mobile_message)[application_manager::strings::msg_params] + [message_params::kModuleId] = module_id; + const ModuleUid module(module_type, module_id); apps_.insert(mock_app_); apps_.insert(mock_app2_); - rc_app_extention_->SubscribeToInteriorVehicleData(enums_value::kRadio); - rc_app_extention2_->SubscribeToInteriorVehicleData(enums_value::kRadio); + rc_app_extention_->SubscribeToInteriorVehicleData(module); + rc_app_extention2_->SubscribeToInteriorVehicleData(module); 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 = + auto command = CreateRCCommand( mobile_message); // Expectations - EXPECT_CALL(mock_interior_data_cache_, Contains(enums_value::kRadio)) + EXPECT_CALL(mock_interior_data_cache_, Contains(module)) .WillOnce(Return(true)); - EXPECT_CALL(mock_interior_data_cache_, Retrieve(enums_value::kRadio)) + EXPECT_CALL(mock_interior_data_cache_, Retrieve(module)) .WillOnce(Return(radio_data)); EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_, _)).Times(0); @@ -358,11 +403,12 @@ TEST_F(GetInteriorVehicleDataRequestTest, .WillOnce(DoAll(SaveArg<0>(&command_result), Return(true))); // Act + ASSERT_TRUE(command->Init()); command->Run(); // Assert - EXPECT_FALSE( - rc_app_extention_->IsSubscibedToInteriorVehicleData(enums_value::kRadio)); + EXPECT_FALSE(rc_app_extention_->IsSubscribedToInteriorVehicleDataOfType( + enums_value::kRadio)); EXPECT_EQ((*command_result)[application_manager::strings::msg_params] [message_params::kModuleData] [message_params::kRadioControlData], @@ -376,22 +422,22 @@ TEST_F( MessageSharedPtr mobile_message = CreateBasicMessage(); ns_smart_device_link::ns_smart_objects::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 = + msg_params[message_params::kModuleType] = module_eType; + auto command = CreateRCCommand( mobile_message); - smart_objects::SmartObject rc_capabilities; ON_CALL(mock_hmi_capabilities_, rc_capability()) - .WillByDefault(Return(&rc_capabilities)); + .WillByDefault(Return(nullptr)); // Expectations EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_, _)).Times(0); - EXPECT_CALL(mock_rpc_service_, - ManageMobileCommand( - MobileResultCodeIs(mobile_apis::Result::UNSUPPORTED_RESOURCE), - _)).WillOnce((Return(true))); + EXPECT_CALL( + mock_rpc_service_, + ManageMobileCommand( + MobileResultCodeIs(mobile_apis::Result::UNSUPPORTED_RESOURCE), _)) + .WillOnce((Return(true))); // Act + ASSERT_TRUE(command->Init()); command->Run(); } @@ -402,9 +448,8 @@ TEST_F( MessageSharedPtr mobile_message = CreateBasicMessage(); ns_smart_device_link::ns_smart_objects::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 = + msg_params[message_params::kModuleType] = module_eType; + auto command = CreateRCCommand( mobile_message); ON_CALL(mock_policy_handler_, CheckModule(_, _)).WillByDefault(Return(false)); @@ -417,6 +462,7 @@ TEST_F( .WillOnce((Return(true))); // Act + ASSERT_TRUE(command->Init()); command->Run(); } @@ -429,12 +475,14 @@ TEST_F(GetInteriorVehicleDataRequestTest, // Arrange MessageSharedPtr mobile_message = CreateBasicMessage(); auto& msg_params = (*mobile_message)[strings::msg_params]; - msg_params[message_params::kModuleType] = module_type; + msg_params[message_params::kModuleType] = module_eType; 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; + hmi_response_params[message_params::kModuleData][message_params::kModuleId] = + module_id; ON_CALL(mock_interior_data_cache_, Contains(_)).WillByDefault(Return(false)); ON_CALL(mock_interior_data_manager_, CheckRequestsToHMIFrequency(_)) @@ -457,6 +505,7 @@ TEST_F(GetInteriorVehicleDataRequestTest, application_manager::event_engine::Event event( hmi_apis::FunctionID::RC_GetInteriorVehicleData); event.set_smart_object(*hmi_response_message); + ASSERT_TRUE(command->Init()); command->Run(); command->on_event(event); } @@ -471,7 +520,7 @@ TEST_F(GetInteriorVehicleDataRequestTest, MessageSharedPtr mobile_message = CreateBasicMessage(); auto& msg_params = (*mobile_message)[application_manager::strings::msg_params]; - msg_params[message_params::kModuleType] = module_type; + msg_params[message_params::kModuleType] = module_eType; MessageSharedPtr hmi_message = CreateBasicMessage(); auto& hmi_msg_params = (*hmi_message)[strings::params]; @@ -497,19 +546,22 @@ TEST_F(GetInteriorVehicleDataRequestTest, hmi_apis::FunctionID::RC_GetInteriorVehicleData); event.set_smart_object(*hmi_message); auto command = CreateRCCommand(mobile_message); + ASSERT_TRUE(command->Init()); command->Run(); command->on_event(event); } TEST_F(GetInteriorVehicleDataRequestTest, - OnEvent_InvalidHmiResponse_DontUnsubscibeLastApp_NoClearCache) { + OnEvent_InvalidHmiResponse_DontUnsubscribeLastApp_NoClearCache) { // Arrange MessageSharedPtr mobile_message = CreateBasicMessage(); (*mobile_message)[application_manager::strings::msg_params] - [message_params::kModuleType] = module_type; + [message_params::kModuleType] = module_eType; + (*mobile_message)[application_manager::strings::msg_params] + [message_params::kModuleId] = module_id; (*mobile_message)[application_manager::strings::msg_params] [message_params::kSubscribe] = false; - + const ModuleUid module(module_type, module_id); MessageSharedPtr hmi_response = CreateBasicMessage(); ns_smart_device_link::ns_smart_objects::SmartObject& hmi_msg_params = (*hmi_response)[application_manager::strings::params]; @@ -518,7 +570,7 @@ TEST_F(GetInteriorVehicleDataRequestTest, hmi_msg_params[application_manager::strings::connection_key] = kConnectionKey; apps_.insert(mock_app_); - rc_app_extention_->SubscribeToInteriorVehicleData(enums_value::kRadio); + rc_app_extention_->SubscribeToInteriorVehicleData(module); ON_CALL(app_mngr_, applications()).WillByDefault(Return(apps_da_)); ON_CALL(mock_interior_data_manager_, CheckRequestsToHMIFrequency(_)) .WillByDefault(Return(true)); @@ -537,10 +589,10 @@ TEST_F(GetInteriorVehicleDataRequestTest, EXPECT_CALL(mock_interior_data_cache_, Clear()).Times(0); // Act - std::shared_ptr< - rc_rpc_plugin::commands::GetInteriorVehicleDataRequest> command = + auto command = CreateRCCommand( mobile_message); + ASSERT_TRUE(command->Init()); command->Run(); application_manager::event_engine::Event event( hmi_apis::FunctionID::RC_GetInteriorVehicleData); @@ -548,45 +600,47 @@ TEST_F(GetInteriorVehicleDataRequestTest, command->on_event(event); // Assert - EXPECT_TRUE( - rc_app_extention_->IsSubscibedToInteriorVehicleData(enums_value::kRadio)); + EXPECT_TRUE(rc_app_extention_->IsSubscribedToInteriorVehicleData(module)); } TEST_F(GetInteriorVehicleDataRequestTest, Execute_ExpectRejectDuToRequestLimitation_NoCahce) { // Arrange - rc_app_extention_->UnsubscribeFromInteriorVehicleData(enums_value::kRadio); + rc_app_extention_->UnsubscribeFromInteriorVehicleDataOfType( + enums_value::kRadio); MessageSharedPtr mobile_message = CreateBasicMessage(); (*mobile_message)[application_manager::strings::msg_params] - [message_params::kModuleType] = module_type; + [message_params::kModuleType] = module_eType; + (*mobile_message)[application_manager::strings::msg_params] + [message_params::kModuleId] = module_id; smart_objects::SmartObject radio_data; radio_data[message_params::kBand] = enums_value::kAM; - std::shared_ptr< - rc_rpc_plugin::commands::GetInteriorVehicleDataRequest> command = + auto command = CreateRCCommand( mobile_message); + const ModuleUid module(module_type, module_id); size_t i = 0; for (; i <= max_request_in_time_frame; ++i) { // Expectations EXPECT_CALL(mock_interior_data_manager_, - CheckRequestsToHMIFrequency(enums_value::kRadio)) + CheckRequestsToHMIFrequency(module)) .WillOnce(Return(true)); - EXPECT_CALL(mock_interior_data_manager_, - StoreRequestToHMITime(enums_value::kRadio)); - EXPECT_CALL(mock_interior_data_cache_, Contains(enums_value::kRadio)) + EXPECT_CALL(mock_interior_data_manager_, StoreRequestToHMITime(module)); + EXPECT_CALL(mock_interior_data_cache_, Contains(module)) .WillRepeatedly(Return(false)); EXPECT_CALL( mock_rpc_service_, ManageHMICommand( HMIResultCodeIs(hmi_apis::FunctionID::RC_GetInteriorVehicleData), - _)).WillRepeatedly(Return(true)); + _)) + .WillRepeatedly(Return(true)); // Act + ASSERT_TRUE(command->Init()); command->Run(); } // Expectations - EXPECT_CALL(mock_interior_data_manager_, - CheckRequestsToHMIFrequency(enums_value::kRadio)) + EXPECT_CALL(mock_interior_data_manager_, CheckRequestsToHMIFrequency(module)) .WillOnce(Return(false)); EXPECT_CALL( mock_rpc_service_, @@ -595,6 +649,130 @@ TEST_F(GetInteriorVehicleDataRequestTest, EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_, _)).Times(0); // Act + ASSERT_TRUE(command->Init()); command->Run(); } + +TEST_F(GetInteriorVehicleDataRequestTest, + OnEvent_ValidHmiResponse_AvailableHDChanelsIsArrayWithHDChanels) { + using rc_rpc_plugin::commands::GetInteriorVehicleDataRequest; + namespace hmi_response = application_manager::hmi_response; + namespace strings = application_manager::strings; + + const uint32_t chanel1_index = 1u; + const uint32_t chanel2_index = 2u; + const uint32_t chanel3_index = 3u; + + const uint32_t expected_array_length = 3u; + + // Arrange + MessageSharedPtr mobile_message = CreateBasicMessage(); + + 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] = kAppId; + + auto& msg_params = (*hmi_response_message)[strings::msg_params]; + msg_params[message_params::kModuleType] = module_type; + + auto available_hd_chanels = + smart_objects::SmartObject(smart_objects::SmartType_Array); + + available_hd_chanels[0] = chanel1_index; + available_hd_chanels[1] = chanel2_index; + available_hd_chanels[2] = chanel3_index; + + msg_params[message_params::kModuleData][message_params::kRadioControlData] + [message_params::kAvailableHdChannels] = available_hd_chanels; + + ON_CALL(mock_interior_data_cache_, Contains(_)).WillByDefault(Return(false)); + ON_CALL(mock_interior_data_manager_, CheckRequestsToHMIFrequency(_)) + .WillByDefault(Return(true)); + + MessageSharedPtr message_to_mob = CreateBasicMessage(); + + // Expectations + EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_, _)).WillOnce(Return(true)); + EXPECT_CALL(mock_rpc_service_, ManageMobileCommand(_, _)) + .WillOnce(DoAll(SaveArg<0>(&message_to_mob), Return(true))); + + // Act + auto command = CreateRCCommand(mobile_message); + application_manager::event_engine::Event event( + hmi_apis::FunctionID::RC_GetInteriorVehicleData); + + ASSERT_TRUE(command->Init()); + command->Run(); + + event.set_smart_object(*hmi_response_message); + command->on_event(event); + + auto& hd_chanels = + (*message_to_mob)[strings::msg_params][message_params::kModuleData] + [message_params::kRadioControlData] + [message_params::kAvailableHdChannels]; + const size_t array_length = hd_chanels.length(); + + EXPECT_EQ(expected_array_length, array_length); + + EXPECT_EQ(chanel1_index, hd_chanels[0].asUInt()); + EXPECT_EQ(chanel2_index, hd_chanels[1].asUInt()); + EXPECT_EQ(chanel3_index, hd_chanels[2].asUInt()); +} + +TEST_F(GetInteriorVehicleDataRequestTest, + OnEvent_ValidHmiResponse_ClimateEnableAvailable) { + using rc_rpc_plugin::commands::GetInteriorVehicleDataRequest; + namespace hmi_response = application_manager::hmi_response; + namespace strings = application_manager::strings; + + // Arrange + MessageSharedPtr mobile_message = CreateBasicMessage(); + + 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] = kAppId; + + auto& msg_params = (*hmi_response_message)[strings::msg_params]; + + auto climate_control_data = + smart_objects::SmartObject(smart_objects::SmartType_Boolean); + climate_control_data = true; + + msg_params[message_params::kModuleData][message_params::kClimateControlData] + [message_params::kClimateEnableAvailable] = climate_control_data; + + ON_CALL(mock_interior_data_cache_, Contains(_)).WillByDefault(Return(false)); + ON_CALL(mock_interior_data_manager_, CheckRequestsToHMIFrequency(_)) + .WillByDefault(Return(true)); + + auto message_to_mob = CreateBasicMessage(); + + // Expectations + EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_, _)).WillOnce(Return(true)); + EXPECT_CALL(mock_rpc_service_, ManageMobileCommand(_, _)) + .WillOnce(DoAll(SaveArg<0>(&message_to_mob), Return(true))); + + // Act + auto command = CreateRCCommand(mobile_message); + application_manager::event_engine::Event event( + hmi_apis::FunctionID::RC_GetInteriorVehicleData); + + ASSERT_TRUE(command->Init()); + command->Run(); + + event.set_smart_object(*hmi_response_message); + command->on_event(event); + + const bool climate_enable_available = + (*message_to_mob)[strings::msg_params][message_params::kModuleData] + [message_params::kClimateControlData] + [message_params::kClimateEnableAvailable] + .asBool(); + + EXPECT_TRUE(climate_enable_available); +} + } // 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 b3444712541..d6771c534db 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 @@ -30,36 +30,40 @@ * POSSIBILITY OF SUCH DAMAGE. */ +#include "rc_rpc_plugin/commands/mobile/on_interior_vehicle_data_notification.h" #include "application_manager/application.h" -#include "application_manager/mock_application.h" #include "application_manager/commands/commands_test.h" -#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/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 "gtest/gtest.h" #include "interfaces/MOBILE_API.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/mock/mock_rc_capabilities_manager.h" +#include "rc_rpc_plugin/mock/mock_rc_consent_manager.h" +#include "rc_rpc_plugin/mock/mock_resource_allocation_manager.h" +#include "rc_rpc_plugin/rc_module_constants.h" +#include "rc_rpc_plugin/rc_rpc_plugin.h" -using ::testing::_; -using ::testing::Return; -using ::testing::NiceMock; -using ::testing::SaveArg; -using ::testing::Mock; using application_manager::ApplicationSet; using application_manager::commands::MessageSharedPtr; using test::components::application_manager_test::MockApplication; using test::components::application_manager_test::MockApplicationManager; using test::components::commands_test::CommandsTest; using test::components::commands_test::CommandsTestMocks; +using ::testing::_; +using ::testing::Mock; +using ::testing::NiceMock; +using ::testing::Return; +using ::testing::SaveArg; namespace { const uint32_t kAppId = 0u; const uint32_t kConnectionKey = 1u; const std::string kPolicyAppId = "Test"; +const std::string module_type = "CLIMATE"; +const std::string module_id = "34045662-a9dc-4823-8435-91056d4c26cb"; const int kModuleId = 153u; -} +} // namespace namespace rc_rpc_plugin_test { using namespace rc_rpc_plugin; @@ -93,6 +97,8 @@ class OnInteriorVehicleDataNotificationTest (*message)[application_manager::strings::msg_params]; msg_param[message_params::kModuleData][message_params::kModuleType] = mobile_apis::ModuleType::CLIMATE; + msg_param[message_params::kModuleData][message_params::kModuleId] = + module_id; return message; } @@ -105,7 +111,9 @@ class OnInteriorVehicleDataNotificationTest mock_policy_handler_, mock_allocation_manager_, mock_interior_data_cache_, - mock_interior_data_manager_}; + mock_interior_data_manager_, + mock_rc_capabilities_manager_, + mock_rc_consent_manger_}; return ::std::make_shared(msg ? msg : msg = CreateMessage(), params); } @@ -122,6 +130,9 @@ class OnInteriorVehicleDataNotificationTest application_manager::ApplicationSet apps_; const std::shared_ptr apps_lock_; DataAccessor apps_da_; + testing::NiceMock + mock_rc_capabilities_manager_; + testing::NiceMock mock_rc_consent_manger_; }; TEST_F(OnInteriorVehicleDataNotificationTest, @@ -129,11 +140,12 @@ TEST_F(OnInteriorVehicleDataNotificationTest, // Arrange MessageSharedPtr mobile_message = CreateBasicMessage(); apps_.insert(mock_app_); - rc_app_extention_->SubscribeToInteriorVehicleData(enums_value::kClimate); + const ModuleUid module(module_type, module_id); + rc_app_extention_->SubscribeToInteriorVehicleData(module); ON_CALL(app_mngr_, applications()).WillByDefault(Return(apps_da_)); // Expectations - EXPECT_CALL(mock_interior_data_cache_, Add(enums_value::kClimate, _)); + EXPECT_CALL(mock_interior_data_cache_, Add(module, _)); MessageSharedPtr message; EXPECT_CALL(mock_rpc_service_, SendMessageToMobile(_, false)) .WillOnce(SaveArg<0>(&message)); 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 b95725e0b44..62b726ac601 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 @@ -32,34 +32,36 @@ #include "application_manager/application.h" #include "application_manager/commands/command_request_test.h" -#include "application_manager/mock_application.h" #include "application_manager/commands/commands_test.h" +#include "application_manager/mock_application.h" +#include "gtest/gtest.h" +#include "interfaces/MOBILE_API.h" #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/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" +#include "rc_rpc_plugin/mock/mock_rc_capabilities_manager.h" +#include "rc_rpc_plugin/mock/mock_rc_consent_manager.h" +#include "rc_rpc_plugin/mock/mock_resource_allocation_manager.h" +#include "rc_rpc_plugin/rc_module_constants.h" +#include "rc_rpc_plugin/rc_rpc_plugin.h" -using ::testing::_; -using ::testing::Return; -using ::testing::NiceMock; -using ::testing::SaveArg; -using ::testing::Mock; using application_manager::ApplicationSet; using application_manager::commands::MessageSharedPtr; using test::components::application_manager_test::MockApplication; using test::components::application_manager_test::MockApplicationManager; using test::components::commands_test::CommandsTest; using test::components::commands_test::CommandsTestMocks; +using ::testing::_; +using ::testing::Mock; +using ::testing::NiceMock; +using ::testing::Return; +using ::testing::SaveArg; namespace { const uint32_t kAppId = 0u; const uint32_t kConnectionKey = 1u; const std::string kPolicyAppId = "Test"; -} +} // namespace namespace rc_rpc_plugin_test { using namespace rc_rpc_plugin; @@ -95,7 +97,9 @@ class RCOnRemoteControlSettingsNotificationTest mock_policy_handler_, mock_allocation_manager_, mock_interior_data_cache_, - mock_interior_data_manager_}; + mock_interior_data_manager_, + mock_rc_capabilities_manager_, + mock_rc_consent_manger_}; return std::make_shared(msg ? msg : msg = CreateMessage(), params); } @@ -107,6 +111,9 @@ class RCOnRemoteControlSettingsNotificationTest mock_interior_data_cache_; testing::NiceMock mock_interior_data_manager_; + testing::NiceMock + mock_rc_capabilities_manager_; + testing::NiceMock mock_rc_consent_manger_; }; TEST_F(RCOnRemoteControlSettingsNotificationTest, @@ -124,8 +131,8 @@ TEST_F(RCOnRemoteControlSettingsNotificationTest, SetAccessMode(hmi_apis::Common_RCAccessMode::ASK_DRIVER)); // Act std::shared_ptr< - rc_rpc_plugin::commands::RCOnRemoteControlSettingsNotification> command = - CreateRCCommand< + rc_rpc_plugin::commands::RCOnRemoteControlSettingsNotification> + command = CreateRCCommand< rc_rpc_plugin::commands::RCOnRemoteControlSettingsNotification>( mobile_message); @@ -141,11 +148,12 @@ TEST_F(RCOnRemoteControlSettingsNotificationTest, EXPECT_CALL(mock_allocation_manager_, ResetAllAllocations()); EXPECT_CALL(mock_interior_data_manager_, OnDisablingRC()); + EXPECT_CALL(mock_rc_consent_manger_, RemoveAllConsents()); // Act std::shared_ptr< - rc_rpc_plugin::commands::RCOnRemoteControlSettingsNotification> command = - CreateRCCommand< + rc_rpc_plugin::commands::RCOnRemoteControlSettingsNotification> + command = CreateRCCommand< rc_rpc_plugin::commands::RCOnRemoteControlSettingsNotification>( mobile_message); 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 567d4b1e20b..d44265a1d59 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 @@ -31,59 +31,61 @@ */ #include "application_manager/application.h" -#include "application_manager/mock_application.h" #include "application_manager/commands/command_request_test.h" -#include "application_manager/rpc_service_impl.h" -#include "application_manager/mock_request_controller_settings.h" #include "application_manager/include/application_manager/command_holder_impl.h" -#include "application_manager/mock_hmi_capabilities.h" -#include "application_manager/request_controller.h" -#include "application_manager/mock_rpc_plugin_manager.h" -#include "application_manager/mock_rpc_plugin.h" +#include "application_manager/message.h" +#include "application_manager/mock_application.h" #include "application_manager/mock_command_factory.h" #include "application_manager/mock_event_dispatcher.h" -#include "application_manager/message.h" -#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" +#include "application_manager/mock_hmi_capabilities.h" +#include "application_manager/mock_request_controller_settings.h" +#include "application_manager/mock_rpc_plugin.h" +#include "application_manager/mock_rpc_plugin_manager.h" +#include "application_manager/mock_rpc_protection_manager.h" +#include "application_manager/request_controller.h" +#include "application_manager/rpc_service_impl.h" #include "hmi_message_handler/mock_hmi_message_handler.h" -#include "interfaces/MOBILE_API.h" #include "include/test/protocol_handler/mock_protocol_handler.h" +#include "interfaces/MOBILE_API.h" +#include "rc_rpc_plugin/commands/hmi/rc_get_interior_vehicle_data_consent_request.h" +#include "rc_rpc_plugin/commands/hmi/rc_get_interior_vehicle_data_consent_response.h" +#include "rc_rpc_plugin/commands/mobile/button_press_request.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/mock/mock_rc_capabilities_manager.h" +#include "rc_rpc_plugin/mock/mock_rc_consent_manager.h" +#include "rc_rpc_plugin/mock/mock_resource_allocation_manager.h" +#include "rc_rpc_plugin/rc_module_constants.h" +#include "rc_rpc_plugin/rc_rpc_plugin.h" #include "test/application_manager/mock_application_manager_settings.h" using ::testing::_; +using ::testing::Mock; +using ::testing::NiceMock; using ::testing::Return; using ::testing::ReturnRef; -using ::testing::NiceMock; using ::testing::SaveArg; -using ::testing::Mock; -using ::testing::NiceMock; namespace am = ::application_manager; using am::ApplicationSet; -using am::commands::MessageSharedPtr; using am::commands::CommandImpl; +using am::commands::MessageSharedPtr; +using am::plugin_manager::MockRPCPlugin; +using am::plugin_manager::MockRPCPluginManager; using am::plugin_manager::RPCPlugin; -using ::smart_objects::SmartObject; +using rc_rpc_plugin::RCRPCPlugin; using rc_rpc_plugin::commands::ButtonPressRequest; -using rc_rpc_plugin::commands::RCGetInteriorVehicleDataConsentResponse; using rc_rpc_plugin::commands::RCGetInteriorVehicleDataConsentRequest; -using rc_rpc_plugin::RCRPCPlugin; -using test::components::commands_test::CommandsTestMocks; -using test::components::commands_test::CommandRequestTest; -using am::plugin_manager::MockRPCPluginManager; -using am::plugin_manager::MockRPCPlugin; +using rc_rpc_plugin::commands::RCGetInteriorVehicleDataConsentResponse; +using ::smart_objects::SmartObject; using test::components::application_manager_test::MockApplication; +using test::components::application_manager_test::MockCommandFactory; +using test::components::application_manager_test::MockHMICapabilities; using test::components::application_manager_test::MockRequestControlerSettings; -using test::components::protocol_handler_test::MockProtocolHandler; +using test::components::commands_test::CommandRequestTest; +using test::components::commands_test::CommandsTestMocks; using test::components::hmi_message_handler_test::MockHMIMessageHandler; -using test::components::application_manager_test::MockHMICapabilities; -using test::components::application_manager_test::MockCommandFactory; using test::components::policy_test::MockPolicyHandlerInterface; +using test::components::protocol_handler_test::MockProtocolHandler; namespace rc_rpc_plugin_test { using namespace rc_rpc_plugin; @@ -92,6 +94,9 @@ namespace { const uint32_t kConnectionKey = 2u; const uint32_t kAppId = 5u; const std::string kResource = "CLIMATE"; +const std::string kResourceId = "34045662-a9dc-4823-8435-91056d4c26cb"; +const std::string kPolicyAppId = "policy_app_id"; +const std::string kMacAddress = "device1"; const uint32_t kPluginID = RCRPCPlugin::kRCPluginID; } // namespace @@ -101,17 +106,25 @@ class RCGetInteriorVehicleDataConsentTest RCGetInteriorVehicleDataConsentTest() : mock_app_(std::make_shared >()) , command_holder(app_mngr_) + , rc_capabilities_(smart_objects::SmartType::SmartType_Array) , request_controller(mock_request_controler) + , rpc_protection_manager_( + std::make_shared()) , rpc_service_(app_mngr_, request_controller, &mock_protocol_handler, &mock_hmi_handler, - command_holder) + command_holder, + rpc_protection_manager_, + hmi_so_factory_, + mobile_so_factoy_) , rc_app_extention_(std::make_shared(kPluginID)) , mock_rpc_plugin_manager( std::make_shared >()) , rpc_plugin(mock_rpc_plugin) , optional_mock_rpc_plugin(mock_rpc_plugin) { + smart_objects::SmartObject control_caps((smart_objects::SmartType_Array)); + rc_capabilities_[strings::kradioControlCapabilities] = control_caps; ON_CALL(*mock_app_, app_id()).WillByDefault(Return(kAppId)); ON_CALL(app_mngr_, hmi_interfaces()) .WillByDefault(ReturnRef(mock_hmi_interfaces_)); @@ -141,10 +154,16 @@ class RCGetInteriorVehicleDataConsentTest .WillByDefault(ReturnRef(*mock_rpc_plugin_manager)); ON_CALL(*mock_rpc_plugin_manager, FindPluginToProcess(_, _)) .WillByDefault(Return(rpc_plugin)); - ON_CALL(mock_allocation_manager_, IsResourceFree(kResource)) + ON_CALL(mock_allocation_manager_, IsResourceFree(kResource, kResourceId)) .WillByDefault(Return(true)); ON_CALL(mock_allocation_manager_, is_rc_enabled()) .WillByDefault(Return(true)); + ON_CALL(mock_protocol_handler, IsRPCServiceSecure(_)) + .WillByDefault(Return(false)); + ON_CALL(*rpc_protection_manager_, CheckPolicyEncryptionFlag(_, _, _)) + .WillByDefault(Return(false)); + ON_CALL(mock_rc_capabilities_manager_, CheckIfModuleExistsInCapabilities(_)) + .WillByDefault(Return(true)); } template @@ -156,7 +175,9 @@ class RCGetInteriorVehicleDataConsentTest mock_policy_handler_, mock_allocation_manager_, mock_interior_data_cache_, - mock_interior_data_manager_}; + mock_interior_data_manager_, + mock_rc_capabilities_manager_, + mock_rc_consent_manger_}; return std::make_shared(msg ? msg : msg = CreateMessage(), params); } @@ -169,6 +190,10 @@ class RCGetInteriorVehicleDataConsentTest [application_manager::strings::connection_key] = kConnectionKey; (*message)[application_manager::strings::params] [application_manager::strings::connection_key] = kAppId; + ns_smart_device_link::ns_smart_objects::SmartObject& msg_params = + (*message)[application_manager::strings::msg_params]; + msg_params[message_params::kModuleType] = kResource; + msg_params[message_params::kModuleId] = kResourceId; return message; } @@ -188,12 +213,19 @@ class RCGetInteriorVehicleDataConsentTest MockRPCPlugin mock_rpc_plugin; MockCommandFactory mock_command_factory; am::request_controller::RequestController request_controller; + std::shared_ptr + rpc_protection_manager_; am::rpc_service::RPCServiceImpl rpc_service_; std::shared_ptr rc_app_extention_; std::shared_ptr mock_rpc_plugin_manager; utils::Optional rpc_plugin; utils::Optional optional_mock_rpc_plugin; + hmi_apis::HMI_API hmi_so_factory_; + mobile_apis::MOBILE_API mobile_so_factoy_; + testing::NiceMock + mock_rc_capabilities_manager_; + testing::NiceMock mock_rc_consent_manger_; }; TEST_F(RCGetInteriorVehicleDataConsentTest, @@ -202,8 +234,17 @@ TEST_F(RCGetInteriorVehicleDataConsentTest, auto mobile_message = CreateBasicMessage(); // Expectations - EXPECT_CALL(mock_allocation_manager_, AcquireResource(_, _)) + EXPECT_CALL(mock_allocation_manager_, AcquireResource(_, _, _)) .WillOnce(Return(rc_rpc_plugin::AcquireResult::ASK_DRIVER)); + ON_CALL(*mock_app_, app_id()).WillByDefault(Return(kAppId)); + ON_CALL(*mock_app_, policy_app_id()).WillByDefault(Return(kPolicyAppId)); + ON_CALL(*mock_app_, mac_address()).WillByDefault(ReturnRef(kMacAddress)); + + rc_rpc_types::ModuleUid moduleUid{kResource, kResourceId}; + EXPECT_CALL(mock_rc_consent_manger_, + GetModuleConsent(kPolicyAppId, _, moduleUid)) + .WillOnce(Return(rc_rpc_types::ModuleConsent::NOT_EXISTS)); + EXPECT_CALL(*optional_mock_rpc_plugin, GetCommandFactory()) .WillOnce(ReturnRef(mock_command_factory)); auto rc_consent_request = @@ -228,7 +269,7 @@ TEST_F(RCGetInteriorVehicleDataConsentTest, auto mobile_message = CreateBasicMessage(); // Expectations - EXPECT_CALL(mock_allocation_manager_, AcquireResource(_, _)) + EXPECT_CALL(mock_allocation_manager_, AcquireResource(_, _, _)) .WillOnce(Return(rc_rpc_plugin::AcquireResult::IN_USE)); EXPECT_CALL(*optional_mock_rpc_plugin, GetCommandFactory()) diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/release_interior_vehicle_data_module_request_test.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/release_interior_vehicle_data_module_request_test.cc new file mode 100644 index 00000000000..200e458c17a --- /dev/null +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/release_interior_vehicle_data_module_request_test.cc @@ -0,0 +1,243 @@ +/* + * Copyright (c) 2019, 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 "gmock/gmock.h" +#include "gtest/gtest.h" + +#include "rc_rpc_plugin/commands/mobile/release_interior_vehicle_data_module_request.h" + +#include "application_manager/commands/command_request_test.h" +#include "application_manager/mock_application.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/mock/mock_rc_capabilities_manager.h" +#include "rc_rpc_plugin/mock/mock_rc_consent_manager.h" +#include "rc_rpc_plugin/mock/mock_resource_allocation_manager.h" +#include "rc_rpc_plugin/rc_module_constants.h" + +using application_manager::commands::MessageSharedPtr; +using rc_rpc_plugin_test::MockInteriorDataCache; +using rc_rpc_plugin_test::MockInteriorDataManager; +using rc_rpc_plugin_test::MockRCCapabilitiesManager; +using rc_rpc_plugin_test::MockRCConsentManager; +using rc_rpc_plugin_test::MockResourceAllocationManager; +using test::components::application_manager_test::MockApplication; +using test::components::commands_test::CommandRequestTest; +using test::components::commands_test::CommandsTestMocks; + +using testing::_; +using ::testing::DoAll; +using ::testing::Mock; +using ::testing::NiceMock; +using ::testing::Return; +using ::testing::SaveArg; + +typedef std::shared_ptr< + rc_rpc_plugin::commands::ReleaseInteriorVehicleDataModuleRequest> + ReleaseCommandPtr; + +namespace { +std::string kPolicyAppID = "app_id"; +std::uint32_t kAppID = 2u; +std::uint32_t kConnectionKey = 1u; +std::string kModuleType = "RADIO"; +std::string kModuleID = "76149d9b-5317-4cf5-9196-b8fac690fec5"; +std::string kDefaultModuleID = "eb7739ea-b263-4fe1-af9c-9311d1acac2d"; +} // namespace + +namespace rc_rpc_plugin_test { +namespace release_interior_vehicle_data_module_request { +using namespace rc_rpc_plugin; + +class ReleaseInteriorVehicleDataModuleRequestTest + : public CommandRequestTest { + public: + ReleaseInteriorVehicleDataModuleRequestTest() : mock_app_(CreateMockApp()) {} + + void SetUp() OVERRIDE { + TestPreCondition(); + ON_CALL(app_mngr_, application(kAppID)).WillByDefault(Return(mock_app_)); + ON_CALL(*mock_app_, app_id()).WillByDefault(Return(kAppID)); + ON_CALL(mock_rc_capabilities_manager_, + GetDefaultModuleIdFromCapabilities(kModuleType)) + .WillByDefault(Return(kDefaultModuleID)); + } + + MessageSharedPtr CreateBasicMessage() { + MessageSharedPtr message = CreateMessage(); + (*message)[application_manager::strings::params] + [application_manager::strings::function_id] = + mobile_apis::FunctionID::ReleaseInteriorVehicleDataModuleID; + (*message)[application_manager::strings::params] + [application_manager::strings::connection_key] = kConnectionKey; + (*message)[application_manager::strings::params] + [application_manager::strings::connection_key] = kAppID; + (*message)[application_manager::strings::msg_params] + [message_params::kModuleType] = mobile_apis::ModuleType::RADIO; + (*message)[application_manager::strings::msg_params] + [message_params::kModuleId] = kModuleID; + return message; + } + + void TestPreCondition() { + message_ = CreateBasicMessage(); + command_ = + CreateRCCommand( + message_); + } + + template + std::shared_ptr CreateRCCommand(MessageSharedPtr& msg) { + InitCommand(kDefaultTimeout_); + RCCommandParams params{app_mngr_, + mock_rpc_service_, + mock_hmi_capabilities_, + mock_policy_handler_, + mock_allocation_manager_, + mock_interior_data_cache_, + mock_interior_data_manager_, + mock_rc_capabilities_manager_, + mock_rc_consent_manger_}; + return std::make_shared(msg ? msg : msg = CreateMessage(), params); + } + + protected: + MessageSharedPtr message_; + ReleaseCommandPtr command_; + + MockAppPtr mock_app_; + NiceMock mock_allocation_manager_; + MockInteriorDataCache mock_interior_data_cache_; + MockInteriorDataManager mock_interior_data_manager_; + NiceMock mock_rc_capabilities_manager_; + MockRCConsentManager mock_rc_consent_manger_; +}; + +TEST_F(ReleaseInteriorVehicleDataModuleRequestTest, + ModuleIDIsAbsnetInMessage_ReturnsDefaultFromCapabilities) { + (*message_)[application_manager::strings::msg_params].erase( + message_params::kModuleId); + + auto module_id = command_->ModuleId(); + EXPECT_EQ(kDefaultModuleID, module_id); +} + +TEST_F(ReleaseInteriorVehicleDataModuleRequestTest, + ResourceIsNotAllocated_ResponseToMobile_UNSUCCESS_IGNORED) { + ON_CALL(mock_allocation_manager_, + ReleaseResource(kModuleType, kModuleID, kAppID)) + .WillByDefault(Return(ResourceReleasedState::eType::NOT_ALLOCATED)); + + MessageSharedPtr message_to_mobile = CreateMessage(); + + EXPECT_CALL( + mock_rpc_service_, + ManageMobileCommand( + _, application_manager::commands::Command::CommandSource::SOURCE_SDL)) + .WillOnce(DoAll(SaveArg<0>(&message_to_mobile), Return(true))); + + command_->Execute(); + + const bool success = + (*message_to_mobile)[application_manager::strings::msg_params] + [application_manager::strings::success] + .asBool(); + auto result_code = static_cast( + (*message_to_mobile)[application_manager::strings::msg_params] + [application_manager::strings::result_code] + .asUInt()); + + EXPECT_FALSE(success); + EXPECT_EQ(mobile_apis::Result::eType::IGNORED, result_code); +} + +TEST_F(ReleaseInteriorVehicleDataModuleRequestTest, + ResourceIsAllocated_ResponseToMobile_UNSUCCESS_REJECTED) { + ON_CALL(mock_allocation_manager_, + ReleaseResource(kModuleType, kModuleID, kAppID)) + .WillByDefault(Return(ResourceReleasedState::eType::IS_ALLOCATED)); + MessageSharedPtr message_to_mobile = CreateMessage(); + + EXPECT_CALL( + mock_rpc_service_, + ManageMobileCommand( + _, application_manager::commands::Command::CommandSource::SOURCE_SDL)) + .WillOnce(DoAll(SaveArg<0>(&message_to_mobile), Return(true))); + + command_->Execute(); + + const bool success = + (*message_to_mobile)[application_manager::strings::msg_params] + [application_manager::strings::success] + .asBool(); + auto result_code = static_cast( + (*message_to_mobile)[application_manager::strings::msg_params] + [application_manager::strings::result_code] + .asUInt()); + + EXPECT_FALSE(success); + EXPECT_EQ(mobile_apis::Result::eType::REJECTED, result_code); +} + +TEST_F(ReleaseInteriorVehicleDataModuleRequestTest, + ResourceIsReleased_ResponseToMobile_SUCCESS_SUCCESS) { + ON_CALL(mock_allocation_manager_, + ReleaseResource(kModuleType, kModuleID, kAppID)) + .WillByDefault(Return(ResourceReleasedState::eType::IS_RELEASED)); + + MessageSharedPtr message_to_mobile = CreateMessage(); + + EXPECT_CALL( + mock_rpc_service_, + ManageMobileCommand( + _, application_manager::commands::Command::CommandSource::SOURCE_SDL)) + .WillOnce(DoAll(SaveArg<0>(&message_to_mobile), Return(true))); + + command_->Execute(); + + const bool success = + (*message_to_mobile)[application_manager::strings::msg_params] + [application_manager::strings::success] + .asBool(); + auto result_code = static_cast( + (*message_to_mobile)[application_manager::strings::msg_params] + [application_manager::strings::result_code] + .asUInt()); + + EXPECT_TRUE(success); + EXPECT_EQ(mobile_apis::Result::eType::SUCCESS, result_code); +} +} // namespace release_interior_vehicle_data_module_request +} // namespace rc_rpc_plugin_test 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 b1cb8271f57..5a822a2fe49 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 @@ -30,34 +30,40 @@ * POSSIBILITY OF SUCH DAMAGE. */ +#include "rc_rpc_plugin/commands/mobile/set_interior_vehicle_data_request.h" #include "application_manager/application.h" #include "application_manager/commands/command_request_test.h" #include "application_manager/mock_application.h" -#include "rc_rpc_plugin/commands/mobile/set_interior_vehicle_data_request.h" -#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 "interfaces/MOBILE_API.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/mock/mock_rc_capabilities_manager.h" +#include "rc_rpc_plugin/mock/mock_rc_consent_manager.h" +#include "rc_rpc_plugin/mock/mock_resource_allocation_manager.h" +#include "rc_rpc_plugin/rc_module_constants.h" +#include "rc_rpc_plugin/rc_rpc_plugin.h" + +#include #include "gtest/gtest.h" -#include "interfaces/MOBILE_API.h" -using ::testing::_; -using ::testing::Return; -using ::testing::NiceMock; using application_manager::ApplicationSet; using application_manager::commands::MessageSharedPtr; using test::components::application_manager_test::MockApplication; using test::components::application_manager_test::MockApplicationManager; using test::components::commands_test::CommandRequestTest; using test::components::commands_test::CommandsTestMocks; +using test::components::commands_test::HMIResultCodeIs; +using ::testing::_; +using ::testing::NiceMock; +using ::testing::Return; +using ::testing::SaveArg; namespace { const uint32_t kAppId = 0u; const int kModuleId = 153u; const uint32_t kConnectionKey = 1u; const std::string kPolicyAppId = "Test"; -} +} // namespace namespace rc_rpc_plugin_test { using namespace rc_rpc_plugin; @@ -67,9 +73,12 @@ class SetInteriorVehicleDataRequestTest public: SetInteriorVehicleDataRequestTest() : mock_app_(std::make_shared >()) - , rc_app_extention_(std::make_shared(kModuleId)) {} + , rc_app_extention_(std::make_shared(kModuleId)) + , rc_capabilities_(smart_objects::SmartType::SmartType_Array) {} void SetUp() OVERRIDE { + smart_objects::SmartObject control_caps((smart_objects::SmartType_Array)); + rc_capabilities_[strings::kradioControlCapabilities] = control_caps; ON_CALL(app_mngr_, hmi_interfaces()) .WillByDefault(ReturnRef(mock_hmi_interfaces_)); ON_CALL( @@ -82,17 +91,24 @@ class SetInteriorVehicleDataRequestTest .WillByDefault(Return(rc_app_extention_)); ON_CALL(*mock_app_, policy_app_id()).WillByDefault(Return(kPolicyAppId)); - ON_CALL(mock_allocation_manager_, IsResourceFree(_)) + ON_CALL(mock_allocation_manager_, IsResourceFree(_, _)) .WillByDefault(Return(true)); - ON_CALL(mock_allocation_manager_, AcquireResource(_, _)) + ON_CALL(mock_allocation_manager_, AcquireResource(_, _, _)) .WillByDefault(Return(AcquireResult::ALLOWED)); ON_CALL(*mock_app_, app_id()).WillByDefault(Return(kAppId)); ON_CALL(mock_policy_handler_, CheckHMIType(kPolicyAppId, mobile_apis::AppHMIType::eType::REMOTE_CONTROL, - nullptr)).WillByDefault(Return(true)); + nullptr)) + .WillByDefault(Return(true)); + ON_CALL(mock_hmi_capabilities_, rc_capability()) + .WillByDefault(Return(&rc_capabilities_)); ON_CALL(mock_allocation_manager_, is_rc_enabled()) .WillByDefault(Return(true)); + ON_CALL(mock_rc_capabilities_manager_, CheckIfModuleExistsInCapabilities(_)) + .WillByDefault(Return(true)); + ON_CALL(mock_rc_capabilities_manager_, GetModuleDataCapabilities(_, _)) + .WillByDefault(Return(std::make_pair("", capabilitiesStatus::success))); } MessageSharedPtr CreateBasicMessage() { @@ -116,7 +132,9 @@ class SetInteriorVehicleDataRequestTest mock_policy_handler_, mock_allocation_manager_, mock_interior_data_cache_, - mock_interior_data_manager_}; + mock_interior_data_manager_, + mock_rc_capabilities_manager_, + mock_rc_consent_manger_}; return std::make_shared(msg ? msg : msg = CreateMessage(), params); } @@ -129,6 +147,10 @@ class SetInteriorVehicleDataRequestTest mock_interior_data_manager_; std::shared_ptr mock_app_; std::shared_ptr rc_app_extention_; + testing::NiceMock + mock_rc_capabilities_manager_; + smart_objects::SmartObject rc_capabilities_; + testing::NiceMock mock_rc_consent_manger_; }; TEST_F(SetInteriorVehicleDataRequestTest, @@ -139,25 +161,25 @@ TEST_F(SetInteriorVehicleDataRequestTest, (*mobile_message)[application_manager::strings::msg_params]; msg_params[message_params::kModuleData][message_params::kModuleType] = mobile_apis::ModuleType::CLIMATE; + smart_objects::SmartObject climate_control_data(smart_objects::SmartType_Map); + climate_control_data[message_params::kFanSpeed] = 10; + msg_params[message_params::kModuleData][message_params::kClimateControlData] = - smart_objects::SmartObject(smart_objects::SmartType_Map); + climate_control_data; // Expectations EXPECT_CALL(mock_policy_handler_, CheckModule(kPolicyAppId, _)) .WillOnce(Return(rc_rpc_plugin::TypeAccess::kAllowed)); - EXPECT_CALL(mock_hmi_capabilities_, rc_capability()) - .WillOnce(Return(nullptr)); - EXPECT_CALL( mock_rpc_service_, - ManageMobileCommand(test::components::commands_test::MobileResultCodeIs( - mobile_apis::Result::READ_ONLY), - application_manager::commands::Command::SOURCE_SDL)); + ManageHMICommand( + HMIResultCodeIs(hmi_apis::FunctionID::RC_SetInteriorVehicleData), _)) + .WillOnce(Return(true)); // Act - std::shared_ptr< - rc_rpc_plugin::commands::SetInteriorVehicleDataRequest> command = + auto command = CreateRCCommand( mobile_message); + ASSERT_TRUE(command->Init()); command->Run(); } @@ -181,22 +203,20 @@ TEST_F( EXPECT_CALL(mock_policy_handler_, CheckModule(kPolicyAppId, _)) .WillOnce(Return(rc_rpc_plugin::TypeAccess::kAllowed)); - EXPECT_CALL(mock_hmi_capabilities_, rc_capability()) - .WillOnce(Return(nullptr)); - EXPECT_CALL(app_mngr_, RemoveHMIFakeParameters(_, _)); EXPECT_CALL( mock_rpc_service_, - ManageMobileCommand(test::components::commands_test::MobileResultCodeIs( - mobile_apis::Result::OUT_OF_MEMORY), - application_manager::commands::Command::SOURCE_SDL)); + ManageHMICommand( + HMIResultCodeIs(hmi_apis::FunctionID::RC_SetInteriorVehicleData), _)) + .WillOnce(Return(true)); // Act - std::shared_ptr< - rc_rpc_plugin::commands::SetInteriorVehicleDataRequest> command = - CreateRCCommand( + std::shared_ptr + command = CreateRCCommand< + rc_rpc_plugin::commands::SetInteriorVehicleDataRequest>( mobile_message); + ASSERT_TRUE(command->Init()); command->Run(); } @@ -224,11 +244,97 @@ TEST_F( application_manager::commands::Command::SOURCE_SDL)); // Act - std::shared_ptr< - rc_rpc_plugin::commands::SetInteriorVehicleDataRequest> command = - CreateRCCommand( + std::shared_ptr + command = CreateRCCommand< + rc_rpc_plugin::commands::SetInteriorVehicleDataRequest>( + mobile_message); + ASSERT_TRUE(command->Init()); + command->Run(); +} + +TEST_F(SetInteriorVehicleDataRequestTest, + Execute_ValidWithSettableParams_SUCCESSSendToHMI) { + MessageSharedPtr mobile_message = CreateBasicMessage(); + auto& msg_params = + (*mobile_message)[application_manager::strings::msg_params]; + msg_params[message_params::kModuleData][message_params::kModuleType] = + mobile_apis::ModuleType::CLIMATE; + + msg_params[message_params::kModuleData][message_params::kClimateControlData] = + smart_objects::SmartObject(smart_objects::SmartType_Map); + + msg_params[message_params::kModuleData][message_params::kClimateControlData] + [message_params::kClimateEnable] = true; + + // Expectations + EXPECT_CALL(mock_policy_handler_, CheckModule(kPolicyAppId, _)) + .WillOnce(Return(rc_rpc_plugin::TypeAccess::kAllowed)); + + MessageSharedPtr message_from_mobile = CreateBasicMessage(); + + EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_, _)) + .WillOnce(DoAll(SaveArg<0>(&message_from_mobile), Return(true))); + + std::shared_ptr + command = CreateRCCommand< + rc_rpc_plugin::commands::SetInteriorVehicleDataRequest>( mobile_message); + + ASSERT_TRUE(command->Init()); command->Run(); + + auto& msg_params_from_mobile = + (*message_from_mobile)[application_manager::strings::msg_params]; + + const bool climate_enable = + msg_params_from_mobile[message_params::kModuleData] + [message_params::kClimateControlData] + [message_params::kClimateEnable] + .asBool(); + EXPECT_TRUE(climate_enable); } +TEST_F(SetInteriorVehicleDataRequestTest, + Execute_ValidWithSettableParams_SUCCESSSendToHMI_HDChannel) { + MessageSharedPtr mobile_message = CreateBasicMessage(); + auto& msg_params = + (*mobile_message)[application_manager::strings::msg_params]; + msg_params[message_params::kModuleData][message_params::kModuleType] = + mobile_apis::ModuleType::RADIO; + + msg_params[message_params::kModuleData][message_params::kRadioControlData] = + smart_objects::SmartObject(smart_objects::SmartType_Map); + + const std::uint32_t hd_channel = 2u; + msg_params[message_params::kModuleData][message_params::kRadioControlData] + [message_params::kHdChannel] = hd_channel; + + // Expectations + EXPECT_CALL(mock_policy_handler_, CheckModule(kPolicyAppId, _)) + .WillOnce(Return(rc_rpc_plugin::TypeAccess::kAllowed)); + + auto message_from_mobile = CreateBasicMessage(); + + EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_, _)) + .WillOnce(DoAll(SaveArg<0>(&message_from_mobile), Return(true))); + + std::shared_ptr + command = CreateRCCommand< + rc_rpc_plugin::commands::SetInteriorVehicleDataRequest>( + mobile_message); + + command->Init(); + command->Run(); + + auto& msg_params_from_mobile = + (*message_from_mobile)[application_manager::strings::msg_params]; + + const uint64_t hd_channel_from_hmi = + msg_params_from_mobile[message_params::kModuleData] + [message_params::kRadioControlData] + [message_params::kHdChannel] + .asUInt(); + + EXPECT_EQ(hd_channel, hd_channel_from_hmi); +} } // namespace rc_rpc_plugin_test diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/grid_test.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/grid_test.cc new file mode 100644 index 00000000000..b8a0d712031 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/grid_test.cc @@ -0,0 +1,72 @@ +/* + * Copyright (c) 2019, 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/rc_app_extension.h" + +namespace rc_rpc_plugin_test { +namespace grid_test { +using namespace rc_rpc_plugin; + +TEST(Grid, IsLevelIntersectionExists) { + Grid grid_level0{1, 1, 0, 1, 1, 1}; + Grid grid_level1{1, 1, 1, 1, 1, 1}; + EXPECT_FALSE(grid_level0.LevelIntersectionExists(grid_level1)); + + Grid grid_level1_v2{1, 2, 1, 1, 2, 1}; + EXPECT_TRUE(grid_level1.LevelIntersectionExists(grid_level1_v2)); +} + +TEST(Grid, TwoSameGrisAreEqual) { + Grid grid2{1, 1, 0, 1, 1, 1}; + Grid grid1{1, 1, 0, 1, 1, 1}; + + EXPECT_EQ(grid1, grid2); +} + +TEST(Grid, IsIntersectionExists) { + Grid grid_1{0, 1, 2, 1, 1, 1}; + Grid grid_2{0, 0, 1, 0, 0, 1}; + + // There is intersection but levels missmatch + EXPECT_FALSE(grid_1.IntersectionExists(grid_2)); + + Grid grid_3{1, 0, 2, 0, 0, 0}; + // There isn't intersection but level match + EXPECT_FALSE(grid_1.IntersectionExists(grid_3)); + + Grid grid_4{0, 1, 2, 1, 1, 1}; + EXPECT_TRUE(grid_1.IntersectionExists(grid_4)); +} +} // namespace grid_test +} // namespace rc_rpc_plugin_test 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 index 45465f96b03..025cef21658 100644 --- 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 @@ -42,10 +42,14 @@ 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&)); + void(const rc_rpc_plugin::ModuleUid&, + const smart_objects::SmartObject&)); + MOCK_CONST_METHOD1( + Retrieve, smart_objects::SmartObject(const rc_rpc_plugin::ModuleUid&)); + MOCK_CONST_METHOD1(GetCachedModulesByType, + std::vector(const std::string&)); + MOCK_CONST_METHOD1(Contains, bool(const rc_rpc_plugin::ModuleUid&)); + MOCK_METHOD1(Remove, void(const rc_rpc_plugin::ModuleUid&)); MOCK_METHOD0(Clear, void()); }; 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 index fc19c6a889a..231ac2ae368 100644 --- 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 @@ -46,8 +46,9 @@ class MockInteriorDataManager : public rc_rpc_plugin::InteriorDataManager { 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&)); + MOCK_METHOD1(StoreRequestToHMITime, void(const rc_rpc_plugin::ModuleUid&)); + MOCK_METHOD1(CheckRequestsToHMIFrequency, + bool(const rc_rpc_plugin::ModuleUid&)); }; } // namespace rc_rpc_plugin_test diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/include/rc_rpc_plugin/mock/mock_rc_capabilities_manager.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/include/rc_rpc_plugin/mock/mock_rc_capabilities_manager.h new file mode 100644 index 00000000000..6f1593dcbb3 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/include/rc_rpc_plugin/mock/mock_rc_capabilities_manager.h @@ -0,0 +1,93 @@ +/* + * Copyright (c) 2019, 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_RC_CAPABILITIES_MANAGER_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_TEST_INCLUDE_RC_RPC_PLUGIN_MOCK_MOCK_RC_CAPABILITIES_MANAGER_H_ +#include "gmock/gmock.h" +#include "rc_rpc_plugin/rc_capabilities_manager.h" + +namespace rc_rpc_plugin_test { +class MockRCCapabilitiesManager : public rc_rpc_plugin::RCCapabilitiesManager { + public: + MOCK_CONST_METHOD2(CheckButtonName, + bool(const std::string& module_type, + const std::string& button_name)); + + MOCK_CONST_METHOD1(CheckIfModuleExistsInCapabilities, + bool(const rc_rpc_plugin::ModuleUid& module_type)); + + MOCK_CONST_METHOD2(GetModuleDataCapabilities, + rc_rpc_plugin::ModuleTypeCapability( + const smart_objects::SmartObject& module_data, + const std::string& module_id)); + + MOCK_CONST_METHOD2(ControlDataForType, + const smart_objects::SmartObject&( + const smart_objects::SmartObject& module_data, + const std::string& module_type)); + + MOCK_CONST_METHOD3( + AreReadOnlyParamsPresent, + bool(const smart_objects::SmartObject& module_data, + const std::string& module_type, + rc_rpc_plugin::ModuleTypeCapability& module_data_capabilities)); + + MOCK_CONST_METHOD2(AreAllParamsReadOnly, + bool(const smart_objects::SmartObject& module_data, + const std::string& module_type)); + + MOCK_CONST_METHOD1(GetDefaultModuleIdFromCapabilities, + const std::string(const std::string& module_type)); + + MOCK_CONST_METHOD1(CheckIfButtonExistInRCCaps, + bool(const mobile_apis::ButtonName::eType button)); + + MOCK_CONST_METHOD0(GetResources, + const std::vector()); + + MOCK_CONST_METHOD1(GetModuleServiceArea, + rc_rpc_plugin::Grid(const rc_rpc_plugin::ModuleUid&)); + + MOCK_CONST_METHOD1(IsMultipleAccessAllowed, + bool(const rc_rpc_plugin::ModuleUid&)); + + MOCK_CONST_METHOD0(GetDriverLocationFromSeatLocationCapability, + const rc_rpc_plugin::Grid()); + + MOCK_CONST_METHOD0(IsSeatLocationCapabilityProvided, bool()); + + MOCK_CONST_METHOD1( + GetModuleIdForSeatLocation, + const std::string(const mobile_apis::SupportedSeat::eType id)); +}; +} // namespace rc_rpc_plugin_test +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_TEST_INCLUDE_RC_RPC_PLUGIN_MOCK_MOCK_RC_СAPABILITIES_MANAGER_H_ diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/include/rc_rpc_plugin/mock/mock_rc_consent_manager.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/include/rc_rpc_plugin/mock/mock_rc_consent_manager.h new file mode 100644 index 00000000000..147da9ed55c --- /dev/null +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/include/rc_rpc_plugin/mock/mock_rc_consent_manager.h @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2019, 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_PLUGIN_MANAGER_MOCK_RC_CONSENT_MANAGER_H +#define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_PLUGIN_MANAGER_MOCK_RC_CONSENT_MANAGER_H + +#include + +#include "gmock/gmock.h" +#include "rc_rpc_plugin/rc_consent_manager.h" + +namespace rc_rpc_plugin_test { + +class MockRCConsentManager : public rc_rpc_plugin::RCConsentManager { + public: + MOCK_METHOD3(SaveModuleConsents, + void(const std::string&, + const std::string&, + const rc_rpc_plugin::rc_rpc_types::ModuleIdConsentVector&)); + MOCK_CONST_METHOD3(GetModuleConsent, + rc_rpc_plugin::rc_rpc_types::ModuleConsent( + const std::string&, + const std::string&, + const rc_rpc_plugin::rc_rpc_types::ModuleUid&)); + MOCK_METHOD0(RemoveExpiredConsents, void()); + MOCK_METHOD0(RemoveAllConsents, void()); +}; + +} // namespace rc_rpc_plugin_test + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_PLUGIN_MANAGER_MOCK_RC_CONSENT_MANAGER_H diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/include/rc_rpc_plugin/mock/mock_rc_helpers.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/include/rc_rpc_plugin/mock/mock_rc_helpers.h new file mode 100644 index 00000000000..c73472d2a89 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/include/rc_rpc_plugin/mock/mock_rc_helpers.h @@ -0,0 +1,97 @@ +/* + * Copyright (c) 2019, 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_RC_RPC_PLUGINS_RC_RPC_PLUGIN_TEST_INCLUDE_RC_RPC_PLUGIN_MOCK_MOCK_RC_HELPERS_H +#define SRC_COMPONENTS_APPLICATION_MANAGER_RC_RPC_PLUGINS_RC_RPC_PLUGIN_TEST_INCLUDE_RC_RPC_PLUGIN_MOCK_MOCK_RC_HELPERS_H + +#include +#include +#include +#include "gmock/gmock.h" + +#include "application_manager/application.h" +#include "application_manager/application_manager.h" +#include "rc_rpc_plugin/rc_helpers.h" + +namespace rc_rpc_plugin { + +class MockRCHelpers { + public: + MOCK_METHOD0(GetModuleTypeToDataMapping, + std::function()); + MOCK_METHOD0(GetModuleTypeToCapabilitiesMapping, + std::function()); + MOCK_METHOD0(GetModuleTypesList, const std::vector()); + MOCK_METHOD1( + GetRCExtension, + rc_rpc_plugin::RCAppExtensionPtr(application_manager::Application&)); + MOCK_METHOD2(CreateUnsubscribeRequestToHMI, + smart_objects::SmartObjectSPtr(const rc_rpc_plugin::ModuleUid&, + const uint32_t)); + MOCK_METHOD2(AppsSubscribedToModule, + std::vector( + application_manager::ApplicationManager&, + const rc_rpc_plugin::ModuleUid&)); + MOCK_METHOD2(AppsSubscribedToModuleType, + std::vector( + application_manager::ApplicationManager&, + const std::string&)); + MOCK_METHOD1(GetApplicationsAllowedModuleTypes, + rc_rpc_plugin::RCHelpers::AppsModuleTypes( + application_manager::ApplicationManager&)); + MOCK_METHOD0(buttons_climate, const std::vector()); + MOCK_METHOD0(buttons_radio, const std::vector()); + MOCK_METHOD0(buttons_map, const rc_rpc_plugin::RCHelpers::ButtonsMap()); + MOCK_METHOD1(GetModuleReadOnlyParams, + std::vector(const std::string&)); + MOCK_METHOD3( + FillModuleConsents, + rc_rpc_types::ModuleIdConsentVector(const std::string&, + const std::vector&, + const std::vector)); + MOCK_METHOD1(RetrieveModuleIds, + std::vector(const smart_objects::SmartObject&)); + MOCK_METHOD1(RetrieveModuleConsents, + std::vector(const smart_objects::SmartObject& consents)); + MOCK_METHOD1(RemoveRedundantGPSDataFromIVDataMsg, + void(smart_objects::SmartObject& msg_params)); + MOCK_METHOD2( + MergeModuleData, + smart_objects::SmartObject(const smart_objects::SmartObject& data1, + const smart_objects::SmartObject& data2)); + + static MockRCHelpers* rc_helpers_mock(); +}; + +} // namespace rc_rpc_plugin + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RC_RPC_PLUGINS_RC_RPC_PLUGIN_TEST_INCLUDE_RC_RPC_PLUGIN_MOCK_MOCK_RC_HELPERS_H 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 72ace1432a7..fca6c9c77e3 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 @@ -33,21 +33,27 @@ #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" +#include "gmock/gmock.h" namespace rc_rpc_plugin_test { class MockResourceAllocationManager : public rc_rpc_plugin::ResourceAllocationManager { public: - MOCK_METHOD2(AcquireResource, - rc_rpc_plugin::AcquireResult::eType( - const std::string& module_type, const uint32_t app_id)); - MOCK_METHOD2(ForceAcquireResource, - void(const std::string& module_type, const uint32_t app_id)); - MOCK_METHOD2(OnDriverDisallowed, - void(const std::string& module_type, const uint32_t app_id)); + MOCK_METHOD3( + AcquireResource, + rc_rpc_plugin::AcquireResult::eType(const std::string& module_type, + const std::string& module_id, + const uint32_t app_id)); + MOCK_METHOD3(ForceAcquireResource, + void(const std::string& module_type, + const std::string& module_id, + const uint32_t app_id)); + MOCK_METHOD3(OnDriverDisallowed, + void(const std::string& module_type, + const std::string& module_id, + const uint32_t app_id)); MOCK_METHOD2(OnApplicationEvent, void(application_manager::plugin_manager::ApplicationEvent event, application_manager::ApplicationSharedPtr application)); @@ -56,17 +62,32 @@ class MockResourceAllocationManager MOCK_METHOD1(SetAccessMode, void(const hmi_apis::Common_RCAccessMode::eType access_mode)); MOCK_CONST_METHOD0(GetAccessMode, hmi_apis::Common_RCAccessMode::eType()); - MOCK_METHOD3(SetResourceState, + MOCK_METHOD4(SetResourceState, void(const std::string& module_type, + const std::string& module_id, const uint32_t app_id, const rc_rpc_plugin::ResourceState::eType state)); - MOCK_CONST_METHOD1(IsResourceFree, bool(const std::string& module_type)); + MOCK_CONST_METHOD2(IsResourceFree, + bool(const std::string& module_type, + const std::string& module_id)); MOCK_METHOD0(ResetAllAllocations, void()); MOCK_METHOD2(SendOnRCStatusNotifications, void(rc_rpc_plugin::NotificationTrigger::eType, application_manager::ApplicationSharedPtr application)); MOCK_CONST_METHOD0(is_rc_enabled, bool()); MOCK_METHOD1(set_rc_enabled, void(const bool value)); + MOCK_METHOD3(ReleaseResource, + rc_rpc_plugin::ResourceReleasedState::eType( + const std::string& module_type, + const std::string& module_id, + const uint32_t application_id)); + MOCK_METHOD3(SetResourceAcquired, + void(const std::string& module_type, + const std::string& module_id, + const uint32_t app_id)); + MOCK_CONST_METHOD2(IsResourceAlreadyAcquiredByApp, + bool(const rc_rpc_plugin::ModuleUid& moduleUid, + const uint32_t app_id)); }; } // namespace rc_rpc_plugin_test 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 index e6922a4c834..40a6bdf41d3 100644 --- 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 @@ -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 "application_manager/smart_object_keys.h" #include "gtest/gtest.h" #include "rc_rpc_plugin/interior_data_cache_impl.h" @@ -38,41 +39,49 @@ class InteriorDataCacheTest : public ::testing::Test {}; namespace { const uint32_t time_frame_alowed_requests = 1; +const std::string kValueKey = "value"; +const std::string kArray = "array"; } // 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); + std::string module_id = "34045662-a9dc-4823-8435-91056d4c26cb"; + rc_rpc_plugin::ModuleUid module(module_type_key, module_id); + EXPECT_FALSE(cache.Contains(module)); + auto retrieved_data = cache.Retrieve(module); 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"; + std::string module_id = "34045662-a9dc-4823-8435-91056d4c26cb"; + rc_rpc_plugin::ModuleUid module(module_type_key, module_id); 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); + cache.Add(module, data); + EXPECT_TRUE(cache.Contains(module)); + auto retrieved_data = cache.Retrieve(module); EXPECT_EQ(data, retrieved_data); } TEST_F(InteriorDataCacheTest, DataDoesNotExistAfterClear) { rc_rpc_plugin::InteriorDataCacheImpl cache; const std::string module_type_key = "random_module_type"; + std::string module_id = "34045662-a9dc-4823-8435-91056d4c26cb"; + rc_rpc_plugin::ModuleUid module(module_type_key, module_id); 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); + cache.Add(module, data); + EXPECT_TRUE(cache.Contains(module)); + auto Retrieved_data = cache.Retrieve(module); EXPECT_EQ(Retrieved_data, data); cache.Clear(); - auto Retrieved_data_after_clear = cache.Retrieve(module_type_key); + auto Retrieved_data_after_clear = cache.Retrieve(module); EXPECT_EQ(smart_objects::SmartType_Null, Retrieved_data_after_clear.getType()); } @@ -81,19 +90,23 @@ TEST_F(InteriorDataCacheTest, MultipleDataCached) { rc_rpc_plugin::InteriorDataCacheImpl cache; const std::string module_type_key1 = "random_module_type"; + std::string module_id1 = "34045662-a9dc-4823-8435-91056d4c26cb"; + rc_rpc_plugin::ModuleUid module1(module_type_key1, module_id1); 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); + cache.Add(module1, data1); + EXPECT_TRUE(cache.Contains(module1)); + auto retrieved_data1 = cache.Retrieve(module1); EXPECT_EQ(data1, retrieved_data1); std::string module_type_key2 = "random_module_type2"; + std::string module_id2 = "eb7739ea-b263-4fe1-af9c-9311d1acac2d"; + rc_rpc_plugin::ModuleUid module2(module_type_key2, module_id2); 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); + cache.Add(module2, data2); + EXPECT_TRUE(cache.Contains(module2)); + auto retrieved_data2 = cache.Retrieve(module2); EXPECT_EQ(retrieved_data2, data2); ASSERT_TRUE(data1 != data2); @@ -105,30 +118,36 @@ TEST_F(InteriorDataCacheTest, RemoveFromChacheSuccessful) { rc_rpc_plugin::InteriorDataCacheImpl cache; const std::string module_type = "random_module_type"; + std::string module_id = "34045662-a9dc-4823-8435-91056d4c26cb"; + rc_rpc_plugin::ModuleUid module(module_type, module_id); 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); + cache.Add(module, data); + EXPECT_TRUE(cache.Contains(module)); + auto retrieved_data1 = cache.Retrieve(module); EXPECT_EQ(data, retrieved_data1); - cache.Remove(module_type); - EXPECT_FALSE(cache.Contains(module_type)); - auto retreived = cache.Retrieve(module_type); + cache.Remove(module); + EXPECT_FALSE(cache.Contains(module)); + auto retreived = cache.Retrieve(module); 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"; + std::string module_id = "34045662-a9dc-4823-8435-91056d4c26cb"; + rc_rpc_plugin::ModuleUid module(module_type_key, module_id); smart_objects::SmartObject data; data["key"] = "value"; - cache.Add(module_type_key, data); - cache.Remove("some other module_type"); + cache.Add(module, data); + rc_rpc_plugin::ModuleUid other_module("some other module_type", + "some other module id"); + cache.Remove(other_module); - EXPECT_TRUE(cache.Contains(module_type_key)); - auto retrieved_data = cache.Retrieve(module_type_key); + EXPECT_TRUE(cache.Contains(module)); + auto retrieved_data = cache.Retrieve(module); EXPECT_EQ(data, retrieved_data); } @@ -136,25 +155,72 @@ TEST_F(InteriorDataCacheTest, Exist2ModuleTypesRemoveOneAnotherOneLeft) { rc_rpc_plugin::InteriorDataCacheImpl cache; const std::string module_type_key1 = "random_module_type"; + std::string module_id1 = "34045662-a9dc-4823-8435-91056d4c26cb"; + rc_rpc_plugin::ModuleUid module1(module_type_key1, module_id1); smart_objects::SmartObject data1; data1["key"] = "value1"; - cache.Add(module_type_key1, data1); + cache.Add(module1, data1); std::string module_type_key2 = "random_module_type2"; + std::string module_id2 = "eb7739ea-b263-4fe1-af9c-9311d1acac2d"; + rc_rpc_plugin::ModuleUid module2(module_type_key2, module_id2); smart_objects::SmartObject data2; data2["key"] = "value2"; - cache.Add(module_type_key2, data2); + cache.Add(module2, data2); ASSERT_TRUE(data1 != data2); - cache.Remove(module_type_key1); - EXPECT_FALSE(cache.Contains(module_type_key1)); - EXPECT_TRUE(cache.Contains(module_type_key2)); + cache.Remove(module1); + EXPECT_FALSE(cache.Contains(module1)); + EXPECT_TRUE(cache.Contains(module2)); - auto retrieved_data1 = cache.Retrieve(module_type_key1); + auto retrieved_data1 = cache.Retrieve(module1); EXPECT_EQ(smart_objects::SmartType_Null, retrieved_data1.getType()); - auto retrieved_data2 = cache.Retrieve(module_type_key2); + auto retrieved_data2 = cache.Retrieve(module2); EXPECT_EQ(data2, retrieved_data2); } -} // rc_rpc_plugin_test +TEST_F(InteriorDataCacheTest, CheckCacheDataMerge) { + using namespace smart_objects; + const std::string module_type_key = "random_module_type"; + const std::string module_id = "random_module_id"; + rc_rpc_plugin::ModuleUid module(module_type_key, module_id); + + auto gen_smart_object = [](const std::string& id, + const std::string& value) -> SmartObject { + SmartObject result(SmartType_Map); + result[application_manager::strings::id] = id; + result[kValueKey] = value; + return result; + }; + + SmartObject data1; + SmartObject data1_array(SmartType_Array); + (*data1_array.asArray()) = SmartArray{gen_smart_object("id1", "value1"), + gen_smart_object("id2", "value2")}; + data1[kArray] = data1_array; + + SmartObject data2(SmartType_Map); + SmartObject data2_array(SmartType_Array); + (*data2_array.asArray()) = SmartArray{gen_smart_object("id1", "value3"), + gen_smart_object("id3", "value4")}; + data2[kArray] = data2_array; + + SmartObject expected_data(SmartType_Map); + SmartObject expected_array(SmartType_Array); + (*expected_array.asArray()) = SmartArray{gen_smart_object("id1", "value3"), + gen_smart_object("id2", "value2"), + gen_smart_object("id3", "value4")}; + expected_data[kArray] = expected_array; + + rc_rpc_plugin::InteriorDataCacheImpl cache; + cache.Add(module, data1); + cache.Add(module, data2); + + const auto retrieved_data = cache.Retrieve(module); + + EXPECT_TRUE(cache.Contains(module)); + EXPECT_EQ(expected_data, retrieved_data); +} + +} // namespace rc_rpc_plugin_test diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/mock_rc_helpers.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/mock_rc_helpers.cc new file mode 100644 index 00000000000..3e60591c6b0 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/mock_rc_helpers.cc @@ -0,0 +1,138 @@ +/* + * Copyright (c) 2019, 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 "rc_rpc_plugin/mock/mock_rc_helpers.h" + +namespace rc_rpc_plugin { + +smart_objects::SmartObject RCHelpers::MergeModuleData( + const smart_objects::SmartObject& data1, + const smart_objects::SmartObject& data2) { + return MockRCHelpers::rc_helpers_mock()->MergeModuleData(data1, data2); +} + +const std::function +rc_rpc_plugin::RCHelpers::GetModuleTypeToDataMapping() { + return MockRCHelpers::rc_helpers_mock()->GetModuleTypeToDataMapping(); +} + +const std::function +rc_rpc_plugin::RCHelpers::GetModuleTypeToCapabilitiesMapping() { + return MockRCHelpers::rc_helpers_mock()->GetModuleTypeToCapabilitiesMapping(); +} + +const std::vector rc_rpc_plugin::RCHelpers::GetModuleTypesList() { + return MockRCHelpers::rc_helpers_mock()->GetModuleTypesList(); +} + +rc_rpc_plugin::RCAppExtensionPtr rc_rpc_plugin::RCHelpers::GetRCExtension( + application_manager::Application& app) { + return MockRCHelpers::rc_helpers_mock()->GetRCExtension(app); +} + +smart_objects::SmartObjectSPtr +rc_rpc_plugin::RCHelpers::CreateUnsubscribeRequestToHMI( + const ModuleUid& module, const uint32_t correlation_id) { + return MockRCHelpers::rc_helpers_mock()->CreateUnsubscribeRequestToHMI( + module, correlation_id); +} + +std::vector +rc_rpc_plugin::RCHelpers::AppsSubscribedToModule( + application_manager::ApplicationManager& app_mngr, + const ModuleUid& module) { + return MockRCHelpers::rc_helpers_mock()->AppsSubscribedToModule(app_mngr, + module); +} + +std::vector +rc_rpc_plugin::RCHelpers::AppsSubscribedToModuleType( + application_manager::ApplicationManager& app_mngr, + const std::string& module_type) { + return MockRCHelpers::rc_helpers_mock()->AppsSubscribedToModuleType( + app_mngr, module_type); +} + +rc_rpc_plugin::RCHelpers::AppsModuleTypes +rc_rpc_plugin::RCHelpers::GetApplicationsAllowedModuleTypes( + application_manager::ApplicationManager& app_mngr) { + return MockRCHelpers::rc_helpers_mock()->GetApplicationsAllowedModuleTypes( + app_mngr); +} + +const std::vector RCHelpers::buttons_climate() { + return MockRCHelpers::rc_helpers_mock()->buttons_climate(); +} + +const std::vector RCHelpers::buttons_radio() { + return MockRCHelpers::rc_helpers_mock()->buttons_radio(); +} + +const rc_rpc_plugin::RCHelpers::ButtonsMap RCHelpers::buttons_map() { + return MockRCHelpers::rc_helpers_mock()->buttons_map(); +} + +std::vector RCHelpers::GetModuleReadOnlyParams( + const std::string& module_type) { + return MockRCHelpers::rc_helpers_mock()->GetModuleReadOnlyParams(module_type); +} + +rc_rpc_types::ModuleIdConsentVector RCHelpers::FillModuleConsents( + const std::string& module_type, + const std::vector& module_ids, + const std::vector allowed) { + return MockRCHelpers::rc_helpers_mock()->FillModuleConsents( + module_type, module_ids, allowed); +} + +std::vector RCHelpers::RetrieveModuleIds( + const smart_objects::SmartObject& moduleIds) { + return MockRCHelpers::rc_helpers_mock()->RetrieveModuleIds(moduleIds); +} + +std::vector RCHelpers::RetrieveModuleConsents( + const smart_objects::SmartObject& consents) { + return MockRCHelpers::rc_helpers_mock()->RetrieveModuleConsents(consents); +} + +void RCHelpers::RemoveRedundantGPSDataFromIVDataMsg( + smart_objects::SmartObject& msg_params) { + return MockRCHelpers::rc_helpers_mock()->RemoveRedundantGPSDataFromIVDataMsg( + msg_params); +} + +MockRCHelpers* MockRCHelpers::rc_helpers_mock() { + static ::testing::NiceMock mock_rc_helpers; + return &mock_rc_helpers; +} + +} // namespace rc_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/rc_consent_manager_impl_test.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/rc_consent_manager_impl_test.cc new file mode 100644 index 00000000000..b4d826719a1 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/rc_consent_manager_impl_test.cc @@ -0,0 +1,339 @@ +/* + * Copyright (c) 2019, 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 + +#include "gmock/gmock.h" +#include "gtest/gtest.h" + +#include "application_manager/mock_application_manager_settings.h" +#include "rc_rpc_plugin/rc_consent_manager_impl.h" +#include "resumption/last_state.h" +#include "resumption/last_state_impl.h" +#include "utils/date_time.h" +#include "utils/file_system.h" + +#include "application_manager/mock_application_manager.h" + +using test::components::application_manager_test::MockApplicationManager; +using test::components::application_manager_test:: + MockApplicationManagerSettings; + +using ::testing::NiceMock; +using ::testing::Return; +using ::testing::ReturnRef; + +namespace { +const std::string kPolicyApp1Id = "app1_id"; +const std::string kPolicyApp2Id = "app2_id"; +const std::string kMacAddress1 = "device1"; +const std::string kMacAddress2 = "device2"; +const std::string kClimateModule = "CLIMATE"; +const std::string kRadioModule = "RADIO"; +const std::string kAppTestStorageFolder = "app_test_storage_folder"; +const std::string kAppTestInfoStorage = "app_test_info_storage"; +const uint32_t kPeriodOfConsentExpired = 30; // in days +} // namespace + +namespace rc_rpc_plugin_test { +namespace rc_consent_manager_test { +using namespace rc_rpc_plugin::rc_rpc_types; +using namespace rc_rpc_plugin; + +class RCConsentManagerImplTest : public ::testing::Test { + public: + RCConsentManagerImplTest() + : current_date_(0u) + , last_state_(new resumption::LastStateImpl(kAppTestStorageFolder, + kAppTestInfoStorage)) + , rc_consent_manager_(new rc_rpc_plugin::RCConsentManagerImpl( + *last_state_, mock_app_mngr_, kPeriodOfConsentExpired)) {} + + void SetUp() OVERRIDE { + current_date_ = std::time(0); + RemoveTemproraryTetsFiles(); + + ON_CALL(mock_app_mngr_, get_settings()) + .WillByDefault(ReturnRef(mock_app_mnrg_settings_)); + ON_CALL(mock_app_mnrg_settings_, period_for_consent_expiration()) + .WillByDefault(Return(kPeriodOfConsentExpired)); + } + + void RemoveTemproraryTetsFiles() { + // Remove exists storage file + if (file_system::FileExists(kAppTestInfoStorage)) { + file_system::DeleteFile(kAppTestInfoStorage); + } + + // Remove exists storage folder + if (file_system::DirectoryExists(kAppTestStorageFolder)) { + file_system::RemoveDirectory(kAppTestStorageFolder); + } + + last_state_->get_dictionary().clear(); + } + + protected: + time_t current_date_; + NiceMock mock_app_mnrg_settings_; + NiceMock mock_app_mngr_; + std::unique_ptr last_state_; + std::unique_ptr rc_consent_manager_; +}; + +TEST_F(RCConsentManagerImplTest, SaveAndGetModuleConsents_SUCCESS) { + const std::string radio_moduleId = "eb7739ea-b263-4fe1-af9c-9311d1acac2d"; + const std::string climate_moduleId = "34045662-a9dc-4823-8435-91056d4c26cb"; + + ModuleIdConsent radio_module_consent{ + {kRadioModule, radio_moduleId}, ModuleConsent::CONSENTED, current_date_}; + + ModuleIdConsent climate_module_consent{{kClimateModule, climate_moduleId}, + ModuleConsent::NOT_CONSENTED, + current_date_}; + + ModuleIdConsentVector module_consents{radio_module_consent, + climate_module_consent}; + + rc_consent_manager_->SaveModuleConsents( + kPolicyApp1Id, kMacAddress1, module_consents); + last_state_->SaveStateToFileSystem(); + + auto radio_consent = rc_consent_manager_->GetModuleConsent( + kPolicyApp1Id, kMacAddress1, {kRadioModule, radio_moduleId}); + auto climate_consent = rc_consent_manager_->GetModuleConsent( + kPolicyApp1Id, kMacAddress1, {kClimateModule, climate_moduleId}); + + EXPECT_EQ(ModuleConsent::CONSENTED, radio_consent); + EXPECT_EQ(ModuleConsent::NOT_CONSENTED, climate_consent); +} + +TEST_F(RCConsentManagerImplTest, ModuleId_NOT_EXISTS) { + const std::string radio_moduleId = "eb7739ea-b263-4fe1-af9c-9311d1acac2d"; + const std::string climate_moduleId = "34045662-a9dc-4823-8435-91056d4c26cb"; + + ModuleIdConsent radio_module_consent{ + {kRadioModule, radio_moduleId}, ModuleConsent::CONSENTED, current_date_}; + ModuleIdConsent climate_module_consent{{kClimateModule, climate_moduleId}, + ModuleConsent::CONSENTED, + current_date_}; + + const std::string uknown_moduleId = "639f1b7f-1d25-4dca-a2ce-00530860adea"; + const std::string uknown_moduleType = "UNKNOWN_TYPE"; + + ModuleUid unknown_module{uknown_moduleId, uknown_moduleType}; + + ModuleIdConsentVector module_consents{radio_module_consent, + climate_module_consent}; + + rc_consent_manager_->SaveModuleConsents( + kPolicyApp1Id, kMacAddress1, module_consents); + last_state_->SaveStateToFileSystem(); + + ModuleConsent consent = rc_consent_manager_->GetModuleConsent( + kPolicyApp1Id, kMacAddress1, unknown_module); + + EXPECT_EQ(ModuleConsent::NOT_EXISTS, consent); +} + +TEST_F(RCConsentManagerImplTest, ConsentIsExpired) { + time_t expired_date_45_days = + current_date_ - (date_time::SECONDS_IN_DAY * 45); + time_t expired_date_30_days = + current_date_ - (date_time::SECONDS_IN_DAY * 30); + time_t not_expired_date_29_days = + current_date_ - (date_time::SECONDS_IN_DAY * 29); + + const std::string moduleId1 = "dbef7693-adf9-42f1-95c7-5dff314d9985"; + const std::string moduleId2 = "1536b2ac-213f-463f-8589-a11453cd3729"; + const std::string moduleId3 = "e8b8169a-9f29-4499-a60b-2d126a1beffc"; + + ModuleUid module_resource1{kRadioModule, moduleId1}; + ModuleUid module_resource2{kRadioModule, moduleId2}; + ModuleUid module_resource3{kRadioModule, moduleId3}; + + ModuleIdConsent module_consent_expired1{ + module_resource1, ModuleConsent::CONSENTED, expired_date_45_days}; + ModuleIdConsent module_consent_expired2{ + module_resource2, ModuleConsent::CONSENTED, expired_date_30_days}; + + ModuleIdConsent module_consent_not_expired{ + module_resource3, ModuleConsent::CONSENTED, not_expired_date_29_days}; + + ModuleIdConsentVector module_consents{module_consent_expired1, + module_consent_expired2, + module_consent_not_expired}; + rc_consent_manager_->SaveModuleConsents( + kPolicyApp1Id, kMacAddress1, module_consents); + last_state_->SaveStateToFileSystem(); + + // All consents, which consent has been saved more than 30 days, will be + // removed. + rc_consent_manager_->RemoveExpiredConsents(); + + ModuleConsent expired_consent_45_days = rc_consent_manager_->GetModuleConsent( + kPolicyApp1Id, kMacAddress1, module_resource1); + EXPECT_EQ(ModuleConsent::NOT_EXISTS, expired_consent_45_days); + + ModuleConsent expired_consent_30_days = rc_consent_manager_->GetModuleConsent( + kPolicyApp1Id, kMacAddress1, module_resource2); + EXPECT_EQ(ModuleConsent::NOT_EXISTS, expired_consent_30_days); + + ModuleConsent not_expired_consent = rc_consent_manager_->GetModuleConsent( + kPolicyApp1Id, kMacAddress1, module_resource3); + EXPECT_EQ(ModuleConsent::CONSENTED, not_expired_consent); +} + +TEST_F(RCConsentManagerImplTest, + SaveModuleConsents_SameAppID_DifferentDeviceID_NotReplaced) { + const std::string moduleId = "cef4eae6-e22c-4943-bdc3-60e792414c4c"; + ModuleUid module_resource{kRadioModule, moduleId}; + + ModuleIdConsent radio_module_consent_app1_deviceId1{ + module_resource, ModuleConsent::CONSENTED, current_date_}; + + ModuleIdConsent radio_module_consent_app1_deviceId2{ + module_resource, ModuleConsent::NOT_CONSENTED, current_date_}; + + ModuleIdConsentVector module_consents_app1{ + radio_module_consent_app1_deviceId1}; + ModuleIdConsentVector module_consents_app2{ + radio_module_consent_app1_deviceId2}; + + rc_consent_manager_->SaveModuleConsents( + kPolicyApp1Id, kMacAddress1, module_consents_app1); + + rc_consent_manager_->SaveModuleConsents( + kPolicyApp1Id, kMacAddress2, module_consents_app2); + + last_state_->SaveStateToFileSystem(); + + // Module consents for same app ids and different device_id (mac_adress) will + // haven't been replaced each other + + ModuleConsent module_consent_deviceID1 = + rc_consent_manager_->GetModuleConsent( + kPolicyApp1Id, kMacAddress1, module_resource); + + ModuleConsent module_consent_deviceID2 = + rc_consent_manager_->GetModuleConsent( + kPolicyApp1Id, kMacAddress2, module_resource); + + EXPECT_EQ(ModuleConsent::CONSENTED, module_consent_deviceID1); + + // // Module consent for app_id2 has different value as has been saved above + EXPECT_EQ(ModuleConsent::NOT_CONSENTED, module_consent_deviceID2); +} + +TEST_F(RCConsentManagerImplTest, + SaveModuleConsents_SameAppID_SameDeviceID_Replaced) { + const std::string moduleId = "194aee9e-26cb-4f48-a775-8841a658002d"; + + ModuleUid radio_module_resource_consented{kRadioModule, moduleId}; + ModuleUid radio_module_resource_not_consented{kRadioModule, moduleId}; + + ModuleIdConsent radio_module_consent_app1_deviceId1{ + radio_module_resource_consented, ModuleConsent::CONSENTED, current_date_}; + + ModuleIdConsent radio_module_consent_app1_deviceId2{ + radio_module_resource_not_consented, + ModuleConsent::NOT_CONSENTED, + current_date_}; + + ModuleIdConsentVector module_consents_app1{ + radio_module_consent_app1_deviceId1}; + ModuleIdConsentVector module_consents_app2{ + radio_module_consent_app1_deviceId2}; + + rc_consent_manager_->SaveModuleConsents( + kPolicyApp1Id, kMacAddress1, module_consents_app1); + + last_state_->SaveStateToFileSystem(); + + rc_consent_manager_->SaveModuleConsents( + kPolicyApp1Id, kMacAddress1, module_consents_app2); + + last_state_->SaveStateToFileSystem(); + + // Module consents for same app ids and same device_id (mac_adress) will + // have been replaced each other + + ModuleConsent module_consent = rc_consent_manager_->GetModuleConsent( + kPolicyApp1Id, kMacAddress1, radio_module_resource_not_consented); + + EXPECT_EQ(ModuleConsent::NOT_CONSENTED, module_consent); +} + +TEST_F(RCConsentManagerImplTest, RemoveAllModuleConsents_SUCCESS) { + const std::string moduleId = "1c5408f2-9766-464c-a7bf-d834b62f43fa"; + + ModuleUid module_resource{kRadioModule, moduleId}; + + ModuleIdConsent radio_module_consent_app1_deviceId1{ + module_resource, ModuleConsent::CONSENTED, current_date_}; + + ModuleIdConsent radio_module_consent_app1_deviceId2{ + module_resource, ModuleConsent::NOT_CONSENTED, current_date_}; + + ModuleIdConsentVector module_consents_app1{ + radio_module_consent_app1_deviceId1}; + ModuleIdConsentVector module_consents_app2{ + radio_module_consent_app1_deviceId2}; + + rc_consent_manager_->SaveModuleConsents( + kPolicyApp1Id, kMacAddress1, module_consents_app1); + + rc_consent_manager_->SaveModuleConsents( + kPolicyApp1Id, kMacAddress2, module_consents_app2); + + last_state_->SaveStateToFileSystem(); + + rc_consent_manager_->RemoveAllConsents(); + + ModuleConsent module_consent_deviceID1 = + rc_consent_manager_->GetModuleConsent( + kPolicyApp1Id, kMacAddress1, module_resource); + + ModuleConsent module_consent_deviceID2 = + rc_consent_manager_->GetModuleConsent( + kPolicyApp1Id, kMacAddress2, module_resource); + + EXPECT_EQ(ModuleConsent::NOT_EXISTS, module_consent_deviceID1); + + EXPECT_EQ(ModuleConsent::NOT_EXISTS, module_consent_deviceID2); +} + +} // namespace rc_consent_manager_test +} // namespace rc_rpc_plugin_test diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/rc_helpers_test.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/rc_helpers_test.cc new file mode 100644 index 00000000000..21876c4c197 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/rc_helpers_test.cc @@ -0,0 +1,285 @@ +/* + * Copyright (c) 2019, 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 "rc_rpc_plugin/rc_helpers.h" +#include +#include +#include +#include +#include +#include "gtest/gtest.h" +#include "rc_rpc_plugin/rc_module_constants.h" + +namespace { +const std::string kKeyId = "id"; +const std::string kKeyStatus = "status"; +const std::string kKeyDensity = "density"; +const std::string kKeyValue = "value"; +const std::string kArray = "array"; +} // namespace + +namespace rc_rpc_plugin_test { + +using namespace rc_rpc_plugin; +using namespace smart_objects; + +class RCHelpersTest : public ::testing::Test { + public: + /** + * @brief Generates smart object with next structure: + * { + * "status": "status", + * "value": "value", + * "id": "id" + * } + * where is number specified with 'object_number' param. + * + * @param int object_number - number of object + * @param bool use_id_key - defines, whether "id" key must be added to smart + * object + * + * @return smart_objects::SmartObject - generated smart object + */ + smart_objects::SmartObject gen_smart_object(int object_number, + bool use_id_key) { + smart_objects::SmartObject result(smart_objects::SmartType_Map); + result[kKeyStatus] = kKeyStatus + std::to_string(object_number); + result[kKeyValue] = kKeyValue + std::to_string(object_number); + if (use_id_key) { + result[kKeyId] = kKeyId + std::to_string(object_number); + } + return result; + } +}; + +TEST_F(RCHelpersTest, + MergeModuleData_OneOfParamsNotSmartMap_ExpectDataReplacedWithNewOne) { + SmartObject data1(SmartType_Map); + SmartObject data2(SmartType_Array); + + const auto result = RCHelpers::MergeModuleData(data1, data2); + EXPECT_NE(result, data1); + EXPECT_EQ(result, data2); +} + +TEST_F(RCHelpersTest, + MergeModuleData_FirstObjectDontContainKey_ExpectDataAppendedWithNewOne) { + SmartObject data1(SmartType_Map); + SmartObject data2(SmartType_Map); + + std::map expected_keys_values = { + {"key1", "value1"}, {"key2", "value2"}}; + auto it = expected_keys_values.begin(); + + data1[it->first] = it->second; + ++it; + data2[it->first] = it->second; + + const auto result = RCHelpers::MergeModuleData(data1, data2); + for (auto& item : expected_keys_values) { + EXPECT_TRUE(result.keyExists(item.first)); + EXPECT_EQ(result[item.first], expected_keys_values[item.first]); + } +} + +TEST_F( + RCHelpersTest, + MergeModuleData_SecondObjectContainsDifferentValueType_ExpectDataReplacedWithNewOne) { + SmartObject data1(SmartType_Map); + SmartObject data2(SmartType_Map); + + data1["key1"] = "value1"; + data2["key1"] = 30; + + const auto result = RCHelpers::MergeModuleData(data1, data2); + EXPECT_EQ(data2["key1"], result["key1"]); +} + +TEST_F(RCHelpersTest, MergeModuleData_Recursive) { + SmartObject data1(SmartType_Map); + SmartObject data2(SmartType_Map); + + data1["key1"]["subkey1"] = "subvalue1"; + data2["key1"]["subkey2"] = 30; + + const auto result = RCHelpers::MergeModuleData(data1, data2); + EXPECT_EQ(result["key1"]["subkey1"], data1["key1"]["subkey1"]); + EXPECT_EQ(result["key1"]["subkey2"], data2["key1"]["subkey2"]); +} + +TEST_F( + RCHelpersTest, + MergeModuleData_MergeObjectsThatContainArrays_ExpectDataReplacedWithNewOne) { + SmartObject data1(SmartType_Map); + SmartObject data1_array(SmartType_Array); + (*data1_array.asArray()) = + SmartArray{gen_smart_object(1, true), gen_smart_object(2, false)}; + data1[kArray] = data1_array; + + SmartObject data2(SmartType_Map); + SmartObject data2_array(SmartType_Array); + (*data2_array.asArray()) = + SmartArray{gen_smart_object(3, true), gen_smart_object(4, false)}; + data2[kArray] = data2_array; + + SmartObject expected_result(SmartType_Map); + SmartObject expected_result_array(SmartType_Array); + (*expected_result_array.asArray()) = + SmartArray{data2[kArray].getElement(0), data2[kArray].getElement(1)}; + + expected_result[kArray] = expected_result_array; + + const auto result = RCHelpers::MergeModuleData(data1, data2); + EXPECT_EQ(expected_result, result); +} + +TEST_F(RCHelpersTest, + MergeArray_OneOfParamsNotSmartArray_ExpectDataReplacedWithSecond) { + SmartObject data1(SmartType_Array); + SmartObject data2(SmartType_Map); + + const auto result = RCHelpers::MergeArray(data1, data2); + EXPECT_NE(result, data1); + EXPECT_EQ(result, data2); +} + +TEST_F(RCHelpersTest, MergeArray_FirstArrayEmpty_ExpectDataReplacedWithSecond) { + SmartObject data1(SmartType_Array); + SmartObject data2(SmartType_Array); + for (int object : {0, 1}) { + data2.asArray()->emplace(data2.asArray()->begin(), SmartObject(object)); + } + + ASSERT_EQ(0u, data1.length()); + ASSERT_EQ(2u, data2.length()); + + const auto result = RCHelpers::MergeArray(data1, data2); + EXPECT_NE(result, data1); + EXPECT_EQ(result, data2); +} + +TEST_F(RCHelpersTest, + MergeArray_SecondArrayEmpty_ExpectDataReplacedWithSecond) { + SmartObject data1(SmartType_Array); + for (int object : {0, 1}) { + data1.asArray()->emplace(data1.asArray()->begin(), SmartObject(object)); + } + SmartObject data2(SmartType_Array); + + ASSERT_EQ(2u, data1.length()); + ASSERT_EQ(0u, data2.length()); + + const auto result = RCHelpers::MergeArray(data1, data2); + EXPECT_NE(result, data1); + EXPECT_EQ(result, data2); +} + +TEST_F(RCHelpersTest, MergeArray_SimpleArrays_ExpectDataReplacedWithSecond) { + SmartObject data1(SmartType_Array); + for (int object : {0, 1, 2, 3, 4, 5}) { + data1.asArray()->emplace(data1.asArray()->begin(), SmartObject(object)); + } + + SmartObject data2(SmartType_Array); + for (int object : {0, 1}) { + data2.asArray()->emplace(data2.asArray()->begin(), SmartObject(object)); + } + + ASSERT_EQ(6u, data1.length()); + ASSERT_EQ(2u, data2.length()); + + const auto result = RCHelpers::MergeArray(data1, data2); + EXPECT_NE(result, data1); + EXPECT_EQ(result, data2); +} + +TEST_F(RCHelpersTest, + MergeArray_ObjectsHaveNotEqualIds_ExpectDataAppendedWithNewOne) { + SmartObject data1 = gen_smart_object(1, true); + SmartObject data2 = gen_smart_object(2, true); + + SmartObject array1(SmartType_Array); + array1.asArray()->push_back(data1); + SmartObject array2(SmartType_Array); + array2.asArray()->push_back(data2); + + SmartObject expected_array(SmartType_Array); + expected_array.asArray()->push_back(data1); + expected_array.asArray()->push_back(data2); + ASSERT_EQ(2u, expected_array.length()); + + const auto result = RCHelpers::MergeArray(array1, array2); + EXPECT_EQ(expected_array, result); +} + +TEST_F(RCHelpersTest, + MergeArray_SomeObjectsDontHaveIdKey_ExpectDataReplacedWithSecond) { + int object_number = 1; + + SmartObject array1(SmartType_Array); + array1.asArray()->push_back(gen_smart_object(object_number++, true)); + + SmartObject array2(SmartType_Array); + array2.asArray()->push_back(gen_smart_object(object_number++, false)); + array2.asArray()->push_back(gen_smart_object(object_number++, true)); + + const auto result = RCHelpers::MergeArray(array1, array2); + EXPECT_EQ(array2, result); +} + +TEST_F( + RCHelpersTest, + MergeArray_SomeObjectsHaveEqualIds_ExpectDataWithSameIdUpdateValueOnlyNewDataAdded) { + SmartObject temp = gen_smart_object(1, true); + + SmartObject data1(SmartType_Array); + auto& data1_array = *data1.asArray(); + + data1_array.push_back(temp); + data1_array.push_back(gen_smart_object(2, true)); + + SmartObject data2(SmartType_Array); + auto& data2_array = *data2.asArray(); + + temp[kKeyValue] = "CUSTOM VALUE"; + data2_array.push_back(temp); + data2_array.push_back(gen_smart_object(3, true)); + + SmartObject expected_result(SmartType_Array); + expected_result.asArray()->push_back(temp); + expected_result.asArray()->push_back(data1_array[1]); + expected_result.asArray()->push_back(data2_array[1]); + + const auto result = RCHelpers::MergeArray(data1, data2); + EXPECT_EQ(expected_result, result); +} + +} // namespace rc_rpc_plugin_test diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/resource_allocation_manager/CMakeLists.txt b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/resource_allocation_manager/CMakeLists.txt new file mode 100644 index 00000000000..4b10d346437 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/resource_allocation_manager/CMakeLists.txt @@ -0,0 +1,83 @@ +# Copyright (c) 2019, 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 copyright holders nor the names of their contributors +# may be used to endorse or promote products derived from this software +# without specific prior written permission. + +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. + +include(${CMAKE_SOURCE_DIR}/tools/cmake/helpers/sources.cmake) + +include_directories ( + ${GMOCK_INCLUDE_DIRECTORY} + ${COMPONENTS_DIR}/application_manager/test/include + ${COMPONENTS_DIR}/application_manager/rpc_plugins/rc_rpc_plugin/include + ${COMPONENTS_DIR}/application_manager/rpc_plugins/rc_rpc_plugin/test/include/ + ${COMPONENTS_DIR}/include/test/application_manager/ + ${COMPONENTS_DIR}/rc_rpc_plugin/test/include +) + +set (RESOURCE_ALLOC_MANAGER_TEST_SOURCES +${COMPONENTS_DIR}/application_manager/rpc_plugins/rc_rpc_plugin/src/interior_data_manager_impl.cc +${COMPONENTS_DIR}/application_manager/rpc_plugins/rc_rpc_plugin/src/interior_data_cache_impl.cc +${COMPONENTS_DIR}/application_manager/rpc_plugins/rc_rpc_plugin/src/resource_allocation_manager_impl.cc +${COMPONENTS_DIR}/application_manager/rpc_plugins/rc_rpc_plugin/src/rc_rpc_plugin.cc +${COMPONENTS_DIR}/application_manager/rpc_plugins/rc_rpc_plugin/src/rc_app_extension.cc +${COMPONENTS_DIR}/application_manager/rpc_plugins/rc_rpc_plugin/src/rc_consent_manager_impl.cc +${COMPONENTS_DIR}/application_manager/rpc_plugins/rc_rpc_plugin/src/rc_capabilities_manager_impl.cc +${COMPONENTS_DIR}/application_manager/rpc_plugins/rc_rpc_plugin/src/rc_command_factory.cc +${COMPONENTS_DIR}/application_manager/rpc_plugins/rc_rpc_plugin/test/mock_rc_helpers.cc +${CMAKE_CURRENT_SOURCE_DIR}/resource_allocation_manager_impl_test.cc +) + +set(RC_COMMANDS_TEST_SOURCE_DIR ${COMPONENTS_DIR}/application_manager/rpc_plugins/rc_rpc_plugin/test/commands) +set(RC_COMMANDS_SOURCE_DIR ${COMPONENTS_DIR}/application_manager/rpc_plugins/rc_rpc_plugin/src/commands) +collect_sources(COMMANDS_SOURCES "${RC_COMMANDS_SOURCE_DIR}" "${RC_COMMANDS_TEST_SOURCE_DIR}") + +set(LIBRARIES + ApplicationManager + connectionHandler + SmartObjects + ProtocolHandler + MessageHelper + connectionHandler + Utils + Resumption + jsoncpp + gmock_main + dl +) + +if(ENABLE_LOG) + list(APPEND LIBRARIES log4cxx -L${LOG4CXX_LIBS_DIRECTORY}) + list(APPEND LIBRARIES apr-1 -L${APR_LIBS_DIRECTORY}) + list(APPEND LIBRARIES aprutil-1 -L${APR_UTIL_LIBS_DIRECTORY}) + list(APPEND LIBRARIES expat -L${EXPAT_LIBS_DIRECTORY}) +endif() + +list(APPEND COMMANDS_SOURCES ${RESOURCE_ALLOC_MANAGER_TEST_SOURCES}) + +create_test("resource_allocation_manager_test" "${COMMANDS_SOURCES}" "${LIBRARIES}") + 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/resource_allocation_manager_impl_test.cc similarity index 64% rename from src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/resource_allocation_manager_impl_test.cc rename to src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/resource_allocation_manager/resource_allocation_manager_impl_test.cc index 86c58b9d460..70ed832cb14 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/resource_allocation_manager_impl_test.cc @@ -30,41 +30,47 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include +#include #include "gtest/gtest.h" -#include "rc_rpc_plugin/resource_allocation_manager_impl.h" -#include "rc_rpc_plugin/rc_rpc_plugin.h" -#include "rc_rpc_plugin/rc_module_constants.h" #include "application_manager/mock_application.h" #include "application_manager/mock_application_manager.h" +#include "application_manager/mock_hmi_capabilities.h" #include "application_manager/mock_rpc_service.h" #include "application_manager/policies/mock_policy_handler_interface.h" #include "interfaces/HMI_API.h" #include "interfaces/MOBILE_API.h" +#include "rc_rpc_plugin/mock/mock_rc_capabilities_manager.h" +#include "rc_rpc_plugin/mock/mock_rc_helpers.h" +#include "rc_rpc_plugin/rc_module_constants.h" +#include "rc_rpc_plugin/rc_rpc_plugin.h" +#include "rc_rpc_plugin/resource_allocation_manager_impl.h" using test::components::application_manager_test::MockApplication; using test::components::application_manager_test::MockApplicationManager; using test::components::application_manager_test::MockRPCService; +using ::application_manager::ApplicationSharedPtr; +using ::application_manager::Message; +using ::application_manager::MessageType; +using ::protocol_handler::MessagePriority; +using ::rc_rpc_plugin::MockRCHelpers; using ::testing::_; +using ::testing::DoAll; +using ::testing::Eq; using ::testing::Mock; using ::testing::NiceMock; -using ::testing::StrictMock; using ::testing::Return; using ::testing::ReturnRef; using ::testing::SaveArg; -using ::testing::Eq; -using ::testing::DoAll; using ::testing::SetArgPointee; -using ::application_manager::Message; -using ::application_manager::MessageType; -using ::application_manager::ApplicationSharedPtr; -using ::protocol_handler::MessagePriority; +using ::testing::StrictMock; namespace { const bool kDeviceHandle = 1u; const std::string kModuleType1 = "CLIMATE"; const std::string kModuleType2 = "RADIO"; +const std::string kModuleId = "id1"; const int32_t kConnectionKey = 5; const int32_t kCorrelationId = 5; const uint32_t kAppId1 = 11u; @@ -72,12 +78,27 @@ const uint32_t kHMIAppId1 = 1u; const uint32_t kAppId2 = 22u; const std::string policy_app_id_1_ = "policy_id_1"; const uint32_t kSizeOfModules = 6u; -} +const application_manager::WindowID kDefaultWindowId = + mobile_apis::PredefinedWindows::DEFAULT_WINDOW; +const rc_rpc_plugin::Grid KDefaultUserLocation = {2, 0, 0, 1, 1, 1}; +const rc_rpc_plugin::Grid kDriverLocation = {0, 0, 0, 1, 1, 1}; +const rc_rpc_plugin::Grid kInvalidLocation = {0, 0, 0, 0, 0, 0}; +const std::vector kModuleList = { + rc_rpc_plugin::enums_value::kClimate, + rc_rpc_plugin::enums_value::kRadio, + rc_rpc_plugin::enums_value::kSeat, + rc_rpc_plugin::enums_value::kAudio, + rc_rpc_plugin::enums_value::kLight, + rc_rpc_plugin::enums_value::kHmiSettings}; + +} // namespace namespace rc_rpc_plugin_test { using namespace rc_rpc_plugin; +typedef std::shared_ptr MockRCHelpersPtr; + class RAManagerTest : public ::testing::Test { public: RAManagerTest() @@ -86,22 +107,58 @@ class RAManagerTest : public ::testing::Test { , mock_app_1_(std::make_shared >()) , mock_app_2_(std::make_shared >()) , apps_lock_ptr_(std::make_shared()) - , apps_da_(apps_, apps_lock_ptr_) { + , apps_da_(apps_, apps_lock_ptr_) + , module_service_area_(0, 0, 0, 3, 2, 1) + , mock_rc_helpers_(MockRCHelpers::rc_helpers_mock()) { ON_CALL(mock_app_mngr_, GetPolicyHandler()) .WillByDefault(ReturnRef(mock_policy_handler_)); auto plugin_id = rc_rpc_plugin::RCRPCPlugin::kRCPluginID; app_ext_ptr_ = std::make_shared(plugin_id); ON_CALL(*mock_app_1_, app_id()).WillByDefault(Return(kAppId1)); + PrepareResources(); + ON_CALL(mock_rc_capabilities_manager_, GetResources()) + .WillByDefault(Return(resources_)); + ON_CALL(mock_rc_capabilities_manager_, IsSeatLocationCapabilityProvided()) + .WillByDefault(Return(false)); + ON_CALL(mock_rc_capabilities_manager_, IsMultipleAccessAllowed(_)) + .WillByDefault(Return(true)); + ON_CALL(mock_rc_capabilities_manager_, GetModuleServiceArea(_)) + .WillByDefault(Return(module_service_area_)); + + ON_CALL(mock_app_mngr_, application(kAppId1)) + .WillByDefault(Return(mock_app_1_)); + ON_CALL(*mock_app_1_, + QueryInterface(rc_rpc_plugin::RCRPCPlugin::kRCPluginID)) + .WillByDefault(Return(app_ext_ptr_)); + + ON_CALL(mock_app_mngr_, application(kAppId2)) + .WillByDefault(Return(mock_app_2_)); + ON_CALL(*mock_app_2_, + QueryInterface(rc_rpc_plugin::RCRPCPlugin::kRCPluginID)) + .WillByDefault(Return(app_ext_ptr_)); + OnRCStatusNotificationExpectations(); } + void SetUp() OVERRIDE { + rc_app_extension_ = std::make_shared( + static_cast( + rc_rpc_plugin::RCRPCPlugin::kRCPluginID)); + ON_CALL(mock_rc_capabilities_manager_, + GetDriverLocationFromSeatLocationCapability()) + .WillByDefault(Return(kDriverLocation)); + ON_CALL(*mock_rc_helpers_, GetRCExtension(_)) + .WillByDefault(Return(rc_app_extension_)); + } + void CheckResultWithHMILevelAndAccessMode( ResourceAllocationManagerImpl& ra_manager, mobile_apis::HMILevel::eType app_level, const rc_rpc_plugin::AcquireResult::eType expected_result, const hmi_apis::Common_RCAccessMode::eType access_mode); + void PrepareResources(); void OnRCStatusNotificationExpectations(); protected: @@ -117,6 +174,12 @@ class RAManagerTest : public ::testing::Test { application_manager::ApplicationSet apps_; std::shared_ptr apps_lock_ptr_; DataAccessor apps_da_; + testing::NiceMock + mock_rc_capabilities_manager_; + std::vector resources_; + Grid module_service_area_; + RCAppExtensionPtr rc_app_extension_; + MockRCHelpers* mock_rc_helpers_; }; void RAManagerTest::CheckResultWithHMILevelAndAccessMode( @@ -131,19 +194,27 @@ void RAManagerTest::CheckResultWithHMILevelAndAccessMode( ra_manager.SetAccessMode(access_mode); EXPECT_EQ(rc_rpc_plugin::AcquireResult::ALLOWED, - ra_manager.AcquireResource(kModuleType1, kAppId1)); + ra_manager.AcquireResource(kModuleType1, kModuleId, kAppId1)); + + ra_manager.SetResourceAcquired(kModuleType1, kModuleId, kAppId1); + EXPECT_CALL(mock_app_mngr_, application(kAppId2)) .WillOnce(Return(mock_app_2_)); - EXPECT_CALL(*mock_app_2_, hmi_level()).WillOnce(Return(app_level)); + EXPECT_CALL(*mock_app_2_, hmi_level(kDefaultWindowId)) + .WillOnce(Return(app_level)); // Second app tries to get already acquired resource by 1st app - EXPECT_EQ(expected_result, ra_manager.AcquireResource(kModuleType1, kAppId2)); + EXPECT_EQ(expected_result, + ra_manager.AcquireResource(kModuleType1, kModuleId, kAppId2)); +} + +void RAManagerTest::PrepareResources() { + for (auto& module_type : kModuleList) { + ModuleUid module(module_type, kModuleId); + resources_.push_back(module); + } } void RAManagerTest::OnRCStatusNotificationExpectations() { - ON_CALL(mock_app_mngr_, application(kAppId1)) - .WillByDefault(Return(mock_app_1_)); - ON_CALL(*mock_app_1_, QueryInterface(rc_rpc_plugin::RCRPCPlugin::kRCPluginID)) - .WillByDefault(Return(app_ext_ptr_)); apps_.insert(mock_app_1_); ON_CALL(mock_app_mngr_, applications()).WillByDefault(Return(apps_da_)); } @@ -152,19 +223,21 @@ TEST_F(RAManagerTest, AcquireResource_NoAppRegistered_Expect_InUse) { // Arrange EXPECT_CALL(mock_app_mngr_, application(kAppId1)) .WillOnce(Return(ApplicationSharedPtr())); - ResourceAllocationManagerImpl ra_manager(mock_app_mngr_, mock_rpc_service_); + ResourceAllocationManagerImpl ra_manager( + mock_app_mngr_, mock_rpc_service_, mock_rc_capabilities_manager_); // Act & Assert EXPECT_EQ(rc_rpc_plugin::AcquireResult::IN_USE, - ra_manager.AcquireResource(kModuleType1, kAppId1)); + ra_manager.AcquireResource(kModuleType1, kModuleId, kAppId1)); } TEST_F(RAManagerTest, AcquireResource_AppRegisteredAnyHmiLevelResourceFree_Expect_Allowed) { // Arrange - ResourceAllocationManagerImpl ra_manager(mock_app_mngr_, mock_rpc_service_); + ResourceAllocationManagerImpl ra_manager( + mock_app_mngr_, mock_rpc_service_, mock_rc_capabilities_manager_); // Act & Assert EXPECT_EQ(rc_rpc_plugin::AcquireResult::ALLOWED, - ra_manager.AcquireResource(kModuleType1, kAppId1)); + ra_manager.AcquireResource(kModuleType1, kModuleId, kAppId1)); } TEST_F( @@ -173,14 +246,15 @@ TEST_F( // Arrange EXPECT_CALL(mock_app_mngr_, application(kAppId1)) .WillOnce(Return(mock_app_1_)); - ResourceAllocationManagerImpl ra_manager(mock_app_mngr_, mock_rpc_service_); + ResourceAllocationManagerImpl ra_manager( + mock_app_mngr_, mock_rpc_service_, mock_rc_capabilities_manager_); EXPECT_EQ(rc_rpc_plugin::AcquireResult::ALLOWED, - ra_manager.AcquireResource(kModuleType1, kAppId1)); + ra_manager.AcquireResource(kModuleType1, kModuleId, kAppId1)); EXPECT_CALL(mock_app_mngr_, application(kAppId1)) .WillOnce(Return(mock_app_1_)); // Same app tries to get already acquired resource EXPECT_EQ(rc_rpc_plugin::AcquireResult::ALLOWED, - ra_manager.AcquireResource(kModuleType1, kAppId1)); + ra_manager.AcquireResource(kModuleType1, kModuleId, kAppId1)); } TEST_F( @@ -193,7 +267,8 @@ TEST_F( const AcquireResult::eType expected_result = AcquireResult::REJECTED; const Common_RCAccessMode::eType access_mode = Common_RCAccessMode::eType::AUTO_ALLOW; - ResourceAllocationManagerImpl ra_manager(mock_app_mngr_, mock_rpc_service_); + ResourceAllocationManagerImpl ra_manager( + mock_app_mngr_, mock_rpc_service_, mock_rc_capabilities_manager_); CheckResultWithHMILevelAndAccessMode( ra_manager, app_level, expected_result, access_mode); } @@ -208,7 +283,8 @@ TEST_F( const AcquireResult::eType expected_result = AcquireResult::IN_USE; const Common_RCAccessMode::eType access_mode = Common_RCAccessMode::eType::AUTO_DENY; - ResourceAllocationManagerImpl ra_manager(mock_app_mngr_, mock_rpc_service_); + ResourceAllocationManagerImpl ra_manager( + mock_app_mngr_, mock_rpc_service_, mock_rc_capabilities_manager_); CheckResultWithHMILevelAndAccessMode( ra_manager, app_level, expected_result, access_mode); } @@ -223,7 +299,8 @@ TEST_F( const AcquireResult::eType expected_result = AcquireResult::ALLOWED; const Common_RCAccessMode::eType access_mode = Common_RCAccessMode::eType::AUTO_ALLOW; - ResourceAllocationManagerImpl ra_manager(mock_app_mngr_, mock_rpc_service_); + ResourceAllocationManagerImpl ra_manager( + mock_app_mngr_, mock_rpc_service_, mock_rc_capabilities_manager_); CheckResultWithHMILevelAndAccessMode( ra_manager, app_level, expected_result, access_mode); } @@ -238,7 +315,8 @@ TEST_F( const AcquireResult::eType expected_result = AcquireResult::ASK_DRIVER; const Common_RCAccessMode::eType access_mode = Common_RCAccessMode::eType::ASK_DRIVER; - ResourceAllocationManagerImpl ra_manager(mock_app_mngr_, mock_rpc_service_); + ResourceAllocationManagerImpl ra_manager( + mock_app_mngr_, mock_rpc_service_, mock_rc_capabilities_manager_); CheckResultWithHMILevelAndAccessMode( ra_manager, app_level, expected_result, access_mode); } @@ -246,32 +324,36 @@ TEST_F( TEST_F(RAManagerTest, AcquireResource_AcquiredModuleIsRejectedForApp2_ExpectApp2Rejected) { // Arrange - ResourceAllocationManagerImpl ra_manager(mock_app_mngr_, mock_rpc_service_); + ResourceAllocationManagerImpl ra_manager( + mock_app_mngr_, mock_rpc_service_, mock_rc_capabilities_manager_); EXPECT_CALL(mock_app_mngr_, application(kAppId1)) .WillRepeatedly(Return(mock_app_1_)); EXPECT_EQ(AcquireResult::ALLOWED, - ra_manager.AcquireResource(kModuleType1, kAppId1)); + ra_manager.AcquireResource(kModuleType1, kModuleId, kAppId1)); + + ra_manager.SetResourceAcquired(kModuleType1, kModuleId, kAppId1); // Act - ra_manager.OnDriverDisallowed(kModuleType1, kAppId2); + ra_manager.OnDriverDisallowed(kModuleType1, kModuleId, kAppId2); // Assert EXPECT_CALL(mock_app_mngr_, application(kAppId2)) .WillOnce(Return(mock_app_2_)); EXPECT_EQ(AcquireResult::REJECTED, - ra_manager.AcquireResource(kModuleType1, kAppId2)); + ra_manager.AcquireResource(kModuleType1, kModuleId, kAppId2)); } TEST_F(RAManagerTest, AppExit_ReleaseResource) { // Arrange - ResourceAllocationManagerImpl ra_manager(mock_app_mngr_, mock_rpc_service_); + ResourceAllocationManagerImpl ra_manager( + mock_app_mngr_, mock_rpc_service_, mock_rc_capabilities_manager_); ra_manager.SetAccessMode(hmi_apis::Common_RCAccessMode::eType::AUTO_DENY); EXPECT_CALL(mock_app_mngr_, application(kAppId1)) .WillRepeatedly(Return(mock_app_1_)); EXPECT_EQ(rc_rpc_plugin::AcquireResult::ALLOWED, - ra_manager.AcquireResource(kModuleType1, kAppId1)); + ra_manager.AcquireResource(kModuleType1, kModuleId, kAppId1)); // Act ra_manager.OnApplicationEvent( @@ -281,19 +363,22 @@ TEST_F(RAManagerTest, AppExit_ReleaseResource) { .WillRepeatedly(Return(mock_app_2_)); EXPECT_EQ(rc_rpc_plugin::AcquireResult::ALLOWED, - ra_manager.AcquireResource(kModuleType1, kAppId2)); + ra_manager.AcquireResource(kModuleType1, kModuleId, kAppId2)); } TEST_F(RAManagerTest, AnotherAppExit_NoReleaseResource) { // Arrange - ResourceAllocationManagerImpl ra_manager(mock_app_mngr_, mock_rpc_service_); + ResourceAllocationManagerImpl ra_manager( + mock_app_mngr_, mock_rpc_service_, mock_rc_capabilities_manager_); ra_manager.SetAccessMode(hmi_apis::Common_RCAccessMode::eType::AUTO_DENY); EXPECT_CALL(mock_app_mngr_, application(kAppId1)) .WillOnce(Return(mock_app_1_)); EXPECT_EQ(rc_rpc_plugin::AcquireResult::ALLOWED, - ra_manager.AcquireResource(kModuleType1, kAppId1)); + ra_manager.AcquireResource(kModuleType1, kModuleId, kAppId1)); + + ra_manager.SetResourceAcquired(kModuleType1, kModuleId, kAppId1); EXPECT_CALL(mock_app_mngr_, application(kAppId2)) .WillRepeatedly(Return(mock_app_2_)); @@ -306,15 +391,16 @@ TEST_F(RAManagerTest, AnotherAppExit_NoReleaseResource) { EXPECT_CALL(mock_app_mngr_, application(kAppId2)) .WillOnce(Return(mock_app_2_)); - EXPECT_CALL(*mock_app_2_, hmi_level()) + EXPECT_CALL(*mock_app_2_, hmi_level(kDefaultWindowId)) .WillOnce(Return(mobile_apis::HMILevel::HMI_FULL)); EXPECT_EQ(rc_rpc_plugin::AcquireResult::IN_USE, - ra_manager.AcquireResource(kModuleType1, kAppId2)); + ra_manager.AcquireResource(kModuleType1, kModuleId, kAppId2)); } TEST_F(RAManagerTest, AppUnregistered_ReleaseResource) { // Arrange - ResourceAllocationManagerImpl ra_manager(mock_app_mngr_, mock_rpc_service_); + ResourceAllocationManagerImpl ra_manager( + mock_app_mngr_, mock_rpc_service_, mock_rc_capabilities_manager_); ra_manager.SetAccessMode(hmi_apis::Common_RCAccessMode::eType::AUTO_DENY); RCAppExtensionPtr rc_extention_ptr = @@ -322,7 +408,7 @@ TEST_F(RAManagerTest, AppUnregistered_ReleaseResource) { rc_rpc_plugin::RCRPCPlugin::kRCPluginID)); EXPECT_EQ(rc_rpc_plugin::AcquireResult::ALLOWED, - ra_manager.AcquireResource(kModuleType1, kAppId1)); + ra_manager.AcquireResource(kModuleType1, kModuleId, kAppId1)); // Act application_manager::ApplicationSharedPtr app_ptr(mock_app_1_); @@ -335,18 +421,21 @@ TEST_F(RAManagerTest, AppUnregistered_ReleaseResource) { .WillOnce(Return(mock_app_2_)); EXPECT_EQ(rc_rpc_plugin::AcquireResult::ALLOWED, - ra_manager.AcquireResource(kModuleType1, kAppId2)); + ra_manager.AcquireResource(kModuleType1, kModuleId, kAppId2)); } TEST_F(RAManagerTest, AnotherAppUnregistered_NoReleaseResource) { // Arrange - ResourceAllocationManagerImpl ra_manager(mock_app_mngr_, mock_rpc_service_); + ResourceAllocationManagerImpl ra_manager( + mock_app_mngr_, mock_rpc_service_, mock_rc_capabilities_manager_); ra_manager.SetAccessMode(hmi_apis::Common_RCAccessMode::eType::AUTO_DENY); EXPECT_CALL(mock_app_mngr_, application(kAppId1)) .WillOnce(Return(mock_app_1_)); EXPECT_EQ(rc_rpc_plugin::AcquireResult::ALLOWED, - ra_manager.AcquireResource(kModuleType1, kAppId1)); + ra_manager.AcquireResource(kModuleType1, kModuleId, kAppId1)); + + ra_manager.SetResourceAcquired(kModuleType1, kModuleId, kAppId1); EXPECT_CALL(mock_app_mngr_, application(kAppId1)) .WillRepeatedly(Return(mock_app_2_)); @@ -360,24 +449,25 @@ TEST_F(RAManagerTest, AnotherAppUnregistered_NoReleaseResource) { EXPECT_CALL(mock_app_mngr_, application(kAppId2)) .WillOnce(Return(mock_app_2_)); - EXPECT_CALL(*mock_app_2_, hmi_level()) + EXPECT_CALL(*mock_app_2_, hmi_level(kDefaultWindowId)) .WillOnce(Return(mobile_apis::HMILevel::HMI_FULL)); EXPECT_EQ(rc_rpc_plugin::AcquireResult::IN_USE, - ra_manager.AcquireResource(kModuleType1, kAppId2)); + ra_manager.AcquireResource(kModuleType1, kModuleId, kAppId2)); } TEST_F(RAManagerTest, AppsDisallowed_ReleaseAllResources) { // Arrange - ResourceAllocationManagerImpl ra_manager(mock_app_mngr_, mock_rpc_service_); + ResourceAllocationManagerImpl ra_manager( + mock_app_mngr_, mock_rpc_service_, mock_rc_capabilities_manager_); ra_manager.SetAccessMode(hmi_apis::Common_RCAccessMode::eType::AUTO_DENY); EXPECT_CALL(mock_app_mngr_, application(kAppId1)) .WillRepeatedly(Return(mock_app_1_)); EXPECT_EQ(rc_rpc_plugin::AcquireResult::ALLOWED, - ra_manager.AcquireResource(kModuleType1, kAppId1)); + ra_manager.AcquireResource(kModuleType1, kModuleId, kAppId1)); EXPECT_EQ(rc_rpc_plugin::AcquireResult::ALLOWED, - ra_manager.AcquireResource(kModuleType2, kAppId1)); + ra_manager.AcquireResource(kModuleType2, kModuleId, kAppId1)); application_manager::ApplicationSet apps; apps.insert(mock_app_1_); @@ -400,18 +490,19 @@ TEST_F(RAManagerTest, AppsDisallowed_ReleaseAllResources) { EXPECT_CALL(mock_app_mngr_, application(kAppId2)) .WillRepeatedly(Return(mock_app_2_)); - EXPECT_CALL(*mock_app_2_, hmi_level()) + EXPECT_CALL(*mock_app_2_, hmi_level(kDefaultWindowId)) .WillRepeatedly(Return(mobile_apis::HMILevel::HMI_FULL)); EXPECT_EQ(rc_rpc_plugin::AcquireResult::ALLOWED, - ra_manager.AcquireResource(kModuleType1, kAppId2)); + ra_manager.AcquireResource(kModuleType1, kModuleId, kAppId2)); EXPECT_EQ(rc_rpc_plugin::AcquireResult::ALLOWED, - ra_manager.AcquireResource(kModuleType2, kAppId2)); + ra_manager.AcquireResource(kModuleType2, kModuleId, kAppId2)); Mock::VerifyAndClearExpectations(&mock_app_mngr_); } TEST_F(RAManagerTest, AppGotRevokedModulesWithPTU_ReleaseRevokedResource) { // Arrange - ResourceAllocationManagerImpl ra_manager(mock_app_mngr_, mock_rpc_service_); + ResourceAllocationManagerImpl ra_manager( + mock_app_mngr_, mock_rpc_service_, mock_rc_capabilities_manager_); ra_manager.SetAccessMode(hmi_apis::Common_RCAccessMode::eType::AUTO_DENY); EXPECT_CALL(mock_app_mngr_, application(kAppId1)) @@ -437,9 +528,13 @@ TEST_F(RAManagerTest, AppGotRevokedModulesWithPTU_ReleaseRevokedResource) { .WillRepeatedly(Return(policy_app_id_1_)); EXPECT_EQ(rc_rpc_plugin::AcquireResult::ALLOWED, - ra_manager.AcquireResource(kModuleType1, kAppId1)); + ra_manager.AcquireResource(kModuleType1, kModuleId, kAppId1)); + + ra_manager.SetResourceAcquired(kModuleType1, kModuleId, kAppId1); + EXPECT_EQ(rc_rpc_plugin::AcquireResult::ALLOWED, - ra_manager.AcquireResource(kModuleType2, kAppId1)); + ra_manager.AcquireResource(kModuleType2, kModuleId, kAppId1)); + ra_manager.SetResourceAcquired(kModuleType2, kModuleId, kAppId1); application_manager::ApplicationSet apps; apps.insert(mock_app_1_); @@ -449,29 +544,31 @@ TEST_F(RAManagerTest, AppGotRevokedModulesWithPTU_ReleaseRevokedResource) { EXPECT_CALL(mock_app_mngr_, applications()).WillRepeatedly(Return(apps_da)); - Resources allowed_modules; + std::vector allowed_modules; allowed_modules.push_back(kModuleType1); EXPECT_CALL(mock_policy_handler_, GetModuleTypes(policy_app_id_1_, _)) .WillOnce(DoAll(SetArgPointee<1>(allowed_modules), Return(true))); + EXPECT_CALL(mock_app_mngr_, application(kAppId2)) + .WillRepeatedly(Return(mock_app_2_)); + EXPECT_CALL(*mock_app_2_, hmi_level(kDefaultWindowId)) + .WillRepeatedly(Return(mobile_apis::HMILevel::HMI_FULL)); + // Act ra_manager.OnPolicyEvent(application_manager::plugin_manager::PolicyEvent:: kApplicationPolicyUpdated); - EXPECT_CALL(mock_app_mngr_, application(kAppId2)) - .WillRepeatedly(Return(mock_app_2_)); - EXPECT_CALL(*mock_app_2_, hmi_level()) - .WillRepeatedly(Return(mobile_apis::HMILevel::HMI_FULL)); EXPECT_EQ(rc_rpc_plugin::AcquireResult::IN_USE, - ra_manager.AcquireResource(kModuleType1, kAppId2)); + ra_manager.AcquireResource(kModuleType1, kModuleId, kAppId2)); EXPECT_EQ(rc_rpc_plugin::AcquireResult::ALLOWED, - ra_manager.AcquireResource(kModuleType2, kAppId2)); + ra_manager.AcquireResource(kModuleType2, kModuleId, kAppId2)); Mock::VerifyAndClearExpectations(&mock_app_mngr_); } TEST_F(RAManagerTest, GetAccessMode_ExpectedSameAsHadSet) { - ResourceAllocationManagerImpl ra_manager(mock_app_mngr_, mock_rpc_service_); + ResourceAllocationManagerImpl ra_manager( + mock_app_mngr_, mock_rpc_service_, mock_rc_capabilities_manager_); ra_manager.SetAccessMode(hmi_apis::Common_RCAccessMode::AUTO_DENY); EXPECT_EQ(hmi_apis::Common_RCAccessMode::AUTO_DENY, @@ -492,7 +589,8 @@ TEST_F(RAManagerTest, GetAccessMode_ExpectedSameAsHadSet) { TEST_F(RAManagerTest, OnRCStatus_AppRegistation_RC_allowed) { // Arrange - ResourceAllocationManagerImpl ra_manager(mock_app_mngr_, mock_rpc_service_); + ResourceAllocationManagerImpl ra_manager( + mock_app_mngr_, mock_rpc_service_, mock_rc_capabilities_manager_); ON_CALL((*mock_app_1_), is_remote_control_supported()) .WillByDefault(Return(true)); ON_CALL((*mock_app_1_), hmi_app_id()).WillByDefault(Return(kHMIAppId1)); @@ -521,7 +619,8 @@ TEST_F(RAManagerTest, OnRCStatus_AppRegistation_RC_allowed) { TEST_F(RAManagerTest, OnRCStatus_AppRegistation_RC_disallowed) { // Arrange - ResourceAllocationManagerImpl ra_manager(mock_app_mngr_, mock_rpc_service_); + ResourceAllocationManagerImpl ra_manager( + mock_app_mngr_, mock_rpc_service_, mock_rc_capabilities_manager_); ra_manager.set_rc_enabled(false); ON_CALL((*mock_app_1_), is_remote_control_supported()) @@ -549,7 +648,8 @@ TEST_F(RAManagerTest, OnRCStatus_AppRegistation_RC_disallowed) { TEST_F(RAManagerTest, OnRCStatus_RCStateChanging_RC_disabling) { // Arrange - ResourceAllocationManagerImpl ra_manager(mock_app_mngr_, mock_rpc_service_); + ResourceAllocationManagerImpl ra_manager( + mock_app_mngr_, mock_rpc_service_, mock_rc_capabilities_manager_); ON_CALL((*mock_app_1_), is_remote_control_supported()) .WillByDefault(Return(true)); ON_CALL((*mock_app_1_), hmi_app_id()).WillByDefault(Return(kHMIAppId1)); @@ -586,7 +686,8 @@ TEST_F(RAManagerTest, OnRCStatus_RCStateChanging_RC_disabling) { TEST_F(RAManagerTest, OnRCStatus_RCStateChanging_RC_enabling) { // Arrange - ResourceAllocationManagerImpl ra_manager(mock_app_mngr_, mock_rpc_service_); + ResourceAllocationManagerImpl ra_manager( + mock_app_mngr_, mock_rpc_service_, mock_rc_capabilities_manager_); ON_CALL((*mock_app_1_), is_remote_control_supported()) .WillByDefault(Return(true)); ON_CALL((*mock_app_1_), hmi_app_id()).WillByDefault(Return(kHMIAppId1)); @@ -623,14 +724,17 @@ TEST_F(RAManagerTest, OnRCStatus_RCStateChanging_RC_enabling) { TEST_F(RAManagerTest, OnRCStatus_ModuleAllocation) { // Arrange - ResourceAllocationManagerImpl ra_manager(mock_app_mngr_, mock_rpc_service_); + ResourceAllocationManagerImpl ra_manager( + mock_app_mngr_, mock_rpc_service_, mock_rc_capabilities_manager_); ON_CALL((*mock_app_1_), is_remote_control_supported()) .WillByDefault(Return(true)); ON_CALL((*mock_app_1_), hmi_app_id()).WillByDefault(Return(kHMIAppId1)); EXPECT_EQ(rc_rpc_plugin::AcquireResult::ALLOWED, - ra_manager.AcquireResource(kModuleType1, kAppId1)); + ra_manager.AcquireResource(kModuleType1, kModuleId, kAppId1)); + + ra_manager.SetResourceAcquired(kModuleType1, kModuleId, kAppId1); application_manager::commands::MessageSharedPtr message_to_mob; EXPECT_CALL(mock_rpc_service_, SendMessageToMobile(_, false)) @@ -665,4 +769,118 @@ TEST_F(RAManagerTest, OnRCStatus_ModuleAllocation) { kHMIAppId1); } -} // namespace rc_rpc_plugin +// UL - User Location +// If User Location is invalid, in any case AcquireResult will be REJECTED +TEST_F(RAManagerTest, AcquireResource_UL_IsInvalid_REJECTED) { + ResourceAllocationManagerImpl ra_manager( + mock_app_mngr_, mock_rpc_service_, mock_rc_capabilities_manager_); + + ON_CALL(mock_rc_capabilities_manager_, IsSeatLocationCapabilityProvided()) + .WillByDefault(Return(true)); + rc_app_extension_->SetUserLocation(kInvalidLocation); + + EXPECT_EQ(AcquireResult::REJECTED, + ra_manager.AcquireResource(kModuleType1, kModuleId, kAppId1)); +} + +// UL - User Location, MA - Multiple Access +TEST_F(RAManagerTest, + AcquireResource_UL_IsValid_ResourceIsFree_MA_False_ALLOWED) { + ResourceAllocationManagerImpl ra_manager( + mock_app_mngr_, mock_rpc_service_, mock_rc_capabilities_manager_); + + ON_CALL(mock_rc_capabilities_manager_, IsSeatLocationCapabilityProvided()) + .WillByDefault(Return(true)); + rc_app_extension_->SetUserLocation(KDefaultUserLocation); + + EXPECT_EQ(AcquireResult::ALLOWED, + ra_manager.AcquireResource(kModuleType1, kModuleId, kAppId1)); +} + +// UL - User Location, MA - Multiple Access +TEST_F(RAManagerTest, + AcquireResource_UL_IsValid_ResourceIsAcquired_MA_False_REJECTED) { + ResourceAllocationManagerImpl ra_manager( + mock_app_mngr_, mock_rpc_service_, mock_rc_capabilities_manager_); + + ON_CALL(mock_rc_capabilities_manager_, IsSeatLocationCapabilityProvided()) + .WillByDefault(Return(true)); + rc_app_extension_->SetUserLocation(KDefaultUserLocation); + + EXPECT_EQ(AcquireResult::ALLOWED, + ra_manager.AcquireResource(kModuleType1, kModuleId, kAppId1)); + + ra_manager.SetResourceAcquired(kModuleType1, kModuleId, kAppId1); + ON_CALL(*mock_app_2_, hmi_level(kDefaultWindowId)) + .WillByDefault(Return(mobile_apis::HMILevel::HMI_FULL)); + ON_CALL(mock_rc_capabilities_manager_, IsMultipleAccessAllowed(_)) + .WillByDefault(Return(false)); + EXPECT_EQ(AcquireResult::REJECTED, + ra_manager.AcquireResource(kModuleType1, kModuleId, kAppId2)); +} + +// UL - User Location, MA - Multiple Access +TEST_F(RAManagerTest, + AcquireResource_UL_IsValid_ResourceIsFree_MA_True_ALLOWED) { + ResourceAllocationManagerImpl ra_manager( + mock_app_mngr_, mock_rpc_service_, mock_rc_capabilities_manager_); + + ON_CALL(mock_rc_capabilities_manager_, IsSeatLocationCapabilityProvided()) + .WillByDefault(Return(true)); + rc_app_extension_->SetUserLocation(KDefaultUserLocation); + + EXPECT_EQ(AcquireResult::ALLOWED, + ra_manager.AcquireResource(kModuleType1, kModuleId, kAppId1)); + + ON_CALL(*mock_app_2_, hmi_level(kDefaultWindowId)) + .WillByDefault(Return(mobile_apis::HMILevel::HMI_FULL)); + EXPECT_EQ(AcquireResult::ALLOWED, + ra_manager.AcquireResource(kModuleType1, kModuleId, kAppId2)); +} + +// UL - User Location, MA - Multiple Access, AM - Access Mode +TEST_F(RAManagerTest, + AcquireResource_UL_IsValid_ResourceIsAcquired_MA_True_AM_AUTO_DENY) { + ResourceAllocationManagerImpl ra_manager( + mock_app_mngr_, mock_rpc_service_, mock_rc_capabilities_manager_); + + ON_CALL(mock_rc_capabilities_manager_, IsSeatLocationCapabilityProvided()) + .WillByDefault(Return(true)); + rc_app_extension_->SetUserLocation(KDefaultUserLocation); + + EXPECT_EQ(AcquireResult::ALLOWED, + ra_manager.AcquireResource(kModuleType1, kModuleId, kAppId1)); + + ra_manager.SetResourceAcquired(kModuleType1, kModuleId, kAppId1); + + ra_manager.SetAccessMode(hmi_apis::Common_RCAccessMode::AUTO_DENY); + + ON_CALL(*mock_app_2_, hmi_level(kDefaultWindowId)) + .WillByDefault(Return(mobile_apis::HMILevel::HMI_FULL)); + EXPECT_EQ(AcquireResult::IN_USE, + ra_manager.AcquireResource(kModuleType1, kModuleId, kAppId2)); +} + +TEST_F(RAManagerTest, + AcquireResource_UL_IsValid_ResourceIsAcquired_MA_True_AM_ASK_DRIVER) { + ResourceAllocationManagerImpl ra_manager( + mock_app_mngr_, mock_rpc_service_, mock_rc_capabilities_manager_); + + ON_CALL(mock_rc_capabilities_manager_, IsSeatLocationCapabilityProvided()) + .WillByDefault(Return(true)); + rc_app_extension_->SetUserLocation(KDefaultUserLocation); + + EXPECT_EQ(AcquireResult::ALLOWED, + ra_manager.AcquireResource(kModuleType1, kModuleId, kAppId1)); + + ra_manager.SetResourceAcquired(kModuleType1, kModuleId, kAppId1); + + ra_manager.SetAccessMode(hmi_apis::Common_RCAccessMode::ASK_DRIVER); + + ON_CALL(*mock_app_2_, hmi_level(kDefaultWindowId)) + .WillByDefault(Return(mobile_apis::HMILevel::HMI_FULL)); + EXPECT_EQ(AcquireResult::ASK_DRIVER, + ra_manager.AcquireResource(kModuleType1, kModuleId, kAppId2)); +} + +} // namespace rc_rpc_plugin_test diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/CMakeLists.txt b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/CMakeLists.txt index fdf02b57cb7..fe8857b6b10 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/CMakeLists.txt +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/CMakeLists.txt @@ -51,21 +51,27 @@ collect_sources(APP_EXTENSIONS "${EXTENSIONS_SOURCE_DIR}") collect_sources(RPC_PLUGIN_SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/src") set(LIBRARIES + ApplicationManager HMI_API MOBILE_API - ApplicationManager + MessageHelper + connectionHandler v4_protocol_v1_2_no_extra SmartObjects Utils - Policy + PolicyStatic + jsoncpp ) if(ENABLE_LOG) list(APPEND LIBRARIES log4cxx -L${LOG4CXX_LIBS_DIRECTORY}) endif() -add_library("sdl_rpc_plugin" SHARED ${MOBILE_COMMANDS} ${HMI_COMMANDS} ${RPC_PLUGIN_SOURCES} ${APP_EXTENSIONS}) -target_link_libraries("sdl_rpc_plugin" ${LIBRARIES}) +add_library("sdl_rpc_plugin_static" ${MOBILE_COMMANDS} ${HMI_COMMANDS} ${RPC_PLUGIN_SOURCES} ${APP_EXTENSIONS}) +target_link_libraries("sdl_rpc_plugin_static" ${LIBRARIES}) + +add_library("sdl_rpc_plugin" SHARED "src/sdl_rpc_plugin.cc") +target_link_libraries("sdl_rpc_plugin" sdl_rpc_plugin_static) set(INSTALL_DESTINATION bin) diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/activate_app_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/activate_app_request.h index 7b0911fef9b..6d8f5e4b2bd 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/activate_app_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/activate_app_request.h @@ -72,6 +72,6 @@ class ActivateAppRequest : public app_mngr::commands::RequestToHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ACTIVATE_APP_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/activate_app_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/activate_app_response.h index f937b4f63bc..93be297bf61 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/activate_app_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/activate_app_response.h @@ -72,6 +72,6 @@ class ActivateAppResponse : public app_mngr::commands::ResponseFromHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ACTIVATE_APP_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/add_statistics_info_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/add_statistics_info_notification.h index 4e9e4d54d73..6e7ef63cf46 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/add_statistics_info_notification.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/add_statistics_info_notification.h @@ -74,6 +74,6 @@ class AddStatisticsInfoNotification } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ADD_STATISTICS_INFO_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/allow_all_apps_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/allow_all_apps_request.h index 45acb3a424d..54a81f50f30 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/allow_all_apps_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/allow_all_apps_request.h @@ -72,6 +72,6 @@ class AllowAllAppsRequest : public app_mngr::commands::RequestToHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ALLOW_ALL_APPS_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/allow_all_apps_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/allow_all_apps_response.h index 41d1c9e752e..ffd60a61d86 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/allow_all_apps_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/allow_all_apps_response.h @@ -72,6 +72,6 @@ class AllowAllAppsResponse : public app_mngr::commands::ResponseFromHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ALLOW_ALL_APPS_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/allow_app_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/allow_app_request.h index b3a2d88d7d4..c8c0198cc8d 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/allow_app_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/allow_app_request.h @@ -72,6 +72,6 @@ class AllowAppRequest : public app_mngr::commands::RequestToHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ALLOW_APP_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/allow_app_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/allow_app_response.h index 55637e17565..5f6ee670ecb 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/allow_app_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/allow_app_response.h @@ -72,6 +72,6 @@ class AllowAppResponse : public app_mngr::commands::ResponseFromHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ALLOW_APP_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/basic_communication_close_application_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/basic_communication_close_application_request.h new file mode 100644 index 00000000000..9847f567e08 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/basic_communication_close_application_request.h @@ -0,0 +1,80 @@ +/* + Copyright (c) 2019, Ford Motor Company, Livio + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + + Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following + disclaimer in the documentation and/or other materials provided with the + distribution. + + Neither the name of the the copyright holders nor the names of their + contributors may be used to endorse or promote products derived from this + software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_BASIC_COMMUNICATION_CLOSE_APPLICATION_REQUEST_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_BASIC_COMMUNICATION_CLOSE_APPLICATION_REQUEST_H_ + +#include "application_manager/commands/request_to_hmi.h" +#include "sdl_rpc_plugin/sdl_rpc_plugin.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief BasicCommunicationCloseApplicationRequest command class + **/ +class BasicCommunicationCloseApplicationRequest + : public app_mngr::commands::RequestToHMI { + public: + /** + * @brief BasicCommunicationCloseApplicationRequest class constructor + * + * @param message Incoming SmartObject message + **/ + BasicCommunicationCloseApplicationRequest( + const app_mngr::commands::MessageSharedPtr& message, + app_mngr::ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle); + + /** + * @brief BasicCommunicationCloseApplicationRequest class destructor + **/ + ~BasicCommunicationCloseApplicationRequest() OVERRIDE; + + /** + * @brief Execute command + **/ + void Run() OVERRIDE; + + private: + DISALLOW_COPY_AND_ASSIGN(BasicCommunicationCloseApplicationRequest); +}; + +} // namespace commands + +} // namespace sdl_rpc_plugin + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_BASIC_COMMUNICATION_CLOSE_APPLICATION_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/basic_communication_close_application_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/basic_communication_close_application_response.h new file mode 100644 index 00000000000..9576684b77e --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/basic_communication_close_application_response.h @@ -0,0 +1,80 @@ +/* + Copyright (c) 2019, Ford Motor Company, Livio + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + + Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following + disclaimer in the documentation and/or other materials provided with the + distribution. + + Neither the name of the the copyright holders nor the names of their + contributors may be used to endorse or promote products derived from this + software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_BASIC_COMMUNICATION_CLOSE_APPLICATION_RESPONSE_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_BASIC_COMMUNICATION_CLOSE_APPLICATION_RESPONSE_H_ + +#include "application_manager/commands/response_from_hmi.h" +#include "sdl_rpc_plugin/sdl_rpc_plugin.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief BasicCommunicationCloseApplicationResponse command class + **/ +class BasicCommunicationCloseApplicationResponse + : public app_mngr::commands::ResponseFromHMI { + public: + /** + * @brief BasicCommunicationCloseApplicationResponse class constructor + * + * @param message Incoming SmartObject message + **/ + BasicCommunicationCloseApplicationResponse( + const app_mngr::commands::MessageSharedPtr& message, + app_mngr::ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle); + + /** + * @brief BasicCommunicationCloseApplicationResponse class destructor + **/ + ~BasicCommunicationCloseApplicationResponse() OVERRIDE; + + /** + * @brief Execute command + **/ + void Run() OVERRIDE; + + private: + DISALLOW_COPY_AND_ASSIGN(BasicCommunicationCloseApplicationResponse); +}; + +} // namespace commands + +} // namespace sdl_rpc_plugin + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_BASIC_COMMUNICATION_CLOSE_APPLICATION_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/basic_communication_get_system_time_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/basic_communication_get_system_time_response.h index 3a97ebdfb5e..e90e6cd20fb 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/basic_communication_get_system_time_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/basic_communication_get_system_time_response.h @@ -35,8 +35,8 @@ #include "application_manager/commands/response_from_hmi.h" -#include "utils/macro.h" #include "application_manager/application_manager.h" +#include "utils/macro.h" namespace sdl_rpc_plugin { namespace app_mngr = application_manager; diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/basic_communication_on_awake_sdl.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/basic_communication_on_awake_sdl.h index 2ac1be2580b..82ac7b0efaf 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/basic_communication_on_awake_sdl.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/basic_communication_on_awake_sdl.h @@ -72,6 +72,6 @@ class OnAwakeSDLNotification : public app_mngr::commands::NotificationFromHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_BASIC_COMMUNICATION_ON_AWAKE_SDL_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/basic_communication_system_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/basic_communication_system_request.h index a7eb8201468..71eb9e41059 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/basic_communication_system_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/basic_communication_system_request.h @@ -74,6 +74,6 @@ class BasicCommunicationSystemRequest } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_BASIC_COMMUNICATION_SYSTEM_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/basic_communication_system_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/basic_communication_system_response.h index 20483a45e35..c76993cc6f4 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/basic_communication_system_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/basic_communication_system_response.h @@ -74,6 +74,6 @@ class BasicCommunicationSystemResponse } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_BASIC_COMMUNICATION_SYSTEM_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/button_get_capabilities_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/button_get_capabilities_request.h index 5c650fb8e41..9bb3d9a6fb6 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/button_get_capabilities_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/button_get_capabilities_request.h @@ -73,6 +73,6 @@ class ButtonGetCapabilitiesRequest : public app_mngr::commands::RequestToHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_BUTTON_GET_CAPABILITIES_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/button_get_capabilities_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/button_get_capabilities_response.h index bf2f15c18a6..4431ea12249 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/button_get_capabilities_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/button_get_capabilities_response.h @@ -74,6 +74,6 @@ class ButtonGetCapabilitiesResponse } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_BUTTON_GET_CAPABILITIES_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/close_popup_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/close_popup_request.h index 635b0579f43..bfcf4789309 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/close_popup_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/close_popup_request.h @@ -72,6 +72,6 @@ class ClosePopupRequest : public app_mngr::commands::RequestToHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_CLOSE_POPUP_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/close_popup_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/close_popup_response.h index 199b40f0704..7477bda854b 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/close_popup_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/close_popup_response.h @@ -72,6 +72,6 @@ class ClosePopupResponse : public app_mngr::commands::ResponseFromHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_CLOSE_POPUP_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/decrypt_certificate_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/decrypt_certificate_request.h index a70bff2553c..f59b36fe09d 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/decrypt_certificate_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/decrypt_certificate_request.h @@ -67,6 +67,6 @@ class DecryptCertificateRequest : public app_mngr::commands::RequestToHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_DECRYPT_CERTIFICATE_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/decrypt_certificate_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/decrypt_certificate_response.h index 88b216eeea4..9844ed91659 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/decrypt_certificate_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/decrypt_certificate_response.h @@ -73,6 +73,6 @@ class DecryptCertificateResponse : public app_mngr::commands::ResponseFromHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_DECRYPT_CERTIFICATE_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/dial_number_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/dial_number_request.h index fa0efb90e68..bafe9c1e915 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/dial_number_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/dial_number_request.h @@ -75,6 +75,6 @@ class DialNumberRequest : public app_mngr::commands::RequestToHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_DIAL_NUMBER_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/dial_number_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/dial_number_response.h index 33d4788ecaa..9097757ab23 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/dial_number_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/dial_number_response.h @@ -76,6 +76,6 @@ class DialNumberResponse : public app_mngr::commands::ResponseFromHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_DIAL_NUMBER_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/get_system_info_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/get_system_info_request.h index d771167798b..8d3be685394 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/get_system_info_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/get_system_info_request.h @@ -72,6 +72,6 @@ class GetSystemInfoRequest : public app_mngr::commands::RequestToHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_GET_SYSTEM_INFO_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/get_system_info_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/get_system_info_response.h index 5bf5f41b739..d4f35a4e2a0 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/get_system_info_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/get_system_info_response.h @@ -33,8 +33,8 @@ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_GET_SYSTEM_INFO_RESPONSE_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_GET_SYSTEM_INFO_RESPONSE_H_ -#include "application_manager/commands/response_from_hmi.h" #include "application_manager/application_manager.h" +#include "application_manager/commands/response_from_hmi.h" namespace sdl_rpc_plugin { namespace app_mngr = application_manager; @@ -82,6 +82,6 @@ class GetSystemInfoResponse : public app_mngr::commands::ResponseFromHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_GET_SYSTEM_INFO_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/mixing_audio_supported_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/mixing_audio_supported_request.h index 34c10cedf12..46aa575eb5b 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/mixing_audio_supported_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/mixing_audio_supported_request.h @@ -73,6 +73,6 @@ class MixingAudioSupportedRequest : public app_mngr::commands::RequestToHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_MIXING_AUDIO_SUPPORTED_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/mixing_audio_supported_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/mixing_audio_supported_response.h index 5c676662253..32dd23d352d 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/mixing_audio_supported_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/mixing_audio_supported_response.h @@ -74,6 +74,6 @@ class MixingAudioSupportedResponse } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_MIXING_AUDIO_SUPPORTED_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_alert_maneuver_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_alert_maneuver_request.h index 3f63ef883dd..a04488df76b 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_alert_maneuver_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_alert_maneuver_request.h @@ -72,6 +72,6 @@ class NaviAlertManeuverRequest : public app_mngr::commands::RequestToHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_NAVI_ALERT_MANEUVER_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_alert_maneuver_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_alert_maneuver_response.h index 7d7c4de85e9..610af3fbfc0 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_alert_maneuver_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_alert_maneuver_response.h @@ -72,6 +72,6 @@ class NaviAlertManeuverResponse : public app_mngr::commands::ResponseFromHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_NAVI_ALERT_MANEUVER_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_audio_start_stream_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_audio_start_stream_request.h index 80e948ad250..fa9eee485e2 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_audio_start_stream_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_audio_start_stream_request.h @@ -63,8 +63,8 @@ class AudioStartStreamRequest : public app_mngr::commands::RequestToHMI, virtual ~AudioStartStreamRequest(); /** - * @brief onTimeOut from requrst Controller - */ + * @brief onTimeOut from requrst Controller + */ virtual void onTimeOut(); /** @@ -78,9 +78,9 @@ class AudioStartStreamRequest : public app_mngr::commands::RequestToHMI, virtual void on_event(const app_mngr::event_engine::Event& event); /** - * @brief RetryStartSession resend HMI startSession request if needed. - * If limit expired, set audio_stream_retry_number counter to 0 - */ + * @brief RetryStartSession resend HMI startSession request if needed. + * If limit expired, set audio_stream_retry_number counter to 0 + */ void RetryStartSession(); private: @@ -90,6 +90,6 @@ class AudioStartStreamRequest : public app_mngr::commands::RequestToHMI, } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_NAVI_AUDIO_START_STREAM_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_audio_start_stream_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_audio_start_stream_response.h index 926cfc36edb..0f669084cbc 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_audio_start_stream_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_audio_start_stream_response.h @@ -71,6 +71,6 @@ class AudioStartStreamResponse : public app_mngr::commands::ResponseFromHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_NAVI_AUDIO_START_STREAM_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_audio_stop_stream_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_audio_stop_stream_request.h index 7c5fbbdd3d1..9f3aa8c3120 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_audio_stop_stream_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_audio_stop_stream_request.h @@ -71,6 +71,6 @@ class AudioStopStreamRequest : public app_mngr::commands::RequestToHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_NAVI_AUDIO_STOP_STREAM_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_audio_stop_stream_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_audio_stop_stream_response.h index 8eb091dd921..740efc2d19c 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_audio_stop_stream_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_audio_stop_stream_response.h @@ -71,6 +71,6 @@ class AudioStopStreamResponse : public app_mngr::commands::ResponseFromHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_NAVI_AUDIO_STOP_STREAM_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_get_way_points_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_get_way_points_request.h index dab5fc1022c..0e2ad8b9a32 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_get_way_points_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_get_way_points_request.h @@ -70,6 +70,6 @@ class NaviGetWayPointsRequest : public app_mngr::commands::RequestToHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_NAVI_GET_WAY_POINTS_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_get_way_points_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_get_way_points_response.h index fb93c2c64ad..9fef4f041e9 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_get_way_points_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_get_way_points_response.h @@ -72,6 +72,6 @@ class NaviGetWayPointsResponse : public app_mngr::commands::ResponseFromHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_NAVI_GET_WAY_POINTS_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_is_ready_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_is_ready_request.h index 404ddc9f005..17d4eb483f0 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_is_ready_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_is_ready_request.h @@ -78,6 +78,6 @@ class NaviIsReadyRequest : public app_mngr::commands::RequestToHMI, } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_NAVI_IS_READY_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_is_ready_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_is_ready_response.h index 7f94312d045..5dcbdd46df2 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_is_ready_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_is_ready_response.h @@ -72,6 +72,6 @@ class NaviIsReadyResponse : public app_mngr::commands::ResponseFromHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_NAVI_IS_READY_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_send_location_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_send_location_request.h index 7bdf0e4787a..02068779a90 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_send_location_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_send_location_request.h @@ -72,6 +72,6 @@ class NaviSendLocationRequest : public app_mngr::commands::RequestToHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_NAVI_SEND_LOCATION_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_send_location_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_send_location_response.h index 6a65eb00a15..e322177e457 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_send_location_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_send_location_response.h @@ -72,6 +72,6 @@ class NaviSendLocationResponse : public app_mngr::commands::ResponseFromHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_NAVI_SEND_LOCATION_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_set_video_config_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_set_video_config_request.h index a981b8ff81f..437d58861c8 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_set_video_config_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_set_video_config_request.h @@ -84,6 +84,6 @@ class NaviSetVideoConfigRequest : public app_mngr::commands::RequestToHMI, } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_NAVI_SET_VIDEO_CONFIG_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_set_video_config_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_set_video_config_response.h index f5f9e7a5ee4..3cf3ca17ae0 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_set_video_config_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_set_video_config_response.h @@ -74,6 +74,6 @@ class NaviSetVideoConfigResponse : public app_mngr::commands::ResponseFromHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_NAVI_SET_VIDEO_CONFIG_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_show_constant_tbt_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_show_constant_tbt_request.h index f64bdf6ce03..efe6743d888 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_show_constant_tbt_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_show_constant_tbt_request.h @@ -73,6 +73,6 @@ class NaviShowConstantTBTRequest : public app_mngr::commands::RequestToHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_NAVI_SHOW_CONSTANT_TBT_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_show_constant_tbt_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_show_constant_tbt_response.h index fd4da08cf01..a77d2b9dbb4 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_show_constant_tbt_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_show_constant_tbt_response.h @@ -73,6 +73,6 @@ class NaviShowConstantTBTResponse : public app_mngr::commands::ResponseFromHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_NAVI_SHOW_CONSTANT_TBT_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_start_stream_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_start_stream_request.h index d5aae676617..afad744eb35 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_start_stream_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_start_stream_request.h @@ -47,10 +47,10 @@ class NaviStartStreamRequest : public app_mngr::commands::RequestToHMI, public app_mngr::event_engine::EventObserver { public: /** - * @brief NaviStartStreamRequest class constructor - * - * @param message Incoming SmartObject message - **/ + * @brief NaviStartStreamRequest class constructor + * + * @param message Incoming SmartObject message + **/ NaviStartStreamRequest(const app_mngr::commands::MessageSharedPtr& message, app_mngr::ApplicationManager& application_manager, app_mngr::rpc_service::RPCService& rpc_service, @@ -78,9 +78,9 @@ class NaviStartStreamRequest : public app_mngr::commands::RequestToHMI, virtual void onTimeOut(); /** - * @brief RetryStartSession resend HMI startSession request if needed. - * If limit expired, set video_stream_retry_number counter to 0 - */ + * @brief RetryStartSession resend HMI startSession request if needed. + * If limit expired, set video_stream_retry_number counter to 0 + */ void RetryStartSession(); private: @@ -90,6 +90,6 @@ class NaviStartStreamRequest : public app_mngr::commands::RequestToHMI, } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_NAVI_START_STREAM_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_start_stream_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_start_stream_response.h index b4770e82fe5..38d9ba905c2 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_start_stream_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_start_stream_response.h @@ -71,6 +71,6 @@ class NaviStartStreamResponse : public app_mngr::commands::ResponseFromHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_NAVI_START_STREAM_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_stop_stream_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_stop_stream_request.h index 400c61ba078..0d14d0595f9 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_stop_stream_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_stop_stream_request.h @@ -71,6 +71,6 @@ class NaviStopStreamRequest : public app_mngr::commands::RequestToHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_NAVI_STOP_STREAM_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_stop_stream_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_stop_stream_response.h index 39512ac2bb5..10b5ef0f80c 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_stop_stream_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_stop_stream_response.h @@ -71,6 +71,6 @@ class NaviStopStreamResponse : public app_mngr::commands::ResponseFromHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_NAVI_STOP_STREAM_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_subscribe_way_points_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_subscribe_way_points_request.h index 052c3c7151b..3def06ba9aa 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_subscribe_way_points_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_subscribe_way_points_request.h @@ -71,6 +71,6 @@ class NaviSubscribeWayPointsRequest : public app_mngr::commands::RequestToHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_NAVI_SUBSCRIBE_WAY_POINTS_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_subscribe_way_points_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_subscribe_way_points_response.h index 73aab4633f2..c424ae08579 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_subscribe_way_points_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_subscribe_way_points_response.h @@ -74,6 +74,6 @@ class NaviSubscribeWayPointsResponse } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_NAVI_SUBSCRIBE_WAY_POINTS_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_unsubscribe_way_points_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_unsubscribe_way_points_request.h index f20386a2464..be1ccbb45b3 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_unsubscribe_way_points_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_unsubscribe_way_points_request.h @@ -72,6 +72,6 @@ class NaviUnsubscribeWayPointsRequest } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_NAVI_UNSUBSCRIBE_WAY_POINTS_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_unsubscribe_way_points_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_unsubscribe_way_points_response.h index ec4f4eb9631..d4f98a871cd 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_unsubscribe_way_points_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_unsubscribe_way_points_response.h @@ -74,5 +74,5 @@ class NaviUnsubscribeWayPointsResponse } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_NAVI_UNSUBSCRIBE_WAY_POINTS_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_update_turn_list_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_update_turn_list_request.h index db269a65d30..a80d111dae7 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_update_turn_list_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_update_turn_list_request.h @@ -72,6 +72,6 @@ class NaviUpdateTurnListRequest : public app_mngr::commands::RequestToHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_NAVI_UPDATE_TURN_LIST_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_update_turn_list_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_update_turn_list_response.h index 20295485a38..8f715ac33d3 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_update_turn_list_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_update_turn_list_response.h @@ -73,6 +73,6 @@ class NaviUpdateTurnListResponse : public app_mngr::commands::ResponseFromHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_NAVI_UPDATE_TURN_LIST_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_allow_sdl_functionality_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_allow_sdl_functionality_notification.h index 42bf877f2d2..3f9d0966252 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_allow_sdl_functionality_notification.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_allow_sdl_functionality_notification.h @@ -74,6 +74,6 @@ class OnAllowSDLFunctionalityNotification } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_ALLOW_SDL_FUNCTIONALITY_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_app_activated_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_app_activated_notification.h index cc21d699fb0..f856ce966e2 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_app_activated_notification.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_app_activated_notification.h @@ -74,6 +74,6 @@ class OnAppActivatedNotification } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_APP_ACTIVATED_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_app_deactivated_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_app_deactivated_notification.h index 9b4a6ba5a05..6a7fd006325 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_app_deactivated_notification.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_app_deactivated_notification.h @@ -74,6 +74,6 @@ class OnAppDeactivatedNotification } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_APP_DEACTIVATED_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_app_permission_changed_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_app_permission_changed_notification.h index 6008a8ce51a..afed4bfa394 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_app_permission_changed_notification.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_app_permission_changed_notification.h @@ -74,6 +74,6 @@ class OnAppPermissionChangedNotification } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_APP_PERMISSION_CHANGED_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_app_permission_consent_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_app_permission_consent_notification.h index a751b25d85b..1f06e38ccd7 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_app_permission_consent_notification.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_app_permission_consent_notification.h @@ -74,6 +74,6 @@ class OnAppPermissionConsentNotification } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_APP_PERMISSION_CONSENT_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_app_registered_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_app_registered_notification.h index 3548786d1d7..00c75d2c23a 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_app_registered_notification.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_app_registered_notification.h @@ -74,6 +74,6 @@ class OnAppRegisteredNotification } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_APP_REGISTERED_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_app_unregistered_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_app_unregistered_notification.h index 097eb1eb280..791374f6f4d 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_app_unregistered_notification.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_app_unregistered_notification.h @@ -64,13 +64,13 @@ class OnAppUnregisteredNotification ~OnAppUnregisteredNotification() FINAL; /** - * @brief Init overrides and skips replacement of app id with hmi id since - * 1) at the moment this notification is being sent there is no application - * registered in application manager - * 2) hmi id is already used whenever this message is being constructed, so - * its already there - * @return True in any case - */ + * @brief Init overrides and skips replacement of app id with hmi id since + * 1) at the moment this notification is being sent there is no application + * registered in application manager + * 2) hmi id is already used whenever this message is being constructed, so + * its already there + * @return True in any case + */ bool Init() FINAL; /** @@ -84,6 +84,6 @@ class OnAppUnregisteredNotification } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_APP_UNREGISTERED_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_audio_data_streaming_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_audio_data_streaming_notification.h index cac306f7608..8f51a822a21 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_audio_data_streaming_notification.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_audio_data_streaming_notification.h @@ -74,6 +74,6 @@ class OnAudioDataStreamingNotification } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_AUDIO_DATA_STREAMING_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_bc_system_capability_updated_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_bc_system_capability_updated_notification.h index 17f8a5b3c80..0e956e86880 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_bc_system_capability_updated_notification.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_bc_system_capability_updated_notification.h @@ -74,6 +74,6 @@ class OnBCSystemCapabilityUpdatedNotification } // namespace commands -} // namespace app_service_rpc_plugin +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_BC_SYSTEM_CAPABILITY_UPDATED_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_bc_system_capability_updated_notification_from_hmi.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_bc_system_capability_updated_notification_from_hmi.h new file mode 100644 index 00000000000..39b5c3aee39 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_bc_system_capability_updated_notification_from_hmi.h @@ -0,0 +1,97 @@ +/* + * Copyright (c) 2019, Ford Motor Company + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following + * disclaimer in the documentation and/or other materials provided with the + * distribution. + * + * Neither the name of the Ford Motor Company nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_BC_SYSTEM_CAPABILITY_UPDATED_NOTIFICATION_FROM_HMI_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_BC_SYSTEM_CAPABILITY_UPDATED_NOTIFICATION_FROM_HMI_H_ + +#include "application_manager/commands/notification_from_hmi.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief OnBCSystemCapabilityUpdatedNotificationFromHMI command class + **/ +class OnBCSystemCapabilityUpdatedNotificationFromHMI + : public app_mngr::commands::NotificationFromHMI { + public: + /** + * @brief OnBCSystemCapabilityUpdatedNotificationFromHMI class constructor + * @param message Incoming SmartObject message from HMI + * @note all parameters described below required for base class + * @param application_manager Application manager instance to interact with + * related application + * @param rpc_service - service to handle appropriate RPC + * @param hmi_capabilities - HMI capabilities + * @param policy_handle - instance which allows interaction between + * application manager and application policies + **/ + OnBCSystemCapabilityUpdatedNotificationFromHMI( + const app_mngr::commands::MessageSharedPtr& message, + app_mngr::ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle); + + /** + * @brief OnBCSystemCapabilityUpdatedNotificationFromHMI class destructor + **/ + ~OnBCSystemCapabilityUpdatedNotificationFromHMI() FINAL; + + void Run() FINAL; + + private: + enum ProcessSystemDisplayCapabilitiesResult { + SUCCESS, + FAIL, + CAPABILITIES_CACHED + }; + /** + * @brief ProcessSystemDisplayCapabilities processes provided display + * capabilities according to its structure + * @param display_capabilities display capabilities to process + * @return true if display capabilities have been processed properly, + * otherwise returns false + */ + ProcessSystemDisplayCapabilitiesResult ProcessSystemDisplayCapabilities( + const smart_objects::SmartObject& display_capabilities); + + DISALLOW_COPY_AND_ASSIGN(OnBCSystemCapabilityUpdatedNotificationFromHMI); +}; + +} // namespace commands + +} // namespace sdl_rpc_plugin + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_BC_SYSTEM_CAPABILITY_UPDATED_NOTIFICATION_FROM_HMI_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_button_event_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_button_event_notification.h index b83fe1bfe06..955249bd4be 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_button_event_notification.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_button_event_notification.h @@ -74,6 +74,6 @@ class OnButtonEventNotification } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_BUTTON_EVENT_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_button_press_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_button_press_notification.h index e996c9952cf..9de86d1d9c2 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_button_press_notification.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_button_press_notification.h @@ -74,6 +74,6 @@ class OnButtonPressNotification } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_BUTTON_PRESS_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_button_subscription_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_button_subscription_notification.h index 4ed60f9a07a..0a0a8c3c5d4 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_button_subscription_notification.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_button_subscription_notification.h @@ -78,6 +78,6 @@ class OnButtonSubscriptionNotification } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_BUTTON_SUBSCRIPTION_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_device_chosen_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_device_chosen_notification.h index 99c165c12ff..7fe0b2a8c3a 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_device_chosen_notification.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_device_chosen_notification.h @@ -74,6 +74,6 @@ class OnDeviceChosenNotification } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_DEVICE_CHOSEN_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_device_state_changed_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_device_state_changed_notification.h index 7701e2a6012..df1efb4d309 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_device_state_changed_notification.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_device_state_changed_notification.h @@ -74,6 +74,6 @@ class OnDeviceStateChangedNotification } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_DEVICE_STATE_CHANGED_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_driver_distraction_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_driver_distraction_notification.h index 51fb49c6bc7..df8dd3d4018 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_driver_distraction_notification.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_driver_distraction_notification.h @@ -80,6 +80,6 @@ class OnDriverDistractionNotification } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_DRIVER_DISTRACTION_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_event_changed_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_event_changed_notification.h index cff0a0e617d..4fcde5f7d0b 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_event_changed_notification.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_event_changed_notification.h @@ -74,6 +74,6 @@ class OnEventChangedNotification } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_EVENT_CHANGED_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_exit_all_applications_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_exit_all_applications_notification.h index 116932d87a9..dbbbe925fea 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_exit_all_applications_notification.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_exit_all_applications_notification.h @@ -79,6 +79,6 @@ class OnExitAllApplicationsNotification } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_EXIT_ALL_APPLICATIONS_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_exit_application_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_exit_application_notification.h index 11c397bfe7c..403642f64d1 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_exit_application_notification.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_exit_application_notification.h @@ -74,6 +74,6 @@ class OnExitApplicationNotification } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_EXIT_APPLICATION_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_file_removed_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_file_removed_notification.h index 38c5dcf5357..7658017364c 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_file_removed_notification.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_file_removed_notification.h @@ -72,6 +72,6 @@ class OnFileRemovedNotification : public app_mngr::commands::NotificationToHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_FILE_REMOVED_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_find_applications.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_find_applications.h index 672ded9dcf3..bf3a9d530e2 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_find_applications.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_find_applications.h @@ -72,6 +72,6 @@ class OnFindApplications : public app_mngr::commands::NotificationFromHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_FIND_APPLICATIONS_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_ignition_cycle_over_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_ignition_cycle_over_notification.h index 85b7ed356e8..d215b3d07d4 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_ignition_cycle_over_notification.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_ignition_cycle_over_notification.h @@ -33,8 +33,8 @@ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_IGNITION_CYCLE_OVER_NOTIFICATION_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_IGNITION_CYCLE_OVER_NOTIFICATION_H_ -#include "application_manager/commands/notification_from_hmi.h" #include "application_manager/application_impl.h" +#include "application_manager/commands/notification_from_hmi.h" namespace sdl_rpc_plugin { namespace app_mngr = application_manager; @@ -75,6 +75,6 @@ class OnIgnitionCycleOverNotification } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_IGNITION_CYCLE_OVER_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_navi_tbt_client_state_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_navi_tbt_client_state_notification.h index 075dc2cb5c2..a07af99df16 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_navi_tbt_client_state_notification.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_navi_tbt_client_state_notification.h @@ -33,8 +33,8 @@ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_NAVI_TBT_CLIENT_STATE_NOTIFICATION_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_NAVI_TBT_CLIENT_STATE_NOTIFICATION_H_ -#include "application_manager/commands/notification_from_hmi.h" #include "application_manager/application_manager.h" +#include "application_manager/commands/notification_from_hmi.h" namespace sdl_rpc_plugin { namespace app_mngr = application_manager; @@ -75,6 +75,6 @@ class OnNaviTBTClientStateNotification } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_NAVI_TBT_CLIENT_STATE_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_navi_way_point_change_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_navi_way_point_change_notification.h index 3efde9c8c1b..74058e246cf 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_navi_way_point_change_notification.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_navi_way_point_change_notification.h @@ -33,8 +33,8 @@ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_NAVI_WAY_POINT_CHANGE_NOTIFICATION_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_NAVI_WAY_POINT_CHANGE_NOTIFICATION_H_ -#include "application_manager/commands/notification_from_hmi.h" #include "application_manager/application_manager.h" +#include "application_manager/commands/notification_from_hmi.h" namespace sdl_rpc_plugin { namespace app_mngr = application_manager; @@ -75,5 +75,5 @@ class OnNaviWayPointChangeNotification } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_NAVI_WAY_POINT_CHANGE_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_policy_update.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_policy_update.h index 331e3527954..ede78dd3629 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_policy_update.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_policy_update.h @@ -66,6 +66,6 @@ class OnPolicyUpdate : public app_mngr::commands::NotificationFromHMI { DISALLOW_COPY_AND_ASSIGN(OnPolicyUpdate); }; } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_POLICY_UPDATE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_put_file_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_put_file_notification.h index 503013ff58d..e64edd51bc9 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_put_file_notification.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_put_file_notification.h @@ -33,8 +33,8 @@ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_PUT_FILE_NOTIFICATION_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_PUT_FILE_NOTIFICATION_H_ -#include "application_manager/commands/notification_to_hmi.h" #include "application_manager/application_impl.h" +#include "application_manager/commands/notification_to_hmi.h" namespace sdl_rpc_plugin { namespace app_mngr = application_manager; @@ -73,6 +73,6 @@ class OnPutFileNotification : public app_mngr::commands::NotificationToHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_PUT_FILE_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_ready_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_ready_notification.h index c4adc200904..f540abbf4a0 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_ready_notification.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_ready_notification.h @@ -33,8 +33,8 @@ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_READY_NOTIFICATION_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_READY_NOTIFICATION_H_ -#include "application_manager/commands/notification_from_hmi.h" #include "application_manager/application_manager.h" +#include "application_manager/commands/notification_from_hmi.h" namespace sdl_rpc_plugin { namespace app_mngr = application_manager; @@ -73,6 +73,6 @@ class OnReadyNotification : public app_mngr::commands::NotificationFromHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_READY_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_received_policy_update.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_received_policy_update.h index c1e1b01a18e..1ffe038a82d 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_received_policy_update.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_received_policy_update.h @@ -43,10 +43,10 @@ namespace commands { class OnReceivedPolicyUpdate : public app_mngr::commands::NotificationFromHMI { public: /** - * @brief OnReceivedPolicyUpdate class constructor - * - * @param message Incoming SmartObject message - **/ + * @brief OnReceivedPolicyUpdate class constructor + * + * @param message Incoming SmartObject message + **/ OnReceivedPolicyUpdate(const app_mngr::commands::MessageSharedPtr& message, app_mngr::ApplicationManager& application_manager, app_mngr::rpc_service::RPCService& rpc_service, @@ -69,6 +69,6 @@ class OnReceivedPolicyUpdate : public app_mngr::commands::NotificationFromHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_RECEIVED_POLICY_UPDATE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_record_start_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_record_start_notification.h index c5755a364c3..68cc5ca4877 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_record_start_notification.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_record_start_notification.h @@ -74,6 +74,6 @@ class OnRecordStartdNotification } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_RECORD_START_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_resume_audio_source_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_resume_audio_source_notification.h index ef2b5a34eb7..63ea6597471 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_resume_audio_source_notification.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_resume_audio_source_notification.h @@ -33,8 +33,8 @@ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_RESUME_AUDIO_SOURCE_NOTIFICATION_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_RESUME_AUDIO_SOURCE_NOTIFICATION_H_ -#include "application_manager/commands/notification_to_hmi.h" #include "application_manager/application_impl.h" +#include "application_manager/commands/notification_to_hmi.h" namespace sdl_rpc_plugin { namespace app_mngr = application_manager; @@ -75,6 +75,6 @@ class OnResumeAudioSourceNotification } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_RESUME_AUDIO_SOURCE_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_sdl_close_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_sdl_close_notification.h index 34fe41de81c..a40872b5788 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_sdl_close_notification.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_sdl_close_notification.h @@ -72,6 +72,6 @@ class OnSDLCloseNotification : public app_mngr::commands::NotificationToHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_SDL_CLOSE_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_sdl_consent_needed_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_sdl_consent_needed_notification.h index 9fe736a5950..00bc6c9a052 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_sdl_consent_needed_notification.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_sdl_consent_needed_notification.h @@ -74,6 +74,6 @@ class OnSDLConsentNeededNotification } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_SDL_CONSENT_NEEDED_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_sdl_persistence_complete_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_sdl_persistence_complete_notification.h index 96f63845e1a..6ae9aee1f52 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_sdl_persistence_complete_notification.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_sdl_persistence_complete_notification.h @@ -74,6 +74,6 @@ class OnSDLPersistenceCompleteNotification } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_SDL_PERSISTENCE_COMPLETE_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_service_update_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_service_update_notification.h new file mode 100644 index 00000000000..bfa9b6e6aef --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_service_update_notification.h @@ -0,0 +1,82 @@ +/* + * Copyright (c) 2019, Ford Motor Company + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following + * disclaimer in the documentation and/or other materials provided with the + * distribution. + * + * Neither the name of the Ford Motor Company nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_SERVICE_UPDATE_NOTIFICATION_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_SERVICE_UPDATE_NOTIFICATION_H_ + +#include "application_manager/commands/notification_to_hmi.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { +namespace hmi { + +/** + * @brief OnServiceUpdateNotification command class + **/ +class OnServiceUpdateNotification + : public app_mngr::commands::NotificationToHMI { + public: + /** + * @brief OnServiceUpdateNotification class constructor + * @param application_manager ref to application manager + * @param rpc_service ref to rpc service + * @param hmi_capabilities ref to HMI capabilities + * @param policy_handle ref to policy handler + **/ + OnServiceUpdateNotification( + const app_mngr::commands::MessageSharedPtr& message, + app_mngr::ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handler); + + /** + * @brief OnServiceUpdateNotification class destructor + **/ + virtual ~OnServiceUpdateNotification() OVERRIDE; + + /** + * @brief Execute command + **/ + void Run() OVERRIDE; + + private: + DISALLOW_COPY_AND_ASSIGN(OnServiceUpdateNotification); +}; + +} // namespace hmi +} // namespace commands +} // namespace sdl_rpc_plugin + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_SERVICE_UPDATE_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_start_device_discovery.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_start_device_discovery.h index da049b1dc4f..38bb1db03e3 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_start_device_discovery.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_start_device_discovery.h @@ -72,6 +72,6 @@ class OnStartDeviceDiscovery : public app_mngr::commands::NotificationFromHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_START_DEVICE_DISCOVERY_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_status_update_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_status_update_notification.h index 7c61fac0416..7a6e8b871ae 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_status_update_notification.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_status_update_notification.h @@ -74,6 +74,6 @@ class OnStatusUpdateNotification } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_STATUS_UPDATE_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_system_context_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_system_context_notification.h index d4c940bac7d..a2392030533 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_system_context_notification.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_system_context_notification.h @@ -33,8 +33,8 @@ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_SYSTEM_CONTEXT_NOTIFICATION_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_SYSTEM_CONTEXT_NOTIFICATION_H_ -#include "application_manager/commands/notification_from_hmi.h" #include "application_manager/application.h" +#include "application_manager/commands/notification_from_hmi.h" namespace sdl_rpc_plugin { namespace app_mngr = application_manager; @@ -76,6 +76,6 @@ class OnSystemContextNotification } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_SYSTEM_CONTEXT_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_system_error_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_system_error_notification.h index 76325b078f0..3993eefd8bd 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_system_error_notification.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_system_error_notification.h @@ -73,6 +73,6 @@ class OnSystemErrorNotification } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_SYSTEM_ERROR_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_system_info_changed_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_system_info_changed_notification.h index 1e4046b83b5..a5ab6364643 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_system_info_changed_notification.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_system_info_changed_notification.h @@ -74,6 +74,6 @@ class OnSystemInfoChangedNotification } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_SYSTEM_INFO_CHANGED_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_system_request_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_system_request_notification.h index 1e1e1818b8b..6f9f63b517c 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_system_request_notification.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_system_request_notification.h @@ -33,8 +33,8 @@ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_SYSTEM_REQUEST_NOTIFICATION_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_SYSTEM_REQUEST_NOTIFICATION_H_ -#include "application_manager/commands/notification_from_hmi.h" #include "application_manager/application_impl.h" +#include "application_manager/commands/notification_from_hmi.h" namespace sdl_rpc_plugin { namespace app_mngr = application_manager; @@ -75,6 +75,6 @@ class OnSystemRequestNotification } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_SYSTEM_REQUEST_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_system_time_ready_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_system_time_ready_notification.h index 7cd8410d8e1..799af1e134c 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_system_time_ready_notification.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_system_time_ready_notification.h @@ -33,8 +33,8 @@ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_SYSTEM_TIME_READY_NOTIFICATION_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_SYSTEM_TIME_READY_NOTIFICATION_H_ -#include "application_manager/commands/notification_from_hmi.h" #include "application_manager/application_manager.h" +#include "application_manager/commands/notification_from_hmi.h" namespace sdl_rpc_plugin { namespace app_mngr = application_manager; diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_tts_language_change_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_tts_language_change_notification.h index 33c7d98b6f8..0462925f71f 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_tts_language_change_notification.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_tts_language_change_notification.h @@ -74,6 +74,6 @@ class OnTTSLanguageChangeNotification } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_TTS_LANGUAGE_CHANGE_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_tts_reset_timeout_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_tts_reset_timeout_notification.h index 70050a667ed..c8bd1590641 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_tts_reset_timeout_notification.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_tts_reset_timeout_notification.h @@ -78,6 +78,6 @@ class OnTTSResetTimeoutNotification } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_TTS_RESET_TIMEOUT_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_tts_started_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_tts_started_notification.h index 93dac3f2928..315acf3a5f9 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_tts_started_notification.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_tts_started_notification.h @@ -73,6 +73,6 @@ class OnTTSStartedNotification } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_TTS_STARTED_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_tts_stopped_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_tts_stopped_notification.h index 362e96f4be1..0dafd61c589 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_tts_stopped_notification.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_tts_stopped_notification.h @@ -73,6 +73,6 @@ class OnTTSStoppedNotification } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_TTS_STOPPED_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_ui_command_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_ui_command_notification.h index 0cc4e9e7727..f468ce5b0a7 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_ui_command_notification.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_ui_command_notification.h @@ -72,6 +72,6 @@ class OnUICommandNotification : public app_mngr::commands::NotificationFromHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_UI_COMMAND_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_ui_keyboard_input_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_ui_keyboard_input_notification.h index c4878947701..31b7eef3a31 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_ui_keyboard_input_notification.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_ui_keyboard_input_notification.h @@ -33,8 +33,8 @@ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_UI_KEYBOARD_INPUT_NOTIFICATION_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_UI_KEYBOARD_INPUT_NOTIFICATION_H_ -#include "application_manager/commands/notification_from_hmi.h" #include "application_manager/application_manager.h" +#include "application_manager/commands/notification_from_hmi.h" namespace sdl_rpc_plugin { namespace app_mngr = application_manager; @@ -79,6 +79,6 @@ class OnUIKeyBoardInputNotification } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_UI_KEYBOARD_INPUT_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_ui_language_change_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_ui_language_change_notification.h index f30b8573aa9..2495aa2b965 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_ui_language_change_notification.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_ui_language_change_notification.h @@ -74,6 +74,6 @@ class OnUILanguageChangeNotification } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_UI_LANGUAGE_CHANGE_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_ui_reset_timeout_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_ui_reset_timeout_notification.h index bbdf4d04efb..1c87f82349c 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_ui_reset_timeout_notification.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_ui_reset_timeout_notification.h @@ -78,6 +78,6 @@ class OnUIResetTimeoutNotification } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_UI_RESET_TIMEOUT_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_ui_touch_event_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_ui_touch_event_notification.h index 5c7dd0128be..26c25f437a3 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_ui_touch_event_notification.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_ui_touch_event_notification.h @@ -33,8 +33,8 @@ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_UI_TOUCH_EVENT_NOTIFICATION_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_UI_TOUCH_EVENT_NOTIFICATION_H_ -#include "application_manager/commands/notification_from_hmi.h" #include "application_manager/application_manager.h" +#include "application_manager/commands/notification_from_hmi.h" namespace sdl_rpc_plugin { namespace app_mngr = application_manager; @@ -79,6 +79,6 @@ class OnUITouchEventNotification } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_UI_TOUCH_EVENT_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_update_device_list.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_update_device_list.h index 2942c360530..d638629b3a8 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_update_device_list.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_update_device_list.h @@ -72,6 +72,6 @@ class OnUpdateDeviceList : public app_mngr::commands::NotificationFromHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_UPDATE_DEVICE_LIST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_acc_pedal_position_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_acc_pedal_position_notification.h index ed0b1572ffb..c848233497f 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_acc_pedal_position_notification.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_acc_pedal_position_notification.h @@ -33,8 +33,8 @@ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_VI_ACC_PEDAL_POSITION_NOTIFICATION_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_VI_ACC_PEDAL_POSITION_NOTIFICATION_H_ -#include "application_manager/commands/notification_from_hmi.h" #include "application_manager/application_manager.h" +#include "application_manager/commands/notification_from_hmi.h" namespace sdl_rpc_plugin { namespace app_mngr = application_manager; @@ -75,6 +75,6 @@ class OnVIAccPedalPositionNotification } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_VI_ACC_PEDAL_POSITION_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_belt_status_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_belt_status_notification.h index cc81160ccb2..0cb3e04f4eb 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_belt_status_notification.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_belt_status_notification.h @@ -33,8 +33,8 @@ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_VI_BELT_STATUS_NOTIFICATION_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_VI_BELT_STATUS_NOTIFICATION_H_ -#include "application_manager/commands/notification_from_hmi.h" #include "application_manager/application_manager.h" +#include "application_manager/commands/notification_from_hmi.h" namespace sdl_rpc_plugin { namespace app_mngr = application_manager; @@ -75,6 +75,6 @@ class OnVIBeltStatusNotification } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_VI_BELT_STATUS_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_body_information_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_body_information_notification.h index 2b46b69f553..6ab920204db 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_body_information_notification.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_body_information_notification.h @@ -33,8 +33,8 @@ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_VI_BODY_INFORMATION_NOTIFICATION_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_VI_BODY_INFORMATION_NOTIFICATION_H_ -#include "application_manager/commands/notification_from_hmi.h" #include "application_manager/application_manager.h" +#include "application_manager/commands/notification_from_hmi.h" namespace sdl_rpc_plugin { namespace app_mngr = application_manager; @@ -75,6 +75,6 @@ class OnVIBodyInformationNotification } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_VI_BODY_INFORMATION_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_device_status_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_device_status_notification.h index 05da9a775d0..b3afeb82b32 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_device_status_notification.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_device_status_notification.h @@ -33,8 +33,8 @@ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_VI_DEVICE_STATUS_NOTIFICATION_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_VI_DEVICE_STATUS_NOTIFICATION_H_ -#include "application_manager/commands/notification_from_hmi.h" #include "application_manager/application_manager.h" +#include "application_manager/commands/notification_from_hmi.h" namespace sdl_rpc_plugin { namespace app_mngr = application_manager; @@ -75,6 +75,6 @@ class OnVIDeviceStatusNotification } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_VI_DEVICE_STATUS_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_driver_braking_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_driver_braking_notification.h index 6640d7953ac..a1885c5e294 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_driver_braking_notification.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_driver_braking_notification.h @@ -33,8 +33,8 @@ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_VI_DRIVER_BRAKING_NOTIFICATION_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_VI_DRIVER_BRAKING_NOTIFICATION_H_ -#include "application_manager/commands/notification_from_hmi.h" #include "application_manager/application_manager.h" +#include "application_manager/commands/notification_from_hmi.h" namespace sdl_rpc_plugin { namespace app_mngr = application_manager; @@ -75,6 +75,6 @@ class OnVIDriverBrakingNotification } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_VI_DRIVER_BRAKING_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_engine_torque_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_engine_torque_notification.h index f8c0526f8c7..feb6cc60602 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_engine_torque_notification.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_engine_torque_notification.h @@ -33,8 +33,8 @@ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_VI_ENGINE_TORQUE_NOTIFICATION_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_VI_ENGINE_TORQUE_NOTIFICATION_H_ -#include "application_manager/commands/notification_from_hmi.h" #include "application_manager/application_manager.h" +#include "application_manager/commands/notification_from_hmi.h" namespace sdl_rpc_plugin { namespace app_mngr = application_manager; @@ -75,6 +75,6 @@ class OnVIEngineTorqueNotification } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_VI_ENGINE_TORQUE_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_external_temperature_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_external_temperature_notification.h index 900aecd845d..734420aaee8 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_external_temperature_notification.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_external_temperature_notification.h @@ -33,8 +33,8 @@ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_VI_EXTERNAL_TEMPERATURE_NOTIFICATION_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_VI_EXTERNAL_TEMPERATURE_NOTIFICATION_H_ -#include "application_manager/commands/notification_from_hmi.h" #include "application_manager/application_manager.h" +#include "application_manager/commands/notification_from_hmi.h" namespace sdl_rpc_plugin { namespace app_mngr = application_manager; @@ -75,6 +75,6 @@ class OnVIExternalTemperatureNotification } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_VI_EXTERNAL_TEMPERATURE_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_fuel_level_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_fuel_level_notification.h index 7374de9ad9c..a5588901f72 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_fuel_level_notification.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_fuel_level_notification.h @@ -33,8 +33,8 @@ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_VI_FUEL_LEVEL_NOTIFICATION_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_VI_FUEL_LEVEL_NOTIFICATION_H_ -#include "application_manager/commands/notification_from_hmi.h" #include "application_manager/application_manager.h" +#include "application_manager/commands/notification_from_hmi.h" namespace sdl_rpc_plugin { namespace app_mngr = application_manager; @@ -74,6 +74,6 @@ class OnVIFuelLevelNotification } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_VI_FUEL_LEVEL_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_fuel_level_state_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_fuel_level_state_notification.h index a705fcbd046..5ed661cdbf7 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_fuel_level_state_notification.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_fuel_level_state_notification.h @@ -33,8 +33,8 @@ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_VI_FUEL_LEVEL_STATE_NOTIFICATION_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_VI_FUEL_LEVEL_STATE_NOTIFICATION_H_ -#include "application_manager/commands/notification_from_hmi.h" #include "application_manager/application_manager.h" +#include "application_manager/commands/notification_from_hmi.h" namespace sdl_rpc_plugin { namespace app_mngr = application_manager; @@ -75,6 +75,6 @@ class OnVIFuelLevelStateNotification } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_VI_FUEL_LEVEL_STATE_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_gps_data_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_gps_data_notification.h index 984e1e4c0be..70ee5f6c008 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_gps_data_notification.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_gps_data_notification.h @@ -33,8 +33,8 @@ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_VI_GPS_DATA_NOTIFICATION_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_VI_GPS_DATA_NOTIFICATION_H_ -#include "application_manager/commands/notification_from_hmi.h" #include "application_manager/application_manager.h" +#include "application_manager/commands/notification_from_hmi.h" namespace sdl_rpc_plugin { namespace app_mngr = application_manager; @@ -73,6 +73,6 @@ class OnVIGpsDataNotification : public app_mngr::commands::NotificationFromHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_VI_GPS_DATA_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_head_lamp_status_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_head_lamp_status_notification.h index 1dfda8a9e01..5ef1e3ed927 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_head_lamp_status_notification.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_head_lamp_status_notification.h @@ -33,8 +33,8 @@ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_VI_HEAD_LAMP_STATUS_NOTIFICATION_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_VI_HEAD_LAMP_STATUS_NOTIFICATION_H_ -#include "application_manager/commands/notification_from_hmi.h" #include "application_manager/application_manager.h" +#include "application_manager/commands/notification_from_hmi.h" namespace sdl_rpc_plugin { namespace app_mngr = application_manager; @@ -75,6 +75,6 @@ class OnVIHeadLampStatusNotification } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_VI_HEAD_LAMP_STATUS_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_instant_fuel_consumption_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_instant_fuel_consumption_notification.h index fd8743907cc..7bb7756fc57 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_instant_fuel_consumption_notification.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_instant_fuel_consumption_notification.h @@ -33,8 +33,8 @@ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_VI_INSTANT_FUEL_CONSUMPTION_NOTIFICATION_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_VI_INSTANT_FUEL_CONSUMPTION_NOTIFICATION_H_ -#include "application_manager/commands/notification_from_hmi.h" #include "application_manager/application_manager.h" +#include "application_manager/commands/notification_from_hmi.h" namespace sdl_rpc_plugin { namespace app_mngr = application_manager; @@ -75,6 +75,6 @@ class OnVIInstantFuelConsumptionNotification } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_VI_INSTANT_FUEL_CONSUMPTION_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_my_key_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_my_key_notification.h index 25ace2821d0..cdebc99768a 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_my_key_notification.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_my_key_notification.h @@ -33,8 +33,8 @@ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_VI_MY_KEY_NOTIFICATION_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_VI_MY_KEY_NOTIFICATION_H_ -#include "application_manager/commands/notification_from_hmi.h" #include "application_manager/application_manager.h" +#include "application_manager/commands/notification_from_hmi.h" namespace sdl_rpc_plugin { namespace app_mngr = application_manager; @@ -73,6 +73,6 @@ class OnVIMyKeyNotification : public app_mngr::commands::NotificationFromHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_VI_MY_KEY_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_odometer_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_odometer_notification.h index ad141e733c3..1da26dd3160 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_odometer_notification.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_odometer_notification.h @@ -33,8 +33,8 @@ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_VI_ODOMETER_NOTIFICATION_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_VI_ODOMETER_NOTIFICATION_H_ -#include "application_manager/commands/notification_from_hmi.h" #include "application_manager/application_manager.h" +#include "application_manager/commands/notification_from_hmi.h" namespace sdl_rpc_plugin { namespace app_mngr = application_manager; @@ -74,6 +74,6 @@ class OnVIOdometerNotification } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_VI_ODOMETER_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_prndl_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_prndl_notification.h index 95fb8739575..7d03c626337 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_prndl_notification.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_prndl_notification.h @@ -33,8 +33,8 @@ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_VI_PRNDL_NOTIFICATION_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_VI_PRNDL_NOTIFICATION_H_ -#include "application_manager/commands/notification_from_hmi.h" #include "application_manager/application_manager.h" +#include "application_manager/commands/notification_from_hmi.h" namespace sdl_rpc_plugin { namespace app_mngr = application_manager; @@ -73,6 +73,6 @@ class OnVIPrndlNotification : public app_mngr::commands::NotificationFromHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_VI_PRNDL_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_rpm_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_rpm_notification.h index d4b121a96fa..60a0ce0782a 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_rpm_notification.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_rpm_notification.h @@ -33,8 +33,8 @@ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_VI_RPM_NOTIFICATION_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_VI_RPM_NOTIFICATION_H_ -#include "application_manager/commands/notification_from_hmi.h" #include "application_manager/application_manager.h" +#include "application_manager/commands/notification_from_hmi.h" namespace sdl_rpc_plugin { namespace app_mngr = application_manager; @@ -73,6 +73,6 @@ class OnVIRpmNotification : public app_mngr::commands::NotificationFromHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_VI_RPM_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_speed_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_speed_notification.h index 4afaafc9ff0..4920fbd6612 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_speed_notification.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_speed_notification.h @@ -33,8 +33,8 @@ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_VI_SPEED_NOTIFICATION_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_VI_SPEED_NOTIFICATION_H_ -#include "application_manager/commands/notification_from_hmi.h" #include "application_manager/application_manager.h" +#include "application_manager/commands/notification_from_hmi.h" namespace sdl_rpc_plugin { namespace app_mngr = application_manager; @@ -73,6 +73,6 @@ class OnVISpeedNotification : public app_mngr::commands::NotificationFromHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_VI_SPEED_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_steering_wheel_angle_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_steering_wheel_angle_notification.h index 0d0aeadad88..cff99ecf8e5 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_steering_wheel_angle_notification.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_steering_wheel_angle_notification.h @@ -33,8 +33,8 @@ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_VI_STEERING_WHEEL_ANGLE_NOTIFICATION_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_VI_STEERING_WHEEL_ANGLE_NOTIFICATION_H_ -#include "application_manager/commands/notification_from_hmi.h" #include "application_manager/application_manager.h" +#include "application_manager/commands/notification_from_hmi.h" namespace sdl_rpc_plugin { namespace app_mngr = application_manager; @@ -75,6 +75,6 @@ class OnVISteeringWheelAngleNotification } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_VI_STEERING_WHEEL_ANGLE_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_tire_pressure_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_tire_pressure_notification.h index c358ed37e93..03997808691 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_tire_pressure_notification.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_tire_pressure_notification.h @@ -33,8 +33,8 @@ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_VI_TIRE_PRESSURE_NOTIFICATION_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_VI_TIRE_PRESSURE_NOTIFICATION_H_ -#include "application_manager/commands/notification_from_hmi.h" #include "application_manager/application_manager.h" +#include "application_manager/commands/notification_from_hmi.h" namespace sdl_rpc_plugin { namespace app_mngr = application_manager; @@ -75,6 +75,6 @@ class OnVITirePressureNotification } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_VI_TIRE_PRESSURE_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_vin_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_vin_notification.h index 75062a51e15..60b686683f5 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_vin_notification.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_vin_notification.h @@ -33,8 +33,8 @@ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_VI_VIN_NOTIFICATION_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_VI_VIN_NOTIFICATION_H_ -#include "application_manager/commands/notification_from_hmi.h" #include "application_manager/application_manager.h" +#include "application_manager/commands/notification_from_hmi.h" namespace sdl_rpc_plugin { namespace app_mngr = application_manager; @@ -73,6 +73,6 @@ class OnVIVinNotification : public app_mngr::commands::NotificationFromHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_VI_VIN_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_wiper_status_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_wiper_status_notification.h index de7a5dfc9e8..a6e1ba99214 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_wiper_status_notification.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_wiper_status_notification.h @@ -33,8 +33,8 @@ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_VI_WIPER_STATUS_NOTIFICATION_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_VI_WIPER_STATUS_NOTIFICATION_H_ -#include "application_manager/commands/notification_from_hmi.h" #include "application_manager/application_manager.h" +#include "application_manager/commands/notification_from_hmi.h" namespace sdl_rpc_plugin { namespace app_mngr = application_manager; @@ -75,6 +75,6 @@ class OnVIWiperStatusNotification } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_VI_WIPER_STATUS_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_video_data_streaming_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_video_data_streaming_notification.h index 7a7cf3cd96d..6d6d4a69dbb 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_video_data_streaming_notification.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_video_data_streaming_notification.h @@ -74,6 +74,6 @@ class OnVideoDataStreamingNotification } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_VIDEO_DATA_STREAMING_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vr_command_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vr_command_notification.h index 3ef21fc5683..58ea2e07b56 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vr_command_notification.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vr_command_notification.h @@ -33,8 +33,8 @@ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_VR_COMMAND_NOTIFICATION_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_VR_COMMAND_NOTIFICATION_H_ -#include "application_manager/commands/notification_from_hmi.h" #include "application_manager/application_impl.h" +#include "application_manager/commands/notification_from_hmi.h" namespace sdl_rpc_plugin { namespace app_mngr = application_manager; @@ -73,6 +73,6 @@ class OnVRCommandNotification : public app_mngr::commands::NotificationFromHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_VR_COMMAND_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vr_language_change_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vr_language_change_notification.h index e6bd39d46e4..f583d1e2fe2 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vr_language_change_notification.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vr_language_change_notification.h @@ -74,6 +74,6 @@ class OnVRLanguageChangeNotification } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_VR_LANGUAGE_CHANGE_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vr_started_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vr_started_notification.h index abca9db91d4..98ed40101b7 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vr_started_notification.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vr_started_notification.h @@ -72,6 +72,6 @@ class OnVRStartedNotification : public app_mngr::commands::NotificationFromHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_VR_STARTED_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vr_stopped_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vr_stopped_notification.h index 9b53214f8f7..e16b440da7a 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vr_stopped_notification.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vr_stopped_notification.h @@ -72,6 +72,6 @@ class OnVRStoppedNotification : public app_mngr::commands::NotificationFromHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_VR_STOPPED_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/rc_get_capabilities_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/rc_get_capabilities_request.h index 8f94d4876a8..57a90955f42 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/rc_get_capabilities_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/rc_get_capabilities_request.h @@ -72,6 +72,6 @@ class RCGetCapabilitiesRequest : public app_mngr::commands::RequestToHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_RC_GET_CAPABILITIES_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/rc_get_capabilities_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/rc_get_capabilities_response.h index dec31c9ea1e..e0c305f7966 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/rc_get_capabilities_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/rc_get_capabilities_response.h @@ -72,6 +72,6 @@ class RCGetCapabilitiesResponse : public app_mngr::commands::ResponseFromHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_RC_GET_CAPABILITIES_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/rc_is_ready_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/rc_is_ready_request.h index 3ba614f823f..305a866659b 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/rc_is_ready_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/rc_is_ready_request.h @@ -89,6 +89,6 @@ class RCIsReadyRequest : public app_mngr::commands::RequestToHMI, } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_RC_IS_READY_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/rc_is_ready_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/rc_is_ready_response.h index 93f30e795c8..5f4af235279 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/rc_is_ready_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/rc_is_ready_response.h @@ -72,6 +72,6 @@ class RCIsReadyResponse : public app_mngr::commands::ResponseFromHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_RC_IS_READY_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/sdl_activate_app_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/sdl_activate_app_request.h index e97312b8818..27511044863 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/sdl_activate_app_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/sdl_activate_app_request.h @@ -33,8 +33,8 @@ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_SDL_ACTIVATE_APP_REQUEST_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_SDL_ACTIVATE_APP_REQUEST_H_ -#include "application_manager/commands/request_from_hmi.h" #include "application_manager/application_manager.h" +#include "application_manager/commands/request_from_hmi.h" namespace sdl_rpc_plugin { namespace app_mngr = application_manager; @@ -109,6 +109,6 @@ class SDLActivateAppRequest : public app_mngr::commands::RequestFromHMI { }; } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_SDL_ACTIVATE_APP_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/sdl_activate_app_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/sdl_activate_app_response.h index 7a3f5157da7..fd8b885e887 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/sdl_activate_app_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/sdl_activate_app_response.h @@ -71,6 +71,6 @@ class SDLActivateAppResponse : public app_mngr::commands::ResponseToHMI { }; } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_SDL_ACTIVATE_APP_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/sdl_get_list_of_permissions_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/sdl_get_list_of_permissions_request.h index 61426e0af37..acf390cfbcf 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/sdl_get_list_of_permissions_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/sdl_get_list_of_permissions_request.h @@ -73,6 +73,6 @@ class SDLGetListOfPermissionsRequest }; } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_SDL_GET_LIST_OF_PERMISSIONS_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/sdl_get_list_of_permissions_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/sdl_get_list_of_permissions_response.h index e2556bac3d1..4fc1775c721 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/sdl_get_list_of_permissions_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/sdl_get_list_of_permissions_response.h @@ -74,6 +74,6 @@ class SDLGetListOfPermissionsResponse } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_SDL_GET_LIST_OF_PERMISSIONS_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/get_urls.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/sdl_get_policy_configuration_data_request.h similarity index 59% rename from src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/get_urls.h rename to src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/sdl_get_policy_configuration_data_request.h index 93b414c8c49..043a4369c5a 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/get_urls.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/sdl_get_policy_configuration_data_request.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Ford Motor Company + * Copyright (c) 2019, Ford Motor Company * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -30,36 +30,38 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_GET_URLS_H_ -#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_GET_URLS_H_ +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_SDL_GET_POLICY_CONFIGURATION_DATA_REQUEST_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_SDL_GET_POLICY_CONFIGURATION_DATA_REQUEST_H_ #include "application_manager/commands/request_from_hmi.h" -#include "policy/policy_types.h" -#include "smart_objects/smart_object.h" namespace sdl_rpc_plugin { namespace app_mngr = application_manager; + namespace commands { + /** - * @brief GetUrls command class + * @brief SDLGetPolicyConfigurationDataRequest command class **/ -class GetUrls : public app_mngr::commands::RequestFromHMI { +class SDLGetPolicyConfigurationDataRequest + : public app_mngr::commands::RequestFromHMI { public: /** - * @brief GetUrls class constructor + * @brief SDLGetPolicyConfigurationDataRequest class constructor * * @param message Incoming SmartObject message **/ - GetUrls(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); + SDLGetPolicyConfigurationDataRequest( + const app_mngr::commands::MessageSharedPtr& message, + app_mngr::ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle); /** - * @brief GetUrls class destructor + * @brief SDLGetPolicyConfigurationDataRequest class destructor **/ - virtual ~GetUrls(); + ~SDLGetPolicyConfigurationDataRequest() OVERRIDE; /** * @brief Execute command @@ -67,30 +69,16 @@ class GetUrls : public app_mngr::commands::RequestFromHMI { void Run() OVERRIDE; private: -#ifdef PROPRIETARY_MODE - /** - * @brief Processes URLs collecting for policy service - * @param endpoints Endpoints section of policy table - */ - void ProcessPolicyServiceURLs(const policy::EndpointUrls& endpoints); -#endif // PROPRIETARY_MODE + hmi_apis::Common_Result::eType PrepareResponseParams( + smart_objects::SmartObject& response_out) const; - /** - * @brief Process URLs collecting for service - * @param endpoints Endpoints section of policy table - */ - void ProcessServiceURLs(const policy::EndpointUrls& endpoints); - - /** - * @brief Sends response to HMI - * @param result Result code - */ - void SendResponseToHMI(hmi_apis::Common_Result::eType result); + smart_objects::SmartObject GetValueParam( + const Json::Value& policy_property) const; - DISALLOW_COPY_AND_ASSIGN(GetUrls); + DISALLOW_COPY_AND_ASSIGN(SDLGetPolicyConfigurationDataRequest); }; } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin -#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_GET_URLS_H_ +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_SDL_GET_POLICY_CONFIGURATION_DATA_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/sdl_get_policy_configuration_data_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/sdl_get_policy_configuration_data_response.h new file mode 100644 index 00000000000..2c22f692816 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/sdl_get_policy_configuration_data_response.h @@ -0,0 +1,78 @@ +/* + * Copyright (c) 2019, Ford Motor Company + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following + * disclaimer in the documentation and/or other materials provided with the + * distribution. + * + * Neither the name of the Ford Motor Company nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_SDL_GET_POLICY_CONFIGURATION_DATA_RESPONSE_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_SDL_GET_POLICY_CONFIGURATION_DATA_RESPONSE_H_ + +#include "application_manager/commands/response_to_hmi.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief SDLGetPolicyConfigurationDataResponse command class + **/ +class SDLGetPolicyConfigurationDataResponse + : public app_mngr::commands::ResponseToHMI { + public: + /** + * @brief SDLGetPolicyConfigurationDataResponse class constructor + * + * @param message Incoming SmartObject message + **/ + SDLGetPolicyConfigurationDataResponse( + const app_mngr::commands::MessageSharedPtr& message, + app_mngr::ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle); + + /** + * @brief SDLGetPolicyConfigurationDataResponse class destructor + **/ + virtual ~SDLGetPolicyConfigurationDataResponse(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(SDLGetPolicyConfigurationDataResponse); +}; + +} // namespace commands +} // namespace sdl_rpc_plugin + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_SDL_GET_POLICY_CONFIGURATION_DATA_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/sdl_get_status_update_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/sdl_get_status_update_request.h index b6376bacc67..fae0b6480db 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/sdl_get_status_update_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/sdl_get_status_update_request.h @@ -71,6 +71,6 @@ class SDLGetStatusUpdateRequest : public app_mngr::commands::RequestFromHMI { }; } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_SDL_GET_STATUS_UPDATE_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/sdl_get_status_update_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/sdl_get_status_update_response.h index 4e6da223706..1c10142c99c 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/sdl_get_status_update_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/sdl_get_status_update_response.h @@ -72,6 +72,6 @@ class SDLGetStatusUpdateResponse : public app_mngr::commands::ResponseToHMI { }; } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_SDL_GET_STATUS_UPDATE_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/sdl_get_user_friendly_message_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/sdl_get_user_friendly_message_request.h index 75902e27330..18ad1fa5356 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/sdl_get_user_friendly_message_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/sdl_get_user_friendly_message_request.h @@ -33,8 +33,8 @@ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_SDL_GET_USER_FRIENDLY_MESSAGE_REQUEST_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_SDL_GET_USER_FRIENDLY_MESSAGE_REQUEST_H_ -#include "application_manager/commands/request_from_hmi.h" #include "application_manager/application_manager.h" +#include "application_manager/commands/request_from_hmi.h" namespace sdl_rpc_plugin { namespace app_mngr = application_manager; @@ -74,6 +74,6 @@ class SDLGetUserFriendlyMessageRequest }; } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_SDL_GET_USER_FRIENDLY_MESSAGE_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/sdl_get_user_friendly_message_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/sdl_get_user_friendly_message_response.h index a02d6894e3b..101a13b218c 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/sdl_get_user_friendly_message_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/sdl_get_user_friendly_message_response.h @@ -74,6 +74,6 @@ class SDLGetUserFriendlyMessageResponse } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_SDL_GET_USER_FRIENDLY_MESSAGE_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/sdl_policy_update.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/sdl_policy_update.h index f164aed7758..e330e847b0e 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/sdl_policy_update.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/sdl_policy_update.h @@ -43,10 +43,10 @@ namespace commands { class SDLPolicyUpdate : public app_mngr::commands::RequestToHMI { public: /** - * @brief SDLPolicyUpdate class constructor - * - * @param message Incoming SmartObject message - **/ + * @brief SDLPolicyUpdate class constructor + * + * @param message Incoming SmartObject message + **/ SDLPolicyUpdate(const app_mngr::commands::MessageSharedPtr& message, app_mngr::ApplicationManager& application_manager, app_mngr::rpc_service::RPCService& rpc_service, @@ -66,6 +66,6 @@ class SDLPolicyUpdate : public app_mngr::commands::RequestToHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_SDL_POLICY_UPDATE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/sdl_policy_update_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/sdl_policy_update_response.h index 63f33477b6c..ce7125f251e 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/sdl_policy_update_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/sdl_policy_update_response.h @@ -69,6 +69,6 @@ class SDLPolicyUpdateResponse : public app_mngr::commands::ResponseFromHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_SDL_POLICY_UPDATE_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/tts_change_registration_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/tts_change_registration_request.h index 229ed929472..0905e90b451 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/tts_change_registration_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/tts_change_registration_request.h @@ -73,6 +73,6 @@ class TTSChangeRegistrationRequest : public app_mngr::commands::RequestToHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_TTS_CHANGE_REGISTRATION_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/tts_change_registration_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/tts_change_registration_response.h index 84621782831..1988a7ee626 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/tts_change_registration_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/tts_change_registration_response.h @@ -74,6 +74,6 @@ class TTSChangeRegistratioResponse } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_TTS_CHANGE_REGISTRATION_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/tts_get_capabilities_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/tts_get_capabilities_request.h index df6cf3b4a4f..d636485915c 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/tts_get_capabilities_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/tts_get_capabilities_request.h @@ -72,6 +72,6 @@ class TTSGetCapabilitiesRequest : public app_mngr::commands::RequestToHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_TTS_GET_CAPABILITIES_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/tts_get_capabilities_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/tts_get_capabilities_response.h index 7919f213a4f..5c9b60e2f84 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/tts_get_capabilities_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/tts_get_capabilities_response.h @@ -73,6 +73,6 @@ class TTSGetCapabilitiesResponse : public app_mngr::commands::ResponseFromHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_TTS_GET_CAPABILITIES_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/tts_get_language_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/tts_get_language_request.h index 09345c02d7d..73ef8c52343 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/tts_get_language_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/tts_get_language_request.h @@ -72,6 +72,6 @@ class TTSGetLanguageRequest : public app_mngr::commands::RequestToHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_TTS_GET_LANGUAGE_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/tts_get_language_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/tts_get_language_response.h index e52dbf1ada0..b29b3e73140 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/tts_get_language_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/tts_get_language_response.h @@ -72,6 +72,6 @@ class TTSGetLanguageResponse : public app_mngr::commands::ResponseFromHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_TTS_GET_LANGUAGE_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/tts_get_supported_languages_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/tts_get_supported_languages_request.h index c42d0257d3a..a24a6446b32 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/tts_get_supported_languages_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/tts_get_supported_languages_request.h @@ -74,6 +74,6 @@ class TTSGetSupportedLanguagesRequest } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_TTS_GET_SUPPORTED_LANGUAGES_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/tts_get_supported_languages_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/tts_get_supported_languages_response.h index cc24db22b99..25850de5f23 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/tts_get_supported_languages_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/tts_get_supported_languages_response.h @@ -74,6 +74,6 @@ class TTSGetSupportedLanguagesResponse } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_TTS_GET_SUPPORTED_LANGUAGES_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/tts_is_ready_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/tts_is_ready_request.h index b7dffd5bde2..dd360eeb4a7 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/tts_is_ready_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/tts_is_ready_request.h @@ -88,6 +88,6 @@ class TTSIsReadyRequest : public app_mngr::commands::RequestToHMI, } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_TTS_IS_READY_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/tts_is_ready_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/tts_is_ready_response.h index 268edd0eeb1..881cd981794 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/tts_is_ready_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/tts_is_ready_response.h @@ -72,6 +72,6 @@ class TTSIsReadyResponse : public app_mngr::commands::ResponseFromHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_TTS_IS_READY_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/tts_set_global_properties_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/tts_set_global_properties_request.h index f416b3a7879..009ee8f0bec 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/tts_set_global_properties_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/tts_set_global_properties_request.h @@ -73,6 +73,6 @@ class TTSSetGlobalPropertiesRequest : public app_mngr::commands::RequestToHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_TTS_SET_GLOBAL_PROPERTIES_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/tts_set_global_properties_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/tts_set_global_properties_response.h index ff5622296cc..d7ac422e574 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/tts_set_global_properties_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/tts_set_global_properties_response.h @@ -74,6 +74,6 @@ class TTSSetGlobalPropertiesResponse } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_TTS_SET_GLOBAL_PROPERTIES_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/tts_speak_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/tts_speak_request.h index 9e8915a440e..efb67243fa3 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/tts_speak_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/tts_speak_request.h @@ -72,6 +72,6 @@ class TTSSpeakRequest : public app_mngr::commands::RequestToHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_TTS_SPEAK_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/tts_speak_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/tts_speak_response.h index e4b2c8adbd0..d516a9df1e4 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/tts_speak_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/tts_speak_response.h @@ -72,6 +72,6 @@ class TTSSpeakResponse : public app_mngr::commands::ResponseFromHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_TTS_SPEAK_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/tts_stop_speaking_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/tts_stop_speaking_request.h index 8eb6a66c952..f3ce24d9281 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/tts_stop_speaking_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/tts_stop_speaking_request.h @@ -72,6 +72,6 @@ class TTSStopSpeakingRequest : public app_mngr::commands::RequestToHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_TTS_STOP_SPEAKING_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/tts_stop_speaking_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/tts_stop_speaking_response.h index d433fe22806..6399193ae66 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/tts_stop_speaking_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/tts_stop_speaking_response.h @@ -72,6 +72,6 @@ class TTSStopSpeakingResponse : public app_mngr::commands::ResponseFromHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_TTS_STOP_SPEAKING_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_add_command_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_add_command_request.h index e5d2483576d..2d1e84fbec3 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_add_command_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_add_command_request.h @@ -72,6 +72,6 @@ class UIAddCommandRequest : public app_mngr::commands::RequestToHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_ADD_COMMAND_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_add_command_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_add_command_response.h index 90a9666561a..cf693685519 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_add_command_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_add_command_response.h @@ -72,6 +72,6 @@ class UIAddCommandResponse : public app_mngr::commands::ResponseFromHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_ADD_COMMAND_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_add_submenu_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_add_submenu_request.h index 5de5e41cd63..0cd120b3cda 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_add_submenu_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_add_submenu_request.h @@ -72,6 +72,6 @@ class UIAddSubmenuRequest : public app_mngr::commands::RequestToHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_ADD_SUBMENU_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_add_submenu_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_add_submenu_response.h index 20f830be278..5e951600bd9 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_add_submenu_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_add_submenu_response.h @@ -72,6 +72,6 @@ class UIAddSubmenuResponse : public app_mngr::commands::ResponseFromHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_ADD_SUBMENU_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_alert_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_alert_request.h index 6235a51c7d5..3c0423e35e8 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_alert_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_alert_request.h @@ -72,6 +72,6 @@ class UIAlertRequest : public app_mngr::commands::RequestToHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_ALERT_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_alert_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_alert_response.h index b43185af784..0392da0c7be 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_alert_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_alert_response.h @@ -72,6 +72,6 @@ class UIAlertResponse : public app_mngr::commands::ResponseFromHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_ALERT_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_cancel_interaction_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_cancel_interaction_request.h new file mode 100644 index 00000000000..a637f53df30 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_cancel_interaction_request.h @@ -0,0 +1,79 @@ +/* + * Copyright (c) 2019, Ford Motor Company + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following + * disclaimer in the documentation and/or other materials provided with the + * distribution. + * + * Neither the name of the Ford Motor Company nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_CANCEL_INTERACTION_REQUEST_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_CANCEL_INTERACTION_REQUEST_H_ + +#include "application_manager/commands/request_to_hmi.h" +#include "sdl_rpc_plugin/sdl_rpc_plugin.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief UICancelInteractionRequest command class + **/ +class UICancelInteractionRequest : public app_mngr::commands::RequestToHMI { + public: + /** + * @brief UICancelInteractionRequest class constructor + * + * @param message Incoming SmartObject message + **/ + UICancelInteractionRequest( + const app_mngr::commands::MessageSharedPtr& message, + app_mngr::ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle); + + /** + * @brief UICancelInteractionRequest class destructor + **/ + virtual ~UICancelInteractionRequest(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(UICancelInteractionRequest); +}; + +} // namespace commands + +} // namespace sdl_rpc_plugin + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_CANCEL_INTERACTION_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_cancel_interaction_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_cancel_interaction_response.h new file mode 100644 index 00000000000..751a2ceef84 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_cancel_interaction_response.h @@ -0,0 +1,78 @@ +/* + * Copyright (c) 2019, Ford Motor Company + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following + * disclaimer in the documentation and/or other materials provided with the + * distribution. + * + * Neither the name of the Ford Motor Company nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_CANCEL_INTERACTION_RESPONSE_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_CANCEL_INTERACTION_RESPONSE_H_ + +#include "application_manager/commands/response_from_hmi.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief UICancelInteractionResponse command class + **/ +class UICancelInteractionResponse : public app_mngr::commands::ResponseFromHMI { + public: + /** + * @brief UICancelInteractionResponse class constructor + * + * @param message Incoming SmartObject message + **/ + UICancelInteractionResponse( + const app_mngr::commands::MessageSharedPtr& message, + app_mngr::ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle); + + /** + * @brief UICancelInteractionResponse class destructor + **/ + virtual ~UICancelInteractionResponse(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(UICancelInteractionResponse); +}; + +} // namespace commands + +} // namespace sdl_rpc_plugin + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_CANCEL_INTERACTION_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_change_registration_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_change_registration_request.h index c504c55727f..44440bf49d4 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_change_registration_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_change_registration_request.h @@ -73,6 +73,6 @@ class UIChangeRegistrationRequest : public app_mngr::commands::RequestToHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_CHANGE_REGISTRATION_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_change_registration_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_change_registration_response.h index d7fca83d3e6..e0077744a1a 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_change_registration_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_change_registration_response.h @@ -73,6 +73,6 @@ class UIChangeRegistratioResponse : public app_mngr::commands::ResponseFromHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_CHANGE_REGISTRATION_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_create_window_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_create_window_request.h new file mode 100644 index 00000000000..6fe8e182c4a --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_create_window_request.h @@ -0,0 +1,66 @@ +/* + * Copyright (c) 2019, Ford Motor Company + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following + * disclaimer in the documentation and/or other materials provided with the + * distribution. + * + * Neither the name of the Ford Motor Company nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_CREATE_WINDOW_REQUEST_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_CREATE_WINDOW_REQUEST_H_ + +#include "application_manager/commands/request_to_hmi.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief UI.CreateWindow request command class + **/ +class UICreateWindowRequest : public app_mngr::commands::RequestToHMI { + public: + UICreateWindowRequest(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); + + ~UICreateWindowRequest() FINAL; + + void Run() FINAL; + + private: + DISALLOW_COPY_AND_ASSIGN(UICreateWindowRequest); +}; + +} // namespace commands + +} // namespace sdl_rpc_plugin + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_CREATE_WINDOW_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_create_window_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_create_window_response.h new file mode 100644 index 00000000000..b9452fce1fd --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_create_window_response.h @@ -0,0 +1,66 @@ +/* + * Copyright (c) 2019, Ford Motor Company + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following + * disclaimer in the documentation and/or other materials provided with the + * distribution. + * + * Neither the name of the Ford Motor Company nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_CREATE_WINDOW_RESPONSE_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_CREATE_WINDOW_RESPONSE_H_ + +#include "application_manager/commands/response_from_hmi.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief UI.CreateWindow response command class + **/ +class UICreateWindowResponse : public app_mngr::commands::ResponseFromHMI { + public: + UICreateWindowResponse(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); + + ~UICreateWindowResponse() FINAL; + + void Run() FINAL; + + private: + DISALLOW_COPY_AND_ASSIGN(UICreateWindowResponse); +}; + +} // namespace commands + +} // namespace sdl_rpc_plugin + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_CREATE_WINDOW_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_delete_command_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_delete_command_request.h index ecc0b44495d..4af8b917934 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_delete_command_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_delete_command_request.h @@ -72,6 +72,6 @@ class UIDeleteCommandRequest : public app_mngr::commands::RequestToHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_DELETE_COMMAND_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_delete_command_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_delete_command_response.h index f9601b74916..1eda0d362a7 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_delete_command_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_delete_command_response.h @@ -72,6 +72,6 @@ class UIDeleteCommandResponse : public app_mngr::commands::ResponseFromHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_DELETE_COMMAND_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_delete_submenu_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_delete_submenu_request.h index 3161c84b7c8..9a7cd97ec70 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_delete_submenu_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_delete_submenu_request.h @@ -72,6 +72,6 @@ class UIDeleteSubmenuRequest : public app_mngr::commands::RequestToHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_DELETE_SUBMENU_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_delete_submenu_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_delete_submenu_response.h index 7c73a53c3e0..3edb8489e08 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_delete_submenu_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_delete_submenu_response.h @@ -72,6 +72,6 @@ class UIDeleteSubmenuResponse : public app_mngr::commands::ResponseFromHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_DELETE_SUBMENU_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_delete_window_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_delete_window_request.h new file mode 100644 index 00000000000..58b2c3989fb --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_delete_window_request.h @@ -0,0 +1,66 @@ +/* + * Copyright (c) 2019, Ford Motor Company + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following + * disclaimer in the documentation and/or other materials provided with the + * distribution. + * + * Neither the name of the Ford Motor Company nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_DELETE_WINDOW_REQUEST_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_DELETE_WINDOW_REQUEST_H_ + +#include "application_manager/commands/request_to_hmi.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief UI.DeleteWindow request command class + **/ +class UIDeleteWindowRequest : public app_mngr::commands::RequestToHMI { + public: + UIDeleteWindowRequest(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); + + ~UIDeleteWindowRequest() FINAL; + + void Run() FINAL; + + private: + DISALLOW_COPY_AND_ASSIGN(UIDeleteWindowRequest); +}; + +} // namespace commands + +} // namespace sdl_rpc_plugin + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_DELETE_WINDOW_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_delete_window_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_delete_window_response.h new file mode 100644 index 00000000000..1500a3f9b28 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_delete_window_response.h @@ -0,0 +1,66 @@ +/* + * Copyright (c) 2019, Ford Motor Company + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following + * disclaimer in the documentation and/or other materials provided with the + * distribution. + * + * Neither the name of the Ford Motor Company nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_DELETE_WINDOW_RESPONSE_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_DELETE_WINDOW_RESPONSE_H_ + +#include "application_manager/commands/response_from_hmi.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief UI.DeleteWindow response command class + **/ +class UIDeleteWindowResponse : public app_mngr::commands::ResponseFromHMI { + public: + UIDeleteWindowResponse(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); + + ~UIDeleteWindowResponse() FINAL; + + void Run() FINAL; + + private: + DISALLOW_COPY_AND_ASSIGN(UIDeleteWindowResponse); +}; + +} // namespace commands + +} // namespace sdl_rpc_plugin + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_DELETE_WINDOW_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_end_audio_pass_thru_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_end_audio_pass_thru_request.h index 8d34e1852be..90bf6f7dbc4 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_end_audio_pass_thru_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_end_audio_pass_thru_request.h @@ -73,6 +73,6 @@ class UIEndAudioPassThruRequest : public app_mngr::commands::RequestToHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_END_AUDIO_PASS_THRU_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_end_audio_pass_thru_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_end_audio_pass_thru_response.h index b1c3bfd87a7..69a7959e534 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_end_audio_pass_thru_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_end_audio_pass_thru_response.h @@ -73,6 +73,6 @@ class UIEndAudioPassThruResponse : public app_mngr::commands::ResponseFromHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_END_AUDIO_PASS_THRU_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_get_capabilities_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_get_capabilities_request.h index 47782cc7a95..58d8d0f732b 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_get_capabilities_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_get_capabilities_request.h @@ -72,6 +72,6 @@ class UIGetCapabilitiesRequest : public app_mngr::commands::RequestToHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_GET_CAPABILITIES_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_get_capabilities_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_get_capabilities_response.h index 421844560d5..d83d5f211b4 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_get_capabilities_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_get_capabilities_response.h @@ -72,6 +72,6 @@ class UIGetCapabilitiesResponse : public app_mngr::commands::ResponseFromHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_GET_CAPABILITIES_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_get_language_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_get_language_request.h index 7c825841784..842a97a717a 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_get_language_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_get_language_request.h @@ -72,6 +72,6 @@ class UIGetLanguageRequest : public app_mngr::commands::RequestToHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_GET_LANGUAGE_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_get_language_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_get_language_response.h index 7354e87ee4d..ec02b6fde9b 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_get_language_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_get_language_response.h @@ -72,6 +72,6 @@ class UIGetLanguageResponse : public app_mngr::commands::ResponseFromHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_GET_LANGUAGE_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_get_supported_languages_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_get_supported_languages_request.h index 7fd456b92b3..42ea5553582 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_get_supported_languages_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_get_supported_languages_request.h @@ -73,6 +73,6 @@ class UIGetSupportedLanguagesRequest : public app_mngr::commands::RequestToHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_GET_SUPPORTED_LANGUAGES_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_get_supported_languages_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_get_supported_languages_response.h index 26d8e988924..45137ba5183 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_get_supported_languages_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_get_supported_languages_response.h @@ -74,6 +74,6 @@ class UIGetSupportedLanguagesResponse } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_GET_SUPPORTED_LANGUAGES_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_is_ready_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_is_ready_request.h index 2e7806cd2b8..18536032b7d 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_is_ready_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_is_ready_request.h @@ -88,6 +88,6 @@ class UIIsReadyRequest : public app_mngr::commands::RequestToHMI, } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_IS_READY_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_is_ready_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_is_ready_response.h index f2b4f201f3d..790c0115aa6 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_is_ready_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_is_ready_response.h @@ -72,6 +72,6 @@ class UIIsReadyResponse : public app_mngr::commands::ResponseFromHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_IS_READY_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_perform_audio_pass_thru_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_perform_audio_pass_thru_request.h index 6d4e870228c..be7d3845833 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_perform_audio_pass_thru_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_perform_audio_pass_thru_request.h @@ -73,6 +73,6 @@ class UIPerformAudioPassThruRequest : public app_mngr::commands::RequestToHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_PERFORM_AUDIO_PASS_THRU_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_perform_audio_pass_thru_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_perform_audio_pass_thru_response.h index e36a2925732..05f2cc84fd6 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_perform_audio_pass_thru_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_perform_audio_pass_thru_response.h @@ -74,6 +74,6 @@ class UIPerformAudioPassThruResponse } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_PERFORM_AUDIO_PASS_THRU_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_perform_interaction_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_perform_interaction_request.h index ff4540de23c..15cec6c17e1 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_perform_interaction_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_perform_interaction_request.h @@ -73,6 +73,6 @@ class UIPerformInteractionRequest : public app_mngr::commands::RequestToHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_PERFORM_INTERACTION_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_perform_interaction_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_perform_interaction_response.h index caf5716e185..2d13e15ad2d 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_perform_interaction_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_perform_interaction_response.h @@ -74,6 +74,6 @@ class UIPerformInteractionResponse } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_PERFORM_INTERACTION_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_scrollable_message_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_scrollable_message_request.h index f5acf41c8d4..bc25259662f 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_scrollable_message_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_scrollable_message_request.h @@ -73,6 +73,6 @@ class UIScrollableMessageRequest : public app_mngr::commands::RequestToHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_SCROLLABLE_MESSAGE_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_scrollable_message_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_scrollable_message_response.h index e46265c0e46..f7f92600cdb 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_scrollable_message_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_scrollable_message_response.h @@ -73,6 +73,6 @@ class UIScrollableMessageResponse : public app_mngr::commands::ResponseFromHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_SCROLLABLE_MESSAGE_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_send_haptic_data_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_send_haptic_data_request.h index 4e260a99ff9..56ffe40c21c 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_send_haptic_data_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_send_haptic_data_request.h @@ -73,6 +73,6 @@ class UISendHapticDataRequest : public app_mngr::commands::RequestToHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_SEND_HAPTIC_DATA_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_send_haptic_data_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_send_haptic_data_response.h index 1bf38939bee..439c2f2682c 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_send_haptic_data_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_send_haptic_data_response.h @@ -73,6 +73,6 @@ class UISendHapticDataResponse : public app_mngr::commands::ResponseFromHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_SEND_HAPTIC_DATA_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_set_app_icon_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_set_app_icon_request.h index ea526df1350..a7d07628e3b 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_set_app_icon_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_set_app_icon_request.h @@ -72,6 +72,6 @@ class UISetAppIconRequest : public app_mngr::commands::RequestToHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_SET_APP_ICON_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_set_app_icon_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_set_app_icon_response.h index af2c4fafea1..3e4b338439f 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_set_app_icon_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_set_app_icon_response.h @@ -72,6 +72,6 @@ class UISetAppIconResponse : public app_mngr::commands::ResponseFromHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_SET_APP_ICON_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_set_display_layout_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_set_display_layout_request.h index f60f7325fd7..446b77b997d 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_set_display_layout_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_set_display_layout_request.h @@ -71,6 +71,6 @@ class UiSetDisplayLayoutRequest : public app_mngr::commands::RequestToHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_SET_DISPLAY_LAYOUT_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_set_display_layout_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_set_display_layout_response.h index ce404a40498..ade6aa1c13d 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_set_display_layout_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_set_display_layout_response.h @@ -73,6 +73,6 @@ class UiSetDisplayLayoutResponse : public app_mngr::commands::ResponseFromHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_SET_DISPLAY_LAYOUT_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_set_global_properties_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_set_global_properties_request.h index 44e8bba4506..8df60a318a7 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_set_global_properties_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_set_global_properties_request.h @@ -73,6 +73,6 @@ class UISetGlobalPropertiesRequest : public app_mngr::commands::RequestToHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_SET_GLOBAL_PROPERTIES_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_set_global_properties_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_set_global_properties_response.h index a9c27a423b5..a189093fc73 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_set_global_properties_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_set_global_properties_response.h @@ -74,6 +74,6 @@ class UISetGlobalPropertiesResponse } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_SET_GLOBAL_PROPERTIES_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_set_media_clock_timer_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_set_media_clock_timer_request.h index 24f4d76d897..b1b196a25ff 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_set_media_clock_timer_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_set_media_clock_timer_request.h @@ -73,6 +73,6 @@ class UISetMediaClockTimerRequest : public app_mngr::commands::RequestToHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_SET_MEDIA_CLOCK_TIMER_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_set_media_clock_timer_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_set_media_clock_timer_response.h index c664bd04f94..23b6d3aefa7 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_set_media_clock_timer_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_set_media_clock_timer_response.h @@ -74,6 +74,6 @@ class UISetMediaClockTimerResponse } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_SET_MEDIA_CLOCK_TIMER_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/get_urls_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_show_app_menu_request.h similarity index 66% rename from src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/get_urls_response.h rename to src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_show_app_menu_request.h index 1ff38194b87..c47d73b8585 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/get_urls_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_show_app_menu_request.h @@ -30,43 +30,45 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_GET_URLS_RESPONSE_H_ -#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_GET_URLS_RESPONSE_H_ +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_SHOW_APP_MENU_REQUEST_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_SHOW_APP_MENU_REQUEST_H_ -#include "application_manager/commands/response_to_hmi.h" +#include "application_manager/commands/request_to_hmi.h" namespace sdl_rpc_plugin { namespace app_mngr = application_manager; + namespace commands { -class GetUrlsResponse : public app_mngr::commands::ResponseToHMI { +/** + * @brief UIShowAppMenuRequest command class + **/ +class UIShowAppMenuRequest : public app_mngr::commands::RequestToHMI { public: /** - * @brief GetUrlsResponse class constructor - * - * @param message Incoming SmartObject message + * @brief UIShowAppMenuRequest class constructor **/ - GetUrlsResponse(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); + UIShowAppMenuRequest(const app_mngr::commands::MessageSharedPtr& message, + app_mngr::ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle); /** - * @brief GetUrlsResponse class destructor + * @brief UIShowAppMenuRequest class destructor **/ - virtual ~GetUrlsResponse(); + ~UIShowAppMenuRequest() OVERRIDE; /** * @brief Execute command **/ - virtual void Run(); + void Run() OVERRIDE; private: - DISALLOW_COPY_AND_ASSIGN(GetUrlsResponse); + DISALLOW_COPY_AND_ASSIGN(UIShowAppMenuRequest); }; } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin -#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_GET_URLS_RESPONSE_H_ +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_SHOW_APP_MENU_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_show_app_menu_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_show_app_menu_response.h new file mode 100644 index 00000000000..c03a043e129 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_show_app_menu_response.h @@ -0,0 +1,74 @@ +/* + * Copyright (c) 2018, Ford Motor Company + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following + * disclaimer in the documentation and/or other materials provided with the + * distribution. + * + * Neither the name of the Ford Motor Company nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_SHOW_APP_MENU_RESPONSE_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_SHOW_APP_MENU_RESPONSE_H_ + +#include "application_manager/commands/response_from_hmi.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief UIShowAppMenuResponse command class + **/ +class UIShowAppMenuResponse : public app_mngr::commands::ResponseFromHMI { + public: + /** + * @brief UIShowAppMenuResponse class constructor + **/ + UIShowAppMenuResponse(const app_mngr::commands::MessageSharedPtr& message, + app_mngr::ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle); + + /** + * @brief UIShowAppMenuResponse class destructor + **/ + ~UIShowAppMenuResponse() OVERRIDE; + + /** + * @brief Execute command + **/ + void Run() OVERRIDE; + + private: + DISALLOW_COPY_AND_ASSIGN(UIShowAppMenuResponse); +}; + +} // namespace commands +} // namespace sdl_rpc_plugin + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_SHOW_APP_MENU_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_show_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_show_request.h index 7ba950d5303..6024243481b 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_show_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_show_request.h @@ -72,6 +72,6 @@ class UIShowRequest : public app_mngr::commands::RequestToHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_SHOW_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_show_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_show_response.h index f9f7a61056a..4d196671530 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_show_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_show_response.h @@ -72,6 +72,6 @@ class UIShowResponse : public app_mngr::commands::ResponseFromHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_SHOW_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_slider_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_slider_request.h index 3de1b4e7750..c41e02b44f7 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_slider_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_slider_request.h @@ -72,6 +72,6 @@ class UISliderRequest : public app_mngr::commands::RequestToHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_SLIDER_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_slider_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_slider_response.h index 17d1f8a8ed3..f4e44655684 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_slider_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_slider_response.h @@ -72,6 +72,6 @@ class UISliderResponse : public app_mngr::commands::ResponseFromHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_SLIDER_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/update_app_list_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/update_app_list_request.h index dc0166e33f4..b352a3b273d 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/update_app_list_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/update_app_list_request.h @@ -72,6 +72,6 @@ class UpdateAppListRequest : public app_mngr::commands::RequestToHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UPDATE_APP_LIST_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/update_app_list_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/update_app_list_response.h index 2e3bb79233a..a31621dbd53 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/update_app_list_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/update_app_list_response.h @@ -72,6 +72,6 @@ class UpdateAppListResponse : public app_mngr::commands::ResponseFromHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UPDATE_APP_LIST_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/update_device_list_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/update_device_list_request.h index c4c9f11e06f..db4f265a9fd 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/update_device_list_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/update_device_list_request.h @@ -35,8 +35,8 @@ #include "application_manager/commands/request_to_hmi.h" #include "application_manager/event_engine/event_observer.h" -#include "utils/lock.h" #include "utils/conditional_variable.h" +#include "utils/lock.h" namespace sdl_rpc_plugin { namespace app_mngr = application_manager; @@ -92,6 +92,6 @@ class UpdateDeviceListRequest : public app_mngr::commands::RequestToHMI, } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UPDATE_DEVICE_LIST_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/update_device_list_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/update_device_list_response.h index c33518a5452..5f7afed2c38 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/update_device_list_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/update_device_list_response.h @@ -72,6 +72,6 @@ class UpdateDeviceListResponse : public app_mngr::commands::ResponseFromHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UPDATE_DEVICE_LIST_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/update_sdl_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/update_sdl_request.h index e30b045fcbd..3e001b2582d 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/update_sdl_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/update_sdl_request.h @@ -33,8 +33,8 @@ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UPDATE_SDL_REQUEST_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UPDATE_SDL_REQUEST_H_ -#include "application_manager/commands/request_to_hmi.h" #include "application_manager/application_manager.h" +#include "application_manager/commands/request_to_hmi.h" namespace sdl_rpc_plugin { namespace app_mngr = application_manager; @@ -73,6 +73,6 @@ class UpdateSDLRequest : public app_mngr::commands::RequestToHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UPDATE_SDL_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/update_sdl_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/update_sdl_response.h index f71921ea3af..a6fc9178728 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/update_sdl_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/update_sdl_response.h @@ -72,6 +72,6 @@ class UpdateSDLResponse : public app_mngr::commands::ResponseFromHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UPDATE_SDL_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/vr_add_command_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/vr_add_command_request.h index 0abb37adbc6..b40245256e7 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/vr_add_command_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/vr_add_command_request.h @@ -72,6 +72,6 @@ class VRAddCommandRequest : public app_mngr::commands::RequestToHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_VR_ADD_COMMAND_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/vr_add_command_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/vr_add_command_response.h index 5f9c99a483f..dc123bc82f0 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/vr_add_command_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/vr_add_command_response.h @@ -72,6 +72,6 @@ class VRAddCommandResponse : public app_mngr::commands::ResponseFromHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_VR_ADD_COMMAND_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/vr_change_registration_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/vr_change_registration_request.h index 4af28cb5425..418842395de 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/vr_change_registration_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/vr_change_registration_request.h @@ -73,6 +73,6 @@ class VRChangeRegistrationRequest : public app_mngr::commands::RequestToHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_VR_CHANGE_REGISTRATION_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/vr_change_registration_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/vr_change_registration_response.h index a80df0968b5..08f3dfa501c 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/vr_change_registration_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/vr_change_registration_response.h @@ -74,6 +74,6 @@ class VRChangeRegistrationResponse } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_VR_CHANGE_REGISTRATION_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/vr_delete_command_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/vr_delete_command_request.h index 0ed9521ec58..2e1aa7c0d1f 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/vr_delete_command_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/vr_delete_command_request.h @@ -72,6 +72,6 @@ class VRDeleteCommandRequest : public app_mngr::commands::RequestToHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_VR_DELETE_COMMAND_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/vr_delete_command_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/vr_delete_command_response.h index 63efcab3554..a7d45ed5ea0 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/vr_delete_command_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/vr_delete_command_response.h @@ -72,6 +72,6 @@ class VRDeleteCommandResponse : public app_mngr::commands::ResponseFromHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_VR_DELETE_COMMAND_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/vr_get_capabilities_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/vr_get_capabilities_request.h index f8ac83af589..254d00452f6 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/vr_get_capabilities_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/vr_get_capabilities_request.h @@ -72,6 +72,6 @@ class VRGetCapabilitiesRequest : public app_mngr::commands::RequestToHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_VR_GET_CAPABILITIES_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/vr_get_capabilities_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/vr_get_capabilities_response.h index 9c9bb55b1b3..781e38cda22 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/vr_get_capabilities_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/vr_get_capabilities_response.h @@ -72,6 +72,6 @@ class VRGetCapabilitiesResponse : public app_mngr::commands::ResponseFromHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_VR_GET_CAPABILITIES_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/vr_get_language_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/vr_get_language_request.h index e764cbef91d..441795cfb5d 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/vr_get_language_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/vr_get_language_request.h @@ -72,6 +72,6 @@ class VRGetLanguageRequest : public app_mngr::commands::RequestToHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_VR_GET_LANGUAGE_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/vr_get_language_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/vr_get_language_response.h index 470fe3ebdc4..2bc08e5173a 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/vr_get_language_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/vr_get_language_response.h @@ -72,6 +72,6 @@ class VRGetLanguageResponse : public app_mngr::commands::ResponseFromHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_VR_GET_LANGUAGE_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/vr_get_supported_languages_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/vr_get_supported_languages_request.h index 8d9e9e2a61f..ad87415a87c 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/vr_get_supported_languages_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/vr_get_supported_languages_request.h @@ -73,6 +73,6 @@ class VRGetSupportedLanguagesRequest : public app_mngr::commands::RequestToHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_VR_GET_SUPPORTED_LANGUAGES_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/vr_get_supported_languages_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/vr_get_supported_languages_response.h index 735844cd992..16a67d64681 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/vr_get_supported_languages_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/vr_get_supported_languages_response.h @@ -74,6 +74,6 @@ class VRGetSupportedLanguagesResponse } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_VR_GET_SUPPORTED_LANGUAGES_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/vr_is_ready_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/vr_is_ready_request.h index 0b580f6c1d5..2dba80065a1 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/vr_is_ready_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/vr_is_ready_request.h @@ -89,6 +89,6 @@ class VRIsReadyRequest : public app_mngr::commands::RequestToHMI, } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_VR_IS_READY_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/vr_is_ready_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/vr_is_ready_response.h index 42c47f50772..f9011470948 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/vr_is_ready_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/vr_is_ready_response.h @@ -72,6 +72,6 @@ class VRIsReadyResponse : public app_mngr::commands::ResponseFromHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_VR_IS_READY_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/vr_perform_interaction_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/vr_perform_interaction_request.h index 6f206c010f4..8cbd2e346e8 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/vr_perform_interaction_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/vr_perform_interaction_request.h @@ -73,6 +73,6 @@ class VRPerformInteractionRequest : public app_mngr::commands::RequestToHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_VR_PERFORM_INTERACTION_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/vr_perform_interaction_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/vr_perform_interaction_response.h index 9e8599419fc..60cb4cb80c1 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/vr_perform_interaction_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/vr_perform_interaction_response.h @@ -74,6 +74,6 @@ class VRPerformInteractionResponse } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_VR_PERFORM_INTERACTION_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/add_command_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/add_command_request.h index 745fb3ec18c..8cac0d686d9 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/add_command_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/add_command_request.h @@ -164,6 +164,6 @@ class AddCommandRequest : public app_mngr::commands::CommandRequestImpl { }; } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_ADD_COMMAND_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/add_command_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/add_command_response.h index fb3f172b0bb..811bda2cc74 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/add_command_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/add_command_response.h @@ -73,6 +73,6 @@ class AddCommandResponse : public app_mngr::commands::CommandResponseImpl { }; } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_ADD_COMMAND_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/add_sub_menu_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/add_sub_menu_request.h index 37ba9a59900..d99c5dab381 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/add_sub_menu_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/add_sub_menu_request.h @@ -88,10 +88,12 @@ class AddSubMenuRequest : public app_mngr::commands::CommandRequestImpl { */ bool CheckSubMenuName(); + bool is_menu_layout_available_ = true; + DISALLOW_COPY_AND_ASSIGN(AddSubMenuRequest); }; } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_ADD_SUB_MENU_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/add_sub_menu_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/add_sub_menu_response.h index 253556f899b..ba15f04cd0d 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/add_sub_menu_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/add_sub_menu_response.h @@ -73,6 +73,6 @@ class AddSubMenuResponse : public app_mngr::commands::CommandResponseImpl { }; } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_ADD_SUB_MENU_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/alert_maneuver_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/alert_maneuver_request.h index 93f716cb65a..8b7e86fb3fd 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/alert_maneuver_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/alert_maneuver_request.h @@ -105,6 +105,6 @@ class AlertManeuverRequest : public app_mngr::commands::CommandRequestImpl { }; } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_ALERT_MANEUVER_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/alert_maneuver_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/alert_maneuver_response.h index 8b21aa64ebf..2f21fadb541 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/alert_maneuver_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/alert_maneuver_response.h @@ -73,6 +73,6 @@ class AlertManeuverResponse : public app_mngr::commands::CommandResponseImpl { }; } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_ALERT_MANEUVER_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/alert_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/alert_request.h index e34653daf4d..dfc7b73487d 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/alert_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/alert_request.h @@ -149,6 +149,6 @@ class AlertRequest : public app_mngr::commands::CommandRequestImpl { }; } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_ALERT_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/alert_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/alert_response.h index 4ae95fb9796..51de24fd41f 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/alert_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/alert_response.h @@ -73,6 +73,6 @@ class AlertResponse : public app_mngr::commands::CommandResponseImpl { }; } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_ALERT_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/cancel_interaction_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/cancel_interaction_request.h new file mode 100644 index 00000000000..0063c07512e --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/cancel_interaction_request.h @@ -0,0 +1,85 @@ +/* + Copyright (c) 2019, Ford Motor Company + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + + Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following + disclaimer in the documentation and/or other materials provided with the + distribution. + + Neither the name of the Ford Motor Company nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_CANCEL_INTERACTION_REQUEST_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_CANCEL_INTERACTION_REQUEST_H_ + +#include "application_manager/commands/command_request_impl.h" +#include "sdl_rpc_plugin/sdl_rpc_plugin.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief CancelInteractionRequest command class + **/ +class CancelInteractionRequest : public app_mngr::commands::CommandRequestImpl { + public: + /** + * @brief CancelInteractionRequest class constructor + * + * @param message Incoming SmartObject message + **/ + CancelInteractionRequest(const app_mngr::commands::MessageSharedPtr& message, + app_mngr::ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle); + + /** + * @brief CancelInteractionRequest class destructor + **/ + virtual ~CancelInteractionRequest(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + /** + * @brief Interface method that is called whenever new event received + * + * @param event The received event + */ + void on_event(const app_mngr::event_engine::Event& event); + + private: + DISALLOW_COPY_AND_ASSIGN(CancelInteractionRequest); +}; + +} // namespace commands + +} // namespace sdl_rpc_plugin + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_CANCEL_INTERACTION_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/cancel_interaction_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/cancel_interaction_response.h new file mode 100644 index 00000000000..3e8536e6172 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/cancel_interaction_response.h @@ -0,0 +1,79 @@ +/* + Copyright (c) 2019, Ford Motor Company + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + + Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following + disclaimer in the documentation and/or other materials provided with the + distribution. + + Neither the name of the Ford Motor Company nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_CANCEL_INTERACTION_RESPONSE_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_CANCEL_INTERACTION_RESPONSE_H_ + +#include "application_manager/commands/command_response_impl.h" +#include "sdl_rpc_plugin/sdl_rpc_plugin.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief CancelInteractionResponse command class + **/ +class CancelInteractionResponse + : public app_mngr::commands::CommandResponseImpl { + public: + /** + * @brief CancelInteractionResponse class constructor + * + * @param message Incoming SmartObject message + **/ + CancelInteractionResponse(const app_mngr::commands::MessageSharedPtr& message, + app_mngr::ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle); + + /** + * @brief CancelInteractionResponse class destructor + **/ + virtual ~CancelInteractionResponse(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(CancelInteractionResponse); +}; + +} // namespace commands + +} // namespace sdl_rpc_plugin + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_CANCEL_INTERACTION_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/change_registration_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/change_registration_request.h index bd5c34ebd1b..f9f780b84bc 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/change_registration_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/change_registration_request.h @@ -38,8 +38,8 @@ #include "application_manager/commands/command_request_impl.h" #include "application_manager/commands/pending.h" -#include "utils/macro.h" #include "utils/custom_string.h" +#include "utils/macro.h" namespace sdl_rpc_plugin { namespace app_mngr = application_manager; @@ -123,11 +123,12 @@ class ChangeRegistrationRequest /** * @brief Check parameters (name, vr) for * coincidence with already known parameters of registered applications - * + * @param device_id device identifier * @return SUCCESS if there is no coincidence of app.name/VR synonyms, * otherwise appropriate error code returns */ - mobile_apis::Result::eType CheckCoincidence(); + mobile_apis::Result::eType CheckCoincidence( + const connection_handler::DeviceHandle& device_id); /** * @brief Checks if requested name is allowed by policy @@ -146,11 +147,11 @@ class ChangeRegistrationRequest std::string& ResponseInfo); /** - * @brief Predicate for using with CheckCoincidence method to compare with VR - * synonym SO - * - * @return TRUE if there is coincidence of VR, otherwise FALSE - */ + * @brief Predicate for using with CheckCoincidence method to compare with VR + * synonym SO + * + * @return TRUE if there is coincidence of VR, otherwise FALSE + */ struct CoincidencePredicateVR { CoincidencePredicateVR(const custom_str::CustomString& newItem) : newItem_(newItem) {} @@ -186,6 +187,6 @@ class ChangeRegistrationRequest }; } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_CHANGE_REGISTRATION_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/change_registration_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/change_registration_response.h index 4cb8c394c7d..8c3b7f0be39 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/change_registration_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/change_registration_response.h @@ -75,6 +75,6 @@ class ChangeRegistrationResponse }; } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_CHANGE_REGISTRATION_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/close_application_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/close_application_request.h new file mode 100644 index 00000000000..b965e880b44 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/close_application_request.h @@ -0,0 +1,85 @@ +/* + Copyright (c) 2019, Ford Motor Company, Livio + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + + Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following + disclaimer in the documentation and/or other materials provided with the + distribution. + + Neither the name of the the copyright holders nor the names of their + contributors may be used to endorse or promote products derived from this + software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_CLOSE_APPLICATION_REQUEST_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_CLOSE_APPLICATION_REQUEST_H_ + +#include "application_manager/commands/command_request_impl.h" +#include "sdl_rpc_plugin/sdl_rpc_plugin.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief CloseApplicationRequest command class + **/ +class CloseApplicationRequest : public app_mngr::commands::CommandRequestImpl { + public: + /** + * @brief CloseApplicationRequest class constructor + * + * @param message Incoming SmartObject message + **/ + CloseApplicationRequest(const app_mngr::commands::MessageSharedPtr& message, + app_mngr::ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle); + + /** + * @brief CloseApplicationRequest class destructor + **/ + ~CloseApplicationRequest() OVERRIDE; + + /** + * @brief Execute command + **/ + void Run() OVERRIDE; + + /** + * @brief Interface method that is called whenever new event received + * + * @param event The received event + */ + void on_event(const app_mngr::event_engine::Event& event); + + private: + DISALLOW_COPY_AND_ASSIGN(CloseApplicationRequest); +}; + +} // namespace commands + +} // namespace sdl_rpc_plugin + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_CLOSE_APPLICATION_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/close_application_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/close_application_response.h new file mode 100644 index 00000000000..c7b649f4e97 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/close_application_response.h @@ -0,0 +1,79 @@ +/* + Copyright (c) 2019, Ford Motor Company, Livio + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + + Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following + disclaimer in the documentation and/or other materials provided with the + distribution. + + Neither the name of the the copyright holders nor the names of their + contributors may be used to endorse or promote products derived from this + software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_CLOSE_APPLICATION_RESPONSE_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_CLOSE_APPLICATION_RESPONSE_H_ + +#include "application_manager/commands/command_response_impl.h" +#include "sdl_rpc_plugin/sdl_rpc_plugin.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief CloseApplicationResponse command class + **/ +class CloseApplicationResponse + : public app_mngr::commands::CommandResponseImpl { + public: + /** + * @brief CloseApplicationResponse class constructor + * + * @param message Incoming SmartObject message + **/ + CloseApplicationResponse(const app_mngr::commands::MessageSharedPtr& message, + app_mngr::ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle); + + /** + * @brief CloseApplicationResponse class destructor + **/ + ~CloseApplicationResponse() OVERRIDE; + + /** + * @brief Execute command + **/ + void Run() OVERRIDE; + + private: + DISALLOW_COPY_AND_ASSIGN(CloseApplicationResponse); +}; + +} // namespace commands + +} // namespace sdl_rpc_plugin + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_CLOSE_APPLICATION_RESPONSE_H_ 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 1ad1c07b2a0..a1bc8663478 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 @@ -162,11 +162,11 @@ class CreateInteractionChoiceSetRequest app_mngr::ApplicationConstSharedPtr app); /* - * @brief Predicate for using with CheckChoiceSet method to compare choice ID - *param - * - * return TRUE if there is coincidence of choice ID, otherwise FALSE - */ + * @brief Predicate for using with CheckChoiceSet method to compare choice ID + *param + * + * return TRUE if there is coincidence of choice ID, otherwise FALSE + */ struct CoincidencePredicateChoiceID { CoincidencePredicateChoiceID(const uint32_t newItem) : newItem_(newItem) {} @@ -178,11 +178,11 @@ class CreateInteractionChoiceSetRequest }; /* - * @brief Predicate for using with CheckChoiceSet method to compare menu name - *param - * - * return TRUE if there is coincidence of menu name, otherwise FALSE - */ + * @brief Predicate for using with CheckChoiceSet method to compare menu name + *param + * + * return TRUE if there is coincidence of menu name, otherwise FALSE + */ struct CoincidencePredicateMenuName { CoincidencePredicateMenuName(const std::string& newItem) : newItem_(newItem) {} @@ -195,11 +195,11 @@ class CreateInteractionChoiceSetRequest }; /* - * @brief Predicate for using with CheckChoiceSet method to compare VR commands - *param - * - * return TRUE if there is coincidence of VR commands, otherwise FALSE - */ + * @brief Predicate for using with CheckChoiceSet method to compare VR + *commands param + * + * return TRUE if there is coincidence of VR commands, otherwise FALSE + */ struct CoincidencePredicateVRCommands { CoincidencePredicateVRCommands(const smart_objects::SmartObject& newItem) : newItem_(newItem) {} @@ -219,7 +219,7 @@ class CreateInteractionChoiceSetRequest * * return Return TRUE if there are similar VR synonyms in choice set, * otherwise FALSE - */ + */ bool compareSynonyms( const ns_smart_device_link::ns_smart_objects::SmartObject& choice1, const ns_smart_device_link::ns_smart_objects::SmartObject& choice2); @@ -232,7 +232,7 @@ class CreateInteractionChoiceSetRequest * * return Return TRUE if there are similar VR synonyms in choice set, * otherwise FALSE - */ + */ static bool compareStr( const ns_smart_device_link::ns_smart_objects::SmartObject& str1, const ns_smart_device_link::ns_smart_objects::SmartObject& str2); @@ -273,6 +273,6 @@ class CreateInteractionChoiceSetRequest }; } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_CREATE_INTERACTION_CHOICE_SET_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/create_interaction_choice_set_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/create_interaction_choice_set_response.h index 76718bc2c3d..0bfc0e5cdf9 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/create_interaction_choice_set_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/create_interaction_choice_set_response.h @@ -75,6 +75,6 @@ class CreateInteractionChoiceSetResponse }; } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_CREATE_INTERACTION_CHOICE_SET_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/create_window_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/create_window_request.h new file mode 100644 index 00000000000..cfbfc460b71 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/create_window_request.h @@ -0,0 +1,117 @@ +/* + Copyright (c) 2019, Ford Motor Company + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + + Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following + disclaimer in the documentation and/or other materials provided with the + distribution. + + Neither the name of the Ford Motor Company nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_CREATE_WINDOW_REQUEST_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_CREATE_WINDOW_REQUEST_H_ + +#include "application_manager/commands/command_request_impl.h" +#include "application_manager/hmi_state.h" +#include "utils/macro.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief CreateWindow request command class + **/ +class CreateWindowRequest : public app_mngr::commands::CommandRequestImpl { + public: + CreateWindowRequest(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); + + ~CreateWindowRequest() FINAL; + + app_mngr::WindowID window_id() const FINAL; + + void Run() FINAL; + + void on_event(const app_mngr::event_engine::Event& event) FINAL; + + /** + * @brief Init sets hash update mode for request + */ + bool Init() FINAL; + + private: + /** + * @brief CheckWindowName checks if provided window_name exists and allowed to + * be created + * @param app pointer to application owns affected window + * @param window_name window name to check + * @return true if window_name is valid, otherwise returns false + */ + bool CheckWindowName(app_mngr::ApplicationSharedPtr app, + const app_mngr::WindowID window_id, + const std::string& window_name) const; + + /** + * @brief ValidateWindowCreation checks whether window can be created + * @return true if window can be created, otherwise returns false + */ + bool ValidateWindowCreation(app_mngr::ApplicationSharedPtr app, + const app_mngr::WindowID window_id); + + /** + * @brief IsWindowForAssociatedServiceCreated check whether a window with + * current associated type has already been created + * @return true if window has been created, otherwise returns false + */ + bool IsWindowForAssociatedServiceCreated( + app_mngr::ApplicationSharedPtr app) const; + + /** + * @brief DoesExceedMaxAllowedWindows check wheter max allowed amount of + * windows is exceeded + * @return true if amount us exceeded, otherwise returns false + */ + bool DoesExceedMaxAllowedWindows(app_mngr::ApplicationSharedPtr app) const; + + /** + * @brief ApplyWindowInitialState apply changes related to window HMI state + * initialization + * @param app pointer to application owns affected window + */ + void ApplyWindowInitialState(app_mngr::ApplicationSharedPtr app) const; + + DISALLOW_COPY_AND_ASSIGN(CreateWindowRequest); +}; + +} // namespace commands + +} // namespace sdl_rpc_plugin + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_CREATE_WINDOW_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/create_window_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/create_window_response.h new file mode 100644 index 00000000000..5163293a7c4 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/create_window_response.h @@ -0,0 +1,67 @@ +/* + Copyright (c) 2019, Ford Motor Company + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + + Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following + disclaimer in the documentation and/or other materials provided with the + distribution. + + Neither the name of the Ford Motor Company nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_CREATE_WINDOW_RESPONSE_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_CREATE_WINDOW_RESPONSE_H_ + +#include "application_manager/commands/command_response_impl.h" +#include "utils/macro.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief CreateWindow response command class + **/ +class CreateWindowResponse : public app_mngr::commands::CommandResponseImpl { + public: + CreateWindowResponse(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); + + ~CreateWindowResponse() FINAL; + + void Run() FINAL; + + private: + DISALLOW_COPY_AND_ASSIGN(CreateWindowResponse); +}; + +} // namespace commands + +} // namespace sdl_rpc_plugin + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_CREATE_WINDOW_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/delete_command_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/delete_command_request.h index a21b1928d04..45864ca3aac 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/delete_command_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/delete_command_request.h @@ -114,6 +114,6 @@ class DeleteCommandRequest : public app_mngr::commands::CommandRequestImpl { }; } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_DELETE_COMMAND_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/delete_command_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/delete_command_response.h index f81f119792f..a91012a934d 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/delete_command_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/delete_command_response.h @@ -73,6 +73,6 @@ class DeleteCommandResponse : public app_mngr::commands::CommandResponseImpl { }; } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_DELETE_COMMAND_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/delete_file_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/delete_file_request.h index 02cd0086b61..8e4d63df4a4 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/delete_file_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/delete_file_request.h @@ -78,6 +78,6 @@ class DeleteFileRequest : public app_mngr::commands::CommandRequestImpl { }; } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_DELETE_FILE_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/delete_file_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/delete_file_response.h index fbdc70c9bcb..8fbc79ba9f1 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/delete_file_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/delete_file_response.h @@ -73,6 +73,6 @@ class DeleteFileResponse : public app_mngr::commands::CommandResponseImpl { }; } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_DELETE_FILE_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/delete_interaction_choice_set_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/delete_interaction_choice_set_request.h index 4dec11a67b9..c1d87599623 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/delete_interaction_choice_set_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/delete_interaction_choice_set_request.h @@ -34,8 +34,8 @@ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_DELETE_INTERACTION_CHOICE_SET_REQUEST_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_DELETE_INTERACTION_CHOICE_SET_REQUEST_H_ -#include "application_manager/commands/command_request_impl.h" #include "application_manager/application.h" +#include "application_manager/commands/command_request_impl.h" #include "utils/macro.h" namespace sdl_rpc_plugin { @@ -90,6 +90,6 @@ class DeleteInteractionChoiceSetRequest }; } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_DELETE_INTERACTION_CHOICE_SET_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/delete_interaction_choice_set_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/delete_interaction_choice_set_response.h index 0fce16ea9f5..bd67f9c5565 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/delete_interaction_choice_set_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/delete_interaction_choice_set_response.h @@ -75,6 +75,6 @@ class DeleteInteractionChoiceSetResponse }; } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_DELETE_INTERACTION_CHOICE_SET_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/delete_sub_menu_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/delete_sub_menu_request.h index c947fda78a1..2f85065ee71 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/delete_sub_menu_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/delete_sub_menu_request.h @@ -34,8 +34,8 @@ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_DELETE_SUB_MENU_REQUEST_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_DELETE_SUB_MENU_REQUEST_H_ -#include "application_manager/commands/command_request_impl.h" #include "application_manager/application.h" +#include "application_manager/commands/command_request_impl.h" #include "utils/macro.h" namespace sdl_rpc_plugin { @@ -104,6 +104,6 @@ class DeleteSubMenuRequest : public app_mngr::commands::CommandRequestImpl { }; } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_DELETE_SUB_MENU_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/delete_sub_menu_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/delete_sub_menu_response.h index e5b0c58a34f..c569d612585 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/delete_sub_menu_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/delete_sub_menu_response.h @@ -73,6 +73,6 @@ class DeleteSubMenuResponse : public app_mngr::commands::CommandResponseImpl { }; } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_DELETE_SUB_MENU_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/delete_window_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/delete_window_request.h new file mode 100644 index 00000000000..b837724d7bc --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/delete_window_request.h @@ -0,0 +1,91 @@ +/* + Copyright (c) 2019, Ford Motor Company + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + + Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following + disclaimer in the documentation and/or other materials provided with the + distribution. + + Neither the name of the Ford Motor Company nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_DELETE_WINDOW_REQUEST_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_DELETE_WINDOW_REQUEST_H_ + +#include "application_manager/commands/command_request_impl.h" +#include "application_manager/hmi_state.h" +#include "utils/macro.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief CreateWindow request command class + **/ +class DeleteWindowRequest : public app_mngr::commands::CommandRequestImpl { + public: + DeleteWindowRequest(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); + + ~DeleteWindowRequest() FINAL; + + void Run() FINAL; + + void on_event(const app_mngr::event_engine::Event& event) FINAL; + + app_mngr::WindowID window_id() const FINAL; + + /** + * @brief Init sets hash update mode for request + */ + bool Init() FINAL; + + private: + /** + * @brief CheckWindowId checks if provided window_id exists and allowed to be + * deleted + * @param app pointer to application owns affected window + * @return true if window_id is valid, otherwise returns false + */ + bool CheckWindowId(app_mngr::ApplicationSharedPtr app) const; + + /** + * @brief DeleteWindow deletes data related to a request window id + * @param app pointer to applications owns affected window + */ + void DeleteWindow(app_mngr::ApplicationSharedPtr app) const; + + DISALLOW_COPY_AND_ASSIGN(DeleteWindowRequest); +}; + +} // namespace commands + +} // namespace sdl_rpc_plugin + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_DELETE_WINDOW_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/delete_window_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/delete_window_response.h new file mode 100644 index 00000000000..279541724ae --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/delete_window_response.h @@ -0,0 +1,67 @@ +/* + Copyright (c) 2019, Ford Motor Company + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + + Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following + disclaimer in the documentation and/or other materials provided with the + distribution. + + Neither the name of the Ford Motor Company nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_DELETE_WINDOW_RESPONSE_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_DELETE_WINDOW_RESPONSE_H_ + +#include "application_manager/commands/command_response_impl.h" +#include "utils/macro.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief DeleteWindow response command class + **/ +class DeleteWindowResponse : public app_mngr::commands::CommandResponseImpl { + public: + DeleteWindowResponse(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); + + ~DeleteWindowResponse() FINAL; + + void Run() FINAL; + + private: + DISALLOW_COPY_AND_ASSIGN(DeleteWindowResponse); +}; + +} // namespace commands + +} // namespace sdl_rpc_plugin + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_DELETE_WINDOW_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/dial_number_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/dial_number_request.h index 3e313602c7c..750288f5e82 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/dial_number_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/dial_number_request.h @@ -61,13 +61,13 @@ class DialNumberRequest : public app_mngr::commands::CommandRequestImpl { ~DialNumberRequest() OVERRIDE; /** - * @brief Initialize request params + * @brief Initialize request params **/ bool Init() OVERRIDE; /** - * @brief Execute command - **/ + * @brief Execute command + **/ void Run() OVERRIDE; /** @@ -90,6 +90,6 @@ class DialNumberRequest : public app_mngr::commands::CommandRequestImpl { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_DIAL_NUMBER_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/dial_number_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/dial_number_response.h index 6181231458d..9c47537c6f0 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/dial_number_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/dial_number_response.h @@ -73,6 +73,6 @@ class DialNumberResponse : public app_mngr::commands::CommandResponseImpl { }; } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_DIAL_NUMBER_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/end_audio_pass_thru_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/end_audio_pass_thru_request.h index 319a20958e8..1c18de32378 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/end_audio_pass_thru_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/end_audio_pass_thru_request.h @@ -80,6 +80,6 @@ class EndAudioPassThruRequest : public app_mngr::commands::CommandRequestImpl { }; } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_END_AUDIO_PASS_THRU_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/end_audio_pass_thru_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/end_audio_pass_thru_response.h index e2a667f272e..1003d9d2d7c 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/end_audio_pass_thru_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/end_audio_pass_thru_response.h @@ -74,6 +74,6 @@ class EndAudioPassThruResponse }; } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_END_AUDIO_PASS_THRU_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/generic_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/generic_response.h index b780daaf032..6516d3cef11 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/generic_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/generic_response.h @@ -72,6 +72,6 @@ class GenericResponse : public app_mngr::commands::CommandResponseImpl { }; } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_GENERIC_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/get_system_capability_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/get_system_capability_request.h index b8da0618704..a5d1611f029 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/get_system_capability_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/get_system_capability_request.h @@ -61,7 +61,7 @@ class GetSystemCapabilityRequest DISALLOW_COPY_AND_ASSIGN(GetSystemCapabilityRequest); }; // GetSystemCapabilityRequest -} // commands -} // application_manager +} // namespace commands +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_GET_SYSTEM_CAPABILITY_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/get_system_capability_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/get_system_capability_response.h index 9fa954c89f8..61079b3ac25 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/get_system_capability_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/get_system_capability_response.h @@ -60,7 +60,7 @@ class GetSystemCapabilityResponse DISALLOW_COPY_AND_ASSIGN(GetSystemCapabilityResponse); }; // GetSystemCapabilityResponse -} // commands -} // application_manager +} // namespace commands +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_GET_SYSTEM_CAPABILITY_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/get_way_points_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/get_way_points_request.h index 71978744754..ec656820e55 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/get_way_points_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/get_way_points_request.h @@ -76,6 +76,6 @@ class GetWayPointsRequest : public app_mngr::commands::CommandRequestImpl { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_GET_WAY_POINTS_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/get_way_points_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/get_way_points_response.h index bb480a7ac08..1b8f055e9ce 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/get_way_points_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/get_way_points_response.h @@ -71,6 +71,6 @@ class GetWayPointsResponse : public app_mngr::commands::CommandResponseImpl { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_GET_WAY_POINTS_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/list_files_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/list_files_request.h index 53d75819f8b..d98fa433b45 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/list_files_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/list_files_request.h @@ -73,6 +73,6 @@ class ListFilesRequest : public app_mngr::commands::CommandRequestImpl { }; } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_LIST_FILES_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/list_files_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/list_files_response.h index 1b3cdf1b021..d259b27ecf8 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/list_files_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/list_files_response.h @@ -73,6 +73,6 @@ class ListFilesResponse : public app_mngr::commands::CommandResponseImpl { }; } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_LIST_FILES_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_app_interface_unregistered_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_app_interface_unregistered_notification.h index ba01d4bb28c..28508d386c1 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_app_interface_unregistered_notification.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_app_interface_unregistered_notification.h @@ -75,6 +75,6 @@ class OnAppInterfaceUnregisteredNotification }; } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_ON_APP_INTERFACE_UNREGISTERED_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_audio_pass_thru_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_audio_pass_thru_notification.h index e3410bd8733..a6de6b929cd 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_audio_pass_thru_notification.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_audio_pass_thru_notification.h @@ -77,6 +77,6 @@ class OnAudioPassThruNotification }; } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_ON_AUDIO_PASS_THRU_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_button_event_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_button_event_notification.h index 6afdc0e1cf4..afde9bac92f 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_button_event_notification.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_button_event_notification.h @@ -34,8 +34,8 @@ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_ON_BUTTON_EVENT_NOTIFICATION_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_ON_BUTTON_EVENT_NOTIFICATION_H_ -#include "application_manager/commands/command_notification_impl.h" #include "application_manager/application.h" +#include "application_manager/commands/command_notification_impl.h" #include "utils/macro.h" namespace sdl_rpc_plugin { @@ -87,6 +87,6 @@ class OnButtonEventNotification } // namespace mobile } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_ON_BUTTON_EVENT_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_button_press_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_button_press_notification.h index fe9bc449beb..57fda49be74 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_button_press_notification.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_button_press_notification.h @@ -34,8 +34,8 @@ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_ON_BUTTON_PRESS_NOTIFICATION_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_ON_BUTTON_PRESS_NOTIFICATION_H_ -#include "application_manager/commands/command_notification_impl.h" #include "application_manager/application.h" +#include "application_manager/commands/command_notification_impl.h" #include "utils/macro.h" namespace sdl_rpc_plugin { @@ -86,6 +86,6 @@ class OnButtonPressNotification } // namespace mobile } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_ON_BUTTON_PRESS_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_command_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_command_notification.h index 367b280e731..76ee0b4052d 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_command_notification.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_command_notification.h @@ -77,6 +77,6 @@ class OnCommandNotification }; } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_ON_COMMAND_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_driver_distraction_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_driver_distraction_notification.h index 82e6097d847..9c7fb5e91b8 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_driver_distraction_notification.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_driver_distraction_notification.h @@ -79,6 +79,6 @@ class OnDriverDistractionNotification } // namespace mobile } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_ON_DRIVER_DISTRACTION_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_hash_change_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_hash_change_notification.h index 76c9cf34c54..b62f74e199a 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_hash_change_notification.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_hash_change_notification.h @@ -76,6 +76,6 @@ class OnHashChangeNotification } // namespace mobile } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_ON_HASH_CHANGE_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_hmi_status_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_hmi_status_notification.h index 0e1919676b4..ef040de3de2 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_hmi_status_notification.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_hmi_status_notification.h @@ -74,6 +74,6 @@ class OnHMIStatusNotification }; } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_ON_HMI_STATUS_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_hmi_status_notification_from_mobile.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_hmi_status_notification_from_mobile.h index 12e3b54be99..6f3ef400760 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_hmi_status_notification_from_mobile.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_hmi_status_notification_from_mobile.h @@ -34,8 +34,8 @@ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_ON_HMI_STATUS_NOTIFICATION_FROM_MOBILE_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_ON_HMI_STATUS_NOTIFICATION_FROM_MOBILE_H_ -#include "application_manager/commands/command_notification_from_mobile_impl.h" #include "application_manager/application_manager.h" +#include "application_manager/commands/command_notification_from_mobile_impl.h" #include "interfaces/MOBILE_API.h" #include "utils/macro.h" @@ -77,6 +77,6 @@ class OnHMIStatusNotificationFromMobile }; } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_ON_HMI_STATUS_NOTIFICATION_FROM_MOBILE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_keyboard_input_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_keyboard_input_notification.h index d34815ff2fc..52f6e5d487f 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_keyboard_input_notification.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_keyboard_input_notification.h @@ -78,6 +78,6 @@ class OnKeyBoardInputNotification } // namespace mobile } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_ON_KEYBOARD_INPUT_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_language_change_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_language_change_notification.h index b234b937967..1bc1e94b1f0 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_language_change_notification.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_language_change_notification.h @@ -75,6 +75,6 @@ class OnLanguageChangeNotification }; } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_ON_LANGUAGE_CHANGE_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_permissions_change_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_permissions_change_notification.h index f586a0d36cb..eca3cebf31b 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_permissions_change_notification.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_permissions_change_notification.h @@ -75,6 +75,6 @@ class OnPermissionsChangeNotification }; } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_ON_PERMISSIONS_CHANGE_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_system_capability_updated_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_system_capability_updated_notification.h index 1f7e8468dbd..f29c7dcf2bb 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_system_capability_updated_notification.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_system_capability_updated_notification.h @@ -33,9 +33,9 @@ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_ON_SYSTEM_CAPABILITY_UPDATED_NOTIFICATION_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_ON_SYSTEM_CAPABILITY_UPDATED_NOTIFICATION_H_ +#include #include "application_manager/commands/command_notification_impl.h" #include "policy/policy_table/enums.h" -#include namespace sdl_rpc_plugin { namespace app_mngr = application_manager; @@ -79,6 +79,6 @@ class OnSystemCapabilityUpdatedNotification } // namespace mobile } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_ON_SYSTEM_CAPABILITY_UPDATED_NOTIFICATION_H_ 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 b369ad38f27..a0148a4abd9 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 @@ -33,9 +33,9 @@ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_ON_SYSTEM_REQUEST_NOTIFICATION_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_ON_SYSTEM_REQUEST_NOTIFICATION_H_ +#include #include "application_manager/commands/command_notification_impl.h" #include "policy/policy_table/enums.h" -#include namespace sdl_rpc_plugin { namespace app_mngr = application_manager; @@ -88,6 +88,6 @@ class OnSystemRequestNotification } // namespace mobile } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_ON_SYSTEM_REQUEST_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_tbt_client_state_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_tbt_client_state_notification.h index 39b12fea151..cbb7525092f 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_tbt_client_state_notification.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_tbt_client_state_notification.h @@ -75,6 +75,6 @@ class OnTBTClientStateNotification }; } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_ON_TBT_CLIENT_STATE_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_touch_event_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_touch_event_notification.h index 858759b793e..48872d9b279 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_touch_event_notification.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_touch_event_notification.h @@ -77,6 +77,6 @@ class OnTouchEventNotification } // namespace mobile } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_ON_TOUCH_EVENT_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_way_point_change_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_way_point_change_notification.h index c379fceb02e..ed7cbccf4a8 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_way_point_change_notification.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_way_point_change_notification.h @@ -71,5 +71,5 @@ class OnWayPointChangeNotification }; } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_ON_WAY_POINT_CHANGE_NOTIFICATION_H_ 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 1a4c248a02e..434b6de0288 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 @@ -35,8 +35,8 @@ #define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_PERFORM_AUDIO_PASS_THRU_REQUEST_H_ #include "application_manager/commands/command_request_impl.h" -#include "utils/macro.h" #include "interfaces/MOBILE_API.h" +#include "utils/macro.h" namespace sdl_rpc_plugin { namespace app_mngr = application_manager; @@ -184,6 +184,6 @@ class PerformAudioPassThruRequest }; } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_PERFORM_AUDIO_PASS_THRU_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/perform_audio_pass_thru_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/perform_audio_pass_thru_response.h index 6654762067e..300ea6531ff 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/perform_audio_pass_thru_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/perform_audio_pass_thru_response.h @@ -75,6 +75,6 @@ class PerformAudioPassThruResponse }; } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_PERFORM_AUDIO_PASS_THRU_RESPONSE_H_ 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 2d4cbc9afc1..0572679c852 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 @@ -36,8 +36,8 @@ #include -#include "application_manager/commands/command_request_impl.h" #include "application_manager/application.h" +#include "application_manager/commands/command_request_impl.h" #include "utils/macro.h" namespace sdl_rpc_plugin { @@ -246,6 +246,6 @@ class PerformInteractionRequest }; } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_PERFORM_INTERACTION_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/perform_interaction_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/perform_interaction_response.h index 6bb9135dcca..113757a1ad9 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/perform_interaction_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/perform_interaction_response.h @@ -75,6 +75,6 @@ class PerformInteractionResponse }; } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_PERFORM_INTERACTION_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/put_file_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/put_file_request.h index 2783280f87e..b3e04f77966 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/put_file_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/put_file_request.h @@ -34,9 +34,9 @@ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_PUT_FILE_REQUEST_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_PUT_FILE_REQUEST_H_ +#include "application_manager/application_manager.h" #include "application_manager/commands/command_request_impl.h" #include "utils/macro.h" -#include "application_manager/application_manager.h" namespace sdl_rpc_plugin { namespace app_mngr = application_manager; @@ -76,11 +76,11 @@ class PutFileRequest : public app_mngr::commands::CommandRequestImpl { mobile_apis::FileType::eType file_type_; bool is_persistent_file_; - void SendOnPutFileNotification(); + void SendOnPutFileNotification(bool is_system_file); DISALLOW_COPY_AND_ASSIGN(PutFileRequest); }; } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_PUT_FILE_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/put_file_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/put_file_response.h index 22dbf1b5d53..348a217eba6 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/put_file_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/put_file_response.h @@ -73,6 +73,6 @@ class PutFileResponse : public app_mngr::commands::CommandResponseImpl { }; } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_PUT_FILE_RESPONSE_H_ 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 91ee8ea8134..c55dcb65fc2 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 @@ -36,8 +36,8 @@ #include "application_manager/commands/command_request_impl.h" #include "application_manager/policies/policy_handler_interface.h" -#include "utils/macro.h" #include "utils/custom_string.h" +#include "utils/macro.h" namespace policy { struct DeviceInfo; @@ -126,7 +126,7 @@ class RegisterAppInterfaceRequest * * @param app application with changed HMI status * @param resumption If true, resumption-related parameters will be sent to - *the HMI + * the HMI * @param need_restore_vr If resumption is true, whether or not VR commands *should be resumed **/ @@ -154,11 +154,11 @@ class RegisterAppInterfaceRequest std::vector& out_duplicate_apps); /* - * @brief Predicate for using with CheckCoincidence method to compare with VR - * synonym SO - * - * return TRUE if there is coincidence of VR, otherwise FALSE - */ + * @brief Predicate for using with CheckCoincidence method to compare with VR + * synonym SO + * + * return TRUE if there is coincidence of VR, otherwise FALSE + */ struct CoincidencePredicateVR { CoincidencePredicateVR(const custom_str::CustomString& newItem) : newItem_(newItem) {} @@ -207,17 +207,31 @@ class RegisterAppInterfaceRequest void SendSubscribeCustomButtonNotification(); /** - * @brief IsApplicationSwitched checks whether application is switched from - * another transport. If application id is found, but not in reconnection + * @brief IsApplicationSwitched checks whether application is switched + * from another transport. If application id is found, but not in reconnection * list, returns 'already registered' code. Otherwise - proceed with * switching. * @return True if application is detected as switched, otherwise false. */ bool IsApplicationSwitched(); + /** + * @brief Information about given Connection Key. + * @param key Unique key used by other components as session identifier + * @param device_id device identifier. + * @param mac_address uniq address + * @return false in case of error or true in case of success + */ + bool GetDataOnSessionKey( + const uint32_t key, + connection_handler::DeviceHandle* device_id = nullptr, + std::string* mac_address = nullptr) const; + private: std::string response_info_; mobile_apis::Result::eType result_code_; + connection_handler::DeviceHandle device_handle_; + std::string device_id_; policy::PolicyHandlerInterface& GetPolicyHandler(); DISALLOW_COPY_AND_ASSIGN(RegisterAppInterfaceRequest); @@ -225,6 +239,6 @@ class RegisterAppInterfaceRequest } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_REGISTER_APP_INTERFACE_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/register_app_interface_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/register_app_interface_response.h index d591d677941..2a6e847067f 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/register_app_interface_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/register_app_interface_response.h @@ -79,6 +79,6 @@ class RegisterAppInterfaceResponse }; } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_REGISTER_APP_INTERFACE_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/reset_global_properties_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/reset_global_properties_request.h index 6f7e330bf50..880fced6baf 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/reset_global_properties_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/reset_global_properties_request.h @@ -34,8 +34,8 @@ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_RESET_GLOBAL_PROPERTIES_REQUEST_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_RESET_GLOBAL_PROPERTIES_REQUEST_H_ -#include "application_manager/commands/command_request_impl.h" #include "application_manager/application.h" +#include "application_manager/commands/command_request_impl.h" #include "utils/macro.h" namespace sdl_rpc_plugin { @@ -144,6 +144,6 @@ class ResetGlobalPropertiesRequest }; } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_RESET_GLOBAL_PROPERTIES_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/reset_global_properties_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/reset_global_properties_response.h index b33ef41426d..6d9b604b41e 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/reset_global_properties_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/reset_global_properties_response.h @@ -75,6 +75,6 @@ class ResetGlobalPropertiesResponse }; } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_RESET_GLOBAL_PROPERTIES_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/scrollable_message_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/scrollable_message_request.h index a641fa0cd4b..58b7b4491a9 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/scrollable_message_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/scrollable_message_request.h @@ -85,6 +85,6 @@ class ScrollableMessageRequest : public app_mngr::commands::CommandRequestImpl { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_SCROLLABLE_MESSAGE_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/scrollable_message_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/scrollable_message_response.h index 8bc8a363636..e5c668b424b 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/scrollable_message_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/scrollable_message_response.h @@ -68,6 +68,6 @@ class ScrollableMessageResponse }; } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_SCROLLABLE_MESSAGE_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/send_haptic_data_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/send_haptic_data_request.h index e3ed6ef28be..2f00b58d9e4 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/send_haptic_data_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/send_haptic_data_request.h @@ -34,8 +34,8 @@ #define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_SEND_HAPTIC_DATA_REQUEST_H_ #include -#include "application_manager/commands/command_request_impl.h" #include "application_manager/application_manager.h" +#include "application_manager/commands/command_request_impl.h" #include "application_manager/event_engine/event.h" #include "smart_objects/smart_object.h" @@ -83,6 +83,6 @@ class SendHapticDataRequest : public app_mngr::commands::CommandRequestImpl { }; } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_SEND_HAPTIC_DATA_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/send_haptic_data_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/send_haptic_data_response.h index 53e87662410..515fe3f74d4 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/send_haptic_data_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/send_haptic_data_response.h @@ -72,6 +72,6 @@ class SendHapticDataResponse : public app_mngr::commands::CommandResponseImpl { }; } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_SEND_HAPTIC_DATA_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/send_location_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/send_location_request.h index 6626da4c9d3..5a0dc67f35b 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/send_location_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/send_location_request.h @@ -75,10 +75,10 @@ class SendLocationRequest : public app_mngr::commands::CommandRequestImpl { private: /** - * @brief CheckFieldsCompatibility checks if fields are compatible with each - * other. - * @return true if compatible, otherwise return false - */ + * @brief CheckFieldsCompatibility checks if fields are compatible with each + * other. + * @return true if compatible, otherwise return false + */ bool CheckFieldsCompatibility(); /** @@ -95,6 +95,6 @@ class SendLocationRequest : public app_mngr::commands::CommandRequestImpl { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_SEND_LOCATION_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/send_location_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/send_location_response.h index cb461f9a601..a2e9d1eb0a7 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/send_location_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/send_location_response.h @@ -66,6 +66,6 @@ class SendLocationResponse : public app_mngr::commands::CommandResponseImpl { }; } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_SEND_LOCATION_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/set_app_icon_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/set_app_icon_request.h index 1075999af9e..86ca2fb1267 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/set_app_icon_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/set_app_icon_request.h @@ -111,6 +111,6 @@ class SetAppIconRequest : public app_mngr::commands::CommandRequestImpl { }; } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_SET_APP_ICON_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/set_app_icon_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/set_app_icon_response.h index e4ce0725dcd..a9b203bec7f 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/set_app_icon_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/set_app_icon_response.h @@ -73,6 +73,6 @@ class SetAppIconResponse : public app_mngr::commands::CommandResponseImpl { }; } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_SET_APP_ICON_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/set_display_layout_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/set_display_layout_request.h index 4bd800988cb..2f9c0946d39 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/set_display_layout_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/set_display_layout_request.h @@ -80,6 +80,6 @@ class SetDisplayLayoutRequest : public app_mngr::commands::CommandRequestImpl { }; } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_SET_DISPLAY_LAYOUT_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/set_display_layout_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/set_display_layout_response.h index 73f57fc1878..7b43613ac49 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/set_display_layout_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/set_display_layout_response.h @@ -74,6 +74,6 @@ class SetDisplayLayoutResponse }; } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_SET_DISPLAY_LAYOUT_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/set_global_properties_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/set_global_properties_request.h index 674de4731af..3a32d1b671d 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/set_global_properties_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/set_global_properties_request.h @@ -33,9 +33,9 @@ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_SET_GLOBAL_PROPERTIES_REQUEST_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_SET_GLOBAL_PROPERTIES_REQUEST_H_ #include +#include "application_manager/application.h" #include "application_manager/commands/command_request_impl.h" #include "utils/macro.h" -#include "application_manager/application.h" namespace sdl_rpc_plugin { namespace app_mngr = application_manager; @@ -82,7 +82,76 @@ class SetGlobalPropertiesRequest */ bool Init() FINAL; + /** + * @brief Prepares total result for mobile according to three results: + * ui_properties_result, tts_properties_result, rc_properties_result. + * @param first ResponseInfo as first argument + * @param second ResponseInfo as secondargument + * @param third ResponseInfo as third argument + * @return total result + */ + bool PrepareResultForMobileResponse( + const app_mngr::commands::ResponseInfo& first, + const app_mngr::commands::ResponseInfo& second, + const app_mngr::commands::ResponseInfo& third) const; + + /** + * @brief Prepare result code for sending to mobile application + * @param first contains result_code from HMI response and + * interface that returns response + * @param second contains result_code from HMI response and + * interface that returns response. + * * @param third contains result_code from HMI response and + * interface that returns response. + * @return resulting code for sending to mobile application. + */ + mobile_apis::Result::eType PrepareResultCodeForResponse( + const app_mngr::commands::ResponseInfo& first, + const app_mngr::commands::ResponseInfo& second, + const app_mngr::commands::ResponseInfo& third); + + /** + * @brief Resolves if the return code must be + * UNSUPPORTED_RESOURCE + * @param first contains result_code from HMI response and + * interface that returns response + * @param second contains result_code from HMI response and + * interface that returns response. + * * @param third contains result_code from HMI response and + * interface that returns response. + * @return True, if the communication return code must be + * UNSUPPORTED_RESOURCE, otherwise false. + */ + bool IsResultCodeUnsupported( + const app_mngr::commands::ResponseInfo& first, + const app_mngr::commands::ResponseInfo& second, + const app_mngr::commands::ResponseInfo& third) const; + private: + /** + * @brief MergeInfos merge 2 infos into one string with info + * @param first_info -contains result_code from HMI response and + * interface that returns response + * @param first_str - info string that should be first in result info + * @param second_info -contains result_code from HMI response and + * interface that returns response + * @param second_str - info string that should be second in result info + * @param third_info - contains result_code from HMI response and + * interface that returns response + * @param third_str - info string that should be third in result info + * @return if first_info is not available and second_str and third_info not + * empty return second if second_info is not available and first_str and + * third_info not empty return first if third_info is not available and + * first_str and second_str not empty return first other cases return result + * MergeInfos for 2 params + */ + std::string MergeInfos(const app_mngr::commands::ResponseInfo& first_info, + const std::string& first_str, + const app_mngr::commands::ResponseInfo& second_info, + const std::string& second_str, + const app_mngr::commands::ResponseInfo& third_info, + const std::string& third_str); + // prepare UI sending data (VrHelps, Menus, Keyboard) to SmartObject static void PrepareUIRequestVRHelpData( const app_mngr::ApplicationSharedPtr app, @@ -101,6 +170,9 @@ class SetGlobalPropertiesRequest // Send UI request to HMI void SendUIRequest(const smart_objects::SmartObject& params, bool use_events); + // Send SetGlobalProperties with userLocation parameter + void SendRCRequest(const smart_objects::SmartObject& params, bool use_events); + // VRHelp shall contain sequential positions and start from 1 static bool CheckVrHelpItemsOrder(const smart_objects::SmartObject& vr_help); @@ -140,19 +212,25 @@ class SetGlobalPropertiesRequest bool is_ui_send_; bool is_tts_send_; + bool is_rc_send_; bool is_ui_received_; bool is_tts_received_; + bool is_rc_received_; hmi_apis::Common_Result::eType ui_result_; hmi_apis::Common_Result::eType tts_result_; + hmi_apis::Common_Result::eType rc_result_; std::string ui_response_info_; std::string tts_response_info_; + std::string rc_response_info_; + + bool is_menu_layout_available_ = true; DISALLOW_COPY_AND_ASSIGN(SetGlobalPropertiesRequest); }; } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_SET_GLOBAL_PROPERTIES_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/set_global_properties_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/set_global_properties_response.h index 778dc9b7d75..f8d8117250e 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/set_global_properties_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/set_global_properties_response.h @@ -75,6 +75,6 @@ class SetGlobalPropertiesResponse }; } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_SET_GLOBAL_PROPERTIES_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/set_media_clock_timer_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/set_media_clock_timer_request.h index ef674f1c38e..adced13d73b 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/set_media_clock_timer_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/set_media_clock_timer_request.h @@ -81,6 +81,6 @@ class SetMediaClockRequest : public app_mngr::commands::CommandRequestImpl { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_SET_MEDIA_CLOCK_TIMER_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/set_media_clock_timer_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/set_media_clock_timer_response.h index 2fb3f25839e..240d1be8d16 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/set_media_clock_timer_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/set_media_clock_timer_response.h @@ -69,6 +69,6 @@ class SetMediaClockTimerResponse }; } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_SET_MEDIA_CLOCK_TIMER_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/show_app_menu_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/show_app_menu_request.h new file mode 100644 index 00000000000..c9691a808fe --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/show_app_menu_request.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_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_SHOW_APP_MENU_REQUEST_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_SHOW_APP_MENU_REQUEST_H_ + +#include "application_manager/commands/command_request_impl.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief ShowAppMenuRequest command class + **/ +class ShowAppMenuRequest : public app_mngr::commands::CommandRequestImpl { + public: + /** + * @brief ShowAppMenuRequest class constructor + **/ + ShowAppMenuRequest(const app_mngr::commands::MessageSharedPtr& message, + app_mngr::ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handler); + + /** + * @brief ShowAppMenuRequest class destructor + **/ + ~ShowAppMenuRequest() OVERRIDE; + + /** + * @brief Execute command + **/ + void Run() OVERRIDE; + + /** + * @brief Interface method that is called whenever new event received + * + * @param event The received event + **/ + void on_event(const app_mngr::event_engine::Event& event) OVERRIDE; + + private: + DISALLOW_COPY_AND_ASSIGN(ShowAppMenuRequest); +}; + +} // namespace commands +} // namespace sdl_rpc_plugin + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_SHOW_APP_MENU_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/show_app_menu_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/show_app_menu_response.h new file mode 100644 index 00000000000..1e357e8a115 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/show_app_menu_response.h @@ -0,0 +1,74 @@ +/* + * Copyright (c) 2018, Ford Motor Company + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following + * disclaimer in the documentation and/or other materials provided with the + * distribution. + * + * Neither the name of the Ford Motor Company nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_SHOW_APP_MENU_RESPONSE_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_SHOW_APP_MENU_RESPONSE_H_ + +#include "application_manager/commands/command_response_impl.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief ShowAppMenuResponse command class + **/ +class ShowAppMenuResponse : public app_mngr::commands::CommandResponseImpl { + public: + /** + * @brief ShowAppMenuResponse class constructor + **/ + ShowAppMenuResponse(const app_mngr::commands::MessageSharedPtr& messasge, + app_mngr::ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handler); + + /** + * @brief ShowAppMenuResponse class destructor + **/ + ~ShowAppMenuResponse() OVERRIDE; + + /** + * @brief Execute command + **/ + void Run() OVERRIDE; + + private: + DISALLOW_COPY_AND_ASSIGN(ShowAppMenuResponse); +}; + +} // namespace commands +} // namespace sdl_rpc_plugin + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_SHOW_APP_MENU_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/show_constant_tbt_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/show_constant_tbt_request.h index cadc87cef60..7694070a723 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/show_constant_tbt_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/show_constant_tbt_request.h @@ -89,6 +89,6 @@ class ShowConstantTBTRequest : public app_mngr::commands::CommandRequestImpl { }; } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_SHOW_CONSTANT_TBT_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/show_constant_tbt_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/show_constant_tbt_response.h index 4129a7640e4..4b2136ad11a 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/show_constant_tbt_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/show_constant_tbt_response.h @@ -73,6 +73,6 @@ class ShowConstantTBTResponse : public app_mngr::commands::CommandResponseImpl { }; } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_SHOW_CONSTANT_TBT_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/show_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/show_request.h index 2277a38f11a..26612609a41 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/show_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/show_request.h @@ -90,14 +90,39 @@ class ShowRequest : public app_mngr::commands::CommandRequestImpl { int32_t field_index, smart_objects::SmartObject& msg_params); + /** + * @brief Handle the template configuration information from the + * incoming mobile json message format for specified application + * @param app - application for which configuration should be checked + * @return True if template config can be successfully applied otherwise - + * false + */ + bool CheckTemplateConfigurationForApp(application_manager::Application& app); + + /** + * @brief Applies the template configuration which was set up beforehand + * @param result - result code on which template application is dependent + * @param app - application for which configuration should be applied + */ + void ApplyTemplateConfigurationForApp(mobile_apis::Result::eType result, + application_manager::Application& app); + mobile_apis::Result::eType core_result_code_; std::string core_response_info_; + app_mngr::WindowID current_window_id_; + smart_objects::SmartObject template_config_; + bool layout_change_required_; + + // dcs - abbreviation of Day Color Scheme + bool dcs_change_required_; + // ncd - abbreviation of Night Color Scheme + bool ncs_change_required_; DISALLOW_COPY_AND_ASSIGN(ShowRequest); }; } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_SHOW_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/show_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/show_response.h index c78820a26e7..97843c21487 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/show_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/show_response.h @@ -67,6 +67,6 @@ class ShowResponse : public app_mngr::commands::CommandResponseImpl { }; } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_SHOW_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/slider_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/slider_request.h index f1e06e8d8df..5dbcbb7d414 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/slider_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/slider_request.h @@ -91,6 +91,6 @@ class SliderRequest : public app_mngr::commands::CommandRequestImpl { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_SLIDER_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/slider_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/slider_response.h index 2a931036324..842e52f595b 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/slider_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/slider_response.h @@ -67,6 +67,6 @@ class SliderResponse : public app_mngr::commands::CommandResponseImpl { }; } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_SLIDER_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/speak_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/speak_request.h index d6d47bb8691..68e35fcd1d5 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/speak_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/speak_request.h @@ -93,6 +93,6 @@ class SpeakRequest : public app_mngr::commands::CommandRequestImpl { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_SPEAK_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/speak_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/speak_response.h index 30eda078101..02b7baae543 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/speak_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/speak_response.h @@ -67,6 +67,6 @@ class SpeakResponse : public app_mngr::commands::CommandResponseImpl { }; } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_SPEAK_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/subscribe_button_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/subscribe_button_request.h index 011c0aa3596..2b9887daad2 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/subscribe_button_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/subscribe_button_request.h @@ -34,8 +34,8 @@ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_SUBSCRIBE_BUTTON_REQUEST_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_SUBSCRIBE_BUTTON_REQUEST_H_ -#include "application_manager/commands/command_request_impl.h" #include "application_manager/application_impl.h" +#include "application_manager/commands/command_request_impl.h" #include "utils/macro.h" namespace sdl_rpc_plugin { @@ -98,6 +98,6 @@ class SubscribeButtonRequest : public app_mngr::commands::CommandRequestImpl { }; } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_SUBSCRIBE_BUTTON_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/subscribe_button_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/subscribe_button_response.h index 28e942ec17f..b42ccb91e1e 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/subscribe_button_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/subscribe_button_response.h @@ -73,6 +73,6 @@ class SubscribeButtonResponse : public app_mngr::commands::CommandResponseImpl { }; } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_SUBSCRIBE_BUTTON_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/subscribe_way_points_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/subscribe_way_points_request.h index 6105f087509..8b88a1c884a 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/subscribe_way_points_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/subscribe_way_points_request.h @@ -80,8 +80,8 @@ class SubscribeWayPointsRequest DISALLOW_COPY_AND_ASSIGN(SubscribeWayPointsRequest); }; -} // commands +} // namespace commands -} // application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_SUBSCRIBE_WAY_POINTS_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/subscribe_way_points_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/subscribe_way_points_response.h index cd27e96d255..4039f21f8ec 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/subscribe_way_points_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/subscribe_way_points_response.h @@ -71,8 +71,8 @@ class SubscribeWayPointsResponse DISALLOW_COPY_AND_ASSIGN(SubscribeWayPointsResponse); }; -} // commands +} // namespace commands -} // application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_SUBSCRIBE_WAY_POINTS_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/system_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/system_request.h index c34db34506e..eb2398f279d 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/system_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/system_request.h @@ -35,8 +35,8 @@ #define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_SYSTEM_REQUEST_H_ #include -#include "application_manager/commands/command_request_impl.h" #include "application_manager/application_manager.h" +#include "application_manager/commands/command_request_impl.h" #include "application_manager/event_engine/event.h" #include "smart_objects/smart_object.h" @@ -93,6 +93,6 @@ class SystemRequest : public app_mngr::commands::CommandRequestImpl { }; } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_SYSTEM_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/system_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/system_response.h index afbd557d12d..5c3f69d7572 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/system_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/system_response.h @@ -72,6 +72,6 @@ class SystemResponse : public app_mngr::commands::CommandResponseImpl { }; } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_SYSTEM_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/unregister_app_interface_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/unregister_app_interface_request.h index 172f934a152..0bc01f2aaaa 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/unregister_app_interface_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/unregister_app_interface_request.h @@ -80,6 +80,6 @@ class UnregisterAppInterfaceRequest } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_UNREGISTER_APP_INTERFACE_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/unregister_app_interface_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/unregister_app_interface_response.h index 13d8b549e8a..d1ac004ca00 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/unregister_app_interface_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/unregister_app_interface_response.h @@ -76,6 +76,6 @@ class UnregisterAppInterfaceResponse }; } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_UNREGISTER_APP_INTERFACE_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/unsubscribe_button_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/unsubscribe_button_request.h index 8cbaafbfe10..51c10642cf2 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/unsubscribe_button_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/unsubscribe_button_request.h @@ -84,6 +84,6 @@ class UnsubscribeButtonRequest : public app_mngr::commands::CommandRequestImpl { }; } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_UNSUBSCRIBE_BUTTON_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/unsubscribe_button_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/unsubscribe_button_response.h index 1db067acce3..efd54783635 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/unsubscribe_button_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/unsubscribe_button_response.h @@ -74,6 +74,6 @@ class UnsubscribeButtonResponse }; } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_UNSUBSCRIBE_BUTTON_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/unsubscribe_way_points_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/unsubscribe_way_points_request.h index fe14f5c7eb9..e83e9b7509d 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/unsubscribe_way_points_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/unsubscribe_way_points_request.h @@ -79,8 +79,8 @@ class UnsubscribeWayPointsRequest DISALLOW_COPY_AND_ASSIGN(UnsubscribeWayPointsRequest); }; -} // commands +} // namespace commands -} // application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_UNSUBSCRIBE_WAY_POINTS_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/unsubscribe_way_points_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/unsubscribe_way_points_response.h index c578bf9f994..9ab167284ac 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/unsubscribe_way_points_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/unsubscribe_way_points_response.h @@ -71,8 +71,8 @@ class UnsubscribeWayPointsResponse DISALLOW_COPY_AND_ASSIGN(UnsubscribeWayPointsResponse); }; -} // commands +} // namespace commands -} // application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_UNSUBSCRIBE_WAY_POINTS_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/update_turn_list_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/update_turn_list_request.h index 8766339f960..e1e5df22899 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/update_turn_list_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/update_turn_list_request.h @@ -97,6 +97,6 @@ class UpdateTurnListRequest : public app_mngr::commands::CommandRequestImpl { }; } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_UPDATE_TURN_LIST_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/update_turn_list_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/update_turn_list_response.h index 59d3bf0b2c1..80e143644f6 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/update_turn_list_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/update_turn_list_response.h @@ -73,6 +73,6 @@ class UpdateTurnListResponse : public app_mngr::commands::CommandResponseImpl { }; } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_UPDATE_TURN_LIST_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/extensions/system_capability_app_extension.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/extensions/system_capability_app_extension.h index fb82cf37c23..935716aa301 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/extensions/system_capability_app_extension.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/extensions/system_capability_app_extension.h @@ -78,6 +78,6 @@ class SystemCapabilityAppExtension : public app_mngr_::AppExtension { SDLRPCPlugin& plugin_; app_mngr_::Application& app_; }; -} +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_EXTENSIONS_SYSTEM_CAPABILITY_APP_EXTENSION_H diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/hmi_command_factory.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/hmi_command_factory.h index eee454fb00e..95bb2531206 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/hmi_command_factory.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/hmi_command_factory.h @@ -33,8 +33,8 @@ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_HMI_COMMAND_FACTORY_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_HMI_COMMAND_FACTORY_H_ -#include "application_manager/command_factory.h" #include "application_manager/application_manager.h" +#include "application_manager/command_factory.h" namespace sdl_rpc_plugin { namespace app_mngr = application_manager; @@ -70,6 +70,6 @@ class HMICommandFactory : public app_mngr::CommandFactory { DISALLOW_COPY_AND_ASSIGN(HMICommandFactory); }; -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_HMI_COMMAND_FACTORY_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/mobile_command_factory.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/mobile_command_factory.h index 44a4475b620..132b68aaec3 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/mobile_command_factory.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/mobile_command_factory.h @@ -33,8 +33,8 @@ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_MOBILE_COMMAND_FACTORY_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_MOBILE_COMMAND_FACTORY_H_ -#include "application_manager/command_factory.h" #include "application_manager/application_manager.h" +#include "application_manager/command_factory.h" namespace sdl_rpc_plugin { namespace app_mngr = application_manager; @@ -77,6 +77,6 @@ class MobileCommandFactory : public app_mngr::CommandFactory { DISALLOW_COPY_AND_ASSIGN(MobileCommandFactory); }; -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_MOBILE_COMMAND_FACTORY_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/sdl_command_factory.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/sdl_command_factory.h index 5b5f0ae49fb..edbfe1bdc05 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/sdl_command_factory.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/sdl_command_factory.h @@ -36,11 +36,11 @@ #include #include "application_manager/application_manager.h" #include "application_manager/command_factory.h" -#include "sdl_rpc_plugin/hmi_command_factory.h" -#include "sdl_rpc_plugin/mobile_command_factory.h" -#include "application_manager/rpc_service.h" #include "application_manager/hmi_capabilities.h" #include "application_manager/policies/policy_handler_interface.h" +#include "application_manager/rpc_service.h" +#include "sdl_rpc_plugin/hmi_command_factory.h" +#include "sdl_rpc_plugin/mobile_command_factory.h" namespace sdl_rpc_plugin { namespace app_mngr = application_manager; @@ -69,5 +69,5 @@ class SDLCommandFactory : public app_mngr::CommandFactory { std::unique_ptr hmi_command_factory_; std::unique_ptr mobile_command_factory_; }; -} +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_SDL_COMMAND_FACTORY_H diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/sdl_rpc_plugin.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/sdl_rpc_plugin.h index b57fcbec128..91298f4883a 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/sdl_rpc_plugin.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/sdl_rpc_plugin.h @@ -32,8 +32,8 @@ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_SDL_RPC_PLUGIN_H #define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_SDL_RPC_PLUGIN_H -#include "application_manager/plugin_manager/rpc_plugin.h" #include "application_manager/command_factory.h" +#include "application_manager/plugin_manager/rpc_plugin.h" namespace sdl_rpc_plugin { namespace app_mngr = application_manager; @@ -47,7 +47,8 @@ class SDLRPCPlugin : public plugins::RPCPlugin { bool Init(app_mngr::ApplicationManager& app_manager, app_mngr::rpc_service::RPCService& rpc_service, app_mngr::HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handler) OVERRIDE; + policy::PolicyHandlerInterface& policy_handler, + resumption::LastState& last_state) OVERRIDE; bool IsAbleToProcess( const int32_t function_id, @@ -64,8 +65,8 @@ class SDLRPCPlugin : public plugins::RPCPlugin { std::unique_ptr command_factory_; }; -} +} // namespace sdl_rpc_plugin extern "C" application_manager::plugin_manager::RPCPlugin* Create(); - +extern "C" void Delete(application_manager::plugin_manager::RPCPlugin* data); #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_SDL_RPC_PLUGIN_H diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/activate_app_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/activate_app_request.cc index 19d01b594f1..c6d181bf57d 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/activate_app_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/activate_app_request.cc @@ -75,4 +75,4 @@ void ActivateAppRequest::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/activate_app_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/activate_app_response.cc index d7e38c5d5b5..b829ef711ee 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/activate_app_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/activate_app_response.cc @@ -63,4 +63,4 @@ void ActivateAppResponse::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/add_statistics_info_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/add_statistics_info_notification.cc index 3e46bd353af..93999f704de 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/add_statistics_info_notification.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/add_statistics_info_notification.cc @@ -64,4 +64,4 @@ void AddStatisticsInfoNotification::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/allow_all_apps_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/allow_all_apps_request.cc index b227dd79dc2..68c7896a7f9 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/allow_all_apps_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/allow_all_apps_request.cc @@ -59,4 +59,4 @@ void AllowAllAppsRequest::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/allow_all_apps_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/allow_all_apps_response.cc index 2fdf29a7dd1..c2182f4853b 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/allow_all_apps_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/allow_all_apps_response.cc @@ -59,4 +59,4 @@ void AllowAllAppsResponse::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/allow_app_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/allow_app_request.cc index 0c6e5145c78..6b5af76fb1f 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/allow_app_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/allow_app_request.cc @@ -59,4 +59,4 @@ void AllowAppRequest::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/allow_app_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/allow_app_response.cc index 4853c3764a7..c62645c6c08 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/allow_app_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/allow_app_response.cc @@ -70,4 +70,4 @@ void AllowAppResponse::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/basic_communication_close_application_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/basic_communication_close_application_request.cc new file mode 100644 index 00000000000..b021faefd8d --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/basic_communication_close_application_request.cc @@ -0,0 +1,61 @@ +/* + Copyright (c) 2019, Ford Motor Company, Livio + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + + Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following + disclaimer in the documentation and/or other materials provided with the + distribution. + + Neither the name of the the copyright holders nor the names of their + contributors may be used to endorse or promote products derived from this + software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + */ + +#include "sdl_rpc_plugin/commands/hmi/basic_communication_close_application_request.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; +namespace commands { + +BasicCommunicationCloseApplicationRequest:: + BasicCommunicationCloseApplicationRequest( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handler) + : RequestToHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handler) {} + +BasicCommunicationCloseApplicationRequest:: + ~BasicCommunicationCloseApplicationRequest() {} + +void BasicCommunicationCloseApplicationRequest::Run() { + LOG4CXX_AUTO_TRACE(logger_); + SendRequest(); +} + +} // namespace commands +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/basic_communication_close_application_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/basic_communication_close_application_response.cc new file mode 100644 index 00000000000..2e56271cf2f --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/basic_communication_close_application_response.cc @@ -0,0 +1,65 @@ +/* + Copyright (c) 2019, Ford Motor Company, Livio + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + + Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following + disclaimer in the documentation and/or other materials provided with the + distribution. + + Neither the name of the the copyright holders nor the names of their + contributors may be used to endorse or promote products derived from this + software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + */ + +#include "sdl_rpc_plugin/commands/hmi/basic_communication_close_application_response.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; +namespace commands { + +BasicCommunicationCloseApplicationResponse:: + BasicCommunicationCloseApplicationResponse( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handler) + : ResponseFromHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handler) {} + +BasicCommunicationCloseApplicationResponse:: + ~BasicCommunicationCloseApplicationResponse() {} + +void BasicCommunicationCloseApplicationResponse::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + event_engine::Event event( + hmi_apis::FunctionID::BasicCommunication_CloseApplication); + event.set_smart_object(*message_); + event.raise(application_manager_.event_dispatcher()); +} + +} // namespace commands +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/basic_communication_get_system_time_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/basic_communication_get_system_time_request.cc index fb87612e198..19c9fa91d82 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/basic_communication_get_system_time_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/basic_communication_get_system_time_request.cc @@ -51,7 +51,7 @@ BasicCommunicationGetSystemTimeRequest::BasicCommunicationGetSystemTimeRequest( void BasicCommunicationGetSystemTimeRequest::onTimeOut() { LOG4CXX_AUTO_TRACE(logger_); - application_manager_.protocol_handler().NotifyOnFailedHandshake(); + application_manager_.protocol_handler().NotifyOnGetSystemTimeFailed(); } } // namespace commands diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/basic_communication_get_system_time_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/basic_communication_get_system_time_response.cc index c067debf36e..e26753b3f2d 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/basic_communication_get_system_time_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/basic_communication_get_system_time_response.cc @@ -62,4 +62,4 @@ void BasicCommunicationGetSystemTimeResponse::Run() { } } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/basic_communication_on_awake_sdl.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/basic_communication_on_awake_sdl.cc index 0c393891162..361dc5fea6f 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/basic_communication_on_awake_sdl.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/basic_communication_on_awake_sdl.cc @@ -79,4 +79,4 @@ void OnAwakeSDLNotification::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/basic_communication_system_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/basic_communication_system_request.cc index 04e44a69791..052a40a888b 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/basic_communication_system_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/basic_communication_system_request.cc @@ -58,4 +58,4 @@ void BasicCommunicationSystemRequest::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/basic_communication_system_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/basic_communication_system_response.cc index 5f8221fdbe9..0b052de88d9 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/basic_communication_system_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/basic_communication_system_response.cc @@ -63,4 +63,4 @@ void BasicCommunicationSystemResponse::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/bc_get_file_path_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/bc_get_file_path_response.cc index b86ab6a2b8b..58cda68a2b0 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/bc_get_file_path_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/bc_get_file_path_response.cc @@ -32,9 +32,9 @@ #include "sdl_rpc_plugin/commands/hmi/bc_get_file_path_response.h" #include "application_manager/application_impl.h" +#include "application_manager/event_engine/event.h" #include "application_manager/rpc_service.h" #include "interfaces/MOBILE_API.h" -#include "application_manager/event_engine/event.h" namespace sdl_rpc_plugin { using namespace application_manager; diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/button_get_capabilities_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/button_get_capabilities_request.cc index cf2fbd97615..6696689174e 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/button_get_capabilities_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/button_get_capabilities_request.cc @@ -60,4 +60,4 @@ void ButtonGetCapabilitiesRequest::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/button_get_capabilities_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/button_get_capabilities_response.cc index 628eaa2e585..b6ab822c476 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/button_get_capabilities_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/button_get_capabilities_response.cc @@ -78,4 +78,4 @@ void ButtonGetCapabilitiesResponse::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/close_popup_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/close_popup_request.cc index 84a47b9deb8..988794f6684 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/close_popup_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/close_popup_request.cc @@ -58,4 +58,4 @@ void ClosePopupRequest::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/close_popup_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/close_popup_response.cc index 25396af3378..072e1960e95 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/close_popup_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/close_popup_response.cc @@ -58,4 +58,4 @@ void ClosePopupResponse::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/decrypt_certificate_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/decrypt_certificate_request.cc index 0e09c14650d..71782ef575d 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/decrypt_certificate_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/decrypt_certificate_request.cc @@ -59,4 +59,4 @@ void DecryptCertificateRequest::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/decrypt_certificate_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/decrypt_certificate_response.cc index 694298ed913..cf2a4d092c3 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/decrypt_certificate_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/decrypt_certificate_response.cc @@ -64,5 +64,5 @@ void DecryptCertificateResponse::Run() { } } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // EXTERNAL_PROPRIETARY_MODE diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/dial_number_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/dial_number_request.cc index 63f5c2e815f..97b51096421 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/dial_number_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/dial_number_request.cc @@ -61,4 +61,4 @@ void DialNumberRequest::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/dial_number_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/dial_number_response.cc index 6d37ece2bf1..4ff6785052c 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/dial_number_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/dial_number_response.cc @@ -63,4 +63,4 @@ void DialNumberResponse::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/get_system_info_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/get_system_info_request.cc index c06c90973d5..85462521192 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/get_system_info_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/get_system_info_request.cc @@ -61,4 +61,4 @@ void GetSystemInfoRequest::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/get_system_info_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/get_system_info_response.cc index aef428b39f8..baff925a4e5 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/get_system_info_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/get_system_info_response.cc @@ -31,6 +31,7 @@ */ #include "sdl_rpc_plugin/commands/hmi/get_system_info_response.h" #include "application_manager/message_helper.h" +#include "application_manager/policies/policy_handler_interface.h" namespace sdl_rpc_plugin { using namespace application_manager; @@ -90,4 +91,4 @@ const SystemInfo GetSystemInfoResponse::GetSystemInfo( } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/get_urls.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/get_urls.cc deleted file mode 100644 index ae375e40874..00000000000 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/get_urls.cc +++ /dev/null @@ -1,230 +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 "sdl_rpc_plugin/commands/hmi/get_urls.h" -#include "application_manager/message.h" -#include "application_manager/application_manager.h" -#include "application_manager/rpc_service.h" -#include "application_manager/policies/policy_handler.h" -#include "utils/helpers.h" - -namespace sdl_rpc_plugin { -using namespace application_manager; -namespace commands { - -GetUrls::GetUrls(const application_manager::commands::MessageSharedPtr& message, - ApplicationManager& application_manager, - rpc_service::RPCService& rpc_service, - HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handle) - : RequestFromHMI(message, - application_manager, - rpc_service, - hmi_capabilities, - policy_handle) {} - -GetUrls::~GetUrls() {} - -void GetUrls::Run() { - LOG4CXX_AUTO_TRACE(logger_); - namespace Common_Result = hmi_apis::Common_Result; - using policy::EndpointUrls; - - if (!policy_handler_.PolicyEnabled()) { - SendResponseToHMI(Common_Result::DATA_NOT_AVAILABLE); - return; - } - - const uint32_t service_to_check = - (*message_)[strings::msg_params][hmi_request::service].asUInt(); - - EndpointUrls endpoints; - policy_handler_.GetUpdateUrls(service_to_check, endpoints); - - if (endpoints.empty()) { - LOG4CXX_ERROR(logger_, "No URLs for service " << service_to_check); - SendResponseToHMI(Common_Result::DATA_NOT_AVAILABLE); - return; - } - -#ifdef PROPRIETARY_MODE - const uint32_t policy_service = 7u; - - if (policy_service == service_to_check) { - ProcessPolicyServiceURLs(endpoints); - return; - } -#endif // PROPRIETARY_MODE - - ProcessServiceURLs(endpoints); -} - -void GetUrls::ProcessServiceURLs(const policy::EndpointUrls& endpoints) { - namespace Common_Result = hmi_apis::Common_Result; - using smart_objects::SmartObject; - - (*message_)[strings::msg_params].erase(hmi_request::service); - SmartObject& urls = (*message_)[strings::msg_params][hmi_response::urls]; - - size_t index = 0; - for (size_t e = 0; e < endpoints.size(); ++e) { - ApplicationSharedPtr app = - application_manager_.application_by_policy_id(endpoints[e].app_id); - -#ifndef PROPRIETARY_MODE - bool registered_not_default = false; - if (policy::kDefaultId != endpoints[e].app_id) { - if (!app) { - LOG4CXX_ERROR(logger_, - "Can't find application with policy id " - << endpoints[e].app_id - << " URLs adding for this application is skipped."); - continue; - } - registered_not_default = true; - } -#endif // EXTERNAL_PROPRIETARY_MODE || HTTP - for (size_t u = 0; u < endpoints[e].url.size(); ++u, ++index) { - const std::string& app_url = endpoints[e].url[u]; - SmartObject& service_info = urls[index]; - - service_info[strings::url] = app_url; -#ifndef PROPRIETARY_MODE - if (registered_not_default) { - service_info[strings::app_id] = app->hmi_app_id(); - } -#else // EXTERNAL_PROPRIETARY_MODE || HTTP - service_info[hmi_response::policy_app_id] = endpoints[e].app_id; -#endif - } - } - SendResponseToHMI(Common_Result::SUCCESS); -} - -void GetUrls::SendResponseToHMI(hmi_apis::Common_Result::eType result) { - (*message_)[strings::params][strings::message_type] = MessageType::kResponse; - (*message_)[strings::params][hmi_response::code] = result; - rpc_service_.ManageHMICommand(message_); -} - -#ifdef PROPRIETARY_MODE -struct PolicyAppIdComparator { - PolicyAppIdComparator(const std::string& policy_app_id) - : policy_app_id_(policy_app_id) {} - - bool operator()(const policy::EndpointData& data) { - return data.app_id == policy_app_id_; - } - std::string policy_app_id_; -}; - -void FillSODefaultUrls(smart_objects::SmartObject& urls, - const policy::EndpointUrls& endpoints) { - using smart_objects::SmartObject; - PolicyAppIdComparator comparator(policy::kDefaultId); - policy::EndpointUrls::const_iterator it = - std::find_if(endpoints.begin(), endpoints.end(), comparator); - if (it == endpoints.end()) { - return; - } - SmartObject service_info = SmartObject(smart_objects::SmartType_Map); - for (size_t i = 0; i < (*it).url.size(); ++i) { - service_info[strings::url] = (*it).url[i]; - urls[i] = service_info; - } -} - -void GetUrls::ProcessPolicyServiceURLs(const policy::EndpointUrls& endpoints) { - LOG4CXX_AUTO_TRACE(logger_); - using namespace smart_objects; - using namespace application_manager; - using namespace strings; - using namespace hmi_apis; - - const uint32_t app_id_to_send_to = policy_handler_.GetAppIdForSending(); - - if (!app_id_to_send_to) { - LOG4CXX_ERROR(logger_, - "There are no available applications for processing."); - SmartObject urls(SmartType_Array); - FillSODefaultUrls(urls, endpoints); - if (!urls.empty()) { - (*message_)[msg_params][hmi_response::urls] = urls; - } - (*message_).erase(hmi_request::service); - SendResponseToHMI(Common_Result::SUCCESS); - return; - } - - ApplicationSharedPtr app = - application_manager_.application(app_id_to_send_to); - - if (app.use_count() == 0) { - LOG4CXX_WARN(logger_, - "There is no registered application with " - "connection key '" - << app_id_to_send_to << "'"); - SendResponseToHMI(Common_Result::DATA_NOT_AVAILABLE); - return; - } - - SmartObject& object = *message_; - object[msg_params].erase(hmi_request::service); - object[msg_params][hmi_response::urls] = SmartObject(SmartType_Array); - SmartObject& urls = object[msg_params][hmi_response::urls]; - const std::string mobile_app_id = app->policy_app_id(); - - size_t index = 0; - for (size_t i = 0; i < endpoints.size(); ++i) { - using namespace helpers; - - const bool to_add = Compare( - endpoints[i].app_id, mobile_app_id, policy::kDefaultId); - const bool is_default = policy::kDefaultId == endpoints[i].app_id; - - if (to_add) { - for (size_t k = 0; k < endpoints[i].url.size(); ++k) { - if (!is_default) { - urls[index][strings::app_id] = app_id_to_send_to; - } - urls[index][strings::url] = endpoints[i].url[k]; - ++index; - } - } - } - SendResponseToHMI(Common_Result::SUCCESS); - return; -} -#endif // PROPRIETARY_MODE - -} // namespace commands -} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/mixing_audio_supported_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/mixing_audio_supported_request.cc index 39f7e61c064..b8c61ca9027 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/mixing_audio_supported_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/mixing_audio_supported_request.cc @@ -59,4 +59,4 @@ void MixingAudioSupportedRequest::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/mixing_audio_supported_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/mixing_audio_supported_response.cc index 26fa967844b..089e56e598d 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/mixing_audio_supported_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/mixing_audio_supported_response.cc @@ -60,4 +60,4 @@ void MixingAudioSupportedResponse::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_alert_maneuver_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_alert_maneuver_request.cc index ae3695b68e6..8390fea5bc2 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_alert_maneuver_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_alert_maneuver_request.cc @@ -59,4 +59,4 @@ void NaviAlertManeuverRequest::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_alert_maneuver_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_alert_maneuver_response.cc index 6a6307038a3..a1603f069da 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_alert_maneuver_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_alert_maneuver_response.cc @@ -63,4 +63,4 @@ void NaviAlertManeuverResponse::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_audio_start_stream_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_audio_start_stream_request.cc index a9698d36ab6..371f47a759a 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_audio_start_stream_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_audio_start_stream_request.cc @@ -79,8 +79,8 @@ void AudioStartStreamRequest::Run() { application_manager_.application_by_hmi_app(application_id()); if (!app) { LOG4CXX_ERROR(logger_, - "Applcation with hmi_app_id " << application_id() - << " does not exist"); + "Application with hmi_app_id " << application_id() + << " does not exist"); return; } SetAllowedToTerminate(false); @@ -189,4 +189,4 @@ void AudioStartStreamRequest::RetryStartSession() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_audio_start_stream_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_audio_start_stream_response.cc index 362a46cc192..61d49577f66 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_audio_start_stream_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_audio_start_stream_response.cc @@ -60,4 +60,4 @@ void AudioStartStreamResponse::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_audio_stop_stream_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_audio_stop_stream_request.cc index ba2b8c8157c..a5d436f015c 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_audio_stop_stream_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_audio_stop_stream_request.cc @@ -62,4 +62,4 @@ void AudioStopStreamRequest::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_audio_stop_stream_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_audio_stop_stream_response.cc index 87ddc816960..98023ab571e 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_audio_stop_stream_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_audio_stop_stream_response.cc @@ -56,4 +56,4 @@ void AudioStopStreamResponse::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_get_way_points_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_get_way_points_request.cc index 77ef3e33694..edc4afe1e4c 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_get_way_points_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_get_way_points_request.cc @@ -59,4 +59,4 @@ void NaviGetWayPointsRequest::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_get_way_points_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_get_way_points_response.cc index 0aad5e5724b..0f0b652d01d 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_get_way_points_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_get_way_points_response.cc @@ -63,4 +63,4 @@ void NaviGetWayPointsResponse::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_is_ready_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_is_ready_request.cc index 781b8d30453..15e5b46b363 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_is_ready_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_is_ready_request.cc @@ -84,4 +84,4 @@ void NaviIsReadyRequest::on_event(const event_engine::Event& event) { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_is_ready_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_is_ready_response.cc index b4e64e2a3ef..073513eda95 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_is_ready_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_is_ready_response.cc @@ -58,4 +58,4 @@ void NaviIsReadyResponse::Run() { } } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_send_location_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_send_location_request.cc index a10f61310d9..360870e21cc 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_send_location_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_send_location_request.cc @@ -59,4 +59,4 @@ void NaviSendLocationRequest::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_send_location_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_send_location_response.cc index f93e2e17c31..dc60f2fbf0a 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_send_location_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_send_location_response.cc @@ -61,4 +61,4 @@ void NaviSendLocationResponse::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_set_video_config_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_set_video_config_request.cc index 5e4426bd20b..764315f37f7 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_set_video_config_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_set_video_config_request.cc @@ -65,9 +65,9 @@ void NaviSetVideoConfigRequest::Run() { ApplicationSharedPtr app = application_manager_.application_by_hmi_app(application_id()); if (!app) { - LOG4CXX_ERROR(logger_, - "Application with hmi_app_id " << application_id() - << "does not exist"); + LOG4CXX_ERROR( + logger_, + "Application with hmi_app_id " << application_id() << "does not exist"); return; } @@ -100,9 +100,9 @@ void NaviSetVideoConfigRequest::on_event(const event_engine::Event& event) { LOG4CXX_DEBUG(logger_, "Received SetVideoConfig success response"); result = true; } else { - LOG4CXX_DEBUG(logger_, - "Received SetVideoConfig failure response (" << event.id() - << ")"); + LOG4CXX_DEBUG( + logger_, + "Received SetVideoConfig failure response (" << event.id() << ")"); result = false; if (message[strings::msg_params].keyExists(strings::rejected_params)) { const smart_objects::SmartArray* list = @@ -153,4 +153,4 @@ void NaviSetVideoConfigRequest::onTimeOut() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_set_video_config_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_set_video_config_response.cc index c5f1c5307f0..e4a30c9da5c 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_set_video_config_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_set_video_config_response.cc @@ -61,4 +61,4 @@ void NaviSetVideoConfigResponse::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_show_constant_tbt_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_show_constant_tbt_request.cc index 22d604ab0da..95dd4561fcf 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_show_constant_tbt_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_show_constant_tbt_request.cc @@ -59,4 +59,4 @@ void NaviShowConstantTBTRequest::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_show_constant_tbt_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_show_constant_tbt_response.cc index d2ff26b6456..f73099d29ab 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_show_constant_tbt_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_show_constant_tbt_response.cc @@ -63,4 +63,4 @@ void NaviShowConstantTBTResponse::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_start_stream_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_start_stream_request.cc index f3d971acba8..90f7c2d0f10 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_start_stream_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_start_stream_request.cc @@ -64,8 +64,9 @@ NaviStartStreamRequest::NaviStartStreamRequest( } NaviStartStreamRequest::~NaviStartStreamRequest() { - // unsubscribe_from_all_events() in EventObserver's destructor isn't enough; - // we must unsubscribe before this NaviStartStreamRequest instance is removed + // unsubscribe_from_all_hmi_events() in EventObserver's destructor isn't + // enough; we must unsubscribe before this NaviStartStreamRequest instance is + // removed unsubscribe_from_event(hmi_apis::FunctionID::Navigation_StartStream); } @@ -79,9 +80,9 @@ void NaviStartStreamRequest::Run() { ApplicationSharedPtr app = application_manager_.application_by_hmi_app(application_id()); if (!app) { - LOG4CXX_ERROR(logger_, - "Applcation with hmi_app_id " << application_id() - << "does not exist"); + LOG4CXX_ERROR( + logger_, + "Application with hmi_app_id " << application_id() << "does not exist"); return; } SetAllowedToTerminate(false); @@ -190,4 +191,4 @@ void NaviStartStreamRequest::RetryStartSession() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_start_stream_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_start_stream_response.cc index f09a334f51e..eafd81148a6 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_start_stream_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_start_stream_response.cc @@ -60,4 +60,4 @@ void NaviStartStreamResponse::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_stop_stream_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_stop_stream_request.cc index 3e27692d62c..ad09b0aee10 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_stop_stream_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_stop_stream_request.cc @@ -62,4 +62,4 @@ void NaviStopStreamRequest::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_stop_stream_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_stop_stream_response.cc index 61b8d5a1e2d..ff8c0bddffc 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_stop_stream_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_stop_stream_response.cc @@ -56,4 +56,4 @@ void NaviStopStreamResponse::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_subscribe_way_points_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_subscribe_way_points_request.cc index a4445ebce8b..ba29f552b74 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_subscribe_way_points_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_subscribe_way_points_request.cc @@ -59,4 +59,4 @@ void NaviSubscribeWayPointsRequest::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_subscribe_way_points_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_subscribe_way_points_response.cc index ae5f236f6f4..ddf8f75e589 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_subscribe_way_points_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_subscribe_way_points_response.cc @@ -64,4 +64,4 @@ void NaviSubscribeWayPointsResponse::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_unsubscribe_way_points_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_unsubscribe_way_points_request.cc index ec22c93d8f5..d3c998cfdf9 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_unsubscribe_way_points_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_unsubscribe_way_points_request.cc @@ -59,4 +59,4 @@ void NaviUnsubscribeWayPointsRequest::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_unsubscribe_way_points_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_unsubscribe_way_points_response.cc index c084bd52d36..beed29e1e2c 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_unsubscribe_way_points_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_unsubscribe_way_points_response.cc @@ -32,8 +32,8 @@ #include "sdl_rpc_plugin/commands/hmi/navi_unsubscribe_way_points_response.h" #include "application_manager/event_engine/event.h" -#include "interfaces/MOBILE_API.h" #include "interfaces/HMI_API.h" +#include "interfaces/MOBILE_API.h" namespace sdl_rpc_plugin { using namespace application_manager; @@ -65,4 +65,4 @@ void NaviUnsubscribeWayPointsResponse::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_update_turn_list_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_update_turn_list_request.cc index 9c507c3637f..a8a258b1c0b 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_update_turn_list_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_update_turn_list_request.cc @@ -59,4 +59,4 @@ void NaviUpdateTurnListRequest::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_update_turn_list_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_update_turn_list_response.cc index eb232e6d01b..a2f737df38e 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_update_turn_list_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_update_turn_list_response.cc @@ -63,4 +63,4 @@ void NaviUpdateTurnListResponse::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_allow_sdl_functionality_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_allow_sdl_functionality_notification.cc index 398c2dac304..204cc7d347d 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_allow_sdl_functionality_notification.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_allow_sdl_functionality_notification.cc @@ -66,4 +66,4 @@ void OnAllowSDLFunctionalityNotification::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_app_activated_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_app_activated_notification.cc index 189596c58ae..e882020f8b7 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_app_activated_notification.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_app_activated_notification.cc @@ -64,4 +64,4 @@ void OnAppActivatedNotification::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_app_deactivated_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_app_deactivated_notification.cc index ee45f9bf1e8..18b796eaa81 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_app_deactivated_notification.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_app_deactivated_notification.cc @@ -66,4 +66,4 @@ void OnAppDeactivatedNotification::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_app_permission_changed_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_app_permission_changed_notification.cc index e13299ece7c..a1eb412c661 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_app_permission_changed_notification.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_app_permission_changed_notification.cc @@ -58,4 +58,4 @@ void OnAppPermissionChangedNotification::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_app_permission_consent_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_app_permission_consent_notification.cc index cf83c48a5a6..0033b392d22 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_app_permission_consent_notification.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_app_permission_consent_notification.cc @@ -32,12 +32,12 @@ */ #include "sdl_rpc_plugin/commands/hmi/on_app_permission_consent_notification.h" -#include "application_manager/application_manager.h" -#include "application_manager/policies/policy_handler.h" -#include "application_manager/message_helper.h" #include #include #include +#include "application_manager/application_manager.h" +#include "application_manager/message_helper.h" +#include "application_manager/policies/policy_handler.h" #include "policy/policy_types.h" #include "smart_objects/smart_object.h" @@ -178,5 +178,5 @@ void OnAppPermissionConsentNotification::Run() { policy_handler_.OnAppPermissionConsent(connection_key, permission_consent); #endif } -} // commands -} // namespace application_manager +} // namespace commands +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_app_registered_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_app_registered_notification.cc index 24c5a94272d..51c3125921e 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_app_registered_notification.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_app_registered_notification.cc @@ -64,4 +64,4 @@ void OnAppRegisteredNotification::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_app_unregistered_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_app_unregistered_notification.cc index 001b9fa5e09..07aadada810 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_app_unregistered_notification.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_app_unregistered_notification.cc @@ -73,4 +73,4 @@ void OnAppUnregisteredNotification::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_audio_data_streaming_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_audio_data_streaming_notification.cc index e2cd6d2cbfe..d9c11204094 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_audio_data_streaming_notification.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_audio_data_streaming_notification.cc @@ -58,4 +58,4 @@ void OnAudioDataStreamingNotification::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_bc_system_capability_updated_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_bc_system_capability_updated_notification.cc index 0677c97db8b..1a104c0fa1c 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_bc_system_capability_updated_notification.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_bc_system_capability_updated_notification.cc @@ -69,7 +69,8 @@ void OnBCSystemCapabilityUpdatedNotification::Run() { hmi_apis::Common_SystemCapabilityType::eType system_capability_type = static_cast( msg_params[strings::system_capability] - [strings::system_capability_type].asInt()); + [strings::system_capability_type] + .asInt()); switch (system_capability_type) { case hmi_apis::Common_SystemCapabilityType::NAVIGATION: { smart_objects::SmartObject nav_capability(smart_objects::SmartType_Map); @@ -134,21 +135,24 @@ void OnBCSystemCapabilityUpdatedNotification::Run() { for (size_t i = 0; i < updated_capabilities.length(); i++) { std::string service_id = updated_capabilities[i][strings::updated_app_service_record] - [strings::service_id].asString(); - auto matching_service_predicate = [&service_id]( - const smart_objects::SmartObject& app_service_capability) { - return service_id == - app_service_capability[strings::updated_app_service_record] - [strings::service_id].asString(); - }; + [strings::service_id] + .asString(); + auto matching_service_predicate = + [&service_id]( + const smart_objects::SmartObject& app_service_capability) { + return service_id == + app_service_capability[strings::updated_app_service_record] + [strings::service_id] + .asString(); + }; auto it = std::find_if(app_services->begin(), app_services->end(), matching_service_predicate); if (it != app_services->end()) { - LOG4CXX_DEBUG(logger_, - "Replacing updated record with service_id " - << service_id); + LOG4CXX_DEBUG( + logger_, + "Replacing updated record with service_id " << service_id); app_services->erase(it); } app_services->push_back(updated_capabilities[i]); @@ -157,6 +161,15 @@ void OnBCSystemCapabilityUpdatedNotification::Run() { [strings::app_services_capabilities] = app_service_caps; break; } + case mobile_apis::SystemCapabilityType::DISPLAYS: { + if (!hmi_capabilities_.system_display_capabilities()) { + LOG4CXX_INFO(logger_, "system_display_capabilities are not available"); + return; + } + msg_params[strings::system_capability][strings::display_capabilities] = + *hmi_capabilities_.system_display_capabilities(); + break; + } default: return; } @@ -164,4 +177,4 @@ void OnBCSystemCapabilityUpdatedNotification::Run() { } } // namespace commands -} // namespace app_service_rpc_plugin +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_bc_system_capability_updated_notification_from_hmi.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_bc_system_capability_updated_notification_from_hmi.cc new file mode 100644 index 00000000000..f32aef1102d --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_bc_system_capability_updated_notification_from_hmi.cc @@ -0,0 +1,145 @@ +/* + * Copyright (c) 2019, Ford Motor Company + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following + * disclaimer in the documentation and/or other materials provided with the + * distribution. + * + * Neither the name of the Ford Motor Company nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#include "sdl_rpc_plugin/commands/hmi/on_bc_system_capability_updated_notification_from_hmi.h" + +#include "application_manager/display_capabilities_builder.h" +#include "application_manager/message_helper.h" +#include "interfaces/HMI_API.h" +#include "interfaces/MOBILE_API.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +OnBCSystemCapabilityUpdatedNotificationFromHMI:: + OnBCSystemCapabilityUpdatedNotificationFromHMI( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : NotificationFromHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +OnBCSystemCapabilityUpdatedNotificationFromHMI:: + ~OnBCSystemCapabilityUpdatedNotificationFromHMI() {} + +OnBCSystemCapabilityUpdatedNotificationFromHMI:: + ProcessSystemDisplayCapabilitiesResult + OnBCSystemCapabilityUpdatedNotificationFromHMI:: + ProcessSystemDisplayCapabilities( + const smart_objects::SmartObject& display_capabilities) { + LOG4CXX_AUTO_TRACE(logger_); + + if (!(*message_)[strings::msg_params].keyExists(strings::app_id)) { + LOG4CXX_DEBUG(logger_, "Updating general display capabilities"); + hmi_capabilities_.set_system_display_capabilities(display_capabilities); + return ProcessSystemDisplayCapabilitiesResult::SUCCESS; + } + + const auto app_id = + (*message_)[strings::msg_params][strings::app_id].asUInt(); + auto app = application_manager_.application(app_id); + if (!app) { + LOG4CXX_ERROR(logger_, + "Application with app_id " << app_id << " is not registered"); + return ProcessSystemDisplayCapabilitiesResult::FAIL; + } + + LOG4CXX_DEBUG(logger_, "Updating display capabilities for app " << app_id); + app->set_display_capabilities(display_capabilities); + + // Remove app_id from notification to mobile + (*message_)[strings::params][strings::connection_key] = + (*message_)[strings::msg_params][strings::app_id]; + (*message_)[strings::msg_params].erase(strings::app_id); + if (app->is_resuming() && app->is_app_data_resumption_allowed()) { + LOG4CXX_DEBUG(logger_, "Application is resuming"); + app->display_capabilities_builder().UpdateDisplayCapabilities( + display_capabilities); + return ProcessSystemDisplayCapabilitiesResult::CAPABILITIES_CACHED; + } + + return ProcessSystemDisplayCapabilitiesResult::SUCCESS; +} + +void OnBCSystemCapabilityUpdatedNotificationFromHMI::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + // Prepare SmartObject for mobile factory + (*message_)[strings::params][strings::function_id] = static_cast( + mobile_apis::FunctionID::OnSystemCapabilityUpdatedID); + + const auto& system_capability = + (*message_)[strings::msg_params][strings::system_capability]; + + switch (system_capability[strings::system_capability_type].asInt()) { + case mobile_apis::SystemCapabilityType::DISPLAYS: { + if (system_capability.keyExists(strings::display_capabilities)) { + const auto result = ProcessSystemDisplayCapabilities( + system_capability[strings::display_capabilities]); + if (ProcessSystemDisplayCapabilitiesResult::FAIL == result) { + LOG4CXX_ERROR( + logger_, + "Failed to process display capabilities. Notification will " + "be ignored"); + return; + } else if (ProcessSystemDisplayCapabilitiesResult:: + CAPABILITIES_CACHED == result) { + LOG4CXX_TRACE(logger_, + "Capabilities are being cached for resuming app"); + return; + } + } + break; + } + case mobile_apis::SystemCapabilityType::REMOTE_CONTROL: { + if (system_capability.keyExists(strings::rc_capability)) { + LOG4CXX_DEBUG(logger_, "Updating RC Capabilities"); + hmi_capabilities_.set_rc_capability( + system_capability[strings::rc_capability]); + } + break; + } + } + + SendNotificationToMobile(message_); +} + +} // namespace commands + +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_button_event_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_button_event_notification.cc index 1f052b865bc..f25e6202cd8 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_button_event_notification.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_button_event_notification.cc @@ -67,4 +67,4 @@ void OnButtonEventNotification::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_button_press_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_button_press_notification.cc index 6c5d8f5a43e..fee6b1b4850 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_button_press_notification.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_button_press_notification.cc @@ -33,8 +33,8 @@ #include "sdl_rpc_plugin/commands/hmi/on_button_press_notification.h" #include "application_manager/application_impl.h" -#include "utils/logger.h" #include "application_manager/event_engine/event.h" +#include "utils/logger.h" namespace sdl_rpc_plugin { using namespace application_manager; @@ -69,4 +69,4 @@ void OnButtonPressNotification::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_button_subscription_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_button_subscription_notification.cc index 70ff1c3fad4..4ac752d6c51 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_button_subscription_notification.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_button_subscription_notification.cc @@ -63,4 +63,4 @@ void OnButtonSubscriptionNotification::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_device_chosen_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_device_chosen_notification.cc index 2c4f9a1cccc..f27c1fe5e5d 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_device_chosen_notification.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_device_chosen_notification.cc @@ -63,4 +63,4 @@ void OnDeviceChosenNotification::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_device_state_changed_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_device_state_changed_notification.cc index 307dccd09bf..129ba8c9ba5 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_device_state_changed_notification.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_device_state_changed_notification.cc @@ -30,12 +30,13 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include #include "sdl_rpc_plugin/commands/hmi/on_device_state_changed_notification.h" +#include #include "application_manager/application_manager.h" #include "application_manager/message_helper.h" -#include "interfaces/HMI_API.h" +#include "application_manager/policies/policy_handler_interface.h" #include "encryption/hashing.h" +#include "interfaces/HMI_API.h" namespace { // TODO(AOleynik) : replace this !!! @@ -72,7 +73,7 @@ std::string convert_to_bt_mac(std::string& deviceInternalId) { return bt_mac; } -} +} // namespace namespace sdl_rpc_plugin { using namespace application_manager; @@ -121,4 +122,4 @@ void OnDeviceStateChangedNotification::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_driver_distraction_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_driver_distraction_notification.cc index a5fb9b206e6..a743c586721 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_driver_distraction_notification.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_driver_distraction_notification.cc @@ -30,13 +30,14 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include #include "sdl_rpc_plugin/commands/hmi/on_driver_distraction_notification.h" +#include #include "application_manager/application_impl.h" #include "application_manager/message_helper.h" -#include "interfaces/MOBILE_API.h" +#include "application_manager/policies/policy_handler_interface.h" #include "interfaces/HMI_API.h" +#include "interfaces/MOBILE_API.h" namespace sdl_rpc_plugin { using namespace application_manager; @@ -59,12 +60,39 @@ struct OnDriverDistractionProcessor { void operator()(ApplicationSharedPtr application) { if (application) { - (*on_driver_distraction_so_)[strings::params][strings::connection_key] = - application->app_id(); + // Create modifiable copy of base message + smart_objects::SmartObject message = *on_driver_distraction_so_; + message[strings::params][strings::connection_key] = application->app_id(); const RPCParams params; policy::CheckPermissionResult result; application_manager_.GetPolicyHandler().CheckPermissions( - application, stringified_function_id_, params, result); + application, + mobile_apis::PredefinedWindows::DEFAULT_WINDOW, + stringified_function_id_, + params, + result); + auto& msg_params = message[strings::msg_params]; + const bool is_lock_screen_dismissal_exists = msg_params.keyExists( + mobile_notification::lock_screen_dismissal_enabled); + + if (is_lock_screen_dismissal_exists && + msg_params[mobile_notification::lock_screen_dismissal_enabled] + .asBool()) { + const auto language = + MessageHelper::MobileLanguageToString(application->ui_language()); + + const auto warning_message = + application_manager_.GetPolicyHandler() + .LockScreenDismissalWarningMessage(language); + // Only allow lock screen dismissal if a warning message is available + if (warning_message && !warning_message->empty()) { + msg_params[mobile_notification::lock_screen_dismissal_warning] = + *warning_message; + } else { + msg_params[mobile_notification::lock_screen_dismissal_enabled] = + false; + } + } if (result.hmi_level_permitted != policy::kRpcAllowed) { MobileMessageQueue messages; application->SwapMobileMessageQueue(messages); @@ -72,15 +100,19 @@ struct OnDriverDistractionProcessor { std::remove_if( messages.begin(), messages.end(), - [this](smart_objects::SmartObjectSPtr message) { + [](smart_objects::SmartObjectSPtr message) { return (*message)[strings::params][strings::function_id] - .asString() == stringified_function_id_; + .asUInt() == + mobile_api::FunctionID::OnDriverDistractionID; }), messages.end()); - application->PushMobileMessage(on_driver_distraction_so_); + application->SwapMobileMessageQueue(messages); + application->PushMobileMessage( + std::make_shared(message)); return; } - command_.SendNotificationToMobile(on_driver_distraction_so_); + command_.SendNotificationToMobile( + std::make_shared(message)); } } @@ -90,7 +122,7 @@ struct OnDriverDistractionProcessor { ApplicationManager& application_manager_; std::string stringified_function_id_; }; -} +} // namespace OnDriverDistractionNotification::OnDriverDistractionNotification( const application_manager::commands::MessageSharedPtr& message, @@ -108,14 +140,12 @@ OnDriverDistractionNotification::~OnDriverDistractionNotification() {} void OnDriverDistractionNotification::Run() { LOG4CXX_AUTO_TRACE(logger_); - const hmi_apis::Common_DriverDistractionState::eType state = + const auto state = static_cast( (*message_)[strings::msg_params][hmi_notification::state].asInt()); application_manager_.set_driver_distraction_state(state); - smart_objects::SmartObjectSPtr on_driver_distraction = - std::make_shared(); - + auto on_driver_distraction = std::make_shared(); if (!on_driver_distraction) { LOG4CXX_ERROR(logger_, "NULL pointer"); return; @@ -127,6 +157,17 @@ void OnDriverDistractionNotification::Run() { (*on_driver_distraction)[strings::msg_params][mobile_notification::state] = state; + const auto lock_screen_dismissal = + application_manager_.GetPolicyHandler().LockScreenDismissalEnabledState(); + + if (lock_screen_dismissal && + hmi_apis::Common_DriverDistractionState::DD_ON == state) { + (*on_driver_distraction) + [strings::msg_params] + [mobile_notification::lock_screen_dismissal_enabled] = + *lock_screen_dismissal; + } + const ApplicationSet applications = application_manager_.applications().GetData(); @@ -139,4 +180,4 @@ void OnDriverDistractionNotification::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_event_changed_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_event_changed_notification.cc index cd3f2c23e6e..f6ea22ae34b 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_event_changed_notification.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_event_changed_notification.cc @@ -61,4 +61,4 @@ void OnEventChangedNotification::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_exit_all_applications_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_exit_all_applications_notification.cc index 9d250d288e4..4c168f9eff9 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_exit_all_applications_notification.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_exit_all_applications_notification.cc @@ -32,13 +32,13 @@ #include "sdl_rpc_plugin/commands/hmi/on_exit_all_applications_notification.h" +#include #include #include -#include #include "application_manager/application_manager.h" -#include "application_manager/rpc_service.h" #include "application_manager/resumption/resume_ctrl.h" +#include "application_manager/rpc_service.h" #include "interfaces/HMI_API.h" namespace sdl_rpc_plugin { @@ -122,4 +122,4 @@ void OnExitAllApplicationsNotification::SendOnSDLPersistenceComplete() { } } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_exit_application_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_exit_application_notification.cc index 6658f410056..3eec6c5d1aa 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_exit_application_notification.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_exit_application_notification.cc @@ -33,11 +33,11 @@ #include "sdl_rpc_plugin/commands/hmi/on_exit_application_notification.h" #include "application_manager/application_impl.h" -#include "application_manager/state_controller.h" #include "application_manager/message_helper.h" #include "application_manager/rpc_service.h" -#include "interfaces/MOBILE_API.h" +#include "application_manager/state_controller.h" #include "interfaces/HMI_API.h" +#include "interfaces/MOBILE_API.h" namespace sdl_rpc_plugin { using namespace application_manager; @@ -119,14 +119,9 @@ void OnExitApplicationNotification::Run() { } } - application_manager_.state_controller().SetRegularState( - app_impl, - HMILevel::HMI_NONE, - AudioStreamingState::NOT_AUDIBLE, - VideoStreamingState::NOT_STREAMABLE, - false); + application_manager_.state_controller().ExitDefaultWindow(app_impl); } } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_file_removed_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_file_removed_notification.cc index ec680c667dd..e1f0e2b1047 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_file_removed_notification.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_file_removed_notification.cc @@ -59,4 +59,4 @@ void OnFileRemovedNotification::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_find_applications.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_find_applications.cc index c74dd70c848..2e8f15387fb 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_find_applications.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_find_applications.cc @@ -59,4 +59,4 @@ void OnFindApplications::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_ignition_cycle_over_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_ignition_cycle_over_notification.cc index 9ff1851e3f7..1e8da19c0aa 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_ignition_cycle_over_notification.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_ignition_cycle_over_notification.cc @@ -32,6 +32,7 @@ #include "sdl_rpc_plugin/commands/hmi/on_ignition_cycle_over_notification.h" #include "application_manager/application_manager.h" +#include "application_manager/policies/policy_handler_interface.h" namespace sdl_rpc_plugin { using namespace application_manager; @@ -59,4 +60,4 @@ void OnIgnitionCycleOverNotification::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_navi_tbt_client_state_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_navi_tbt_client_state_notification.cc index 20f20ece08b..f611b817643 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_navi_tbt_client_state_notification.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_navi_tbt_client_state_notification.cc @@ -64,4 +64,4 @@ void OnNaviTBTClientStateNotification::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_navi_way_point_change_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_navi_way_point_change_notification.cc index fa8819ca5b8..2a1a9c29fb9 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_navi_way_point_change_notification.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_navi_way_point_change_notification.cc @@ -60,4 +60,4 @@ void OnNaviWayPointChangeNotification::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_policy_update.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_policy_update.cc index e069bea7404..a0e75371b53 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_policy_update.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_policy_update.cc @@ -32,6 +32,7 @@ #include "sdl_rpc_plugin/commands/hmi/on_policy_update.h" #include "application_manager/application_manager.h" +#include "application_manager/policies/policy_handler_interface.h" namespace sdl_rpc_plugin { using namespace application_manager; @@ -57,4 +58,4 @@ void OnPolicyUpdate::Run() { } } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_put_file_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_put_file_notification.cc index 1524aa9ea26..441e36a3858 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_put_file_notification.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_put_file_notification.cc @@ -59,4 +59,4 @@ void OnPutFileNotification::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_ready_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_ready_notification.cc index 76c9115662b..da3612b043a 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_ready_notification.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_ready_notification.cc @@ -62,4 +62,4 @@ void OnReadyNotification::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_received_policy_update.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_received_policy_update.cc index 1eaef0b5e1a..b2c9151b403 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_received_policy_update.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_received_policy_update.cc @@ -30,9 +30,10 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include #include "sdl_rpc_plugin/commands/hmi/on_received_policy_update.h" +#include #include "application_manager/application_manager.h" +#include "application_manager/policies/policy_handler_interface.h" #include "utils/file_system.h" namespace sdl_rpc_plugin { @@ -74,4 +75,4 @@ void OnReceivedPolicyUpdate::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_record_start_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_record_start_notification.cc index 60699e5b9ca..dbef717539d 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_record_start_notification.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_record_start_notification.cc @@ -59,4 +59,4 @@ void OnRecordStartdNotification::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_resume_audio_source_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_resume_audio_source_notification.cc index 9f8a713ffec..11d549655e2 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_resume_audio_source_notification.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_resume_audio_source_notification.cc @@ -59,4 +59,4 @@ void OnResumeAudioSourceNotification::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_sdl_close_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_sdl_close_notification.cc index 65879edce60..d0c584c66c4 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_sdl_close_notification.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_sdl_close_notification.cc @@ -59,4 +59,4 @@ void OnSDLCloseNotification::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_sdl_consent_needed_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_sdl_consent_needed_notification.cc index cf8feb4ca19..314a9e8f710 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_sdl_consent_needed_notification.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_sdl_consent_needed_notification.cc @@ -59,4 +59,4 @@ void OnSDLConsentNeededNotification::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_sdl_persistence_complete_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_sdl_persistence_complete_notification.cc index 0ac4afd4d29..5db38d070b3 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_sdl_persistence_complete_notification.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_sdl_persistence_complete_notification.cc @@ -58,4 +58,4 @@ void OnSDLPersistenceCompleteNotification::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_service_update_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_service_update_notification.cc new file mode 100644 index 00000000000..de03b752140 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_service_update_notification.cc @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2019, Ford Motor Company + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following + * disclaimer in the documentation and/or other materials provided with the + * distribution. + * + * Neither the name of the Ford Motor Company nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#include "sdl_rpc_plugin/commands/hmi/on_service_update_notification.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +namespace hmi { + +OnServiceUpdateNotification::OnServiceUpdateNotification( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handler) + : NotificationToHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handler) {} + +OnServiceUpdateNotification::~OnServiceUpdateNotification() {} + +void OnServiceUpdateNotification::Run() { + LOG4CXX_AUTO_TRACE(logger_); + SendNotification(); +} + +} // namespace hmi +} // namespace commands +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_start_device_discovery.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_start_device_discovery.cc index 2cee7926bd7..035def10e0b 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_start_device_discovery.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_start_device_discovery.cc @@ -59,4 +59,4 @@ void OnStartDeviceDiscovery::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_status_update_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_status_update_notification.cc index 4cb01e7e90a..5ee2ede198b 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_status_update_notification.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_status_update_notification.cc @@ -58,4 +58,4 @@ void OnStatusUpdateNotification::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_system_context_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_system_context_notification.cc index 242fb1d8cda..bf52492ae13 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_system_context_notification.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_system_context_notification.cc @@ -33,8 +33,8 @@ #include "sdl_rpc_plugin/commands/hmi/on_system_context_notification.h" #include "application_manager/application_impl.h" -#include "application_manager/state_controller.h" #include "application_manager/message_helper.h" +#include "application_manager/state_controller.h" namespace sdl_rpc_plugin { using namespace application_manager; @@ -62,13 +62,27 @@ void OnSystemContextNotification::Run() { (*message_)[strings::msg_params][hmi_notification::system_context] .asInt()); + WindowID window_id = mobile_apis::PredefinedWindows::DEFAULT_WINDOW; + if ((*message_)[strings::msg_params].keyExists(strings::window_id)) { + window_id = (*message_)[strings::msg_params][strings::window_id].asInt(); + } + ApplicationSharedPtr app; - if ((mobile_api::SystemContext::SYSCTXT_VRSESSION == system_context) || - (mobile_api::SystemContext::SYSCTXT_MENU == system_context) || - (mobile_api::SystemContext::SYSCTXT_HMI_OBSCURED == system_context)) { + if (helpers:: + Compare( + system_context, + mobile_api::SystemContext::SYSCTXT_VRSESSION, + mobile_api::SystemContext::SYSCTXT_MENU, + mobile_api::SystemContext::SYSCTXT_HMI_OBSCURED)) { app = application_manager_.active_application(); - } else if ((mobile_api::SystemContext::SYSCTXT_ALERT == system_context) || - (mobile_api::SystemContext::SYSCTXT_MAIN == system_context)) { + } + + if (mobile_apis::PredefinedWindows::DEFAULT_WINDOW != window_id || + helpers::Compare(system_context, + mobile_api::SystemContext::SYSCTXT_ALERT, + mobile_api::SystemContext::SYSCTXT_MAIN)) { if ((*message_)[strings::msg_params].keyExists(strings::app_id)) { app = application_manager_.application( (*message_)[strings::msg_params][strings::app_id].asUInt()); @@ -76,8 +90,8 @@ void OnSystemContextNotification::Run() { } if (app && mobile_api::SystemContext::INVALID_ENUM != system_context) { - application_manager_.state_controller().SetRegularState(app, - system_context); + application_manager_.state_controller().SetRegularState( + app, window_id, system_context); } else { LOG4CXX_ERROR(logger_, "Application does not exist"); } @@ -85,4 +99,4 @@ void OnSystemContextNotification::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_system_error_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_system_error_notification.cc index 5591d593550..9b8523e882a 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_system_error_notification.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_system_error_notification.cc @@ -32,6 +32,7 @@ #include "sdl_rpc_plugin/commands/hmi/on_system_error_notification.h" #include "application_manager/application_manager.h" +#include "application_manager/policies/policy_handler_interface.h" #include "interfaces/HMI_API.h" namespace sdl_rpc_plugin { @@ -64,4 +65,4 @@ void OnSystemErrorNotification::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_system_info_changed_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_system_info_changed_notification.cc index 11b24712945..171c1440550 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_system_info_changed_notification.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_system_info_changed_notification.cc @@ -33,6 +33,7 @@ #include "sdl_rpc_plugin/commands/hmi/on_system_info_changed_notification.h" #include "application_manager/application_manager.h" #include "application_manager/message_helper.h" +#include "application_manager/policies/policy_handler_interface.h" namespace sdl_rpc_plugin { using namespace application_manager; @@ -66,4 +67,4 @@ void OnSystemInfoChangedNotification::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_system_request_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_system_request_notification.cc index d7958967646..6d95febe712 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_system_request_notification.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_system_request_notification.cc @@ -32,11 +32,15 @@ #include "application_manager/application_impl.h" -#include "sdl_rpc_plugin/commands/hmi/on_system_request_notification.h" #include "application_manager/policies/policy_handler_interface.h" #include "interfaces/MOBILE_API.h" +#include "sdl_rpc_plugin/commands/hmi/on_system_request_notification.h" #include "utils/macro.h" +#ifdef EXTERNAL_PROPRIETARY_MODE +#include "policy/ptu_retry_handler.h" +#endif // EXTERNAL_PROPRIETARY_MODE + using policy::PolicyHandlerInterface; namespace sdl_rpc_plugin { @@ -116,9 +120,20 @@ void OnSystemRequestNotification::Run() { "Sending request with application id " << app->policy_app_id()); params[strings::connection_key] = app->app_id(); + +#ifdef EXTERNAL_PROPRIETARY_MODE + using namespace rpc::policy_table_interface_base; + const auto request_type = + static_cast( + (*message_)[strings::msg_params][strings::request_type].asUInt()); + + if (RequestType::RT_PROPRIETARY == request_type) { + policy_handler_.ptu_retry_handler().OnSystemRequestReceived(); + } +#endif SendNotificationToMobile(message_); } } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_system_time_ready_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_system_time_ready_notification.cc index b5fd1a007ef..b0688355456 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_system_time_ready_notification.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_system_time_ready_notification.cc @@ -59,4 +59,4 @@ void OnSystemTimeReadyNotification::Run() { } } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_tts_language_change_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_tts_language_change_notification.cc index 5b5cfeefb14..f89baad7373 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_tts_language_change_notification.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_tts_language_change_notification.cc @@ -100,4 +100,4 @@ void OnTTSLanguageChangeNotification::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_tts_reset_timeout_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_tts_reset_timeout_notification.cc index 701dbe0538b..8b60762b31b 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_tts_reset_timeout_notification.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_tts_reset_timeout_notification.cc @@ -66,4 +66,4 @@ void OnTTSResetTimeoutNotification::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_tts_started_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_tts_started_notification.cc index 34ba82df1d7..2d215b2ec9c 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_tts_started_notification.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_tts_started_notification.cc @@ -60,4 +60,4 @@ void OnTTSStartedNotification::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_tts_stopped_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_tts_stopped_notification.cc index 0935a36848a..6910b188f29 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_tts_stopped_notification.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_tts_stopped_notification.cc @@ -63,4 +63,4 @@ void OnTTSStoppedNotification::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_ui_command_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_ui_command_notification.cc index 21cf0d96282..6cc9f85d6f0 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_ui_command_notification.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_ui_command_notification.cc @@ -65,4 +65,4 @@ void OnUICommandNotification::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_ui_keyboard_input_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_ui_keyboard_input_notification.cc index fbdd4fce2b4..f069e4ed65d 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_ui_keyboard_input_notification.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_ui_keyboard_input_notification.cc @@ -67,4 +67,4 @@ void OnUIKeyBoardInputNotification::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_ui_language_change_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_ui_language_change_notification.cc index 3bf5a5aed4c..697b2036c4b 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_ui_language_change_notification.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_ui_language_change_notification.cc @@ -99,4 +99,4 @@ void OnUILanguageChangeNotification::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_ui_reset_timeout_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_ui_reset_timeout_notification.cc index 953932cdb62..bd1e1b8ea7f 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_ui_reset_timeout_notification.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_ui_reset_timeout_notification.cc @@ -67,4 +67,4 @@ void OnUIResetTimeoutNotification::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_ui_touch_event_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_ui_touch_event_notification.cc index e5b321e1ffb..193c3666d2b 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_ui_touch_event_notification.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_ui_touch_event_notification.cc @@ -67,4 +67,4 @@ void OnUITouchEventNotification::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_update_device_list.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_update_device_list.cc index 2a5e6ba7971..e6275adab24 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_update_device_list.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_update_device_list.cc @@ -56,4 +56,4 @@ void OnUpdateDeviceList::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_acc_pedal_position_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_acc_pedal_position_notification.cc index c8ecba458a9..99c6520feef 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_acc_pedal_position_notification.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_acc_pedal_position_notification.cc @@ -64,4 +64,4 @@ void OnVIAccPedalPositionNotification::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_belt_status_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_belt_status_notification.cc index ee909d19dc3..dbfd9487e3d 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_belt_status_notification.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_belt_status_notification.cc @@ -64,4 +64,4 @@ void OnVIBeltStatusNotification::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_body_information_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_body_information_notification.cc index f0386646ced..b8e66b9c0f5 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_body_information_notification.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_body_information_notification.cc @@ -64,4 +64,4 @@ void OnVIBodyInformationNotification::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_device_status_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_device_status_notification.cc index 549c73065a1..418c751d1cb 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_device_status_notification.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_device_status_notification.cc @@ -64,4 +64,4 @@ void OnVIDeviceStatusNotification::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_driver_braking_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_driver_braking_notification.cc index 23f0d370685..29545fcd874 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_driver_braking_notification.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_driver_braking_notification.cc @@ -64,4 +64,4 @@ void OnVIDriverBrakingNotification::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_engine_torque_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_engine_torque_notification.cc index 735a2252253..4c2fb944002 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_engine_torque_notification.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_engine_torque_notification.cc @@ -64,4 +64,4 @@ void OnVIEngineTorqueNotification::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_external_temperature_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_external_temperature_notification.cc index 0b4bfa893fa..6ac26a74fc9 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_external_temperature_notification.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_external_temperature_notification.cc @@ -64,4 +64,4 @@ void OnVIExternalTemperatureNotification::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_fuel_level_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_fuel_level_notification.cc index a5e84f11080..1f1cad5b8b4 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_fuel_level_notification.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_fuel_level_notification.cc @@ -64,4 +64,4 @@ void OnVIFuelLevelNotification::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_fuel_level_state_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_fuel_level_state_notification.cc index 950b5a36f1e..31c80860fde 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_fuel_level_state_notification.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_fuel_level_state_notification.cc @@ -64,4 +64,4 @@ void OnVIFuelLevelStateNotification::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_gps_data_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_gps_data_notification.cc index 0d94194f763..43ae3524ad7 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_gps_data_notification.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_gps_data_notification.cc @@ -64,4 +64,4 @@ void OnVIGpsDataNotification::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_head_lamp_status_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_head_lamp_status_notification.cc index 80edb88e387..282a173b69b 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_head_lamp_status_notification.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_head_lamp_status_notification.cc @@ -64,4 +64,4 @@ void OnVIHeadLampStatusNotification::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_instant_fuel_consumption_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_instant_fuel_consumption_notification.cc index a2b0b1a8fda..f9bb3eca3f2 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_instant_fuel_consumption_notification.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_instant_fuel_consumption_notification.cc @@ -65,4 +65,4 @@ void OnVIInstantFuelConsumptionNotification::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_my_key_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_my_key_notification.cc index 5e3555bbc41..8f5e845c02b 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_my_key_notification.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_my_key_notification.cc @@ -64,4 +64,4 @@ void OnVIMyKeyNotification::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_odometer_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_odometer_notification.cc index 1dbef77fa37..ea5d8be9ca7 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_odometer_notification.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_odometer_notification.cc @@ -64,4 +64,4 @@ void OnVIOdometerNotification::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_prndl_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_prndl_notification.cc index d4ae93b324f..73231ff4de6 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_prndl_notification.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_prndl_notification.cc @@ -64,4 +64,4 @@ void OnVIPrndlNotification::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_rpm_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_rpm_notification.cc index 77f694c92ea..4587939b8fb 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_rpm_notification.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_rpm_notification.cc @@ -64,4 +64,4 @@ void OnVIRpmNotification::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_speed_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_speed_notification.cc index e5860c9eec3..df0bfd5cd77 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_speed_notification.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_speed_notification.cc @@ -64,4 +64,4 @@ void OnVISpeedNotification::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_steering_wheel_angle_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_steering_wheel_angle_notification.cc index db591d9da3b..b7eaad7edf0 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_steering_wheel_angle_notification.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_steering_wheel_angle_notification.cc @@ -64,4 +64,4 @@ void OnVISteeringWheelAngleNotification::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_tire_pressure_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_tire_pressure_notification.cc index b5c7e188032..5f438ef8d1c 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_tire_pressure_notification.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_tire_pressure_notification.cc @@ -64,4 +64,4 @@ void OnVITirePressureNotification::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_vin_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_vin_notification.cc index 323fe5b8853..1b40da4c406 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_vin_notification.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_vin_notification.cc @@ -64,4 +64,4 @@ void OnVIVinNotification::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_wiper_status_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_wiper_status_notification.cc index 6a3b863e7c0..7221e88ef16 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_wiper_status_notification.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_wiper_status_notification.cc @@ -64,4 +64,4 @@ void OnVIWiperStatusNotification::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_video_data_streaming_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_video_data_streaming_notification.cc index 701dee53854..7d5c0165aab 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_video_data_streaming_notification.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_video_data_streaming_notification.cc @@ -59,4 +59,4 @@ void OnVideoDataStreamingNotification::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vr_command_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vr_command_notification.cc index 386ef1d1c79..c4678f69e00 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vr_command_notification.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vr_command_notification.cc @@ -32,13 +32,13 @@ #include "sdl_rpc_plugin/commands/hmi/on_vr_command_notification.h" -#include "application_manager/policies/policy_handler.h" #include "application_manager/message_helper.h" +#include "application_manager/policies/policy_handler.h" #include "application_manager/state_controller.h" -#include "interfaces/MOBILE_API.h" -#include "interfaces/HMI_API.h" #include "application_manager/event_engine/event.h" +#include "interfaces/HMI_API.h" +#include "interfaces/MOBILE_API.h" namespace sdl_rpc_plugin { using namespace application_manager; @@ -65,14 +65,17 @@ void OnVRCommandNotification::Run() { (*message_)[strings::msg_params][strings::cmd_id].asUInt(); uint32_t max_cmd_id = application_manager_.get_settings().max_cmd_id(); - // Check if this is one of standart VR commands (i.e. "Help") + // Check if this is one of standard VR commands (i.e. "Help") if (cmd_id > max_cmd_id + 1) { LOG4CXX_INFO(logger_, "Switched App"); const uint32_t app_id = cmd_id - max_cmd_id; ApplicationSharedPtr app = application_manager_.application(app_id); if (app) { application_manager_.state_controller().SetRegularState( - app, mobile_apis::HMILevel::HMI_FULL, true); + app, + mobile_apis::PredefinedWindows::DEFAULT_WINDOW, + mobile_apis::HMILevel::HMI_FULL, + true); } else { LOG4CXX_ERROR(logger_, "Unable to find appication " << app_id); } @@ -110,4 +113,4 @@ void OnVRCommandNotification::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vr_language_change_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vr_language_change_notification.cc index 6a58ab9ffad..c308af9b922 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vr_language_change_notification.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vr_language_change_notification.cc @@ -33,9 +33,9 @@ #include "sdl_rpc_plugin/commands/hmi/on_vr_language_change_notification.h" #include "application_manager/application_impl.h" -#include "application_manager/state_controller.h" #include "application_manager/message_helper.h" #include "application_manager/rpc_service.h" +#include "application_manager/state_controller.h" #include "interfaces/MOBILE_API.h" namespace sdl_rpc_plugin { @@ -83,7 +83,10 @@ void OnVRLanguageChangeNotification::Run() { if (static_cast(app->language()) != (*message_)[strings::msg_params][strings::language].asInt()) { application_manager_.state_controller().SetRegularState( - app, mobile_api::HMILevel::HMI_NONE, false); + app, + mobile_apis::PredefinedWindows::DEFAULT_WINDOW, + mobile_apis::HMILevel::HMI_NONE, + false); rpc_service_.ManageMobileCommand( MessageHelper::GetOnAppInterfaceUnregisteredNotificationToMobile( @@ -98,4 +101,4 @@ void OnVRLanguageChangeNotification::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vr_started_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vr_started_notification.cc index 04eb9a9ed06..bfc033a865c 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vr_started_notification.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vr_started_notification.cc @@ -61,4 +61,4 @@ void OnVRStartedNotification::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vr_stopped_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vr_stopped_notification.cc index 8fea5ddd1cf..ede1efab851 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vr_stopped_notification.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vr_stopped_notification.cc @@ -61,4 +61,4 @@ void OnVRStoppedNotification::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/rc_get_capabilities_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/rc_get_capabilities_request.cc index 5947454517c..d8ad6087a6e 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/rc_get_capabilities_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/rc_get_capabilities_request.cc @@ -59,4 +59,4 @@ void RCGetCapabilitiesRequest::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/rc_get_capabilities_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/rc_get_capabilities_response.cc index b14c28426c7..128b111c5ed 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/rc_get_capabilities_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/rc_get_capabilities_response.cc @@ -54,16 +54,26 @@ void RCGetCapabilitiesResponse::Run() { LOG4CXX_AUTO_TRACE(logger_); HMICapabilities& hmi_capabilities = hmi_capabilities_; - bool capability_exists = + bool rc_capability_exists = (*message_)[strings::msg_params].keyExists(strings::rc_capability); - if (capability_exists) { + if (rc_capability_exists) { hmi_capabilities.set_rc_capability( (*message_)[strings::msg_params][strings::rc_capability]); } - hmi_capabilities.set_rc_supported(capability_exists); + + bool seat_location_capability_exists = + (*message_)[strings::msg_params].keyExists( + strings::seat_location_capability); + + if (seat_location_capability_exists) { + hmi_capabilities.set_seat_location_capability( + (*message_)[strings::msg_params][strings::seat_location_capability]); + } + + hmi_capabilities.set_rc_supported(rc_capability_exists); } } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/rc_is_ready_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/rc_is_ready_request.cc index d538878dc8a..5e4af1503aa 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/rc_is_ready_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/rc_is_ready_request.cc @@ -105,4 +105,4 @@ void RCIsReadyRequest::SendMessageToHMI() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/rc_is_ready_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/rc_is_ready_response.cc index 75345672044..71e16a831c2 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/rc_is_ready_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/rc_is_ready_response.cc @@ -58,4 +58,4 @@ void RCIsReadyResponse::Run() { } } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_activate_app_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_activate_app_request.cc index 92a7020208b..13690809bb1 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_activate_app_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_activate_app_request.cc @@ -31,8 +31,9 @@ */ #include "sdl_rpc_plugin/commands/hmi/sdl_activate_app_request.h" -#include "application_manager/state_controller.h" #include "application_manager/message_helper.h" +#include "application_manager/policies/policy_handler_interface.h" +#include "application_manager/state_controller.h" namespace sdl_rpc_plugin { using namespace application_manager; @@ -45,8 +46,7 @@ struct ProtoV4AppsOnDevice : std::unary_function { ProtoV4AppsOnDevice(const connection_handler::DeviceHandle handle) : handle_(handle) {} bool operator()(const ApplicationSharedPtr app) const { - return app - ? handle_ == app->device() && + return app ? handle_ == app->device() && Message::is_sufficient_version( protocol_handler::MajorProtocolVersion:: PROTOCOL_VERSION_4, @@ -80,7 +80,7 @@ struct SendLaunchApp return; } }; -} +} // namespace SDLActivateAppRequest::SDLActivateAppRequest( const application_manager::commands::MessageSharedPtr& message, @@ -317,4 +317,4 @@ ApplicationSharedPtr SDLActivateAppRequest::get_foreground_app( } } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_activate_app_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_activate_app_response.cc index 3262b12759e..560b75213c0 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_activate_app_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_activate_app_response.cc @@ -61,4 +61,4 @@ void SDLActivateAppResponse::Run() { } } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_get_list_of_permissions_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_get_list_of_permissions_request.cc index 6b983d566a8..c8266e0f39f 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_get_list_of_permissions_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_get_list_of_permissions_request.cc @@ -32,6 +32,7 @@ #include "sdl_rpc_plugin/commands/hmi/sdl_get_list_of_permissions_request.h" #include "application_manager/application_manager.h" +#include "application_manager/policies/policy_handler_interface.h" namespace sdl_rpc_plugin { using namespace application_manager; @@ -64,4 +65,4 @@ void SDLGetListOfPermissionsRequest::Run() { } } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_get_list_of_permissions_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_get_list_of_permissions_response.cc index 784b4922d4b..280d2cb0712 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_get_list_of_permissions_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_get_list_of_permissions_response.cc @@ -61,4 +61,4 @@ void SDLGetListOfPermissionsResponse::Run() { } } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_get_policy_configuration_data_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_get_policy_configuration_data_request.cc new file mode 100644 index 00000000000..26077542283 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_get_policy_configuration_data_request.cc @@ -0,0 +1,156 @@ +/* + * Copyright (c) 2019, Ford Motor Company + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following + * disclaimer in the documentation and/or other materials provided with the + * distribution. + * + * Neither the name of the Ford Motor Company nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#include "sdl_rpc_plugin/commands/hmi/sdl_get_policy_configuration_data_request.h" +#include "application_manager/application_manager.h" +#include "application_manager/policies/policy_handler_interface.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +SDLGetPolicyConfigurationDataRequest::SDLGetPolicyConfigurationDataRequest( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : RequestFromHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +SDLGetPolicyConfigurationDataRequest::~SDLGetPolicyConfigurationDataRequest() {} + +void SDLGetPolicyConfigurationDataRequest::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + smart_objects::SmartObject response_value( + smart_objects::SmartType::SmartType_Array); + + hmi_apis::Common_Result::eType result_code = + PrepareResponseParams(response_value); + + if (hmi_apis::Common_Result::SUCCESS != result_code) { + LOG4CXX_ERROR(logger_, "Unable to PrepareResponseParams"); + SendErrorResponse( + correlation_id(), + hmi_apis::FunctionID::SDL_GetPolicyConfigurationData, + result_code, + "", + application_manager::commands::Command::SOURCE_SDL_TO_HMI); + return; + } + + smart_objects::SmartObject response_msg_params( + smart_objects::SmartType::SmartType_Map); + response_msg_params[strings::value] = response_value; + SendResponse(true, + correlation_id(), + hmi_apis::FunctionID::SDL_GetPolicyConfigurationData, + result_code, + &response_msg_params, + application_manager::commands::Command::SOURCE_SDL_TO_HMI); +} + +hmi_apis::Common_Result::eType +SDLGetPolicyConfigurationDataRequest::PrepareResponseParams( + smart_objects::SmartObject& response_out) const { + LOG4CXX_AUTO_TRACE(logger_); + const auto policy_type = + (*message_)[strings::msg_params][strings::policy_type].asString(); + + const auto property = + (*message_)[strings::msg_params][strings::property].asString(); + + auto policy_table_data = policy_handler_.GetPolicyTableData(); + if (!policy_table_data.isMember(policy_type)) { + LOG4CXX_ERROR( + logger_, + "policy_type " << policy_type << " doesn't exist in policy table."); + return hmi_apis::Common_Result::DATA_NOT_AVAILABLE; + } + + auto& policy_section_table_data = policy_table_data[policy_type]; + if (!policy_section_table_data.isMember(property)) { + LOG4CXX_ERROR( + logger_, + "property " << property << " doesn't exist in " << policy_type); + return hmi_apis::Common_Result::DATA_NOT_AVAILABLE; + } + + auto& property_table_data = policy_section_table_data[property]; + response_out = GetValueParam(property_table_data); + + return hmi_apis::Common_Result::SUCCESS; +} + +void clear_new_line_symbol(std::string& str_to_clear) { + str_to_clear.erase( + std::remove_if(str_to_clear.begin(), + str_to_clear.end(), + [](char character) { return '\n' == character; }), + str_to_clear.end()); +} + +smart_objects::SmartObject SDLGetPolicyConfigurationDataRequest::GetValueParam( + const Json::Value& policy_property) const { + LOG4CXX_AUTO_TRACE(logger_); + smart_objects::SmartObject value(smart_objects::SmartType_Array); + + auto put_element_in_value_array = [&value](const Json::Value& element, + const int32_t index) { + Json::FastWriter writer; + std::string str; + if (element.type() == Json::objectValue) { + str = writer.write(element); + clear_new_line_symbol(str); + } else { + str = element.asString(); + } + value[index] = str; + }; + + if (policy_property.type() == Json::arrayValue) { + for (Json::ArrayIndex i = 0; i < policy_property.size(); i++) { + put_element_in_value_array(policy_property[i], i); + } + return value; + } + put_element_in_value_array(policy_property, 0); + return value; +} + +} // namespace commands +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/get_urls_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_get_policy_configuration_data_response.cc similarity index 86% rename from src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/get_urls_response.cc rename to src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_get_policy_configuration_data_response.cc index 57c925e08f6..21b7dea41c9 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/get_urls_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_get_policy_configuration_data_response.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Ford Motor Company + * Copyright (c) 2019, Ford Motor Company * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -30,14 +30,15 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include "sdl_rpc_plugin/commands/hmi/get_urls_response.h" +#include "sdl_rpc_plugin/commands/hmi/sdl_get_policy_configuration_data_response.h" #include "application_manager/rpc_service.h" namespace sdl_rpc_plugin { using namespace application_manager; + namespace commands { -GetUrlsResponse::GetUrlsResponse( +SDLGetPolicyConfigurationDataResponse::SDLGetPolicyConfigurationDataResponse( const application_manager::commands::MessageSharedPtr& message, ApplicationManager& application_manager, rpc_service::RPCService& rpc_service, @@ -49,15 +50,15 @@ GetUrlsResponse::GetUrlsResponse( hmi_capabilities, policy_handle) {} -GetUrlsResponse::~GetUrlsResponse() {} +SDLGetPolicyConfigurationDataResponse:: + ~SDLGetPolicyConfigurationDataResponse() {} -void GetUrlsResponse::Run() { +void SDLGetPolicyConfigurationDataResponse::Run() { LOG4CXX_AUTO_TRACE(logger_); (*message_)[strings::params][strings::protocol_type] = hmi_protocol_type_; (*message_)[strings::params][strings::protocol_version] = protocol_version_; - rpc_service_.SendMessageToHMI(message_); } } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_get_status_update_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_get_status_update_request.cc index 9a6c0fd520e..b494be56e85 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_get_status_update_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_get_status_update_request.cc @@ -32,6 +32,7 @@ #include "sdl_rpc_plugin/commands/hmi/sdl_get_status_update_request.h" #include "application_manager/application_manager.h" +#include "application_manager/policies/policy_handler_interface.h" namespace sdl_rpc_plugin { using namespace application_manager; @@ -59,4 +60,4 @@ void SDLGetStatusUpdateRequest::Run() { } } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_get_status_update_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_get_status_update_response.cc index 8fc85da4812..4b0f3d0ca89 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_get_status_update_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_get_status_update_response.cc @@ -61,4 +61,4 @@ void SDLGetStatusUpdateResponse::Run() { } } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_get_user_friendly_message_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_get_user_friendly_message_request.cc index ab8ec4e3d94..38a63611fac 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_get_user_friendly_message_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_get_user_friendly_message_request.cc @@ -32,6 +32,7 @@ #include "sdl_rpc_plugin/commands/hmi/sdl_get_user_friendly_message_request.h" #include "application_manager/message_helper.h" +#include "application_manager/policies/policy_handler_interface.h" namespace sdl_rpc_plugin { using namespace application_manager; @@ -93,4 +94,4 @@ void SDLGetUserFriendlyMessageRequest::Run() { } } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_get_user_friendly_message_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_get_user_friendly_message_response.cc index c5b34507230..b95591c4fa8 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_get_user_friendly_message_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_get_user_friendly_message_response.cc @@ -61,4 +61,4 @@ void SDLGetUserFriendlyMessageResponse::Run() { } } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_policy_update.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_policy_update.cc index aef2e286d78..5f699035487 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_policy_update.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_policy_update.cc @@ -64,4 +64,4 @@ void SDLPolicyUpdate::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_policy_update_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_policy_update_response.cc index d16fc578aba..12cdfb4ad92 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_policy_update_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_policy_update_response.cc @@ -56,4 +56,4 @@ void SDLPolicyUpdateResponse::Run() { } } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/tts_change_registration_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/tts_change_registration_request.cc index 163d7494260..988be68a809 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/tts_change_registration_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/tts_change_registration_request.cc @@ -59,4 +59,4 @@ void TTSChangeRegistrationRequest::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/tts_change_registration_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/tts_change_registration_response.cc index 2c28d615d31..e5e38ef34ac 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/tts_change_registration_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/tts_change_registration_response.cc @@ -63,4 +63,4 @@ void TTSChangeRegistratioResponse::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/tts_get_capabilities_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/tts_get_capabilities_request.cc index 49623e01d7b..9baaabf4013 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/tts_get_capabilities_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/tts_get_capabilities_request.cc @@ -59,4 +59,4 @@ void TTSGetCapabilitiesRequest::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/tts_get_capabilities_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/tts_get_capabilities_response.cc index 1cef3daf150..c0581a6380a 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/tts_get_capabilities_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/tts_get_capabilities_response.cc @@ -69,4 +69,4 @@ void TTSGetCapabilitiesResponse::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/tts_get_language_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/tts_get_language_request.cc index 5533537b33a..7d2c15a9bff 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/tts_get_language_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/tts_get_language_request.cc @@ -59,4 +59,4 @@ void TTSGetLanguageRequest::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/tts_get_language_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/tts_get_language_response.cc index ac423a2bf3b..627056dce1a 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/tts_get_language_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/tts_get_language_response.cc @@ -77,4 +77,4 @@ void TTSGetLanguageResponse::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/tts_get_supported_languages_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/tts_get_supported_languages_request.cc index 8b87b9c6eac..2cb47380d59 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/tts_get_supported_languages_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/tts_get_supported_languages_request.cc @@ -59,4 +59,4 @@ void TTSGetSupportedLanguagesRequest::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/tts_get_supported_languages_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/tts_get_supported_languages_response.cc index a4e97d9d700..a70d1c89a30 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/tts_get_supported_languages_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/tts_get_supported_languages_response.cc @@ -69,4 +69,4 @@ void TTSGetSupportedLanguagesResponse::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/tts_is_ready_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/tts_is_ready_request.cc index c7e2c0c4cbb..89b59618950 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/tts_is_ready_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/tts_is_ready_request.cc @@ -31,8 +31,8 @@ */ #include "sdl_rpc_plugin/commands/hmi/tts_is_ready_request.h" -#include "application_manager/rpc_service.h" #include "application_manager/message_helper.h" +#include "application_manager/rpc_service.h" namespace sdl_rpc_plugin { using namespace application_manager; @@ -112,4 +112,4 @@ void TTSIsReadyRequest::SendMessageToHMI() { } } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/tts_is_ready_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/tts_is_ready_response.cc index c7d634bee20..67e0fb6396b 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/tts_is_ready_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/tts_is_ready_response.cc @@ -59,4 +59,4 @@ void TTSIsReadyResponse::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/tts_set_global_properties_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/tts_set_global_properties_request.cc index 8c7443d4654..0b3d9a77bfe 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/tts_set_global_properties_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/tts_set_global_properties_request.cc @@ -59,4 +59,4 @@ void TTSSetGlobalPropertiesRequest::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/tts_set_global_properties_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/tts_set_global_properties_response.cc index dae06d75f99..0901378c4ad 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/tts_set_global_properties_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/tts_set_global_properties_response.cc @@ -63,4 +63,4 @@ void TTSSetGlobalPropertiesResponse::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/tts_speak_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/tts_speak_request.cc index 96b93b724ff..6dce94f931f 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/tts_speak_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/tts_speak_request.cc @@ -59,4 +59,4 @@ void TTSSpeakRequest::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/tts_speak_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/tts_speak_response.cc index cb2346083bd..69be5ab160b 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/tts_speak_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/tts_speak_response.cc @@ -32,8 +32,8 @@ #include "sdl_rpc_plugin/commands/hmi/tts_speak_response.h" #include "application_manager/event_engine/event.h" -#include "interfaces/MOBILE_API.h" #include "interfaces/HMI_API.h" +#include "interfaces/MOBILE_API.h" namespace sdl_rpc_plugin { using namespace application_manager; @@ -64,4 +64,4 @@ void TTSSpeakResponse::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/tts_stop_speaking_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/tts_stop_speaking_request.cc index 25a05f085b0..43c595040ca 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/tts_stop_speaking_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/tts_stop_speaking_request.cc @@ -59,4 +59,4 @@ void TTSStopSpeakingRequest::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/tts_stop_speaking_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/tts_stop_speaking_response.cc index a2620c13409..892b3e6295b 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/tts_stop_speaking_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/tts_stop_speaking_response.cc @@ -62,4 +62,4 @@ void TTSStopSpeakingResponse::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_add_command_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_add_command_request.cc index 749b3ad56bf..7c95e8a9193 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_add_command_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_add_command_request.cc @@ -59,4 +59,4 @@ void UIAddCommandRequest::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_add_command_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_add_command_response.cc index 266dffd225e..72d841a8780 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_add_command_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_add_command_response.cc @@ -62,4 +62,4 @@ void UIAddCommandResponse::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_add_submenu_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_add_submenu_request.cc index de338d46706..15342c6ecb4 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_add_submenu_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_add_submenu_request.cc @@ -59,4 +59,4 @@ void UIAddSubmenuRequest::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_add_submenu_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_add_submenu_response.cc index 85e600c87d2..ae699dc2bdb 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_add_submenu_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_add_submenu_response.cc @@ -63,4 +63,4 @@ void UIAddSubmenuResponse::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_alert_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_alert_request.cc index ae5f861ba6a..793e70d9e17 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_alert_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_alert_request.cc @@ -47,7 +47,11 @@ UIAlertRequest::UIAlertRequest( application_manager, rpc_service, hmi_capabilities, - policy_handle) {} + policy_handle) { + const auto& msg_params = (*message_)[strings::msg_params]; + uint32_t request_timeout = msg_params[strings::duration].asUInt(); + default_timeout_ += request_timeout; +} UIAlertRequest::~UIAlertRequest() {} @@ -59,4 +63,4 @@ void UIAlertRequest::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_alert_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_alert_response.cc index 3076eabc4c4..f53f14e0503 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_alert_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_alert_response.cc @@ -63,4 +63,4 @@ void UIAlertResponse::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_cancel_interaction_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_cancel_interaction_request.cc new file mode 100644 index 00000000000..c186077b1ea --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_cancel_interaction_request.cc @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2019, Ford Motor Company + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following + * disclaimer in the documentation and/or other materials provided with the + * distribution. + * + * Neither the name of the Ford Motor Company nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#include "sdl_rpc_plugin/commands/hmi/ui_cancel_interaction_request.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +UICancelInteractionRequest::UICancelInteractionRequest( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : RequestToHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +UICancelInteractionRequest::~UICancelInteractionRequest() {} + +void UICancelInteractionRequest::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + SendRequest(); +} + +} // namespace commands + +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_cancel_interaction_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_cancel_interaction_response.cc new file mode 100644 index 00000000000..2d5db4eecbe --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_cancel_interaction_response.cc @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2019, Ford Motor Company + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following + * disclaimer in the documentation and/or other materials provided with the + * distribution. + * + * Neither the name of the Ford Motor Company nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ +#include "sdl_rpc_plugin/commands/hmi/ui_cancel_interaction_response.h" +#include "application_manager/event_engine/event.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +UICancelInteractionResponse::UICancelInteractionResponse( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : ResponseFromHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +UICancelInteractionResponse::~UICancelInteractionResponse() {} + +void UICancelInteractionResponse::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + event_engine::Event event(hmi_apis::FunctionID::UI_CancelInteraction); + event.set_smart_object(*message_); + event.raise(application_manager_.event_dispatcher()); +} + +} // namespace commands + +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_change_registration_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_change_registration_request.cc index d1099870096..bb001b37c77 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_change_registration_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_change_registration_request.cc @@ -59,4 +59,4 @@ void UIChangeRegistrationRequest::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_change_registration_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_change_registration_response.cc index 6557269e499..8acd6544885 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_change_registration_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_change_registration_response.cc @@ -63,4 +63,4 @@ void UIChangeRegistratioResponse::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_create_window_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_create_window_request.cc new file mode 100644 index 00000000000..b354009e3fc --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_create_window_request.cc @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2019, Ford Motor Company + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following + * disclaimer in the documentation and/or other materials provided with the + * distribution. + * + * Neither the name of the Ford Motor Company nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#include "sdl_rpc_plugin/commands/hmi/ui_create_window_request.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +UICreateWindowRequest::UICreateWindowRequest( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : RequestToHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +UICreateWindowRequest::~UICreateWindowRequest() {} + +void UICreateWindowRequest::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + SendRequest(); +} + +} // namespace commands + +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_create_window_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_create_window_response.cc new file mode 100644 index 00000000000..c3a323818d4 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_create_window_response.cc @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2019, Ford Motor Company + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following + * disclaimer in the documentation and/or other materials provided with the + * distribution. + * + * Neither the name of the Ford Motor Company nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ +#include "sdl_rpc_plugin/commands/hmi/ui_create_window_response.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +UICreateWindowResponse::UICreateWindowResponse( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : ResponseFromHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +UICreateWindowResponse::~UICreateWindowResponse() {} + +void UICreateWindowResponse::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + event_engine::Event event(hmi_apis::FunctionID::UI_CreateWindow); + event.set_smart_object(*message_); + event.raise(application_manager_.event_dispatcher()); +} + +} // namespace commands + +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_delete_command_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_delete_command_request.cc index 9e52f5fc18a..1d741bba74c 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_delete_command_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_delete_command_request.cc @@ -59,4 +59,4 @@ void UIDeleteCommandRequest::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_delete_command_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_delete_command_response.cc index a8f5b59d39f..40a5ec8a73c 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_delete_command_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_delete_command_response.cc @@ -63,4 +63,4 @@ void UIDeleteCommandResponse::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_delete_submenu_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_delete_submenu_request.cc index 1b84df8beda..fdca37cee67 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_delete_submenu_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_delete_submenu_request.cc @@ -59,4 +59,4 @@ void UIDeleteSubmenuRequest::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_delete_submenu_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_delete_submenu_response.cc index ec4025bea16..9d522431dc6 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_delete_submenu_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_delete_submenu_response.cc @@ -63,4 +63,4 @@ void UIDeleteSubmenuResponse::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_delete_window_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_delete_window_request.cc new file mode 100644 index 00000000000..7933574d926 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_delete_window_request.cc @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2019, Ford Motor Company + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following + * disclaimer in the documentation and/or other materials provided with the + * distribution. + * + * Neither the name of the Ford Motor Company nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#include "sdl_rpc_plugin/commands/hmi/ui_delete_window_request.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +UIDeleteWindowRequest::UIDeleteWindowRequest( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : RequestToHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +UIDeleteWindowRequest::~UIDeleteWindowRequest() {} + +void UIDeleteWindowRequest::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + SendRequest(); +} + +} // namespace commands + +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_delete_window_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_delete_window_response.cc new file mode 100644 index 00000000000..ba703e18ae9 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_delete_window_response.cc @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2019, Ford Motor Company + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following + * disclaimer in the documentation and/or other materials provided with the + * distribution. + * + * Neither the name of the Ford Motor Company nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ +#include "sdl_rpc_plugin/commands/hmi/ui_delete_window_response.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +UIDeleteWindowResponse::UIDeleteWindowResponse( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : ResponseFromHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +UIDeleteWindowResponse::~UIDeleteWindowResponse() {} + +void UIDeleteWindowResponse::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + event_engine::Event event(hmi_apis::FunctionID::UI_DeleteWindow); + event.set_smart_object(*message_); + event.raise(application_manager_.event_dispatcher()); +} + +} // namespace commands + +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_end_audio_pass_thru_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_end_audio_pass_thru_request.cc index fe11185c624..92f51bc9cf8 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_end_audio_pass_thru_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_end_audio_pass_thru_request.cc @@ -59,4 +59,4 @@ void UIEndAudioPassThruRequest::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_end_audio_pass_thru_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_end_audio_pass_thru_response.cc index 3a6d4efbe46..b6639dcbb9c 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_end_audio_pass_thru_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_end_audio_pass_thru_response.cc @@ -63,4 +63,4 @@ void UIEndAudioPassThruResponse::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_get_capabilities_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_get_capabilities_request.cc index 3bd56a06827..5f8704b3e56 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_get_capabilities_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_get_capabilities_request.cc @@ -59,4 +59,4 @@ void UIGetCapabilitiesRequest::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_get_capabilities_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_get_capabilities_response.cc index cd5f3c9a423..a3eb9244bdc 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_get_capabilities_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_get_capabilities_response.cc @@ -73,9 +73,17 @@ void UIGetCapabilitiesResponse::Run() { msg_params[hmi_response::soft_button_capabilities]); } - if (msg_params.keyExists(strings::audio_pass_thru_capabilities)) { + // use newer parameter "audioPassThruCapabilitiesList" when available + if (msg_params.keyExists(strings::audio_pass_thru_capabilities_list)) { hmi_capabilities.set_audio_pass_thru_capabilities( - msg_params[strings::audio_pass_thru_capabilities]); + msg_params[strings::audio_pass_thru_capabilities_list]); + } else if (msg_params.keyExists(strings::audio_pass_thru_capabilities)) { + smart_objects::SmartObject audio_pass_thru_capabilities_list( + smart_objects::SmartType_Array); + audio_pass_thru_capabilities_list[0] = + msg_params[strings::audio_pass_thru_capabilities]; + hmi_capabilities.set_audio_pass_thru_capabilities( + audio_pass_thru_capabilities_list); } if (msg_params.keyExists(strings::hmi_capabilities)) { @@ -113,9 +121,15 @@ void UIGetCapabilitiesResponse::Run() { msg_params[strings::system_capabilities] [strings::video_streaming_capability]); } + if (msg_params[strings::system_capabilities].keyExists( + strings::display_capabilities)) { + hmi_capabilities.set_system_display_capabilities( + msg_params[strings::system_capabilities] + [strings::display_capabilities]); + } } } } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_get_language_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_get_language_request.cc index 8acba424936..d3b44d11680 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_get_language_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_get_language_request.cc @@ -59,4 +59,4 @@ void UIGetLanguageRequest::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_get_language_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_get_language_response.cc index 27e46e52b41..2a5c0ab016f 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_get_language_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_get_language_response.cc @@ -78,4 +78,4 @@ void UIGetLanguageResponse::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_get_supported_languages_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_get_supported_languages_request.cc index 2f8ef12a25c..06656125257 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_get_supported_languages_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_get_supported_languages_request.cc @@ -59,4 +59,4 @@ void UIGetSupportedLanguagesRequest::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_get_supported_languages_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_get_supported_languages_response.cc index d20dd8545f2..19ee62e51da 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_get_supported_languages_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_get_supported_languages_response.cc @@ -69,4 +69,4 @@ void UIGetSupportedLanguagesResponse::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_is_ready_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_is_ready_request.cc index 2eab2116909..2546b704b2b 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_is_ready_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_is_ready_request.cc @@ -112,4 +112,4 @@ void UIIsReadyRequest::SendMessageToHMI() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_is_ready_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_is_ready_response.cc index e25e8ee8abc..96a2d1212cf 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_is_ready_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_is_ready_response.cc @@ -60,4 +60,4 @@ void UIIsReadyResponse::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_perform_audio_pass_thru_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_perform_audio_pass_thru_request.cc index cca89e30734..18d5376b259 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_perform_audio_pass_thru_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_perform_audio_pass_thru_request.cc @@ -59,4 +59,4 @@ void UIPerformAudioPassThruRequest::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_perform_audio_pass_thru_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_perform_audio_pass_thru_response.cc index 057448ab33d..afbd1bbed75 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_perform_audio_pass_thru_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_perform_audio_pass_thru_response.cc @@ -62,4 +62,4 @@ void UIPerformAudioPassThruResponse::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_perform_interaction_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_perform_interaction_request.cc index d5696a39e72..a07c72cbf4d 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_perform_interaction_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_perform_interaction_request.cc @@ -47,7 +47,11 @@ UIPerformInteractionRequest::UIPerformInteractionRequest( application_manager, rpc_service, hmi_capabilities, - policy_handle) {} + policy_handle) { + const auto& msg_params = (*message_)[strings::msg_params]; + uint32_t request_timeout = msg_params[strings::timeout].asUInt(); + default_timeout_ += request_timeout; +} UIPerformInteractionRequest::~UIPerformInteractionRequest() {} @@ -59,4 +63,4 @@ void UIPerformInteractionRequest::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_perform_interaction_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_perform_interaction_response.cc index 7629faa131f..4cbc58d278f 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_perform_interaction_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_perform_interaction_response.cc @@ -61,4 +61,4 @@ void UIPerformInteractionResponse::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_scrollable_message_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_scrollable_message_request.cc index dbe0ceb529f..cad68e23aa4 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_scrollable_message_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_scrollable_message_request.cc @@ -47,7 +47,11 @@ UIScrollableMessageRequest::UIScrollableMessageRequest( application_manager, rpc_service, hmi_capabilities, - policy_handle) {} + policy_handle) { + const auto& msg_params = (*message_)[strings::msg_params]; + uint32_t request_timeout = msg_params[strings::timeout].asUInt(); + default_timeout_ += request_timeout; +} UIScrollableMessageRequest::~UIScrollableMessageRequest() {} @@ -59,4 +63,4 @@ void UIScrollableMessageRequest::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_scrollable_message_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_scrollable_message_response.cc index a96b9fa3ee8..4e844095b4a 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_scrollable_message_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_scrollable_message_response.cc @@ -62,4 +62,4 @@ void UIScrollableMessageResponse::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_send_haptic_data_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_send_haptic_data_request.cc index f5f8f7bafda..4a538ac9924 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_send_haptic_data_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_send_haptic_data_request.cc @@ -58,4 +58,4 @@ void UISendHapticDataRequest::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_send_haptic_data_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_send_haptic_data_response.cc index 4555d81a0a1..92afdaaa4a0 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_send_haptic_data_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_send_haptic_data_response.cc @@ -62,4 +62,4 @@ void UISendHapticDataResponse::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_set_app_icon_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_set_app_icon_request.cc index d25bbd1cd93..821f78a046c 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_set_app_icon_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_set_app_icon_request.cc @@ -59,4 +59,4 @@ void UISetAppIconRequest::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_set_app_icon_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_set_app_icon_response.cc index 711b5767f2d..68e96725d49 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_set_app_icon_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_set_app_icon_response.cc @@ -62,4 +62,4 @@ void UISetAppIconResponse::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_set_display_layout_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_set_display_layout_request.cc index 73b813d0eb8..63166157c85 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_set_display_layout_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_set_display_layout_request.cc @@ -58,4 +58,4 @@ void UiSetDisplayLayoutRequest::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_set_display_layout_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_set_display_layout_response.cc index d5d2e02e333..f35427895ea 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_set_display_layout_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_set_display_layout_response.cc @@ -63,4 +63,4 @@ void UiSetDisplayLayoutResponse::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_set_global_properties_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_set_global_properties_request.cc index 06644043616..0aaaae7cc77 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_set_global_properties_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_set_global_properties_request.cc @@ -59,4 +59,4 @@ void UISetGlobalPropertiesRequest::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_set_global_properties_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_set_global_properties_response.cc index 2e5fecf2af7..48d73d146c8 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_set_global_properties_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_set_global_properties_response.cc @@ -62,4 +62,4 @@ void UISetGlobalPropertiesResponse::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_set_media_clock_timer_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_set_media_clock_timer_request.cc index 4e87b9ccc3e..4c8fcefcdf4 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_set_media_clock_timer_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_set_media_clock_timer_request.cc @@ -59,4 +59,4 @@ void UISetMediaClockTimerRequest::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_set_media_clock_timer_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_set_media_clock_timer_response.cc index 39e7e1c232c..fb5b25fc2ba 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_set_media_clock_timer_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_set_media_clock_timer_response.cc @@ -62,4 +62,4 @@ void UISetMediaClockTimerResponse::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_show_app_menu_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_show_app_menu_request.cc new file mode 100644 index 00000000000..c2c8566e821 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_show_app_menu_request.cc @@ -0,0 +1,61 @@ +/* + * 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 "sdl_rpc_plugin/commands/hmi/ui_show_app_menu_request.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +UIShowAppMenuRequest::UIShowAppMenuRequest( + 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) + : RequestToHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +UIShowAppMenuRequest::~UIShowAppMenuRequest() {} + +void UIShowAppMenuRequest::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + SendRequest(); +} + +} // namespace commands +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_show_app_menu_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_show_app_menu_response.cc new file mode 100644 index 00000000000..14bbc79e038 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_show_app_menu_response.cc @@ -0,0 +1,63 @@ +/* + * 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 "sdl_rpc_plugin/commands/hmi/ui_show_app_menu_response.h" +#include "application_manager/event_engine/event.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { +UIShowAppMenuResponse::UIShowAppMenuResponse( + 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) + : ResponseFromHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +UIShowAppMenuResponse::~UIShowAppMenuResponse() {} + +void UIShowAppMenuResponse::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + app_mngr::event_engine::Event event(hmi_apis::FunctionID::UI_ShowAppMenu); + event.set_smart_object(*message_); + event.raise(application_manager_.event_dispatcher()); +} + +} // namespace commands +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_show_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_show_request.cc index 5b7568abfea..d7160dc70be 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_show_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_show_request.cc @@ -59,4 +59,4 @@ void UIShowRequest::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_show_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_show_response.cc index 3e3c0b79d85..768069bf3a1 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_show_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_show_response.cc @@ -61,4 +61,4 @@ void UIShowResponse::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_slider_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_slider_request.cc index 4df3adbe146..eae8cc523c0 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_slider_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_slider_request.cc @@ -47,7 +47,11 @@ UISliderRequest::UISliderRequest( application_manager, rpc_service, hmi_capabilities, - policy_handle) {} + policy_handle) { + const auto& msg_params = (*message_)[strings::msg_params]; + uint32_t request_timeout = msg_params[strings::timeout].asUInt(); + default_timeout_ += request_timeout; +} UISliderRequest::~UISliderRequest() {} @@ -59,4 +63,4 @@ void UISliderRequest::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_slider_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_slider_response.cc index 2431c65ddfa..9cf7224ddb9 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_slider_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_slider_response.cc @@ -62,4 +62,4 @@ void UISliderResponse::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/update_app_list_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/update_app_list_request.cc index 05b08cb7237..c5966fcb363 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/update_app_list_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/update_app_list_request.cc @@ -59,4 +59,4 @@ void UpdateAppListRequest::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/update_app_list_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/update_app_list_response.cc index 3dd03993ef3..7fc830b4e65 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/update_app_list_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/update_app_list_response.cc @@ -59,4 +59,4 @@ void UpdateAppListResponse::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/update_device_list_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/update_device_list_request.cc index 7736f2b1e6d..3a014480c14 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/update_device_list_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/update_device_list_request.cc @@ -100,4 +100,4 @@ bool UpdateDeviceListRequest::CleanUp() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/update_device_list_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/update_device_list_response.cc index 25dc9be5bd8..d69e683f2b4 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/update_device_list_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/update_device_list_response.cc @@ -58,4 +58,4 @@ void UpdateDeviceListResponse::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/update_sdl_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/update_sdl_request.cc index cafacea28f9..a52f03b9985 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/update_sdl_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/update_sdl_request.cc @@ -32,6 +32,7 @@ */ #include "sdl_rpc_plugin/commands/hmi/update_sdl_request.h" +#include "application_manager/policies/policy_handler_interface.h" namespace sdl_rpc_plugin { using namespace application_manager; @@ -61,4 +62,4 @@ void UpdateSDLRequest::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/update_sdl_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/update_sdl_response.cc index a35571ec26c..c02cde41113 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/update_sdl_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/update_sdl_response.cc @@ -61,4 +61,4 @@ void UpdateSDLResponse::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/vr_add_command_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/vr_add_command_request.cc index 72ce387f778..788eda5a87a 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/vr_add_command_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/vr_add_command_request.cc @@ -59,4 +59,4 @@ void VRAddCommandRequest::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/vr_add_command_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/vr_add_command_response.cc index 19d43616ff1..37b3e4696d1 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/vr_add_command_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/vr_add_command_response.cc @@ -63,4 +63,4 @@ void VRAddCommandResponse::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/vr_change_registration_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/vr_change_registration_request.cc index 9ba5fa35719..d1be04ad44b 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/vr_change_registration_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/vr_change_registration_request.cc @@ -59,4 +59,4 @@ void VRChangeRegistrationRequest::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/vr_change_registration_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/vr_change_registration_response.cc index 42c5b6d65b7..27bde2bafa3 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/vr_change_registration_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/vr_change_registration_response.cc @@ -62,4 +62,4 @@ void VRChangeRegistrationResponse::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/vr_delete_command_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/vr_delete_command_request.cc index efc09dc157a..ebcfe78fa92 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/vr_delete_command_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/vr_delete_command_request.cc @@ -59,4 +59,4 @@ void VRDeleteCommandRequest::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/vr_delete_command_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/vr_delete_command_response.cc index f8f7535e68d..d1d725b3565 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/vr_delete_command_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/vr_delete_command_response.cc @@ -62,4 +62,4 @@ void VRDeleteCommandResponse::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/vr_get_capabilities_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/vr_get_capabilities_request.cc index 7e9c846857d..b06bfa0e777 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/vr_get_capabilities_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/vr_get_capabilities_request.cc @@ -59,4 +59,4 @@ void VRGetCapabilitiesRequest::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/vr_get_capabilities_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/vr_get_capabilities_response.cc index 47ffb3a675e..80c308ea40e 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/vr_get_capabilities_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/vr_get_capabilities_response.cc @@ -61,4 +61,4 @@ void VRGetCapabilitiesResponse::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/vr_get_language_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/vr_get_language_request.cc index d57faa08fdf..84179f6357a 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/vr_get_language_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/vr_get_language_request.cc @@ -59,4 +59,4 @@ void VRGetLanguageRequest::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/vr_get_language_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/vr_get_language_response.cc index 469452d1086..6b7fec736df 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/vr_get_language_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/vr_get_language_response.cc @@ -78,4 +78,4 @@ void VRGetLanguageResponse::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/vr_get_supported_languages_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/vr_get_supported_languages_request.cc index bb27168a775..351940bf686 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/vr_get_supported_languages_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/vr_get_supported_languages_request.cc @@ -59,4 +59,4 @@ void VRGetSupportedLanguagesRequest::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/vr_get_supported_languages_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/vr_get_supported_languages_response.cc index 722040388db..4c725267fa8 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/vr_get_supported_languages_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/vr_get_supported_languages_response.cc @@ -31,8 +31,8 @@ */ #include "sdl_rpc_plugin/commands/hmi/vr_get_supported_languages_response.h" -#include "interfaces/MOBILE_API.h" #include "interfaces/HMI_API.h" +#include "interfaces/MOBILE_API.h" namespace sdl_rpc_plugin { using namespace application_manager; @@ -69,4 +69,4 @@ void VRGetSupportedLanguagesResponse::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/vr_is_ready_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/vr_is_ready_request.cc index 22afb039458..12414eab106 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/vr_is_ready_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/vr_is_ready_request.cc @@ -112,4 +112,4 @@ void VRIsReadyRequest::SendMessageToHMI() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/vr_is_ready_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/vr_is_ready_response.cc index 48d9c3e075d..373f97bf80d 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/vr_is_ready_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/vr_is_ready_response.cc @@ -59,4 +59,4 @@ void VRIsReadyResponse::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/vr_perform_interaction_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/vr_perform_interaction_request.cc index 26e308a0bc5..4257158f6a0 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/vr_perform_interaction_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/vr_perform_interaction_request.cc @@ -47,7 +47,11 @@ VRPerformInteractionRequest::VRPerformInteractionRequest( application_manager, rpc_service, hmi_capabilities, - policy_handle) {} + policy_handle) { + const auto& msg_params = (*message_)[strings::msg_params]; + uint32_t request_timeout = msg_params[strings::timeout].asUInt(); + default_timeout_ += request_timeout; +} VRPerformInteractionRequest::~VRPerformInteractionRequest() {} @@ -59,4 +63,4 @@ void VRPerformInteractionRequest::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/vr_perform_interaction_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/vr_perform_interaction_response.cc index dec371e8896..16378ab55ac 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/vr_perform_interaction_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/vr_perform_interaction_response.cc @@ -60,4 +60,4 @@ void VRPerformInteractionResponse::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin 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 155f819761a..a57d222765e 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 @@ -31,14 +31,14 @@ POSSIBILITY OF SUCH DAMAGE. */ -#include #include "sdl_rpc_plugin/commands/mobile/add_command_request.h" +#include #include "application_manager/application.h" #include "application_manager/message_helper.h" +#include "utils/custom_string.h" #include "utils/file_system.h" #include "utils/helpers.h" -#include "utils/custom_string.h" namespace sdl_rpc_plugin { using namespace application_manager; @@ -126,9 +126,9 @@ void AddCommandRequest::Run() { } if (((*message_)[strings::msg_params][strings::menu_params].keyExists( hmi_request::parent_id)) && - (0 != - (*message_)[strings::msg_params][strings::menu_params] - [hmi_request::parent_id].asUInt())) { + (0 != (*message_)[strings::msg_params][strings::menu_params] + [hmi_request::parent_id] + .asUInt())) { if (!CheckCommandParentId(app)) { SendResponse( false, mobile_apis::Result::INVALID_ID, "Parent ID doesn't exist"); @@ -224,7 +224,8 @@ bool AddCommandRequest::CheckCommandName(ApplicationConstSharedPtr app) { if ((*message_)[strings::msg_params][strings::menu_params].keyExists( hmi_request::parent_id)) { parent_id = (*message_)[strings::msg_params][strings::menu_params] - [hmi_request::parent_id].asUInt(); + [hmi_request::parent_id] + .asUInt(); } for (; commands.end() != i; ++i) { @@ -239,7 +240,8 @@ bool AddCommandRequest::CheckCommandName(ApplicationConstSharedPtr app) { } if (((*i->second)[strings::menu_params][strings::menu_name].asString() == (*message_)[strings::msg_params][strings::menu_params] - [strings::menu_name].asString()) && + [strings::menu_name] + .asString()) && (saved_parent_id == parent_id)) { LOG4CXX_INFO(logger_, "AddCommandRequest::CheckCommandName received" @@ -293,7 +295,8 @@ bool AddCommandRequest::CheckCommandParentId(ApplicationConstSharedPtr app) { const int32_t parent_id = (*message_)[strings::msg_params][strings::menu_params] - [hmi_request::parent_id].asInt(); + [hmi_request::parent_id] + .asInt(); smart_objects::SmartObject* parent = app->FindSubMenu(parent_id); if (!parent) { @@ -524,7 +527,8 @@ bool AddCommandRequest::IsWhiteSpaceExist() { if ((*message_)[strings::msg_params].keyExists(strings::menu_params)) { str = (*message_)[strings::msg_params][strings::menu_params] - [strings::menu_name].asCharArray(); + [strings::menu_name] + .asCharArray(); if (!CheckSyntax(str)) { LOG4CXX_ERROR(logger_, "Invalid menu name syntax check failed."); return true; @@ -624,4 +628,4 @@ void AddCommandRequest::RemoveCommand() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/add_command_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/add_command_response.cc index ccb84cecbb1..24ff3b5a286 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/add_command_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/add_command_response.cc @@ -61,4 +61,4 @@ void AddCommandResponse::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin 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 183b4453260..89ccfb8bd7a 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 @@ -33,8 +33,8 @@ #include "sdl_rpc_plugin/commands/mobile/add_sub_menu_request.h" -#include "application_manager/message_helper.h" #include "application_manager/application.h" +#include "application_manager/message_helper.h" #include "utils/helpers.h" namespace sdl_rpc_plugin { @@ -109,15 +109,28 @@ void AddSubMenuRequest::Run() { smart_objects::SmartObject msg_params = smart_objects::SmartObject(smart_objects::SmartType_Map); + if (received_msg_params.keyExists(strings::menu_layout)) { + auto menu_layout = static_cast( + received_msg_params[strings::menu_layout].asUInt()); + if (app->menu_layout_supported(menu_layout)) { + msg_params[strings::menu_layout] = + received_msg_params[strings::menu_layout]; + } else { + is_menu_layout_available_ = false; + } + } + msg_params[strings::menu_id] = received_msg_params[strings::menu_id]; if (received_msg_params.keyExists(strings::position)) { msg_params[strings::menu_params][strings::position] = received_msg_params[strings::position]; } + if (received_msg_params.keyExists(strings::menu_icon)) { + msg_params[strings::menu_icon] = received_msg_params[strings::menu_icon]; + } msg_params[strings::menu_params][strings::menu_name] = received_msg_params[strings::menu_name]; msg_params[strings::app_id] = app->app_id(); - 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); @@ -150,11 +163,22 @@ void AddSubMenuRequest::on_event(const event_engine::Event& event) { application->AddSubMenu( (*message_)[strings::msg_params][strings::menu_id].asInt(), (*message_)[strings::msg_params]); + response_info = + "The MenuLayout specified is unsupported, the " + "default MenuLayout will be used." + + response_info; + SendResponse(result, + is_menu_layout_available_ + ? MessageHelper::HMIToMobileResult(result_code) + : mobile_apis::Result::WARNINGS, + is_menu_layout_available_ ? NULL : response_info.c_str(), + &(message[strings::msg_params])); + } else { + SendResponse(result, + MessageHelper::HMIToMobileResult(result_code), + response_info.empty() ? NULL : response_info.c_str(), + &(message[strings::msg_params])); } - SendResponse(result, - MessageHelper::HMIToMobileResult(result_code), - response_info.empty() ? NULL : response_info.c_str(), - &(message[strings::msg_params])); break; } default: { @@ -183,4 +207,4 @@ bool AddSubMenuRequest::CheckSubMenuName() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/add_sub_menu_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/add_sub_menu_response.cc index d0ec635dd06..d91f13f1df9 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/add_sub_menu_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/add_sub_menu_response.cc @@ -32,8 +32,8 @@ */ #include "sdl_rpc_plugin/commands/mobile/add_sub_menu_response.h" -#include "application_manager/rpc_service.h" #include "application_manager/application_impl.h" +#include "application_manager/rpc_service.h" namespace sdl_rpc_plugin { using namespace application_manager; @@ -62,4 +62,4 @@ void AddSubMenuResponse::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/alert_maneuver_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/alert_maneuver_request.cc index 5dda34b743a..9f36f260ae4 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/alert_maneuver_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/alert_maneuver_request.cc @@ -25,12 +25,12 @@ POSSIBILITY OF SUCH DAMAGE. */ +#include "sdl_rpc_plugin/commands/mobile/alert_maneuver_request.h" #include #include -#include "sdl_rpc_plugin/commands/mobile/alert_maneuver_request.h" #include "application_manager/application_impl.h" -#include "application_manager/policies/policy_handler.h" #include "application_manager/message_helper.h" +#include "application_manager/policies/policy_handler.h" namespace sdl_rpc_plugin { using namespace application_manager; @@ -107,9 +107,9 @@ void AlertManeuverRequest::Run() { MessageHelper::VerifyTtsFiles(tts_chunks, app, application_manager_); if (mobile_apis::Result::FILE_NOT_FOUND == verification_result) { - LOG4CXX_ERROR(logger_, - "MessageHelper::VerifyTtsFiles return " - << verification_result); + LOG4CXX_ERROR( + logger_, + "MessageHelper::VerifyTtsFiles return " << verification_result); SendResponse(false, mobile_apis::Result::FILE_NOT_FOUND, "One or more files needed for tts_chunks are not present"); @@ -288,4 +288,4 @@ bool AlertManeuverRequest::IsWhiteSpaceExist() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/alert_maneuver_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/alert_maneuver_response.cc index d3e527f6ae7..97c93d74557 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/alert_maneuver_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/alert_maneuver_response.cc @@ -62,4 +62,4 @@ void AlertManeuverResponse::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/alert_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/alert_request.cc index 2806ac1d93b..57912e7087e 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/alert_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/alert_request.cc @@ -35,12 +35,12 @@ #include -#include "application_manager/message_helper.h" #include "application_manager/application_impl.h" +#include "application_manager/message_helper.h" #include "application_manager/policies/policy_handler.h" -#include "utils/helpers.h" #include "smart_objects/smart_object.h" +#include "utils/helpers.h" namespace sdl_rpc_plugin { using namespace application_manager; @@ -73,18 +73,15 @@ AlertRequest::~AlertRequest() {} bool AlertRequest::Init() { /* Timeout in milliseconds. - If omitted a standard value of 10000 milliseconds is used.*/ - if ((*message_)[strings::msg_params].keyExists(strings::duration)) { - default_timeout_ = - (*message_)[strings::msg_params][strings::duration].asUInt(); - } else { - const int32_t def_value = 5000; - default_timeout_ = def_value; - } + If omitted a standard value of 10000 milliseconds is used.*/ + auto& msg_params = (*message_)[strings::msg_params]; + uint32_t duration_timeout = msg_params[strings::duration].asUInt(); + + default_timeout_ += duration_timeout; // If soft buttons are present, SDL will not use initiate timeout tracking for // response. - if ((*message_)[strings::msg_params].keyExists(strings::soft_buttons)) { + if (msg_params.keyExists(strings::soft_buttons)) { LOG4CXX_INFO(logger_, "Request contains soft buttons - request timeout " "will be set to 0."); @@ -251,7 +248,8 @@ bool AlertRequest::Validate(uint32_t app_id) { return false; } - if (mobile_apis::HMILevel::HMI_BACKGROUND == app->hmi_level() && + if (mobile_apis::HMILevel::HMI_BACKGROUND == + app->hmi_level(mobile_apis::PredefinedWindows::DEFAULT_WINDOW) && app->AreCommandLimitsExceeded( static_cast(function_id()), application_manager::TLimitSource::POLICY_TABLE)) { @@ -298,9 +296,9 @@ bool AlertRequest::Validate(uint32_t app_id) { MessageHelper::VerifyTtsFiles(tts_chunks, app, application_manager_); if (mobile_apis::Result::FILE_NOT_FOUND == verification_result) { - LOG4CXX_ERROR(logger_, - "MessageHelper::VerifyTtsFiles return " - << verification_result); + LOG4CXX_ERROR( + logger_, + "MessageHelper::VerifyTtsFiles return " << verification_result); SendResponse(false, mobile_apis::Result::FILE_NOT_FOUND, "One or more files needed for tts_chunks are not present"); @@ -321,6 +319,11 @@ void AlertRequest::SendAlertRequest(int32_t app_id) { msg_params[hmi_request::alert_strings] = smart_objects::SmartObject(smart_objects::SmartType_Array); + if ((*message_)[strings::msg_params].keyExists(strings::cancel_id)) { + msg_params[strings::cancel_id] = + (*message_)[strings::msg_params][strings::cancel_id].asInt(); + } + int32_t index = 0; if ((*message_)[strings::msg_params].keyExists(strings::alert_text1)) { msg_params[hmi_request::alert_strings][index][hmi_request::field_name] = @@ -349,10 +352,30 @@ void AlertRequest::SendAlertRequest(int32_t app_id) { (*message_)[strings::msg_params][strings::soft_buttons]; MessageHelper::SubscribeApplicationToSoftButton( (*message_)[strings::msg_params], app, function_id()); + msg_params[strings::duration] = 0; + } else { + msg_params[strings::duration] = + (*message_)[strings::msg_params][strings::duration].asUInt(); + } + + if ((*message_)[strings::msg_params].keyExists(strings::alert_icon)) { + auto verification_result = MessageHelper::VerifyImage( + (*message_)[strings::msg_params][strings::alert_icon], + app, + application_manager_); + + if (mobile_apis::Result::INVALID_DATA == verification_result) { + LOG4CXX_ERROR(logger_, "Image verification failed."); + SendResponse(false, verification_result); + return; + } + + msg_params[strings::alert_icon] = + (*message_)[strings::msg_params][strings::alert_icon]; } + // app_id msg_params[strings::app_id] = app_id; - msg_params[strings::duration] = default_timeout_; // NAVI platform progressIndicator if ((*message_)[strings::msg_params].keyExists(strings::progress_indicator)) { @@ -450,4 +473,4 @@ bool AlertRequest::HasHmiResponsesToWait() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/alert_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/alert_response.cc index bab5e5a5d85..b709d139580 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/alert_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/alert_response.cc @@ -32,10 +32,10 @@ */ #include "sdl_rpc_plugin/commands/mobile/alert_response.h" -#include "application_manager/rpc_service.h" #include "application_manager/application_impl.h" -#include "interfaces/MOBILE_API.h" +#include "application_manager/rpc_service.h" #include "interfaces/HMI_API.h" +#include "interfaces/MOBILE_API.h" namespace sdl_rpc_plugin { using namespace application_manager; @@ -64,4 +64,4 @@ void AlertResponse::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/cancel_interaction_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/cancel_interaction_request.cc new file mode 100644 index 00000000000..82e0703da12 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/cancel_interaction_request.cc @@ -0,0 +1,117 @@ + +/* +Copyright (c) 2019, Ford Motor Company, Livio +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. + +Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following +disclaimer in the documentation and/or other materials provided with the +distribution. + +Neither the name of the the copyright holders nor the names of their +contributors may be used to endorse or promote products derived from this +software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. +*/ + +#include "sdl_rpc_plugin/commands/mobile/cancel_interaction_request.h" +#include "application_manager/application_impl.h" +#include "application_manager/message_helper.h" +#include "interfaces/MOBILE_API.h" +#include "utils/helpers.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; +namespace commands { + +CancelInteractionRequest::CancelInteractionRequest( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handler) + : CommandRequestImpl(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handler) {} + +CancelInteractionRequest::~CancelInteractionRequest() {} + +void CancelInteractionRequest::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + auto function_id = static_cast( + (*message_)[strings::msg_params][strings::func_id].asInt()); + + if (helpers:: + Compare( + function_id, + mobile_apis::FunctionID::PerformInteractionID, + mobile_apis::FunctionID::AlertID, + mobile_apis::FunctionID::ScrollableMessageID, + mobile_apis::FunctionID::SliderID)) { + LOG4CXX_ERROR(logger_, "Bad function ID" << function_id); + SendResponse(false, mobile_apis::Result::INVALID_ID); + return; + } + + smart_objects::SmartObject msg_params; + msg_params[strings::app_id] = connection_key(); + msg_params[strings::func_id] = function_id; + + if ((*message_)[strings::msg_params].keyExists(strings::cancel_id)) { + msg_params[strings::cancel_id] = + (*message_)[strings::msg_params][strings::cancel_id].asInt(); + } + + SendHMIRequest(hmi_apis::FunctionID::UI_CancelInteraction, &msg_params, true); +} + +void CancelInteractionRequest::on_event(const event_engine::Event& event) { + LOG4CXX_AUTO_TRACE(logger_); + + if (event.id() != hmi_apis::FunctionID::UI_CancelInteraction) { + LOG4CXX_ERROR(logger_, "Received unknown event" << event.id()); + return; + } + + auto message = event.smart_object(); + + hmi_apis::Common_Result::eType hmi_result = + static_cast( + message[strings::params][hmi_response::code].asInt()); + + mobile_apis::Result::eType result = + MessageHelper::HMIToMobileResult(hmi_result); + bool success = PrepareResultForMobileResponse( + hmi_result, HmiInterfaces::HMI_INTERFACE_UI); + + auto msg_params = message[strings::msg_params]; + + const char* info = msg_params.keyExists(strings::info) + ? msg_params[strings::info].asCharArray() + : NULL; + + SendResponse(success, result, info, &msg_params); +} + +} // namespace commands +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/cancel_interaction_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/cancel_interaction_response.cc new file mode 100644 index 00000000000..af73e72a6f5 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/cancel_interaction_response.cc @@ -0,0 +1,60 @@ +/* + Copyright (c) 2019, Ford Motor Company, Livio + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + + Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following + disclaimer in the documentation and/or other materials provided with the + distribution. + + Neither the name of the the copyright holders nor the names of their + contributors may be used to endorse or promote products derived from this + software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + */ + +#include "sdl_rpc_plugin/commands/mobile/cancel_interaction_response.h" +#include "application_manager/application_impl.h" +#include "interfaces/MOBILE_API.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; +namespace commands { + +CancelInteractionResponse::CancelInteractionResponse( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handler) + : CommandResponseImpl(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handler) {} + +CancelInteractionResponse::~CancelInteractionResponse() {} + +void CancelInteractionResponse::Run() { + LOG4CXX_AUTO_TRACE(logger_); + rpc_service_.SendMessageToMobile(message_); +} + +} // namespace commands +} // namespace sdl_rpc_plugin \ No newline at end of file diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/change_registration_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/change_registration_request.cc index 6af930ea53f..50217a9c8a0 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/change_registration_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/change_registration_request.cc @@ -31,14 +31,15 @@ POSSIBILITY OF SUCH DAMAGE. */ +#include "sdl_rpc_plugin/commands/mobile/change_registration_request.h" #include #include -#include "sdl_rpc_plugin/commands/mobile/change_registration_request.h" -#include "application_manager/application_manager.h" #include "application_manager/application_impl.h" -#include "interfaces/MOBILE_API.h" -#include "interfaces/HMI_API.h" +#include "application_manager/application_manager.h" #include "application_manager/message_helper.h" +#include "application_manager/policies/policy_handler_interface.h" +#include "interfaces/HMI_API.h" +#include "interfaces/MOBILE_API.h" namespace { namespace custom_str = utils::custom_string; @@ -49,9 +50,9 @@ struct IsSameNickname { } private: - const custom_str::CustomString& app_id_; + const custom_str::CustomString app_id_; }; -} +} // namespace namespace sdl_rpc_plugin { using namespace application_manager; @@ -160,7 +161,7 @@ void ChangeRegistrationRequest::Run() { return; } - if (mobile_apis::Result::SUCCESS != CheckCoincidence()) { + if (mobile_apis::Result::SUCCESS != CheckCoincidence(app->device())) { SendResponse(false, mobile_apis::Result::DUPLICATE_NAME); return; } @@ -194,9 +195,9 @@ void ChangeRegistrationRequest::Run() { MessageHelper::VerifyTtsFiles(tts_name, app, application_manager_); if (mobile_apis::Result::FILE_NOT_FOUND == verification_result) { - LOG4CXX_ERROR(logger_, - "MessageHelper::VerifyTtsFiles return " - << verification_result); + LOG4CXX_ERROR( + logger_, + "MessageHelper::VerifyTtsFiles return " << verification_result); SendResponse(false, mobile_apis::Result::FILE_NOT_FOUND, "One or more files needed for tts_name are not present"); @@ -216,9 +217,9 @@ void ChangeRegistrationRequest::Run() { hmi_interfaces.GetInterfaceState( HmiInterfaces::InterfaceID::HMI_INTERFACE_TTS); + using helpers::ALL; using helpers::Compare; using helpers::EQ; - using helpers::ALL; if (Compare( HmiInterfaces::InterfaceState::STATE_NOT_AVAILABLE, @@ -578,36 +579,46 @@ bool ChangeRegistrationRequest::IsWhiteSpaceExist() { return false; } -mobile_apis::Result::eType ChangeRegistrationRequest::CheckCoincidence() { +mobile_apis::Result::eType ChangeRegistrationRequest::CheckCoincidence( + const connection_handler::DeviceHandle& device_id) { LOG4CXX_AUTO_TRACE(logger_); const smart_objects::SmartObject& msg_params = (*message_)[strings::msg_params]; - ApplicationSet accessor = application_manager_.applications().GetData(); + auto compare_tts_name = [](const smart_objects::SmartObject& obj_1, + const smart_objects::SmartObject& obj_2) { + return obj_1[application_manager::strings::text] + .asCustomString() + .CompareIgnoreCase( + obj_2[application_manager::strings::text].asCustomString()); + }; + + const auto& accessor = application_manager_.applications().GetData(); custom_str::CustomString app_name; - uint32_t app_id = connection_key(); + const uint32_t app_id = connection_key(); if (msg_params.keyExists(strings::app_name)) { app_name = msg_params[strings::app_name].asCustomString(); } - ApplicationSetConstIt it = accessor.begin(); - for (; accessor.end() != it; ++it) { - if (app_id == (*it)->app_id()) { + for (const auto& app : accessor) { + if (app->device() != device_id) { + continue; + } + + if (app->app_id() == app_id) { continue; } - const custom_str::CustomString& cur_name = (*it)->name(); + const auto& cur_name = app->name(); if (msg_params.keyExists(strings::app_name)) { if (app_name.CompareIgnoreCase(cur_name)) { LOG4CXX_ERROR(logger_, "Application name is known already."); return mobile_apis::Result::DUPLICATE_NAME; } - - const smart_objects::SmartObject* vr = (*it)->vr_synonyms(); - const std::vector* curr_vr = NULL; - if (NULL != vr) { - curr_vr = vr->asArray(); + const auto vr = app->vr_synonyms(); + if (vr) { + const auto curr_vr = vr->asArray(); CoincidencePredicateVR v(app_name); if (0 != std::count_if(curr_vr->begin(), curr_vr->end(), v)) { @@ -617,18 +628,37 @@ mobile_apis::Result::eType ChangeRegistrationRequest::CheckCoincidence() { } } - // vr check + // VR check if (msg_params.keyExists(strings::vr_synonyms)) { - const std::vector* new_vr = - msg_params[strings::vr_synonyms].asArray(); + const auto new_vr = msg_params[strings::vr_synonyms].asArray(); CoincidencePredicateVR v(cur_name); if (0 != std::count_if(new_vr->begin(), new_vr->end(), v)) { LOG4CXX_ERROR(logger_, "vr_synonyms duplicated with app_name ."); return mobile_apis::Result::DUPLICATE_NAME; } - } // end vr check - } // application for end + } // End vr check + + // TTS check + if (msg_params.keyExists(strings::tts_name) && app->tts_name()) { + const auto tts_array = msg_params[strings::tts_name].asArray(); + const auto tts_curr = app->tts_name()->asArray(); + const auto& it_tts = std::find_first_of(tts_array->begin(), + tts_array->end(), + tts_curr->begin(), + tts_curr->end(), + compare_tts_name); + if (it_tts != tts_array->end()) { + LOG4CXX_ERROR( + logger_, + "TTS name: " + << (*it_tts)[strings::text].asCustomString().AsMBString() + << " is known already"); + return mobile_apis::Result::DUPLICATE_NAME; + } + } // End tts check + + } // Application for end return mobile_apis::Result::SUCCESS; } @@ -638,9 +668,9 @@ bool ChangeRegistrationRequest::IsNicknameAllowed( ApplicationSharedPtr app = application_manager_.application(connection_key()); if (!app) { - LOG4CXX_ERROR(logger_, - "Can't find appication with connection key " - << connection_key()); + LOG4CXX_ERROR( + logger_, + "Can't find appication with connection key " << connection_key()); return false; } @@ -681,4 +711,4 @@ bool ChangeRegistrationRequest::IsNicknameAllowed( } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/change_registration_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/change_registration_response.cc index 2dae92cd9b4..78c60bc7464 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/change_registration_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/change_registration_response.cc @@ -61,4 +61,4 @@ void ChangeRegistrationResponse::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/close_application_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/close_application_request.cc new file mode 100644 index 00000000000..275f1d82a60 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/close_application_request.cc @@ -0,0 +1,119 @@ +/* + Copyright (c) 2019, Ford Motor Company, Livio + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + + Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following + disclaimer in the documentation and/or other materials provided with the + distribution. + + Neither the name of the the copyright holders nor the names of their + contributors may be used to endorse or promote products derived from this + software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + */ + +#include "sdl_rpc_plugin/commands/mobile/close_application_request.h" +#include "application_manager/application_impl.h" +#include "application_manager/message_helper.h" +#include "interfaces/MOBILE_API.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; +namespace commands { + +CloseApplicationRequest::CloseApplicationRequest( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handler) + : CommandRequestImpl(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handler) {} + +CloseApplicationRequest::~CloseApplicationRequest() {} + +void CloseApplicationRequest::Run() { + LOG4CXX_AUTO_TRACE(logger_); + ApplicationSharedPtr app = application_manager_.application(connection_key()); + + if (app.use_count() == 0) { + LOG4CXX_ERROR(logger_, "Application does not exist"); + SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED); + return; + } + + smart_objects::SmartObject msg_params; + msg_params[strings::app_id] = connection_key(); + SendHMIRequest(hmi_apis::FunctionID::BasicCommunication_CloseApplication, + &msg_params, + true); +} + +void CloseApplicationRequest::on_event(const event_engine::Event& event) { + LOG4CXX_AUTO_TRACE(logger_); + const smart_objects::SmartObject& message = event.smart_object(); + + auto msg_params = message[strings::msg_params]; + + hmi_apis::Common_Result::eType hmi_result = + static_cast( + message[strings::params][hmi_response::code].asInt()); + + mobile_apis::Result::eType result = + MessageHelper::HMIToMobileResult(hmi_result); + bool success = PrepareResultForMobileResponse( + hmi_result, HmiInterfaces::HMI_INTERFACE_BasicCommunication); + if (success) { + ApplicationSharedPtr app = + application_manager_.application(connection_key()); + + if (app.use_count() == 0) { + LOG4CXX_ERROR(logger_, "Application does not exist"); + SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED); + return; + } + + auto on_app_exit = [app](plugin_manager::RPCPlugin& plugin) { + plugin.OnApplicationEvent(plugin_manager::kApplicationExit, app); + }; + + application_manager_.GetPluginManager().ForEachPlugin(on_app_exit); + application_manager_.state_controller().SetRegularState( + app, + mobile_apis::PredefinedWindows::DEFAULT_WINDOW, + mobile_apis::HMILevel::HMI_NONE, + mobile_apis::AudioStreamingState::NOT_AUDIBLE, + mobile_apis::VideoStreamingState::NOT_STREAMABLE, + false); + } + + const char* info = msg_params.keyExists(strings::info) + ? msg_params[strings::info].asCharArray() + : NULL; + + SendResponse(success, result, info, &msg_params); +} + +} // namespace commands +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/close_application_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/close_application_response.cc new file mode 100644 index 00000000000..934804e1b1a --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/close_application_response.cc @@ -0,0 +1,61 @@ +/* + Copyright (c) 2019, Ford Motor Company, Livio + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + + Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following + disclaimer in the documentation and/or other materials provided with the + distribution. + + Neither the name of the the copyright holders nor the names of their + contributors may be used to endorse or promote products derived from this + software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + */ + +#include "sdl_rpc_plugin/commands/mobile/close_application_response.h" +#include "application_manager/application_impl.h" +#include "interfaces/MOBILE_API.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; +namespace commands { + +CloseApplicationResponse::CloseApplicationResponse( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handler) + : CommandResponseImpl(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handler) {} + +CloseApplicationResponse::~CloseApplicationResponse() {} + +void CloseApplicationResponse::Run() { + LOG4CXX_AUTO_TRACE(logger_); + rpc_service_.SendMessageToMobile(message_); +} + +} // namespace commands +} // namespace sdl_rpc_plugin 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 416f4f20852..258aefd63f2 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 @@ -31,11 +31,11 @@ POSSIBILITY OF SUCH DAMAGE. */ -#include -#include +#include "sdl_rpc_plugin/commands/mobile/create_interaction_choice_set_request.h" #include +#include +#include #include -#include "sdl_rpc_plugin/commands/mobile/create_interaction_choice_set_request.h" #include "application_manager/application_impl.h" #include "application_manager/message_helper.h" @@ -218,9 +218,9 @@ bool CreateInteractionChoiceSetRequest::compareSynonyms( CreateInteractionChoiceSetRequest::compareStr); if (it != vr_cmds_1->end()) { - LOG4CXX_INFO(logger_, - "Incoming choice set has duplicated VR synonyms " - << it->asString()); + LOG4CXX_INFO( + logger_, + "Incoming choice set has duplicated VR synonyms " << it->asString()); return true; } @@ -332,9 +332,9 @@ void CreateInteractionChoiceSetRequest::SendVRAddCommandRequests( VRCommandInfo vr_command(vr_cmd_id); sent_commands_map_[vr_corr_id] = vr_command; - LOG4CXX_DEBUG(logger_, - "VR_command sent corr_id " << vr_corr_id << " cmd_id " - << vr_corr_id); + LOG4CXX_DEBUG( + logger_, + "VR_command sent corr_id " << vr_corr_id << " cmd_id " << vr_corr_id); } expected_chs_count_ = chs_num; LOG4CXX_DEBUG(logger_, "expected_chs_count_ = " << expected_chs_count_); @@ -480,4 +480,4 @@ void CreateInteractionChoiceSetRequest::OnAllHMIResponsesReceived() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/create_interaction_choice_set_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/create_interaction_choice_set_response.cc index 807770ed122..43dba2f238a 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/create_interaction_choice_set_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/create_interaction_choice_set_response.cc @@ -72,4 +72,4 @@ void CreateInteractionChoiceSetResponse::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/create_window_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/create_window_request.cc new file mode 100644 index 00000000000..b69b0ee8015 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/create_window_request.cc @@ -0,0 +1,376 @@ +/* + Copyright (c) 2019, Ford Motor Company + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + + Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following + disclaimer in the documentation and/or other materials provided with the + distribution. + + Neither the name of the Ford Motor Company nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + */ + +#include "sdl_rpc_plugin/commands/mobile/create_window_request.h" + +#include + +#include "application_manager/application_impl.h" +#include "application_manager/application_state.h" +#include "application_manager/message_helper.h" +#include "utils/helpers.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; +using app_mngr::ApplicationSharedPtr; + +namespace commands { + +CreateWindowRequest::CreateWindowRequest( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handler) + : CommandRequestImpl(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handler) {} + +CreateWindowRequest::~CreateWindowRequest() {} + +bool CreateWindowRequest::CheckWindowName( + app_mngr::ApplicationSharedPtr app, + const app_mngr::WindowID window_id, + const std::string& window_name) const { + if (mobile_apis::PredefinedWindows::PRIMARY_WIDGET == window_id) { + LOG4CXX_DEBUG(logger_, + "Window name check is ignored for the primary widgets"); + return true; + } + + const bool names_are_equal = window_name == app->name().c_str(); + if (names_are_equal && + mobile_apis::PredefinedWindows::DEFAULT_WINDOW != window_id) { + LOG4CXX_ERROR(logger_, + "Regular widget can't have the same name as application: " + << window_name); + return false; + } + + const WindowNames window_names = app->GetWindowNames(); + return !helpers::in_range(window_names, window_name); +} + +void CreateWindowRequest::ApplyWindowInitialState( + ApplicationSharedPtr app) const { + const mobile_apis::WindowType::eType window_type = + static_cast( + (*message_)[strings::msg_params][strings::window_type].asInt()); + + // State should be initialized with INVALID_ENUM value to let state controller + // trigger OnHmiStatus notifiation sending + HmiStatePtr initial_state = application_manager_.CreateRegularState( + app, + window_type, + mobile_apis::HMILevel::INVALID_ENUM, + mobile_apis::AudioStreamingState::INVALID_ENUM, + mobile_apis::VideoStreamingState::INVALID_ENUM, + mobile_api::SystemContext::INVALID_ENUM); + + const WindowID window_id = + (*message_)[strings::msg_params][strings::window_id].asInt(); + const std::string window_name = + (*message_)[strings::msg_params][strings::window_name].asString(); + + smart_objects::SmartObject window_info(smart_objects::SmartType_Map); + if ((*message_)[strings::msg_params].keyExists( + strings::associated_service_type)) { + window_info[strings::associated_service_type] = + (*message_)[strings::msg_params][strings::associated_service_type]; + } + if ((*message_)[strings::msg_params].keyExists( + strings::duplicate_updates_from_window_id)) { + window_info[strings::duplicate_updates_from_window_id] = + (*message_)[strings::msg_params] + [strings::duplicate_updates_from_window_id]; + } + + window_info[strings::window_name] = window_name; + + app->SetWindowInfo(window_id, window_info); + + app->SetInitialState(window_id, window_name, initial_state); + + // Default HMI level for all windows except the main one is always NONE + application_manager_.state_controller().OnAppWindowAdded( + app, window_id, window_type, mobile_apis::HMILevel::HMI_NONE); +} + +app_mngr::WindowID CreateWindowRequest::window_id() const { + return mobile_apis::PredefinedWindows::DEFAULT_WINDOW; +} + +void CreateWindowRequest::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + const auto application = application_manager_.application(connection_key()); + + if (!application) { + LOG4CXX_ERROR(logger_, "Application is not registered"); + SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED); + return; + } + + const auto window_id = + (*message_)[strings::msg_params][strings::window_id].asInt(); + if (application->WindowIdExists(window_id)) { + LOG4CXX_ERROR(logger_, + "Window with id #" << window_id << " does already exist"); + SendResponse(false, mobile_apis::Result::INVALID_ID); + return; + } + + const auto window_type = + (*message_)[strings::msg_params][strings::window_type].asInt(); + + if (mobile_apis::WindowType::eType::MAIN == window_type) { + LOG4CXX_ERROR(logger_, "MAIN application window already exists"); + SendResponse(false, mobile_apis::Result::INVALID_DATA); + return; + } + + if ((*message_)[strings::msg_params].keyExists( + strings::duplicate_updates_from_window_id)) { + const auto duplicate_updates_from_window_id = + (*message_)[strings::msg_params] + [strings::duplicate_updates_from_window_id] + .asInt(); + if (!application->WindowIdExists(duplicate_updates_from_window_id)) { + LOG4CXX_ERROR(logger_, + "Window with id #" << duplicate_updates_from_window_id + << " does not exist"); + SendResponse(false, mobile_apis::Result::INVALID_DATA); + return; + } + } + + const std::string window_name = + (*message_)[strings::msg_params][strings::window_name].asString(); + if (!CheckWindowName(application, window_id, window_name)) { + LOG4CXX_ERROR(logger_, + "Window name \"" << window_name + << "\" is disallowed for window #" + << window_id); + SendResponse(false, mobile_apis::Result::DUPLICATE_NAME); + return; + } + + if (!ValidateWindowCreation(application, window_id)) { + return; + } + + smart_objects::SmartObject msg_params = (*message_)[strings::msg_params]; + msg_params[strings::app_id] = application->hmi_app_id(); + + StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_UI); + SendHMIRequest(hmi_apis::FunctionID::UI_CreateWindow, &msg_params, true); +} + +void CreateWindowRequest::on_event(const event_engine::Event& event) { + LOG4CXX_AUTO_TRACE(logger_); + + if (hmi_apis::FunctionID::UI_CreateWindow != event.id()) { + LOG4CXX_ERROR(logger_, "Received unknown event" << event.id()); + return; + } + + auto application = application_manager_.application(connection_key()); + + if (!application) { + LOG4CXX_ERROR(logger_, "Application is not registered"); + SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED); + return; + } + + LOG4CXX_INFO(logger_, "Received CreateWindow event"); + EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_UI); + + const smart_objects::SmartObject& response_message = event.smart_object(); + const auto result_code = CommandRequestImpl::GetMobileResultCode( + static_cast( + response_message[strings::params][hmi_response::code].asInt())); + + const bool is_success = IsMobileResultSuccess(result_code); + std::string response_info; + GetInfo(response_message, response_info); + + if (!is_success) { + LOG4CXX_ERROR(logger_, "CreateWindow request has failed on HMI side"); + SendResponse(is_success, + result_code, + response_info.empty() ? nullptr : response_info.c_str()); + return; + } + + ApplyWindowInitialState(application); + + SendResponse(is_success, + result_code, + response_info.empty() ? nullptr : response_info.c_str()); +} + +bool CreateWindowRequest::Init() { + hash_update_mode_ = HashUpdateMode::kDoHashUpdate; + return true; +} + +bool CreateWindowRequest::IsWindowForAssociatedServiceCreated( + app_mngr::ApplicationSharedPtr app) const { + LOG4CXX_AUTO_TRACE(logger_); + + const auto window_optional_params_map = + app->window_optional_params_map().GetData(); + + if (!(*message_)[strings::msg_params].keyExists( + strings::associated_service_type)) { + return false; + } + + const auto associated_service_type = + (*message_)[strings::msg_params][strings::associated_service_type] + .asString(); + + const auto find_res = std::find_if( + window_optional_params_map.begin(), + window_optional_params_map.end(), + [&associated_service_type]( + const std::pair& element) { + LOG4CXX_DEBUG(logger_, + "Searching for " << associated_service_type + << " in window info for id " + << element.first); + if (element.second->keyExists(strings::associated_service_type) && + associated_service_type == + (*element.second)[strings::associated_service_type] + .asString()) { + return true; + } + + return false; + }); + + return find_res != window_optional_params_map.end(); +} + +bool CreateWindowRequest::DoesExceedMaxAllowedWindows( + app_mngr::ApplicationSharedPtr app) const { + LOG4CXX_AUTO_TRACE(logger_); + + auto get_current_number_of_windows = + [&app](const mobile_apis::WindowType::eType window_type) -> size_t { + switch (window_type) { + case mobile_apis::WindowType::MAIN: { + return 1u; + } + case mobile_apis::WindowType::WIDGET: { + return app->window_optional_params_map().GetData().size(); + } + + default: { + LOG4CXX_WARN(logger_, "Unknown window type"); + return 0u; + } + } + }; + + const auto window_type = static_cast( + (*message_)[strings::msg_params][strings::window_type].asInt()); + + auto display_capabilities = hmi_capabilities_.system_display_capabilities(); + if (app->display_capabilities()) { + display_capabilities = app->display_capabilities(); + } + + if (!display_capabilities) { + LOG4CXX_WARN(logger_, "Application has no capabilities"); + return false; + } + + MessageHelper::PrintSmartObject(*display_capabilities); + + const auto windowTypeSupported = + (*display_capabilities)[0][strings::window_type_supported].asArray(); + + DCHECK(windowTypeSupported); + + const auto find_res = std::find_if( + windowTypeSupported->begin(), + windowTypeSupported->end(), + [&window_type](const smart_objects::SmartObject& element) { + if (window_type == static_cast( + element[strings::window_type].asInt())) { + return true; + } + + return false; + }); + + if (find_res == windowTypeSupported->end()) { + LOG4CXX_WARN(logger_, "Requested Window Type is not supported by the HMI"); + return true; + } + + if (get_current_number_of_windows(window_type) + 1 > + (*find_res)[strings::maximum_number_of_windows].asUInt()) { + return true; + } + + return false; +} + +bool CreateWindowRequest::ValidateWindowCreation( + app_mngr::ApplicationSharedPtr app, const WindowID window_id) { + LOG4CXX_AUTO_TRACE(logger_); + + if (DoesExceedMaxAllowedWindows(app)) { + std::string info("Maximum allowed amount of windows is exceeded"); + LOG4CXX_WARN(logger_, info); + SendResponse(false, mobile_apis::Result::REJECTED, info.c_str()); + return false; + } + + if (IsWindowForAssociatedServiceCreated(app)) { + std::string info( + "Window for this associated service type is already created"); + LOG4CXX_WARN(logger_, info); + SendResponse(false, mobile_apis::Result::REJECTED, info.c_str()); + return false; + } + + return true; +} + +} // namespace commands + +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/create_window_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/create_window_response.cc new file mode 100644 index 00000000000..0d9bbc2815f --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/create_window_response.cc @@ -0,0 +1,64 @@ +/* + + Copyright (c) 2019, Ford Motor Company + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + + Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following + disclaimer in the documentation and/or other materials provided with the + distribution. + + Neither the name of the Ford Motor Company nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + */ + +#include "sdl_rpc_plugin/commands/mobile/create_window_response.h" +#include "application_manager/rpc_service.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +CreateWindowResponse::CreateWindowResponse( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handler) + : CommandResponseImpl(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handler) {} + +CreateWindowResponse::~CreateWindowResponse() {} + +void CreateWindowResponse::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + rpc_service_.SendMessageToMobile(message_); +} + +} // namespace commands + +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/delete_command_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/delete_command_request.cc index 38069c341e7..363b14f92f4 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/delete_command_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/delete_command_request.cc @@ -35,8 +35,8 @@ #include "application_manager/application_impl.h" #include "application_manager/message_helper.h" -#include "interfaces/MOBILE_API.h" #include "interfaces/HMI_API.h" +#include "interfaces/MOBILE_API.h" #include "utils/helpers.h" namespace sdl_rpc_plugin { @@ -204,8 +204,9 @@ void DeleteCommandRequest::on_event(const event_engine::Event& event) { if (!command) { LOG4CXX_ERROR(logger_, - "Command id " << cmd_id << " not found for " - "application with connection key " + "Command id " << cmd_id + << " not found for " + "application with connection key " << connection_key()); return; } @@ -232,4 +233,4 @@ bool DeleteCommandRequest::IsPendingResponseExist() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/delete_command_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/delete_command_response.cc index 8f85d50e288..919385ee502 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/delete_command_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/delete_command_response.cc @@ -61,4 +61,4 @@ void DeleteCommandResponse::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/delete_file_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/delete_file_request.cc index cf8a6d259f0..46af8353b75 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/delete_file_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/delete_file_request.cc @@ -68,7 +68,9 @@ void DeleteFileRequest::Run() { return; } - if ((mobile_api::HMILevel::HMI_NONE == application->hmi_level()) && + if ((mobile_api::HMILevel::HMI_NONE == + application->hmi_level( + mobile_apis::PredefinedWindows::DEFAULT_WINDOW)) && (application_manager_.get_settings().delete_file_in_none() <= application->delete_file_in_none_count())) { // If application is in the HMI_NONE level the quantity of allowed @@ -129,4 +131,4 @@ void DeleteFileRequest::SendFileRemovedNotification( } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/delete_file_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/delete_file_response.cc index 66c61c9e4ad..732a1e56b59 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/delete_file_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/delete_file_response.cc @@ -72,4 +72,4 @@ void DeleteFileResponse::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/delete_interaction_choice_set_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/delete_interaction_choice_set_request.cc index a9db3975db1..7950595b1cf 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/delete_interaction_choice_set_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/delete_interaction_choice_set_request.cc @@ -34,9 +34,9 @@ #include "sdl_rpc_plugin/commands/mobile/delete_interaction_choice_set_request.h" #include "application_manager/application_impl.h" -#include "interfaces/MOBILE_API.h" -#include "interfaces/HMI_API.h" #include "application_manager/message_helper.h" +#include "interfaces/HMI_API.h" +#include "interfaces/MOBILE_API.h" namespace sdl_rpc_plugin { using namespace application_manager; @@ -63,9 +63,9 @@ void DeleteInteractionChoiceSetRequest::Run() { ApplicationSharedPtr app = application_manager_.application(connection_key()); if (!app) { - LOG4CXX_ERROR(logger_, - "No application associated with connection key " - << connection_key()); + LOG4CXX_ERROR( + logger_, + "No application associated with connection key " << connection_key()); SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED); return; } @@ -165,4 +165,4 @@ void DeleteInteractionChoiceSetRequest::SendVrDeleteCommand( } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/delete_interaction_choice_set_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/delete_interaction_choice_set_response.cc index 18ca60f255f..cf5ad3a2c2b 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/delete_interaction_choice_set_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/delete_interaction_choice_set_response.cc @@ -34,8 +34,8 @@ #include "sdl_rpc_plugin/commands/mobile/delete_interaction_choice_set_response.h" #include "application_manager/application_impl.h" -#include "interfaces/MOBILE_API.h" #include "interfaces/HMI_API.h" +#include "interfaces/MOBILE_API.h" namespace sdl_rpc_plugin { using namespace application_manager; @@ -81,4 +81,4 @@ void DeleteInteractionChoiceSetResponse::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/delete_sub_menu_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/delete_sub_menu_request.cc index 9a011637025..6aaa2406e8d 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/delete_sub_menu_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/delete_sub_menu_request.cc @@ -33,8 +33,8 @@ #include "sdl_rpc_plugin/commands/mobile/delete_sub_menu_request.h" -#include "application_manager/message_helper.h" #include "application_manager/application_impl.h" +#include "application_manager/message_helper.h" #include "interfaces/HMI_API.h" #include "utils/helpers.h" @@ -200,4 +200,4 @@ bool DeleteSubMenuRequest::Init() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/delete_sub_menu_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/delete_sub_menu_response.cc index 6831a66e1e5..3cefef5c387 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/delete_sub_menu_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/delete_sub_menu_response.cc @@ -61,4 +61,4 @@ void DeleteSubMenuResponse::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/delete_window_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/delete_window_request.cc new file mode 100644 index 00000000000..7f253e25fd3 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/delete_window_request.cc @@ -0,0 +1,162 @@ +/* + Copyright (c) 2019, Ford Motor Company + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + + Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following + disclaimer in the documentation and/or other materials provided with the + distribution. + + Neither the name of the Ford Motor Company nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + */ + +#include "sdl_rpc_plugin/commands/mobile/delete_window_request.h" + +#include + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +DeleteWindowRequest::DeleteWindowRequest( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handler) + : CommandRequestImpl(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handler) {} + +DeleteWindowRequest::~DeleteWindowRequest() {} + +bool DeleteWindowRequest::CheckWindowId( + app_mngr::ApplicationSharedPtr app) const { + const WindowID window_id = + (*message_)[strings::msg_params][strings::window_id].asInt(); + if (mobile_apis::PredefinedWindows::DEFAULT_WINDOW == window_id) { + LOG4CXX_ERROR(logger_, "Main application window can't be deleted"); + return false; + } + + if (!app->WindowIdExists(window_id)) { + LOG4CXX_ERROR(logger_, + "Window with id #" << window_id << " does not exist"); + return false; + } + + return true; +} + +app_mngr::WindowID DeleteWindowRequest::window_id() const { + return mobile_apis::PredefinedWindows::DEFAULT_WINDOW; +} + +void DeleteWindowRequest::DeleteWindow( + app_mngr::ApplicationSharedPtr app) const { + const WindowID window_id = + (*message_)[strings::msg_params][strings::window_id].asInt(); + app->RemoveWindowInfo(window_id); + app->RemoveHMIState(window_id, HmiState::StateID::STATE_ID_REGULAR); + app->remove_window_capability(window_id); +} + +void DeleteWindowRequest::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + ApplicationSharedPtr application = + application_manager_.application(connection_key()); + + if (!application) { + LOG4CXX_ERROR(logger_, "Application is not registered"); + SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED); + return; + } + + if (!CheckWindowId(application)) { + SendResponse(false, mobile_apis::Result::INVALID_ID); + return; + } + + smart_objects::SmartObject msg_params = (*message_)[strings::msg_params]; + msg_params[strings::app_id] = application->hmi_app_id(); + + StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_UI); + SendHMIRequest(hmi_apis::FunctionID::UI_DeleteWindow, &msg_params, true); +} + +void DeleteWindowRequest::on_event(const event_engine::Event& event) { + LOG4CXX_AUTO_TRACE(logger_); + + if (hmi_apis::FunctionID::UI_DeleteWindow != event.id()) { + LOG4CXX_ERROR(logger_, "Received unknown event" << event.id()); + return; + } + + ApplicationSharedPtr application = + application_manager_.application(connection_key()); + + if (!application) { + LOG4CXX_ERROR(logger_, "Application is not registered"); + SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED); + return; + } + + LOG4CXX_INFO(logger_, "Received DeleteWindow event"); + EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_UI); + + const smart_objects::SmartObject& response_message = event.smart_object(); + const auto result_code = CommandRequestImpl::GetMobileResultCode( + static_cast( + response_message[strings::params][hmi_response::code].asInt())); + + const bool is_success = IsMobileResultSuccess(result_code); + std::string response_info; + GetInfo(response_message, response_info); + + if (!is_success) { + LOG4CXX_ERROR(logger_, "DeleteWindow request has failed on HMI side"); + SendResponse(is_success, + result_code, + response_info.empty() ? nullptr : response_info.c_str()); + return; + } + + DeleteWindow(application); + + SendResponse(is_success, + result_code, + response_info.empty() ? nullptr : response_info.c_str()); +} + +bool DeleteWindowRequest::Init() { + hash_update_mode_ = HashUpdateMode::kDoHashUpdate; + return true; +} + +} // namespace commands + +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/delete_window_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/delete_window_response.cc new file mode 100644 index 00000000000..f9ac9a46d69 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/delete_window_response.cc @@ -0,0 +1,64 @@ +/* + + Copyright (c) 2019, Ford Motor Company + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + + Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following + disclaimer in the documentation and/or other materials provided with the + distribution. + + Neither the name of the Ford Motor Company nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + */ + +#include "sdl_rpc_plugin/commands/mobile/delete_window_response.h" +#include "application_manager/rpc_service.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +DeleteWindowResponse::DeleteWindowResponse( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handler) + : CommandResponseImpl(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handler) {} + +DeleteWindowResponse::~DeleteWindowResponse() {} + +void DeleteWindowResponse::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + rpc_service_.SendMessageToMobile(message_); +} + +} // namespace commands + +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/dial_number_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/dial_number_request.cc index ee0297ded6b..1de7a3ea03e 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/dial_number_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/dial_number_request.cc @@ -30,9 +30,9 @@ POSSIBILITY OF SUCH DAMAGE. */ +#include "sdl_rpc_plugin/commands/mobile/dial_number_request.h" #include #include -#include "sdl_rpc_plugin/commands/mobile/dial_number_request.h" #include "application_manager/application_impl.h" @@ -153,4 +153,4 @@ void DialNumberRequest::StripNumberParam(std::string& number) { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/dial_number_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/dial_number_response.cc index a264f96e0d8..4385b3fe90f 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/dial_number_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/dial_number_response.cc @@ -60,4 +60,4 @@ void DialNumberResponse::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/end_audio_pass_thru_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/end_audio_pass_thru_request.cc index 3650a8226cb..66ff7b48d5e 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/end_audio_pass_thru_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/end_audio_pass_thru_request.cc @@ -97,4 +97,4 @@ void EndAudioPassThruRequest::on_event(const event_engine::Event& event) { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/end_audio_pass_thru_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/end_audio_pass_thru_response.cc index f9f9f89d116..6c9bd05e09f 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/end_audio_pass_thru_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/end_audio_pass_thru_response.cc @@ -61,4 +61,4 @@ void EndAudioPassThruResponse::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/generic_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/generic_response.cc index b0715225e4f..fda6cc64e5e 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/generic_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/generic_response.cc @@ -63,4 +63,4 @@ void GenericResponse::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/get_cloud_app_properties_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/get_cloud_app_properties_request.cc index 34ed30c2430..0b7e611e591 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/get_cloud_app_properties_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/get_cloud_app_properties_request.cc @@ -1,4 +1,5 @@ #include "sdl_rpc_plugin/commands/mobile/get_cloud_app_properties_request.h" +#include "application_manager/policies/policy_handler_interface.h" namespace sdl_rpc_plugin { using namespace application_manager; diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/get_cloud_app_properties_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/get_cloud_app_properties_response.cc index 813a9e70066..f50897303a2 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/get_cloud_app_properties_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/get_cloud_app_properties_response.cc @@ -1,6 +1,6 @@ +#include "sdl_rpc_plugin/commands/mobile/get_cloud_app_properties_response.h" #include "application_manager/application_manager.h" #include "application_manager/rpc_service.h" -#include "sdl_rpc_plugin/commands/mobile/get_cloud_app_properties_response.h" namespace sdl_rpc_plugin { using namespace application_manager; @@ -28,4 +28,4 @@ void GetCloudAppPropertiesResponse::Run() { } } // namespace commands -} // namespace sdl_rpc_plugins +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/get_file_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/get_file_request.cc index a582670426d..75263494c2a 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/get_file_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/get_file_request.cc @@ -32,20 +32,20 @@ #include "sdl_rpc_plugin/commands/mobile/get_file_request.h" +#include #include "application_manager/app_service_manager.h" #include "application_manager/application_impl.h" +#include "application_manager/message_helper.h" #include "application_manager/rpc_service.h" #include "interfaces/MOBILE_API.h" -#include "application_manager/message_helper.h" #include "utils/file_system.h" -#include namespace { /** -* Calculates CRC32 checksum -* @param binary_data - input data for which CRC32 should be calculated -* @return calculated CRC32 checksum -*/ + * Calculates CRC32 checksum + * @param binary_data - input data for which CRC32 should be calculated + * @return calculated CRC32 checksum + */ uint32_t GetCrc32CheckSum(const std::vector& binary_data) { const std::size_t file_size = binary_data.size(); boost::crc_32_type result; @@ -195,9 +195,9 @@ void GetFileRequest::Run() { } if (offset_ > file_size) { - LOG4CXX_ERROR(logger_, - "Offset " << offset_ << " greater than file size " - << file_size); + LOG4CXX_ERROR( + logger_, + "Offset " << offset_ << " greater than file size " << file_size); SendResponse(false, mobile_apis::Result::INVALID_DATA, "Offset greater than file size", @@ -309,9 +309,9 @@ void GetFileRequest::on_event(const app_mngr::event_engine::Event& event) { } if (offset_ > file_size) { - LOG4CXX_ERROR(logger_, - "Offset " << offset_ << " greater than file size " - << file_size); + LOG4CXX_ERROR( + logger_, + "Offset " << offset_ << " greater than file size " << file_size); SendResponse(false, mobile_apis::Result::INVALID_DATA, "Offset greater than file size", diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/get_system_capability_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/get_system_capability_request.cc index 5c6839660fd..6121747ccc2 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/get_system_capability_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/get_system_capability_request.cc @@ -32,10 +32,10 @@ #include "sdl_rpc_plugin/commands/mobile/get_system_capability_request.h" -#include "sdl_rpc_plugin/extensions/system_capability_app_extension.h" +#include #include "application_manager/app_service_manager.h" #include "application_manager/message_helper.h" -#include +#include "sdl_rpc_plugin/extensions/system_capability_app_extension.h" namespace sdl_rpc_plugin { using namespace application_manager; @@ -133,6 +133,17 @@ void GetSystemCapabilityRequest::Run() { } break; } + case mobile_apis::SystemCapabilityType::SEAT_LOCATION: { + if (hmi_capabilities.seat_location_capability()) { + response_params[strings::system_capability] + [strings::seat_location_capability] = + *hmi_capabilities.seat_location_capability(); + } else { + SendResponse(false, mobile_apis::Result::DATA_NOT_AVAILABLE); + return; + } + break; + } case mobile_apis::SystemCapabilityType::VIDEO_STREAMING: if (hmi_capabilities.video_streaming_capability()) { response_params[strings::system_capability] @@ -146,9 +157,26 @@ void GetSystemCapabilityRequest::Run() { case mobile_apis::SystemCapabilityType::APP_SERVICES: { auto all_services = application_manager_.GetAppServiceManager().GetAllServiceRecords(); - response_params - [strings::system_capability][strings::app_services_capabilities] = - MessageHelper::CreateAppServiceCapabilities(all_services); + response_params[strings::system_capability] + [strings::app_services_capabilities] = + MessageHelper::CreateAppServiceCapabilities( + all_services); + break; + } + case mobile_apis::SystemCapabilityType::DISPLAYS: { + auto capabilities = hmi_capabilities.system_display_capabilities(); + if (app->display_capabilities()) { + capabilities = app->display_capabilities(); + } + + if (!capabilities) { + SendResponse(false, mobile_apis::Result::DATA_NOT_AVAILABLE); + LOG4CXX_INFO(logger_, "system_display_capabilities are not available"); + return; + } + + response_params[strings::system_capability] + [strings::display_capabilities] = *capabilities; break; } default: // Return unsupported resource @@ -156,22 +184,33 @@ void GetSystemCapabilityRequest::Run() { return; } - if ((*message_)[app_mngr::strings::msg_params].keyExists( - strings::subscribe)) { - auto& ext = SystemCapabilityAppExtension::ExtractExtension(*app); - if ((*message_)[app_mngr::strings::msg_params][strings::subscribe] - .asBool() == true) { - LOG4CXX_DEBUG(logger_, - "Subscribe to system capability: " << response_type); - ext.SubscribeTo(response_type); - } else { - LOG4CXX_DEBUG(logger_, - "Unsubscribe from system capability: " << response_type); - ext.UnsubscribeFrom(response_type); + const char* info = nullptr; + // Ignore subscription/unsubscription for DISPLAYS type + if (mobile_apis::SystemCapabilityType::DISPLAYS != response_type) { + if ((*message_)[app_mngr::strings::msg_params].keyExists( + strings::subscribe)) { + auto& ext = SystemCapabilityAppExtension::ExtractExtension(*app); + if ((*message_)[app_mngr::strings::msg_params][strings::subscribe] + .asBool() == true) { + LOG4CXX_DEBUG(logger_, + "Subscribe to system capability: " << response_type); + ext.SubscribeTo(response_type); + } else { + LOG4CXX_DEBUG(logger_, + "Unsubscribe from system capability: " << response_type); + ext.UnsubscribeFrom(response_type); + } + } + } else { + if ((*message_)[app_mngr::strings::msg_params].keyExists( + strings::subscribe)) { + info = + "Subscribe parameter is ignored. Auto Subscription/Unsubscription is " + "used for DISPLAY capability type."; } } - SendResponse(true, mobile_apis::Result::SUCCESS, NULL, &response_params); + SendResponse(true, mobile_apis::Result::SUCCESS, info, &response_params); } void GetSystemCapabilityRequest::on_event(const event_engine::Event& event) { @@ -179,4 +218,4 @@ void GetSystemCapabilityRequest::on_event(const event_engine::Event& event) { } } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/get_system_capability_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/get_system_capability_response.cc index dd5461081cb..5df0c726071 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/get_system_capability_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/get_system_capability_response.cc @@ -30,9 +30,9 @@ POSSIBILITY OF SUCH DAMAGE. */ +#include "sdl_rpc_plugin/commands/mobile/get_system_capability_response.h" #include "application_manager/application_manager.h" #include "application_manager/rpc_service.h" -#include "sdl_rpc_plugin/commands/mobile/get_system_capability_response.h" namespace sdl_rpc_plugin { using namespace application_manager; @@ -61,4 +61,4 @@ void GetSystemCapabilityResponse::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/get_way_points_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/get_way_points_request.cc index 7dc9eb9ad99..cd7d7a37b72 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/get_way_points_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/get_way_points_request.cc @@ -30,8 +30,8 @@ POSSIBILITY OF SUCH DAMAGE. */ -#include "application_manager/application_manager.h" #include "sdl_rpc_plugin/commands/mobile/get_way_points_request.h" +#include "application_manager/application_manager.h" #include "application_manager/message_helper.h" namespace sdl_rpc_plugin { @@ -113,4 +113,4 @@ void GetWayPointsRequest::on_event(const event_engine::Event& event) { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/get_way_points_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/get_way_points_response.cc index 75819902731..e481c926b81 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/get_way_points_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/get_way_points_response.cc @@ -30,8 +30,8 @@ POSSIBILITY OF SUCH DAMAGE. */ -#include "application_manager/application_manager.h" #include "sdl_rpc_plugin/commands/mobile/get_way_points_response.h" +#include "application_manager/application_manager.h" #include "application_manager/rpc_service.h" namespace sdl_rpc_plugin { @@ -61,4 +61,4 @@ void GetWayPointsResponse::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/list_files_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/list_files_request.cc index e671dab4635..b8714b47845 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/list_files_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/list_files_request.cc @@ -31,8 +31,8 @@ POSSIBILITY OF SUCH DAMAGE. */ -#include #include "sdl_rpc_plugin/commands/mobile/list_files_request.h" +#include #include "application_manager/application_impl.h" @@ -70,7 +70,9 @@ void ListFilesRequest::Run() { return; } - if ((mobile_api::HMILevel::HMI_NONE == application->hmi_level()) && + if ((mobile_api::HMILevel::HMI_NONE == + application->hmi_level( + mobile_apis::PredefinedWindows::DEFAULT_WINDOW)) && (application_manager_.get_settings().list_files_in_none() <= application->list_files_in_none_count())) { // If application is in the HMI_NONE level the quantity of allowed @@ -112,4 +114,4 @@ void ListFilesRequest::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/list_files_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/list_files_response.cc index d025f053580..ffa8a443d58 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/list_files_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/list_files_response.cc @@ -32,8 +32,8 @@ */ #include "sdl_rpc_plugin/commands/mobile/list_files_response.h" -#include "application_manager/rpc_service.h" #include "application_manager/application_impl.h" +#include "application_manager/rpc_service.h" namespace sdl_rpc_plugin { using namespace application_manager; @@ -62,4 +62,4 @@ void ListFilesResponse::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_app_interface_unregistered_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_app_interface_unregistered_notification.cc index 128ce1e3bfc..5714043a510 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_app_interface_unregistered_notification.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_app_interface_unregistered_notification.cc @@ -60,4 +60,4 @@ void OnAppInterfaceUnregisteredNotification::Run() { SendNotification(); } } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_audio_pass_thru_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_audio_pass_thru_notification.cc index ff88ae96bdd..3088c7df33f 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_audio_pass_thru_notification.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_audio_pass_thru_notification.cc @@ -57,4 +57,4 @@ void OnAudioPassThruNotification::Run() { SendNotification(); } } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin 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 79fb1f4272f..0bf9b40cb62 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 @@ -79,9 +79,8 @@ void OnButtonEventNotification::Run() { (*message_)[strings::msg_params][strings::app_id].asUInt()); // custom_button_id is mandatory for CUSTOM_BUTTON notification - if (false == - (*message_)[strings::msg_params].keyExists( - hmi_response::custom_button_id)) { + if (false == (*message_)[strings::msg_params].keyExists( + hmi_response::custom_button_id)) { LOG4CXX_ERROR(logger_, "CUSTOM_BUTTON OnButtonEvent without custom_button_id."); return; @@ -103,8 +102,11 @@ void OnButtonEventNotification::Run() { return; } - if ((mobile_api::HMILevel::HMI_FULL != app->hmi_level()) && - (mobile_api::HMILevel::HMI_LIMITED != app->hmi_level())) { + const auto window_id = app->GetSoftButtonWindowID(custom_btn_id); + (*message_)[strings::msg_params][strings::window_id] = window_id; + const auto window_hmi_level = app->hmi_level(window_id); + if ((mobile_api::HMILevel::HMI_FULL != window_hmi_level) && + (mobile_api::HMILevel::HMI_LIMITED != window_hmi_level)) { LOG4CXX_WARN(logger_, "CUSTOM_BUTTON OnButtonEvent notification is allowed only " << "in FULL or LIMITED hmi level"); @@ -128,8 +130,11 @@ void OnButtonEventNotification::Run() { } // Send ButtonEvent notification only in HMI_FULL or HMI_LIMITED mode - if ((mobile_api::HMILevel::HMI_FULL != subscribed_app->hmi_level()) && - (mobile_api::HMILevel::HMI_LIMITED != subscribed_app->hmi_level())) { + const mobile_apis::HMILevel::eType app_hmi_level = + subscribed_app->hmi_level( + mobile_apis::PredefinedWindows::DEFAULT_WINDOW); + if ((mobile_api::HMILevel::HMI_FULL != app_hmi_level) && + (mobile_api::HMILevel::HMI_LIMITED != app_hmi_level)) { LOG4CXX_WARN(logger_, "OnButtonEvent notification is allowed only" << "in FULL or LIMITED hmi level"); @@ -180,6 +185,11 @@ void OnButtonEventNotification::SendButtonEvent(ApplicationConstSharedPtr app) { (*message_)[strings::msg_params][strings::custom_button_id]; } + if ((*message_)[strings::msg_params].keyExists(strings::window_id)) { + (*on_btn_event)[strings::msg_params][strings::window_id] = + (*message_)[strings::msg_params][strings::window_id]; + } + message_ = on_btn_event; SendNotification(); } @@ -188,4 +198,4 @@ void OnButtonEventNotification::SendButtonEvent(ApplicationConstSharedPtr app) { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin 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 c73f2b4b984..8c22844865d 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 @@ -80,9 +80,8 @@ void OnButtonPressNotification::Run() { (*message_)[strings::msg_params][strings::app_id].asUInt()); // custom_button_id is mandatory for CUSTOM_BUTTON notification - if (false == - (*message_)[strings::msg_params].keyExists( - hmi_response::custom_button_id)) { + if (false == (*message_)[strings::msg_params].keyExists( + hmi_response::custom_button_id)) { LOG4CXX_ERROR(logger_, "CUSTOM_BUTTON OnButtonPress without custom_button_id."); return; @@ -105,8 +104,12 @@ void OnButtonPressNotification::Run() { } // Send ButtonPress notification only in HMI_FULL or HMI_LIMITED mode - if ((mobile_api::HMILevel::HMI_FULL != app->hmi_level()) && - (mobile_api::HMILevel::HMI_LIMITED != app->hmi_level())) { + const auto window_id = app->GetSoftButtonWindowID(custom_btn_id); + app->hmi_level(mobile_apis::PredefinedWindows::DEFAULT_WINDOW); + (*message_)[strings::msg_params][strings::window_id] = window_id; + const auto window_hmi_level = app->hmi_level(window_id); + if ((mobile_api::HMILevel::HMI_FULL != window_hmi_level) && + (mobile_api::HMILevel::HMI_LIMITED != window_hmi_level)) { LOG4CXX_WARN(logger_, "CUSTOM_BUTTON OnButtonPress notification is allowed only " << "in FULL or LIMITED hmi level"); @@ -130,8 +133,11 @@ void OnButtonPressNotification::Run() { } // Send ButtonPress notification only in HMI_FULL or HMI_LIMITED mode - if ((mobile_api::HMILevel::HMI_FULL != subscribed_app->hmi_level()) && - (mobile_api::HMILevel::HMI_LIMITED != subscribed_app->hmi_level())) { + const mobile_apis::HMILevel::eType app_hmi_level = + subscribed_app->hmi_level( + mobile_apis::PredefinedWindows::DEFAULT_WINDOW); + if ((mobile_api::HMILevel::HMI_FULL != app_hmi_level) && + (mobile_api::HMILevel::HMI_LIMITED != app_hmi_level)) { LOG4CXX_WARN(logger_, "OnButtonPress notification is allowed only" << "in FULL or LIMITED hmi level"); @@ -188,6 +194,11 @@ void OnButtonPressNotification::SendButtonPress(ApplicationConstSharedPtr app) { (*message_)[strings::msg_params][strings::custom_button_id]; } + if ((*message_)[strings::msg_params].keyExists(strings::window_id)) { + (*on_btn_press)[strings::msg_params][strings::window_id] = + (*message_)[strings::msg_params][strings::window_id]; + } + message_ = on_btn_press; SendNotification(); } @@ -196,4 +207,4 @@ void OnButtonPressNotification::SendButtonPress(ApplicationConstSharedPtr app) { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_command_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_command_notification.cc index dff3aa68083..9c7edf74e67 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_command_notification.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_command_notification.cc @@ -84,4 +84,4 @@ void OnCommandNotification::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_driver_distraction_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_driver_distraction_notification.cc index ca5d4bfed4a..42a1928f2e9 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_driver_distraction_notification.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_driver_distraction_notification.cc @@ -67,4 +67,4 @@ void OnDriverDistractionNotification::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_hash_change_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_hash_change_notification.cc index e252b031e63..c2ce2550b97 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_hash_change_notification.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_hash_change_notification.cc @@ -34,9 +34,9 @@ #include "sdl_rpc_plugin/commands/mobile/on_hash_change_notification.h" +#include #include "application_manager/application_impl.h" #include "interfaces/MOBILE_API.h" -#include namespace sdl_rpc_plugin { using namespace application_manager; @@ -81,4 +81,4 @@ void OnHashChangeNotification::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_hmi_status_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_hmi_status_notification.cc index 6b5838e40ac..df3bce01549 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_hmi_status_notification.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_hmi_status_notification.cc @@ -33,8 +33,8 @@ #include "sdl_rpc_plugin/commands/mobile/on_hmi_status_notification.h" -#include "application_manager/message_helper.h" #include "application_manager/message.h" +#include "application_manager/message_helper.h" #include "interfaces/MOBILE_API.h" namespace sdl_rpc_plugin { @@ -92,4 +92,4 @@ void OnHMIStatusNotification::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_hmi_status_notification_from_mobile.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_hmi_status_notification_from_mobile.cc index c4ee22afed2..28325a40f5a 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_hmi_status_notification_from_mobile.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_hmi_status_notification_from_mobile.cc @@ -32,8 +32,8 @@ */ #include "sdl_rpc_plugin/commands/mobile/on_hmi_status_notification_from_mobile.h" -#include "application_manager/message_helper.h" #include "application_manager/message.h" +#include "application_manager/message_helper.h" namespace sdl_rpc_plugin { using namespace application_manager; @@ -132,4 +132,4 @@ void OnHMIStatusNotificationFromMobile::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_keyboard_input_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_keyboard_input_notification.cc index 04b52f29e10..1c0609e17d2 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_keyboard_input_notification.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_keyboard_input_notification.cc @@ -76,7 +76,8 @@ void OnKeyBoardInputNotification::Run() { break; } - if (mobile_apis::HMILevel::eType::HMI_FULL == app->hmi_level()) { + if (mobile_apis::HMILevel::eType::HMI_FULL == + app->hmi_level(mobile_apis::PredefinedWindows::DEFAULT_WINDOW)) { LOG4CXX_INFO(logger_, "There is application in HMI_FULL level"); app_to_notify = app; } @@ -93,4 +94,4 @@ void OnKeyBoardInputNotification::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_language_change_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_language_change_notification.cc index fdbdd910a05..9605fd60740 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_language_change_notification.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_language_change_notification.cc @@ -60,4 +60,4 @@ void OnLanguageChangeNotification::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_permissions_change_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_permissions_change_notification.cc index 32d940aca26..f64ca34bf2b 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_permissions_change_notification.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_permissions_change_notification.cc @@ -62,4 +62,4 @@ void OnPermissionsChangeNotification::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_system_capability_updated_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_system_capability_updated_notification.cc index a8544ae643b..cc6ab7b65b3 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_system_capability_updated_notification.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_system_capability_updated_notification.cc @@ -2,6 +2,7 @@ #include "application_manager/app_service_manager.h" #include "application_manager/application_manager.h" +#include "application_manager/display_capabilities_builder.h" #include "application_manager/helpers/application_helper.h" #include "application_manager/message_helper.h" #include "sdl_rpc_plugin/extensions/system_capability_app_extension.h" @@ -31,10 +32,11 @@ void OnSystemCapabilityUpdatedNotification::Run() { LOG4CXX_AUTO_TRACE(logger_); smart_objects::SmartObject& msg_params = (*message_)[strings::msg_params]; - mobile_apis::SystemCapabilityType::eType system_capability_type = static_cast< - mobile_apis::SystemCapabilityType::eType>( - msg_params[strings::system_capability][strings::system_capability_type] - .asInt()); + const auto system_capability_type = + static_cast( + msg_params[strings::system_capability] + [strings::system_capability_type] + .asInt()); switch (system_capability_type) { case mobile_apis::SystemCapabilityType::NAVIGATION: { @@ -100,21 +102,24 @@ void OnSystemCapabilityUpdatedNotification::Run() { for (size_t i = 0; i < updated_capabilities.length(); i++) { std::string service_id = updated_capabilities[i][strings::updated_app_service_record] - [strings::service_id].asString(); - auto matching_service_predicate = [&service_id]( - const smart_objects::SmartObject& app_service_capability) { - return service_id == - app_service_capability[strings::updated_app_service_record] - [strings::service_id].asString(); - }; + [strings::service_id] + .asString(); + auto matching_service_predicate = + [&service_id]( + const smart_objects::SmartObject& app_service_capability) { + return service_id == + app_service_capability[strings::updated_app_service_record] + [strings::service_id] + .asString(); + }; auto it = std::find_if(app_services->begin(), app_services->end(), matching_service_predicate); if (it != app_services->end()) { - LOG4CXX_DEBUG(logger_, - "Replacing updated record with service_id " - << service_id); + LOG4CXX_DEBUG( + logger_, + "Replacing updated record with service_id " << service_id); app_services->erase(it); } app_services->push_back(updated_capabilities[i]); @@ -123,8 +128,21 @@ void OnSystemCapabilityUpdatedNotification::Run() { [strings::app_services_capabilities] = app_service_caps; break; } - default: + + case mobile_apis::SystemCapabilityType::DISPLAYS: { + // Display capabilities content will be populated in the code after the + // switch so just breaking here + break; + } + + default: { + LOG4CXX_ERROR(logger_, + "Unknown system capability type: " + << msg_params[strings::system_capability] + [strings::system_capability_type] + .asInt()); return; + } } const char* capability_type_string; @@ -132,11 +150,34 @@ void OnSystemCapabilityUpdatedNotification::Run() { mobile_apis::SystemCapabilityType::eType>:: EnumToCString(system_capability_type, &capability_type_string); + const auto initial_connection_key = + (*message_)[strings::params][strings::connection_key].asUInt(); + auto subscribed_to_capability_predicate = - [&system_capability_type](const ApplicationSharedPtr app) { + [&system_capability_type, + &initial_connection_key](const ApplicationSharedPtr app) { DCHECK_OR_RETURN(app, false); auto& ext = SystemCapabilityAppExtension::ExtractExtension(*app); - return ext.IsSubscribedTo(system_capability_type); + if (!ext.IsSubscribedTo(system_capability_type)) { + LOG4CXX_DEBUG(logger_, + "App " << app->app_id() + << " is not subscribed to this capability type"); + return false; + } + + if (mobile_apis::SystemCapabilityType::DISPLAYS == + system_capability_type && + initial_connection_key > 0) { + LOG4CXX_DEBUG(logger_, + "Display capabilities notification for app " + << initial_connection_key << " only"); + return app->app_id() == initial_connection_key; + } + + LOG4CXX_DEBUG(logger_, + "App " << app->app_id() + << " is subscribed to specified capability type"); + return true; }; const std::vector& applications = FindAllApps( @@ -163,6 +204,40 @@ void OnSystemCapabilityUpdatedNotification::Run() { ext.UnsubscribeFrom(system_capability_type); continue; } + + if (mobile_apis::SystemCapabilityType::DISPLAYS == system_capability_type) { + LOG4CXX_DEBUG(logger_, "Using common display capabilities"); + auto capabilities = hmi_capabilities_.system_display_capabilities(); + if (app->is_resuming() && app->is_app_data_resumption_allowed()) { + LOG4CXX_DEBUG(logger_, + "Application " + << app->app_id() + << " is resuming. Providing cached capabilities"); + auto display_caps = + app->display_capabilities_builder().display_capabilities(); + capabilities = display_caps; + } else if (app->display_capabilities()) { + LOG4CXX_DEBUG(logger_, + "Application " << app->app_id() + << " has specific display capabilities"); + const WindowID window_id = + msg_params[strings::system_capability] + [strings::display_capabilities][0] + [strings::window_capabilities][0][strings::window_id] + .asInt(); + capabilities = app->display_capabilities(window_id); + } + + if (!capabilities) { + LOG4CXX_WARN(logger_, + "No available display capabilities for sending. Skipping"); + continue; + } + + msg_params[strings::system_capability][strings::display_capabilities] = + *capabilities; + } + LOG4CXX_INFO(logger_, "Sending OnSystemCapabilityUpdated " << capability_type_string << " application id " @@ -174,4 +249,4 @@ void OnSystemCapabilityUpdatedNotification::Run() { } // namespace mobile } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin 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 10b0b41a580..fc99bb323c0 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 @@ -30,16 +30,16 @@ POSSIBILITY OF SUCH DAMAGE. */ -#include +#include "sdl_rpc_plugin/commands/mobile/on_system_request_notification.h" #include +#include #include -#include "sdl_rpc_plugin/commands/mobile/on_system_request_notification.h" +#include "application_manager/application_manager.h" +#include "application_manager/policies/policy_handler_interface.h" #include "interfaces/MOBILE_API.h" +#include "policy/policy_table/enums.h" #include "utils/file_system.h" #include "utils/helpers.h" -#include "policy/policy_table/enums.h" -#include "application_manager/application_manager.h" -#include "application_manager/policies/policy_handler_interface.h" namespace sdl_rpc_plugin { using namespace application_manager; @@ -86,8 +86,8 @@ void OnSystemRequestNotification::Run() { static_cast( request_type)); - if (!policy_handler.IsRequestTypeAllowed(app->policy_app_id(), - request_type)) { + if (!policy_handler.IsRequestTypeAllowed( + app->device(), app->policy_app_id(), request_type)) { LOG4CXX_WARN(logger_, "Request type " << stringified_request_type << " is not allowed by policies"); @@ -129,11 +129,11 @@ void OnSystemRequestNotification::Run() { } if (mobile_apis::RequestType::PROPRIETARY == request_type) { -/* According to requirements: - "If the requestType = PROPRIETARY, add to mobile API fileType = JSON - If the requestType = HTTP, add to mobile API fileType = BINARY" - Also in Genivi SDL we don't save the PT to file - we put it directly in - binary_data */ + /* According to requirements: + "If the requestType = PROPRIETARY, add to mobile API fileType = JSON + If the requestType = HTTP, add to mobile API fileType = BINARY" + Also in Genivi SDL we don't save the PT to file - we put it directly in + binary_data */ #if defined(PROPRIETARY_MODE) AddHeader(binary_data); @@ -246,4 +246,4 @@ size_t OnSystemRequestNotification::ParsePTString( } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_tbt_client_state_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_tbt_client_state_notification.cc index 503f1b04d50..0a8420b6a3a 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_tbt_client_state_notification.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_tbt_client_state_notification.cc @@ -67,7 +67,8 @@ void OnTBTClientStateNotification::Run() { std::vector::const_iterator it = applications.begin(); for (; applications.end() != it; ++it) { ApplicationSharedPtr app = *it; - if (mobile_apis::HMILevel::eType::HMI_NONE != app->hmi_level()) { + if (mobile_apis::HMILevel::eType::HMI_NONE != + app->hmi_level(mobile_apis::PredefinedWindows::DEFAULT_WINDOW)) { (*message_)[strings::params][strings::connection_key] = app->app_id(); SendNotification(); } @@ -76,4 +77,4 @@ void OnTBTClientStateNotification::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_touch_event_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_touch_event_notification.cc index 502f0ae57d5..6ceb381d2e6 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_touch_event_notification.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_touch_event_notification.cc @@ -93,4 +93,4 @@ void OnTouchEventNotification::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_way_point_change_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_way_point_change_notification.cc index 2f666ffc039..e89ede53b90 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_way_point_change_notification.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_way_point_change_notification.cc @@ -67,4 +67,4 @@ void OnWayPointChangeNotification::Run() { } } } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin 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 c90038a8b7f..04815425655 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 @@ -31,8 +31,8 @@ POSSIBILITY OF SUCH DAMAGE. */ -#include #include "sdl_rpc_plugin/commands/mobile/perform_audio_pass_thru_request.h" +#include #include "application_manager/application_impl.h" #include "application_manager/message_helper.h" @@ -87,7 +87,8 @@ void PerformAudioPassThruRequest::Run() { return; } - if (mobile_api::HMILevel::HMI_NONE == app->hmi_level()) { + if (mobile_api::HMILevel::HMI_NONE == + app->hmi_level(mobile_apis::PredefinedWindows::DEFAULT_WINDOW)) { LOG4CXX_ERROR(logger_, "application isn't activated"); SendResponse(false, mobile_apis::Result::REJECTED); return; @@ -113,9 +114,9 @@ void PerformAudioPassThruRequest::Run() { initial_prompt, app, application_manager_); if (mobile_apis::Result::FILE_NOT_FOUND == verification_result) { - LOG4CXX_ERROR(logger_, - "MessageHelper::VerifyTtsFiles return " - << verification_result); + LOG4CXX_ERROR( + logger_, + "MessageHelper::VerifyTtsFiles return " << verification_result); SendResponse( false, mobile_apis::Result::FILE_NOT_FOUND, @@ -450,4 +451,4 @@ bool PerformAudioPassThruRequest::IsWaitingHMIResponse() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/perform_audio_pass_thru_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/perform_audio_pass_thru_response.cc index a5eb98f2bab..5dae6327eb6 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/perform_audio_pass_thru_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/perform_audio_pass_thru_response.cc @@ -61,4 +61,4 @@ void PerformAudioPassThruResponse::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin 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 42489fd8bdc..622f64f7923 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 @@ -31,20 +31,20 @@ POSSIBILITY OF SUCH DAMAGE. */ -#include +#include "sdl_rpc_plugin/commands/mobile/perform_interaction_request.h" #include +#include #include -#include "sdl_rpc_plugin/commands/mobile/perform_interaction_request.h" #include "application_manager/application_impl.h" #include "application_manager/message_helper.h" -#include "interfaces/MOBILE_API.h" #include "interfaces/HMI_API.h" -#include "utils/file_system.h" -#include "utils/helpers.h" +#include "interfaces/MOBILE_API.h" #include "utils/custom_string.h" +#include "utils/file_system.h" #include "utils/gen_hash.h" +#include "utils/helpers.h" namespace sdl_rpc_plugin { using namespace application_manager; @@ -82,17 +82,18 @@ PerformInteractionRequest::~PerformInteractionRequest() {} bool PerformInteractionRequest::Init() { /* Timeout in milliseconds. If omitted a standard value of 10000 milliseconds is used.*/ - if ((*message_)[strings::msg_params].keyExists(strings::timeout)) { - default_timeout_ = - (*message_)[strings::msg_params][strings::timeout].asUInt(); - } + const auto& msg_params = (*message_)[strings::msg_params]; + uint32_t request_timeout = msg_params[strings::timeout].asUInt(); interaction_mode_ = static_cast( - (*message_)[strings::msg_params][strings::interaction_mode].asInt()); + msg_params[strings::interaction_mode].asInt()); if (mobile_apis::InteractionMode::BOTH == interaction_mode_ || mobile_apis::InteractionMode::MANUAL_ONLY == interaction_mode_) { - default_timeout_ *= 2; + const uint32_t increase_value = 2; + default_timeout_ += request_timeout * increase_value; + } else { + default_timeout_ += request_timeout; } return true; } @@ -284,7 +285,7 @@ void PerformInteractionRequest::onTimeOut() { CommandRequestImpl::onTimeOut(); } else { application_manager_.updateRequestTimeout( - connection_key(), correlation_id(), default_timeout()); + connection_key(), correlation_id(), default_timeout_); } break; } @@ -341,7 +342,7 @@ bool PerformInteractionRequest::ProcessVRResponse( } LOG4CXX_DEBUG(logger_, "Update timeout for UI"); application_manager_.updateRequestTimeout( - connection_key(), correlation_id(), default_timeout()); + connection_key(), correlation_id(), default_timeout_); return false; } @@ -358,6 +359,13 @@ bool PerformInteractionRequest::ProcessVRResponse( msg_params[strings::choice_id] = choice_id; } + if (mobile_apis::InteractionMode::BOTH == interaction_mode_ || + mobile_apis::InteractionMode::MANUAL_ONLY == interaction_mode_) { + LOG4CXX_DEBUG(logger_, "Update timeout for UI"); + application_manager_.updateRequestTimeout( + connection_key(), correlation_id(), default_timeout_); + } + const bool is_vr_result_success = Compare( vr_result_code_, Common_Result::SUCCESS, Common_Result::WARNINGS); @@ -449,6 +457,11 @@ void PerformInteractionRequest::SendUIPerformInteractionRequest( smart_objects::SmartObject msg_params = smart_objects::SmartObject(smart_objects::SmartType_Map); + if ((*message_)[strings::msg_params].keyExists(strings::cancel_id)) { + msg_params[strings::cancel_id] = + (*message_)[strings::msg_params][strings::cancel_id].asInt(); + } + mobile_apis::InteractionMode::eType mode = static_cast( (*message_)[strings::msg_params][strings::interaction_mode].asInt()); @@ -471,12 +484,8 @@ void PerformInteractionRequest::SendUIPerformInteractionRequest( } } - if (mobile_apis::InteractionMode::BOTH == mode || - mobile_apis::InteractionMode::MANUAL_ONLY == mode) { - msg_params[strings::timeout] = default_timeout_ / 2; - } else { - msg_params[strings::timeout] = default_timeout_; - } + msg_params[strings::timeout] = + (*message_)[strings::msg_params][strings::timeout].asUInt(); msg_params[strings::app_id] = app->app_id(); if (mobile_apis::InteractionMode::VR_ONLY != mode) { msg_params[strings::choice_set] = @@ -532,6 +541,11 @@ void PerformInteractionRequest::SendVRPerformInteractionRequest( smart_objects::SmartObject msg_params = smart_objects::SmartObject(smart_objects::SmartType_Map); + if ((*message_)[strings::msg_params].keyExists(strings::cancel_id)) { + msg_params[strings::cancel_id] = + (*message_)[strings::msg_params][strings::cancel_id].asInt(); + } + smart_objects::SmartObject& choice_list = (*message_)[strings::msg_params][strings::interaction_choice_set_id_list]; @@ -560,9 +574,9 @@ void PerformInteractionRequest::SendVRPerformInteractionRequest( MessageHelper::VerifyTtsFiles(help_prompt, app, application_manager_); if (mobile_apis::Result::FILE_NOT_FOUND == verification_result) { - LOG4CXX_WARN(logger_, - "MessageHelper::VerifyTtsFiles return " - << verification_result); + LOG4CXX_WARN( + logger_, + "MessageHelper::VerifyTtsFiles return " << verification_result); invalid_params.push_back("help_prompt"); } else { msg_params[strings::help_prompt] = help_prompt; @@ -608,9 +622,9 @@ void PerformInteractionRequest::SendVRPerformInteractionRequest( timeout_prompt, app, application_manager_); if (mobile_apis::Result::FILE_NOT_FOUND == verification_result) { - LOG4CXX_WARN(logger_, - "MessageHelper::VerifyTtsFiles return " - << verification_result); + LOG4CXX_WARN( + logger_, + "MessageHelper::VerifyTtsFiles return " << verification_result); invalid_params.push_back("timeout_prompt"); } else { msg_params[strings::timeout_prompt] = timeout_prompt; @@ -629,9 +643,9 @@ void PerformInteractionRequest::SendVRPerformInteractionRequest( initial_prompt, app, application_manager_); if (mobile_apis::Result::FILE_NOT_FOUND == verification_result) { - LOG4CXX_WARN(logger_, - "MessageHelper::VerifyTtsFiles return " - << verification_result); + LOG4CXX_WARN( + logger_, + "MessageHelper::VerifyTtsFiles return " << verification_result); invalid_params.push_back("initial_prompt"); } else { msg_params[strings::initial_prompt] = initial_prompt; @@ -652,16 +666,9 @@ void PerformInteractionRequest::SendVRPerformInteractionRequest( return; } - mobile_apis::InteractionMode::eType mode = - static_cast( - (*message_)[strings::msg_params][strings::interaction_mode].asInt()); - - if (mobile_apis::InteractionMode::BOTH == mode || - mobile_apis::InteractionMode::MANUAL_ONLY == mode) { - msg_params[strings::timeout] = default_timeout_ / 2; - } else { - msg_params[strings::timeout] = default_timeout_; - } + msg_params[strings::timeout] = + (*message_)[strings::msg_params][strings::timeout].asUInt(); + ; msg_params[strings::app_id] = app->app_id(); StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_VR); SendHMIRequest( @@ -1065,4 +1072,4 @@ void PerformInteractionRequest::SendBothModeResponse( } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/perform_interaction_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/perform_interaction_response.cc index 85bef9b2ad0..fa02641c2b5 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/perform_interaction_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/perform_interaction_response.cc @@ -61,4 +61,4 @@ void PerformInteractionResponse::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin 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 b418f52fa3f..e25215fb484 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 @@ -31,22 +31,22 @@ POSSIBILITY OF SUCH DAMAGE. */ -#include #include "sdl_rpc_plugin/commands/mobile/put_file_request.h" +#include -#include "application_manager/policies/policy_handler.h" #include "application_manager/application_impl.h" +#include "application_manager/policies/policy_handler.h" #include "application_manager/rpc_service.h" -#include "utils/file_system.h" #include +#include "utils/file_system.h" namespace { /** -* Calculates CRC32 checksum -* @param binary_data - input data for which CRC32 should be calculated -* @return calculated CRC32 checksum -*/ + * Calculates CRC32 checksum + * @param binary_data - input data for which CRC32 should be calculated + * @return calculated CRC32 checksum + */ uint32_t GetCrc32CheckSum(const std::vector& binary_data) { const std::size_t file_size = binary_data.size(); boost::crc_32_type result; @@ -94,7 +94,9 @@ void PutFileRequest::Run() { return; } - if (mobile_api::HMILevel::HMI_NONE == application->hmi_level() && + if (mobile_api::HMILevel::HMI_NONE == + application->hmi_level( + mobile_apis::PredefinedWindows::DEFAULT_WINDOW) && application_manager_.get_settings().put_file_in_none() <= application->put_file_in_none_count()) { // If application is in the HMI_NONE level the quantity of allowed @@ -284,9 +286,7 @@ void PutFileRequest::Run() { } SendResponse(true, save_result, "File was downloaded", &response_params); - if (is_system_file) { - SendOnPutFileNotification(); - } + SendOnPutFileNotification(is_system_file); break; } default: @@ -297,7 +297,7 @@ void PutFileRequest::Run() { } } -void PutFileRequest::SendOnPutFileNotification() { +void PutFileRequest::SendOnPutFileNotification(bool is_system_file) { LOG4CXX_INFO(logger_, "SendOnPutFileNotification"); smart_objects::SmartObjectSPtr notification = std::make_shared( @@ -316,9 +316,10 @@ void PutFileRequest::SendOnPutFileNotification() { message[strings::msg_params][strings::length] = length_; message[strings::msg_params][strings::persistent_file] = is_persistent_file_; message[strings::msg_params][strings::file_type] = file_type_; + message[strings::msg_params][strings::is_system_file] = is_system_file; rpc_service_.ManageHMICommand(notification); } } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/put_file_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/put_file_response.cc index 8c54970a5c4..f9ddbf77174 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/put_file_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/put_file_response.cc @@ -32,8 +32,8 @@ */ #include "sdl_rpc_plugin/commands/mobile/put_file_response.h" -#include "utils/file_system.h" #include "application_manager/application_impl.h" +#include "utils/file_system.h" namespace sdl_rpc_plugin { using namespace application_manager; @@ -70,4 +70,4 @@ void PutFileResponse::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin 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 924705f82b7..14a94fd1a2e 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 @@ -33,19 +33,19 @@ #include "sdl_rpc_plugin/commands/mobile/register_app_interface_request.h" +#include #include #include #include -#include -#include "application_manager/application_manager.h" -#include "application_manager/policies/policy_handler_interface.h" -#include "application_manager/application_impl.h" #include "application_manager/app_launch/app_launch_ctrl.h" +#include "application_manager/application_impl.h" +#include "application_manager/application_manager.h" +#include "application_manager/helpers/application_helper.h" #include "application_manager/message_helper.h" -#include "application_manager/resumption/resume_ctrl.h" #include "application_manager/policies/policy_handler.h" -#include "application_manager/helpers/application_helper.h" +#include "application_manager/policies/policy_handler_interface.h" +#include "application_manager/resumption/resume_ctrl.h" #include "application_manager/rpc_service.h" #include "config_profile/profile.h" #include "interfaces/MOBILE_API.h" @@ -158,15 +158,16 @@ class SmartArrayValueExtractor { }; struct IsSameNickname { - IsSameNickname(const custom_str::CustomString& app_id) : app_id_(app_id) {} + IsSameNickname(const custom_str::CustomString app_name) + : app_name_(app_name) {} bool operator()(const policy::StringArray::value_type& nickname) const { - return app_id_.CompareIgnoreCase(nickname.c_str()); + return app_name_.CompareIgnoreCase(nickname.c_str()); } private: - const custom_str::CustomString& app_id_; + const custom_str::CustomString app_name_; }; -} +} // namespace namespace sdl_rpc_plugin { using namespace application_manager; @@ -184,7 +185,8 @@ RegisterAppInterfaceRequest::RegisterAppInterfaceRequest( rpc_service, hmi_capabilities, policy_handler) - , result_code_(mobile_apis::Result::INVALID_ENUM) {} + , result_code_(mobile_apis::Result::INVALID_ENUM) + , device_handle_(0) {} RegisterAppInterfaceRequest::~RegisterAppInterfaceRequest() {} @@ -224,20 +226,38 @@ void RegisterAppInterfaceRequest::Run() { return; } + // Cache the original app ID (for legacy behavior) + const auto policy_app_id = + application_manager_.GetCorrectMobileIDFromMessage(message_); + + if (application_manager_.IsApplicationForbidden(connection_key(), + policy_app_id)) { + SendResponse(false, mobile_apis::Result::TOO_MANY_PENDING_REQUESTS); + return; + } + + if (!GetDataOnSessionKey(connection_key(), &device_handle_, &device_id_)) { + SendResponse(false, + mobile_apis::Result::GENERIC_ERROR, + "Could not find a session for your connection key!"); + return; + } + + LOG4CXX_DEBUG( + logger_, + "device_handle: " << device_handle_ << " device_id: " << device_id_); + if (IsApplicationSwitched()) { return; } ApplicationSharedPtr application = - application_manager_.application(connection_key()); + application_manager_.application(device_id_, policy_app_id); if (application) { SendResponse(false, mobile_apis::Result::APPLICATION_REGISTERED_ALREADY); return; } - // cache the original app ID (for legacy behavior) - const std::string policy_app_id = - application_manager_.GetCorrectMobileIDFromMessage(message_); const smart_objects::SmartObject& msg_params = (*message_)[strings::msg_params]; @@ -260,11 +280,6 @@ void RegisterAppInterfaceRequest::Run() { ::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); - return; - } if (IsApplicationWithSameAppIdRegistered()) { SendResponse(false, mobile_apis::Result::DISALLOWED); @@ -400,9 +415,9 @@ void RegisterAppInterfaceRequest::Run() { tts_name, application, application_manager_); if (mobile_apis::Result::FILE_NOT_FOUND == verification_result) { - LOG4CXX_WARN(logger_, - "MessageHelper::VerifyTtsFiles return " - << verification_result); + LOG4CXX_WARN( + logger_, + "MessageHelper::VerifyTtsFiles return " << verification_result); response_info_ = "One or more files needed for tts_name are not present"; result_code_ = mobile_apis::Result::WARNINGS; } @@ -454,17 +469,16 @@ void RegisterAppInterfaceRequest::Run() { // Add device to policy table and set device info, if any policy::DeviceParams dev_params; - if (-1 == - application_manager_.connection_handler() - .get_session_observer() - .GetDataOnDeviceID(application->device(), - &dev_params.device_name, - NULL, - &dev_params.device_mac_address, - &dev_params.device_connection_type)) { - LOG4CXX_ERROR(logger_, - "Failed to extract information for device " - << application->device()); + if (-1 == application_manager_.connection_handler() + .get_session_observer() + .GetDataOnDeviceID(application->device(), + &dev_params.device_name, + NULL, + &dev_params.device_mac_address, + &dev_params.device_connection_type)) { + LOG4CXX_ERROR( + logger_, + "Failed to extract information for device " << application->device()); } policy::DeviceInfo device_info; device_info.AdoptDeviceType(dev_params.device_connection_type); @@ -614,15 +628,9 @@ void FillUIRelatedFields(smart_objects::SmartObject& response_params, } if (hmi_capabilities.audio_pass_thru_capabilities()) { - if (smart_objects::SmartType_Array == - hmi_capabilities.audio_pass_thru_capabilities()->getType()) { - // hmi_capabilities json contains array and HMI response object - response_params[strings::audio_pass_thru_capabilities] = - *hmi_capabilities.audio_pass_thru_capabilities(); - } else { - response_params[strings::audio_pass_thru_capabilities][0] = - *hmi_capabilities.audio_pass_thru_capabilities(); - } + // hmi_capabilities json contains array and HMI response object + response_params[strings::audio_pass_thru_capabilities] = + *hmi_capabilities.audio_pass_thru_capabilities(); } response_params[strings::hmi_capabilities] = smart_objects::SmartObject(smart_objects::SmartType_Map); @@ -634,6 +642,11 @@ void FillUIRelatedFields(smart_objects::SmartObject& response_params, hmi_capabilities.video_streaming_supported(); response_params[strings::hmi_capabilities][strings::remote_control] = hmi_capabilities.rc_supported(); + response_params[strings::hmi_capabilities][strings::app_services] = true; + // Apps are automatically subscribed to the SystemCapability: DISPLAYS + response_params[strings::hmi_capabilities][strings::displays] = true; + response_params[strings::hmi_capabilities][strings::seat_location] = + hmi_capabilities.seat_location_capability() ? true : false; } void RegisterAppInterfaceRequest::SendRegisterAppInterfaceResponseToMobile( @@ -786,15 +799,16 @@ void RegisterAppInterfaceRequest::SendRegisterAppInterfaceResponseToMobile( return; } - bool resumption = + const bool hash_id_present = (*message_)[strings::msg_params].keyExists(strings::hash_id); + const std::string hash_id = + (*message_)[strings::msg_params][strings::hash_id].asString(); + const bool resumption = hash_id_present && !hash_id.empty(); bool need_restore_vr = resumption; - std::string hash_id; std::string add_info; if (resumption) { - hash_id = (*message_)[strings::msg_params][strings::hash_id].asString(); if (!resumer.CheckApplicationHash(application, hash_id)) { LOG4CXX_WARN(logger_, "Hash from RAI does not match to saved resume data."); @@ -808,6 +822,8 @@ void RegisterAppInterfaceRequest::SendRegisterAppInterfaceResponseToMobile( need_restore_vr = false; } else { add_info = "Resume succeeded."; + application->set_app_data_resumption_allowance(true); + application->set_is_resuming(true); } } if ((mobile_apis::Result::SUCCESS == result_code) && @@ -816,10 +832,18 @@ void RegisterAppInterfaceRequest::SendRegisterAppInterfaceResponseToMobile( result_code = result_code_; } - // in case application exist in resumption we need to send resumeVrgrammars - if (false == resumption) { - resumption = resumer.IsApplicationSaved(application->policy_app_id(), - application->mac_address()); + // In case application exist in resumption we need to send resumeVrgrammars + const bool is_app_saved_in_resumption = resumer.IsApplicationSaved( + application->policy_app_id(), application->mac_address()); + + // If app is in resuming state + // DisplayCapabilitiesBuilder has to collect all the information + // from incoming HMI notifications and send only one notification + // to mobile app, even if hash does not match, which means that app data + // will not be resumed, notification should be sent for default window as + // it will be resumed in any case + if (resumption || is_app_saved_in_resumption) { + resumer.StartWaitingForDisplayCapabilitiesUpdate(application); } AppHmiTypes hmi_types; @@ -836,14 +860,15 @@ void RegisterAppInterfaceRequest::SendRegisterAppInterfaceResponseToMobile( } } policy::StatusNotifier notify_upd_manager = GetPolicyHandler().AddApplication( - application->policy_app_id(), hmi_types); + application->mac_address(), application->policy_app_id(), hmi_types); response_params[strings::icon_resumed] = file_system::FileExists(application->app_icon_path()); SendResponse(true, result_code, add_info.c_str(), &response_params); if (msg_params.keyExists(strings::app_hmi_type)) { - GetPolicyHandler().SetDefaultHmiTypes(application->policy_app_id(), + GetPolicyHandler().SetDefaultHmiTypes(application->device(), + application->policy_app_id(), &(msg_params[strings::app_hmi_type])); } @@ -857,11 +882,13 @@ void RegisterAppInterfaceRequest::SendRegisterAppInterfaceResponseToMobile( // Start PTU after successfull registration // Sends OnPermissionChange notification to mobile right after RAI response // and HMI level set-up - GetPolicyHandler().OnAppRegisteredOnMobile(application->policy_app_id()); + GetPolicyHandler().OnAppRegisteredOnMobile(application->mac_address(), + application->policy_app_id()); - if (result_code != mobile_apis::Result::RESUME_FAILED) { + if (result_code != mobile_apis::Result::RESUME_FAILED && + application->is_app_data_resumption_allowed()) { resumer.StartResumption(application, hash_id); - } else { + } else if (is_app_saved_in_resumption) { resumer.StartResumptionOnlyHMILevel(application); } @@ -962,48 +989,72 @@ mobile_apis::Result::eType RegisterAppInterfaceRequest::CheckCoincidence( const smart_objects::SmartObject& msg_params = (*message_)[strings::msg_params]; - ApplicationSet accessor = application_manager_.applications().GetData(); + auto compare_tts_name = [](const smart_objects::SmartObject& obj_1, + const smart_objects::SmartObject& obj_2) { + return obj_1[application_manager::strings::text] + .asCustomString() + .CompareIgnoreCase( + obj_2[application_manager::strings::text].asCustomString()); + }; - ApplicationSetConstIt it = accessor.begin(); - const custom_str::CustomString& app_name = - msg_params[strings::app_name].asCustomString(); + const auto& accessor = application_manager_.applications().GetData(); + const auto& app_name = msg_params[strings::app_name].asCustomString(); - for (; accessor.end() != it; ++it) { - // name check - const custom_str::CustomString& cur_name = (*it)->name(); + for (const auto& app : accessor) { + if (app->device() != device_handle_) { + continue; + } + // Name check + const auto& cur_name = app->name(); if (app_name.CompareIgnoreCase(cur_name)) { LOG4CXX_ERROR(logger_, "Application name is known already."); - out_duplicate_apps.push_back(*it); + out_duplicate_apps.push_back(app); continue; } - - const smart_objects::SmartObject* vr = (*it)->vr_synonyms(); - const std::vector* curr_vr = NULL; - if (NULL != vr) { - curr_vr = vr->asArray(); + const auto vr = app->vr_synonyms(); + if (vr) { + const auto curr_vr = vr->asArray(); CoincidencePredicateVR v(app_name); if (0 != std::count_if(curr_vr->begin(), curr_vr->end(), v)) { LOG4CXX_ERROR(logger_, "Application name is known already."); - out_duplicate_apps.push_back(*it); + out_duplicate_apps.push_back(app); continue; } } - // vr check + // VR check if (msg_params.keyExists(strings::vr_synonyms)) { - const std::vector* new_vr = - msg_params[strings::vr_synonyms].asArray(); + const auto new_vr = msg_params[strings::vr_synonyms].asArray(); CoincidencePredicateVR v(cur_name); if (0 != std::count_if(new_vr->begin(), new_vr->end(), v)) { LOG4CXX_ERROR(logger_, "vr_synonyms duplicated with app_name ."); - out_duplicate_apps.push_back(*it); + out_duplicate_apps.push_back(app); continue; } - } // end vr check + } // End vr check + + // TTS check + if (msg_params.keyExists(strings::tts_name) && app->tts_name()) { + const auto tts_array = msg_params[strings::tts_name].asArray(); + const auto tts_curr = app->tts_name()->asArray(); + const auto& it_tts = std::find_first_of(tts_array->begin(), + tts_array->end(), + tts_curr->begin(), + tts_curr->end(), + compare_tts_name); + if (it_tts != tts_array->end()) { + LOG4CXX_ERROR( + logger_, + "TTS name: " + << (*it_tts)[strings::text].asCustomString().AsMBString() + << " is known already"); + return mobile_apis::Result::DUPLICATE_NAME; + } + } // End tts check - } // application for end + } // Application for end if (!out_duplicate_apps.empty()) { return mobile_apis::Result::DUPLICATE_NAME; @@ -1132,14 +1183,19 @@ bool RegisterAppInterfaceRequest::IsApplicationWithSameAppIdRegistered() { const custom_string::CustomString mobile_app_id( application_manager_.GetCorrectMobileIDFromMessage(message_)); - const ApplicationSet& applications = - application_manager_.applications().GetData(); - - ApplicationSetConstIt it = applications.begin(); - ApplicationSetConstIt it_end = applications.end(); - - for (; it != it_end; ++it) { - if (mobile_app_id.CompareIgnoreCase((*it)->policy_app_id().c_str())) { + const auto& applications = application_manager_.applications().GetData(); + + for (const auto& app : applications) { + if (mobile_app_id.CompareIgnoreCase(app->policy_app_id().c_str())) { + if (app->device() != device_handle_) { + LOG4CXX_DEBUG(logger_, + "These policy_app_id equal, but applications have " + "different device id" + << " mobile_app_id: " << mobile_app_id.c_str() + << " device_handle: " << device_handle_ + << " device_handle: " << app->device()); + continue; + } return true; } } @@ -1212,7 +1268,8 @@ bool RegisterAppInterfaceRequest::IsWhiteSpaceExist() { if ((*message_)[strings::msg_params][strings::device_info].keyExists( strings::hardware)) { str = (*message_)[strings::msg_params][strings::device_info] - [strings::hardware].asCharArray(); + [strings::hardware] + .asCharArray(); if (strlen(str) && !CheckSyntax(str)) { LOG4CXX_ERROR(logger_, "Invalid device_info hardware syntax check failed"); @@ -1223,7 +1280,8 @@ bool RegisterAppInterfaceRequest::IsWhiteSpaceExist() { if ((*message_)[strings::msg_params][strings::device_info].keyExists( strings::firmware_rev)) { str = (*message_)[strings::msg_params][strings::device_info] - [strings::firmware_rev].asCharArray(); + [strings::firmware_rev] + .asCharArray(); if (strlen(str) && !CheckSyntax(str)) { LOG4CXX_ERROR(logger_, "Invalid device_info firmware_rev syntax check failed"); @@ -1244,7 +1302,8 @@ bool RegisterAppInterfaceRequest::IsWhiteSpaceExist() { if ((*message_)[strings::msg_params][strings::device_info].keyExists( strings::os_version)) { str = (*message_)[strings::msg_params][strings::device_info] - [strings::os_version].asCharArray(); + [strings::os_version] + .asCharArray(); if (strlen(str) && !CheckSyntax(str)) { LOG4CXX_ERROR(logger_, "Invalid device_info os_version syntax check failed"); @@ -1255,7 +1314,8 @@ bool RegisterAppInterfaceRequest::IsWhiteSpaceExist() { if ((*message_)[strings::msg_params][strings::device_info].keyExists( strings::carrier)) { str = (*message_)[strings::msg_params][strings::device_info] - [strings::carrier].asCharArray(); + [strings::carrier] + .asCharArray(); if (strlen(str) && !CheckSyntax(str)) { LOG4CXX_ERROR(logger_, "Invalid device_info carrier syntax check failed"); @@ -1305,13 +1365,12 @@ void RegisterAppInterfaceRequest::CheckResponseVehicleTypeParam( void RegisterAppInterfaceRequest::SendSubscribeCustomButtonNotification() { using namespace smart_objects; - using namespace hmi_apis; - SmartObject msg_params = SmartObject(SmartType_Map); msg_params[strings::app_id] = connection_key(); - msg_params[strings::name] = Common_ButtonName::CUSTOM_BUTTON; + msg_params[strings::name] = hmi_apis::Common_ButtonName::CUSTOM_BUTTON; msg_params[strings::is_suscribed] = true; - CreateHMINotification(FunctionID::Buttons_OnButtonSubscription, msg_params); + CreateHMINotification(hmi_apis::FunctionID::Buttons_OnButtonSubscription, + msg_params); } bool RegisterAppInterfaceRequest::IsApplicationSwitched() { @@ -1319,24 +1378,26 @@ bool RegisterAppInterfaceRequest::IsApplicationSwitched() { application_manager_.GetCorrectMobileIDFromMessage(message_); LOG4CXX_DEBUG(logger_, "Looking for application id " << policy_app_id); - - auto app = application_manager_.application_by_policy_id(policy_app_id); + auto app = + application_manager_.reregister_application_by_policy_id(policy_app_id); if (!app) { - LOG4CXX_DEBUG(logger_, - "Application with policy id " << policy_app_id - << " is not found."); + LOG4CXX_DEBUG( + logger_, + "Application with policy id " << policy_app_id << " is not found."); return false; } LOG4CXX_DEBUG(logger_, "Application with policy id " << policy_app_id << " is found."); - if (!application_manager_.IsAppInReconnectMode(policy_app_id)) { + + const auto app_device_handle = app->device(); + if (app_device_handle == device_handle_) { LOG4CXX_DEBUG(logger_, - "Policy id " << policy_app_id - << " is not found in reconnection list."); + "Application " << policy_app_id + << " is already registered from this device."); SendResponse(false, mobile_apis::Result::APPLICATION_REGISTERED_ALREADY); - return false; + return true; } LOG4CXX_DEBUG(logger_, "Application is found in reconnection list."); @@ -1355,13 +1416,61 @@ bool RegisterAppInterfaceRequest::IsApplicationSwitched() { application_manager_.ProcessReconnection(app, connection_key()); SendRegisterAppInterfaceResponseToMobile(app_type); - application_manager_.SendHMIStatusNotification(app); + MessageHelper::SendHMIStatusNotification( + app, + mobile_apis::PredefinedWindows::DEFAULT_WINDOW, + application_manager_); application_manager_.OnApplicationSwitched(app); return true; } +bool RegisterAppInterfaceRequest::GetDataOnSessionKey( + const uint32_t key, + connection_handler::DeviceHandle* device_id, + std::string* mac_address) const { + LOG4CXX_AUTO_TRACE(logger_); + + if ((nullptr == mac_address) && (nullptr == device_id)) { + LOG4CXX_ERROR(logger_, + "Can't get data on session key because device id and mac " + "address are empty."); + return false; + } + + connection_handler::DeviceHandle device_handle = 0; + auto& connect_handler = application_manager_.connection_handler(); + + auto result = connect_handler.GetDataOnSessionKey( + connection_key(), nullptr, nullptr, &device_handle); + + if (result) { + LOG4CXX_DEBUG( + logger_, + "Failed to get device info for connection key: " << connection_key()); + return false; + } + + if (mac_address) { + result = connect_handler.get_session_observer().GetDataOnDeviceID( + device_handle, nullptr, nullptr, mac_address, nullptr); + } + + if (result) { + LOG4CXX_DEBUG(logger_, + "Failed get unique address info for connection key: " + << connection_key()); + return false; + } + + if (device_id) { + *device_id = device_handle; + } + + return true; +} + policy::PolicyHandlerInterface& RegisterAppInterfaceRequest::GetPolicyHandler() { return policy_handler_; @@ -1369,4 +1478,4 @@ RegisterAppInterfaceRequest::GetPolicyHandler() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin 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 584d7db075a..b5683c62cb5 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 @@ -32,11 +32,10 @@ */ #include "sdl_rpc_plugin/commands/mobile/register_app_interface_response.h" -#include "interfaces/MOBILE_API.h" #include "application_manager/application_manager.h" #include "application_manager/policies/policy_handler_interface.h" #include "connection_handler/connection_handler.h" -#include "application_manager/policies/policy_handler_interface.h" +#include "interfaces/MOBILE_API.h" namespace sdl_rpc_plugin { using namespace application_manager; @@ -128,4 +127,4 @@ void RegisterAppInterfaceResponse::SetHeartBeatTimeout( } } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/reset_global_properties_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/reset_global_properties_request.cc index ab6e1cc143d..ffd8a7dc81b 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/reset_global_properties_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/reset_global_properties_request.cc @@ -36,8 +36,8 @@ #include "application_manager/application_impl.h" #include "application_manager/message_helper.h" -#include "interfaces/MOBILE_API.h" #include "interfaces/HMI_API.h" +#include "interfaces/MOBILE_API.h" namespace sdl_rpc_plugin { using namespace application_manager; @@ -161,7 +161,8 @@ void ResetGlobalPropertiesRequest::Run() { key_board_properties[hmi_request::limited_character_list] = limited_character_list;*/ - key_board_properties[hmi_request::auto_complete_text] = ""; + key_board_properties[hmi_request::auto_complete_list] = + smart_objects::SmartObject(smart_objects::SmartType_Array); msg_params[hmi_request::keyboard_properties] = key_board_properties; } @@ -333,4 +334,4 @@ bool ResetGlobalPropertiesRequest::IsPendingResponseExist() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/reset_global_properties_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/reset_global_properties_response.cc index f5542ab26be..07aa23d9c97 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/reset_global_properties_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/reset_global_properties_response.cc @@ -61,4 +61,4 @@ void ResetGlobalPropertiesResponse::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/scrollable_message_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/scrollable_message_request.cc index 0b28e092104..90dbb91b5fb 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/scrollable_message_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/scrollable_message_request.cc @@ -31,14 +31,14 @@ POSSIBILITY OF SUCH DAMAGE. */ -#include #include "sdl_rpc_plugin/commands/mobile/scrollable_message_request.h" +#include #include "application_manager/application_impl.h" -#include "application_manager/policies/policy_handler.h" #include "application_manager/message_helper.h" -#include "interfaces/MOBILE_API.h" +#include "application_manager/policies/policy_handler.h" #include "interfaces/HMI_API.h" +#include "interfaces/MOBILE_API.h" #include "utils/helpers.h" namespace sdl_rpc_plugin { @@ -65,13 +65,9 @@ ScrollableMessageRequest::~ScrollableMessageRequest() {} bool ScrollableMessageRequest::Init() { /* Timeout in milliseconds. If omitted a standard value of 10000 milliseconds is used.*/ - if ((*message_)[strings::msg_params].keyExists(strings::timeout)) { - default_timeout_ = - (*message_)[strings::msg_params][strings::timeout].asUInt(); - } else { - const int32_t def_value = 30000; - default_timeout_ = def_value; - } + uint32_t request_timeout = + (*message_)[strings::msg_params][strings::timeout].asUInt(); + default_timeout_ += request_timeout; return true; } @@ -110,7 +106,13 @@ void ScrollableMessageRequest::Run() { msg_params[hmi_request::message_text][hmi_request::field_text] = (*message_)[strings::msg_params][strings::scroll_message_body]; msg_params[strings::app_id] = app->app_id(); - msg_params[strings::timeout] = default_timeout_; + msg_params[strings::timeout] = + (*message_)[strings::msg_params][strings::timeout].asUInt(); + + if ((*message_)[strings::msg_params].keyExists(strings::cancel_id)) { + msg_params[strings::cancel_id] = + (*message_)[strings::msg_params][strings::cancel_id].asInt(); + } if ((*message_)[strings::msg_params].keyExists(strings::soft_buttons)) { msg_params[strings::soft_buttons] = @@ -160,4 +162,4 @@ void ScrollableMessageRequest::on_event(const event_engine::Event& event) { } } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/scrollable_message_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/scrollable_message_response.cc index 4eee819497c..6236506c006 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/scrollable_message_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/scrollable_message_response.cc @@ -69,4 +69,4 @@ void ScrollableMessageResponse::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/send_haptic_data_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/send_haptic_data_request.cc index a09434ebb69..6e745fe0db2 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/send_haptic_data_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/send_haptic_data_request.cc @@ -105,4 +105,4 @@ void SendHapticDataRequest::on_event(const event_engine::Event& event) { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/send_haptic_data_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/send_haptic_data_response.cc index f4515472a4c..79a05169286 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/send_haptic_data_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/send_haptic_data_response.cc @@ -60,4 +60,4 @@ void SendHapticDataResponse::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin 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 2719d0674d7..1df4d788d2a 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 @@ -30,8 +30,8 @@ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include #include "sdl_rpc_plugin/commands/mobile/send_location_request.h" +#include #include "application_manager/message_helper.h" #include "utils/custom_string.h" @@ -281,4 +281,4 @@ bool SendLocationRequest::CheckHMICapabilities( } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/send_location_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/send_location_response.cc index 59dab4a9a7d..934008b816b 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/send_location_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/send_location_response.cc @@ -32,8 +32,8 @@ */ #include "sdl_rpc_plugin/commands/mobile/send_location_response.h" -#include "application_manager/rpc_service.h" #include "application_manager/application_impl.h" +#include "application_manager/rpc_service.h" #include "interfaces/HMI_API.h" namespace sdl_rpc_plugin { @@ -63,4 +63,4 @@ void SendLocationResponse::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_app_icon_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_app_icon_request.cc index e79fb315ce9..b2363e870f9 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_app_icon_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_app_icon_request.cc @@ -34,10 +34,10 @@ #include "sdl_rpc_plugin/commands/mobile/set_app_icon_request.h" #include -#include "application_manager/message_helper.h" #include "application_manager/application_impl.h" -#include "interfaces/MOBILE_API.h" +#include "application_manager/message_helper.h" #include "interfaces/HMI_API.h" +#include "interfaces/MOBILE_API.h" #include "utils/file_system.h" #include "utils/helpers.h" @@ -148,10 +148,12 @@ void SetAppIconRequest::CopyToIconStorage( if (storage_max_size < file_size) { LOG4CXX_ERROR(logger_, - "Icon size (" << file_size << ") is bigger, than " - " icons storage maximum size (" - << storage_max_size << ")." - "Copying skipped."); + "Icon size (" << file_size + << ") is bigger, than " + " icons storage maximum size (" + << storage_max_size + << ")." + "Copying skipped."); return; } @@ -203,12 +205,12 @@ void SetAppIconRequest::CopyToIconStorage( void SetAppIconRequest::RemoveOldestIcons(const std::string& storage, const uint32_t icons_amount) const { const std::vector icons_list = file_system::ListFiles(storage); - auto compareTime = [](const time_t t1, const time_t t2) - -> bool { return difftime(t1, t2) > 0; }; - std::map > - icon_modification_time(compareTime); + auto compareTime = [](const time_t t1, const time_t t2) -> bool { + return difftime(t1, t2) > 0; + }; + std:: + map > + icon_modification_time(compareTime); std::vector::const_iterator it = icons_list.begin(); for (; it != icons_list.end(); ++it) { const std::string file_name = *it; @@ -271,7 +273,8 @@ void SetAppIconRequest::on_event(const event_engine::Event& event) { const std::string& path = (*message_)[strings::msg_params][strings::sync_file_name] - [strings::value].asString(); + [strings::value] + .asString(); if (is_icons_saving_enabled_) { CopyToIconStorage(path); @@ -298,4 +301,4 @@ void SetAppIconRequest::on_event(const event_engine::Event& event) { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_app_icon_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_app_icon_response.cc index aa8731f0629..55255920d0d 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_app_icon_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_app_icon_response.cc @@ -61,4 +61,4 @@ void SetAppIconResponse::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_cloud_app_properties_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_cloud_app_properties_request.cc index 5173be56d65..3bb1e1c107b 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_cloud_app_properties_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_cloud_app_properties_request.cc @@ -1,4 +1,5 @@ #include "sdl_rpc_plugin/commands/mobile/set_cloud_app_properties_request.h" +#include "application_manager/policies/policy_handler_interface.h" namespace sdl_rpc_plugin { using namespace application_manager; @@ -40,4 +41,4 @@ void SetCloudAppPropertiesRequest::on_event( } } // namespace commands -} // namespace sdl_rpc_plugin \ No newline at end of file +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_cloud_app_properties_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_cloud_app_properties_response.cc index 6d27ce8b3ea..39d2ea7f900 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_cloud_app_properties_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_cloud_app_properties_response.cc @@ -1,6 +1,6 @@ +#include "sdl_rpc_plugin/commands/mobile/set_cloud_app_properties_response.h" #include "application_manager/application_manager.h" #include "application_manager/rpc_service.h" -#include "sdl_rpc_plugin/commands/mobile/set_cloud_app_properties_response.h" namespace sdl_rpc_plugin { using namespace application_manager; @@ -28,4 +28,4 @@ void SetCloudAppPropertiesResponse::Run() { } } // namespace commands -} // namespace sdl_rpc_plugins +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_display_layout_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_display_layout_request.cc index 32164b8f0ed..5ba1076084d 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_display_layout_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_display_layout_request.cc @@ -33,8 +33,8 @@ #include "sdl_rpc_plugin/commands/mobile/set_display_layout_request.h" -#include "application_manager/message_helper.h" #include "application_manager/application_impl.h" +#include "application_manager/message_helper.h" namespace sdl_rpc_plugin { using namespace application_manager; @@ -75,8 +75,8 @@ void SetDisplayLayoutRequest::Run() { new_layout = msg_params[strings::display_layout].asString(); } - if (new_layout != old_layout && - !new_layout.empty()) { // Template switched, allow any color change + if (new_layout != old_layout && !new_layout.empty()) { + // Template switched, hence allow any color change LOG4CXX_DEBUG(logger_, "SetDisplayLayoutRequest New Layout: " << new_layout); app->set_display_layout(new_layout); @@ -85,22 +85,20 @@ void SetDisplayLayoutRequest::Run() { // Template layout is the same as previous layout // Reject message if colors are set if (msg_params.keyExists(strings::day_color_scheme) && - app->day_color_scheme() != NULL && - !(msg_params[strings::day_color_scheme] == - *(app->day_color_scheme()))) { - // Color scheme param exists and has been previously set, do not allow - // color change + app->day_color_scheme().getType() != smart_objects::SmartType_Null && + msg_params[strings::day_color_scheme] != app->day_color_scheme()) { + // Color scheme param exists and has been previously set, + // hence do not allow color change LOG4CXX_DEBUG(logger_, "Reject Day Color Scheme Change"); SendResponse(false, mobile_apis::Result::REJECTED); return; } if (msg_params.keyExists(strings::night_color_scheme) && - app->night_color_scheme() != NULL && - !(msg_params[strings::night_color_scheme] == - *(app->night_color_scheme()))) { - // Color scheme param exists and has been previously set, do not allow - // color change + app->night_color_scheme().getType() != smart_objects::SmartType_Null && + msg_params[strings::night_color_scheme] != app->night_color_scheme()) { + // Color scheme param exists and has been previously set, + // hence do not allow color change LOG4CXX_DEBUG(logger_, "Reject Night Color Scheme Change"); SendResponse(false, mobile_apis::Result::REJECTED); return; @@ -127,6 +125,14 @@ void SetDisplayLayoutRequest::Run() { void SetDisplayLayoutRequest::on_event(const event_engine::Event& event) { 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 smart_objects::SmartObject& message = event.smart_object(); switch (event.id()) { case hmi_apis::FunctionID::UI_SetDisplayLayout: { @@ -143,21 +149,32 @@ void SetDisplayLayoutRequest::on_event(const event_engine::Event& event) { if (response_success) { HMICapabilities& hmi_capabilities = hmi_capabilities_; - // in case templates_available is empty copy from hmi capabilities + // In case templates_available is empty copy from hmi capabilities if (msg_params.keyExists(hmi_response::display_capabilities)) { - if (0 == - msg_params[hmi_response::display_capabilities] - [hmi_response::templates_available].length()) { + if (0 == msg_params[hmi_response::display_capabilities] + [hmi_response::templates_available] + .length()) { msg_params[hmi_response::display_capabilities] [hmi_response::templates_available] = hmi_capabilities.display_capabilities()->getElement( hmi_response::templates_available); } } + const Version& app_version = app->version(); + if (app_version.max_supported_api_version >= APIVersion::kAPIV6) { + // In case of successful response warn user that this RPC is + // deprecated from 6.0 and higher API versions + result_code = hmi_apis::Common_Result::WARNINGS; + info = + "The RPC is deprecated and will be removed in a future version. " + "The requested display layout is set to the main window. Please " + "use `Show.templateConfiguration` instead."; + } } + SendResponse(response_success, MessageHelper::HMIToMobileResult(result_code), - info.empty() ? NULL : info.c_str(), + info.empty() ? nullptr : info.c_str(), &msg_params); break; } @@ -170,4 +187,4 @@ void SetDisplayLayoutRequest::on_event(const event_engine::Event& event) { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_display_layout_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_display_layout_response.cc index 4bab4a3e5b1..0999b596b5d 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_display_layout_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_display_layout_response.cc @@ -62,4 +62,4 @@ void SetDisplayLayoutResponse::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin 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 0c217b6b4ff..a567d1b32f1 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 @@ -30,14 +30,15 @@ POSSIBILITY OF SUCH DAMAGE. */ +#include "sdl_rpc_plugin/commands/mobile/set_global_properties_request.h" #include -#include #include -#include "sdl_rpc_plugin/commands/mobile/set_global_properties_request.h" +#include #include "application_manager/message_helper.h" -#include "interfaces/MOBILE_API.h" #include "interfaces/HMI_API.h" +#include "interfaces/MOBILE_API.h" + #include "utils/helpers.h" namespace sdl_rpc_plugin { @@ -45,6 +46,24 @@ using namespace application_manager; namespace commands { +namespace { +bool IsResultCodeWarning(const app_mngr::commands::ResponseInfo& first, + const app_mngr::commands::ResponseInfo& second, + const app_mngr::commands::ResponseInfo& third) { + const bool first_is_ok_second_is_warn = + (first.is_ok || first.is_not_used) && + (hmi_apis::Common_Result::WARNINGS == second.result_code) && + (hmi_apis::Common_Result::WARNINGS == third.result_code); + + const bool final_warnings = + hmi_apis::Common_Result::WARNINGS == first.result_code && + ((hmi_apis::Common_Result::WARNINGS == second.result_code) && + (hmi_apis::Common_Result::WARNINGS == third.result_code)); + + return first_is_ok_second_is_warn || final_warnings; +} +} // namespace + SetGlobalPropertiesRequest::SetGlobalPropertiesRequest( const application_manager::commands::MessageSharedPtr& message, ApplicationManager& application_manager, @@ -58,25 +77,27 @@ SetGlobalPropertiesRequest::SetGlobalPropertiesRequest( policy_handler) , is_ui_send_(false) , is_tts_send_(false) + , is_rc_send_(false) , is_ui_received_(false) , is_tts_received_(false) + , is_rc_received_(false) , ui_result_(hmi_apis::Common_Result::INVALID_ENUM) - , tts_result_(hmi_apis::Common_Result::INVALID_ENUM) {} + , tts_result_(hmi_apis::Common_Result::INVALID_ENUM) + , rc_result_(hmi_apis::Common_Result::INVALID_ENUM) {} SetGlobalPropertiesRequest::~SetGlobalPropertiesRequest() {} void SetGlobalPropertiesRequest::Run() { LOG4CXX_AUTO_TRACE(logger_); - const smart_objects::SmartObject& msg_params = - (*message_)[strings::msg_params]; + smart_objects::SmartObject& msg_params = (*message_)[strings::msg_params]; ApplicationSharedPtr app = application_manager_.application(connection_key()); if (!app) { - LOG4CXX_ERROR(logger_, - "No application associated with connection key " - << connection_key()); + LOG4CXX_ERROR( + logger_, + "No application associated with connection key " << connection_key()); SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED); return; } @@ -90,11 +111,9 @@ void SetGlobalPropertiesRequest::Run() { mobile_apis::Result::eType verification_result = mobile_apis::Result::SUCCESS; - if ((*message_)[strings::msg_params].keyExists(strings::menu_icon)) { + if (msg_params.keyExists(strings::menu_icon)) { verification_result = MessageHelper::VerifyImage( - (*message_)[strings::msg_params][strings::menu_icon], - app, - application_manager_); + msg_params[strings::menu_icon], app, application_manager_); if (mobile_apis::Result::INVALID_DATA == verification_result) { LOG4CXX_ERROR( logger_, "MessageHelper::VerifyImage return " << verification_result); @@ -103,18 +122,29 @@ void SetGlobalPropertiesRequest::Run() { } } // Check for image file(s) in vrHelpItem - if ((*message_)[strings::msg_params].keyExists(strings::vr_help)) { + if (msg_params.keyExists(strings::vr_help)) { if (mobile_apis::Result::INVALID_DATA == MessageHelper::VerifyImageVrHelpItems( - (*message_)[strings::msg_params][strings::vr_help], - app, - application_manager_)) { + 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 (msg_params.keyExists(strings::keyboard_properties)) { + if (!msg_params[strings::keyboard_properties].keyExists( + strings::auto_complete_list) && + msg_params[strings::keyboard_properties].keyExists( + strings::auto_complete_text)) { + LOG4CXX_ERROR(logger_, "Replacing deprecated autoCompleteText property"); + msg_params[strings::keyboard_properties][strings::auto_complete_list][0] = + msg_params[strings::keyboard_properties][strings::auto_complete_text] + .asString(); + } + msg_params[strings::keyboard_properties].erase(strings::auto_complete_text); + } + if (IsWhiteSpaceExist()) { LOG4CXX_ERROR(logger_, "White spaces found"); SendResponse(false, mobile_apis::Result::INVALID_DATA); @@ -138,6 +168,19 @@ void SetGlobalPropertiesRequest::Run() { return; } + smart_objects::SmartObject params = + smart_objects::SmartObject(smart_objects::SmartType_Map); + + if (msg_params.keyExists(strings::menu_layout)) { + auto menu_layout = static_cast( + msg_params[strings::menu_layout].asUInt()); + if (app->menu_layout_supported(menu_layout)) { + params[strings::menu_layout] = msg_params[strings::menu_layout]; + } else { + is_menu_layout_available_ = false; + } + } + /* Need to set flags before sending request to HMI * for correct processing this flags in method on_event */ if (is_help_prompt_present || is_timeout_prompt_present) { @@ -154,9 +197,6 @@ void SetGlobalPropertiesRequest::Run() { return; } - smart_objects::SmartObject params = - smart_objects::SmartObject(smart_objects::SmartType_Map); - PrepareUIRequestVRHelpData(app, msg_params, params); PrepareUIRequestMenuAndKeyboardData(app, msg_params, params); @@ -169,9 +209,6 @@ void SetGlobalPropertiesRequest::Run() { LOG4CXX_DEBUG(logger_, "VRHelp params does not present"); DCHECK_OR_RETURN_VOID(!is_vr_help_title_present && !is_vr_help_present); - smart_objects::SmartObject params = - smart_objects::SmartObject(smart_objects::SmartType_Map); - PrepareUIRequestMenuAndKeyboardData(app, msg_params, params); // Preparing data @@ -183,45 +220,71 @@ void SetGlobalPropertiesRequest::Run() { } } + // Check RC params + const bool is_user_location_present = + msg_params.keyExists(strings::user_location); + if (is_user_location_present) { + if (msg_params[strings::user_location].empty()) { + SendResponse( + false, mobile_apis::Result::INVALID_DATA, "UserLocation is empty"); + return; + } + LOG4CXX_DEBUG(logger_, "Userlocation params presents"); + const auto& user_location = msg_params[strings::user_location]; + app->set_user_location(user_location); + + auto on_global_properties_updated = [app]( + plugin_manager::RPCPlugin& plugin) { + plugin.OnApplicationEvent(plugin_manager::kGlobalPropertiesUpdated, app); + }; + + application_manager_.GetPluginManager().ForEachPlugin( + on_global_properties_updated); + + smart_objects::SmartObject params = + smart_objects::SmartObject(smart_objects::SmartType_Map); + params[strings::app_id] = app->app_id(); + params[strings::user_location] = user_location; + SendRCRequest(params, true); + } + // check TTS params if (is_help_prompt_present || is_timeout_prompt_present) { LOG4CXX_DEBUG(logger_, "TTS params presents"); - smart_objects::SmartObject params = - smart_objects::SmartObject(smart_objects::SmartType_Map); + auto tts_params = smart_objects::SmartObject(smart_objects::SmartType_Map); std::vector invalid_params; if (is_help_prompt_present) { smart_objects::SmartObject& help_prompt = (*message_)[strings::msg_params][strings::help_prompt]; - mobile_apis::Result::eType verification_result = + verification_result = MessageHelper::VerifyTtsFiles(help_prompt, app, application_manager_); if (mobile_apis::Result::FILE_NOT_FOUND == verification_result) { - LOG4CXX_ERROR(logger_, - "MessageHelper::VerifyTtsFiles return " - << verification_result); + LOG4CXX_ERROR( + logger_, + "MessageHelper::VerifyTtsFiles return " << verification_result); invalid_params.push_back("help_prompt"); } else { app->set_help_prompt(help_prompt); - params[strings::help_prompt] = (*app->help_prompt()); + tts_params[strings::help_prompt] = (*app->help_prompt()); } } if (is_timeout_prompt_present) { smart_objects::SmartObject& timeout_prompt = (*message_)[strings::msg_params][strings::timeout_prompt]; - mobile_apis::Result::eType verification_result = - MessageHelper::VerifyTtsFiles( - timeout_prompt, app, application_manager_); + verification_result = MessageHelper::VerifyTtsFiles( + timeout_prompt, app, application_manager_); if (mobile_apis::Result::FILE_NOT_FOUND == verification_result) { - LOG4CXX_ERROR(logger_, - "MessageHelper::VerifyTtsFiles return " - << verification_result); + LOG4CXX_ERROR( + logger_, + "MessageHelper::VerifyTtsFiles return " << verification_result); invalid_params.push_back("timeout_prompt"); } else { app->set_timeout_prompt(timeout_prompt); - params[strings::timeout_prompt] = (*app->timeout_prompt()); + tts_params[strings::timeout_prompt] = (*app->timeout_prompt()); } } @@ -239,11 +302,18 @@ void SetGlobalPropertiesRequest::Run() { return; } - params[strings::app_id] = app->app_id(); - SendTTSRequest(params, true); + tts_params[strings::app_id] = app->app_id(); + SendTTSRequest(tts_params, true); auto& help_prompt_manager = app->help_prompt_manager(); - help_prompt_manager.OnSetGlobalPropertiesReceived(params, false); + help_prompt_manager.OnSetGlobalPropertiesReceived(tts_params, false); + } else if (!is_ui_send_ && !is_rc_send_) { + std::string response_info = "There are no parameters present in request."; + if (!is_menu_layout_available_) { + response_info += " The MenuLayout specified is unsupported."; + } + SendResponse( + false, mobile_apis::Result::INVALID_DATA, response_info.c_str()); } } @@ -278,7 +348,7 @@ void SetGlobalPropertiesRequest::on_event(const event_engine::Event& event) { switch (event.id()) { case hmi_apis::FunctionID::UI_SetGlobalProperties: { - LOG4CXX_INFO(logger_, "Received UI_SetGlobalProperties event"); + LOG4CXX_DEBUG(logger_, "Received UI_SetGlobalProperties event"); EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_UI); is_ui_received_ = true; ui_result_ = static_cast( @@ -291,7 +361,7 @@ void SetGlobalPropertiesRequest::on_event(const event_engine::Event& event) { break; } case hmi_apis::FunctionID::TTS_SetGlobalProperties: { - LOG4CXX_INFO(logger_, "Received TTS_SetGlobalProperties event"); + LOG4CXX_DEBUG(logger_, "Received TTS_SetGlobalProperties event"); EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_TTS); is_tts_received_ = true; tts_result_ = static_cast( @@ -303,6 +373,15 @@ void SetGlobalPropertiesRequest::on_event(const event_engine::Event& event) { } break; } + case hmi_apis::FunctionID::RC_SetGlobalProperties: { + LOG4CXX_DEBUG(logger_, "Received RC_SetGlobalProperties event"); + EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_RC); + is_rc_received_ = true; + rc_result_ = static_cast( + message[strings::params][hmi_response::code].asInt()); + GetInfo(message, rc_response_info_); + break; + } default: { LOG4CXX_ERROR(logger_, "Received unknown event" << event.id()); return; @@ -317,10 +396,21 @@ void SetGlobalPropertiesRequest::on_event(const event_engine::Event& event) { std::string response_info; const bool result = PrepareResponseParameters(result_code, response_info); - SendResponse(result, - result_code, - response_info.empty() ? NULL : response_info.c_str(), - &(message[strings::msg_params])); + if (result && !is_menu_layout_available_) { + response_info = + "The MenuLayout specified is unsupported, the " + "default MenuLayout will be used." + + response_info; + SendResponse(result, + mobile_apis::Result::WARNINGS, + response_info.c_str(), + &(message[strings::msg_params])); + } else { + SendResponse(result, + result_code, + response_info.empty() ? NULL : response_info.c_str(), + &(message[strings::msg_params])); + } } bool SetGlobalPropertiesRequest::Init() { @@ -338,28 +428,173 @@ bool SetGlobalPropertiesRequest::PrepareResponseParameters( app_mngr::commands::ResponseInfo tts_properties_info( tts_result_, HmiInterfaces::HMI_INTERFACE_TTS, application_manager_); - const bool result = - PrepareResultForMobileResponse(ui_properties_info, tts_properties_info); + + app_mngr::commands::ResponseInfo rc_properties_info( + rc_result_, HmiInterfaces::HMI_INTERFACE_RC, application_manager_); + + bool result = false; + + if (!is_rc_send_) { + result = CommandRequestImpl::PrepareResultForMobileResponse( + ui_properties_info, tts_properties_info); + } else { + result = PrepareResultForMobileResponse( + ui_properties_info, tts_properties_info, rc_properties_info); + } if (result && (HmiInterfaces::STATE_AVAILABLE == tts_properties_info.interface_state) && (tts_properties_info.is_unsupported_resource)) { result_code = mobile_apis::Result::WARNINGS; tts_response_info_ = "Unsupported phoneme type sent in a prompt"; - info = app_mngr::commands::MergeInfos(tts_properties_info, - tts_response_info_, - ui_properties_info, - ui_response_info_); + info = MergeInfos(tts_properties_info, + tts_response_info_, + ui_properties_info, + ui_response_info_, + rc_properties_info, + rc_response_info_); return result; } - result_code = - PrepareResultCodeForResponse(ui_properties_info, tts_properties_info); - info = app_mngr::commands::MergeInfos(tts_properties_info, - tts_response_info_, - ui_properties_info, - ui_response_info_); + + if (!is_rc_send_) { + result_code = CommandRequestImpl::PrepareResultCodeForResponse( + ui_properties_info, tts_properties_info); + } else { + result_code = PrepareResultCodeForResponse( + ui_properties_info, tts_properties_info, rc_properties_info); + } + info = MergeInfos(tts_properties_info, + tts_response_info_, + ui_properties_info, + ui_response_info_, + rc_properties_info, + rc_response_info_); return result; } +bool SetGlobalPropertiesRequest::PrepareResultForMobileResponse( + const app_mngr::commands::ResponseInfo& first, + const app_mngr::commands::ResponseInfo& second, + const app_mngr::commands::ResponseInfo& third) const { + LOG4CXX_AUTO_TRACE(logger_); + + app_mngr::commands::ResponseInfo both_info; + std::vector success_result_codes{ + hmi_apis::Common_Result::SUCCESS, + hmi_apis::Common_Result::WARNINGS, + hmi_apis::Common_Result::WRONG_LANGUAGE, + hmi_apis::Common_Result::RETRY, + hmi_apis::Common_Result::SAVED}; + + both_info.is_ok = + helpers::in_range(success_result_codes, first.result_code) && + helpers::in_range(success_result_codes, second.result_code); + + both_info.is_not_used = + (hmi_apis::Common_Result::INVALID_ENUM == first.result_code) || + (hmi_apis::Common_Result::INVALID_ENUM == second.result_code); + + both_info.is_unsupported_resource = + (hmi_apis::Common_Result::UNSUPPORTED_RESOURCE == first.result_code) || + (hmi_apis::Common_Result::UNSUPPORTED_RESOURCE == second.result_code); + + const bool final_result = CommandRequestImpl::CheckResult(both_info, third) || + CommandRequestImpl::CheckResult(third, both_info); + + return final_result; +} + +mobile_apis::Result::eType +SetGlobalPropertiesRequest::PrepareResultCodeForResponse( + const app_mngr::commands::ResponseInfo& first, + const app_mngr::commands::ResponseInfo& second, + const app_mngr::commands::ResponseInfo& third) { + LOG4CXX_AUTO_TRACE(logger_); + mobile_apis::Result::eType result_code = mobile_apis::Result::INVALID_ENUM; + if (IsResultCodeUnsupported(first, second, third) || + IsResultCodeUnsupported(second, third, first) || + IsResultCodeUnsupported(third, first, second)) { + return mobile_apis::Result::UNSUPPORTED_RESOURCE; + } + if (IsResultCodeWarning(first, second, third) || + IsResultCodeWarning(second, third, first) || + IsResultCodeWarning(third, first, second)) { + return mobile_apis::Result::WARNINGS; + } + // If response contains erroneous result code SDL need return erroneous + // result code. + auto first_result = hmi_apis::Common_Result::INVALID_ENUM; + auto second_result = hmi_apis::Common_Result::INVALID_ENUM; + auto third_result = hmi_apis::Common_Result::INVALID_ENUM; + + if (!first.is_unsupported_resource) { + first_result = first.result_code; + } + if (!second.is_unsupported_resource) { + second_result = second.result_code; + } + if (!third.is_unsupported_resource) { + third_result = third.result_code; + } + + hmi_apis::Common_Result::eType intermediate_result = + std::max(first_result, second_result); + result_code = MessageHelper::HMIToMobileResult( + std::max(intermediate_result, third_result)); + + return result_code; +} + +bool SetGlobalPropertiesRequest::IsResultCodeUnsupported( + const application_manager::commands::ResponseInfo& first, + const application_manager::commands::ResponseInfo& second, + const application_manager::commands::ResponseInfo& third) const { + const bool first_ok_second_or_third_unsupported = + (first.is_ok || first.is_not_used) && + (second.is_unsupported_resource || third.is_unsupported_resource); + const bool final_unsupported = first.is_unsupported_resource && + second.is_unsupported_resource && + third.is_unsupported_resource; + + return first_ok_second_or_third_unsupported || final_unsupported; +} + +std::string SetGlobalPropertiesRequest::MergeInfos( + const app_mngr::commands::ResponseInfo& first_info, + const std::string& first_str, + const app_mngr::commands::ResponseInfo& second_info, + const std::string& second_str, + const app_mngr::commands::ResponseInfo& third_info, + const std::string& third_str) { + if ((first_info.interface_state == HmiInterfaces::STATE_NOT_AVAILABLE) && + + ((second_info.interface_state != HmiInterfaces::STATE_NOT_AVAILABLE) && + !second_str.empty()) && + ((third_info.interface_state != HmiInterfaces::STATE_NOT_AVAILABLE) && + !third_str.empty())) { + return second_str; + } + + if ((second_info.interface_state == HmiInterfaces::STATE_NOT_AVAILABLE) && + ((first_info.interface_state != HmiInterfaces::STATE_NOT_AVAILABLE) && + !first_str.empty()) && + ((third_info.interface_state != HmiInterfaces::STATE_NOT_AVAILABLE) && + !third_str.empty())) { + return first_str; + } + + if ((third_info.interface_state == HmiInterfaces::STATE_NOT_AVAILABLE) && + ((first_info.interface_state != HmiInterfaces::STATE_NOT_AVAILABLE) && + !first_str.empty()) && + ((second_info.interface_state != HmiInterfaces::STATE_NOT_AVAILABLE) && + !second_str.empty())) { + return third_str; + } + + std::string intermediate_result = + app_mngr::commands::MergeInfos(first_str, second_str); + return app_mngr::commands::MergeInfos(intermediate_result, third_str); +} + void SetGlobalPropertiesRequest::PrepareUIRequestVRHelpData( const ApplicationSharedPtr app, const smart_objects::SmartObject& msg_params, @@ -422,8 +657,19 @@ void SetGlobalPropertiesRequest::SendUIRequest( hmi_apis::FunctionID::UI_SetGlobalProperties, ¶ms, use_events); } +void SetGlobalPropertiesRequest::SendRCRequest( + const ns_smart_device_link::ns_smart_objects::SmartObject& params, + bool use_events) { + LOG4CXX_AUTO_TRACE(logger_); + is_rc_send_ = true; + StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_RC); + SendHMIRequest( + hmi_apis::FunctionID::RC_SetGlobalProperties, ¶ms, use_events); +} + bool SetGlobalPropertiesRequest::IsPendingResponseExist() { - return is_ui_send_ != is_ui_received_ || is_tts_send_ != is_tts_received_; + return is_ui_send_ != is_ui_received_ || is_tts_send_ != is_tts_received_ || + is_rc_send_ != is_rc_received_; } bool SetGlobalPropertiesRequest::ValidateConditionalMandatoryParameters( @@ -435,7 +681,9 @@ bool SetGlobalPropertiesRequest::ValidateConditionalMandatoryParameters( params.keyExists(strings::vr_help) || params.keyExists(strings::menu_title) || params.keyExists(strings::menu_icon) || - params.keyExists(strings::keyboard_properties); + params.keyExists(strings::keyboard_properties) || + params.keyExists(strings::menu_layout) || + params.keyExists(strings::user_location); } bool SetGlobalPropertiesRequest::IsWhiteSpaceExist() { @@ -531,7 +779,8 @@ bool SetGlobalPropertiesRequest::IsWhiteSpaceExist() { strings::limited_character_list)) { const smart_objects::SmartArray* lcl_array = msg_params[strings::keyboard_properties] - [strings::limited_character_list].asArray(); + [strings::limited_character_list] + .asArray(); smart_objects::SmartArray::const_iterator it_lcl = lcl_array->begin(); smart_objects::SmartArray::const_iterator it_lcl_end = lcl_array->end(); @@ -548,16 +797,21 @@ bool SetGlobalPropertiesRequest::IsWhiteSpaceExist() { } if (msg_params[strings::keyboard_properties].keyExists( - strings::auto_complete_text)) { - str = - msg_params[strings::keyboard_properties][strings::auto_complete_text] - .asCharArray(); + strings::auto_complete_list)) { + const smart_objects::SmartArray* acl_array = + msg_params[strings::keyboard_properties][strings::auto_complete_list] + .asArray(); - if (!CheckSyntax(str)) { - LOG4CXX_ERROR(logger_, - "Invalid keyboard_properties " - "auto_complete_text syntax check failed"); - return true; + smart_objects::SmartArray::const_iterator it = acl_array->begin(); + + for (; it != acl_array->end(); ++it) { + str = it->asCharArray(); + if (!CheckSyntax(str)) { + LOG4CXX_ERROR(logger_, + "Invalid keyboard_properties " + "auto_complete_list syntax check failed"); + return true; + } } } } @@ -565,4 +819,4 @@ bool SetGlobalPropertiesRequest::IsWhiteSpaceExist() { } } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_global_properties_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_global_properties_response.cc index 567a1a088b9..1de2b97d3a9 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_global_properties_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_global_properties_response.cc @@ -61,4 +61,4 @@ void SetGlobalPropertiesResponse::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_media_clock_timer_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_media_clock_timer_request.cc index 55bd1643684..d610090aa4d 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_media_clock_timer_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_media_clock_timer_request.cc @@ -33,10 +33,10 @@ #include "sdl_rpc_plugin/commands/mobile/set_media_clock_timer_request.h" -#include "application_manager/message_helper.h" #include "application_manager/application_impl.h" -#include "interfaces/MOBILE_API.h" +#include "application_manager/message_helper.h" #include "interfaces/HMI_API.h" +#include "interfaces/MOBILE_API.h" namespace sdl_rpc_plugin { using namespace application_manager; @@ -163,4 +163,4 @@ bool SetMediaClockRequest::isDataValid() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_media_clock_timer_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_media_clock_timer_response.cc index e777533ce41..948ff841569 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_media_clock_timer_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_media_clock_timer_response.cc @@ -61,4 +61,4 @@ void SetMediaClockTimerResponse::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/show_app_menu_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/show_app_menu_request.cc new file mode 100644 index 00000000000..36278168dc0 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/show_app_menu_request.cc @@ -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. + */ + +#include "sdl_rpc_plugin/commands/mobile/show_app_menu_request.h" + +#include "application_manager/message_helper.h" +#include "utils/helpers.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +ShowAppMenuRequest::ShowAppMenuRequest( + 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) + : CommandRequestImpl(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handler) {} + +ShowAppMenuRequest::~ShowAppMenuRequest() {} + +void ShowAppMenuRequest::Run() { + using namespace app_mngr; + LOG4CXX_AUTO_TRACE(logger_); + + ApplicationSharedPtr app = application_manager_.application(connection_key()); + + if (!app) { + LOG4CXX_ERROR( + logger_, + "Application with id " << connection_key() << " is not registered."); + SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED); + return; + } + + if (mobile_apis::HMILevel::HMI_FULL != + app->hmi_level(mobile_apis::PredefinedWindows::DEFAULT_WINDOW) || + helpers::Compare( + app->system_context(mobile_apis::PredefinedWindows::DEFAULT_WINDOW), + mobile_apis::SystemContext::SYSCTXT_MAIN, + mobile_apis::SystemContext::SYSCTXT_MENU)) { + LOG4CXX_ERROR( + logger_, + "Application with id " << connection_key() << " is not activated."); + SendResponse(false, mobile_apis::Result::REJECTED); + return; + } + + auto msg_params = smart_objects::SmartObject(smart_objects::SmartType_Map); + msg_params[strings::app_id] = app->app_id(); + + const auto& received_msg_params = (*message_)[strings::msg_params]; + if (received_msg_params.keyExists(strings::menu_id)) { + const int32_t menu_id = received_msg_params[strings::menu_id].asInt(); + if (!app->FindSubMenu(menu_id)) { + LOG4CXX_ERROR(logger_, "Menu with id " << menu_id << " is not found."); + SendResponse(false, mobile_apis::Result::INVALID_ID); + return; + } + msg_params[strings::menu_id] = menu_id; + } + + StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_UI); + SendHMIRequest(hmi_apis::FunctionID::UI_ShowAppMenu, &msg_params, true); +} + +void ShowAppMenuRequest::on_event(const app_mngr::event_engine::Event& event) { + using namespace app_mngr; + LOG4CXX_AUTO_TRACE(logger_); + const smart_objects::SmartObject& message = event.smart_object(); + + switch (event.id()) { + case hmi_apis::FunctionID::UI_ShowAppMenu: { + EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_UI); + const auto result_code = static_cast( + message[strings::params][hmi_response::code].asInt()); + std::string response_info; + GetInfo(message, response_info); + const bool result = PrepareResultForMobileResponse( + result_code, HmiInterfaces::HMI_INTERFACE_UI); + + ApplicationSharedPtr app = + application_manager_.application(connection_key()); + + if (!app) { + LOG4CXX_ERROR(logger_, + "Application with id " << connection_key() + << " is not registered."); + return; + } + + SendResponse(result, + MessageHelper::HMIToMobileResult(result_code), + response_info.empty() ? NULL : response_info.c_str(), + &message[strings::msg_params]); + break; + } + default: { + LOG4CXX_ERROR(logger_, "Received unknown event: " << event.id()); + return; + } + } +} + +} // namespace commands +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/show_app_menu_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/show_app_menu_response.cc new file mode 100644 index 00000000000..2b952ea9acd --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/show_app_menu_response.cc @@ -0,0 +1,63 @@ +/* + * 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 "sdl_rpc_plugin/commands/mobile/show_app_menu_response.h" + +#include "application_manager/rpc_service.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +ShowAppMenuResponse::ShowAppMenuResponse( + 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) + : CommandResponseImpl(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handler) {} + +ShowAppMenuResponse::~ShowAppMenuResponse() {} + +void ShowAppMenuResponse::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + rpc_service_.SendMessageToMobile(message_); +} + +} // namespace commands +} // namespace sdl_rpc_plugin 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 3b2936e6cd2..b439c1cb169 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 @@ -31,15 +31,15 @@ POSSIBILITY OF SUCH DAMAGE. */ -#include #include "sdl_rpc_plugin/commands/mobile/show_constant_tbt_request.h" +#include -#include "application_manager/policies/policy_handler.h" #include "application_manager/application_impl.h" #include "application_manager/message_helper.h" +#include "application_manager/policies/policy_handler.h" #include "application_manager/policies/policy_handler_interface.h" -#include "interfaces/MOBILE_API.h" #include "interfaces/HMI_API.h" +#include "interfaces/MOBILE_API.h" namespace sdl_rpc_plugin { using namespace application_manager; @@ -228,7 +228,8 @@ bool ShowConstantTBTRequest::IsWhiteSpaceExist() { if ((*message_)[strings::msg_params].keyExists(strings::next_turn_icon)) { str = (*message_)[strings::msg_params][strings::next_turn_icon] - [strings::value].asCharArray(); + [strings::value] + .asCharArray(); if (!CheckSyntax(str)) { LOG4CXX_ERROR(logger_, "Invalid next_turn_icon value syntax check failed"); @@ -289,4 +290,4 @@ bool ShowConstantTBTRequest::IsWhiteSpaceExist() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/show_constant_tbt_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/show_constant_tbt_response.cc index 239040a3b36..d027daf77dc 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/show_constant_tbt_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/show_constant_tbt_response.cc @@ -63,4 +63,4 @@ void ShowConstantTBTResponse::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin 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 e0c3e1da9ac..84d11f8e096 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 @@ -30,12 +30,12 @@ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include #include "sdl_rpc_plugin/commands/mobile/show_request.h" +#include -#include "application_manager/policies/policy_handler.h" #include "application_manager/application.h" #include "application_manager/message_helper.h" +#include "application_manager/policies/policy_handler.h" #include "utils/file_system.h" #include "utils/helpers.h" @@ -55,7 +55,12 @@ ShowRequest::ShowRequest( rpc_service, hmi_capabilities, policy_handler) - , core_result_code_(mobile_apis::Result::INVALID_ENUM) {} + , core_result_code_(mobile_apis::Result::INVALID_ENUM) + , current_window_id_(mobile_apis::PredefinedWindows::DEFAULT_WINDOW) + , template_config_(smart_objects::SmartType::SmartType_Null) + , layout_change_required_(false) + , dcs_change_required_(false) + , ncs_change_required_(false) {} ShowRequest::~ShowRequest() {} @@ -94,6 +99,137 @@ void ShowRequest::HandleMetadata(const char* field_id, } } +bool ShowRequest::CheckTemplateConfigurationForApp( + application_manager::Application& app) { + LOG4CXX_AUTO_TRACE(logger_); + + if ((*message_)[strings::msg_params].keyExists(strings::window_id)) { + current_window_id_ = + (*message_)[strings::msg_params][strings::window_id].asInt(); + } + + const auto set_window_layout = [&app, this]() -> bool { + const auto new_template_layout = + template_config_[strings::template_layout].asString(); + const auto old_template_layout = app.window_layout(current_window_id_); + LOG4CXX_DEBUG(logger_, "New layout: " << new_template_layout); + LOG4CXX_DEBUG(logger_, "Old layout: " << old_template_layout); + + const bool layouts_equal = (new_template_layout == old_template_layout); + + if (!new_template_layout.empty() && !layouts_equal) { + // Template switched, hence allow any color change + LOG4CXX_DEBUG(logger_, + "Show Request: Setting new Layout: " << new_template_layout + << " for window ID: " + << current_window_id_); + layout_change_required_ = true; + return true; + } + LOG4CXX_DEBUG(logger_, "Show Request: No Layout Change"); + return false; + }; + + const auto set_day_color_scheme = [&app, this]() -> bool { + if (!template_config_.keyExists(strings::day_color_scheme)) { + return false; + } + if (app.day_color_scheme(current_window_id_).getType() != + smart_objects::SmartType_Null && + template_config_[strings::day_color_scheme] != + app.day_color_scheme(current_window_id_)) { + // Color scheme param exists and has been previously set, + // hence do not allow color change + LOG4CXX_DEBUG(logger_, "Day Color Scheme change is rejected"); + return false; + } + LOG4CXX_DEBUG(logger_, "Day Color Scheme change is allowed"); + dcs_change_required_ = true; + + return true; + }; + + const auto set_night_color_scheme = [&app, this]() -> bool { + if (!template_config_.keyExists(strings::night_color_scheme)) { + return false; + } + if (app.night_color_scheme(current_window_id_).getType() != + smart_objects::SmartType_Null && + template_config_[strings::night_color_scheme] != + app.night_color_scheme(current_window_id_)) { + // Color scheme param exists and has been previously set, + // hence do not allow color change + LOG4CXX_DEBUG(logger_, "Night Color Scheme change is rejected"); + return false; + } + LOG4CXX_DEBUG(logger_, "Night Color Scheme Change is allowed"); + ncs_change_required_ = true; + + return true; + }; + + const bool set_layout_result = set_window_layout(); + + if (set_layout_result) { + set_day_color_scheme(); + set_night_color_scheme(); + return true; + } + + if (!template_config_.keyExists(strings::night_color_scheme) && + !template_config_.keyExists(strings::day_color_scheme)) { + // In case current layout was not changed and day and night color + // schemes are absent in mobile message SDL has to forward message + // to HMI with the only layout even it was not changed + return true; + } + + const bool set_schemes_result = + (set_day_color_scheme() && set_night_color_scheme()); + + return set_schemes_result; +} + +void ShowRequest::ApplyTemplateConfigurationForApp( + mobile_apis::Result::eType result, application_manager::Application& app) { + LOG4CXX_AUTO_TRACE(logger_); + if (helpers::Compare( + result, + mobile_apis::Result::SUCCESS, + mobile_apis::Result::WARNINGS)) { + if (layout_change_required_) { + const std::string new_layout = + template_config_[strings::template_layout].asString(); + LOG4CXX_DEBUG(logger_, "New layout : " << new_layout << " is applied"); + app.set_window_layout(current_window_id_, new_layout); + + if (template_config_.keyExists(strings::day_color_scheme)) { + app.set_day_color_scheme(current_window_id_, + template_config_[strings::day_color_scheme]); + } + + if (template_config_.keyExists(strings::night_color_scheme)) { + app.set_night_color_scheme( + current_window_id_, template_config_[strings::night_color_scheme]); + } + + return; + } + + if (dcs_change_required_) { + LOG4CXX_DEBUG(logger_, "New day color scheme is applied"); + app.set_day_color_scheme(current_window_id_, + template_config_[strings::day_color_scheme]); + } + + if (ncs_change_required_) { + LOG4CXX_DEBUG(logger_, "New night color scheme is applied"); + app.set_night_color_scheme(current_window_id_, + template_config_[strings::night_color_scheme]); + } + } +} + void ShowRequest::Run() { LOG4CXX_AUTO_TRACE(logger_); @@ -138,7 +274,8 @@ void ShowRequest::Run() { 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()) { + .asString()) + .length()) { verification_result = MessageHelper::VerifyImage( (*message_)[strings::msg_params][strings::graphic], app, @@ -217,6 +354,14 @@ void ShowRequest::Run() { HandleMetadata(strings::main_field_4, main_field_4_index, msg_params); } + if ((*message_)[strings::msg_params].keyExists(strings::template_title)) { + msg_params[hmi_request::show_strings][index][hmi_request::field_name] = + static_cast(hmi_apis::Common_TextFieldName::templateTitle); + msg_params[hmi_request::show_strings][index][hmi_request::field_text] = + (*message_)[strings::msg_params][strings::template_title]; + ++index; + } + if ((*message_)[strings::msg_params].keyExists(strings::media_clock)) { msg_params[hmi_request::show_strings][index][hmi_request::field_name] = static_cast(hmi_apis::Common_TextFieldName::mediaClock); @@ -263,7 +408,7 @@ void ShowRequest::Run() { app->UnsubscribeFromSoftButtons(function_id()); } else { MessageHelper::SubscribeApplicationToSoftButton( - (*message_)[strings::msg_params], app, function_id()); + (*message_)[strings::msg_params], app, function_id(), window_id()); } } @@ -272,6 +417,33 @@ void ShowRequest::Run() { (*message_)[strings::msg_params][strings::custom_presets]; } + if ((*message_)[strings::msg_params].keyExists(strings::window_id)) { + const auto window_id = + (*message_)[strings::msg_params][strings::window_id].asInt(); + if (!app->WindowIdExists(window_id)) { + LOG4CXX_ERROR(logger_, + "Window with id #" << window_id << " does not exist"); + SendResponse(false, mobile_apis::Result::INVALID_ID); + return; + } + msg_params[strings::window_id] = window_id; + } + + if ((*message_)[strings::msg_params].keyExists( + strings::template_configuration)) { + template_config_ = + (*message_)[strings::msg_params][strings::template_configuration]; + const bool result = CheckTemplateConfigurationForApp(*app); + if (!result) { + const char* info( + "Color schemes can not be changed without a new template set"); + SendResponse(false, mobile_apis::Result::REJECTED, info); + return; + } + msg_params[strings::template_configuration] = + (*message_)[strings::msg_params][strings::template_configuration]; + } + StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_UI); SendHMIRequest(hmi_apis::FunctionID::UI_Show, &msg_params, true); @@ -285,6 +457,13 @@ void ShowRequest::on_event(const event_engine::Event& event) { using namespace helpers; const smart_objects::SmartObject& message = event.smart_object(); + 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; + } switch (event.id()) { case hmi_apis::FunctionID::UI_Show: { @@ -304,6 +483,9 @@ void ShowRequest::on_event(const event_engine::Event& event) { } mobile_apis::Result::eType converted_result_code = MessageHelper::HMIToMobileResult(result_code); + + ApplyTemplateConfigurationForApp(converted_result_code, *app); + if (mobile_apis::Result::SUCCESS == converted_result_code && mobile_apis::Result::INVALID_ENUM != core_result_code_) { converted_result_code = core_result_code_; @@ -354,6 +536,14 @@ bool ShowRequest::CheckStringsOfShowRequest() { return false; } } + if ((*message_)[strings::msg_params].keyExists(strings::template_title)) { + str = + (*message_)[strings::msg_params][strings::template_title].asCharArray(); + if (strlen(str) && !CheckSyntax(str)) { + LOG4CXX_ERROR(logger_, "Invalid templateTitle syntax check failed"); + return false; + } + } if ((*message_)[strings::msg_params].keyExists(strings::status_bar)) { str = (*message_)[strings::msg_params][strings::status_bar].asCharArray(); if (strlen(str) && !CheckSyntax(str)) { @@ -398,7 +588,8 @@ bool ShowRequest::CheckStringsOfShowRequest() { if ((*message_)[strings::msg_params].keyExists(strings::secondary_graphic)) { str = (*message_)[strings::msg_params][strings::secondary_graphic] - [strings::value].asCharArray(); + [strings::value] + .asCharArray(); if (!CheckSyntax(str)) { LOG4CXX_ERROR(logger_, "Invalid secondary_graphic value syntax check failed"); @@ -410,4 +601,4 @@ bool ShowRequest::CheckStringsOfShowRequest() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/show_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/show_response.cc index 4e167e75313..f5667189b79 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/show_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/show_response.cc @@ -32,8 +32,8 @@ */ #include "sdl_rpc_plugin/commands/mobile/show_response.h" -#include "application_manager/rpc_service.h" #include "application_manager/application_impl.h" +#include "application_manager/rpc_service.h" #include "interfaces/HMI_API.h" namespace sdl_rpc_plugin { @@ -63,4 +63,4 @@ void ShowResponse::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/slider_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/slider_request.cc index 08b4775d3fc..dd7b426b40d 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/slider_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/slider_request.cc @@ -35,8 +35,8 @@ #include "application_manager/application_impl.h" #include "application_manager/message_helper.h" -#include "utils/helpers.h" #include "config_profile/profile.h" +#include "utils/helpers.h" namespace sdl_rpc_plugin { using namespace application_manager; @@ -116,6 +116,11 @@ void SliderRequest::Run() { msg_params[strings::timeout] = default_timeout_; } + if ((*message_)[strings::msg_params].keyExists(strings::cancel_id)) { + msg_params[strings::cancel_id] = + (*message_)[strings::msg_params][strings::cancel_id].asInt(); + } + StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_UI); SendHMIRequest(hmi_apis::FunctionID::UI_Slider, &msg_params, true); } @@ -204,4 +209,4 @@ bool SliderRequest::IsWhiteSpaceExist() { } } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/slider_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/slider_response.cc index 4d6e714e88a..4ac96a272e3 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/slider_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/slider_response.cc @@ -61,4 +61,4 @@ void SliderResponse::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/speak_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/speak_request.cc index e14321c4882..0730a8730f4 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/speak_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/speak_request.cc @@ -31,8 +31,8 @@ POSSIBILITY OF SUCH DAMAGE. */ -#include #include "sdl_rpc_plugin/commands/mobile/speak_request.h" +#include #include "application_manager/application_impl.h" #include "application_manager/message_helper.h" @@ -84,9 +84,9 @@ void SpeakRequest::Run() { MessageHelper::VerifyTtsFiles(tts_chunks, app, application_manager_); if (mobile_apis::Result::FILE_NOT_FOUND == verification_result) { - LOG4CXX_ERROR(logger_, - "MessageHelper::VerifyTtsFiles return " - << verification_result); + LOG4CXX_ERROR( + logger_, + "MessageHelper::VerifyTtsFiles return " << verification_result); SendResponse(false, mobile_apis::Result::FILE_NOT_FOUND, "One or more files needed for tts_chunks are not present"); @@ -181,4 +181,4 @@ bool SpeakRequest::IsWhiteSpaceExist() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/speak_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/speak_response.cc index f57bd91cd5d..69b04977efe 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/speak_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/speak_response.cc @@ -32,8 +32,8 @@ */ #include "sdl_rpc_plugin/commands/mobile/speak_response.h" -#include "application_manager/rpc_service.h" #include "application_manager/application_impl.h" +#include "application_manager/rpc_service.h" #include "interfaces/HMI_API.h" namespace sdl_rpc_plugin { @@ -63,4 +63,4 @@ void SpeakResponse::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin 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 f76b6ab210a..1acb2a74388 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 @@ -126,6 +126,26 @@ bool SubscribeButtonRequest::IsSubscriptionAllowed( (mobile_apis::ButtonName::TUNEDOWN == btn_id))) { return false; } + + if (!app->is_navi() && + ((mobile_apis::ButtonName::NAV_CENTER_LOCATION == btn_id) || + (mobile_apis::ButtonName::NAV_ZOOM_IN == btn_id) || + (mobile_apis::ButtonName::NAV_ZOOM_OUT == btn_id) || + (mobile_apis::ButtonName::NAV_PAN_UP == btn_id) || + (mobile_apis::ButtonName::NAV_PAN_UP_RIGHT == btn_id) || + (mobile_apis::ButtonName::NAV_PAN_RIGHT == btn_id) || + (mobile_apis::ButtonName::NAV_PAN_DOWN_RIGHT == btn_id) || + (mobile_apis::ButtonName::NAV_PAN_DOWN == btn_id) || + (mobile_apis::ButtonName::NAV_PAN_DOWN_LEFT == btn_id) || + (mobile_apis::ButtonName::NAV_PAN_LEFT == btn_id) || + (mobile_apis::ButtonName::NAV_PAN_UP_LEFT == btn_id) || + (mobile_apis::ButtonName::NAV_TILT_TOGGLE == btn_id) || + (mobile_apis::ButtonName::NAV_ROTATE_CLOCKWISE == btn_id) || + (mobile_apis::ButtonName::NAV_ROTATE_COUNTERCLOCKWISE == btn_id) || + (mobile_apis::ButtonName::NAV_HEADING_TOGGLE == btn_id))) { + return false; + } + return true; } @@ -144,4 +164,4 @@ void SubscribeButtonRequest::SendSubscribeButtonNotification() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/subscribe_button_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/subscribe_button_response.cc index 1350cfb66e3..e584f84f4c0 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/subscribe_button_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/subscribe_button_response.cc @@ -70,4 +70,4 @@ void SubscribeButtonResponse::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/subscribe_way_points_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/subscribe_way_points_request.cc index eb4ca425681..2ee7771833c 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/subscribe_way_points_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/subscribe_way_points_request.cc @@ -30,8 +30,8 @@ POSSIBILITY OF SUCH DAMAGE. */ -#include "application_manager/application_manager.h" #include "sdl_rpc_plugin/commands/mobile/subscribe_way_points_request.h" +#include "application_manager/application_manager.h" #include "application_manager/message_helper.h" namespace sdl_rpc_plugin { @@ -120,4 +120,4 @@ bool SubscribeWayPointsRequest::Init() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/subscribe_way_points_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/subscribe_way_points_response.cc index 7d051df7e9a..45486792d7e 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/subscribe_way_points_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/subscribe_way_points_response.cc @@ -30,9 +30,9 @@ POSSIBILITY OF SUCH DAMAGE. */ +#include "sdl_rpc_plugin/commands/mobile/subscribe_way_points_response.h" #include "application_manager/application_manager.h" #include "application_manager/rpc_service.h" -#include "sdl_rpc_plugin/commands/mobile/subscribe_way_points_response.h" namespace sdl_rpc_plugin { using namespace application_manager; @@ -61,4 +61,4 @@ void SubscribeWayPointsResponse::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/system_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/system_request.cc index ca9182469a9..9be5a270f51 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/system_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/system_request.cc @@ -33,19 +33,19 @@ Copyright (c) 2018, Ford Motor Company #include "sdl_rpc_plugin/commands/mobile/system_request.h" -#include -#include #include #include #include +#include +#include #include "application_manager/policies/policy_handler_interface.h" -#include "interfaces/MOBILE_API.h" -#include "utils/file_system.h" -#include "policy/policy_table/enums.h" #include "formatters/CFormatterJsonBase.h" +#include "interfaces/MOBILE_API.h" #include "json/json.h" -#include "utils/helpers.h" +#include "policy/policy_table/enums.h" #include "utils/custom_string.h" +#include "utils/file_system.h" +#include "utils/helpers.h" namespace sdl_rpc_plugin { using namespace application_manager; @@ -170,17 +170,18 @@ class QueryAppsDataValidator { << "Package name length [" << app_data[json::android][json::packageName] .asString() - .length() << "] exceeds max length [" - << kPackageNameLengthMax << "]in json file."); + .length() + << "] exceeds max length [" << kPackageNameLengthMax + << "]in json file."); return false; } } // Languages verification if (!app_data[os_type].keyExists(json::languages)) { - LOG4CXX_WARN(logger_, - kQueryAppsValidationFailedPrefix - << "'languages' doesn't exist"); + LOG4CXX_WARN( + logger_, + kQueryAppsValidationFailedPrefix << "'languages' doesn't exist"); return false; } if (!ValidateLanguages(app_data[os_type][json::languages], @@ -217,9 +218,9 @@ class QueryAppsDataValidator { ApplicationSharedPtr registered_app = manager_.application_by_policy_id(app_id); if (registered_app) { - LOG4CXX_INFO(logger_, - "Application with the id: " << app_id - << " is already registered."); + LOG4CXX_INFO( + logger_, + "Application with the id: " << app_id << " is already registered."); } // And app name length const std::string appName(app_data[json::name].asString()); @@ -250,9 +251,9 @@ class QueryAppsDataValidator { for (size_t idx = 0; idx < languages_array_size; ++idx) { const smart_objects::SmartObject& language = languages.getElement(idx); if (smart_objects::SmartType_Map != language.getType()) { - LOG4CXX_WARN(logger_, - kQueryAppsValidationFailedPrefix - << "language is not a map."); + LOG4CXX_WARN( + logger_, + kQueryAppsValidationFailedPrefix << "language is not a map."); return false; } if (language.length() != 1) { @@ -263,9 +264,9 @@ class QueryAppsDataValidator { } const std::string language_name = (*language.map_begin()).first; if (!language_name.length()) { - LOG4CXX_WARN(logger_, - kQueryAppsValidationFailedPrefix - << "language name is empty"); + LOG4CXX_WARN( + logger_, + kQueryAppsValidationFailedPrefix << "language name is empty"); return false; } // Verify default language defined @@ -329,9 +330,9 @@ class QueryAppsDataValidator { const smart_objects::SmartArray* synonyms_array = language[language_name][json::vrSynonyms].asArray(); if (!synonyms_array) { - LOG4CXX_WARN(logger_, - kQueryAppsValidationFailedPrefix - << "vrSynonyms is not array."); + LOG4CXX_WARN( + logger_, + kQueryAppsValidationFailedPrefix << "vrSynonyms is not array."); return false; } const size_t synonyms_array_size = synonyms_array->size(); @@ -421,7 +422,7 @@ class QueryAppsDataValidator { DISALLOW_COPY_AND_ASSIGN(QueryAppsDataValidator); }; -} +} // namespace namespace commands { @@ -469,8 +470,8 @@ void SystemRequest::Run() { static_cast( request_type)); - if (!policy_handler.IsRequestTypeAllowed(application->policy_app_id(), - request_type)) { + if (!policy_handler.IsRequestTypeAllowed( + application->device(), application->policy_app_id(), request_type)) { LOG4CXX_ERROR(logger_, "RequestType " << stringified_request_type << " is DISALLOWED by policies"); @@ -699,9 +700,9 @@ void SystemRequest::on_event(const event_engine::Event& event) { bool SystemRequest::ValidateQueryAppData( smart_objects::SmartObject& data) const { if (!data.isValid()) { - LOG4CXX_ERROR(logger_, - kQueryAppsValidationFailedPrefix - << "QueryApps response is not valid."); + LOG4CXX_ERROR( + logger_, + kQueryAppsValidationFailedPrefix << "QueryApps response is not valid."); return false; } if (!data.keyExists(json::response)) { @@ -718,4 +719,4 @@ bool SystemRequest::ValidateQueryAppData( } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/system_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/system_response.cc index dc2e3ea3f5f..428901a1c5a 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/system_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/system_response.cc @@ -61,4 +61,4 @@ void SystemResponse::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/unregister_app_interface_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/unregister_app_interface_request.cc index 9119fb48dac..3ba0513aeb7 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/unregister_app_interface_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/unregister_app_interface_request.cc @@ -32,8 +32,8 @@ */ #include "sdl_rpc_plugin/commands/mobile/unregister_app_interface_request.h" -#include "application_manager/rpc_service.h" #include "application_manager/message_helper.h" +#include "application_manager/rpc_service.h" namespace sdl_rpc_plugin { using namespace application_manager; @@ -62,4 +62,4 @@ void UnregisterAppInterfaceRequest::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/unregister_app_interface_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/unregister_app_interface_response.cc index 4e7c879b588..7c906399684 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/unregister_app_interface_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/unregister_app_interface_response.cc @@ -45,4 +45,4 @@ void UnregisterAppInterfaceResponse::Run() { } } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin 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 0c30f567b44..ec8de68c9ef 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 @@ -94,7 +94,7 @@ void UnsubscribeButtonRequest::Run() { if (!app->UnsubscribeFromButton( static_cast(btn_id))) { - LOG4CXX_ERROR(logger_, "App doesn't subscibe to button " << btn_id); + LOG4CXX_ERROR(logger_, "App doesn't subscribe to button " << btn_id); SendResponse(false, mobile_apis::Result::IGNORED); return; } @@ -123,4 +123,4 @@ void UnsubscribeButtonRequest::SendUnsubscribeButtonNotification() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/unsubscribe_button_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/unsubscribe_button_response.cc index 592b91851e5..c69d49bca10 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/unsubscribe_button_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/unsubscribe_button_response.cc @@ -71,4 +71,4 @@ void UnsubscribeButtonResponse::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/unsubscribe_way_points_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/unsubscribe_way_points_request.cc index 4b40b7a9ce7..17326a99a0a 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/unsubscribe_way_points_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/unsubscribe_way_points_request.cc @@ -30,8 +30,8 @@ POSSIBILITY OF SUCH DAMAGE. */ -#include "application_manager/application_manager.h" #include "sdl_rpc_plugin/commands/mobile/unsubscribe_way_points_request.h" +#include "application_manager/application_manager.h" #include "application_manager/message_helper.h" namespace sdl_rpc_plugin { @@ -125,4 +125,4 @@ bool UnsubscribeWayPointsRequest::Init() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/unsubscribe_way_points_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/unsubscribe_way_points_response.cc index 67e3466a443..a7a180fb46d 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/unsubscribe_way_points_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/unsubscribe_way_points_response.cc @@ -30,8 +30,8 @@ POSSIBILITY OF SUCH DAMAGE. */ -#include "application_manager/application_manager.h" #include "sdl_rpc_plugin/commands/mobile/unsubscribe_way_points_response.h" +#include "application_manager/application_manager.h" #include "application_manager/rpc_service.h" namespace sdl_rpc_plugin { @@ -61,4 +61,4 @@ void UnsubscribeWayPointsResponse::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin 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 c04ad34f5fe..8c2cce97655 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 @@ -31,14 +31,14 @@ POSSIBILITY OF SUCH DAMAGE. */ -#include #include "sdl_rpc_plugin/commands/mobile/update_turn_list_request.h" +#include -#include "application_manager/policies/policy_handler.h" #include "application_manager/application_impl.h" #include "application_manager/message_helper.h" -#include "interfaces/MOBILE_API.h" +#include "application_manager/policies/policy_handler.h" #include "interfaces/HMI_API.h" +#include "interfaces/MOBILE_API.h" #include "utils/custom_string.h" namespace sdl_rpc_plugin { @@ -240,4 +240,4 @@ bool UpdateTurnListRequest::IsWhiteSpaceExist() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/update_turn_list_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/update_turn_list_response.cc index 5ddf355f88d..eca9e3703cf 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/update_turn_list_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/update_turn_list_response.cc @@ -62,4 +62,4 @@ void UpdateTurnListResponse::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/extensions/system_capability_app_extension.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/extensions/system_capability_app_extension.cc index 130585a927b..5ffbbd83bbb 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/extensions/system_capability_app_extension.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/extensions/system_capability_app_extension.cc @@ -25,9 +25,9 @@ bool SystemCapabilityAppExtension::SubscribeTo( bool SystemCapabilityAppExtension::UnsubscribeFrom( const SystemCapabilityType system_capability_type) { - LOG4CXX_INFO(logger_, - "Unsubscribing from System Capability " - << system_capability_type); + LOG4CXX_INFO( + logger_, + "Unsubscribing from System Capability " << system_capability_type); auto it = subscribed_data_.find(system_capability_type); if (it != subscribed_data_.end()) { subscribed_data_.erase(it); @@ -95,4 +95,4 @@ SystemCapabilityAppExtension& SystemCapabilityAppExtension::ExtractExtension( DCHECK(app_extension); return *app_extension; } -} \ No newline at end of file +} // namespace sdl_rpc_plugin \ No newline at end of file diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/hmi_command_factory.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/hmi_command_factory.cc index fb809e8834f..6a231f8e359 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/hmi_command_factory.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/hmi_command_factory.cc @@ -35,215 +35,226 @@ #include "application_manager/message.h" #include "interfaces/HMI_API.h" -#include "sdl_rpc_plugin/commands/hmi/update_device_list_request.h" -#include "sdl_rpc_plugin/commands/hmi/update_device_list_response.h" -#include "sdl_rpc_plugin/commands/hmi/on_update_device_list.h" -#include "sdl_rpc_plugin/commands/hmi/on_start_device_discovery.h" -#include "sdl_rpc_plugin/commands/hmi/update_app_list_request.h" -#include "sdl_rpc_plugin/commands/hmi/update_app_list_response.h" -#include "sdl_rpc_plugin/commands/hmi/on_find_applications.h" +#include "sdl_rpc_plugin/commands/hmi/activate_app_request.h" +#include "sdl_rpc_plugin/commands/hmi/activate_app_response.h" #include "sdl_rpc_plugin/commands/hmi/allow_all_apps_request.h" #include "sdl_rpc_plugin/commands/hmi/allow_all_apps_response.h" #include "sdl_rpc_plugin/commands/hmi/allow_app_request.h" #include "sdl_rpc_plugin/commands/hmi/allow_app_response.h" -#include "sdl_rpc_plugin/commands/hmi/sdl_get_list_of_permissions_request.h" -#include "sdl_rpc_plugin/commands/hmi/sdl_get_list_of_permissions_response.h" -#include "sdl_rpc_plugin/commands/hmi/sdl_get_user_friendly_message_request.h" -#include "sdl_rpc_plugin/commands/hmi/sdl_get_user_friendly_message_response.h" -#include "sdl_rpc_plugin/commands/hmi/sdl_get_status_update_request.h" -#include "sdl_rpc_plugin/commands/hmi/sdl_get_status_update_response.h" -#include "sdl_rpc_plugin/commands/hmi/on_status_update_notification.h" -#include "sdl_rpc_plugin/commands/hmi/update_sdl_request.h" -#include "sdl_rpc_plugin/commands/hmi/update_sdl_response.h" -#include "sdl_rpc_plugin/commands/hmi/activate_app_request.h" -#include "sdl_rpc_plugin/commands/hmi/activate_app_response.h" +#include "sdl_rpc_plugin/commands/hmi/button_get_capabilities_request.h" +#include "sdl_rpc_plugin/commands/hmi/button_get_capabilities_response.h" +#include "sdl_rpc_plugin/commands/hmi/close_popup_request.h" +#include "sdl_rpc_plugin/commands/hmi/close_popup_response.h" +#include "sdl_rpc_plugin/commands/hmi/get_system_info_request.h" +#include "sdl_rpc_plugin/commands/hmi/get_system_info_response.h" #include "sdl_rpc_plugin/commands/hmi/mixing_audio_supported_request.h" #include "sdl_rpc_plugin/commands/hmi/mixing_audio_supported_response.h" #include "sdl_rpc_plugin/commands/hmi/on_allow_sdl_functionality_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_app_activated_notification.h" #include "sdl_rpc_plugin/commands/hmi/on_app_permission_changed_notification.h" #include "sdl_rpc_plugin/commands/hmi/on_app_permission_consent_notification.h" -#include "sdl_rpc_plugin/commands/hmi/on_app_activated_notification.h" #include "sdl_rpc_plugin/commands/hmi/on_audio_data_streaming_notification.h" -#include "sdl_rpc_plugin/commands/hmi/on_video_data_streaming_notification.h" -#include "sdl_rpc_plugin/commands/hmi/on_sdl_consent_needed_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_event_changed_notification.h" #include "sdl_rpc_plugin/commands/hmi/on_exit_all_applications_notification.h" #include "sdl_rpc_plugin/commands/hmi/on_exit_application_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_find_applications.h" +#include "sdl_rpc_plugin/commands/hmi/on_ignition_cycle_over_notification.h" #include "sdl_rpc_plugin/commands/hmi/on_put_file_notification.h" #include "sdl_rpc_plugin/commands/hmi/on_resume_audio_source_notification.h" -#include "sdl_rpc_plugin/commands/hmi/on_ignition_cycle_over_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_sdl_consent_needed_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_start_device_discovery.h" +#include "sdl_rpc_plugin/commands/hmi/on_status_update_notification.h" #include "sdl_rpc_plugin/commands/hmi/on_system_info_changed_notification.h" -#include "sdl_rpc_plugin/commands/hmi/get_system_info_request.h" -#include "sdl_rpc_plugin/commands/hmi/get_system_info_response.h" -#include "sdl_rpc_plugin/commands/hmi/close_popup_request.h" -#include "sdl_rpc_plugin/commands/hmi/close_popup_response.h" -#include "sdl_rpc_plugin/commands/hmi/button_get_capabilities_request.h" -#include "sdl_rpc_plugin/commands/hmi/button_get_capabilities_response.h" +#include "sdl_rpc_plugin/commands/hmi/on_update_device_list.h" +#include "sdl_rpc_plugin/commands/hmi/on_video_data_streaming_notification.h" +#include "sdl_rpc_plugin/commands/hmi/sdl_activate_app_request.h" +#include "sdl_rpc_plugin/commands/hmi/sdl_activate_app_response.h" +#include "sdl_rpc_plugin/commands/hmi/sdl_get_list_of_permissions_request.h" +#include "sdl_rpc_plugin/commands/hmi/sdl_get_list_of_permissions_response.h" +#include "sdl_rpc_plugin/commands/hmi/sdl_get_policy_configuration_data_request.h" +#include "sdl_rpc_plugin/commands/hmi/sdl_get_policy_configuration_data_response.h" +#include "sdl_rpc_plugin/commands/hmi/sdl_get_status_update_request.h" +#include "sdl_rpc_plugin/commands/hmi/sdl_get_status_update_response.h" +#include "sdl_rpc_plugin/commands/hmi/sdl_get_user_friendly_message_request.h" +#include "sdl_rpc_plugin/commands/hmi/sdl_get_user_friendly_message_response.h" +#include "sdl_rpc_plugin/commands/hmi/tts_change_registration_request.h" +#include "sdl_rpc_plugin/commands/hmi/tts_change_registration_response.h" +#include "sdl_rpc_plugin/commands/hmi/tts_get_capabilities_request.h" +#include "sdl_rpc_plugin/commands/hmi/tts_get_capabilities_response.h" +#include "sdl_rpc_plugin/commands/hmi/tts_get_language_request.h" +#include "sdl_rpc_plugin/commands/hmi/tts_get_language_response.h" +#include "sdl_rpc_plugin/commands/hmi/tts_get_supported_languages_request.h" +#include "sdl_rpc_plugin/commands/hmi/tts_get_supported_languages_response.h" +#include "sdl_rpc_plugin/commands/hmi/tts_is_ready_request.h" +#include "sdl_rpc_plugin/commands/hmi/tts_is_ready_response.h" +#include "sdl_rpc_plugin/commands/hmi/tts_set_global_properties_request.h" +#include "sdl_rpc_plugin/commands/hmi/tts_set_global_properties_response.h" +#include "sdl_rpc_plugin/commands/hmi/tts_speak_request.h" +#include "sdl_rpc_plugin/commands/hmi/tts_speak_response.h" +#include "sdl_rpc_plugin/commands/hmi/tts_stop_speaking_request.h" +#include "sdl_rpc_plugin/commands/hmi/tts_stop_speaking_response.h" #include "sdl_rpc_plugin/commands/hmi/ui_add_command_request.h" #include "sdl_rpc_plugin/commands/hmi/ui_add_command_response.h" -#include "sdl_rpc_plugin/commands/hmi/ui_delete_command_request.h" -#include "sdl_rpc_plugin/commands/hmi/ui_delete_command_response.h" #include "sdl_rpc_plugin/commands/hmi/ui_add_submenu_request.h" #include "sdl_rpc_plugin/commands/hmi/ui_add_submenu_response.h" +#include "sdl_rpc_plugin/commands/hmi/ui_alert_request.h" +#include "sdl_rpc_plugin/commands/hmi/ui_alert_response.h" +#include "sdl_rpc_plugin/commands/hmi/ui_change_registration_request.h" +#include "sdl_rpc_plugin/commands/hmi/ui_change_registration_response.h" +#include "sdl_rpc_plugin/commands/hmi/ui_create_window_request.h" +#include "sdl_rpc_plugin/commands/hmi/ui_create_window_response.h" +#include "sdl_rpc_plugin/commands/hmi/ui_delete_command_request.h" +#include "sdl_rpc_plugin/commands/hmi/ui_delete_command_response.h" #include "sdl_rpc_plugin/commands/hmi/ui_delete_submenu_request.h" #include "sdl_rpc_plugin/commands/hmi/ui_delete_submenu_response.h" -#include "sdl_rpc_plugin/commands/hmi/ui_get_supported_languages_request.h" -#include "sdl_rpc_plugin/commands/hmi/ui_get_supported_languages_response.h" -#include "sdl_rpc_plugin/commands/hmi/ui_get_language_request.h" -#include "sdl_rpc_plugin/commands/hmi/ui_get_language_response.h" +#include "sdl_rpc_plugin/commands/hmi/ui_delete_window_request.h" +#include "sdl_rpc_plugin/commands/hmi/ui_delete_window_response.h" +#include "sdl_rpc_plugin/commands/hmi/ui_end_audio_pass_thru_request.h" +#include "sdl_rpc_plugin/commands/hmi/ui_end_audio_pass_thru_response.h" #include "sdl_rpc_plugin/commands/hmi/ui_get_capabilities_request.h" #include "sdl_rpc_plugin/commands/hmi/ui_get_capabilities_response.h" -#include "sdl_rpc_plugin/commands/hmi/ui_change_registration_request.h" -#include "sdl_rpc_plugin/commands/hmi/ui_change_registration_response.h" -#include "sdl_rpc_plugin/commands/hmi/ui_show_request.h" -#include "sdl_rpc_plugin/commands/hmi/ui_show_response.h" -#include "sdl_rpc_plugin/commands/hmi/ui_alert_request.h" -#include "sdl_rpc_plugin/commands/hmi/ui_alert_response.h" +#include "sdl_rpc_plugin/commands/hmi/ui_get_language_request.h" +#include "sdl_rpc_plugin/commands/hmi/ui_get_language_response.h" +#include "sdl_rpc_plugin/commands/hmi/ui_get_supported_languages_request.h" +#include "sdl_rpc_plugin/commands/hmi/ui_get_supported_languages_response.h" #include "sdl_rpc_plugin/commands/hmi/ui_is_ready_request.h" #include "sdl_rpc_plugin/commands/hmi/ui_is_ready_response.h" -#include "sdl_rpc_plugin/commands/hmi/ui_slider_request.h" -#include "sdl_rpc_plugin/commands/hmi/ui_slider_response.h" -#include "sdl_rpc_plugin/commands/hmi/ui_set_media_clock_timer_request.h" -#include "sdl_rpc_plugin/commands/hmi/ui_set_media_clock_timer_response.h" -#include "sdl_rpc_plugin/commands/hmi/ui_set_global_properties_request.h" -#include "sdl_rpc_plugin/commands/hmi/ui_set_global_properties_response.h" +#include "sdl_rpc_plugin/commands/hmi/ui_perform_audio_pass_thru_request.h" +#include "sdl_rpc_plugin/commands/hmi/ui_perform_audio_pass_thru_response.h" +#include "sdl_rpc_plugin/commands/hmi/ui_perform_interaction_request.h" +#include "sdl_rpc_plugin/commands/hmi/ui_perform_interaction_response.h" #include "sdl_rpc_plugin/commands/hmi/ui_scrollable_message_request.h" #include "sdl_rpc_plugin/commands/hmi/ui_scrollable_message_response.h" #include "sdl_rpc_plugin/commands/hmi/ui_set_app_icon_request.h" #include "sdl_rpc_plugin/commands/hmi/ui_set_app_icon_response.h" -#include "sdl_rpc_plugin/commands/hmi/ui_perform_audio_pass_thru_response.h" -#include "sdl_rpc_plugin/commands/hmi/ui_perform_audio_pass_thru_request.h" -#include "sdl_rpc_plugin/commands/hmi/ui_end_audio_pass_thru_response.h" -#include "sdl_rpc_plugin/commands/hmi/ui_end_audio_pass_thru_request.h" -#include "sdl_rpc_plugin/commands/hmi/ui_perform_interaction_request.h" -#include "sdl_rpc_plugin/commands/hmi/ui_perform_interaction_response.h" -#include "sdl_rpc_plugin/commands/hmi/vr_is_ready_request.h" -#include "sdl_rpc_plugin/commands/hmi/vr_is_ready_response.h" +#include "sdl_rpc_plugin/commands/hmi/ui_set_global_properties_request.h" +#include "sdl_rpc_plugin/commands/hmi/ui_set_global_properties_response.h" +#include "sdl_rpc_plugin/commands/hmi/ui_set_media_clock_timer_request.h" +#include "sdl_rpc_plugin/commands/hmi/ui_set_media_clock_timer_response.h" +#include "sdl_rpc_plugin/commands/hmi/ui_show_request.h" +#include "sdl_rpc_plugin/commands/hmi/ui_show_response.h" +#include "sdl_rpc_plugin/commands/hmi/ui_slider_request.h" +#include "sdl_rpc_plugin/commands/hmi/ui_slider_response.h" +#include "sdl_rpc_plugin/commands/hmi/update_app_list_request.h" +#include "sdl_rpc_plugin/commands/hmi/update_app_list_response.h" +#include "sdl_rpc_plugin/commands/hmi/update_device_list_request.h" +#include "sdl_rpc_plugin/commands/hmi/update_device_list_response.h" +#include "sdl_rpc_plugin/commands/hmi/update_sdl_request.h" +#include "sdl_rpc_plugin/commands/hmi/update_sdl_response.h" #include "sdl_rpc_plugin/commands/hmi/vr_add_command_request.h" #include "sdl_rpc_plugin/commands/hmi/vr_add_command_response.h" -#include "sdl_rpc_plugin/commands/hmi/vr_delete_command_request.h" -#include "sdl_rpc_plugin/commands/hmi/vr_delete_command_response.h" #include "sdl_rpc_plugin/commands/hmi/vr_change_registration_request.h" #include "sdl_rpc_plugin/commands/hmi/vr_change_registration_response.h" -#include "sdl_rpc_plugin/commands/hmi/vr_get_supported_languages_request.h" -#include "sdl_rpc_plugin/commands/hmi/vr_get_supported_languages_response.h" -#include "sdl_rpc_plugin/commands/hmi/vr_get_language_request.h" -#include "sdl_rpc_plugin/commands/hmi/vr_get_language_response.h" +#include "sdl_rpc_plugin/commands/hmi/vr_delete_command_request.h" +#include "sdl_rpc_plugin/commands/hmi/vr_delete_command_response.h" #include "sdl_rpc_plugin/commands/hmi/vr_get_capabilities_request.h" #include "sdl_rpc_plugin/commands/hmi/vr_get_capabilities_response.h" -#include "sdl_rpc_plugin/commands/hmi/tts_is_ready_request.h" -#include "sdl_rpc_plugin/commands/hmi/tts_is_ready_response.h" -#include "sdl_rpc_plugin/commands/hmi/tts_change_registration_request.h" -#include "sdl_rpc_plugin/commands/hmi/tts_change_registration_response.h" -#include "sdl_rpc_plugin/commands/hmi/tts_get_supported_languages_request.h" -#include "sdl_rpc_plugin/commands/hmi/tts_get_supported_languages_response.h" -#include "sdl_rpc_plugin/commands/hmi/tts_get_language_request.h" -#include "sdl_rpc_plugin/commands/hmi/tts_get_language_response.h" -#include "sdl_rpc_plugin/commands/hmi/tts_stop_speaking_request.h" -#include "sdl_rpc_plugin/commands/hmi/tts_stop_speaking_response.h" -#include "sdl_rpc_plugin/commands/hmi/tts_speak_request.h" -#include "sdl_rpc_plugin/commands/hmi/tts_speak_response.h" -#include "sdl_rpc_plugin/commands/hmi/tts_set_global_properties_request.h" -#include "sdl_rpc_plugin/commands/hmi/tts_set_global_properties_response.h" -#include "sdl_rpc_plugin/commands/hmi/tts_get_capabilities_request.h" -#include "sdl_rpc_plugin/commands/hmi/tts_get_capabilities_response.h" +#include "sdl_rpc_plugin/commands/hmi/vr_get_language_request.h" +#include "sdl_rpc_plugin/commands/hmi/vr_get_language_response.h" +#include "sdl_rpc_plugin/commands/hmi/vr_get_supported_languages_request.h" +#include "sdl_rpc_plugin/commands/hmi/vr_get_supported_languages_response.h" +#include "sdl_rpc_plugin/commands/hmi/vr_is_ready_request.h" +#include "sdl_rpc_plugin/commands/hmi/vr_is_ready_response.h" #include "sdl_rpc_plugin/commands/hmi/vr_perform_interaction_request.h" #include "sdl_rpc_plugin/commands/hmi/vr_perform_interaction_response.h" -#include "sdl_rpc_plugin/commands/hmi/sdl_activate_app_request.h" -#include "sdl_rpc_plugin/commands/hmi/sdl_activate_app_response.h" -#include "sdl_rpc_plugin/commands/hmi/on_app_permission_changed_notification.h" -#include "sdl_rpc_plugin/commands/hmi/on_event_changed_notification.h" #ifdef EXTERNAL_PROPRIETARY_MODE #include "sdl_rpc_plugin/commands/hmi/decrypt_certificate_request.h" #include "sdl_rpc_plugin/commands/hmi/decrypt_certificate_response.h" #endif // EXTERNAL_PROPRIETARY_MODE +#include "sdl_rpc_plugin/commands/hmi/add_statistics_info_notification.h" +#include "sdl_rpc_plugin/commands/hmi/basic_communication_close_application_request.h" +#include "sdl_rpc_plugin/commands/hmi/basic_communication_close_application_response.h" +#include "sdl_rpc_plugin/commands/hmi/basic_communication_get_system_time_request.h" +#include "sdl_rpc_plugin/commands/hmi/basic_communication_get_system_time_response.h" +#include "sdl_rpc_plugin/commands/hmi/basic_communication_on_awake_sdl.h" +#include "sdl_rpc_plugin/commands/hmi/basic_communication_system_request.h" +#include "sdl_rpc_plugin/commands/hmi/basic_communication_system_response.h" +#include "sdl_rpc_plugin/commands/hmi/dial_number_request.h" +#include "sdl_rpc_plugin/commands/hmi/dial_number_response.h" +#include "sdl_rpc_plugin/commands/hmi/navi_alert_maneuver_request.h" +#include "sdl_rpc_plugin/commands/hmi/navi_alert_maneuver_response.h" +#include "sdl_rpc_plugin/commands/hmi/navi_audio_start_stream_request.h" +#include "sdl_rpc_plugin/commands/hmi/navi_audio_start_stream_response.h" +#include "sdl_rpc_plugin/commands/hmi/navi_audio_stop_stream_request.h" +#include "sdl_rpc_plugin/commands/hmi/navi_audio_stop_stream_response.h" +#include "sdl_rpc_plugin/commands/hmi/navi_get_way_points_request.h" +#include "sdl_rpc_plugin/commands/hmi/navi_get_way_points_response.h" #include "sdl_rpc_plugin/commands/hmi/navi_is_ready_request.h" +#include "sdl_rpc_plugin/commands/hmi/navi_is_ready_response.h" +#include "sdl_rpc_plugin/commands/hmi/navi_send_location_request.h" +#include "sdl_rpc_plugin/commands/hmi/navi_send_location_response.h" +#include "sdl_rpc_plugin/commands/hmi/navi_set_video_config_request.h" +#include "sdl_rpc_plugin/commands/hmi/navi_set_video_config_response.h" #include "sdl_rpc_plugin/commands/hmi/navi_show_constant_tbt_request.h" #include "sdl_rpc_plugin/commands/hmi/navi_show_constant_tbt_response.h" -#include "sdl_rpc_plugin/commands/hmi/navi_is_ready_response.h" -#include "sdl_rpc_plugin/commands/hmi/navi_alert_maneuver_request.h" -#include "sdl_rpc_plugin/commands/hmi/navi_alert_maneuver_response.h" -#include "sdl_rpc_plugin/commands/hmi/navi_update_turn_list_request.h" -#include "sdl_rpc_plugin/commands/hmi/navi_update_turn_list_response.h" +#include "sdl_rpc_plugin/commands/hmi/navi_start_stream_request.h" +#include "sdl_rpc_plugin/commands/hmi/navi_start_stream_response.h" +#include "sdl_rpc_plugin/commands/hmi/navi_stop_stream_request.h" +#include "sdl_rpc_plugin/commands/hmi/navi_stop_stream_response.h" #include "sdl_rpc_plugin/commands/hmi/navi_subscribe_way_points_request.h" #include "sdl_rpc_plugin/commands/hmi/navi_subscribe_way_points_response.h" #include "sdl_rpc_plugin/commands/hmi/navi_unsubscribe_way_points_request.h" #include "sdl_rpc_plugin/commands/hmi/navi_unsubscribe_way_points_response.h" -#include "sdl_rpc_plugin/commands/hmi/navi_get_way_points_request.h" -#include "sdl_rpc_plugin/commands/hmi/navi_get_way_points_response.h" -#include "sdl_rpc_plugin/commands/hmi/on_ready_notification.h" -#include "sdl_rpc_plugin/commands/hmi/on_system_time_ready_notification.h" -#include "sdl_rpc_plugin/commands/hmi/on_device_chosen_notification.h" -#include "sdl_rpc_plugin/commands/hmi/on_file_removed_notification.h" -#include "sdl_rpc_plugin/commands/hmi/on_system_context_notification.h" +#include "sdl_rpc_plugin/commands/hmi/navi_update_turn_list_request.h" +#include "sdl_rpc_plugin/commands/hmi/navi_update_turn_list_response.h" +#include "sdl_rpc_plugin/commands/hmi/on_app_deactivated_notification.h" #include "sdl_rpc_plugin/commands/hmi/on_app_registered_notification.h" #include "sdl_rpc_plugin/commands/hmi/on_app_unregistered_notification.h" -#include "sdl_rpc_plugin/commands/hmi/on_driver_distraction_notification.h" -#include "sdl_rpc_plugin/commands/hmi/on_tts_started_notification.h" -#include "sdl_rpc_plugin/commands/hmi/on_tts_stopped_notification.h" -#include "sdl_rpc_plugin/commands/hmi/on_vr_started_notification.h" -#include "sdl_rpc_plugin/commands/hmi/on_vr_stopped_notification.h" -#include "sdl_rpc_plugin/commands/hmi/on_vr_command_notification.h" -#include "sdl_rpc_plugin/commands/hmi/on_ui_command_notification.h" -#include "sdl_rpc_plugin/commands/hmi/on_app_deactivated_notification.h" -#include "sdl_rpc_plugin/commands/hmi/on_ui_language_change_notification.h" -#include "sdl_rpc_plugin/commands/hmi/on_vr_language_change_notification.h" -#include "sdl_rpc_plugin/commands/hmi/on_tts_language_change_notification.h" -#include "sdl_rpc_plugin/commands/hmi/on_navi_tbt_client_state_notification.h" -#include "sdl_rpc_plugin/commands/hmi/on_navi_way_point_change_notification.h" #include "sdl_rpc_plugin/commands/hmi/on_button_event_notification.h" #include "sdl_rpc_plugin/commands/hmi/on_button_press_notification.h" #include "sdl_rpc_plugin/commands/hmi/on_button_subscription_notification.h" -#include "sdl_rpc_plugin/commands/hmi/on_ui_keyboard_input_notification.h" -#include "sdl_rpc_plugin/commands/hmi/on_ui_touch_event_notification.h" -#include "sdl_rpc_plugin/commands/hmi/on_ui_reset_timeout_notification.h" -#include "sdl_rpc_plugin/commands/hmi/navi_set_video_config_request.h" -#include "sdl_rpc_plugin/commands/hmi/navi_set_video_config_response.h" -#include "sdl_rpc_plugin/commands/hmi/navi_start_stream_request.h" -#include "sdl_rpc_plugin/commands/hmi/navi_start_stream_response.h" -#include "sdl_rpc_plugin/commands/hmi/navi_stop_stream_request.h" -#include "sdl_rpc_plugin/commands/hmi/navi_stop_stream_response.h" -#include "sdl_rpc_plugin/commands/hmi/navi_audio_start_stream_request.h" -#include "sdl_rpc_plugin/commands/hmi/navi_audio_start_stream_response.h" -#include "sdl_rpc_plugin/commands/hmi/navi_audio_stop_stream_request.h" -#include "sdl_rpc_plugin/commands/hmi/navi_audio_stop_stream_response.h" -#include "sdl_rpc_plugin/commands/hmi/on_system_request_notification.h" -#include "sdl_rpc_plugin/commands/hmi/ui_set_display_layout_request.h" -#include "sdl_rpc_plugin/commands/hmi/ui_set_display_layout_response.h" +#include "sdl_rpc_plugin/commands/hmi/on_device_chosen_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_device_state_changed_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_driver_distraction_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_file_removed_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_navi_tbt_client_state_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_navi_way_point_change_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_policy_update.h" +#include "sdl_rpc_plugin/commands/hmi/on_ready_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_received_policy_update.h" +#include "sdl_rpc_plugin/commands/hmi/on_record_start_notification.h" #include "sdl_rpc_plugin/commands/hmi/on_sdl_close_notification.h" #include "sdl_rpc_plugin/commands/hmi/on_sdl_persistence_complete_notification.h" -#include "sdl_rpc_plugin/commands/hmi/on_record_start_notification.h" -#include "sdl_rpc_plugin/commands/hmi/add_statistics_info_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_system_context_notification.h" #include "sdl_rpc_plugin/commands/hmi/on_system_error_notification.h" -#include "sdl_rpc_plugin/commands/hmi/basic_communication_system_request.h" -#include "sdl_rpc_plugin/commands/hmi/basic_communication_system_response.h" -#include "sdl_rpc_plugin/commands/hmi/basic_communication_get_system_time_request.h" -#include "sdl_rpc_plugin/commands/hmi/basic_communication_get_system_time_response.h" -#include "sdl_rpc_plugin/commands/hmi/basic_communication_on_awake_sdl.h" +#include "sdl_rpc_plugin/commands/hmi/on_system_request_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_system_time_ready_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_tts_language_change_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_tts_reset_timeout_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_tts_started_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_tts_stopped_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_ui_command_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_ui_keyboard_input_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_ui_language_change_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_ui_reset_timeout_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_ui_touch_event_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_vr_command_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_vr_language_change_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_vr_started_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_vr_stopped_notification.h" #include "sdl_rpc_plugin/commands/hmi/sdl_policy_update.h" #include "sdl_rpc_plugin/commands/hmi/sdl_policy_update_response.h" -#include "sdl_rpc_plugin/commands/hmi/on_received_policy_update.h" -#include "sdl_rpc_plugin/commands/hmi/on_policy_update.h" -#include "sdl_rpc_plugin/commands/hmi/get_urls.h" -#include "sdl_rpc_plugin/commands/hmi/get_urls_response.h" -#include "sdl_rpc_plugin/commands/hmi/on_device_state_changed_notification.h" -#include "sdl_rpc_plugin/commands/hmi/navi_send_location_request.h" -#include "sdl_rpc_plugin/commands/hmi/navi_send_location_response.h" -#include "sdl_rpc_plugin/commands/hmi/on_tts_reset_timeout_notification.h" -#include "sdl_rpc_plugin/commands/hmi/dial_number_request.h" -#include "sdl_rpc_plugin/commands/hmi/dial_number_response.h" +#include "sdl_rpc_plugin/commands/hmi/ui_cancel_interaction_request.h" +#include "sdl_rpc_plugin/commands/hmi/ui_cancel_interaction_response.h" #include "sdl_rpc_plugin/commands/hmi/ui_send_haptic_data_request.h" #include "sdl_rpc_plugin/commands/hmi/ui_send_haptic_data_response.h" +#include "sdl_rpc_plugin/commands/hmi/ui_set_display_layout_request.h" +#include "sdl_rpc_plugin/commands/hmi/ui_set_display_layout_response.h" +#include "sdl_rpc_plugin/commands/hmi/ui_show_app_menu_request.h" +#include "sdl_rpc_plugin/commands/hmi/ui_show_app_menu_response.h" -#include "sdl_rpc_plugin/commands/hmi/rc_is_ready_request.h" -#include "sdl_rpc_plugin/commands/hmi/rc_is_ready_response.h" -#include "sdl_rpc_plugin/commands/hmi/rc_get_capabilities_request.h" -#include "sdl_rpc_plugin/commands/hmi/rc_get_capabilities_response.h" #include "sdl_rpc_plugin/commands/hmi/bc_get_file_path_request.h" #include "sdl_rpc_plugin/commands/hmi/bc_get_file_path_response.h" +#include "sdl_rpc_plugin/commands/hmi/on_service_update_notification.h" +#include "sdl_rpc_plugin/commands/hmi/rc_get_capabilities_request.h" +#include "sdl_rpc_plugin/commands/hmi/rc_get_capabilities_response.h" +#include "sdl_rpc_plugin/commands/hmi/rc_is_ready_request.h" +#include "sdl_rpc_plugin/commands/hmi/rc_is_ready_response.h" #include "sdl_rpc_plugin/commands/hmi/on_bc_system_capability_updated_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_bc_system_capability_updated_notification_from_hmi.h" namespace sdl_rpc_plugin { using namespace application_manager; @@ -293,7 +304,8 @@ bool HMICommandFactory::IsAbleToProcess( return get_creator_factory( static_cast(function_id), hmi_apis::messageType::INVALID_ENUM, - message_source).CanBeCreated(); + message_source) + .CanBeCreated(); } CommandCreator& HMICommandFactory::get_creator_factory( @@ -317,6 +329,13 @@ CommandCreator& HMICommandFactory::get_creator_factory( ? factory.GetCreator() : factory.GetCreator(); } + case hmi_apis::FunctionID::BasicCommunication_CloseApplication: { + return hmi_apis::messageType::request == message_type + ? factory.GetCreator< + commands::BasicCommunicationCloseApplicationRequest>() + : factory.GetCreator< + commands::BasicCommunicationCloseApplicationResponse>(); + } #ifdef EXTERNAL_PROPRIETARY_MODE case hmi_apis::FunctionID::BasicCommunication_DecryptCertificate: { return hmi_apis::messageType::request == message_type @@ -339,11 +358,6 @@ CommandCreator& HMICommandFactory::get_creator_factory( ? factory.GetCreator() : factory.GetCreator(); } - case hmi_apis::FunctionID::SDL_GetURLS: { - return hmi_apis::messageType::request == message_type - ? factory.GetCreator() - : factory.GetCreator(); - } case hmi_apis::FunctionID::SDL_OnAppPermissionChanged: { return factory.GetCreator(); } @@ -366,6 +380,13 @@ CommandCreator& HMICommandFactory::get_creator_factory( ? factory.GetCreator() : factory.GetCreator(); } + case hmi_apis::FunctionID::SDL_GetPolicyConfigurationData: { + return hmi_apis::messageType::request == message_type + ? factory.GetCreator< + commands::SDLGetPolicyConfigurationDataRequest>() + : factory.GetCreator< + commands::SDLGetPolicyConfigurationDataResponse>(); + } case hmi_apis::FunctionID::SDL_OnStatusUpdate: { return factory.GetCreator(); } @@ -385,6 +406,11 @@ CommandCreator& HMICommandFactory::get_creator_factory( ? factory.GetCreator() : factory.GetCreator(); } + case hmi_apis::FunctionID::UI_CancelInteraction: { + return hmi_apis::messageType::request == message_type + ? factory.GetCreator() + : factory.GetCreator(); + } case hmi_apis::FunctionID::UI_DeleteCommand: { return hmi_apis::messageType::request == message_type ? factory.GetCreator() @@ -400,6 +426,16 @@ CommandCreator& HMICommandFactory::get_creator_factory( ? factory.GetCreator() : factory.GetCreator(); } + case hmi_apis::FunctionID::UI_ShowAppMenu: { + return hmi_apis::messageType::request == message_type + ? factory.GetCreator() + : factory.GetCreator(); + } + case hmi_apis::FunctionID::UI_DeleteWindow: { + return hmi_apis::messageType::request == message_type + ? factory.GetCreator() + : factory.GetCreator(); + } case hmi_apis::FunctionID::UI_SetMediaClockTimer: { return hmi_apis::messageType::request == message_type ? factory.GetCreator() @@ -448,6 +484,11 @@ CommandCreator& HMICommandFactory::get_creator_factory( ? factory.GetCreator() : factory.GetCreator(); } + case hmi_apis::FunctionID::UI_CreateWindow: { + return hmi_apis::messageType::request == message_type + ? factory.GetCreator() + : factory.GetCreator(); + } case hmi_apis::FunctionID::UI_PerformAudioPassThru: { return hmi_apis::messageType::request == message_type ? factory.GetCreator() @@ -828,6 +869,9 @@ CommandCreator& HMICommandFactory::get_creator_factory( ? factory.GetCreator() : factory.GetCreator(); } + case hmi_apis::FunctionID::BasicCommunication_OnServiceUpdate: { + return factory.GetCreator(); + } case hmi_apis::FunctionID::Navigation_OnWayPointChange: { return factory.GetCreator(); } @@ -852,11 +896,16 @@ CommandCreator& HMICommandFactory::get_creator_factory( : factory.GetCreator(); } case hmi_apis::FunctionID::BasicCommunication_OnSystemCapabilityUpdated: { - return factory - .GetCreator(); + return (application_manager::commands::Command::CommandSource:: + SOURCE_HMI == source) + ? factory.GetCreator< + commands:: + OnBCSystemCapabilityUpdatedNotificationFromHMI>() + : factory.GetCreator< + commands::OnBCSystemCapabilityUpdatedNotification>(); } default: { return factory.GetCreator(); } } } -} // namespace application_manager +} // namespace sdl_rpc_plugin 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 fbbe5183dfa..c6f4b64636f 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 @@ -31,29 +31,44 @@ */ #include "sdl_rpc_plugin/mobile_command_factory.h" +#include "interfaces/MOBILE_API.h" #include "sdl_rpc_plugin/commands/mobile/add_command_request.h" #include "sdl_rpc_plugin/commands/mobile/add_command_response.h" -#include "sdl_rpc_plugin/commands/mobile/delete_command_request.h" -#include "sdl_rpc_plugin/commands/mobile/delete_command_response.h" #include "sdl_rpc_plugin/commands/mobile/add_sub_menu_request.h" #include "sdl_rpc_plugin/commands/mobile/add_sub_menu_response.h" -#include "sdl_rpc_plugin/commands/mobile/alert_request.h" -#include "sdl_rpc_plugin/commands/mobile/alert_response.h" #include "sdl_rpc_plugin/commands/mobile/alert_maneuver_request.h" #include "sdl_rpc_plugin/commands/mobile/alert_maneuver_response.h" +#include "sdl_rpc_plugin/commands/mobile/alert_request.h" +#include "sdl_rpc_plugin/commands/mobile/alert_response.h" +#include "sdl_rpc_plugin/commands/mobile/cancel_interaction_request.h" +#include "sdl_rpc_plugin/commands/mobile/cancel_interaction_response.h" #include "sdl_rpc_plugin/commands/mobile/change_registration_request.h" #include "sdl_rpc_plugin/commands/mobile/change_registration_response.h" +#include "sdl_rpc_plugin/commands/mobile/close_application_request.h" +#include "sdl_rpc_plugin/commands/mobile/close_application_response.h" #include "sdl_rpc_plugin/commands/mobile/create_interaction_choice_set_request.h" #include "sdl_rpc_plugin/commands/mobile/create_interaction_choice_set_response.h" +#include "sdl_rpc_plugin/commands/mobile/create_window_request.h" +#include "sdl_rpc_plugin/commands/mobile/create_window_response.h" +#include "sdl_rpc_plugin/commands/mobile/delete_command_request.h" +#include "sdl_rpc_plugin/commands/mobile/delete_command_response.h" #include "sdl_rpc_plugin/commands/mobile/delete_file_request.h" #include "sdl_rpc_plugin/commands/mobile/delete_file_response.h" #include "sdl_rpc_plugin/commands/mobile/delete_interaction_choice_set_request.h" #include "sdl_rpc_plugin/commands/mobile/delete_interaction_choice_set_response.h" #include "sdl_rpc_plugin/commands/mobile/delete_sub_menu_request.h" #include "sdl_rpc_plugin/commands/mobile/delete_sub_menu_response.h" +#include "sdl_rpc_plugin/commands/mobile/delete_window_request.h" +#include "sdl_rpc_plugin/commands/mobile/delete_window_response.h" +#include "sdl_rpc_plugin/commands/mobile/dial_number_request.h" +#include "sdl_rpc_plugin/commands/mobile/dial_number_response.h" #include "sdl_rpc_plugin/commands/mobile/end_audio_pass_thru_request.h" #include "sdl_rpc_plugin/commands/mobile/end_audio_pass_thru_response.h" #include "sdl_rpc_plugin/commands/mobile/generic_response.h" +#include "sdl_rpc_plugin/commands/mobile/get_cloud_app_properties_request.h" +#include "sdl_rpc_plugin/commands/mobile/get_cloud_app_properties_response.h" +#include "sdl_rpc_plugin/commands/mobile/get_file_request.h" +#include "sdl_rpc_plugin/commands/mobile/get_file_response.h" #include "sdl_rpc_plugin/commands/mobile/get_system_capability_request.h" #include "sdl_rpc_plugin/commands/mobile/get_system_capability_response.h" #include "sdl_rpc_plugin/commands/mobile/get_way_points_request.h" @@ -64,16 +79,19 @@ #include "sdl_rpc_plugin/commands/mobile/on_audio_pass_thru_notification.h" #include "sdl_rpc_plugin/commands/mobile/on_button_event_notification.h" #include "sdl_rpc_plugin/commands/mobile/on_button_press_notification.h" +#include "sdl_rpc_plugin/commands/mobile/on_command_notification.h" #include "sdl_rpc_plugin/commands/mobile/on_driver_distraction_notification.h" +#include "sdl_rpc_plugin/commands/mobile/on_hash_change_notification.h" #include "sdl_rpc_plugin/commands/mobile/on_hmi_status_notification.h" #include "sdl_rpc_plugin/commands/mobile/on_hmi_status_notification_from_mobile.h" +#include "sdl_rpc_plugin/commands/mobile/on_keyboard_input_notification.h" #include "sdl_rpc_plugin/commands/mobile/on_language_change_notification.h" -#include "sdl_rpc_plugin/commands/mobile/on_command_notification.h" #include "sdl_rpc_plugin/commands/mobile/on_permissions_change_notification.h" +#include "sdl_rpc_plugin/commands/mobile/on_system_capability_updated_notification.h" +#include "sdl_rpc_plugin/commands/mobile/on_system_request_notification.h" #include "sdl_rpc_plugin/commands/mobile/on_tbt_client_state_notification.h" -#include "sdl_rpc_plugin/commands/mobile/on_hash_change_notification.h" +#include "sdl_rpc_plugin/commands/mobile/on_touch_event_notification.h" #include "sdl_rpc_plugin/commands/mobile/on_way_point_change_notification.h" -#include "sdl_rpc_plugin/commands/mobile/on_system_capability_updated_notification.h" #include "sdl_rpc_plugin/commands/mobile/perform_audio_pass_thru_request.h" #include "sdl_rpc_plugin/commands/mobile/perform_audio_pass_thru_response.h" #include "sdl_rpc_plugin/commands/mobile/perform_interaction_request.h" @@ -86,14 +104,22 @@ #include "sdl_rpc_plugin/commands/mobile/reset_global_properties_response.h" #include "sdl_rpc_plugin/commands/mobile/scrollable_message_request.h" #include "sdl_rpc_plugin/commands/mobile/scrollable_message_response.h" +#include "sdl_rpc_plugin/commands/mobile/send_haptic_data_request.h" +#include "sdl_rpc_plugin/commands/mobile/send_haptic_data_response.h" +#include "sdl_rpc_plugin/commands/mobile/send_location_request.h" +#include "sdl_rpc_plugin/commands/mobile/send_location_response.h" +#include "sdl_rpc_plugin/commands/mobile/set_app_icon_request.h" +#include "sdl_rpc_plugin/commands/mobile/set_app_icon_response.h" +#include "sdl_rpc_plugin/commands/mobile/set_cloud_app_properties_request.h" +#include "sdl_rpc_plugin/commands/mobile/set_cloud_app_properties_response.h" #include "sdl_rpc_plugin/commands/mobile/set_display_layout_request.h" #include "sdl_rpc_plugin/commands/mobile/set_display_layout_response.h" #include "sdl_rpc_plugin/commands/mobile/set_global_properties_request.h" #include "sdl_rpc_plugin/commands/mobile/set_global_properties_response.h" -#include "sdl_rpc_plugin/commands/mobile/set_app_icon_request.h" -#include "sdl_rpc_plugin/commands/mobile/set_app_icon_response.h" #include "sdl_rpc_plugin/commands/mobile/set_media_clock_timer_request.h" #include "sdl_rpc_plugin/commands/mobile/set_media_clock_timer_response.h" +#include "sdl_rpc_plugin/commands/mobile/show_app_menu_request.h" +#include "sdl_rpc_plugin/commands/mobile/show_app_menu_response.h" #include "sdl_rpc_plugin/commands/mobile/show_constant_tbt_request.h" #include "sdl_rpc_plugin/commands/mobile/show_constant_tbt_response.h" #include "sdl_rpc_plugin/commands/mobile/show_request.h" @@ -106,32 +132,16 @@ #include "sdl_rpc_plugin/commands/mobile/subscribe_button_response.h" #include "sdl_rpc_plugin/commands/mobile/subscribe_way_points_request.h" #include "sdl_rpc_plugin/commands/mobile/subscribe_way_points_response.h" -#include "sdl_rpc_plugin/commands/mobile/unsubscribe_way_points_request.h" -#include "sdl_rpc_plugin/commands/mobile/unsubscribe_way_points_response.h" +#include "sdl_rpc_plugin/commands/mobile/system_request.h" +#include "sdl_rpc_plugin/commands/mobile/system_response.h" #include "sdl_rpc_plugin/commands/mobile/unregister_app_interface_request.h" #include "sdl_rpc_plugin/commands/mobile/unregister_app_interface_response.h" #include "sdl_rpc_plugin/commands/mobile/unsubscribe_button_request.h" #include "sdl_rpc_plugin/commands/mobile/unsubscribe_button_response.h" +#include "sdl_rpc_plugin/commands/mobile/unsubscribe_way_points_request.h" +#include "sdl_rpc_plugin/commands/mobile/unsubscribe_way_points_response.h" #include "sdl_rpc_plugin/commands/mobile/update_turn_list_request.h" #include "sdl_rpc_plugin/commands/mobile/update_turn_list_response.h" -#include "sdl_rpc_plugin/commands/mobile/system_request.h" -#include "sdl_rpc_plugin/commands/mobile/system_response.h" -#include "sdl_rpc_plugin/commands/mobile/on_keyboard_input_notification.h" -#include "sdl_rpc_plugin/commands/mobile/on_touch_event_notification.h" -#include "sdl_rpc_plugin/commands/mobile/on_system_request_notification.h" -#include "sdl_rpc_plugin/commands/mobile/send_location_request.h" -#include "sdl_rpc_plugin/commands/mobile/send_location_response.h" -#include "sdl_rpc_plugin/commands/mobile/dial_number_request.h" -#include "sdl_rpc_plugin/commands/mobile/dial_number_response.h" -#include "sdl_rpc_plugin/commands/mobile/send_haptic_data_request.h" -#include "sdl_rpc_plugin/commands/mobile/send_haptic_data_response.h" -#include "sdl_rpc_plugin/commands/mobile/set_cloud_app_properties_request.h" -#include "sdl_rpc_plugin/commands/mobile/set_cloud_app_properties_response.h" -#include "sdl_rpc_plugin/commands/mobile/get_cloud_app_properties_request.h" -#include "sdl_rpc_plugin/commands/mobile/get_cloud_app_properties_response.h" -#include "sdl_rpc_plugin/commands/mobile/get_file_request.h" -#include "sdl_rpc_plugin/commands/mobile/get_file_response.h" -#include "interfaces/MOBILE_API.h" CREATE_LOGGERPTR_GLOBAL(logger_, "ApplicationManager") namespace sdl_rpc_plugin { @@ -170,6 +180,11 @@ CommandCreator& MobileCommandFactory::get_command_creator( ? factory.GetCreator() : factory.GetCreator(); } + case mobile_apis::FunctionID::CreateWindowID: { + return mobile_api::messageType::request == message_type + ? factory.GetCreator() + : factory.GetCreator(); + } case mobile_apis::FunctionID::DeleteCommandID: { return mobile_api::messageType::request == message_type ? factory.GetCreator() @@ -185,6 +200,16 @@ CommandCreator& MobileCommandFactory::get_command_creator( ? factory.GetCreator() : factory.GetCreator(); } + case mobile_apis::FunctionID::ShowAppMenuID: { + return mobile_api::messageType::request == message_type + ? factory.GetCreator() + : factory.GetCreator(); + } + case mobile_apis::FunctionID::DeleteWindowID: { + return mobile_api::messageType::request == message_type + ? factory.GetCreator() + : factory.GetCreator(); + } case mobile_apis::FunctionID::DeleteInteractionChoiceSetID: { return mobile_api::messageType::request == message_type ? factory.GetCreator< @@ -212,6 +237,11 @@ CommandCreator& MobileCommandFactory::get_command_creator( ? factory.GetCreator() : factory.GetCreator(); } + case mobile_apis::FunctionID::CancelInteractionID: { + return mobile_api::messageType::request == message_type + ? factory.GetCreator() + : factory.GetCreator(); + } case mobile_apis::FunctionID::CreateInteractionChoiceSetID: { return mobile_api::messageType::request == message_type ? factory.GetCreator< @@ -356,6 +386,11 @@ CommandCreator& MobileCommandFactory::get_command_creator( : factory .GetCreator(); } + case mobile_apis::FunctionID::CloseApplicationID: { + return mobile_api::messageType::request == message_type + ? factory.GetCreator() + : factory.GetCreator(); + } case mobile_apis::FunctionID::GenericResponseID: { using app_mngr::commands::Command; return factory.GetCreator(); @@ -512,4 +547,4 @@ CommandSharedPtr MobileCommandFactory::CreateCommand( return get_creator_factory(function_id, message_type, source).create(message); } -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/sdl_command_factory.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/sdl_command_factory.cc index d745cd8f44e..21f15a33fe2 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/sdl_command_factory.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/sdl_command_factory.cc @@ -77,4 +77,4 @@ bool SDLCommandFactory::IsAbleToProcess( : is_mobile_command_factory_able_to_process; } -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/sdl_rpc_plugin.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/sdl_rpc_plugin.cc index c448b41ff15..35d3fbe2f6a 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/sdl_rpc_plugin.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/sdl_rpc_plugin.cc @@ -30,10 +30,10 @@ POSSIBILITY OF SUCH DAMAGE. */ -#include "application_manager/plugin_manager/plugin_keys.h" #include "sdl_rpc_plugin/sdl_rpc_plugin.h" -#include "sdl_rpc_plugin/sdl_command_factory.h" +#include "application_manager/plugin_manager/plugin_keys.h" #include "sdl_rpc_plugin/extensions/system_capability_app_extension.h" +#include "sdl_rpc_plugin/sdl_command_factory.h" namespace sdl_rpc_plugin { namespace app_mngr = application_manager; @@ -44,7 +44,9 @@ CREATE_LOGGERPTR_GLOBAL(logger_, "SdlRPCPlugin") bool SDLRPCPlugin::Init(app_mngr::ApplicationManager& app_manager, app_mngr::rpc_service::RPCService& rpc_service, app_mngr::HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handler) { + policy::PolicyHandlerInterface& policy_handler, + resumption::LastState& last_state) { + UNUSED(last_state); command_factory_.reset(new sdl_rpc_plugin::SDLCommandFactory( app_manager, rpc_service, hmi_capabilities, policy_handler)); return true; @@ -70,8 +72,14 @@ void SDLRPCPlugin::OnApplicationEvent( plugins::ApplicationEvent event, app_mngr::ApplicationSharedPtr application) { if (plugins::ApplicationEvent::kApplicationRegistered == event) { - application->AddExtension( - std::make_shared(*this, *application)); + auto sys_cap_ext_ptr = + std::make_shared(*this, *application); + application->AddExtension(sys_cap_ext_ptr); + // Processing automatic subscription to SystemCapabilities for DISPLAY type + const auto capability_type = + mobile_apis::SystemCapabilityType::eType::DISPLAYS; + LOG4CXX_DEBUG(logger_, "Subscription to DISPLAYS capability is enabled"); + sys_cap_ext_ptr->SubscribeTo(capability_type); } else if (plugins::ApplicationEvent::kDeleteApplicationData == event) { ClearSubscriptions(application); } @@ -84,6 +92,14 @@ void SDLRPCPlugin::ClearSubscriptions(app_mngr::ApplicationSharedPtr app) { } // namespace sdl_rpc_plugin -extern "C" application_manager::plugin_manager::RPCPlugin* Create() { +extern "C" __attribute__((visibility("default"))) +application_manager::plugin_manager::RPCPlugin* +Create() { return new sdl_rpc_plugin::SDLRPCPlugin(); } + +extern "C" __attribute__((visibility("default"))) void Delete( + application_manager::plugin_manager::RPCPlugin* data) { + delete data; + DELETE_THREAD_LOGGER(sdl_rpc_plugin::logger_); +} 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 1a206c2cce9..b21ab9dca86 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 @@ -23,15 +23,8 @@ file(GLOB SOURCES ) set(LIBRARIES + sdl_rpc_plugin_static gmock - Utils - SmartObjects - HMI_API - MOBILE_API - connectionHandler - sdl_rpc_plugin - jsoncpp - Policy ) create_cotired_test("sdl_commands_test" "${SOURCES}" "${LIBRARIES}" ) diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/activate_app_request_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/activate_app_request_test.cc index 50b7aae42a8..7dadad59fee 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/activate_app_request_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/activate_app_request_test.cc @@ -30,12 +30,12 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include "gtest/gtest.h" #include "hmi/activate_app_request.h" -#include "smart_objects/smart_object.h" #include "application_manager/commands/command_impl.h" #include "application_manager/commands/commands_test.h" #include "application_manager/mock_application.h" +#include "gtest/gtest.h" +#include "smart_objects/smart_object.h" namespace test { namespace components { @@ -47,9 +47,9 @@ using ::testing::_; namespace am = ::application_manager; namespace strings = ::application_manager::strings; +using am::commands::CommandImpl; using am::commands::MessageSharedPtr; using sdl_rpc_plugin::commands::ActivateAppRequest; -using am::commands::CommandImpl; using ::test::components::application_manager_test::MockApplication; diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/add_statistics_info_notification_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/add_statistics_info_notification_test.cc index a5707488dd9..01487284a4e 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/add_statistics_info_notification_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/add_statistics_info_notification_test.cc @@ -30,15 +30,15 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include "gtest/gtest.h" #include "hmi/add_statistics_info_notification.h" +#include "gtest/gtest.h" -#include "smart_objects/smart_object.h" #include "application_manager/commands/commands_test.h" #include "application_manager/mock_application.h" -#include "application_manager/smart_object_keys.h" -#include "application_manager/policies/policy_handler.h" #include "application_manager/policies/mock_policy_handler_interface.h" +#include "application_manager/policies/policy_handler.h" +#include "application_manager/smart_object_keys.h" +#include "smart_objects/smart_object.h" namespace test { namespace components { @@ -49,11 +49,11 @@ namespace add_statistics_info_notification { namespace am = ::application_manager; namespace strings = ::application_manager::strings; namespace hmi_notification = ::application_manager::hmi_notification; -using am::commands::MessageSharedPtr; -using sdl_rpc_plugin::commands::AddStatisticsInfoNotification; using am::commands::CommandImpl; +using am::commands::MessageSharedPtr; using policy::PolicyHandler; using policy_test::MockPolicyHandlerInterface; +using sdl_rpc_plugin::commands::AddStatisticsInfoNotification; using ::testing::_; using ::testing::Return; using ::testing::ReturnRef; diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/allow_all_apps_response_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/allow_all_apps_response_test.cc index a2fcf8f6056..251fe230fc1 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/allow_all_apps_response_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/allow_all_apps_response_test.cc @@ -30,13 +30,13 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include "gtest/gtest.h" #include "hmi/allow_all_apps_response.h" +#include "gtest/gtest.h" -#include "smart_objects/smart_object.h" #include "application_manager/commands/command_impl.h" #include "application_manager/commands/commands_test.h" #include "application_manager/mock_application.h" +#include "smart_objects/smart_object.h" namespace test { namespace components { namespace commands_test { @@ -53,7 +53,7 @@ typedef std::shared_ptr ResponsePtr; namespace { const bool kResponseIsAllowed = true; -} // +} // namespace class AllowAllAppsResponseTest : public CommandsTest {}; diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/allow_app_response_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/allow_app_response_test.cc index 2ce400542a0..a0e23d7b9d5 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/allow_app_response_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/allow_app_response_test.cc @@ -30,8 +30,8 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include "gtest/gtest.h" #include "hmi/allow_app_response.h" +#include "gtest/gtest.h" #include "application_manager/commands/commands_test.h" #include "application_manager/mock_application.h" @@ -53,7 +53,7 @@ namespace hmi_response = ::application_manager::hmi_response; namespace { const uint32_t kConnectionKey = 1u; const bool kIsResponseAllowed = true; -} +} // namespace typedef std::shared_ptr ResponsePtr; diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/basic_communication_get_system_time_request_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/basic_communication_get_system_time_request_test.cc index a3f0ab6933a..9cd87b053d8 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/basic_communication_get_system_time_request_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/basic_communication_get_system_time_request_test.cc @@ -28,7 +28,7 @@ * 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 "hmi/basic_communication_get_system_time_request.h" @@ -60,7 +60,7 @@ TEST_F(BasicCommunicationGetSystemTimeRequestTest, OnTimeout) { ON_CALL(app_mngr_, protocol_handler()) .WillByDefault(ReturnRef(mock_protocol_handler)); - EXPECT_CALL(mock_protocol_handler, NotifyOnFailedHandshake()); + EXPECT_CALL(mock_protocol_handler, NotifyOnGetSystemTimeFailed()); command->onTimeOut(); } diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/basic_communication_get_system_time_response_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/basic_communication_get_system_time_response_test.cc index 8f56c6462c6..0c8e986fc6a 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/basic_communication_get_system_time_response_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/basic_communication_get_system_time_response_test.cc @@ -30,12 +30,12 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include "gtest/gtest.h" -#include "application_manager/commands/commands_test.h" #include "hmi/basic_communication_get_system_time_response.h" +#include "application_manager/commands/commands_test.h" #include "application_manager/mock_application_manager.h" #include "application_manager/mock_event_dispatcher.h" #include "application_manager/smart_object_keys.h" +#include "gtest/gtest.h" #include "interfaces/HMI_API.h" namespace test { diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/button_get_capabilities_response_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/button_get_capabilities_response_test.cc index 6ed15bebebb..7d9ed899a63 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/button_get_capabilities_response_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/button_get_capabilities_response_test.cc @@ -30,13 +30,13 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include "gtest/gtest.h" #include "hmi/button_get_capabilities_response.h" +#include "gtest/gtest.h" -#include "smart_objects/smart_object.h" #include "application_manager/commands/commands_test.h" #include "application_manager/mock_application.h" #include "application_manager/mock_hmi_capabilities.h" +#include "smart_objects/smart_object.h" namespace test { namespace components { namespace commands_test { @@ -45,8 +45,8 @@ namespace button_get_capabilities_response { using application_manager::commands::MessageSharedPtr; using sdl_rpc_plugin::commands::ButtonGetCapabilitiesResponse; -using ::testing::ReturnRef; using ::testing::NiceMock; +using ::testing::ReturnRef; namespace strings = ::application_manager::strings; namespace hmi_response = ::application_manager::hmi_response; @@ -100,7 +100,8 @@ TEST_F(ButtonGetCapabilitiesResponseTest, Run_CodeAborted_SUCCESS) { EXPECT_CALL(mock_hmi_capabilities_, set_button_capabilities(capabilities_)) .Times(0); EXPECT_CALL(mock_hmi_capabilities_, - set_preset_bank_capabilities(preset_bank_capabilities_)).Times(0); + set_preset_bank_capabilities(preset_bank_capabilities_)) + .Times(0); command->Run(); } diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/close_popup_response_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/close_popup_response_test.cc index 6914a4ca7eb..087109c8719 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/close_popup_response_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/close_popup_response_test.cc @@ -35,13 +35,13 @@ #include "gtest/gtest.h" -#include "smart_objects/smart_object.h" -#include "application_manager/smart_object_keys.h" #include "application_manager/commands/command.h" -#include "application_manager/commands/response_from_hmi.h" -#include "hmi/close_popup_response.h" #include "application_manager/commands/commands_test.h" +#include "application_manager/commands/response_from_hmi.h" #include "application_manager/mock_application.h" +#include "application_manager/smart_object_keys.h" +#include "hmi/close_popup_response.h" +#include "smart_objects/smart_object.h" namespace test { namespace components { @@ -50,9 +50,9 @@ namespace hmi_commands_test { namespace close_popup_response { namespace am = ::application_manager; +using am::commands::CommandImpl; using application_manager::commands::ResponseFromHMI; using sdl_rpc_plugin::commands::ClosePopupResponse; -using am::commands::CommandImpl; typedef std::shared_ptr ResponseFromHMIPtr; diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/dummy_hmi_commands_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/dummy_hmi_commands_test.cc index 874d27b4b07..c66cb811412 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/dummy_hmi_commands_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/dummy_hmi_commands_test.cc @@ -37,194 +37,191 @@ #include #include "gtest/gtest.h" +#include "hmi/activate_app_request.h" +#include "hmi/activate_app_response.h" +#include "hmi/add_statistics_info_notification.h" #include "hmi/allow_all_apps_request.h" #include "hmi/allow_all_apps_response.h" #include "hmi/allow_app_request.h" #include "hmi/allow_app_response.h" +#include "hmi/basic_communication_system_request.h" +#include "hmi/basic_communication_system_response.h" +#include "hmi/bc_get_file_path_request.h" +#include "hmi/bc_get_file_path_response.h" +#include "hmi/button_get_capabilities_request.h" +#include "hmi/button_get_capabilities_response.h" +#include "hmi/close_popup_request.h" +#include "hmi/close_popup_response.h" +#include "hmi/dial_number_request.h" +#include "hmi/dial_number_response.h" +#include "hmi/get_system_info_request.h" +#include "hmi/get_system_info_response.h" +#include "hmi/mixing_audio_supported_request.h" +#include "hmi/mixing_audio_supported_response.h" +#include "hmi/navi_alert_maneuver_request.h" +#include "hmi/navi_alert_maneuver_response.h" #include "hmi/navi_audio_start_stream_request.h" #include "hmi/navi_audio_start_stream_response.h" #include "hmi/navi_audio_stop_stream_request.h" #include "hmi/navi_audio_stop_stream_response.h" -#include "hmi/update_device_list_request.h" -#include "hmi/update_device_list_response.h" -#include "hmi/on_update_device_list.h" -#include "hmi/on_start_device_discovery.h" -#include "hmi/update_app_list_request.h" -#include "hmi/update_app_list_response.h" -#include "hmi/on_find_applications.h" -#include "hmi/sdl_get_list_of_permissions_request.h" -#include "hmi/sdl_get_list_of_permissions_response.h" -#include "hmi/sdl_get_user_friendly_message_request.h" -#include "hmi/sdl_get_user_friendly_message_response.h" -#include "hmi/sdl_get_status_update_request.h" -#include "hmi/sdl_get_status_update_response.h" -#include "hmi/on_status_update_notification.h" -#include "hmi/update_sdl_request.h" -#include "hmi/update_sdl_response.h" -#include "hmi/activate_app_request.h" -#include "hmi/activate_app_response.h" -#include "hmi/mixing_audio_supported_request.h" -#include "hmi/mixing_audio_supported_response.h" +#include "hmi/navi_get_way_points_request.h" +#include "hmi/navi_get_way_points_response.h" +#include "hmi/navi_is_ready_request.h" +#include "hmi/navi_is_ready_response.h" +#include "hmi/navi_send_location_request.h" +#include "hmi/navi_send_location_response.h" +#include "hmi/navi_show_constant_tbt_request.h" +#include "hmi/navi_show_constant_tbt_response.h" +#include "hmi/navi_start_stream_request.h" +#include "hmi/navi_start_stream_response.h" +#include "hmi/navi_stop_stream_request.h" +#include "hmi/navi_stop_stream_response.h" +#include "hmi/navi_subscribe_way_points_request.h" +#include "hmi/navi_subscribe_way_points_response.h" +#include "hmi/navi_unsubscribe_way_points_request.h" +#include "hmi/navi_unsubscribe_way_points_response.h" +#include "hmi/navi_update_turn_list_request.h" +#include "hmi/navi_update_turn_list_response.h" #include "hmi/on_allow_sdl_functionality_notification.h" +#include "hmi/on_app_activated_notification.h" +#include "hmi/on_app_deactivated_notification.h" #include "hmi/on_app_permission_changed_notification.h" #include "hmi/on_app_permission_consent_notification.h" -#include "hmi/on_app_activated_notification.h" +#include "hmi/on_app_registered_notification.h" +#include "hmi/on_app_unregistered_notification.h" #include "hmi/on_audio_data_streaming_notification.h" -#include "hmi/on_video_data_streaming_notification.h" -#include "hmi/on_sdl_consent_needed_notification.h" +#include "hmi/on_button_event_notification.h" +#include "hmi/on_button_press_notification.h" +#include "hmi/on_button_subscription_notification.h" +#include "hmi/on_device_chosen_notification.h" +#include "hmi/on_device_state_changed_notification.h" +#include "hmi/on_driver_distraction_notification.h" +#include "hmi/on_event_changed_notification.h" #include "hmi/on_exit_all_applications_notification.h" #include "hmi/on_exit_application_notification.h" +#include "hmi/on_file_removed_notification.h" +#include "hmi/on_find_applications.h" +#include "hmi/on_ignition_cycle_over_notification.h" +#include "hmi/on_navi_tbt_client_state_notification.h" +#include "hmi/on_navi_way_point_change_notification.h" +#include "hmi/on_policy_update.h" #include "hmi/on_put_file_notification.h" +#include "hmi/on_ready_notification.h" +#include "hmi/on_received_policy_update.h" +#include "hmi/on_record_start_notification.h" #include "hmi/on_resume_audio_source_notification.h" -#include "hmi/on_ignition_cycle_over_notification.h" +#include "hmi/on_sdl_close_notification.h" +#include "hmi/on_sdl_consent_needed_notification.h" +#include "hmi/on_sdl_persistence_complete_notification.h" +#include "hmi/on_start_device_discovery.h" +#include "hmi/on_status_update_notification.h" +#include "hmi/on_system_context_notification.h" +#include "hmi/on_system_error_notification.h" #include "hmi/on_system_info_changed_notification.h" -#include "hmi/get_system_info_request.h" -#include "hmi/get_system_info_response.h" -#include "hmi/close_popup_request.h" -#include "hmi/close_popup_response.h" -#include "hmi/button_get_capabilities_request.h" -#include "hmi/button_get_capabilities_response.h" +#include "hmi/on_system_request_notification.h" +#include "hmi/on_tts_language_change_notification.h" +#include "hmi/on_tts_reset_timeout_notification.h" +#include "hmi/on_tts_started_notification.h" +#include "hmi/on_tts_stopped_notification.h" +#include "hmi/on_ui_command_notification.h" +#include "hmi/on_ui_keyboard_input_notification.h" +#include "hmi/on_ui_language_change_notification.h" +#include "hmi/on_ui_reset_timeout_notification.h" +#include "hmi/on_ui_touch_event_notification.h" +#include "hmi/on_update_device_list.h" +#include "hmi/on_video_data_streaming_notification.h" +#include "hmi/on_vr_command_notification.h" +#include "hmi/on_vr_language_change_notification.h" +#include "hmi/on_vr_started_notification.h" +#include "hmi/on_vr_stopped_notification.h" +#include "hmi/sdl_activate_app_request.h" +#include "hmi/sdl_activate_app_response.h" +#include "hmi/sdl_get_list_of_permissions_request.h" +#include "hmi/sdl_get_list_of_permissions_response.h" +#include "hmi/sdl_get_status_update_request.h" +#include "hmi/sdl_get_status_update_response.h" +#include "hmi/sdl_get_user_friendly_message_request.h" +#include "hmi/sdl_get_user_friendly_message_response.h" +#include "hmi/sdl_policy_update.h" +#include "hmi/sdl_policy_update_response.h" +#include "hmi/tts_change_registration_request.h" +#include "hmi/tts_change_registration_response.h" +#include "hmi/tts_get_capabilities_request.h" +#include "hmi/tts_get_capabilities_response.h" +#include "hmi/tts_get_language_request.h" +#include "hmi/tts_get_language_response.h" +#include "hmi/tts_get_supported_languages_request.h" +#include "hmi/tts_get_supported_languages_response.h" +#include "hmi/tts_is_ready_request.h" +#include "hmi/tts_is_ready_response.h" +#include "hmi/tts_set_global_properties_request.h" +#include "hmi/tts_set_global_properties_response.h" +#include "hmi/tts_speak_request.h" +#include "hmi/tts_speak_response.h" +#include "hmi/tts_stop_speaking_request.h" +#include "hmi/tts_stop_speaking_response.h" #include "hmi/ui_add_command_request.h" #include "hmi/ui_add_command_response.h" -#include "hmi/ui_delete_command_request.h" -#include "hmi/ui_delete_command_response.h" #include "hmi/ui_add_submenu_request.h" #include "hmi/ui_add_submenu_response.h" +#include "hmi/ui_alert_request.h" +#include "hmi/ui_alert_response.h" +#include "hmi/ui_change_registration_request.h" +#include "hmi/ui_change_registration_response.h" +#include "hmi/ui_delete_command_request.h" +#include "hmi/ui_delete_command_response.h" #include "hmi/ui_delete_submenu_request.h" #include "hmi/ui_delete_submenu_response.h" -#include "hmi/ui_get_supported_languages_request.h" -#include "hmi/ui_get_supported_languages_response.h" -#include "hmi/ui_get_language_request.h" -#include "hmi/ui_get_language_response.h" +#include "hmi/ui_end_audio_pass_thru_request.h" +#include "hmi/ui_end_audio_pass_thru_response.h" #include "hmi/ui_get_capabilities_request.h" #include "hmi/ui_get_capabilities_response.h" -#include "hmi/ui_change_registration_request.h" -#include "hmi/ui_change_registration_response.h" -#include "hmi/ui_show_request.h" -#include "hmi/ui_show_response.h" -#include "hmi/ui_alert_request.h" -#include "hmi/ui_alert_response.h" +#include "hmi/ui_get_language_request.h" +#include "hmi/ui_get_language_response.h" +#include "hmi/ui_get_supported_languages_request.h" +#include "hmi/ui_get_supported_languages_response.h" #include "hmi/ui_is_ready_request.h" #include "hmi/ui_is_ready_response.h" -#include "hmi/ui_slider_request.h" -#include "hmi/ui_slider_response.h" -#include "hmi/ui_set_media_clock_timer_request.h" -#include "hmi/ui_set_media_clock_timer_response.h" -#include "hmi/ui_set_global_properties_request.h" -#include "hmi/ui_set_global_properties_response.h" +#include "hmi/ui_perform_audio_pass_thru_request.h" +#include "hmi/ui_perform_audio_pass_thru_response.h" +#include "hmi/ui_perform_interaction_request.h" +#include "hmi/ui_perform_interaction_response.h" #include "hmi/ui_scrollable_message_request.h" #include "hmi/ui_scrollable_message_response.h" #include "hmi/ui_set_app_icon_request.h" #include "hmi/ui_set_app_icon_response.h" -#include "hmi/ui_perform_audio_pass_thru_response.h" -#include "hmi/ui_perform_audio_pass_thru_request.h" -#include "hmi/ui_end_audio_pass_thru_request.h" -#include "hmi/ui_end_audio_pass_thru_response.h" -#include "hmi/ui_perform_interaction_request.h" -#include "hmi/ui_perform_interaction_response.h" -#include "hmi/vr_is_ready_request.h" -#include "hmi/vr_is_ready_response.h" +#include "hmi/ui_set_display_layout_request.h" +#include "hmi/ui_set_display_layout_response.h" +#include "hmi/ui_set_global_properties_request.h" +#include "hmi/ui_set_global_properties_response.h" +#include "hmi/ui_set_media_clock_timer_request.h" +#include "hmi/ui_set_media_clock_timer_response.h" +#include "hmi/ui_show_request.h" +#include "hmi/ui_show_response.h" +#include "hmi/ui_slider_request.h" +#include "hmi/ui_slider_response.h" +#include "hmi/update_app_list_request.h" +#include "hmi/update_app_list_response.h" +#include "hmi/update_device_list_request.h" +#include "hmi/update_device_list_response.h" +#include "hmi/update_sdl_request.h" +#include "hmi/update_sdl_response.h" #include "hmi/vr_add_command_request.h" #include "hmi/vr_add_command_response.h" -#include "hmi/vr_delete_command_request.h" -#include "hmi/vr_delete_command_response.h" #include "hmi/vr_change_registration_request.h" #include "hmi/vr_change_registration_response.h" -#include "hmi/vr_get_supported_languages_request.h" -#include "hmi/vr_get_supported_languages_response.h" -#include "hmi/vr_get_language_request.h" -#include "hmi/vr_get_language_response.h" +#include "hmi/vr_delete_command_request.h" +#include "hmi/vr_delete_command_response.h" #include "hmi/vr_get_capabilities_request.h" #include "hmi/vr_get_capabilities_response.h" -#include "hmi/tts_is_ready_request.h" -#include "hmi/tts_is_ready_response.h" -#include "hmi/tts_change_registration_request.h" -#include "hmi/tts_change_registration_response.h" -#include "hmi/tts_get_supported_languages_request.h" -#include "hmi/tts_get_supported_languages_response.h" -#include "hmi/tts_get_language_request.h" -#include "hmi/tts_get_language_response.h" -#include "hmi/tts_stop_speaking_request.h" -#include "hmi/tts_stop_speaking_response.h" -#include "hmi/tts_speak_request.h" -#include "hmi/tts_speak_response.h" -#include "hmi/tts_set_global_properties_request.h" -#include "hmi/tts_set_global_properties_response.h" -#include "hmi/tts_get_capabilities_request.h" -#include "hmi/tts_get_capabilities_response.h" +#include "hmi/vr_get_language_request.h" +#include "hmi/vr_get_language_response.h" +#include "hmi/vr_get_supported_languages_request.h" +#include "hmi/vr_get_supported_languages_response.h" +#include "hmi/vr_is_ready_request.h" +#include "hmi/vr_is_ready_response.h" #include "hmi/vr_perform_interaction_request.h" #include "hmi/vr_perform_interaction_response.h" -#include "hmi/sdl_activate_app_request.h" -#include "hmi/sdl_activate_app_response.h" -#include "hmi/on_app_permission_changed_notification.h" -#include "hmi/on_event_changed_notification.h" -#include "hmi/navi_is_ready_request.h" -#include "hmi/navi_show_constant_tbt_request.h" -#include "hmi/navi_show_constant_tbt_response.h" -#include "hmi/navi_is_ready_response.h" -#include "hmi/navi_alert_maneuver_request.h" -#include "hmi/navi_alert_maneuver_response.h" -#include "hmi/navi_update_turn_list_request.h" -#include "hmi/navi_update_turn_list_response.h" -#include "hmi/navi_subscribe_way_points_request.h" -#include "hmi/navi_subscribe_way_points_response.h" -#include "hmi/navi_unsubscribe_way_points_request.h" -#include "hmi/navi_unsubscribe_way_points_response.h" -#include "hmi/navi_get_way_points_request.h" -#include "hmi/navi_get_way_points_response.h" -#include "hmi/on_ready_notification.h" -#include "hmi/on_device_chosen_notification.h" -#include "hmi/on_file_removed_notification.h" -#include "hmi/on_system_context_notification.h" -#include "hmi/on_app_registered_notification.h" -#include "hmi/on_app_unregistered_notification.h" -#include "hmi/on_driver_distraction_notification.h" -#include "hmi/on_tts_started_notification.h" -#include "hmi/on_tts_stopped_notification.h" -#include "hmi/on_vr_started_notification.h" -#include "hmi/on_vr_stopped_notification.h" -#include "hmi/on_vr_command_notification.h" -#include "hmi/on_ui_command_notification.h" -#include "hmi/on_app_deactivated_notification.h" -#include "hmi/on_ui_language_change_notification.h" -#include "hmi/on_vr_language_change_notification.h" -#include "hmi/on_tts_language_change_notification.h" -#include "hmi/on_navi_tbt_client_state_notification.h" -#include "hmi/on_navi_way_point_change_notification.h" -#include "hmi/on_button_event_notification.h" -#include "hmi/on_button_press_notification.h" -#include "hmi/on_button_subscription_notification.h" -#include "hmi/on_ui_keyboard_input_notification.h" -#include "hmi/on_ui_touch_event_notification.h" -#include "hmi/on_ui_reset_timeout_notification.h" -#include "hmi/navi_start_stream_request.h" -#include "hmi/navi_start_stream_response.h" -#include "hmi/navi_stop_stream_request.h" -#include "hmi/navi_stop_stream_response.h" -#include "hmi/on_system_request_notification.h" -#include "hmi/ui_set_display_layout_request.h" -#include "hmi/ui_set_display_layout_response.h" -#include "hmi/on_sdl_close_notification.h" -#include "hmi/on_sdl_persistence_complete_notification.h" -#include "hmi/on_record_start_notification.h" -#include "hmi/add_statistics_info_notification.h" -#include "hmi/on_system_error_notification.h" -#include "hmi/basic_communication_system_request.h" -#include "hmi/basic_communication_system_response.h" -#include "hmi/sdl_policy_update.h" -#include "hmi/sdl_policy_update_response.h" -#include "hmi/on_received_policy_update.h" -#include "hmi/on_policy_update.h" -#include "hmi/get_urls.h" -#include "hmi/get_urls_response.h" -#include "hmi/on_device_state_changed_notification.h" -#include "hmi/navi_send_location_request.h" -#include "hmi/navi_send_location_response.h" -#include "hmi/on_tts_reset_timeout_notification.h" -#include "hmi/dial_number_request.h" -#include "hmi/dial_number_response.h" -#include "hmi/bc_get_file_path_request.h" -#include "hmi/bc_get_file_path_response.h" #include "application_manager/commands/commands_test.h" #include "application_manager/mock_application.h" @@ -242,16 +239,16 @@ namespace dummy_hmi_commands_test { namespace commands = sdl_rpc_plugin::commands; -using ::testing::_; -using ::testing::NotNull; -using ::testing::Types; +using ::application_manager::ApplicationSharedPtr; using application_manager::commands::MessageSharedPtr; -using ::test::components::event_engine_test::MockEventDispatcher; +using ::test::components::application_manager_test::MockApplication; using ::test::components::application_manager_test::MockApplicationManager; using ::test::components::application_manager_test:: MockApplicationManagerSettings; -using ::application_manager::ApplicationSharedPtr; -using ::test::components::application_manager_test::MockApplication; +using ::test::components::event_engine_test::MockEventDispatcher; +using ::testing::_; +using ::testing::NotNull; +using ::testing::Types; template class HMICommandsTest : public components::commands_test::CommandRequestTest< @@ -321,8 +318,6 @@ typedef Types HMICommandsListFirst; + commands::UIChangeRegistratioResponse> + HMICommandsListFirst; typedef Types HMICommandsListSecond; + commands::UIIsReadyRequest> + HMICommandsListSecond; typedef Types HMICommandsListThird; + commands::OnAppDeactivatedNotification> + HMICommandsListThird; typedef Types HMICommandsListFourth; + commands::OnTTSLanguageChangeNotification> + HMICommandsListFourth; typedef Types HMICommandsListFifth; + commands::BCGetFilePathResponse> + HMICommandsListFifth; TYPED_TEST_CASE(HMICommandsTestFirst, HMICommandsListFirst); TYPED_TEST_CASE(HMICommandsTestSecond, HMICommandsListSecond); diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/get_system_info_request_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/get_system_info_request_test.cc index 4cbe7305ea0..5b860499dd9 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/get_system_info_request_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/get_system_info_request_test.cc @@ -35,13 +35,13 @@ #include "gtest/gtest.h" -#include "smart_objects/smart_object.h" -#include "application_manager/smart_object_keys.h" -#include "application_manager/commands/commands_test.h" #include "application_manager/application.h" -#include "application_manager/mock_application_manager.h" +#include "application_manager/commands/commands_test.h" #include "application_manager/commands/request_to_hmi.h" +#include "application_manager/mock_application_manager.h" +#include "application_manager/smart_object_keys.h" #include "hmi/get_system_info_request.h" +#include "smart_objects/smart_object.h" namespace test { namespace components { @@ -51,9 +51,9 @@ namespace get_system_info_request { namespace am = ::application_manager; namespace strings = ::application_manager::strings; +using am::commands::CommandImpl; using am::commands::RequestToHMI; using sdl_rpc_plugin::commands::GetSystemInfoRequest; -using am::commands::CommandImpl; typedef std::shared_ptr RequestToHMIPtr; diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/get_system_info_response_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/get_system_info_response_test.cc index 6908e21053d..11589683bee 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/get_system_info_response_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/get_system_info_response_test.cc @@ -33,32 +33,32 @@ #include #include -#include "gtest/gtest.h" -#include "smart_objects/smart_object.h" -#include "application_manager/smart_object_keys.h" #include "application_manager/application.h" +#include "application_manager/commands/commands_test.h" +#include "application_manager/commands/response_from_hmi.h" +#include "application_manager/mock_application_manager.h" #include "application_manager/mock_hmi_capabilities.h" #include "application_manager/mock_message_helper.h" -#include "application_manager/mock_application_manager.h" -#include "application_manager/commands/response_from_hmi.h" -#include "hmi/get_system_info_response.h" #include "application_manager/policies/mock_policy_handler_interface.h" -#include "application_manager/commands/commands_test.h" +#include "application_manager/smart_object_keys.h" +#include "gtest/gtest.h" +#include "hmi/get_system_info_response.h" +#include "smart_objects/smart_object.h" namespace test { namespace components { namespace commands_test { namespace hmi_commands_test { namespace get_system_info_response { -using ::testing::Return; using ::testing::NiceMock; +using ::testing::Return; namespace am = ::application_manager; namespace strings = ::application_manager::strings; namespace hmi_response = am::hmi_response; +using am::commands::CommandImpl; using application_manager::commands::ResponseFromHMI; using sdl_rpc_plugin::commands::GetSystemInfoResponse; using sdl_rpc_plugin::commands::SystemInfo; -using am::commands::CommandImpl; typedef std::shared_ptr ResponseFromHMIPtr; typedef NiceMock< diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/get_urls_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/get_urls_test.cc deleted file mode 100644 index 20a05d8601a..00000000000 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/get_urls_test.cc +++ /dev/null @@ -1,334 +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 -#include - -#include "gtest/gtest.h" -#include "application_manager/message.h" -#include "application_manager/commands/commands_test.h" -#include "application_manager/mock_application.h" -#include "application_manager/mock_application_manager.h" -#include "smart_objects/smart_object.h" -#include "application_manager/smart_object_keys.h" -#include "application_manager/commands/command.h" -#include "hmi/get_urls.h" -#include "application_manager/policies/policy_handler.h" -#include "application_manager/policies/mock_policy_handler_interface.h" -#include "application_manager/commands/command_request_test.h" -#include "application_manager/commands/request_from_hmi.h" -#include "policy/mock_policy_manager.h" -#include "application_manager/event_engine/event_dispatcher.h" - -namespace test { -namespace components { -namespace commands_test { -namespace hmi_commands_test { -namespace get_urls { - -using namespace hmi_apis; -using namespace policy; -using ::testing::NiceMock; -using ::testing::_; -using ::testing::SetArgReferee; -using ::test::components::application_manager_test::MockApplication; -namespace am = ::application_manager; -namespace strings = ::application_manager::strings; -using am::commands::RequestFromHMI; -using sdl_rpc_plugin::commands::GetUrls; -using am::commands::CommandImpl; -using policy::PolicyHandler; -using policy_test::MockPolicyHandlerInterface; - -typedef std::shared_ptr RequestFromHMIPtr; - -namespace { -const uint32_t kInvalidAppId_ = 0u; -const uint32_t kAppIdForSending = 1u; -const uint32_t kConnectionKey = 2u; -const uint32_t kServiceType = 0u; -const std::string kInitialService = "0x0"; -const std::string kPolicyService = "7"; -const std::string kDefaultUrl = "URL is not found"; -const std::string kDefaultId = "default"; -const std::string kPolicyAppId = "policy_app_id"; -} // namespace - -class GetUrlsTest : public CommandRequestTest { - public: - MessageSharedPtr command_msg_; - RequestFromHMIPtr request_command_; - - GetUrlsTest() { - command_msg_ = - CreateMessage(ns_smart_device_link::ns_smart_objects::SmartType_Map); - (*command_msg_)[am::strings::params][am::strings::connection_key] = - kConnectionKey; - (*command_msg_)[am::strings::msg_params][am::hmi_request::service] = - kInitialService; - - request_command_ = CreateCommand(command_msg_); - } -}; - -TEST_F(GetUrlsTest, RUN_SUCCESS) { - EXPECT_CALL(mock_policy_handler_, PolicyEnabled()).WillOnce(Return(true)); - // EXPECT_CALL(mock_policy_handler_, GetUpdateUrls(_, _)); - - request_command_->Run(); -} - -TEST_F(GetUrlsTest, RUN_PolicyNotEnabled_UNSUCCESS) { - EXPECT_CALL(mock_policy_handler_, PolicyEnabled()).WillOnce(Return(false)); - - EXPECT_CALL(mock_rpc_service_, ManageHMICommand(command_msg_, _)) - .WillOnce(Return(true)); - - request_command_->Run(); - - EXPECT_EQ(am::MessageType::kResponse, - (*command_msg_)[strings::params][strings::message_type].asInt()); - EXPECT_EQ(Common_Result::DATA_NOT_AVAILABLE, - (*command_msg_)[strings::params][am::hmi_response::code].asInt()); -} - -TEST_F(GetUrlsTest, RUN_EmptyEndpoints_UNSUCCESS) { - EndpointUrls endpoints_; - EXPECT_CALL(mock_policy_handler_, GetUpdateUrls(kServiceType, _)) - .WillOnce(SetArgReferee<1>(endpoints_)); - EXPECT_CALL(mock_policy_handler_, PolicyEnabled()).WillOnce(Return(true)); - - EXPECT_CALL(mock_rpc_service_, ManageHMICommand(command_msg_, _)) - .WillOnce(Return(true)); - - request_command_->Run(); - - EXPECT_EQ(am::MessageType::kResponse, - (*command_msg_)[strings::params][strings::message_type].asInt()); - EXPECT_EQ(Common_Result::DATA_NOT_AVAILABLE, - (*command_msg_)[strings::params][am::hmi_response::code].asInt()); -} - -#ifdef EXTENDED_POLICY -TEST_F(GetUrlsTest, ProcessPolicyServiceURLs_SUCCESS) { - (*command_msg_)[am::strings::msg_params][am::hmi_request::service] = - kPolicyService; - - EXPECT_CALL(mock_policy_handler_, PolicyEnabled()).WillOnce(Return(true)); - - EndpointUrls endpoints_; - EndpointData data(kDefaultUrl); - endpoints_.push_back(data); - - EXPECT_CALL(mock_policy_handler_, GetUpdateUrls(kPolicyService, _)) - .WillOnce(SetArgReferee<1>(endpoints_)); - - MockAppPtr mock_app = CreateMockApp(); - - EXPECT_CALL(mock_policy_handler_, GetAppIdForSending()) - .WillOnce(Return(kAppIdForSending)); - - EXPECT_CALL(app_mngr_, application(kAppIdForSending)) - .WillOnce(Return(mock_app)); - EXPECT_CALL(*mock_app, app_id()).WillOnce(Return(kAppIdForSending)); - EXPECT_CALL(mock_rpc_service_, ManageHMICommand(command_msg_, _)) - .WillOnce(Return(true)); - - request_command_->Run(); - - EXPECT_FALSE((*command_msg_)[am::strings::msg_params].keyExists( - am::hmi_request::service)); - - EXPECT_EQ(am::MessageType::kResponse, - (*command_msg_)[strings::params][strings::message_type].asInt()); - EXPECT_EQ(Common_Result::SUCCESS, - (*command_msg_)[strings::params][am::hmi_response::code].asInt()); - - EXPECT_EQ(kAppIdForSending, - (*command_msg_)[am::strings::msg_params][am::hmi_response::urls][0] - [strings::app_id].asInt()); - EXPECT_EQ(kDefaultUrl, - (*command_msg_)[am::strings::msg_params][am::hmi_response::urls][0] - [strings::url].asString()); -} - -TEST_F(GetUrlsTest, ProcessPolicyServiceURLs_IncorrectIdForSending_UNSUCCESS) { - (*command_msg_)[am::strings::msg_params][am::hmi_request::service] = - kPolicyService; - - EXPECT_CALL(mock_policy_handler_, PolicyEnabled()).WillOnce(Return(true)); - - EndpointUrls endpoints_; - EndpointData data(kDefaultUrl); - endpoints_.push_back(data); - - EXPECT_CALL(mock_policy_handler_, GetUpdateUrls(kPolicyService, _)) - .WillOnce(SetArgReferee<1>(endpoints_)); - - EXPECT_CALL(mock_policy_handler_, GetAppIdForSending()) - .WillOnce(Return(kInvalidAppId_)); - - EXPECT_CALL(mock_rpc_service_, ManageHMICommand(command_msg_, _)) - .WillOnce(Return(true)); - - EXPECT_CALL(app_mngr_, application(kInvalidAppId_)).Times(0); - - request_command_->Run(); -} - -TEST_F(GetUrlsTest, ProcessPolicyServiceURLs_ApplicationIsNotValid_UNSUCCESS) { - (*command_msg_)[am::strings::msg_params][am::hmi_request::service] = - kPolicyService; - - EXPECT_CALL(mock_policy_handler_, PolicyEnabled()).WillOnce(Return(true)); - - EndpointUrls endpoints_; - EndpointData data(kDefaultUrl); - endpoints_.push_back(data); - - EXPECT_CALL(mock_policy_handler_, GetUpdateUrls(kPolicyService, _)) - .WillOnce(SetArgReferee<1>(endpoints_)); - - MockAppPtr invalid_mock_app; - - EXPECT_CALL(mock_policy_handler_, GetAppIdForSending()) - .WillOnce(Return(kAppIdForSending)); - - EXPECT_CALL(app_mngr_, application(kAppIdForSending)) - .WillOnce(Return(invalid_mock_app)); - - EXPECT_CALL(mock_rpc_service_, ManageHMICommand(command_msg_, _)) - .WillOnce(Return(true)); - - request_command_->Run(); - - EXPECT_EQ(am::MessageType::kResponse, - (*command_msg_)[strings::params][strings::message_type].asInt()); - EXPECT_EQ(Common_Result::DATA_NOT_AVAILABLE, - (*command_msg_)[strings::params][am::hmi_response::code].asInt()); -} - -TEST_F(GetUrlsTest, ProcessPolicyServiceURLs_FoundURLForApplication_SUCCESS) { - (*command_msg_)[am::strings::msg_params][am::hmi_request::service] = - kPolicyService; - - EXPECT_CALL(mock_policy_handler_, PolicyEnabled()).WillOnce(Return(true)); - - EndpointUrls endpoints_; - EndpointData data(kDefaultUrl); - data.app_id = kPolicyAppId; - endpoints_.push_back(data); - - EXPECT_CALL(mock_policy_handler_, GetUpdateUrls(kPolicyService, _)) - .WillOnce(SetArgReferee<1>(endpoints_)); - - MockAppPtr mock_app = CreateMockApp(); - - EXPECT_CALL(mock_policy_handler_, GetAppIdForSending()) - .WillOnce(Return(kAppIdForSending)); - - EXPECT_CALL(app_mngr_, application(kAppIdForSending)) - .WillOnce(Return(mock_app)); - - EXPECT_CALL(*mock_app, policy_app_id()).WillOnce(Return(kPolicyAppId)); - - EXPECT_CALL(mock_rpc_service_, ManageHMICommand(command_msg_, _)) - .WillOnce(Return(true)); - - request_command_->Run(); - - EXPECT_FALSE((*command_msg_)[am::strings::msg_params].keyExists( - am::hmi_request::service)); - - EXPECT_EQ(am::MessageType::kResponse, - (*command_msg_)[strings::params][strings::message_type].asInt()); - EXPECT_EQ(Common_Result::SUCCESS, - (*command_msg_)[strings::params][am::hmi_response::code].asInt()); -} -#endif - -TEST_F(GetUrlsTest, DISABLED_ProcessServiceURLs_SUCCESS) { - (*command_msg_)[am::strings::msg_params][am::hmi_response::urls][0] = - kDefaultUrl; - (*command_msg_)[am::strings::msg_params][am::hmi_response::urls][0] - [am::hmi_response::policy_app_id] = "1"; - - EXPECT_CALL(mock_policy_handler_, PolicyEnabled()).WillOnce(Return(true)); - - EndpointUrls endpoints_; - EndpointData data(kDefaultUrl); - data.app_id = "1"; - endpoints_.push_back(data); - EXPECT_CALL(mock_policy_handler_, GetUpdateUrls(kServiceType, _)) - .WillOnce(SetArgReferee<1>(endpoints_)); - - request_command_->Run(); - - EXPECT_FALSE((*command_msg_)[am::strings::msg_params].keyExists( - am::hmi_request::service)); - EXPECT_EQ(kDefaultUrl, - (*command_msg_)[am::strings::msg_params][am::hmi_response::urls][0] - [am::strings::url].asString()); - EXPECT_EQ(endpoints_[0].app_id, - (*command_msg_)[am::strings::msg_params][am::hmi_response::urls][0] - [am::hmi_response::policy_app_id].asString()); -} - -TEST_F(GetUrlsTest, ProcessServiceURLs_PolicyDefaultId_SUCCESS) { - (*command_msg_)[am::strings::msg_params][am::hmi_response::urls][0] = - kDefaultUrl; - (*command_msg_)[am::strings::msg_params][am::hmi_response::urls][0] - [am::hmi_response::policy_app_id] = kDefaultId; - - EXPECT_CALL(mock_policy_handler_, PolicyEnabled()).WillOnce(Return(true)); - EndpointUrls endpoints_; - EndpointData data(kDefaultUrl); - endpoints_.push_back(data); - EXPECT_CALL(mock_policy_handler_, GetUpdateUrls(kServiceType, _)) - .WillOnce(SetArgReferee<1>(endpoints_)); - MockAppPtr mock_app = CreateMockApp(); - EXPECT_CALL(app_mngr_, application_by_policy_id(_)) - .WillOnce(Return(mock_app)); - request_command_->Run(); - - EXPECT_FALSE((*command_msg_)[am::strings::msg_params].keyExists( - am::hmi_request::service)); - EXPECT_TRUE( - (*command_msg_)[am::strings::msg_params][am::hmi_response::urls][0] - .keyExists(am::hmi_response::policy_app_id)); -} - -} // namespace get_urls -} // namespace hmi_commands_test -} // namespace commands_test -} // namespace components -} // 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 ca322ea4253..26f7a63872c 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 @@ -33,81 +33,81 @@ #include #include #include -#include "gtest/gtest.h" #include "application_manager/commands/commands_test.h" -#include "sdl_rpc_plugin/commands/hmi/on_button_event_notification.h" -#include "sdl_rpc_plugin/commands/hmi/on_navi_tbt_client_state_notification.h" -#include "sdl_rpc_plugin/commands/hmi/on_navi_way_point_change_notification.h" -#include "sdl_rpc_plugin/commands/hmi/on_ui_command_notification.h" -#include "sdl_rpc_plugin/commands/hmi/on_ui_keyboard_input_notification.h" -#include "sdl_rpc_plugin/commands/hmi/on_ui_touch_event_notification.h" +#include "gtest/gtest.h" +#include "sdl_rpc_plugin/commands/hmi/on_allow_sdl_functionality_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_app_activated_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_app_deactivated_notification.h" #include "sdl_rpc_plugin/commands/hmi/on_app_permission_changed_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_app_permission_consent_notification.h" #include "sdl_rpc_plugin/commands/hmi/on_app_registered_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_app_unregistered_notification.h" #include "sdl_rpc_plugin/commands/hmi/on_audio_data_streaming_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_button_event_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_button_press_notification.h" #include "sdl_rpc_plugin/commands/hmi/on_button_subscription_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_device_chosen_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_device_state_changed_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_driver_distraction_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_event_changed_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_exit_all_applications_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_exit_application_notification.h" #include "sdl_rpc_plugin/commands/hmi/on_file_removed_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_ignition_cycle_over_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_navi_tbt_client_state_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_navi_way_point_change_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_policy_update.h" #include "sdl_rpc_plugin/commands/hmi/on_put_file_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_ready_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_received_policy_update.h" +#include "sdl_rpc_plugin/commands/hmi/on_record_start_notification.h" #include "sdl_rpc_plugin/commands/hmi/on_resume_audio_source_notification.h" #include "sdl_rpc_plugin/commands/hmi/on_sdl_close_notification.h" #include "sdl_rpc_plugin/commands/hmi/on_sdl_consent_needed_notification.h" #include "sdl_rpc_plugin/commands/hmi/on_sdl_persistence_complete_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_start_device_discovery.h" #include "sdl_rpc_plugin/commands/hmi/on_status_update_notification.h" -#include "sdl_rpc_plugin/commands/hmi/on_video_data_streaming_notification.h" -#include "sdl_rpc_plugin/commands/hmi/on_record_start_notification.h" -#include "sdl_rpc_plugin/commands/hmi/on_app_activated_notification.h" -#include "sdl_rpc_plugin/commands/hmi/on_app_deactivated_notification.h" -#include "sdl_rpc_plugin/commands/hmi/on_app_unregistered_notification.h" -#include "sdl_rpc_plugin/commands/hmi/on_button_press_notification.h" -#include "sdl_rpc_plugin/commands/hmi/on_event_changed_notification.h" -#include "sdl_rpc_plugin/commands/hmi/on_ready_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_system_context_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_system_error_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_system_info_changed_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_system_request_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_tts_language_change_notification.h" #include "sdl_rpc_plugin/commands/hmi/on_tts_reset_timeout_notification.h" #include "sdl_rpc_plugin/commands/hmi/on_tts_started_notification.h" #include "sdl_rpc_plugin/commands/hmi/on_tts_stopped_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_ui_command_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_ui_keyboard_input_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_ui_language_change_notification.h" #include "sdl_rpc_plugin/commands/hmi/on_ui_reset_timeout_notification.h" -#include "sdl_rpc_plugin/commands/hmi/on_vr_started_notification.h" -#include "sdl_rpc_plugin/commands/hmi/on_vr_stopped_notification.h" -#include "sdl_rpc_plugin/commands/hmi/on_app_permission_consent_notification.h" -#include "sdl_rpc_plugin/commands/hmi/on_ignition_cycle_over_notification.h" -#include "sdl_rpc_plugin/commands/hmi/on_policy_update.h" -#include "sdl_rpc_plugin/commands/hmi/on_received_policy_update.h" -#include "sdl_rpc_plugin/commands/hmi/on_system_error_notification.h" -#include "sdl_rpc_plugin/commands/hmi/on_system_info_changed_notification.h" -#include "sdl_rpc_plugin/commands/hmi/on_allow_sdl_functionality_notification.h" -#include "sdl_rpc_plugin/commands/hmi/on_device_state_changed_notification.h" -#include "sdl_rpc_plugin/commands/hmi/on_exit_all_applications_notification.h" -#include "sdl_rpc_plugin/commands/hmi/on_exit_application_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_ui_touch_event_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_video_data_streaming_notification.h" #include "sdl_rpc_plugin/commands/hmi/on_vr_command_notification.h" #include "sdl_rpc_plugin/commands/hmi/on_vr_language_change_notification.h" -#include "sdl_rpc_plugin/commands/hmi/on_start_device_discovery.h" -#include "sdl_rpc_plugin/commands/hmi/on_device_chosen_notification.h" -#include "sdl_rpc_plugin/commands/hmi/on_system_context_notification.h" -#include "sdl_rpc_plugin/commands/hmi/on_system_request_notification.h" -#include "sdl_rpc_plugin/commands/hmi/on_tts_language_change_notification.h" -#include "sdl_rpc_plugin/commands/hmi/on_ui_language_change_notification.h" -#include "sdl_rpc_plugin/commands/hmi/on_driver_distraction_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_vr_started_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_vr_stopped_notification.h" -#include "utils/lock.h" #include "utils/data_accessor.h" +#include "utils/lock.h" #include "utils/signals.h" -#include "utils/file_system.h" -#include "smart_objects/smart_object.h" -#include "application_manager/smart_object_keys.h" -#include "application_manager/mock_application_manager.h" -#include "application_manager/mock_rpc_plugin_manager.h" -#include "application_manager/mock_state_controller.h" +#include "application_manager/hmi_capabilities_impl.h" #include "application_manager/mock_application.h" +#include "application_manager/mock_application_manager.h" #include "application_manager/mock_event_dispatcher.h" -#include "application_manager/hmi_capabilities_impl.h" #include "application_manager/mock_hmi_capabilities.h" -#include "transport_manager/mock_transport_manager.h" +#include "application_manager/mock_message_helper.h" +#include "application_manager/mock_resume_ctrl.h" +#include "application_manager/mock_rpc_plugin_manager.h" +#include "application_manager/mock_state_controller.h" +#include "application_manager/policies/mock_policy_handler_interface.h" +#include "application_manager/smart_object_keys.h" #include "connection_handler/mock_connection_handler.h" #include "connection_handler/mock_connection_handler_settings.h" -#include "test/application_manager/mock_application_manager_settings.h" -#include "application_manager/policies/mock_policy_handler_interface.h" -#include "application_manager/mock_message_helper.h" #include "protocol_handler/mock_session_observer.h" -#include "application_manager/mock_resume_ctrl.h" +#include "smart_objects/smart_object.h" +#include "test/application_manager/mock_application_manager_settings.h" +#include "transport_manager/mock_transport_manager.h" +#include "utils/file_system.h" namespace am = application_manager; @@ -117,22 +117,22 @@ namespace commands_test { namespace hmi_commands_test { namespace hmi_notifications_test { -using ::testing::_; -using ::testing::Test; -using ::testing::Types; -using ::testing::Return; -using ::testing::ReturnRef; -using ::testing::NiceMock; -using ::testing::InSequence; -using ::smart_objects::SmartObject; +using ::application_manager::ApplicationSharedPtr; +using ::application_manager::MockMessageHelper; using ::application_manager::commands::MessageSharedPtr; +using ::smart_objects::SmartObject; +using ::test::components::application_manager_test::MockApplication; using ::test::components::application_manager_test::MockApplicationManager; using ::test::components::application_manager_test:: MockApplicationManagerSettings; -using ::application_manager::ApplicationSharedPtr; -using ::test::components::application_manager_test::MockApplication; using ::test::components::event_engine_test::MockEventDispatcher; -using ::application_manager::MockMessageHelper; +using ::testing::_; +using ::testing::InSequence; +using ::testing::NiceMock; +using ::testing::Return; +using ::testing::ReturnRef; +using ::testing::Test; +using ::testing::Types; using namespace sdl_rpc_plugin::commands; using namespace am::commands; @@ -148,6 +148,11 @@ typedef NiceMock< #define NAVI true #define NOT_NAVI false +namespace { +const am::WindowID kDefaultWindowId = + mobile_apis::PredefinedWindows::DEFAULT_WINDOW; +} + ACTION_P(GetEventId, event_id) { *event_id = arg0.id(); } @@ -155,8 +160,8 @@ ACTION_P(GetArg, arg) { *arg = arg0; } -ACTION_P(GetArg3, result) { - arg3 = *result; +ACTION_P(GetArg4, result) { + arg4 = *result; } ACTION_P2(GetConnectIdPermissionConsent, connect_id, consent) { @@ -192,6 +197,14 @@ const int32_t kMobileProtocolType_ = 0; const int32_t kProtocolVersion_ = 3; const uint32_t kCorrelationId_ = 1939u; const uint32_t kAppId_ = 2014u; +const std::string kDefaultLanguage = "en-us"; +const mobile_apis::Language::eType kMobileLanguage = + mobile_apis::Language::EN_US; + +// LSDW - lock screen dismissal warning +const std::string kLockScreenDismissalWarningMessage_en = + "Swipe down to dismiss, acknowledging that you are not the driver"; +const uint32_t kConnectionKey = 2u; } // namespace class HMICommandsNotificationsTest @@ -240,6 +253,9 @@ class HMICommandsNotificationsTest .WillByDefault(ReturnRef(mock_event_dispatcher_)); ON_CALL(app_mngr_, application_by_hmi_app(_)).WillByDefault(Return(app_)); ON_CALL(*app_ptr_, app_id()).WillByDefault(Return(kAppId_)); + ON_CALL(app_mngr_, application(kConnectionKey)).WillByDefault(Return(app_)); + ON_CALL(mock_message_helper_, MobileLanguageToString(kMobileLanguage)) + .WillByDefault(Return(kDefaultLanguage)); } am::ApplicationSharedPtr ConfigureApp(NiceMock** app_mock, @@ -259,6 +275,8 @@ class HMICommandsNotificationsTest .WillByDefault(Return(vc)); ON_CALL(**app_mock, IsAudioApplication()) .WillByDefault(Return(media || navi || vc)); + ON_CALL(**app_mock, ui_language()) + .WillByDefault(ReturnRef(kMobileLanguage)); return app; } #if defined(OS_POSIX) @@ -319,7 +337,8 @@ typedef Types HMIOnNotificationsListToHMITypes; + OnRecordStartdNotification> + HMIOnNotificationsListToHMITypes; typedef Types< CommandPairRun(); } @@ -1135,7 +1151,8 @@ TEST_F(HMICommandsNotificationsTest, EXPECT_CALL(app_mngr_, state_controller()) .WillOnce(ReturnRef(mock_state_controller_)); EXPECT_CALL(mock_state_controller_, - SetRegularState(_, mobile_apis::HMILevel::HMI_FULL, true)); + SetRegularState( + _, kDefaultWindowId, mobile_apis::HMILevel::HMI_FULL, true)); EXPECT_CALL(app_mngr_, get_settings()) .WillOnce(ReturnRef(app_mngr_settings_)); @@ -1336,8 +1353,10 @@ TEST_F(HMICommandsNotificationsTest, EXPECT_CALL(*app_ptr_, language()).WillRepeatedly(ReturnRef(kLang)); EXPECT_CALL(app_mngr_, state_controller()) .WillOnce(ReturnRef(mock_state_controller_)); - EXPECT_CALL(mock_state_controller_, - SetRegularState(app_, mobile_apis::HMILevel::HMI_NONE, false)); + EXPECT_CALL( + mock_state_controller_, + SetRegularState( + app_, kDefaultWindowId, mobile_apis::HMILevel::HMI_NONE, false)); EXPECT_CALL(mock_message_helper_, GetOnAppInterfaceUnregisteredNotificationToMobile( kAppId_, @@ -1377,10 +1396,11 @@ TEST_F(HMICommandsNotificationsTest, [am::strings::id] = "2014"; std::shared_ptr command = CreateCommand(message); - EXPECT_CALL(app_mngr_, - ConnectToDevice( - (*message)[am::strings::msg_params][am::strings::device_info] - [am::strings::id].asString())); + EXPECT_CALL( + app_mngr_, + ConnectToDevice((*message)[am::strings::msg_params] + [am::strings::device_info][am::strings::id] + .asString())); command->Run(); } @@ -1413,7 +1433,8 @@ TEST_F(HMICommandsNotificationsTest, EXPECT_CALL(app_mngr_, active_application()).WillOnce(Return(app_)); EXPECT_CALL(app_mngr_, state_controller()) .WillOnce(ReturnRef(mock_state_controller_)); - EXPECT_CALL(mock_state_controller_, SetRegularState(app_, *it)); + EXPECT_CALL(mock_state_controller_, + SetRegularState(app_, kDefaultWindowId, *it)); command->Run(); } } @@ -1462,7 +1483,8 @@ TEST_F(HMICommandsNotificationsTest, EXPECT_CALL(app_mngr_, application(_)).WillOnce(Return(app_)); EXPECT_CALL(app_mngr_, state_controller()) .WillOnce(ReturnRef(mock_state_controller_)); - EXPECT_CALL(mock_state_controller_, SetRegularState(app_, *it)); + EXPECT_CALL(mock_state_controller_, + SetRegularState(app_, kDefaultWindowId, *it)); command->Run(); } } @@ -1790,11 +1812,26 @@ TEST_F(HMICommandsNotificationsTest, OnDriverDistractionNotificationEmptyData) { hmi_apis::Common_DriverDistractionState::DD_ON; MessageSharedPtr message = CreateMessage(); (*message)[am::strings::msg_params][am::hmi_notification::state] = state; + (*message)[am::strings::params][am::strings::connection_key] = kConnectionKey; std::shared_ptr command = CreateCommand(message); EXPECT_CALL(app_mngr_, set_driver_distraction_state(state)); - EXPECT_CALL(app_mngr_, applications()).WillOnce(Return(applications_)); + + ON_CALL(app_mngr_, GetPolicyHandler()) + .WillByDefault(ReturnRef(mock_policy_handler_)); + typedef boost::optional OptionalBool; + + ON_CALL(mock_policy_handler_, LockScreenDismissalEnabledState()) + .WillByDefault(Return(OptionalBool(true))); + std::string required_language = "en-us"; + ON_CALL(mock_policy_handler_, + LockScreenDismissalWarningMessage(required_language)) + .WillByDefault(Return( + boost::optional(kLockScreenDismissalWarningMessage_en))); + + ON_CALL(app_mngr_, applications()).WillByDefault(Return(applications_)); + EXPECT_CALL(mock_rpc_service_, ManageMobileCommand(_, _)).Times(0); EXPECT_CALL(*app_ptr_, app_id()).Times(0); command->Run(); @@ -1802,16 +1839,28 @@ TEST_F(HMICommandsNotificationsTest, OnDriverDistractionNotificationEmptyData) { TEST_F(HMICommandsNotificationsTest, OnDriverDistractionNotificationInvalidApp) { - const hmi_apis::Common_DriverDistractionState::eType state = - hmi_apis::Common_DriverDistractionState::DD_ON; + const auto state = hmi_apis::Common_DriverDistractionState::DD_ON; MessageSharedPtr message = CreateMessage(); (*message)[am::strings::msg_params][am::hmi_notification::state] = state; + (*message)[am::strings::params][am::strings::connection_key] = kConnectionKey; std::shared_ptr command = CreateCommand(message); ApplicationSharedPtr invalid_app; application_set_.insert(invalid_app); - EXPECT_CALL(app_mngr_, applications()).WillOnce(Return(applications_)); + + ON_CALL(app_mngr_, GetPolicyHandler()) + .WillByDefault(ReturnRef(mock_policy_handler_)); + typedef boost::optional OptionalBool; + ON_CALL(mock_policy_handler_, LockScreenDismissalEnabledState()) + .WillByDefault(Return(OptionalBool(true))); + std::string required_language = "en-us"; + ON_CALL(mock_policy_handler_, + LockScreenDismissalWarningMessage(required_language)) + .WillByDefault(Return( + boost::optional(kLockScreenDismissalWarningMessage_en))); + ON_CALL(app_mngr_, applications()).WillByDefault(Return(applications_)); + EXPECT_CALL(mock_rpc_service_, ManageMobileCommand(_, _)).Times(0); EXPECT_CALL(*app_ptr_, app_id()).Times(0); command->Run(); @@ -1822,21 +1871,33 @@ TEST_F(HMICommandsNotificationsTest, OnDriverDistractionNotificationValidApp) { hmi_apis::Common_DriverDistractionState::DD_ON; MessageSharedPtr message = CreateMessage(); (*message)[am::strings::msg_params][am::mobile_notification::state] = state; + (*message)[am::strings::params][am::strings::connection_key] = kConnectionKey; std::shared_ptr command = CreateCommand(message); application_set_.insert(app_); - EXPECT_CALL(app_mngr_, applications()).WillOnce(Return(applications_)); + + ON_CALL(app_mngr_, GetPolicyHandler()) + .WillByDefault(ReturnRef(mock_policy_handler_)); + typedef boost::optional OptionalBool; + ON_CALL(mock_policy_handler_, LockScreenDismissalEnabledState()) + .WillByDefault(Return(OptionalBool(true))); + std::string required_language = "en-us"; + ON_CALL(mock_policy_handler_, + LockScreenDismissalWarningMessage(required_language)) + .WillByDefault(Return( + boost::optional(kLockScreenDismissalWarningMessage_en))); + ON_CALL(app_mngr_, applications()).WillByDefault(Return(applications_)); + policy::CheckPermissionResult result; result.hmi_level_permitted = policy::kRpcAllowed; - EXPECT_CALL(app_mngr_, GetPolicyHandler()) - .WillOnce(ReturnRef(mock_policy_handler_)); - EXPECT_CALL(mock_policy_handler_, CheckPermissions(_, _, _, _)) - .WillOnce(GetArg3(&result)); + EXPECT_CALL(mock_policy_handler_, CheckPermissions(_, _, _, _, _)) + .WillOnce(GetArg4(&result)); + EXPECT_CALL(mock_rpc_service_, ManageMobileCommand(_, Command::CommandSource::SOURCE_SDL)) .WillOnce(GetMessage(message)); - EXPECT_CALL(*app_ptr_, app_id()).WillRepeatedly(Return(kAppId_)); + ON_CALL(*app_ptr_, app_id()).WillByDefault(Return(kAppId_)); command->Run(); EXPECT_EQ( diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/mixing_audio_supported_request_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/mixing_audio_supported_request_test.cc index 8164f957cb7..64bf167f83c 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/mixing_audio_supported_request_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/mixing_audio_supported_request_test.cc @@ -33,13 +33,13 @@ #include #include -#include "gtest/gtest.h" -#include "smart_objects/smart_object.h" -#include "application_manager/smart_object_keys.h" -#include "application_manager/commands/commands_test.h" #include "application_manager/commands/command_request_test.h" +#include "application_manager/commands/commands_test.h" #include "application_manager/commands/request_to_hmi.h" +#include "application_manager/smart_object_keys.h" +#include "gtest/gtest.h" #include "hmi/mixing_audio_supported_request.h" +#include "smart_objects/smart_object.h" namespace test { namespace components { @@ -51,9 +51,9 @@ using ::testing::_; using ::testing::Return; namespace am = ::application_manager; namespace strings = ::application_manager::strings; +using am::commands::CommandImpl; using am::commands::RequestToHMI; using sdl_rpc_plugin::commands::MixingAudioSupportedRequest; -using am::commands::CommandImpl; typedef std::shared_ptr RequestToHMIPtr; diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/mixing_audio_supported_response_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/mixing_audio_supported_response_test.cc index aa651c2dca5..8c2f07a1d6f 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/mixing_audio_supported_response_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/mixing_audio_supported_response_test.cc @@ -33,18 +33,18 @@ #include #include -#include "gtest/gtest.h" -#include "smart_objects/smart_object.h" -#include "application_manager/smart_object_keys.h" #include "application_manager/commands/command.h" -#include "application_manager/commands/commands_test.h" #include "application_manager/commands/command_request_test.h" +#include "application_manager/commands/commands_test.h" #include "application_manager/commands/response_from_hmi.h" -#include "interfaces/HMI_API.h" -#include "interfaces/MOBILE_API.h" #include "application_manager/mock_application.h" #include "application_manager/mock_hmi_capabilities.h" +#include "application_manager/smart_object_keys.h" +#include "gtest/gtest.h" +#include "interfaces/HMI_API.h" +#include "interfaces/MOBILE_API.h" #include "sdl_rpc_plugin/commands/hmi/mixing_audio_supported_response.h" +#include "smart_objects/smart_object.h" namespace test { namespace components { @@ -52,15 +52,15 @@ namespace commands_test { namespace hmi_commands_test { namespace mixing_audio_supported_response { +using ::testing::NiceMock; using ::testing::Return; using ::testing::ReturnRef; -using ::testing::NiceMock; namespace am = ::application_manager; namespace strings = ::application_manager::strings; -using sdl_rpc_plugin::commands::MixingAudioSupportedResponse; -using application_manager::commands::ResponseFromHMI; -using am::commands::CommandImpl; using am::HMICapabilities; +using am::commands::CommandImpl; +using application_manager::commands::ResponseFromHMI; +using sdl_rpc_plugin::commands::MixingAudioSupportedResponse; namespace hmi_response = ::application_manager::hmi_response; typedef std::shared_ptr ResponseFromHMIPtr; diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/navi_audio_start_stream_request_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/navi_audio_start_stream_request_test.cc index d8454bb98e4..926e51446fe 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/navi_audio_start_stream_request_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/navi_audio_start_stream_request_test.cc @@ -36,13 +36,13 @@ #include "gtest/gtest.h" -#include "smart_objects/smart_object.h" -#include "application_manager/smart_object_keys.h" #include "application_manager/commands/command_request_test.h" -#include "application_manager/mock_application_manager.h" +#include "application_manager/commands/commands_test.h" #include "application_manager/hmi_interfaces.h" +#include "application_manager/mock_application_manager.h" #include "application_manager/mock_hmi_interface.h" -#include "application_manager/commands/commands_test.h" +#include "application_manager/smart_object_keys.h" +#include "smart_objects/smart_object.h" namespace test { namespace components { @@ -54,9 +54,9 @@ using ::testing::_; using ::testing::ReturnRef; namespace am = ::application_manager; namespace commands = am::commands; +using am::event_engine::Event; using commands::MessageSharedPtr; using sdl_rpc_plugin::commands::AudioStartStreamRequest; -using am::event_engine::Event; namespace { const uint32_t kHmiAppId = 13u; diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/navi_is_ready_request_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/navi_is_ready_request_test.cc index 1a03ecf5237..5e13755a325 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/navi_is_ready_request_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/navi_is_ready_request_test.cc @@ -34,15 +34,15 @@ #include "gtest/gtest.h" -#include "smart_objects/smart_object.h" -#include "application_manager/smart_object_keys.h" #include "application_manager/commands/command_request_test.h" -#include "application_manager/mock_application_manager.h" -#include "application_manager/hmi_interfaces.h" +#include "application_manager/commands/commands_test.h" #include "application_manager/event_engine/event.h" -#include "application_manager/mock_hmi_interface.h" +#include "application_manager/hmi_interfaces.h" +#include "application_manager/mock_application_manager.h" #include "application_manager/mock_hmi_capabilities.h" -#include "application_manager/commands/commands_test.h" +#include "application_manager/mock_hmi_interface.h" +#include "application_manager/smart_object_keys.h" +#include "smart_objects/smart_object.h" namespace test { namespace components { @@ -54,8 +54,8 @@ using ::testing::_; using ::testing::ReturnRef; namespace am = ::application_manager; using am::commands::MessageSharedPtr; -using sdl_rpc_plugin::commands::NaviIsReadyRequest; using am::event_engine::Event; +using sdl_rpc_plugin::commands::NaviIsReadyRequest; namespace { const hmi_apis::FunctionID::eType kEventID = diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/navi_is_ready_response_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/navi_is_ready_response_test.cc index 23f01fac3fd..e166928348f 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/navi_is_ready_response_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/navi_is_ready_response_test.cc @@ -33,12 +33,12 @@ #include #include -#include "gtest/gtest.h" -#include "application_manager/commands/commands_test.h" #include "application_manager/commands/command_request_test.h" -#include "application_manager/mock_hmi_capabilities.h" +#include "application_manager/commands/commands_test.h" #include "application_manager/mock_application_manager.h" #include "application_manager/mock_event_dispatcher.h" +#include "application_manager/mock_hmi_capabilities.h" +#include "gtest/gtest.h" #include "hmi/navi_is_ready_response.h" namespace test { diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/navi_set_video_config_request_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/navi_set_video_config_request_test.cc index 3110a11fd8d..d6ef540bc0f 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/navi_set_video_config_request_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/navi_set_video_config_request_test.cc @@ -36,14 +36,14 @@ #include "gtest/gtest.h" -#include "smart_objects/smart_object.h" -#include "application_manager/smart_object_keys.h" #include "application_manager/commands/command_request_test.h" -#include "application_manager/mock_application_manager.h" -#include "application_manager/hmi_interfaces.h" -#include "application_manager/mock_hmi_interface.h" #include "application_manager/event_engine/event.h" +#include "application_manager/hmi_interfaces.h" +#include "application_manager/mock_application_manager.h" #include "application_manager/mock_event_dispatcher.h" +#include "application_manager/mock_hmi_interface.h" +#include "application_manager/smart_object_keys.h" +#include "smart_objects/smart_object.h" namespace test { namespace components { @@ -55,8 +55,8 @@ using ::testing::_; using ::testing::ReturnRef; namespace am = ::application_manager; using am::commands::MessageSharedPtr; -using sdl_rpc_plugin::commands::NaviSetVideoConfigRequest; using am::event_engine::Event; +using sdl_rpc_plugin::commands::NaviSetVideoConfigRequest; namespace { const uint32_t kAppId = 1u; diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/navi_set_video_config_response_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/navi_set_video_config_response_test.cc index 06fa61db296..c4e7976bde4 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/navi_set_video_config_response_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/navi_set_video_config_response_test.cc @@ -30,13 +30,13 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include "gtest/gtest.h" -#include "application_manager/commands/commands_test.h" #include "hmi/navi_set_video_config_response.h" +#include "application_manager/commands/commands_test.h" #include "application_manager/mock_application_manager.h" #include "application_manager/mock_event_dispatcher.h" #include "application_manager/mock_hmi_capabilities.h" #include "application_manager/smart_object_keys.h" +#include "gtest/gtest.h" namespace test { namespace components { @@ -47,8 +47,8 @@ namespace navi_set_video_config_response { using sdl_rpc_plugin::commands::NaviSetVideoConfigResponse; using test::components::event_engine_test::MockEventDispatcher; using testing::_; -using testing::ReturnRef; using ::testing::NiceMock; +using testing::ReturnRef; typedef NiceMock< ::test::components::application_manager_test::MockHMICapabilities> diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/navi_start_stream_request_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/navi_start_stream_request_test.cc index a7f50504fb8..232d5ab6281 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/navi_start_stream_request_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/navi_start_stream_request_test.cc @@ -36,12 +36,12 @@ #include "gtest/gtest.h" -#include "smart_objects/smart_object.h" -#include "application_manager/smart_object_keys.h" #include "application_manager/commands/command_request_test.h" -#include "application_manager/mock_application_manager.h" #include "application_manager/hmi_interfaces.h" +#include "application_manager/mock_application_manager.h" #include "application_manager/mock_hmi_interface.h" +#include "application_manager/smart_object_keys.h" +#include "smart_objects/smart_object.h" namespace test { namespace components { @@ -53,9 +53,9 @@ using ::testing::_; using ::testing::ReturnRef; namespace am = ::application_manager; namespace commands = am::commands; +using am::event_engine::Event; using commands::MessageSharedPtr; using sdl_rpc_plugin::commands::NaviStartStreamRequest; -using am::event_engine::Event; namespace { const uint32_t kHmiAppId = 13u; diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/navi_stop_stream_requests_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/navi_stop_stream_requests_test.cc index e4a79997fdc..b32189ce1af 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/navi_stop_stream_requests_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/navi_stop_stream_requests_test.cc @@ -30,17 +30,17 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include "hmi/navi_stop_stream_request.h" #include "hmi/navi_audio_stop_stream_request.h" +#include "hmi/navi_stop_stream_request.h" #include "gtest/gtest.h" -#include "smart_objects/smart_object.h" -#include "application_manager/smart_object_keys.h" #include "application_manager/commands/command_request_test.h" -#include "application_manager/mock_application_manager.h" #include "application_manager/hmi_interfaces.h" +#include "application_manager/mock_application_manager.h" #include "application_manager/mock_hmi_interface.h" +#include "application_manager/smart_object_keys.h" +#include "smart_objects/smart_object.h" namespace test { namespace components { @@ -76,7 +76,8 @@ class NaviStopStreamRequestsTest }; typedef testing::Types RequestCommandsList; + commands::NaviStopStreamRequest> + RequestCommandsList; TYPED_TEST_CASE(NaviStopStreamRequestsTest, RequestCommandsList); TYPED_TEST(NaviStopStreamRequestsTest, Run_HmiInterfaceNotAvailable_NoRequest) { diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/on_bc_system_capability_updated_notification_from_hmi_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/on_bc_system_capability_updated_notification_from_hmi_test.cc new file mode 100644 index 00000000000..f3ed4801805 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/on_bc_system_capability_updated_notification_from_hmi_test.cc @@ -0,0 +1,159 @@ +/* + * Copyright (c) 2019, 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 "hmi/on_bc_system_capability_updated_notification_from_hmi.h" + +#include "application_manager/commands/commands_test.h" +#include "gtest/gtest.h" + +namespace test { +namespace components { +namespace commands_test { +namespace hmi_commands_test { +namespace on_bc_system_capability_updated_notification_from_hmi { + +using sdl_rpc_plugin::commands::OnBCSystemCapabilityUpdatedNotificationFromHMI; +using ::testing::_; +using ::testing::Return; + +typedef std::shared_ptr + OnBCSystemCapabilityUpdatedNotificationFromHMIPtr; + +namespace strings = application_manager::strings; +namespace { +const uint32_t kAppId = 1u; +} // namespace + +MATCHER(CheckMessageToMobile, "") { + const auto function_id = mobile_apis::FunctionID::OnSystemCapabilityUpdatedID; + + const bool is_function_id_matched = + function_id == static_cast( + (*arg)[strings::params][strings::function_id].asInt()); + const bool app_id_exist = + (*arg)[strings::msg_params].keyExists(strings::app_id); + bool is_connection_key_correct = true; + if ((*arg)[strings::msg_params].keyExists(strings::connection_key)) { + is_connection_key_correct = + (*arg)[strings::params][strings::connection_key] == kAppId; + } + return is_function_id_matched && !app_id_exist && is_connection_key_correct; +} + +MATCHER_P(CheckDisplayCapabilitiesNotChanged, display_capability, "") { + return display_capability == arg; +} + +class OnBCSystemCapabilityUpdatedNotificationFromHMITest + : public CommandsTest { + protected: + OnBCSystemCapabilityUpdatedNotificationFromHMITest() + : message_(CreateMessage()) + , display_capability_( + (*message_)[am::strings::msg_params][strings::system_capability] + [strings::display_capabilities]) { + command_ = + CreateCommand(message_); + mock_app_ = CreateMockApp(); + } + + OnBCSystemCapabilityUpdatedNotificationFromHMIPtr command_; + MockAppPtr mock_app_; + MessageSharedPtr message_; + const SmartObject display_capability_; +}; + +TEST_F( + OnBCSystemCapabilityUpdatedNotificationFromHMITest, + Run_AppIdNotPresentedInMessage_SetSystemDisplayCapabilitiesToHMICapabilities_SendMessageToMobile) { + (*message_)[am::strings::msg_params][strings::system_capability] + [am::strings::system_capability_type] = + mobile_apis::SystemCapabilityType::DISPLAYS; + + EXPECT_CALL(mock_hmi_capabilities_, + set_system_display_capabilities( + CheckDisplayCapabilitiesNotChanged(display_capability_))); + EXPECT_CALL( + mock_rpc_service_, + ManageMobileCommand( + CheckMessageToMobile(), + ::application_manager::commands::Command::CommandSource::SOURCE_SDL)) + .WillOnce(Return(true)); + + ASSERT_TRUE(command_->Init()); + command_->Run(); +} + +TEST_F(OnBCSystemCapabilityUpdatedNotificationFromHMITest, + Run_AppNotRegisteredWithPresentedAppIdInMessage_MessageNotSendToMobile) { + (*message_)[am::strings::msg_params][strings::system_capability] + [am::strings::system_capability_type] = + mobile_apis::SystemCapabilityType::DISPLAYS; + (*message_)[strings::msg_params][strings::app_id] = kAppId; + ApplicationSharedPtr app; // Empty application shared pointer + + ON_CALL(app_mngr_, application(kAppId)).WillByDefault(Return(app)); + EXPECT_CALL(mock_rpc_service_, ManageMobileCommand(_, _)).Times(0); + + ASSERT_TRUE(command_->Init()); + command_->Run(); +} + +TEST_F( + OnBCSystemCapabilityUpdatedNotificationFromHMITest, + Run_AppRegisteredWithPresentedAppIdInMessage_SetDisplayCapabilitiesToApp_SendMessageToMobile) { + (*message_)[am::strings::msg_params][strings::system_capability] + [am::strings::system_capability_type] = + mobile_apis::SystemCapabilityType::DISPLAYS; + (*message_)[strings::msg_params][strings::app_id] = kAppId; + + ON_CALL(app_mngr_, application(kAppId)).WillByDefault(Return(mock_app_)); + + EXPECT_CALL(*mock_app_, + set_display_capabilities( + CheckDisplayCapabilitiesNotChanged(display_capability_))); + EXPECT_CALL( + mock_rpc_service_, + ManageMobileCommand( + CheckMessageToMobile(), + ::application_manager::commands::Command::CommandSource::SOURCE_SDL)) + .WillOnce(Return(true)); + + ASSERT_TRUE(command_->Init()); + command_->Run(); +} + +} // namespace on_bc_system_capability_updated_notification_from_hmi +} // namespace hmi_commands_test +} // namespace commands_test +} // namespace components +} // namespace test diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/on_bc_system_capability_updated_notification_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/on_bc_system_capability_updated_notification_test.cc new file mode 100644 index 00000000000..cb8894749f0 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/on_bc_system_capability_updated_notification_test.cc @@ -0,0 +1,118 @@ +/* + * Copyright (c) 2019, 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 "hmi/on_bc_system_capability_updated_notification.h" + +#include "application_manager/commands/commands_test.h" +#include "gtest/gtest.h" + +namespace test { +namespace components { +namespace commands_test { +namespace hmi_commands_test { +namespace on_bc_system_capability_updated_notification { + +using sdl_rpc_plugin::commands::OnBCSystemCapabilityUpdatedNotification; +using ::testing::_; +using ::testing::Return; + +typedef std::shared_ptr + OnBCSystemCapabilityUpdatedNotificationPtr; + +namespace strings = application_manager::strings; +namespace { +const uint32_t kConnectionKey = 1u; +} + +MATCHER_P(CheckDisplayCapabilities, display_capabilities, "") { + return display_capabilities == + (*arg)[strings::msg_params][strings::system_capability] + [strings::display_capabilities]; +} + +class OnBCSystemCapabilityUpdatedNotificationTest + : public CommandsTest { + protected: + void SetUp() OVERRIDE { + message_ = CreateMessage(); + (*message_)[strings::params][strings::connection_key] = kConnectionKey; + + command_ = CreateCommand(message_); + mock_app_ = CreateMockApp(); + } + + OnBCSystemCapabilityUpdatedNotificationPtr command_; + MockAppPtr mock_app_; + MessageSharedPtr message_; +}; + +TEST_F(OnBCSystemCapabilityUpdatedNotificationTest, + SystemDisplayCapabilities_SUCCESS) { + (*message_)[am::strings::msg_params][strings::system_capability] + [am::strings::system_capability_type] = + mobile_apis::SystemCapabilityType::DISPLAYS; + + smart_objects::SmartObjectSPtr system_display_capabilities = + std::make_shared( + smart_objects::SmartType_Null); + + EXPECT_CALL(mock_hmi_capabilities_, system_display_capabilities()) + .Times(2) + .WillRepeatedly(Return(system_display_capabilities)); + + EXPECT_CALL( + mock_rpc_service_, + SendMessageToHMI(CheckDisplayCapabilities(*system_display_capabilities))); + + ASSERT_TRUE(command_->Init()); + command_->Run(); +} + +TEST_F(OnBCSystemCapabilityUpdatedNotificationTest, + SystemDisplayCapabilities_DATA_NOT_AVAILABLE) { + (*message_)[am::strings::msg_params][strings::system_capability] + [am::strings::system_capability_type] = + mobile_apis::SystemCapabilityType::DISPLAYS; + EXPECT_CALL(mock_hmi_capabilities_, system_display_capabilities()) + .WillOnce(Return(nullptr)); + + EXPECT_CALL(mock_rpc_service_, SendMessageToHMI(_)).Times(0); + + ASSERT_TRUE(command_->Init()); + command_->Run(); +} + +} // namespace on_bc_system_capability_updated_notification +} // namespace hmi_commands_test +} // namespace commands_test +} // namespace components +} // namespace test diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/on_driver_distraction_notification_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/on_driver_distraction_notification_test.cc index fc3899e861c..fe6ba7c4e31 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/on_driver_distraction_notification_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/on_driver_distraction_notification_test.cc @@ -33,17 +33,17 @@ #include #include -#include "gtest/gtest.h" -#include "smart_objects/smart_object.h" -#include "application_manager/smart_object_keys.h" -#include "utils/lock.h" -#include "utils/data_accessor.h" #include "application_manager/commands/commands_test.h" #include "application_manager/mock_application.h" #include "application_manager/mock_application_manager.h" #include "application_manager/policies/mock_policy_handler_interface.h" +#include "application_manager/smart_object_keys.h" +#include "gtest/gtest.h" #include "hmi/on_driver_distraction_notification.h" #include "interfaces/MOBILE_API.h" +#include "smart_objects/smart_object.h" +#include "utils/data_accessor.h" +#include "utils/lock.h" namespace test { namespace components { @@ -52,22 +52,65 @@ namespace hmi_commands_test { namespace on_driver_distraction_notification { using ::testing::_; -using ::testing::Return; +using ::testing::DoAll; using ::testing::Eq; +using ::testing::NiceMock; +using ::testing::Return; +using ::testing::SaveArg; +using ::testing::SetArgumentPointee; + namespace am = ::application_manager; using am::commands::MessageSharedPtr; using sdl_rpc_plugin::commands::hmi::OnDriverDistractionNotification; using namespace am::commands; +using test::components::commands_test::MobileResultCodeIs; + +namespace { +const std::string kDefaultLanguage = "en-us"; +const mobile_apis::Language::eType kMobileLanguage = + mobile_apis::Language::EN_US; -typedef std::shared_ptr NotificationPtr; +// LSDW - lock screen dismissal warning +const std::string kLockScreenDismissalWarningMessage_en = + "Swipe down to dismiss, acknowledging that you are not the driver"; +const uint32_t kConnectionKey = 2u; +} // namespace class HMIOnDriverDistractionNotificationTest : public CommandsTest { public: HMIOnDriverDistractionNotificationTest() - : app_set_lock_(std::make_shared()) {} + : mock_app_(CreateMockApp()) + , app_set_lock_(std::make_shared()) + , accessor(app_set_, app_set_lock_) { + app_set_.insert(mock_app_); + InitMocksRelations(); + } + + typedef std::shared_ptr NotificationPtr; + typedef boost::optional OptionalBool; + + void SetUp() OVERRIDE { + ON_CALL(*mock_app_, ui_language()) + .WillByDefault(ReturnRef(kMobileLanguage)); + ON_CALL(app_mngr_, application(kConnectionKey)) + .WillByDefault(Return(mock_app_)); + ON_CALL(mock_message_helper_, MobileLanguageToString(kMobileLanguage)) + .WillByDefault(Return(kDefaultLanguage)); + } + + MockAppPtr mock_app_; std::shared_ptr app_set_lock_; - policy_test::MockPolicyHandlerInterface mock_policy_handler_interface_; + am::ApplicationSet app_set_; + DataAccessor accessor; + NiceMock + mock_policy_handler_interface_; + + void InitMocksRelations() { + ON_CALL(app_mngr_, applications()).WillByDefault(Return(accessor)); + ON_CALL(app_mngr_, GetPolicyHandler()) + .WillByDefault(ReturnRef(mock_policy_handler_interface_)); + } }; MATCHER_P2(CheckNotificationParams, function_id, state, "") { @@ -83,76 +126,238 @@ MATCHER_P2(CheckNotificationParams, function_id, state, "") { return is_function_id_matched && is_state_matched; } -ACTION_P(GetArg3, result) { - arg3 = *result; +ACTION_P(GetArg4, result) { + arg4 = *result; } -TEST_F(HMIOnDriverDistractionNotificationTest, Run_PushMobileMessage_SUCCESS) { - const hmi_apis::Common_DriverDistractionState::eType state = - hmi_apis::Common_DriverDistractionState::DD_ON; +ACTION_P(SetMessage, lockScreenDismissalWarning) { + smart_objects::SmartObject& notification = arg0; + + notification[application_manager::strings::msg_params] + [application_manager::mobile_notification:: + lock_screen_dismissal_warning] = lockScreenDismissalWarning; +} + +TEST_F(HMIOnDriverDistractionNotificationTest, + Run_SendNotificationToMobile_SUCCESS) { + const auto state = hmi_apis::Common_DriverDistractionState::DD_ON; MessageSharedPtr commands_msg(CreateMessage(smart_objects::SmartType_Map)); (*commands_msg)[am::strings::msg_params][am::hmi_notification::state] = state; + (*commands_msg)[am::strings::params][am::strings::connection_key] = + kConnectionKey; NotificationPtr command( CreateCommand(commands_msg)); EXPECT_CALL(app_mngr_, set_driver_distraction_state(Eq(state))); - MockAppPtr mock_app = CreateMockApp(); - am::ApplicationSet app_set; - app_set.insert(mock_app); + ON_CALL(mock_policy_handler_interface_, LockScreenDismissalEnabledState()) + .WillByDefault(Return(OptionalBool(true))); + + ON_CALL(mock_policy_handler_interface_, LockScreenDismissalWarningMessage(_)) + .WillByDefault(Return(kLockScreenDismissalWarningMessage_en)); + + policy::CheckPermissionResult result; + result.hmi_level_permitted = policy::kRpcAllowed; + EXPECT_CALL(mock_policy_handler_interface_, CheckPermissions(_, _, _, _, _)) + .WillOnce(GetArg4(&result)); + + MessageSharedPtr message_to_mobile( + CreateMessage(smart_objects::SmartType_Map)); + EXPECT_CALL(mock_rpc_service_, + ManageMobileCommand( + CheckNotificationParams( + am::mobile_api::FunctionID::OnDriverDistractionID, state), + Command::CommandSource::SOURCE_SDL)) + .WillOnce(DoAll(SaveArg<0>(&message_to_mobile), Return(true))); + command->Run(); + + ASSERT_TRUE((*message_to_mobile)[am::strings::msg_params].keyExists( + am::mobile_notification::lock_screen_dismissal_warning)); + + auto LSDW_message = + (*message_to_mobile) + [am::strings::msg_params] + [am::mobile_notification::lock_screen_dismissal_warning] + .asString(); + + EXPECT_EQ(kLockScreenDismissalWarningMessage_en, LSDW_message); +} + +TEST_F(HMIOnDriverDistractionNotificationTest, + Run_PushMobileMessage_If_DisallowedByPolicy) { + const auto state = hmi_apis::Common_DriverDistractionState::DD_ON; + MessageSharedPtr commands_msg(CreateMessage(smart_objects::SmartType_Map)); + (*commands_msg)[am::strings::msg_params][am::hmi_notification::state] = state; + (*commands_msg)[am::strings::params][am::strings::connection_key] = + kConnectionKey; + NotificationPtr command( + CreateCommand(commands_msg)); + + ON_CALL(mock_policy_handler_interface_, LockScreenDismissalEnabledState()) + .WillByDefault(Return(boost::optional(true))); + + ON_CALL(mock_policy_handler_interface_, LockScreenDismissalWarningMessage(_)) + .WillByDefault(Return(kLockScreenDismissalWarningMessage_en)); - DataAccessor accessor(app_set, app_set_lock_); - EXPECT_CALL(app_mngr_, applications()).WillOnce(Return(accessor)); policy::CheckPermissionResult result; result.hmi_level_permitted = policy::kRpcDisallowed; - EXPECT_CALL(app_mngr_, GetPolicyHandler()) - .WillOnce(ReturnRef(mock_policy_handler_interface_)); - EXPECT_CALL(mock_policy_handler_interface_, CheckPermissions(_, _, _, _)) - .WillOnce(GetArg3(&result)); + EXPECT_CALL(app_mngr_, GetPolicyHandler()).Times(3); + EXPECT_CALL(mock_policy_handler_interface_, CheckPermissions(_, _, _, _, _)) + .WillOnce(GetArg4(&result)); - EXPECT_CALL(*mock_app, + MessageSharedPtr pushed_message(CreateMessage(smart_objects::SmartType_Map)); + EXPECT_CALL(*mock_app_, PushMobileMessage(CheckNotificationParams( - am::mobile_api::FunctionID::OnDriverDistractionID, state))); + am::mobile_api::FunctionID::OnDriverDistractionID, state))) + .WillOnce(SaveArg<0>(&pushed_message)); + EXPECT_CALL(app_mngr_, set_driver_distraction_state(Eq(state))); command->Run(); + + ASSERT_TRUE((*pushed_message)[am::strings::msg_params].keyExists( + am::mobile_notification::lock_screen_dismissal_warning)); + + auto lock_screen_dismissal_warning_message = + (*pushed_message)[am::strings::msg_params] + [am::mobile_notification::lock_screen_dismissal_warning] + .asString(); + + EXPECT_EQ(kLockScreenDismissalWarningMessage_en, + lock_screen_dismissal_warning_message); } TEST_F(HMIOnDriverDistractionNotificationTest, - Run_SendNotificationToMobile_SUCCESS) { - const hmi_apis::Common_DriverDistractionState::eType state = - hmi_apis::Common_DriverDistractionState::DD_ON; + Run_SendNotificationIfLockScreenDismissalMissed) { + const auto state = hmi_apis::Common_DriverDistractionState::DD_ON; MessageSharedPtr commands_msg(CreateMessage(smart_objects::SmartType_Map)); (*commands_msg)[am::strings::msg_params][am::hmi_notification::state] = state; + NotificationPtr command( + CreateCommand(commands_msg)); + + ON_CALL(mock_policy_handler_interface_, LockScreenDismissalEnabledState()) + .WillByDefault(Return(boost::optional())); + + policy::CheckPermissionResult result; + result.hmi_level_permitted = policy::kRpcAllowed; + ON_CALL(mock_policy_handler_interface_, CheckPermissions(_, _, _, _, _)) + .WillByDefault(GetArg4(&result)); + + MessageSharedPtr command_result; + EXPECT_CALL(mock_rpc_service_, + ManageMobileCommand(_, Command::CommandSource::SOURCE_SDL)) + .WillOnce(DoAll(SaveArg<0>(&command_result), Return(true))); + + command->Run(); + + auto& msg_params = + (*command_result)[application_manager::strings::msg_params]; + EXPECT_FALSE(msg_params.keyExists( + application_manager::mobile_notification::lock_screen_dismissal_enabled)); + EXPECT_FALSE(msg_params.keyExists( + application_manager::mobile_notification::lock_screen_dismissal_warning)); +} + +// LSDW - lock screen dimissal +TEST_F(HMIOnDriverDistractionNotificationTest, + Run_SendNotificationToMobile_LSDWMessageIsAbsent_SUCCESS) { + const auto state = hmi_apis::Common_DriverDistractionState::DD_ON; + MessageSharedPtr commands_msg(CreateMessage(smart_objects::SmartType_Map)); + (*commands_msg)[am::strings::msg_params][am::hmi_notification::state] = state; + (*commands_msg)[am::strings::params][am::strings::connection_key] = + kConnectionKey; + NotificationPtr command( CreateCommand(commands_msg)); EXPECT_CALL(app_mngr_, set_driver_distraction_state(Eq(state))); - MockAppPtr mock_app = CreateMockApp(); - am::ApplicationSet app_set; - app_set.insert(mock_app); + ON_CALL(mock_policy_handler_interface_, LockScreenDismissalEnabledState()) + .WillByDefault(Return(OptionalBool(false))); - DataAccessor accessor(app_set, app_set_lock_); - EXPECT_CALL(app_mngr_, applications()).WillOnce(Return(accessor)); + // LockScreenDismissalWarning won't be added to message if value of + // LockScreenDismissalEnabledState is false + std::string required_language = "en-us"; + EXPECT_CALL(mock_policy_handler_interface_, + LockScreenDismissalWarningMessage(required_language)) + .Times(0); policy::CheckPermissionResult result; result.hmi_level_permitted = policy::kRpcAllowed; - EXPECT_CALL(app_mngr_, GetPolicyHandler()) - .WillOnce(ReturnRef(mock_policy_handler_interface_)); - EXPECT_CALL(mock_policy_handler_interface_, CheckPermissions(_, _, _, _)) - .WillOnce(GetArg3(&result)); + MessageSharedPtr message_to_mobile( + CreateMessage(smart_objects::SmartType_Map)); + EXPECT_CALL(app_mngr_, GetPolicyHandler()).Times(2); + EXPECT_CALL(mock_policy_handler_interface_, CheckPermissions(_, _, _, _, _)) + .WillOnce(GetArg4(&result)); EXPECT_CALL(mock_rpc_service_, ManageMobileCommand( CheckNotificationParams( am::mobile_api::FunctionID::OnDriverDistractionID, state), - Command::CommandSource::SOURCE_SDL)); - + Command::CommandSource::SOURCE_SDL)) + .WillOnce(DoAll(SaveArg<0>(&message_to_mobile), Return(true))); command->Run(); + + EXPECT_FALSE((*message_to_mobile)[am::strings::msg_params].keyExists( + am::mobile_notification::lock_screen_dismissal_warning)); } -} // on_driver_distraction_notification +TEST_F(HMIOnDriverDistractionNotificationTest, + Run_SendNotificationToMobile_SpecifiedLanguageIsAbsent_SUCCESS) { + const auto state = hmi_apis::Common_DriverDistractionState::DD_ON; + MessageSharedPtr commands_msg(CreateMessage(smart_objects::SmartType_Map)); + (*commands_msg)[am::strings::msg_params][am::hmi_notification::state] = state; + (*commands_msg)[am::strings::params][am::strings::connection_key] = + kConnectionKey; + + NotificationPtr command( + CreateCommand(commands_msg)); + + EXPECT_CALL(app_mngr_, set_driver_distraction_state(Eq(state))); + + ON_CALL(mock_policy_handler_interface_, LockScreenDismissalEnabledState()) + .WillByDefault(Return(OptionalBool(true))); + + ON_CALL(mock_policy_handler_interface_, LockScreenDismissalWarningMessage(_)) + .WillByDefault(Return(kLockScreenDismissalWarningMessage_en)); + + // In case when specified language is absent in policy table, will added + // message on default language (en-us) + const mobile_apis::Language::eType mobile_language = + mobile_apis::Language::FR_FR; + std::string required_language = "FR-FR"; + ON_CALL(*mock_app_, ui_language()).WillByDefault(ReturnRef(mobile_language)); + ON_CALL(mock_message_helper_, MobileLanguageToString(mobile_language)) + .WillByDefault(Return(required_language)); + + policy::CheckPermissionResult result; + result.hmi_level_permitted = policy::kRpcAllowed; + EXPECT_CALL(mock_policy_handler_interface_, CheckPermissions(_, _, _, _, _)) + .WillOnce(GetArg4(&result)); + + MessageSharedPtr message_to_mobile( + CreateMessage(smart_objects::SmartType_Map)); + EXPECT_CALL(mock_rpc_service_, + ManageMobileCommand( + CheckNotificationParams( + am::mobile_api::FunctionID::OnDriverDistractionID, state), + Command::CommandSource::SOURCE_SDL)) + .WillOnce(DoAll(SaveArg<0>(&message_to_mobile), Return(true))); + command->Run(); + + ASSERT_TRUE((*message_to_mobile)[am::strings::msg_params].keyExists( + am::mobile_notification::lock_screen_dismissal_warning)); + + auto lock_screen_dismissal_warning_message = + (*message_to_mobile) + [am::strings::msg_params] + [am::mobile_notification::lock_screen_dismissal_warning] + .asString(); + + EXPECT_EQ(kLockScreenDismissalWarningMessage_en, + lock_screen_dismissal_warning_message); +} +} // namespace on_driver_distraction_notification } // namespace hmi_commands_test } // namespace commands_test } // namespace components diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/get_urls_response_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/on_service_status_update_notification_test.cc similarity index 55% rename from src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/get_urls_response_test.cc rename to src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/on_service_status_update_notification_test.cc index 339a7499099..a9bc97f8425 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/get_urls_response_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/on_service_status_update_notification_test.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Ford Motor Company + * Copyright (c) 2019, Ford Motor Company * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -29,59 +29,67 @@ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ - #include -#include -#include "gtest/gtest.h" -#include "smart_objects/smart_object.h" -#include "application_manager/smart_object_keys.h" -#include "application_manager/commands/command.h" #include "application_manager/commands/commands_test.h" -#include "application_manager/application.h" +#include "application_manager/mock_application.h" #include "application_manager/mock_application_manager.h" -#include "application_manager/commands/response_to_hmi.h" -#include "hmi/get_urls_response.h" +#include "application_manager/smart_object_keys.h" +#include "gtest/gtest.h" +#include "hmi/on_service_update_notification.h" +#include "smart_objects/smart_object.h" namespace test { namespace components { namespace commands_test { namespace hmi_commands_test { -namespace get_urls_response { +namespace on_service_update_notification { -using ::testing::_; -using ::testing::Return; -namespace am = ::application_manager; -namespace strings = ::application_manager::strings; -using sdl_rpc_plugin::commands::GetUrlsResponse; -using am::commands::ResponseToHMI; -using am::commands::CommandImpl; +using namespace application_manager; +using sdl_rpc_plugin::commands::hmi::OnServiceUpdateNotification; -typedef std::shared_ptr ResponseToHMIPtr; +typedef std::shared_ptr NotificationPtr; +typedef hmi_apis::Common_ServiceType::eType ServiceType; +typedef hmi_apis::Common_ServiceEvent::eType ServiceEvent; namespace { -const uint32_t kConnectionKey = 2u; +const uint32_t kConnectionKey = 1232u; +const uint32_t kHmi_app_id = 321u; } // namespace -class GetUrlResponseTest : public CommandsTest {}; +class OnServiceUpdateNotificationTest + : public CommandsTest { + public: + OnServiceUpdateNotificationTest() + : message_(CreateMessage(smart_objects::SmartType_Map)) {} + + public: + MessageSharedPtr message_; + NotificationPtr command_; +}; + +TEST_F(OnServiceUpdateNotificationTest, SendNotificationToHMI) { + (*message_)[strings::msg_params][hmi_notification::service_type] = + ServiceType::AUDIO; + (*message_)[strings::msg_params][hmi_notification::service_event] = + ServiceEvent::REQUEST_ACCEPTED; + (*message_)[strings::msg_params][strings::app_id] = kConnectionKey; + command_ = CreateCommand(message_); + + EXPECT_CALL(mock_rpc_service_, SendMessageToHMI(message_)).Times(1); -TEST_F(GetUrlResponseTest, RUN_SendRequest_SUCCESS) { - MessageSharedPtr command_msg(CreateMessage(smart_objects::SmartType_Map)); - (*command_msg)[strings::msg_params][strings::number] = "123"; - (*command_msg)[strings::params][strings::connection_key] = kConnectionKey; + auto mock_app = std::make_shared >(); - ResponseToHMIPtr command(CreateCommand(command_msg)); - EXPECT_CALL(mock_rpc_service_, SendMessageToHMI(command_msg)); + ON_CALL(app_mngr_, application(kConnectionKey)) + .WillByDefault(Return(mock_app)); - command->Run(); + ON_CALL(*mock_app, hmi_app_id()).WillByDefault(Return(kHmi_app_id)); - EXPECT_EQ((*command_msg)[strings::params][strings::protocol_type].asInt(), - CommandImpl::hmi_protocol_type_); - EXPECT_EQ((*command_msg)[strings::params][strings::protocol_version].asInt(), - CommandImpl::protocol_version_); + command_->Init(); + command_->Run(); } -} // namespace get_urls_response +} // namespace on_service_update_notification } // namespace hmi_commands_test } // namespace commands_test } // namespace components diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/on_system_time_ready_notification_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/on_system_time_ready_notification_test.cc index 2d50ec2b729..f9dbbf259f2 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/on_system_time_ready_notification_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/on_system_time_ready_notification_test.cc @@ -30,12 +30,12 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include "gtest/gtest.h" -#include "application_manager/commands/commands_test.h" #include "hmi/on_system_time_ready_notification.h" +#include "application_manager/commands/commands_test.h" #include "application_manager/mock_application_manager.h" #include "application_manager/mock_event_dispatcher.h" #include "application_manager/smart_object_keys.h" +#include "gtest/gtest.h" #include "interfaces/HMI_API.h" namespace test { diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/rc_get_capabilities_response_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/rc_get_capabilities_response_test.cc index 8e62c1a4094..67c36dce9c2 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/rc_get_capabilities_response_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/rc_get_capabilities_response_test.cc @@ -34,13 +34,13 @@ #include "gtest/gtest.h" -#include "smart_objects/smart_object.h" -#include "interfaces/MOBILE_API.h" +#include "application_manager/commands/command_impl.h" +#include "application_manager/commands/commands_test.h" #include "application_manager/mock_hmi_capabilities.h" #include "application_manager/smart_object_keys.h" -#include "application_manager/commands/commands_test.h" -#include "application_manager/commands/command_impl.h" #include "hmi/rc_get_capabilities_response.h" +#include "interfaces/MOBILE_API.h" +#include "smart_objects/smart_object.h" namespace test { namespace components { @@ -52,8 +52,8 @@ using ::testing::NiceMock; namespace am = ::application_manager; namespace strings = am::strings; namespace hmi_response = am::hmi_response; -using sdl_rpc_plugin::commands::RCGetCapabilitiesResponse; using am::commands::CommandImpl; +using sdl_rpc_plugin::commands::RCGetCapabilitiesResponse; typedef std::shared_ptr RCGetCapabilitiesResponsePtr; typedef NiceMock< @@ -139,6 +139,7 @@ TEST_F(RCGetCapabilitiesResponseTest, RUN_SUCCESSS) { radio_control_capability["hdChannelAvailable"] = true; radio_control_capability["rdsDataAvailable"] = true; radio_control_capability["availableHDsAvailable"] = true; + radio_control_capability["availableHdChannelsAvailable"] = true; radio_control_capability["stateAvailable"] = true; radio_control_capability["signalStrengthAvailable"] = true; radio_control_capability["signalChangeThresholdAvailable"] = true; diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/rc_is_ready_request_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/rc_is_ready_request_test.cc index c7fbdb663b6..539c0efeb32 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/rc_is_ready_request_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/rc_is_ready_request_test.cc @@ -34,15 +34,15 @@ #include "gtest/gtest.h" -#include "smart_objects/smart_object.h" -#include "application_manager/smart_object_keys.h" #include "application_manager/commands/command_request_test.h" -#include "application_manager/mock_application_manager.h" +#include "application_manager/event_engine/event.h" #include "application_manager/hmi_interfaces.h" -#include "application_manager/mock_hmi_interface.h" +#include "application_manager/mock_application_manager.h" #include "application_manager/mock_hmi_capabilities.h" +#include "application_manager/mock_hmi_interface.h" #include "application_manager/mock_message_helper.h" -#include "application_manager/event_engine/event.h" +#include "application_manager/smart_object_keys.h" +#include "smart_objects/smart_object.h" namespace test { namespace components { @@ -54,8 +54,8 @@ using ::testing::_; using ::testing::ReturnRef; namespace am = ::application_manager; using am::commands::MessageSharedPtr; -using sdl_rpc_plugin::commands::RCIsReadyRequest; using am::event_engine::Event; +using sdl_rpc_plugin::commands::RCIsReadyRequest; typedef std::shared_ptr RCIsReadyRequestPtr; diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/rc_is_ready_response_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/rc_is_ready_response_test.cc index a1a8c1c87e7..4224e82b5fb 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/rc_is_ready_response_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/rc_is_ready_response_test.cc @@ -35,11 +35,11 @@ #include "gtest/gtest.h" -#include "smart_objects/smart_object.h" #include "application_manager/commands/commands_test.h" +#include "application_manager/mock_event_dispatcher.h" #include "application_manager/mock_hmi_capabilities.h" #include "hmi/rc_is_ready_response.h" -#include "application_manager/mock_event_dispatcher.h" +#include "smart_objects/smart_object.h" namespace test { namespace components { diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/response_from_hmi_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/response_from_hmi_test.cc index 25abefb0105..3e7e6e6f59e 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/response_from_hmi_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/response_from_hmi_test.cc @@ -32,24 +32,24 @@ #include -#include "gtest/gtest.h" -#include "smart_objects/smart_object.h" +#include "application_manager/commands/command.h" +#include "application_manager/commands/response_from_hmi.h" #include "application_manager/smart_object_keys.h" #include "application_manager/test/include/application_manager/commands/commands_test.h" -#include "application_manager/commands/command.h" #include "application_manager/test/include/application_manager/mock_event_dispatcher.h" -#include "application_manager/commands/response_from_hmi.h" +#include "gtest/gtest.h" +#include "smart_objects/smart_object.h" namespace test { namespace components { namespace commands_test { namespace hmi_commands_test { namespace response_from_hmi { +using ::test::components::event_engine_test::MockEventDispatcher; using ::testing::_; +using ::testing::DoAll; using ::testing::Return; using ::testing::SaveArg; -using ::testing::DoAll; -using ::test::components::event_engine_test::MockEventDispatcher; namespace am = ::application_manager; using application_manager::commands::ResponseFromHMI; diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/sdl_activate_app_request_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/sdl_activate_app_request_test.cc index 917de81fb3f..93344f1a0df 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/sdl_activate_app_request_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/sdl_activate_app_request_test.cc @@ -32,19 +32,19 @@ #include -#include "gtest/gtest.h" -#include "utils/lock.h" -#include "utils/helpers.h" -#include "hmi/sdl_activate_app_request.h" -#include "application_manager/mock_application.h" #include "application_manager/application_manager.h" -#include "application_manager/policies/mock_policy_handler_interface.h" #include "application_manager/commands/command_request_test.h" -#include "application_manager/mock_message_helper.h" #include "application_manager/event_engine/event.h" +#include "application_manager/mock_application.h" #include "application_manager/mock_event_dispatcher.h" +#include "application_manager/mock_message_helper.h" #include "application_manager/mock_state_controller.h" +#include "application_manager/policies/mock_policy_handler_interface.h" #include "connection_handler/mock_connection_handler.h" +#include "gtest/gtest.h" +#include "hmi/sdl_activate_app_request.h" +#include "utils/helpers.h" +#include "utils/lock.h" namespace test { namespace components { @@ -55,18 +55,17 @@ namespace sdl_activate_app_request { namespace am = ::application_manager; namespace strings = am::strings; namespace hmi_response = am::hmi_response; +using am::ApplicationSet; using am::commands::MessageSharedPtr; +using am::event_engine::Event; +using connection_handler_test::MockConnectionHandler; +using policy_test::MockPolicyHandlerInterface; using sdl_rpc_plugin::commands::SDLActivateAppRequest; -using am::ApplicationSet; +using testing::Gt; using testing::Mock; +using ::testing::NiceMock; using testing::Return; using testing::ReturnRef; -using testing::Mock; -using testing::Gt; -using ::testing::NiceMock; -using policy_test::MockPolicyHandlerInterface; -using connection_handler_test::MockConnectionHandler; -using am::event_engine::Event; namespace { const uint32_t kCorrelationID = 1u; diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/sdl_activate_app_response_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/sdl_activate_app_response_test.cc index bca316bcfa5..b35ccde3141 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/sdl_activate_app_response_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/sdl_activate_app_response_test.cc @@ -33,12 +33,12 @@ #include #include -#include "gtest/gtest.h" -#include "smart_objects/smart_object.h" -#include "application_manager/smart_object_keys.h" -#include "application_manager/commands/commands_test.h" #include "application_manager/application.h" +#include "application_manager/commands/commands_test.h" +#include "application_manager/smart_object_keys.h" +#include "gtest/gtest.h" #include "hmi/sdl_activate_app_response.h" +#include "smart_objects/smart_object.h" namespace test { namespace components { @@ -48,8 +48,8 @@ namespace sdl_activate_app_response { namespace am = ::application_manager; namespace strings = ::application_manager::strings; -using sdl_rpc_plugin::commands::SDLActivateAppResponse; using am::commands::CommandImpl; +using sdl_rpc_plugin::commands::SDLActivateAppResponse; typedef std::shared_ptr SDLActivateAppResponsePtr; diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/sdl_get_list_of_permisssions_request_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/sdl_get_list_of_permisssions_request_test.cc index 262ac5fc7dc..c8cc4bb18c0 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/sdl_get_list_of_permisssions_request_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/sdl_get_list_of_permisssions_request_test.cc @@ -32,11 +32,11 @@ #include -#include "gtest/gtest.h" -#include "hmi/sdl_get_list_of_permissions_request.h" +#include "application_manager/commands/command_request_test.h" #include "application_manager/mock_application.h" #include "application_manager/policies/mock_policy_handler_interface.h" -#include "application_manager/commands/command_request_test.h" +#include "gtest/gtest.h" +#include "hmi/sdl_get_list_of_permissions_request.h" namespace test { namespace components { @@ -46,8 +46,8 @@ namespace sdl_get_list_of_permissions_request { using application_manager::commands::MessageSharedPtr; using sdl_rpc_plugin::commands::SDLGetListOfPermissionsRequest; -using test::components::policy_test::MockPolicyHandlerInterface; using smart_objects::SmartObject; +using test::components::policy_test::MockPolicyHandlerInterface; using testing::Return; using testing::ReturnRef; diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/sdl_get_policy_configuration_data_request_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/sdl_get_policy_configuration_data_request_test.cc new file mode 100644 index 00000000000..8e802bbd7dd --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/sdl_get_policy_configuration_data_request_test.cc @@ -0,0 +1,180 @@ +/* + * Copyright (c) 2019, 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 "hmi/sdl_get_policy_configuration_data_request.h" +#include "application_manager/commands/command_request_test.h" +#include "gtest/gtest.h" +#include "smart_objects/smart_object.h" + +namespace test { +namespace components { +namespace commands_test { +namespace hmi_commands_test { +namespace sdl_get_policy_configuration_data_request { + +using testing::Return; + +using sdl_rpc_plugin::commands::SDLGetPolicyConfigurationDataRequest; +using test::components::policy_test::MockPolicyHandlerInterface; + +namespace strings = ::app_mngr::strings; +namespace hmi_response = ::app_mngr::hmi_response; + +class SDLGetPolicyConfigurationDataRequestTest + : public CommandRequestTest {}; + +MATCHER_P(GetPolicyConfigurationDataFirstElementMatches, + string_first_element_value, + "") { + auto message = static_cast(*arg); + if (!message.keyExists(strings::msg_params) || + !message[strings::msg_params].keyExists(strings::value)) { + return false; + } + + if (message[strings::msg_params][strings::value].getType() != + smart_objects::SmartType::SmartType_Array || + message[strings::msg_params][strings::value].empty()) { + return false; + } + + Json::Reader reader; + Json::Value msg_json_value(Json::ValueType::arrayValue); + + auto msg_value_first = message[strings::msg_params][strings::value][0]; + return msg_value_first.asString() == string_first_element_value; +} + +MATCHER_P(HMIResultCodeIs, result_code, "") { + return result_code == + static_cast( + (*arg)[strings::params][hmi_response::code].asInt()); +} + +TEST_F(SDLGetPolicyConfigurationDataRequestTest, Run_Fail_DataNotAvailable) { + std::string kInvalidKey = "invalid_key"; + + PolicyTable pt; + ON_CALL(mock_policy_handler_, GetPolicyTableData()) + .WillByDefault(Return(pt.ToJsonValue())); + + MessageSharedPtr msg = CreateMessage(); + (*msg)[strings::msg_params][strings::policy_type] = kInvalidKey; + (*msg)[strings::msg_params][strings::property] = kInvalidKey; + + std::shared_ptr command( + CreateCommand(msg)); + + EXPECT_CALL(mock_rpc_service_, + ManageHMICommand( + HMIResultCodeIs(hmi_apis::Common_Result::DATA_NOT_AVAILABLE), + Command::SOURCE_SDL_TO_HMI)); + + command->Run(); +} + +void clear_new_line_symbol(std::string& str_to_clear) { + str_to_clear.erase( + std::remove_if(str_to_clear.begin(), + str_to_clear.end(), + [](char character) { return '\n' == character; }), + str_to_clear.end()); +} + +TEST_F(SDLGetPolicyConfigurationDataRequestTest, Run_Success) { + MessageSharedPtr msg = CreateMessage(); + (*msg)[strings::msg_params][strings::policy_type] = "module_config"; + (*msg)[strings::msg_params][strings::property] = "endpoints"; + + std::shared_ptr command( + CreateCommand(msg)); + + policy_table::ModuleConfig module_config_with_endpoints; + policy_table::URLList endpoint_url_list; + policy_table::URL urls; + urls.push_back("https://url1.com"); + urls.push_back("https://url2.com"); + endpoint_url_list["default"] = urls; + module_config_with_endpoints.endpoints["0x9"] = endpoint_url_list; + + PolicyTable pt; + pt.mark_initialized(); + pt.module_config.mark_initialized(); + pt.module_config = module_config_with_endpoints; + + ON_CALL(mock_policy_handler_, GetPolicyTableData()) + .WillByDefault(Return(pt.ToJsonValue())); + + auto json_val = module_config_with_endpoints.endpoints.ToJsonValue(); + Json::FastWriter writer; + std::string expected_string = writer.write(json_val); + clear_new_line_symbol(expected_string); + + EXPECT_CALL(mock_rpc_service_, + ManageHMICommand(GetPolicyConfigurationDataFirstElementMatches( + expected_string), + Command::SOURCE_SDL_TO_HMI)); + command->Run(); +} + +TEST_F(SDLGetPolicyConfigurationDataRequestTest, + Run_RetriveStringValueFromPolicy) { + MessageSharedPtr msg = CreateMessage(); + (*msg)[strings::msg_params][strings::policy_type] = + "consumer_friendly_messages"; + (*msg)[strings::msg_params][strings::property] = "version"; + + auto command = CreateCommand(msg); + + const std::string version_test_value("version string"); + PolicyTable pt; + pt.mark_initialized(); + pt.consumer_friendly_messages->mark_initialized(); + pt.consumer_friendly_messages->version = + rpc::String<1, 100>(version_test_value); + + ON_CALL(mock_policy_handler_, GetPolicyTableData()) + .WillByDefault(Return(pt.ToJsonValue())); + + EXPECT_CALL(mock_rpc_service_, + ManageHMICommand(GetPolicyConfigurationDataFirstElementMatches( + version_test_value), + Command::SOURCE_SDL_TO_HMI)); + + command->Run(); +} + +} // namespace sdl_get_policy_configuration_data_request +} // namespace hmi_commands_test +} // namespace commands_test +} // namespace components +} // namespace test diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/sdl_get_status_update_request_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/sdl_get_status_update_request_test.cc index fca8ed840fa..021dfc8b1d4 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/sdl_get_status_update_request_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/sdl_get_status_update_request_test.cc @@ -32,11 +32,11 @@ #include -#include "gtest/gtest.h" -#include "hmi/sdl_get_status_update_request.h" +#include "application_manager/commands/command_request_test.h" #include "application_manager/mock_application.h" #include "application_manager/policies/mock_policy_handler_interface.h" -#include "application_manager/commands/command_request_test.h" +#include "gtest/gtest.h" +#include "hmi/sdl_get_status_update_request.h" namespace test { namespace components { diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/sdl_get_user_friendly_message_request_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/sdl_get_user_friendly_message_request_test.cc index b040f8ea408..5cac1c823f6 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/sdl_get_user_friendly_message_request_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/sdl_get_user_friendly_message_request_test.cc @@ -34,15 +34,15 @@ #include #include -#include "gtest/gtest.h" -#include "hmi/sdl_get_user_friendly_message_request.h" +#include "application_manager/commands/command_request_test.h" #include "application_manager/mock_application.h" +#include "application_manager/mock_hmi_capabilities.h" +#include "application_manager/mock_message_helper.h" #include "application_manager/mock_state_controller.h" #include "application_manager/policies/mock_policy_handler_interface.h" -#include "application_manager/mock_message_helper.h" -#include "application_manager/mock_hmi_capabilities.h" +#include "gtest/gtest.h" +#include "hmi/sdl_get_user_friendly_message_request.h" #include "smart_objects/smart_object.h" -#include "application_manager/commands/command_request_test.h" namespace test { namespace components { @@ -50,11 +50,11 @@ namespace commands_test { namespace hmi_commands_test { namespace sdl_get_user_friendly_message_request { +using application_manager::MockMessageHelper; using application_manager::commands::MessageSharedPtr; using sdl_rpc_plugin::commands::SDLGetUserFriendlyMessageRequest; -using application_manager::MockMessageHelper; -using test::components::policy_test::MockPolicyHandlerInterface; using test::components::application_manager_test::MockHMICapabilities; +using test::components::policy_test::MockPolicyHandlerInterface; using testing::_; using testing::Return; using testing::ReturnRef; diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/simple_notifications_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/simple_notifications_test.cc index 581913d3a5a..57bb018273f 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/simple_notifications_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/simple_notifications_test.cc @@ -34,8 +34,8 @@ #include "application_manager/commands/commands_test.h" -#include "application_manager/commands/notification_to_hmi.h" #include "application_manager/commands/command_notification_impl.h" +#include "application_manager/commands/notification_to_hmi.h" namespace test { namespace components { @@ -45,8 +45,8 @@ namespace simple_notifications_test { using namespace application_manager; -using ::testing::Types; using commands::NotificationToHMI; +using ::testing::Types; template class SimpleNotificationsTest : public CommandsTest { diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/simple_request_from_hmi_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/simple_request_from_hmi_test.cc index a69f6c71fc6..fc2cd1cca44 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/simple_request_from_hmi_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/simple_request_from_hmi_test.cc @@ -30,14 +30,14 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include "gtest/gtest.h" -#include "smart_objects/smart_object.h" -#include "application_manager/smart_object_keys.h" -#include "application_manager/commands/commands_test.h" #include "application_manager/commands/command.h" +#include "application_manager/commands/commands_test.h" +#include "application_manager/commands/request_from_hmi.h" #include "application_manager/event_engine/event.h" #include "application_manager/mock_event_dispatcher.h" -#include "application_manager/commands/request_from_hmi.h" +#include "application_manager/smart_object_keys.h" +#include "gtest/gtest.h" +#include "smart_objects/smart_object.h" namespace test { namespace components { @@ -46,12 +46,12 @@ namespace hmi_commands_test { namespace simple_requests_from_hmi_test { using ::testing::_; -using ::testing::Types; -using ::testing::NotNull; using ::testing::NiceMock; +using ::testing::NotNull; +using ::testing::Types; namespace commands = ::application_manager::commands; -using commands::MessageSharedPtr; using ::application_manager::event_engine::EventObserver; +using commands::MessageSharedPtr; using ::test::components::event_engine_test::MockEventDispatcher; class RequestFromHMITest : public CommandsTest { @@ -89,7 +89,7 @@ TEST_F(RequestFromHMITest, SendResponse_SUCCESS) { hmi_apis::Common_Result::SUCCESS); } -} // namespace simple_requests_to_hmi_test +} // namespace simple_requests_from_hmi_test } // namespace hmi_commands_test } // namespace commands_test } // namespace components diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/simple_requests_to_hmi_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/simple_requests_to_hmi_test.cc index 599c7e50f2b..162e832e9f4 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/simple_requests_to_hmi_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/simple_requests_to_hmi_test.cc @@ -30,16 +30,18 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include "gtest/gtest.h" -#include "smart_objects/smart_object.h" -#include "application_manager/smart_object_keys.h" -#include "application_manager/commands/commands_test.h" -#include "application_manager/commands/command_request_test.h" #include "application_manager/commands/command.h" -#include "sdl_rpc_plugin/commands/hmi/allow_app_request.h" +#include "application_manager/commands/command_request_test.h" +#include "application_manager/commands/commands_test.h" +#include "application_manager/commands/request_to_hmi.h" +#include "application_manager/smart_object_keys.h" +#include "gtest/gtest.h" #include "sdl_rpc_plugin/commands/hmi/allow_all_apps_request.h" +#include "sdl_rpc_plugin/commands/hmi/allow_app_request.h" #include "sdl_rpc_plugin/commands/hmi/basic_communication_system_request.h" #include "sdl_rpc_plugin/commands/hmi/button_get_capabilities_request.h" +#include "sdl_rpc_plugin/commands/hmi/close_popup_request.h" +#include "sdl_rpc_plugin/commands/hmi/dial_number_request.h" #include "sdl_rpc_plugin/commands/hmi/navi_alert_maneuver_request.h" #include "sdl_rpc_plugin/commands/hmi/navi_audio_stop_stream_request.h" #include "sdl_rpc_plugin/commands/hmi/navi_get_way_points_request.h" @@ -53,21 +55,15 @@ #include "sdl_rpc_plugin/commands/hmi/sdl_activate_app_response.h" #include "sdl_rpc_plugin/commands/hmi/sdl_get_list_of_permissions_response.h" #include "sdl_rpc_plugin/commands/hmi/sdl_get_status_update_response.h" -#include "sdl_rpc_plugin/commands/hmi/ui_scrollable_message_request.h" -#include "sdl_rpc_plugin/commands/hmi/ui_set_app_icon_request.h" -#include "sdl_rpc_plugin/commands/hmi/ui_set_display_layout_request.h" -#include "sdl_rpc_plugin/commands/hmi/ui_set_global_properties_request.h" -#include "application_manager/commands/request_to_hmi.h" -#include "sdl_rpc_plugin/commands/hmi/dial_number_request.h" +#include "sdl_rpc_plugin/commands/hmi/sdl_policy_update.h" +#include "sdl_rpc_plugin/commands/hmi/tts_change_registration_request.h" +#include "sdl_rpc_plugin/commands/hmi/tts_get_capabilities_request.h" +#include "sdl_rpc_plugin/commands/hmi/tts_get_language_request.h" +#include "sdl_rpc_plugin/commands/hmi/tts_get_supported_languages_request.h" #include "sdl_rpc_plugin/commands/hmi/tts_is_ready_request.h" #include "sdl_rpc_plugin/commands/hmi/tts_set_global_properties_request.h" #include "sdl_rpc_plugin/commands/hmi/tts_speak_request.h" #include "sdl_rpc_plugin/commands/hmi/tts_stop_speaking_request.h" -#include "sdl_rpc_plugin/commands/hmi/tts_get_supported_languages_request.h" -#include "sdl_rpc_plugin/commands/hmi/tts_change_registration_request.h" -#include "sdl_rpc_plugin/commands/hmi/tts_get_capabilities_request.h" -#include "sdl_rpc_plugin/commands/hmi/tts_get_language_request.h" -#include "sdl_rpc_plugin/commands/hmi/close_popup_request.h" #include "sdl_rpc_plugin/commands/hmi/ui_add_command_request.h" #include "sdl_rpc_plugin/commands/hmi/ui_add_submenu_request.h" #include "sdl_rpc_plugin/commands/hmi/ui_alert_request.h" @@ -81,6 +77,11 @@ #include "sdl_rpc_plugin/commands/hmi/ui_is_ready_request.h" #include "sdl_rpc_plugin/commands/hmi/ui_perform_audio_pass_thru_request.h" #include "sdl_rpc_plugin/commands/hmi/ui_perform_interaction_request.h" +#include "sdl_rpc_plugin/commands/hmi/ui_scrollable_message_request.h" +#include "sdl_rpc_plugin/commands/hmi/ui_send_haptic_data_request.h" +#include "sdl_rpc_plugin/commands/hmi/ui_set_app_icon_request.h" +#include "sdl_rpc_plugin/commands/hmi/ui_set_display_layout_request.h" +#include "sdl_rpc_plugin/commands/hmi/ui_set_global_properties_request.h" #include "sdl_rpc_plugin/commands/hmi/ui_set_media_clock_timer_request.h" #include "sdl_rpc_plugin/commands/hmi/ui_show_request.h" #include "sdl_rpc_plugin/commands/hmi/ui_slider_request.h" @@ -88,23 +89,11 @@ #include "sdl_rpc_plugin/commands/hmi/vr_change_registration_request.h" #include "sdl_rpc_plugin/commands/hmi/vr_delete_command_request.h" #include "sdl_rpc_plugin/commands/hmi/vr_get_capabilities_request.h" -#include "sdl_rpc_plugin/commands/hmi/vr_get_supported_languages_request.h" #include "sdl_rpc_plugin/commands/hmi/vr_get_language_request.h" +#include "sdl_rpc_plugin/commands/hmi/vr_get_supported_languages_request.h" #include "sdl_rpc_plugin/commands/hmi/vr_is_ready_request.h" #include "sdl_rpc_plugin/commands/hmi/vr_perform_interaction_request.h" -#include "sdl_rpc_plugin/commands/hmi/allow_all_apps_request.h" -#include "sdl_rpc_plugin/commands/hmi/basic_communication_system_request.h" -#include "sdl_rpc_plugin/commands/hmi/button_get_capabilities_request.h" -#include "sdl_rpc_plugin/commands/hmi/allow_app_request.h" -#include "sdl_rpc_plugin/commands/hmi/navi_send_location_request.h" -#include "sdl_rpc_plugin/commands/hmi/navi_unsubscribe_way_points_request.h" -#include "sdl_rpc_plugin/commands/hmi/navi_update_turn_list_request.h" -#include "sdl_rpc_plugin/commands/hmi/navi_show_constant_tbt_request.h" -#include "sdl_rpc_plugin/commands/hmi/navi_stop_stream_request.h" -#include "sdl_rpc_plugin/commands/hmi/navi_subscribe_way_points_request.h" -#include "sdl_rpc_plugin/commands/hmi/sdl_policy_update.h" -#include "sdl_rpc_plugin/commands/hmi/dial_number_request.h" -#include "sdl_rpc_plugin/commands/hmi/ui_send_haptic_data_request.h" +#include "smart_objects/smart_object.h" #include "application_manager/mock_event_dispatcher.h" @@ -115,8 +104,8 @@ namespace hmi_commands_test { namespace simple_requests_to_hmi_test { using ::testing::_; -using ::testing::Types; using ::testing::NotNull; +using ::testing::Types; namespace am_commands = application_manager::commands; using am_commands::MessageSharedPtr; using event_engine_test::MockEventDispatcher; @@ -221,7 +210,8 @@ typedef Types RequestCommandsList3; + sdl_rpc_plugin::commands::VRIsReadyRequest> + RequestCommandsList3; TYPED_TEST_CASE(RequestToHMICommandsTest, RequestCommandsList); TYPED_TEST_CASE(RequestToHMICommandsTest2, RequestCommandsList2); diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/simple_response_from_hmi_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/simple_response_from_hmi_test.cc index 4f415975bad..f232240c288 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/simple_response_from_hmi_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/simple_response_from_hmi_test.cc @@ -32,13 +32,18 @@ #include -#include "gtest/gtest.h" -#include "smart_objects/smart_object.h" -#include "application_manager/smart_object_keys.h" -#include "application_manager/commands/commands_test.h" #include "application_manager/commands/command.h" +#include "application_manager/commands/commands_test.h" +#include "application_manager/commands/notification_from_hmi.h" +#include "application_manager/mock_event_dispatcher.h" +#include "application_manager/mock_hmi_capabilities.h" +#include "application_manager/policies/mock_policy_handler_interface.h" +#include "application_manager/smart_object_keys.h" +#include "gtest/gtest.h" #include "hmi/activate_app_response.h" #include "hmi/basic_communication_system_response.h" +#include "hmi/close_popup_response.h" +#include "hmi/dial_number_response.h" #include "hmi/navi_alert_maneuver_response.h" #include "hmi/navi_audio_start_stream_response.h" #include "hmi/navi_audio_stop_stream_response.h" @@ -50,20 +55,13 @@ #include "hmi/navi_subscribe_way_points_response.h" #include "hmi/navi_unsubscribe_way_points_response.h" #include "hmi/navi_update_turn_list_response.h" +#include "hmi/on_find_applications.h" +#include "hmi/on_update_device_list.h" +#include "hmi/sdl_policy_update_response.h" #include "hmi/tts_change_registration_response.h" -#include "hmi/ui_set_app_icon_response.h" -#include "hmi/ui_set_display_layout_response.h" -#include "hmi/ui_set_global_properties_response.h" -#include "hmi/ui_scrollable_message_response.h" -#include "application_manager/mock_event_dispatcher.h" -#include "application_manager/mock_hmi_capabilities.h" -#include "application_manager/policies/mock_policy_handler_interface.h" -#include "hmi/dial_number_response.h" -#include "hmi/close_popup_response.h" #include "hmi/tts_set_global_properties_response.h" #include "hmi/tts_speak_response.h" #include "hmi/tts_stop_speaking_response.h" -#include "hmi/tts_change_registration_response.h" #include "hmi/ui_add_command_response.h" #include "hmi/ui_add_submenu_response.h" #include "hmi/ui_alert_response.h" @@ -73,28 +71,21 @@ #include "hmi/ui_end_audio_pass_thru_response.h" #include "hmi/ui_perform_audio_pass_thru_response.h" #include "hmi/ui_perform_interaction_response.h" +#include "hmi/ui_scrollable_message_response.h" +#include "hmi/ui_send_haptic_data_response.h" +#include "hmi/ui_set_app_icon_response.h" +#include "hmi/ui_set_display_layout_response.h" +#include "hmi/ui_set_global_properties_response.h" #include "hmi/ui_set_media_clock_timer_response.h" #include "hmi/ui_show_response.h" #include "hmi/ui_slider_response.h" +#include "hmi/update_app_list_response.h" +#include "hmi/update_device_list_response.h" #include "hmi/vr_add_command_response.h" #include "hmi/vr_change_registration_response.h" #include "hmi/vr_delete_command_response.h" #include "hmi/vr_perform_interaction_response.h" -#include "hmi/activate_app_response.h" -#include "hmi/basic_communication_system_response.h" -#include "hmi/navi_unsubscribe_way_points_response.h" -#include "hmi/navi_update_turn_list_response.h" -#include "hmi/navi_send_location_response.h" -#include "hmi/navi_show_constant_tbt_response.h" -#include "hmi/navi_start_stream_response.h" -#include "hmi/navi_subscribe_way_points_response.h" -#include "hmi/on_find_applications.h" -#include "hmi/on_update_device_list.h" -#include "hmi/sdl_policy_update_response.h" -#include "hmi/update_app_list_response.h" -#include "hmi/update_device_list_response.h" -#include "application_manager/commands/notification_from_hmi.h" -#include "hmi/ui_send_haptic_data_response.h" +#include "smart_objects/smart_object.h" namespace test { namespace components { @@ -102,12 +93,12 @@ namespace commands_test { namespace hmi_commands_test { namespace simple_response_from_hmi_test { +using ::test::components::event_engine_test::MockEventDispatcher; using ::testing::_; +using ::testing::Eq; using ::testing::Return; using ::testing::ReturnRef; using ::testing::Types; -using ::testing::Eq; -using ::test::components::event_engine_test::MockEventDispatcher; namespace am = ::application_manager; namespace commands = sdl_rpc_plugin::commands; @@ -218,7 +209,8 @@ typedef Types< CommandData, CommandData > ResponseCommandsList; + hmi_apis::FunctionID::UI_SendHapticData> > + ResponseCommandsList; typedef Types ResponseCommandsList; + commands::SDLGetUserFriendlyMessageResponse> + ResponseCommandsList; TYPED_TEST_CASE(ResponseToHMICommandsTest, ResponseCommandsList); diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/tts_get_capabilities_response_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/tts_get_capabilities_response_test.cc index bc9d262e6d4..c7b96f1acfd 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/tts_get_capabilities_response_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/tts_get_capabilities_response_test.cc @@ -32,11 +32,11 @@ #include +#include "application_manager/commands/commands_test.h" +#include "application_manager/mock_hmi_capabilities.h" #include "gtest/gtest.h" #include "hmi/tts_get_capabilities_response.h" -#include "application_manager/mock_hmi_capabilities.h" #include "smart_objects/smart_object.h" -#include "application_manager/commands/commands_test.h" namespace test { namespace components { diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/tts_get_language_response_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/tts_get_language_response_test.cc index 0d22500f48e..c0d23cb34b9 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/tts_get_language_response_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/tts_get_language_response_test.cc @@ -30,13 +30,12 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include "gtest/gtest.h" #include "hmi/tts_get_language_response.h" -#include "application_manager/smart_object_keys.h" #include "application_manager/commands/commands_test.h" -#include "application_manager/mock_hmi_capabilities.h" #include "application_manager/mock_event_dispatcher.h" -#include "application_manager/commands/commands_test.h" +#include "application_manager/mock_hmi_capabilities.h" +#include "application_manager/smart_object_keys.h" +#include "gtest/gtest.h" namespace test { namespace components { diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/tts_get_supported_languages_response_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/tts_get_supported_languages_response_test.cc index 417b8e18989..c0f187a85fc 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/tts_get_supported_languages_response_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/tts_get_supported_languages_response_test.cc @@ -33,17 +33,17 @@ #include #include -#include "gtest/gtest.h" -#include "smart_objects/smart_object.h" -#include "application_manager/smart_object_keys.h" -#include "application_manager/commands/commands_test.h" #include "application_manager/application.h" +#include "application_manager/commands/commands_test.h" +#include "application_manager/commands/response_from_hmi.h" +#include "application_manager/mock_application_manager.h" #include "application_manager/mock_hmi_capabilities.h" #include "application_manager/mock_message_helper.h" -#include "application_manager/mock_application_manager.h" -#include "application_manager/commands/response_from_hmi.h" -#include "hmi/tts_get_supported_languages_response.h" #include "application_manager/policies/mock_policy_handler_interface.h" +#include "application_manager/smart_object_keys.h" +#include "gtest/gtest.h" +#include "hmi/tts_get_supported_languages_response.h" +#include "smart_objects/smart_object.h" namespace test { namespace components { @@ -52,14 +52,14 @@ namespace hmi_commands_test { namespace tts_get_supported_languages_response { using ::testing::_; -using ::testing::Return; using ::testing::NiceMock; +using ::testing::Return; namespace am = ::application_manager; namespace strings = ::application_manager::strings; namespace hmi_response = am::hmi_response; +using am::commands::CommandImpl; using application_manager::commands::ResponseFromHMI; using sdl_rpc_plugin::commands::TTSGetSupportedLanguagesResponse; -using am::commands::CommandImpl; typedef std::shared_ptr ResponseFromHMIPtr; typedef NiceMock< @@ -113,7 +113,8 @@ TEST_F(TTSGetSupportedLanguageResponseTest, RUN_UNSUCCESS) { CreateCommand(command_msg)); EXPECT_CALL(mock_hmi_capabilities_, - set_tts_supported_languages(supported_languages)).Times(0); + set_tts_supported_languages(supported_languages)) + .Times(0); command->Run(); diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/tts_is_ready_response_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/tts_is_ready_response_test.cc index 2fae8a68193..a2f4440c86c 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/tts_is_ready_response_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/tts_is_ready_response_test.cc @@ -33,18 +33,18 @@ #include #include -#include "gtest/gtest.h" -#include "smart_objects/smart_object.h" -#include "application_manager/smart_object_keys.h" -#include "application_manager/commands/commands_test.h" #include "application_manager/application.h" +#include "application_manager/commands/commands_test.h" +#include "application_manager/commands/response_from_hmi.h" +#include "application_manager/mock_application_manager.h" +#include "application_manager/mock_event_dispatcher.h" #include "application_manager/mock_hmi_capabilities.h" #include "application_manager/mock_message_helper.h" -#include "application_manager/mock_application_manager.h" -#include "application_manager/commands/response_from_hmi.h" -#include "hmi/tts_is_ready_response.h" #include "application_manager/policies/mock_policy_handler_interface.h" -#include "application_manager/mock_event_dispatcher.h" +#include "application_manager/smart_object_keys.h" +#include "gtest/gtest.h" +#include "hmi/tts_is_ready_response.h" +#include "smart_objects/smart_object.h" namespace test { namespace components { @@ -53,14 +53,14 @@ namespace hmi_commands_test { namespace tts_is_ready_response { using ::testing::_; -using ::testing::Return; using ::testing::NiceMock; +using ::testing::Return; namespace am = ::application_manager; namespace strings = ::application_manager::strings; namespace hmi_response = am::hmi_response; +using am::commands::CommandImpl; using application_manager::commands::ResponseFromHMI; using sdl_rpc_plugin::commands::TTSIsReadyResponse; -using am::commands::CommandImpl; using test::components::event_engine_test::MockEventDispatcher; typedef std::shared_ptr ResponseFromHMIPtr; diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/ui_get_capabilities_response_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/ui_get_capabilities_response_test.cc index 31e4860d4ac..4683fc62c73 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/ui_get_capabilities_response_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/ui_get_capabilities_response_test.cc @@ -32,14 +32,14 @@ #include -#include "gtest/gtest.h" -#include "smart_objects/smart_object.h" -#include "interfaces/MOBILE_API.h" +#include "application_manager/commands/command_impl.h" +#include "application_manager/commands/commands_test.h" #include "application_manager/mock_hmi_capabilities.h" #include "application_manager/smart_object_keys.h" -#include "application_manager/commands/commands_test.h" -#include "application_manager/commands/command_impl.h" +#include "gtest/gtest.h" #include "hmi/ui_get_capabilities_response.h" +#include "interfaces/MOBILE_API.h" +#include "smart_objects/smart_object.h" namespace test { namespace components { @@ -51,9 +51,9 @@ using ::testing::NiceMock; namespace am = ::application_manager; namespace strings = am::strings; namespace hmi_response = am::hmi_response; +using am::commands::CommandImpl; using application_manager::commands::ResponseFromHMI; using sdl_rpc_plugin::commands::UIGetCapabilitiesResponse; -using am::commands::CommandImpl; typedef std::shared_ptr ResponseFromHMIPtr; typedef NiceMock< @@ -113,8 +113,9 @@ TEST_F(UIGetCapabilitiesResponseTest, SetSoftButton_SUCCESS) { ResponseFromHMIPtr command( CreateCommand(command_msg)); - smart_objects::SmartObject soft_button_capabilities_so = (*command_msg) - [strings::msg_params][hmi_response::soft_button_capabilities]; + smart_objects::SmartObject soft_button_capabilities_so = + (*command_msg)[strings::msg_params] + [hmi_response::soft_button_capabilities]; EXPECT_CALL(mock_hmi_capabilities_, set_soft_button_capabilities(soft_button_capabilities_so)); @@ -144,16 +145,48 @@ TEST_F(UIGetCapabilitiesResponseTest, SetHmiZone_SUCCESS) { TEST_F(UIGetCapabilitiesResponseTest, SetAudioPassThru_SUCCESS) { MessageSharedPtr command_msg = CreateCommandMsg(); (*command_msg)[strings::msg_params][strings::audio_pass_thru_capabilities] = + smart_objects::SmartObject(smart_objects::SmartType_Map); + + ResponseFromHMIPtr command( + CreateCommand(command_msg)); + + smart_objects::SmartObject audio_pass_thru_capabilities_so = + (*command_msg)[strings::msg_params] + [strings::audio_pass_thru_capabilities]; + + // hmi_capabilities will receive a list of capabilities, the first element + // being audio_pass_thru_capabilities_so + smart_objects::SmartObject audio_pass_thru_capabilities_list_so = + smart_objects::SmartObject(smart_objects::SmartType_Array); + audio_pass_thru_capabilities_list_so[0] = audio_pass_thru_capabilities_so; + EXPECT_CALL( + mock_hmi_capabilities_, + set_audio_pass_thru_capabilities(audio_pass_thru_capabilities_list_so)); + + command->Run(); +} + +TEST_F(UIGetCapabilitiesResponseTest, SetAudioPassThruList_SUCCESS) { + MessageSharedPtr command_msg = CreateCommandMsg(); + + // if both audioPassThruCapabilities and audioPassThruCapabilitiesList are + // supplied, audioPassThruCapabilitiesList should be used + smart_objects::SmartObject audio_pass_thru_capabilities_so = + smart_objects::SmartObject(smart_objects::SmartType_Map); + smart_objects::SmartObject audio_pass_thru_capabilities_list_so = smart_objects::SmartObject(smart_objects::SmartType_Array); + (*command_msg)[strings::msg_params][strings::audio_pass_thru_capabilities] = + audio_pass_thru_capabilities_so; + (*command_msg)[strings::msg_params] + [strings::audio_pass_thru_capabilities_list] = + audio_pass_thru_capabilities_list_so; ResponseFromHMIPtr command( CreateCommand(command_msg)); - smart_objects::SmartObject audio_pass_thru_capabilities_so = (*command_msg) - [strings::msg_params][strings::audio_pass_thru_capabilities]; EXPECT_CALL( mock_hmi_capabilities_, - set_audio_pass_thru_capabilities(audio_pass_thru_capabilities_so)); + set_audio_pass_thru_capabilities(audio_pass_thru_capabilities_list_so)); command->Run(); } @@ -277,7 +310,7 @@ TEST_F(UIGetCapabilitiesResponseTest, SetVideoStreamingCapability_SUCCESS) { video_streaming_capability[strings::preferred_resolution] [strings::resolution_width] = 800; video_streaming_capability[strings::preferred_resolution] - [strings::resolution_height] = 350; + [strings::resolution_height] = 354; video_streaming_capability[strings::max_bitrate] = 10000; @@ -295,6 +328,12 @@ TEST_F(UIGetCapabilitiesResponseTest, SetVideoStreamingCapability_SUCCESS) { video_streaming_capability[strings::haptic_spatial_data_supported] = true; + video_streaming_capability[strings::diagonal_screen_size] = 7.47; + + video_streaming_capability[strings::pixel_per_inch] = 117.f; + + video_streaming_capability[strings::scale] = 1.f; + ResponseFromHMIPtr command( CreateCommand(command_msg)); @@ -304,6 +343,25 @@ TEST_F(UIGetCapabilitiesResponseTest, SetVideoStreamingCapability_SUCCESS) { command->Run(); } +TEST_F(UIGetCapabilitiesResponseTest, SetSystemDisplayCapabilities_SUCCESS) { + MessageSharedPtr command_msg = CreateCommandMsg(); + (*command_msg)[strings::msg_params][strings::system_capabilities] = + smart_objects::SmartObject(smart_objects::SmartType_Map); + + ResponseFromHMIPtr command( + CreateCommand(command_msg)); + + const auto& display_capability_so = + (*command_msg)[strings::msg_params][strings::system_capabilities] + [strings::display_capabilities]; + + EXPECT_CALL(mock_hmi_capabilities_, + set_system_display_capabilities(display_capability_so)); + + ASSERT_TRUE(command->Init()); + command->Run(); +} + } // namespace ui_get_capabilities_response } // namespace hmi_commands_test } // namespace commands_test diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/ui_get_language_response_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/ui_get_language_response_test.cc index de69c5de5c0..7e8040543d3 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/ui_get_language_response_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/ui_get_language_response_test.cc @@ -30,13 +30,13 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include "gtest/gtest.h" #include "hmi/ui_get_language_response.h" -#include "application_manager/smart_object_keys.h" #include "application_manager/commands/commands_test.h" -#include "application_manager/mock_hmi_capabilities.h" -#include "application_manager/mock_event_dispatcher.h" #include "application_manager/mock_application_manager.h" +#include "application_manager/mock_event_dispatcher.h" +#include "application_manager/mock_hmi_capabilities.h" +#include "application_manager/smart_object_keys.h" +#include "gtest/gtest.h" namespace test { namespace components { @@ -47,8 +47,8 @@ namespace ui_get_language_response { using sdl_rpc_plugin::commands::UIGetLanguageResponse; using test::components::event_engine_test::MockEventDispatcher; using testing::_; -using testing::ReturnRef; using ::testing::NiceMock; +using testing::ReturnRef; namespace strings = application_manager::strings; namespace hmi_response = application_manager::hmi_response; diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/ui_get_supported_languages_response_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/ui_get_supported_languages_response_test.cc index 5626e2b0eed..10cf244bcf3 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/ui_get_supported_languages_response_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/ui_get_supported_languages_response_test.cc @@ -33,15 +33,15 @@ #include #include -#include "gtest/gtest.h" -#include "smart_objects/smart_object.h" -#include "application_manager/smart_object_keys.h" #include "application_manager/application.h" #include "application_manager/commands/commands_test.h" -#include "application_manager/mock_hmi_capabilities.h" #include "application_manager/mock_application_manager.h" -#include "hmi/ui_get_supported_languages_response.h" +#include "application_manager/mock_hmi_capabilities.h" #include "application_manager/policies/mock_policy_handler_interface.h" +#include "application_manager/smart_object_keys.h" +#include "gtest/gtest.h" +#include "hmi/ui_get_supported_languages_response.h" +#include "smart_objects/smart_object.h" namespace test { namespace components { @@ -49,8 +49,8 @@ namespace commands_test { namespace hmi_commands_test { namespace ui_get_supported_languages_response { -using ::testing::Return; using ::testing::NiceMock; +using ::testing::Return; namespace am = ::application_manager; namespace strings = ::application_manager::strings; namespace hmi_response = am::hmi_response; @@ -107,7 +107,8 @@ TEST_F(UIGetSupportedLanguagesResponseTest, RUN_UNSUCCESS) { CreateCommand(command_msg)); EXPECT_CALL(mock_hmi_capabilities_, - set_ui_supported_languages(supported_languages)).Times(0); + set_ui_supported_languages(supported_languages)) + .Times(0); command->Run(); diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/ui_is_ready_request_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/ui_is_ready_request_test.cc index 70fc80bbd14..837b8438dc1 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/ui_is_ready_request_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/ui_is_ready_request_test.cc @@ -34,16 +34,16 @@ #include "gtest/gtest.h" -#include "smart_objects/smart_object.h" -#include "application_manager/smart_object_keys.h" #include "application_manager/commands/command_request_test.h" -#include "application_manager/mock_application_manager.h" +#include "application_manager/event_engine/event.h" #include "application_manager/hmi_interfaces.h" -#include "application_manager/mock_hmi_interface.h" +#include "application_manager/mock_application_manager.h" #include "application_manager/mock_hmi_capabilities.h" -#include "application_manager/policies/mock_policy_handler_interface.h" +#include "application_manager/mock_hmi_interface.h" #include "application_manager/mock_message_helper.h" -#include "application_manager/event_engine/event.h" +#include "application_manager/policies/mock_policy_handler_interface.h" +#include "application_manager/smart_object_keys.h" +#include "smart_objects/smart_object.h" namespace test { namespace components { @@ -53,12 +53,12 @@ namespace ui_is_ready_request { namespace am = ::application_manager; +using am::commands::MessageSharedPtr; +using am::event_engine::Event; +using sdl_rpc_plugin::commands::UIIsReadyRequest; using ::testing::_; using ::testing::Return; using ::testing::ReturnRef; -using am::commands::MessageSharedPtr; -using sdl_rpc_plugin::commands::UIIsReadyRequest; -using am::event_engine::Event; typedef std::shared_ptr UIIsReadyRequestPtr; diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/ui_is_ready_response_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/ui_is_ready_response_test.cc index cccdbdc44d1..44b95040556 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/ui_is_ready_response_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/ui_is_ready_response_test.cc @@ -33,12 +33,12 @@ #include #include -#include "gtest/gtest.h" -#include "smart_objects/smart_object.h" #include "application_manager/commands/commands_test.h" +#include "application_manager/mock_event_dispatcher.h" #include "application_manager/mock_hmi_capabilities.h" +#include "gtest/gtest.h" #include "hmi/ui_is_ready_response.h" -#include "application_manager/mock_event_dispatcher.h" +#include "smart_objects/smart_object.h" namespace test { namespace components { @@ -46,8 +46,8 @@ namespace commands_test { namespace hmi_commands_test { namespace ui_is_ready_response { -using ::testing::Return; using ::testing::NiceMock; +using ::testing::Return; namespace am = ::application_manager; namespace strings = ::application_manager::strings; namespace hmi_response = am::hmi_response; diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/update_device_list_request_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/update_device_list_request_test.cc index c5667029980..31c03a7ed55 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/update_device_list_request_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/update_device_list_request_test.cc @@ -32,20 +32,20 @@ #include -#include "gtest/gtest.h" -#include "smart_objects/smart_object.h" -#include "interfaces/HMI_API.h" -#include "application_manager/smart_object_keys.h" -#include "application_manager/commands/commands_test.h" -#include "application_manager/commands/command_impl.h" #include "application_manager/application_manager.h" #include "application_manager/application_manager_impl.h" -#include "application_manager/mock_event_dispatcher.h" -#include "application_manager/mock_application.h" +#include "application_manager/commands/command_impl.h" +#include "application_manager/commands/commands_test.h" #include "application_manager/event_engine/event.h" -#include "application_manager/request_controller_settings.h" +#include "application_manager/mock_application.h" #include "application_manager/mock_application_manager_settings.h" +#include "application_manager/mock_event_dispatcher.h" +#include "application_manager/request_controller_settings.h" +#include "application_manager/smart_object_keys.h" +#include "gtest/gtest.h" #include "hmi/update_device_list_request.h" +#include "interfaces/HMI_API.h" +#include "smart_objects/smart_object.h" namespace test { namespace components { @@ -53,18 +53,18 @@ namespace commands_test { namespace hmi_commands_test { namespace update_device_list_request { -using testing::_; -using testing::ReturnRef; -using testing::Return; -using test::components::event_engine_test::MockEventDispatcher; using ::test::components::application_manager_test:: MockApplicationManagerSettings; +using test::components::event_engine_test::MockEventDispatcher; +using testing::_; +using testing::Return; +using testing::ReturnRef; namespace am = ::application_manager; namespace strings = am::strings; namespace hmi_response = am::hmi_response; +using am::commands::CommandImpl; using am::event_engine::Event; using sdl_rpc_plugin::commands::UpdateDeviceListRequest; -using am::commands::CommandImpl; typedef std::shared_ptr UpdateDeviceListRequestPtr; diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/update_sdl_request_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/update_sdl_request_test.cc index af3b9bebf6d..96f3b38fbf0 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/update_sdl_request_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/update_sdl_request_test.cc @@ -33,13 +33,13 @@ #include #include -#include "gtest/gtest.h" -#include "smart_objects/smart_object.h" -#include "application_manager/smart_object_keys.h" -#include "application_manager/commands/commands_test.h" #include "application_manager/application.h" +#include "application_manager/commands/commands_test.h" #include "application_manager/policies/mock_policy_handler_interface.h" +#include "application_manager/smart_object_keys.h" +#include "gtest/gtest.h" #include "hmi/update_sdl_request.h" +#include "smart_objects/smart_object.h" namespace test { namespace components { @@ -47,8 +47,8 @@ namespace commands_test { namespace hmi_commands_test { namespace update_sdl_request { -using ::testing::ReturnRef; using ::testing::NiceMock; +using ::testing::ReturnRef; namespace am = ::application_manager; namespace strings = ::application_manager::strings; using sdl_rpc_plugin::commands::UpdateSDLRequest; diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/update_sdl_response_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/update_sdl_response_test.cc index 93c49724ce5..62ffc6be4d8 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/update_sdl_response_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/update_sdl_response_test.cc @@ -33,12 +33,12 @@ #include #include -#include "gtest/gtest.h" -#include "smart_objects/smart_object.h" -#include "application_manager/smart_object_keys.h" -#include "application_manager/commands/commands_test.h" #include "application_manager/application.h" +#include "application_manager/commands/commands_test.h" +#include "application_manager/smart_object_keys.h" +#include "gtest/gtest.h" #include "hmi/update_sdl_response.h" +#include "smart_objects/smart_object.h" namespace test { namespace components { @@ -48,8 +48,8 @@ namespace update_sdl_response { namespace am = ::application_manager; namespace strings = ::application_manager::strings; -using sdl_rpc_plugin::commands::UpdateSDLResponse; using am::commands::CommandImpl; +using sdl_rpc_plugin::commands::UpdateSDLResponse; typedef std::shared_ptr UpdateSDLResponsePtr; diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/vr_get_capabilities_response_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/vr_get_capabilities_response_test.cc index 15d38d4ef3c..21acf2bb709 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/vr_get_capabilities_response_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/vr_get_capabilities_response_test.cc @@ -32,14 +32,14 @@ #include -#include "gtest/gtest.h" -#include "smart_objects/smart_object.h" -#include "interfaces/MOBILE_API.h" +#include "application_manager/commands/command_impl.h" +#include "application_manager/commands/commands_test.h" #include "application_manager/mock_hmi_capabilities.h" #include "application_manager/smart_object_keys.h" -#include "application_manager/commands/commands_test.h" -#include "application_manager/commands/command_impl.h" +#include "gtest/gtest.h" #include "hmi/vr_get_capabilities_response.h" +#include "interfaces/MOBILE_API.h" +#include "smart_objects/smart_object.h" namespace test { namespace components { @@ -51,8 +51,8 @@ using ::testing::NiceMock; namespace am = ::application_manager; namespace strings = am::strings; namespace hmi_response = am::hmi_response; -using sdl_rpc_plugin::commands::VRGetCapabilitiesResponse; using am::commands::CommandImpl; +using sdl_rpc_plugin::commands::VRGetCapabilitiesResponse; typedef std::shared_ptr VRGetCapabilitiesResponsePtr; typedef NiceMock< diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/vr_get_language_response_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/vr_get_language_response_test.cc index 05ed1869634..8b00b4ddede 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/vr_get_language_response_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/vr_get_language_response_test.cc @@ -30,13 +30,13 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include "gtest/gtest.h" #include "hmi/vr_get_language_response.h" -#include "application_manager/smart_object_keys.h" #include "application_manager/commands/commands_test.h" -#include "application_manager/mock_hmi_capabilities.h" -#include "application_manager/mock_event_dispatcher.h" #include "application_manager/mock_application_manager.h" +#include "application_manager/mock_event_dispatcher.h" +#include "application_manager/mock_hmi_capabilities.h" +#include "application_manager/smart_object_keys.h" +#include "gtest/gtest.h" namespace test { namespace components { @@ -47,8 +47,8 @@ namespace vr_get_language_response { using sdl_rpc_plugin::commands::VRGetLanguageResponse; using test::components::event_engine_test::MockEventDispatcher; using testing::_; -using testing::ReturnRef; using ::testing::NiceMock; +using testing::ReturnRef; namespace strings = application_manager::strings; namespace hmi_response = application_manager::hmi_response; diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/vr_get_supported_languages_response_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/vr_get_supported_languages_response_test.cc index 56b11ad440f..b81823624cd 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/vr_get_supported_languages_response_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/vr_get_supported_languages_response_test.cc @@ -33,15 +33,15 @@ #include #include -#include "gtest/gtest.h" -#include "smart_objects/smart_object.h" -#include "application_manager/smart_object_keys.h" #include "application_manager/application.h" #include "application_manager/commands/commands_test.h" -#include "application_manager/mock_hmi_capabilities.h" #include "application_manager/mock_application_manager.h" -#include "hmi/vr_get_supported_languages_response.h" +#include "application_manager/mock_hmi_capabilities.h" #include "application_manager/policies/mock_policy_handler_interface.h" +#include "application_manager/smart_object_keys.h" +#include "gtest/gtest.h" +#include "hmi/vr_get_supported_languages_response.h" +#include "smart_objects/smart_object.h" namespace test { namespace components { @@ -49,8 +49,8 @@ namespace commands_test { namespace hmi_commands_test { namespace vr_get_supported_languages_response { -using ::testing::Return; using ::testing::NiceMock; +using ::testing::Return; namespace am = ::application_manager; namespace strings = ::application_manager::strings; namespace hmi_response = am::hmi_response; @@ -107,7 +107,8 @@ TEST_F(VRGetSupportedLanguagesResponseTest, RUN_UNSUCCESS) { CreateCommand(command_msg)); EXPECT_CALL(mock_hmi_capabilities_, - set_vr_supported_languages(supported_languages)).Times(0); + set_vr_supported_languages(supported_languages)) + .Times(0); command->Run(); diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/vr_is_ready_request_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/vr_is_ready_request_test.cc index 259fd0b92bb..9bb8e4c2d5d 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/vr_is_ready_request_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/vr_is_ready_request_test.cc @@ -34,15 +34,15 @@ #include "gtest/gtest.h" -#include "smart_objects/smart_object.h" -#include "application_manager/smart_object_keys.h" #include "application_manager/commands/command_request_test.h" -#include "application_manager/mock_application_manager.h" +#include "application_manager/event_engine/event.h" #include "application_manager/hmi_interfaces.h" -#include "application_manager/mock_hmi_interface.h" +#include "application_manager/mock_application_manager.h" #include "application_manager/mock_hmi_capabilities.h" +#include "application_manager/mock_hmi_interface.h" #include "application_manager/mock_message_helper.h" -#include "application_manager/event_engine/event.h" +#include "application_manager/smart_object_keys.h" +#include "smart_objects/smart_object.h" namespace test { namespace components { @@ -54,8 +54,8 @@ using ::testing::_; using ::testing::ReturnRef; namespace am = ::application_manager; using am::commands::MessageSharedPtr; -using sdl_rpc_plugin::commands::VRIsReadyRequest; using am::event_engine::Event; +using sdl_rpc_plugin::commands::VRIsReadyRequest; typedef std::shared_ptr VRIsReadyRequestPtr; diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/vr_is_ready_response_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/vr_is_ready_response_test.cc index 0e56f5b483b..8b7b0a94f44 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/vr_is_ready_response_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/vr_is_ready_response_test.cc @@ -33,12 +33,12 @@ #include #include -#include "gtest/gtest.h" -#include "smart_objects/smart_object.h" #include "application_manager/commands/commands_test.h" +#include "application_manager/mock_event_dispatcher.h" #include "application_manager/mock_hmi_capabilities.h" +#include "gtest/gtest.h" #include "hmi/vr_is_ready_response.h" -#include "application_manager/mock_event_dispatcher.h" +#include "smart_objects/smart_object.h" namespace test { namespace components { @@ -46,8 +46,8 @@ namespace commands_test { namespace hmi_commands_test { namespace vr_is_ready_response { -using ::testing::Return; using ::testing::NiceMock; +using ::testing::Return; namespace am = ::application_manager; namespace strings = ::application_manager::strings; namespace hmi_response = am::hmi_response; 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 0023368b5a1..b11312eb339 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 @@ -32,8 +32,8 @@ #include #include -#include #include +#include #include "mobile/add_command_request.h" @@ -41,16 +41,16 @@ #include "utils/helpers.h" -#include "smart_objects/smart_object.h" -#include "utils/custom_string.h" #include "application_manager/commands/command_request_test.h" -#include "application_manager/smart_object_keys.h" +#include "application_manager/event_engine/event.h" #include "application_manager/mock_application.h" #include "application_manager/mock_application_manager.h" -#include "application_manager/mock_message_helper.h" -#include "application_manager/event_engine/event.h" -#include "application_manager/mock_hmi_interface.h" #include "application_manager/mock_help_prompt_manager.h" +#include "application_manager/mock_hmi_interface.h" +#include "application_manager/mock_message_helper.h" +#include "application_manager/smart_object_keys.h" +#include "smart_objects/smart_object.h" +#include "utils/custom_string.h" namespace test { namespace components { @@ -60,17 +60,17 @@ namespace add_command_request { namespace am = application_manager; namespace am_test = application_manager_test; -using am::commands::CommandImpl; using am::ApplicationManager; -using am::commands::MessageSharedPtr; using am::ApplicationSharedPtr; -using ::testing::_; -using ::testing::Return; -using ::testing::InSequence; -using sdl_rpc_plugin::commands::AddCommandRequest; +using am::commands::CommandImpl; +using am::commands::MessageSharedPtr; +using am::event_engine::EventObserver; using ns_smart_device_link::ns_smart_objects::SmartObjectSPtr; +using sdl_rpc_plugin::commands::AddCommandRequest; using ::test::components::application_manager_test::MockApplication; -using am::event_engine::EventObserver; +using ::testing::_; +using ::testing::InSequence; +using ::testing::Return; using namespace smart_objects; namespace custom_str = utils::custom_string; diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/add_sub_menu_request_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/add_sub_menu_request_test.cc index ecaa436529e..a88a1ade691 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/add_sub_menu_request_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/add_sub_menu_request_test.cc @@ -35,14 +35,14 @@ #include "mobile/add_sub_menu_request.h" -#include "gtest/gtest.h" -#include "application_manager/commands/commands_test.h" #include "application_manager/commands/command_request_test.h" -#include "application_manager/mock_application_manager.h" -#include "application_manager/mock_application.h" -#include "application_manager/mock_message_helper.h" +#include "application_manager/commands/commands_test.h" #include "application_manager/event_engine/event.h" +#include "application_manager/mock_application.h" +#include "application_manager/mock_application_manager.h" #include "application_manager/mock_hmi_interface.h" +#include "application_manager/mock_message_helper.h" +#include "gtest/gtest.h" namespace test { namespace components { @@ -51,9 +51,9 @@ namespace mobile_commands_test { namespace add_sub_menu_request { namespace am = ::application_manager; -using sdl_rpc_plugin::commands::AddSubMenuRequest; using am::commands::MessageSharedPtr; using am::event_engine::Event; +using sdl_rpc_plugin::commands::AddSubMenuRequest; using ::testing::_; using ::testing::Return; diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/alert_maneuver_request_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/alert_maneuver_request_test.cc index 7d2dd0b2c28..e726616345b 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/alert_maneuver_request_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/alert_maneuver_request_test.cc @@ -35,20 +35,20 @@ #include "gtest/gtest.h" -#include "smart_objects/smart_object.h" -#include "application_manager/smart_object_keys.h" -#include "application_manager/commands/commands_test.h" -#include "application_manager/commands/command_request_test.h" #include "application_manager/application.h" -#include "application_manager/mock_application_manager.h" +#include "application_manager/commands/command_request_test.h" +#include "application_manager/commands/commands_test.h" +#include "application_manager/event_engine/event.h" #include "application_manager/mock_application.h" +#include "application_manager/mock_application_manager.h" +#include "application_manager/mock_hmi_interface.h" #include "application_manager/mock_message_helper.h" -#include "application_manager/event_engine/event.h" -#include "mobile/alert_maneuver_request.h" -#include "interfaces/MOBILE_API.h" -#include "application_manager/policies/policy_handler_interface.h" #include "application_manager/policies/mock_policy_handler_interface.h" -#include "application_manager/mock_hmi_interface.h" +#include "application_manager/policies/policy_handler_interface.h" +#include "application_manager/smart_object_keys.h" +#include "interfaces/MOBILE_API.h" +#include "mobile/alert_maneuver_request.h" +#include "smart_objects/smart_object.h" namespace test { namespace components { @@ -60,9 +60,9 @@ using ::testing::_; using ::testing::Return; using ::testing::ReturnRef; namespace am = ::application_manager; -using sdl_rpc_plugin::commands::AlertManeuverRequest; using am::commands::MessageSharedPtr; using am::event_engine::Event; +using sdl_rpc_plugin::commands::AlertManeuverRequest; typedef std::shared_ptr CommandPtr; diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/alert_request_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/alert_request_test.cc index a66d0d557f2..dc7731bfc83 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/alert_request_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/alert_request_test.cc @@ -31,19 +31,19 @@ */ #include -#include #include +#include #include "mobile/alert_request.h" -#include "gtest/gtest.h" #include "application_manager/commands/command_request_test.h" +#include "application_manager/event_engine/event.h" #include "application_manager/mock_application.h" #include "application_manager/mock_application_manager.h" -#include "application_manager/mock_message_helper.h" -#include "application_manager/event_engine/event.h" #include "application_manager/mock_hmi_interface.h" +#include "application_manager/mock_message_helper.h" #include "application_manager/policies/mock_policy_handler_interface.h" +#include "gtest/gtest.h" namespace test { namespace components { @@ -52,12 +52,12 @@ namespace mobile_commands_test { namespace alert_request { namespace am = application_manager; -using sdl_rpc_plugin::commands::AlertRequest; +using am::MockMessageHelper; using am::commands::CommandImpl; using am::commands::MessageSharedPtr; -using am::MockMessageHelper; using am::event_engine::Event; using policy_test::MockPolicyHandlerInterface; +using sdl_rpc_plugin::commands::AlertRequest; using ::testing::_; using ::testing::Return; using ::testing::ReturnRef; @@ -73,6 +73,8 @@ const uint32_t kDefaultTimeout = 1000u; const uint32_t kCorrelationId = 2u; const mobile_apis::FunctionID::eType kFunctionId = mobile_apis::FunctionID::AlertID; +const am::WindowID kDefaultWindowId = + mobile_apis::PredefinedWindows::DEFAULT_WINDOW; } // namespace class AlertRequestTest : public CommandRequestTest { @@ -138,9 +140,9 @@ class AlertRequestTest : public CommandRequestTest { *mock_app_, AreCommandLimitsExceeded(kFunctionId, am::TLimitSource::POLICY_TABLE)) .WillByDefault(Return(false)); - ON_CALL(*mock_app_, hmi_level()) + ON_CALL(*mock_app_, hmi_level(kDefaultWindowId)) .WillByDefault(Return(mobile_apis::HMILevel::HMI_FULL)); - ON_CALL(*mock_app_, hmi_level()) + ON_CALL(*mock_app_, hmi_level(kDefaultWindowId)) .WillByDefault(Return(mobile_apis::HMILevel::HMI_BACKGROUND)); } @@ -155,7 +157,8 @@ class AlertRequestTest : public CommandRequestTest { } void ExpectCallHmiLevel(const mobile_apis::HMILevel::eType level) { - EXPECT_CALL(*mock_app_, hmi_level()).WillRepeatedly(Return(level)); + EXPECT_CALL(*mock_app_, hmi_level(kDefaultWindowId)) + .WillRepeatedly(Return(level)); } void ExpectManageMobileCommandWithResultCode( @@ -477,9 +480,10 @@ TEST_F(AlertRequestTest, DISABLED_OnEvent_TTSWarnings_SUCCESS) { (*msg_)[am::strings::msg_params][am::strings::tts_chunks], _, _)) .WillOnce(Return(mobile_apis::Result::SUCCESS)); - EXPECT_CALL(mock_rpc_service_, - ManageHMICommand(HMIResultCodeIs(hmi_apis::FunctionID::TTS_Speak), - _)).WillOnce(Return(true)); + EXPECT_CALL( + mock_rpc_service_, + ManageHMICommand(HMIResultCodeIs(hmi_apis::FunctionID::TTS_Speak), _)) + .WillOnce(Return(true)); CommandPtr command(CreateCommand(msg_)); command->Run(); @@ -508,9 +512,10 @@ TEST_F(AlertRequestTest, DISABLED_OnEvent_TTSUnsupportedResource_SUCCESS) { VerifyTtsFiles( (*msg_)[am::strings::msg_params][am::strings::tts_chunks], _, _)) .WillOnce(Return(mobile_apis::Result::SUCCESS)); - EXPECT_CALL(mock_rpc_service_, - ManageHMICommand(HMIResultCodeIs(hmi_apis::FunctionID::TTS_Speak), - _)).WillOnce(Return(true)); + EXPECT_CALL( + mock_rpc_service_, + ManageHMICommand(HMIResultCodeIs(hmi_apis::FunctionID::TTS_Speak), _)) + .WillOnce(Return(true)); CommandPtr command(CreateCommand(msg_)); command->Run(); @@ -641,9 +646,10 @@ TEST_F(AlertRequestTest, OnEvent_TTSSuccesUiAlertInvalidEnum_SUCCESS) { VerifyTtsFiles( (*msg_)[am::strings::msg_params][am::strings::tts_chunks], _, _)) .WillOnce(Return(mobile_apis::Result::SUCCESS)); - EXPECT_CALL(mock_rpc_service_, - ManageHMICommand(HMIResultCodeIs(hmi_apis::FunctionID::TTS_Speak), - _)).WillOnce(Return(true)); + EXPECT_CALL( + mock_rpc_service_, + ManageHMICommand(HMIResultCodeIs(hmi_apis::FunctionID::TTS_Speak), _)) + .WillOnce(Return(true)); CommandPtr command(CreateCommand(msg_)); command->Run(); @@ -690,9 +696,10 @@ TEST_F(AlertRequestTest, DISABLED_OnEvent_TTSAbortedUiAlertNotSent_SUCCESS) { VerifyTtsFiles( (*msg_)[am::strings::msg_params][am::strings::tts_chunks], _, _)) .WillOnce(Return(mobile_apis::Result::SUCCESS)); - EXPECT_CALL(mock_rpc_service_, - ManageHMICommand(HMIResultCodeIs(hmi_apis::FunctionID::TTS_Speak), - _)).WillOnce(Return(true)); + EXPECT_CALL( + mock_rpc_service_, + ManageHMICommand(HMIResultCodeIs(hmi_apis::FunctionID::TTS_Speak), _)) + .WillOnce(Return(true)); CommandPtr command(CreateCommand(msg_)); command->Run(); diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/change_registration_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/change_registration_test.cc index 58755c8b361..4394c6fe5e9 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/change_registration_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/change_registration_test.cc @@ -31,25 +31,25 @@ */ #include -#include #include +#include #include "mobile/change_registration_request.h" -#include "gtest/gtest.h" -#include "utils/helpers.h" -#include "utils/custom_string.h" -#include "smart_objects/smart_object.h" #include "application_manager/commands/command_request_test.h" -#include "application_manager/smart_object_keys.h" -#include "policy/policy_regular/policy/usage_statistics/mock_statistics_manager.h" +#include "application_manager/event_engine/event.h" #include "application_manager/mock_application.h" #include "application_manager/mock_application_manager.h" -#include "application_manager/mock_message_helper.h" #include "application_manager/mock_hmi_capabilities.h" -#include "application_manager/event_engine/event.h" #include "application_manager/mock_hmi_interface.h" +#include "application_manager/mock_message_helper.h" #include "application_manager/policies/mock_policy_handler_interface.h" +#include "application_manager/smart_object_keys.h" +#include "gtest/gtest.h" +#include "policy/policy_regular/policy/usage_statistics/mock_statistics_manager.h" +#include "smart_objects/smart_object.h" +#include "utils/custom_string.h" +#include "utils/helpers.h" namespace test { namespace components { @@ -58,18 +58,18 @@ namespace mobile_commands_test { namespace change_registration_request { namespace am = application_manager; -using am::commands::CommandImpl; using am::ApplicationManager; -using am::commands::MessageSharedPtr; using am::ApplicationSharedPtr; using am::MockMessageHelper; +using am::commands::CommandImpl; +using am::commands::MessageSharedPtr; +using policy_test::MockPolicyHandlerInterface; +using sdl_rpc_plugin::commands::ChangeRegistrationRequest; +using ::test::components::application_manager_test::MockApplication; using ::testing::_; using ::testing::Return; using ::testing::ReturnRef; using ::testing::SetArgPointee; -using sdl_rpc_plugin::commands::ChangeRegistrationRequest; -using policy_test::MockPolicyHandlerInterface; -using ::test::components::application_manager_test::MockApplication; namespace custom_str = utils::custom_string; namespace strings = ::application_manager::strings; 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 3abda892349..73a00086243 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 @@ -31,24 +31,24 @@ */ #include -#include #include +#include #include "mobile/create_interaction_choice_set_request.h" #include "mobile/create_interaction_choice_set_response.h" -#include "gtest/gtest.h" -#include "utils/helpers.h" -#include "smart_objects/smart_object.h" -#include "utils/custom_string.h" #include "application_manager/commands/command_request_test.h" -#include "application_manager/smart_object_keys.h" +#include "application_manager/event_engine/event.h" #include "application_manager/mock_application.h" #include "application_manager/mock_application_manager.h" -#include "application_manager/mock_message_helper.h" -#include "application_manager/event_engine/event.h" -#include "application_manager/mock_hmi_interface.h" #include "application_manager/mock_hmi_capabilities.h" +#include "application_manager/mock_hmi_interface.h" +#include "application_manager/mock_message_helper.h" +#include "application_manager/smart_object_keys.h" +#include "gtest/gtest.h" +#include "smart_objects/smart_object.h" +#include "utils/custom_string.h" +#include "utils/helpers.h" namespace test { namespace components { @@ -57,18 +57,18 @@ namespace mobile_commands_test { namespace create_interaction_choice_set_request { namespace am = application_manager; -using am::commands::CommandImpl; using am::ApplicationManager; -using am::commands::MessageSharedPtr; using am::ApplicationSharedPtr; using am::MockMessageHelper; -using ::testing::_; -using ::testing::Return; -using ::testing::ReturnRef; -using ::testing::AtLeast; +using am::commands::CommandImpl; +using am::commands::MessageSharedPtr; using sdl_rpc_plugin::commands::CreateInteractionChoiceSetRequest; using sdl_rpc_plugin::commands::CreateInteractionChoiceSetResponse; using ::test::components::application_manager_test::MockApplication; +using ::testing::_; +using ::testing::AtLeast; +using ::testing::Return; +using ::testing::ReturnRef; namespace custom_str = utils::custom_string; namespace strings = ::application_manager::strings; @@ -920,4 +920,4 @@ TEST_F(CreateInteractionChoiceSetRequestTest, Run_ErrorFromHmiFalse_UNSUCCESS) { } // namespace mobile_commands_test } // namespace commands_test } // namespace components -} // namespace tests +} // namespace test diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/create_window_request_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/create_window_request_test.cc new file mode 100644 index 00000000000..905c6ceb720 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/create_window_request_test.cc @@ -0,0 +1,460 @@ +/* + * Copyright (c) 2019, 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 + +#include "mobile/create_window_request.h" + +#include "application_manager/commands/command_request_test.h" +#include "application_manager/event_engine/event.h" +#include "application_manager/hmi_state.h" +#include "application_manager/mock_application.h" +#include "application_manager/mock_application_manager.h" +#include "application_manager/mock_hmi_interface.h" +#include "application_manager/mock_message_helper.h" +#include "application_manager/mock_state_controller.h" +#include "gtest/gtest.h" +#include "interfaces/MOBILE_API.h" + +namespace test { +namespace components { +namespace commands_test { +namespace mobile_commands_test { +namespace create_window_request { + +namespace am = application_manager; +using am::MockMessageHelper; +using am::commands::CommandImpl; +using am::commands::MessageSharedPtr; +using sdl_rpc_plugin::commands::CreateWindowRequest; +using namespace mobile_apis::PredefinedWindows; +using am::commands::Command; +using application_manager::WindowID; +using test::components::application_manager_test::MockStateController; +using test::components::policy_test::MockPolicyHandlerInterface; +using ::testing::_; +using ::testing::Return; +using ::testing::ReturnRef; + +namespace { +const uint32_t kAppId = 1u; +const uint32_t kConnectionKey = 2u; +const int32_t kFunctionID = mobile_apis::FunctionID::CreateWindowID; +const WindowID kTestWindowId = 12; +const WindowID kDuplicateWindowID = 13; +const char* const kWindowName = "WindowName"; +const utils::custom_string::CustomString kAppName("TestApp"); +} // namespace + +MATCHER_P2(CheckMessageToMobile, result_code, success, "") { + const bool is_success = + (*arg)[am::strings::msg_params][am::strings::success].asBool() == success; + + const bool is_result_code_correct = + (*arg)[am::strings::msg_params][am::strings::result_code].asInt() == + static_cast(result_code); + return is_success && is_result_code_correct; +} + +class CreateWindowRequestTest + : public CommandRequestTest { + public: + CreateWindowRequestTest() { + mock_app_ = CreateMockApp(); + ON_CALL(app_mngr_, application(kConnectionKey)) + .WillByDefault(Return(mock_app_)); + } + + protected: + MessageSharedPtr CreateMsgParams() { + auto msg = CreateMessage(); + (*msg)[am::strings::params][am::strings::connection_key] = kConnectionKey; + (*msg)[am::strings::params][am::strings::function_id] = kFunctionID; + return msg; + } + + void SetupHelperApplyWindowInitialState(const MockAppPtr& app, + const MessageSharedPtr& msg) { + am::HmiStatePtr state(new am::HmiState(app, app_mngr_)); + const auto window_type = static_cast( + (*msg)[am::strings::msg_params][am::strings::window_type].asInt()); + const auto window_id = static_cast( + (*msg)[am::strings::msg_params][am::strings::window_id].asInt()); + const auto window_name = + (*msg)[am::strings::msg_params][am::strings::window_name].asString(); + + state->set_window_type(window_type); + state->set_hmi_level(mobile_apis::HMILevel::INVALID_ENUM); + state->set_audio_streaming_state( + mobile_apis::AudioStreamingState::INVALID_ENUM); + state->set_video_streaming_state( + mobile_apis::VideoStreamingState::INVALID_ENUM); + state->set_system_context(mobile_apis::SystemContext::INVALID_ENUM); + ApplicationSharedPtr AppPtr = app; + ON_CALL(app_mngr_, + CreateRegularState(AppPtr, + window_type, + mobile_apis::HMILevel::INVALID_ENUM, + mobile_apis::AudioStreamingState::INVALID_ENUM, + mobile_apis::VideoStreamingState::INVALID_ENUM, + mobile_apis::SystemContext::INVALID_ENUM)) + .WillByDefault(Return(state)); + ON_CALL(*mock_app_, SetInitialState(kTestWindowId, window_name, state)) + .WillByDefault(Return()); + ON_CALL(app_mngr_, state_controller()) + .WillByDefault(ReturnRef(mock_state_controller)); + ON_CALL( + mock_state_controller, + OnAppWindowAdded( + AppPtr, window_id, window_type, mobile_apis::HMILevel::HMI_NONE)) + .WillByDefault(Return()); + } + + void SetUp() OVERRIDE { + using namespace application_manager; + display_capabilities_ = std::make_shared( + smart_objects::SmartType_Array); + + smart_objects::SmartObject window_type_supported( + smart_objects::SmartType_Array); + + const uint32_t maximum_widgets_amount = 4; + smart_objects::SmartObject maximum_widgets(smart_objects::SmartType_Map); + maximum_widgets[strings::window_type] = mobile_apis::WindowType::WIDGET; + maximum_widgets[strings::maximum_number_of_windows] = + maximum_widgets_amount; + + window_type_supported[window_type_supported.length()] = maximum_widgets; + + (*display_capabilities_)[0][strings::window_type_supported] = + window_type_supported; + + ON_CALL(*mock_app_, display_capabilities()) + .WillByDefault(Return(display_capabilities_)); + + ON_CALL(mock_hmi_capabilities_, system_display_capabilities()) + .WillByDefault(Return(display_capabilities_)); + + window_params_map_lock_ptr_ = std::make_shared(); + + DataAccessor window_params_map( + test_window_params_map_, window_params_map_lock_ptr_); + ON_CALL(*mock_app_, window_optional_params_map()) + .WillByDefault(Return(window_params_map)); + } + + MockAppPtr mock_app_; + NiceMock mock_state_controller; + std::shared_ptr window_params_map_lock_ptr_; + application_manager::WindowParamsMap test_window_params_map_; + smart_objects::SmartObjectSPtr display_capabilities_; +}; + +TEST_F(CreateWindowRequestTest, WindowID_ExpectDefaultWindowID) { + auto msg = CreateMsgParams(); + const auto command = CreateCommand(msg); + EXPECT_EQ(mobile_apis::PredefinedWindows::DEFAULT_WINDOW, + command->window_id()); +} + +TEST_F(CreateWindowRequestTest, + Run_AppDoesNotExist_ExpectAppNotRegisteredResponseToMobile) { + const auto result_code = mobile_apis::Result::APPLICATION_NOT_REGISTERED; + EXPECT_CALL(mock_rpc_service_, + ManageMobileCommand(CheckMessageToMobile(result_code, false), + Command::CommandSource::SOURCE_SDL)) + .WillOnce(Return(true)); + EXPECT_CALL(app_mngr_, application(kConnectionKey)).WillOnce(Return(nullptr)); + + auto msg = CreateMsgParams(); + auto command = CreateCommand(msg); + EXPECT_TRUE(command->Init()); + command->Run(); +} + +TEST_F(CreateWindowRequestTest, + Run_WindowIDAlreadyExist_ExpectInvalidIDResponseToMobile) { + const auto result_code = mobile_apis::Result::INVALID_ID; + EXPECT_CALL(mock_rpc_service_, + ManageMobileCommand(CheckMessageToMobile(result_code, false), + Command::CommandSource::SOURCE_SDL)) + .WillOnce(Return(true)); + ON_CALL(*mock_app_, WindowIdExists(kTestWindowId)) + .WillByDefault(Return(true)); + + auto msg = CreateMsgParams(); + (*msg)[am::strings::msg_params][am::strings::window_id] = kTestWindowId; + + auto command = CreateCommand(msg); + EXPECT_TRUE(command->Init()); + command->Run(); +} + +TEST_F(CreateWindowRequestTest, + Run_CreateWindowForMAINWindowType_ExpectInvalidDataResponseToMobile) { + const auto result_code = mobile_apis::Result::INVALID_DATA; + EXPECT_CALL(mock_rpc_service_, + ManageMobileCommand(CheckMessageToMobile(result_code, false), + Command::CommandSource::SOURCE_SDL)) + .WillOnce(Return(true)); + ON_CALL(*mock_app_, WindowIdExists(kTestWindowId)) + .WillByDefault(Return(false)); + + auto msg = CreateMsgParams(); + (*msg)[am::strings::msg_params][am::strings::window_id] = kTestWindowId; + (*msg)[am::strings::msg_params][am::strings::window_type] = + mobile_apis::WindowType::eType::MAIN; + + auto command = CreateCommand(msg); + EXPECT_TRUE(command->Init()); + command->Run(); +} + +TEST_F( + CreateWindowRequestTest, + Run_DuplicateUpdatesFromNotExistingWindowId_ExpectInvalidDataResponseToMobile) { + const auto result_code = mobile_apis::Result::INVALID_DATA; + EXPECT_CALL(mock_rpc_service_, + ManageMobileCommand(CheckMessageToMobile(result_code, false), + Command::CommandSource::SOURCE_SDL)) + .WillOnce(Return(true)); + ON_CALL(*mock_app_, WindowIdExists(kTestWindowId)) + .WillByDefault(Return(false)); + ON_CALL(*mock_app_, WindowIdExists(kDuplicateWindowID)) + .WillByDefault(Return(false)); + + auto msg = CreateMsgParams(); + (*msg)[am::strings::msg_params][am::strings::window_id] = kTestWindowId; + (*msg)[am::strings::msg_params] + [am::strings::duplicate_updates_from_window_id] = kDuplicateWindowID; + + auto command = CreateCommand(msg); + EXPECT_TRUE(command->Init()); + command->Run(); +} + +TEST_F( + CreateWindowRequestTest, + Run_DuplicateUpdatesFromExistingWindowId_ExpectUICreateWindowIsSentToHMI) { + EXPECT_CALL( + mock_rpc_service_, + ManageHMICommand(HMIResultCodeIs(hmi_apis::FunctionID::UI_CreateWindow), + Command::CommandSource::SOURCE_SDL_TO_HMI)) + .WillOnce(Return(true)); + ON_CALL(*mock_app_, WindowIdExists(kTestWindowId)) + .WillByDefault(Return(false)); + ON_CALL(*mock_app_, WindowIdExists(kDuplicateWindowID)) + .WillByDefault(Return(true)); + ON_CALL(*mock_app_, name()).WillByDefault(ReturnRef(kAppName)); + ON_CALL(*mock_app_, GetWindowNames()) + .WillByDefault(Return(std::vector())); + + auto msg = CreateMsgParams(); + (*msg)[am::strings::msg_params][am::strings::window_id] = kTestWindowId; + (*msg)[am::strings::msg_params] + [am::strings::duplicate_updates_from_window_id] = kDuplicateWindowID; + (*msg)[am::strings::msg_params][am::strings::window_type] = + mobile_apis::WindowType::WIDGET; + + auto command = CreateCommand(msg); + EXPECT_TRUE(command->Init()); + command->Run(); +} + +TEST_F(CreateWindowRequestTest, + Run_WindowNameAppNameAreEqual_ExpectDuplicateNameResponseToMobile) { + const auto result_code = mobile_apis::Result::DUPLICATE_NAME; + EXPECT_CALL(mock_rpc_service_, + ManageMobileCommand(CheckMessageToMobile(result_code, false), + Command::CommandSource::SOURCE_SDL)) + .WillOnce(Return(true)); + ON_CALL(*mock_app_, WindowIdExists(kTestWindowId)) + .WillByDefault(Return(false)); + ON_CALL(*mock_app_, name()).WillByDefault(ReturnRef(kAppName)); + + auto msg = CreateMsgParams(); + (*msg)[am::strings::msg_params][am::strings::window_id] = kTestWindowId; + (*msg)[am::strings::msg_params][am::strings::window_name] = kAppName; + + auto command = CreateCommand(msg); + EXPECT_TRUE(command->Init()); + command->Run(); +} + +TEST_F(CreateWindowRequestTest, + Run_AllParametersCorrect_ExpectUICreateWindowIsSentToHMI) { + EXPECT_CALL( + mock_rpc_service_, + ManageHMICommand(HMIResultCodeIs(hmi_apis::FunctionID::UI_CreateWindow), + Command::CommandSource::SOURCE_SDL_TO_HMI)) + .WillOnce(Return(true)); + ON_CALL(*mock_app_, WindowIdExists(kTestWindowId)) + .WillByDefault(Return(false)); + ON_CALL(*mock_app_, WindowIdExists(kDuplicateWindowID)) + .WillByDefault(Return(true)); + ON_CALL(*mock_app_, name()).WillByDefault(ReturnRef(kAppName)); + + const std::vector windowNames = { + "WindowName_1", "WindowName_2", "WindowName_3"}; + ON_CALL(*mock_app_, GetWindowNames()).WillByDefault(Return(windowNames)); + + auto msg = CreateMsgParams(); + (*msg)[am::strings::msg_params][am::strings::window_id] = kTestWindowId; + (*msg)[am::strings::msg_params][am::strings::window_name] = kWindowName; + (*msg)[am::strings::msg_params] + [am::strings::duplicate_updates_from_window_id] = kDuplicateWindowID; + (*msg)[am::strings::msg_params][am::strings::associated_service_type] = + "MEDIA"; + (*msg)[am::strings::msg_params][am::strings::window_type] = + mobile_apis::WindowType::WIDGET; + + auto command = CreateCommand(msg); + EXPECT_TRUE(command->Init()); + command->Run(); +} + +TEST_F( + CreateWindowRequestTest, + CheckWindowName_AllParametersCorrectCreateWindowForPrimaryWidget_SendMessageToHMI) { + EXPECT_CALL( + mock_rpc_service_, + ManageHMICommand(HMIResultCodeIs(hmi_apis::FunctionID::UI_CreateWindow), + Command::CommandSource::SOURCE_SDL_TO_HMI)) + .WillOnce(Return(true)); + ON_CALL(*mock_app_, WindowIdExists(kTestWindowId)) + .WillByDefault(Return(false)); + ON_CALL(*mock_app_, WindowIdExists(kDuplicateWindowID)) + .WillByDefault(Return(true)); + ON_CALL(*mock_app_, name()).WillByDefault(ReturnRef(kAppName)); + + auto msg = CreateMsgParams(); + (*msg)[am::strings::msg_params][am::strings::window_id] = + mobile_apis::PredefinedWindows::PRIMARY_WIDGET; + (*msg)[am::strings::msg_params][am::strings::window_name] = kWindowName; + (*msg)[am::strings::msg_params] + [am::strings::duplicate_updates_from_window_id] = kDuplicateWindowID; + (*msg)[am::strings::msg_params][am::strings::associated_service_type] = + "MEDIA"; + (*msg)[am::strings::msg_params][am::strings::window_type] = + mobile_apis::WindowType::WIDGET; + + auto command = CreateCommand(msg); + EXPECT_TRUE(command->Init()); + command->Run(); +} + +TEST_F(CreateWindowRequestTest, + OnEvent_InvalidFunctionId_MessageNotSendToMobile) { + EXPECT_CALL(mock_rpc_service_, ManageMobileCommand(_, _)).Times(0); + auto msg = CreateMsgParams(); + auto command = CreateCommand(msg); + EXPECT_TRUE(command->Init()); + Event event(hmi_apis::FunctionID::INVALID_ENUM); + command->on_event(event); +} + +TEST_F(CreateWindowRequestTest, + OnEvent_AppDoesNotExist_ExpectAppNotRegisteredResponseToMobile) { + const auto result_code = mobile_apis::Result::APPLICATION_NOT_REGISTERED; + EXPECT_CALL(mock_rpc_service_, + ManageMobileCommand(CheckMessageToMobile(result_code, false), + Command::CommandSource::SOURCE_SDL)) + .WillOnce(Return(true)); + EXPECT_CALL(app_mngr_, application(kConnectionKey)).WillOnce(Return(nullptr)); + + auto msg = CreateMsgParams(); + auto command = CreateCommand(msg); + EXPECT_TRUE(command->Init()); + Event event(hmi_apis::FunctionID::UI_CreateWindow); + command->on_event(event); +} + +TEST_F(CreateWindowRequestTest, + OnEvent_RequestFailedOnHMISide_SendGenericErrorResponseToMobile) { + const auto result_code = mobile_apis::Result::GENERIC_ERROR; + EXPECT_CALL(mock_rpc_service_, + ManageMobileCommand(CheckMessageToMobile(result_code, false), + Command::CommandSource::SOURCE_SDL)) + .WillOnce(Return(true)); + + auto msg = CreateMsgParams(); + (*msg)[am::strings::params][am::hmi_response::code] = + hmi_apis::Common_Result::GENERIC_ERROR; + (*msg)[am::strings::msg_params][am::strings::window_name] = kWindowName; + (*msg)[am::strings::msg_params][am::strings::window_id] = kTestWindowId; + (*msg)[am::strings::msg_params][am::strings::window_type] = + mobile_apis::WindowType::eType::WIDGET; + + SetupHelperApplyWindowInitialState(mock_app_, msg); + + Event event(hmi_apis::FunctionID::UI_CreateWindow); + event.set_smart_object(*msg); + + auto command = CreateCommand(msg); + EXPECT_TRUE(command->Init()); + command->on_event(event); +} + +TEST_F(CreateWindowRequestTest, + OnEvent_AllParametersCorrect_SendSuccessResponseToMobile) { + const auto result_code = mobile_apis::Result::SUCCESS; + EXPECT_CALL(mock_rpc_service_, + ManageMobileCommand(CheckMessageToMobile(result_code, true), + Command::CommandSource::SOURCE_SDL)) + .WillOnce(Return(true)); + EXPECT_CALL(*mock_app_, UpdateHash()).Times(1); + auto msg = CreateMsgParams(); + (*msg)[am::strings::params][am::hmi_response::code] = + hmi_apis::Common_Result::SUCCESS; + (*msg)[am::strings::msg_params][am::strings::window_name] = kWindowName; + (*msg)[am::strings::msg_params][am::strings::window_id] = kTestWindowId; + (*msg)[am::strings::msg_params][am::strings::window_type] = + mobile_apis::WindowType::eType::WIDGET; + + SetupHelperApplyWindowInitialState(mock_app_, msg); + + Event event(hmi_apis::FunctionID::UI_CreateWindow); + event.set_smart_object(*msg); + + auto command = CreateCommand(msg); + EXPECT_TRUE(command->Init()); + command->on_event(event); +} + +} // namespace create_window_request +} // namespace mobile_commands_test +} // namespace commands_test +} // namespace components +} // namespace test diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/delete_command_request_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/delete_command_request_test.cc index a87d172923f..081058f05a3 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/delete_command_request_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/delete_command_request_test.cc @@ -37,15 +37,15 @@ #include "gtest/gtest.h" -#include "smart_objects/smart_object.h" -#include "application_manager/smart_object_keys.h" #include "application_manager/commands/command_request_test.h" -#include "application_manager/mock_application_manager.h" +#include "application_manager/event_engine/event.h" #include "application_manager/mock_application.h" -#include "application_manager/mock_message_helper.h" -#include "application_manager/mock_hmi_interface.h" +#include "application_manager/mock_application_manager.h" #include "application_manager/mock_help_prompt_manager.h" -#include "application_manager/event_engine/event.h" +#include "application_manager/mock_hmi_interface.h" +#include "application_manager/mock_message_helper.h" +#include "application_manager/smart_object_keys.h" +#include "smart_objects/smart_object.h" namespace test { namespace components { @@ -58,11 +58,11 @@ using ::testing::Return; using ::testing::ReturnRef; namespace am = ::application_manager; namespace am_test = application_manager_test; -using sdl_rpc_plugin::commands::DeleteCommandRequest; +using am::MockHmiInterfaces; +using am::MockMessageHelper; using am::commands::MessageSharedPtr; using am::event_engine::Event; -using am::MockMessageHelper; -using am::MockHmiInterfaces; +using sdl_rpc_plugin::commands::DeleteCommandRequest; typedef std::shared_ptr DeleteCommandPtr; diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/delete_file_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/delete_file_test.cc index 0ed7a92fa41..cce53bb4803 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/delete_file_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/delete_file_test.cc @@ -31,32 +31,32 @@ */ #include -#include -#include #include +#include +#include #include "mobile/delete_file_request.h" #include "mobile/delete_file_response.h" #include "gtest/gtest.h" -#include "utils/file_system.h" -#include "smart_objects/smart_object.h" -#include "application_manager/smart_object_keys.h" -#include "application_manager/commands/commands_test.h" -#include "application_manager/commands/command_request_test.h" #include "application_manager/application.h" -#include "application_manager/mock_application_manager.h" -#include "application_manager/mock_application.h" -#include "application_manager/mock_message_helper.h" +#include "application_manager/commands/command_request_test.h" +#include "application_manager/commands/commands_test.h" #include "application_manager/event_engine/event.h" +#include "application_manager/mock_application.h" +#include "application_manager/mock_application_manager.h" +#include "application_manager/mock_application_manager_settings.h" #include "application_manager/mock_hmi_capabilities.h" +#include "application_manager/mock_message_helper.h" #include "application_manager/policies/mock_policy_handler_interface.h" -#include "application_manager/mock_application_manager_settings.h" +#include "application_manager/smart_object_keys.h" +#include "smart_objects/smart_object.h" +#include "utils/file_system.h" -#include "interfaces/MOBILE_API.h" -#include "application_manager/policies/policy_handler_interface.h" #include "application_manager/policies/policy_handler.h" +#include "application_manager/policies/policy_handler_interface.h" +#include "interfaces/MOBILE_API.h" namespace test { namespace components { @@ -65,17 +65,17 @@ namespace mobile_commands_test { namespace delete_file { using ::testing::_; -using ::testing::Test; +using ::testing::AtLeast; using ::testing::Return; using ::testing::ReturnRef; using ::testing::SetArgReferee; -using ::testing::AtLeast; +using ::testing::Test; namespace am = ::application_manager; -using sdl_rpc_plugin::commands::DeleteFileRequest; -using sdl_rpc_plugin::commands::DeleteFileResponse; +using am::MockMessageHelper; using am::commands::MessageSharedPtr; using am::event_engine::Event; -using am::MockMessageHelper; +using sdl_rpc_plugin::commands::DeleteFileRequest; +using sdl_rpc_plugin::commands::DeleteFileResponse; typedef std::shared_ptr DeleteFileRequestPtr; typedef std::shared_ptr DeleteFileResponsePtr; @@ -98,6 +98,8 @@ namespace { const uint32_t kConnectionKey = 1u; const uint32_t kCorrelationId = 10u; const int32_t kMenuId = 5; +const am::WindowID kDefaultWindowId = + mobile_apis::PredefinedWindows::DEFAULT_WINDOW; } // namespace class DeleteFileRequestTest @@ -134,7 +136,7 @@ TEST_F(DeleteFileRequestTest, Run_HMILevelNone_UNSUCCESS) { EXPECT_CALL(app_mngr_, application(kConnectionKey)) .WillOnce(Return(mock_app_)); - EXPECT_CALL(*mock_app_, hmi_level()) + EXPECT_CALL(*mock_app_, hmi_level(kDefaultWindowId)) .WillOnce(Return(am::mobile_api::HMILevel::HMI_NONE)); EXPECT_CALL(app_mngr_, get_settings()) @@ -161,7 +163,7 @@ TEST_F(DeleteFileRequestTest, Run_ValidFileName_SUCCESS) { EXPECT_CALL(app_mngr_, application(kConnectionKey)) .WillRepeatedly(Return(mock_app_)); - EXPECT_CALL(*mock_app_, hmi_level()) + EXPECT_CALL(*mock_app_, hmi_level(kDefaultWindowId)) .WillOnce(Return(am::mobile_api::HMILevel::HMI_FULL)); EXPECT_CALL(app_mngr_, get_settings()) @@ -191,7 +193,7 @@ TEST_F(DeleteFileRequestTest, Run_InvalidFile_UNSUCCESS) { (*message_)[am::strings::msg_params][am::strings::sync_file_name] = file_name; EXPECT_CALL(app_mngr_, application(_)).WillOnce(Return(mock_app_)); - EXPECT_CALL(*mock_app_, hmi_level()) + EXPECT_CALL(*mock_app_, hmi_level(kDefaultWindowId)) .WillOnce(Return(am::mobile_api::HMILevel::HMI_FULL)); EXPECT_CALL(app_mngr_, get_settings()) diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/delete_interaction_choice_set_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/delete_interaction_choice_set_test.cc index c209c4fea21..fa96b21ca78 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/delete_interaction_choice_set_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/delete_interaction_choice_set_test.cc @@ -38,13 +38,13 @@ #include "gtest/gtest.h" -#include "smart_objects/smart_object.h" -#include "application_manager/smart_object_keys.h" -#include "application_manager/commands/commands_test.h" #include "application_manager/commands/command_request_test.h" -#include "application_manager/mock_application_manager.h" -#include "application_manager/mock_application.h" +#include "application_manager/commands/commands_test.h" #include "application_manager/event_engine/event.h" +#include "application_manager/mock_application.h" +#include "application_manager/mock_application_manager.h" +#include "application_manager/smart_object_keys.h" +#include "smart_objects/smart_object.h" namespace test { namespace components { @@ -53,15 +53,15 @@ namespace mobile_commands_test { namespace delete_interaction_choice_set { using ::testing::_; -using ::testing::Return; using ::testing::InSequence; +using ::testing::Return; namespace am = ::application_manager; -using sdl_rpc_plugin::commands::DeleteInteractionChoiceSetRequest; -using sdl_rpc_plugin::commands::DeleteInteractionChoiceSetResponse; using am::commands::MessageSharedPtr; using am::event_engine::Event; +using sdl_rpc_plugin::commands::DeleteInteractionChoiceSetRequest; +using sdl_rpc_plugin::commands::DeleteInteractionChoiceSetResponse; typedef std::shared_ptr DeleteInteractionChoiceSetRequestPtr; diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/delete_sub_menu_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/delete_sub_menu_test.cc index ff9e29c8721..04f12568b4a 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/delete_sub_menu_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/delete_sub_menu_test.cc @@ -36,14 +36,14 @@ #include "mobile/delete_sub_menu_request.h" #include "mobile/delete_sub_menu_response.h" -#include "gtest/gtest.h" #include "application_manager/commands/command_request_test.h" -#include "application_manager/mock_application_manager.h" -#include "application_manager/mock_application.h" -#include "application_manager/mock_message_helper.h" #include "application_manager/event_engine/event.h" -#include "application_manager/mock_hmi_interface.h" +#include "application_manager/mock_application.h" +#include "application_manager/mock_application_manager.h" #include "application_manager/mock_help_prompt_manager.h" +#include "application_manager/mock_hmi_interface.h" +#include "application_manager/mock_message_helper.h" +#include "gtest/gtest.h" namespace test { namespace components { @@ -52,15 +52,15 @@ namespace mobile_commands_test { namespace delete_sub_menu_request { using ::testing::_; +using ::testing::InSequence; using ::testing::Return; using ::testing::ReturnRef; -using ::testing::InSequence; namespace am = ::application_manager; namespace am_test = application_manager_test; -using am::commands::MessageSharedPtr; -using am::event_engine::Event; using am::MockHmiInterfaces; using am::MockMessageHelper; +using am::commands::MessageSharedPtr; +using am::event_engine::Event; using sdl_rpc_plugin::commands::DeleteSubMenuRequest; using sdl_rpc_plugin::commands::DeleteSubMenuResponse; diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/delete_window_request_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/delete_window_request_test.cc new file mode 100644 index 00000000000..f951d5c2a73 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/delete_window_request_test.cc @@ -0,0 +1,278 @@ +/* + * Copyright (c) 2019, 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 + +#include "mobile/delete_window_request.h" + +#include "application_manager/commands/command_request_test.h" +#include "application_manager/event_engine/event.h" +#include "application_manager/hmi_state.h" +#include "application_manager/mock_application.h" +#include "application_manager/mock_application_manager.h" +#include "application_manager/mock_hmi_interface.h" +#include "application_manager/mock_message_helper.h" +#include "application_manager/mock_state_controller.h" +#include "gtest/gtest.h" +#include "interfaces/MOBILE_API.h" + +namespace test { +namespace components { +namespace commands_test { +namespace mobile_commands_test { +namespace delete_window_request { + +namespace am = application_manager; +using am::MockMessageHelper; +using am::commands::CommandImpl; +using am::commands::MessageSharedPtr; +using sdl_rpc_plugin::commands::DeleteWindowRequest; +using namespace mobile_apis::PredefinedWindows; +using am::commands::Command; +using application_manager::WindowID; +using test::components::application_manager_test::MockStateController; +using test::components::policy_test::MockPolicyHandlerInterface; +using ::testing::_; +using ::testing::Return; +using ::testing::ReturnRef; + +namespace { +const uint32_t kConnectionKey = 2u; +const int32_t kFunctionID = mobile_apis::FunctionID::DeleteWindowID; +const WindowID kTestWindowId = 12; +} // namespace + +MATCHER_P2(CheckMessageToMobile, result_code, success, "") { + const bool is_success = + (*arg)[am::strings::msg_params][am::strings::success].asBool() == success; + + const bool is_result_code_correct = + (*arg)[am::strings::msg_params][am::strings::result_code].asInt() == + static_cast(result_code); + return is_success && is_result_code_correct; +} + +class DeleteWindowRequestTest + : public CommandRequestTest { + public: + DeleteWindowRequestTest() { + mock_app_ = CreateMockApp(); + ON_CALL(app_mngr_, application(kConnectionKey)) + .WillByDefault(Return(mock_app_)); + } + + protected: + MessageSharedPtr CreateMsgParams() { + auto msg = CreateMessage(); + (*msg)[am::strings::params][am::strings::connection_key] = kConnectionKey; + (*msg)[am::strings::params][am::strings::function_id] = kFunctionID; + return msg; + } + + MockAppPtr mock_app_; + NiceMock mock_state_controller; +}; + +TEST_F(DeleteWindowRequestTest, WindowID_ExpectDefaultWindowID) { + auto msg = CreateMsgParams(); + const auto command = CreateCommand(msg); + EXPECT_EQ(mobile_apis::PredefinedWindows::DEFAULT_WINDOW, + command->window_id()); +} + +TEST_F(DeleteWindowRequestTest, + Run_AppDoesNotExist_ExpectAppNotRegisteredResponseToMobile) { + const auto result_code = mobile_apis::Result::APPLICATION_NOT_REGISTERED; + EXPECT_CALL(mock_rpc_service_, + ManageMobileCommand(CheckMessageToMobile(result_code, false), + Command::CommandSource::SOURCE_SDL)) + .WillOnce(Return(true)); + EXPECT_CALL(app_mngr_, application(kConnectionKey)).WillOnce(Return(nullptr)); + + auto msg = CreateMsgParams(); + auto command = CreateCommand(msg); + EXPECT_TRUE(command->Init()); + command->Run(); +} + +TEST_F(DeleteWindowRequestTest, + Run_WindowIDForMainApplicationWindow_ExpectInvalidIDResponseToMobile) { + const auto result_code = mobile_apis::Result::INVALID_ID; + EXPECT_CALL(mock_rpc_service_, + ManageMobileCommand(CheckMessageToMobile(result_code, false), + Command::CommandSource::SOURCE_SDL)) + .WillOnce(Return(true)); + + auto msg = CreateMsgParams(); + (*msg)[am::strings::msg_params][am::strings::window_id] = + mobile_apis::PredefinedWindows::DEFAULT_WINDOW; + + auto command = CreateCommand(msg); + EXPECT_TRUE(command->Init()); + command->Run(); +} + +TEST_F(DeleteWindowRequestTest, + Run_WindowIDNotExist_ExpectInvalidIDResponseToMobile) { + const auto result_code = mobile_apis::Result::INVALID_ID; + EXPECT_CALL(mock_rpc_service_, + ManageMobileCommand(CheckMessageToMobile(result_code, false), + Command::CommandSource::SOURCE_SDL)) + .WillOnce(Return(true)); + ON_CALL(*mock_app_, GetWindowIds()).WillByDefault(Return(am::WindowIds())); + + auto msg = CreateMsgParams(); + (*msg)[am::strings::msg_params][am::strings::window_id] = kTestWindowId; + + auto command = CreateCommand(msg); + EXPECT_TRUE(command->Init()); + command->Run(); +} + +TEST_F(DeleteWindowRequestTest, + Run_AllParametersCorrect_ExpectUIDeleteWindowIsSentToHMI) { + EXPECT_CALL( + mock_rpc_service_, + ManageHMICommand(HMIResultCodeIs(hmi_apis::FunctionID::UI_DeleteWindow), + Command::CommandSource::SOURCE_SDL_TO_HMI)) + .WillOnce(Return(true)); + + ON_CALL(*mock_app_, GetWindowIds()) + .WillByDefault(Return(am::WindowIds(1, kTestWindowId))); + EXPECT_CALL(*mock_app_, WindowIdExists(kTestWindowId)).WillOnce(Return(true)); + auto msg = CreateMsgParams(); + (*msg)[am::strings::msg_params][am::strings::window_id] = kTestWindowId; + + auto command = CreateCommand(msg); + EXPECT_TRUE(command->Init()); + command->Run(); +} + +TEST_F(DeleteWindowRequestTest, + Run_AllParametersCorrectDeleteWindowForPrimaryWidget_SendMessageToHMI) { + EXPECT_CALL( + mock_rpc_service_, + ManageHMICommand(HMIResultCodeIs(hmi_apis::FunctionID::UI_DeleteWindow), + Command::CommandSource::SOURCE_SDL_TO_HMI)) + .WillOnce(Return(true)); + const auto primary_widget_window_id = + mobile_apis::PredefinedWindows::PRIMARY_WIDGET; + ON_CALL(*mock_app_, GetWindowIds()) + .WillByDefault(Return(am::WindowIds(1, primary_widget_window_id))); + EXPECT_CALL(*mock_app_, WindowIdExists(primary_widget_window_id)) + .WillOnce(Return(true)); + auto msg = CreateMsgParams(); + (*msg)[am::strings::msg_params][am::strings::window_id] = + primary_widget_window_id; + + auto command = CreateCommand(msg); + EXPECT_TRUE(command->Init()); + command->Run(); +} + +TEST_F(DeleteWindowRequestTest, + OnEvent_InvalidFunctionId_MessageNotSendToMobile) { + EXPECT_CALL(mock_rpc_service_, ManageMobileCommand(_, _)).Times(0); + auto msg = CreateMsgParams(); + auto command = CreateCommand(msg); + EXPECT_TRUE(command->Init()); + Event event(hmi_apis::FunctionID::INVALID_ENUM); + command->on_event(event); +} + +TEST_F(DeleteWindowRequestTest, + OnEvent_AppDoesNotExist_ExpectAppNotRegisteredResponseToMobile) { + const auto result_code = mobile_apis::Result::APPLICATION_NOT_REGISTERED; + EXPECT_CALL(mock_rpc_service_, + ManageMobileCommand(CheckMessageToMobile(result_code, false), + Command::CommandSource::SOURCE_SDL)) + .WillOnce(Return(true)); + EXPECT_CALL(app_mngr_, application(kConnectionKey)).WillOnce(Return(nullptr)); + + auto msg = CreateMsgParams(); + auto command = CreateCommand(msg); + EXPECT_TRUE(command->Init()); + Event event(hmi_apis::FunctionID::UI_DeleteWindow); + command->on_event(event); +} + +TEST_F(DeleteWindowRequestTest, + OnEvent_RequestFailedOnHMISide_SendGenericErrorResponseToMobile) { + const auto result_code = mobile_apis::Result::GENERIC_ERROR; + EXPECT_CALL(mock_rpc_service_, + ManageMobileCommand(CheckMessageToMobile(result_code, false), + Command::CommandSource::SOURCE_SDL)) + .WillOnce(Return(true)); + + auto msg = CreateMsgParams(); + (*msg)[am::strings::params][am::hmi_response::code] = + hmi_apis::Common_Result::GENERIC_ERROR; + + Event event(hmi_apis::FunctionID::UI_DeleteWindow); + event.set_smart_object(*msg); + + auto command = CreateCommand(msg); + EXPECT_TRUE(command->Init()); + command->on_event(event); +} + +TEST_F(DeleteWindowRequestTest, + OnEvent_AllParametersCorrect_SendSuccessResponseToMobile) { + const auto result_code = mobile_apis::Result::SUCCESS; + EXPECT_CALL(mock_rpc_service_, + ManageMobileCommand(CheckMessageToMobile(result_code, true), + Command::CommandSource::SOURCE_SDL)) + .WillOnce(Return(true)); + EXPECT_CALL(*mock_app_, UpdateHash()).Times(1); + EXPECT_CALL(*mock_app_, RemoveHMIState(kTestWindowId, _)).Times(1); + + auto msg = CreateMsgParams(); + (*msg)[am::strings::params][am::hmi_response::code] = + hmi_apis::Common_Result::SUCCESS; + (*msg)[am::strings::msg_params][am::strings::window_id] = kTestWindowId; + + Event event(hmi_apis::FunctionID::UI_DeleteWindow); + event.set_smart_object(*msg); + + auto command = CreateCommand(msg); + EXPECT_TRUE(command->Init()); + command->on_event(event); +} + +} // namespace delete_window_request +} // namespace mobile_commands_test +} // namespace commands_test +} // namespace components +} // namespace test diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/dial_number_request_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/dial_number_request_test.cc index ffa1b833be1..cf2634b37c3 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/dial_number_request_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/dial_number_request_test.cc @@ -36,16 +36,16 @@ #include "gtest/gtest.h" -#include "smart_objects/smart_object.h" -#include "application_manager/smart_object_keys.h" -#include "application_manager/commands/commands_test.h" -#include "application_manager/commands/command_request_test.h" #include "application_manager/application.h" -#include "application_manager/mock_application_manager.h" -#include "application_manager/mock_application.h" +#include "application_manager/commands/command_request_test.h" +#include "application_manager/commands/commands_test.h" #include "application_manager/event_engine/event.h" -#include "mobile/dial_number_request.h" +#include "application_manager/mock_application.h" +#include "application_manager/mock_application_manager.h" +#include "application_manager/smart_object_keys.h" #include "interfaces/MOBILE_API.h" +#include "mobile/dial_number_request.h" +#include "smart_objects/smart_object.h" namespace test { namespace components { @@ -57,8 +57,8 @@ using ::testing::_; using ::testing::Return; namespace am = ::application_manager; using am::commands::MessageSharedPtr; -using sdl_rpc_plugin::commands::DialNumberRequest; using am::event_engine::Event; +using sdl_rpc_plugin::commands::DialNumberRequest; namespace mobile_result = mobile_apis::Result; typedef std::shared_ptr DialNumberRequestPtr; diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/dummy_mobile_commands_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/dummy_mobile_commands_test.cc index 9c20143c390..8f83a2dd10e 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/dummy_mobile_commands_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/dummy_mobile_commands_test.cc @@ -131,8 +131,8 @@ #include "application_manager/mock_application.h" #include "application_manager/mock_application_manager.h" -#include "test/application_manager/mock_application_manager_settings.h" #include "application_manager/mock_event_dispatcher.h" +#include "test/application_manager/mock_application_manager_settings.h" namespace am = application_manager; @@ -143,16 +143,16 @@ namespace mobile_commands_test { namespace dummy_mobile_commands_test { namespace commands = sdl_rpc_plugin::commands; -using ::testing::_; -using ::testing::NotNull; -using ::testing::Types; using am::commands::MessageSharedPtr; -using ::test::components::event_engine_test::MockEventDispatcher; +using ::application_manager::ApplicationSharedPtr; +using ::test::components::application_manager_test::MockApplication; using ::test::components::application_manager_test::MockApplicationManager; using ::test::components::application_manager_test:: MockApplicationManagerSettings; -using ::application_manager::ApplicationSharedPtr; -using ::test::components::application_manager_test::MockApplication; +using ::test::components::event_engine_test::MockEventDispatcher; +using ::testing::_; +using ::testing::NotNull; +using ::testing::Types; namespace { const std::string kEmptyString_ = ""; @@ -283,7 +283,8 @@ typedef Types MobileCommandsListSecond; + commands::UnregisterAppInterfaceRequest> + MobileCommandsListSecond; typedef Types MobileCommandsListThird; + commands::UpdateTurnListResponse> + MobileCommandsListThird; TYPED_TEST_CASE(MobileCommandsTestFirst, MobileCommandsListFirst); TYPED_TEST_CASE(MobileCommandsTestSecond, MobileCommandsListSecond); diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/end_audio_pass_thru_request_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/end_audio_pass_thru_request_test.cc index 304cf13ffdb..ba09e0dabe5 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/end_audio_pass_thru_request_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/end_audio_pass_thru_request_test.cc @@ -36,14 +36,14 @@ #include "mobile/end_audio_pass_thru_request.h" -#include "gtest/gtest.h" -#include "application_manager/smart_object_keys.h" -#include "application_manager/commands/commands_test.h" #include "application_manager/commands/command_request_test.h" -#include "application_manager/mock_application_manager.h" +#include "application_manager/commands/commands_test.h" #include "application_manager/event_engine/event.h" -#include "application_manager/mock_message_helper.h" +#include "application_manager/mock_application_manager.h" #include "application_manager/mock_hmi_interface.h" +#include "application_manager/mock_message_helper.h" +#include "application_manager/smart_object_keys.h" +#include "gtest/gtest.h" namespace test { namespace components { @@ -52,13 +52,13 @@ namespace mobile_commands_test { namespace end_audio_pass_thru_request { namespace am = ::application_manager; +using am::MockMessageHelper; +using am::commands::MessageSharedPtr; +using am::event_engine::Event; +using sdl_rpc_plugin::commands::EndAudioPassThruRequest; using ::testing::_; using ::testing::Return; using ::testing::ReturnRef; -using am::commands::MessageSharedPtr; -using sdl_rpc_plugin::commands::EndAudioPassThruRequest; -using am::event_engine::Event; -using am::MockMessageHelper; typedef std::shared_ptr EndAudioPassThruRequestPtr; diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/get_system_capability_request_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/get_system_capability_request_test.cc new file mode 100644 index 00000000000..74c61410e87 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/get_system_capability_request_test.cc @@ -0,0 +1,124 @@ +/* + Copyright (c) 2019, 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 "mobile/get_system_capability_request.h" + +#include "application_manager/commands/command_request_test.h" +#include "gtest/gtest.h" +#include "interfaces/MOBILE_API.h" +#include "smart_objects/smart_object.h" + +namespace test { +namespace components { +namespace commands_test { +namespace mobile_commands_test { +namespace get_system_capability_request_test { + +using sdl_rpc_plugin::commands::GetSystemCapabilityRequest; +using ::testing::_; +using ::testing::Return; +typedef std::shared_ptr + GetSystemCapabilityRequestPtr; + +namespace strings = application_manager::strings; +namespace { +const uint32_t kConnectionKey = 1u; +} + +class GetSystemCapabilityRequestTest + : public CommandRequestTest { + protected: + void SetUp() OVERRIDE { + message_ = CreateMessage(); + (*message_)[strings::params][strings::connection_key] = kConnectionKey; + + command_ = CreateCommand(message_); + mock_app_ = CreateMockApp(); + + ON_CALL(app_mngr_, application(kConnectionKey)) + .WillByDefault(Return(mock_app_)); + } + + GetSystemCapabilityRequestPtr command_; + MessageSharedPtr message_; + MockAppPtr mock_app_; +}; + +TEST_F( + GetSystemCapabilityRequestTest, + Run_GetSystemDisplayCapabilities_SendMessageToMobileWithSUCCESSResultCode) { + (*message_)[strings::msg_params][strings::system_capability_type] = + mobile_apis::SystemCapabilityType::DISPLAYS; + + smart_objects::SmartObjectSPtr system_display_capabilities( + std::make_shared()); + + ON_CALL(*mock_app_, display_capabilities()) + .WillByDefault(Return(system_display_capabilities)); + + ON_CALL(mock_hmi_capabilities_, system_display_capabilities()) + .WillByDefault(Return(system_display_capabilities)); + + EXPECT_CALL( + mock_rpc_service_, + ManageMobileCommand(MobileResultCodeIs(mobile_apis::Result::SUCCESS), + Command::CommandSource::SOURCE_SDL)); + + ASSERT_TRUE(command_->Init()); + command_->Run(); +} + +TEST_F( + GetSystemCapabilityRequestTest, + Run_GetSystemDisplayCapabilities_CapabilitiesNotExistSendMessageToMobileWithDATA_NOT_AVAILABLEResultCode) { + (*message_)[strings::msg_params][strings::system_capability_type] = + mobile_apis::SystemCapabilityType::DISPLAYS; + + EXPECT_CALL(*mock_app_, display_capabilities()).WillOnce(Return(nullptr)); + + ON_CALL(mock_hmi_capabilities_, system_display_capabilities()) + .WillByDefault(Return(nullptr)); + + EXPECT_CALL(mock_rpc_service_, + ManageMobileCommand( + MobileResultCodeIs(mobile_apis::Result::DATA_NOT_AVAILABLE), + Command::CommandSource::SOURCE_SDL)); + + ASSERT_TRUE(command_->Init()); + command_->Run(); +} + +} // namespace get_system_capability_request_test +} // namespace mobile_commands_test +} // namespace commands_test +} // namespace components +} // namespace test diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/get_way_points_request_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/get_way_points_request_test.cc index f450d4b671d..7f7a8b55bdf 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/get_way_points_request_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/get_way_points_request_test.cc @@ -32,18 +32,17 @@ #include "gtest/gtest.h" -#include "application_manager/commands/commands_test.h" -#include "application_manager/commands/command_request_test.h" #include "application_manager/application.h" -#include "application_manager/mock_application_manager.h" +#include "application_manager/commands/command_request_test.h" +#include "application_manager/commands/commands_test.h" #include "application_manager/mock_application.h" -#include "mobile/get_way_points_request.h" -#include "application_manager/smart_object_keys.h" +#include "application_manager/mock_application_manager.h" +#include "application_manager/mock_hmi_interface.h" #include "application_manager/mock_message_helper.h" +#include "application_manager/smart_object_keys.h" #include "interfaces/HMI_API.h" #include "interfaces/MOBILE_API.h" -#include "application_manager/mock_hmi_interface.h" -#include "application_manager/mock_message_helper.h" +#include "mobile/get_way_points_request.h" namespace test { namespace components { @@ -52,11 +51,11 @@ namespace mobile_commands_test { namespace get_way_points_request { using namespace mobile_apis::Result; -using ::testing::Return; -using ::testing::_; -using sdl_rpc_plugin::commands::GetWayPointsRequest; -using application_manager::MockMessageHelper; using application_manager::MockHmiInterfaces; +using application_manager::MockMessageHelper; +using sdl_rpc_plugin::commands::GetWayPointsRequest; +using ::testing::_; +using ::testing::Return; typedef std::shared_ptr CommandPtr; typedef mobile_apis::Result::eType MobileResult; @@ -67,7 +66,7 @@ const uint32_t kCorrelationId = 2u; const uint32_t kAppId = 3u; const uint32_t kConnectionKey = kAppId; const std::string kMethodName = "Navigation.GetWayPoints"; -} +} // namespace class GetWayPointsRequestTest : public CommandRequestTest { diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/list_files_request_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/list_files_request_test.cc index 3fcc4225f3c..06ecc1116e5 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/list_files_request_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/list_files_request_test.cc @@ -35,15 +35,15 @@ #include "gtest/gtest.h" -#include "smart_objects/smart_object.h" -#include "application_manager/commands/commands_test.h" -#include "application_manager/commands/command_request_test.h" #include "application_manager/application.h" -#include "application_manager/mock_application_manager.h" +#include "application_manager/commands/command_request_test.h" +#include "application_manager/commands/commands_test.h" #include "application_manager/mock_application.h" -#include "mobile/list_files_request.h" -#include "interfaces/MOBILE_API.h" +#include "application_manager/mock_application_manager.h" #include "application_manager/smart_object_keys.h" +#include "interfaces/MOBILE_API.h" +#include "mobile/list_files_request.h" +#include "smart_objects/smart_object.h" namespace test { namespace components { @@ -52,13 +52,18 @@ namespace mobile_commands_test { namespace list_files_request { using ::testing::_; +using ::testing::DoAll; using ::testing::Return; using ::testing::ReturnRef; -using ::testing::DoAll; using ::testing::SaveArg; namespace am = ::application_manager; -using sdl_rpc_plugin::commands::ListFilesRequest; using am::commands::MessageSharedPtr; +using sdl_rpc_plugin::commands::ListFilesRequest; + +namespace { +const am::WindowID kDefaultWindowId = + mobile_apis::PredefinedWindows::DEFAULT_WINDOW; +} class ListFilesRequestTest : public CommandRequestTest { @@ -86,7 +91,7 @@ TEST_F(ListFilesRequestTest, Run_TooManyHmiNone_UNSUCCESS) { std::shared_ptr command(CreateCommand()); ON_CALL(app_mngr_, application(_)).WillByDefault(Return(app)); - ON_CALL(*app, hmi_level()) + ON_CALL(*app, hmi_level(kDefaultWindowId)) .WillByDefault(Return(mobile_apis::HMILevel::HMI_NONE)); const uint32_t kListFilesInNoneAllowed = 1u; @@ -121,7 +126,7 @@ TEST_F(ListFilesRequestTest, Run_SUCCESS) { ON_CALL(app_mngr_, application(_)).WillByDefault(Return(app)); - ON_CALL(*app, hmi_level()) + ON_CALL(*app, hmi_level(kDefaultWindowId)) .WillByDefault(Return(mobile_apis::HMILevel::HMI_FULL)); ON_CALL(*app, increment_list_files_in_none_count()).WillByDefault(Return()); diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/on_button_notification_commands_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/on_button_notification_commands_test.cc index a0e41cf7286..c0305a15cae 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/on_button_notification_commands_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/on_button_notification_commands_test.cc @@ -33,16 +33,16 @@ #include #include +#include "application_manager/smart_object_keys.h" #include "gtest/gtest.h" #include "smart_objects/smart_object.h" -#include "application_manager/smart_object_keys.h" -#include "application_manager/mock_application_manager.h" #include "application_manager/mock_application.h" +#include "application_manager/mock_application_manager.h" #include "application_manager/commands/command_impl.h" -#include "application_manager/commands/commands_test.h" #include "application_manager/commands/command_request_test.h" +#include "application_manager/commands/commands_test.h" #include "mobile/on_button_event_notification.h" #include "mobile/on_button_press_notification.h" @@ -54,17 +54,19 @@ namespace on_button_notification { namespace am = ::application_manager; namespace commands = am::commands; +using am::commands::MessageSharedPtr; using sdl_rpc_plugin::commands::mobile::OnButtonEventNotification; using sdl_rpc_plugin::commands::mobile::OnButtonPressNotification; using ::testing::_; -using ::testing::Types; using ::testing::Return; -using am::commands::MessageSharedPtr; +using ::testing::Types; namespace { const uint32_t kAppId = 5u; const uint32_t kCustomButtonId = 3u; const mobile_apis::ButtonName::eType kButtonName = mobile_apis::ButtonName::OK; +const am::WindowID kDefaultWindowId = + mobile_apis::PredefinedWindows::DEFAULT_WINDOW; } // namespace template template CreateCommand(notification_msg)); typename TestFixture::MockAppPtr mock_app = this->CreateMockApp(); - ON_CALL(*mock_app, hmi_level()) + ON_CALL(*mock_app, hmi_level(kDefaultWindowId)) .WillByDefault(Return(mobile_apis::HMILevel::HMI_FULL)); EXPECT_CALL(this->app_mngr_, application(kAppId)).WillOnce(Return(mock_app)); EXPECT_CALL(*mock_app, IsSubscribedToSoftButton(kCustomButtonId)) @@ -264,7 +266,7 @@ TYPED_TEST(OnButtonNotificationCommandsTest, Run_InvalidHmiLevel_UNSUCCESS) { std::vector subscribed_apps_list; subscribed_apps_list.push_back(mock_app); - EXPECT_CALL(*mock_app, hmi_level()) + EXPECT_CALL(*mock_app, hmi_level(kDefaultWindowId)) .WillRepeatedly(Return(mobile_apis::HMILevel::HMI_NONE)); EXPECT_CALL(this->app_mngr_, applications_by_button(kButtonName)) @@ -290,7 +292,7 @@ TYPED_TEST(OnButtonNotificationCommandsTest, std::vector subscribed_apps_list; subscribed_apps_list.push_back(mock_app); - EXPECT_CALL(*mock_app, hmi_level()) + EXPECT_CALL(*mock_app, hmi_level(kDefaultWindowId)) .WillRepeatedly(Return(mobile_apis::HMILevel::HMI_LIMITED)); EXPECT_CALL(this->app_mngr_, applications_by_button(kButtonName)) @@ -316,7 +318,7 @@ TYPED_TEST(OnButtonNotificationCommandsTest, Run_SUCCESS) { std::vector subscribed_apps_list; subscribed_apps_list.push_back(mock_app); - EXPECT_CALL(*mock_app, hmi_level()) + EXPECT_CALL(*mock_app, hmi_level(kDefaultWindowId)) .WillRepeatedly(Return(mobile_apis::HMILevel::HMI_FULL)); ON_CALL(*mock_app, IsFullscreen()).WillByDefault(Return(true)); diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/on_command_notification_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/on_command_notification_test.cc index 2fd6f6137da..1356b1c5fab 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/on_command_notification_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/on_command_notification_test.cc @@ -35,11 +35,11 @@ #include "gtest/gtest.h" -#include "smart_objects/smart_object.h" -#include "application_manager/smart_object_keys.h" -#include "application_manager/commands/commands_test.h" #include "application_manager/commands/command_impl.h" +#include "application_manager/commands/commands_test.h" +#include "application_manager/smart_object_keys.h" #include "mobile/on_command_notification.h" +#include "smart_objects/smart_object.h" namespace test { namespace components { diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/on_hash_change_notification_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/on_hash_change_notification_test.cc index 1d6711e36f6..15faa5c13fb 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/on_hash_change_notification_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/on_hash_change_notification_test.cc @@ -32,12 +32,12 @@ #include -#include "gtest/gtest.h" -#include "mobile/on_hash_change_notification.h" +#include "application_manager/commands/command_impl.h" #include "application_manager/mock_message_helper.h" #include "application_manager/smart_object_keys.h" -#include "application_manager/commands/command_impl.h" #include "application_manager/test/include/application_manager/commands/commands_test.h" +#include "gtest/gtest.h" +#include "mobile/on_hash_change_notification.h" namespace test { namespace components { @@ -47,13 +47,13 @@ namespace on_hash_change_notification { namespace strings = application_manager::strings; -using sdl_rpc_plugin::commands::mobile::OnHashChangeNotification; using application_manager::MockMessageHelper; using application_manager::commands::CommandImpl; +using sdl_rpc_plugin::commands::mobile::OnHashChangeNotification; +using testing::_; using testing::Mock; using testing::Return; using testing::ReturnRef; -using testing::_; class OnHashChangeNotificationTest : public CommandsTest {}; diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/on_hmi_status_notification_from_mobile_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/on_hmi_status_notification_from_mobile_test.cc index 333c204d576..528f1d8618c 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/on_hmi_status_notification_from_mobile_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/on_hmi_status_notification_from_mobile_test.cc @@ -30,13 +30,13 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include "gtest/gtest.h" #include "mobile/on_hmi_status_notification_from_mobile.h" -#include "application_manager/commands/commands_test.h" #include -#include "application_manager/message.h" #include "application_manager/application_manager.h" +#include "application_manager/commands/commands_test.h" +#include "application_manager/message.h" #include "application_manager/mock_message_helper.h" +#include "gtest/gtest.h" namespace test { namespace components { @@ -51,12 +51,12 @@ const connection_handler::DeviceHandle kHandle = 2u; namespace strings = application_manager::strings; -using sdl_rpc_plugin::commands::OnHMIStatusNotificationFromMobile; -using protocol_handler::MajorProtocolVersion; using application_manager::ApplicationSet; +using protocol_handler::MajorProtocolVersion; +using sdl_rpc_plugin::commands::OnHMIStatusNotificationFromMobile; +using testing::_; using testing::Mock; using testing::Return; -using testing::_; class OnHMIStatusNotificationFromMobileTest : public CommandsTest { diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/on_hmi_status_notification_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/on_hmi_status_notification_test.cc index ba3b1e8f1da..5bf68414e51 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/on_hmi_status_notification_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/on_hmi_status_notification_test.cc @@ -30,11 +30,11 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include "gtest/gtest.h" #include "mobile/on_hmi_status_notification.h" -#include "application_manager/test/include/application_manager/commands/commands_test.h" -#include "application_manager/mock_message_helper.h" #include "application_manager/commands/command_impl.h" +#include "application_manager/mock_message_helper.h" +#include "application_manager/test/include/application_manager/commands/commands_test.h" +#include "gtest/gtest.h" namespace test { namespace components { @@ -47,13 +47,13 @@ const uint32_t kConnectionKey = 1u; } // namespace namespace strings = application_manager::strings; -using sdl_rpc_plugin::commands::OnHMIStatusNotification; -using protocol_handler::MajorProtocolVersion; using application_manager::MockMessageHelper; using application_manager::commands::CommandImpl; +using protocol_handler::MajorProtocolVersion; +using sdl_rpc_plugin::commands::OnHMIStatusNotification; +using testing::_; using testing::Mock; using testing::Return; -using testing::_; class OnHMIStatusNotificationTest : public CommandsTest { diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/on_keyboard_input_notification_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/on_keyboard_input_notification_test.cc index 04f88e2b13f..b7b827bb4c1 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/on_keyboard_input_notification_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/on_keyboard_input_notification_test.cc @@ -30,13 +30,13 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include "gtest/gtest.h" #include "mobile/on_keyboard_input_notification.h" -#include "application_manager/commands/commands_test.h" #include +#include "application_manager/commands/command_impl.h" +#include "application_manager/commands/commands_test.h" #include "application_manager/message.h" #include "application_manager/mock_message_helper.h" -#include "application_manager/commands/command_impl.h" +#include "gtest/gtest.h" namespace test { namespace components { @@ -48,15 +48,17 @@ namespace strings = application_manager::strings; namespace { const uint32_t kConnectionKey = 1u; +const am::WindowID kDefaultWindowId = + mobile_apis::PredefinedWindows::DEFAULT_WINDOW; } // namespace -using sdl_rpc_plugin::commands::mobile::OnKeyBoardInputNotification; +using application_manager::ApplicationSet; using application_manager::MockMessageHelper; using application_manager::commands::CommandImpl; -using application_manager::ApplicationSet; +using sdl_rpc_plugin::commands::mobile::OnKeyBoardInputNotification; +using testing::_; using testing::Mock; using testing::Return; -using testing::_; class OnKeyBoardInputNotificationTest : public CommandsTest { @@ -102,7 +104,7 @@ TEST_F(OnKeyBoardInputNotificationTest, Run_ActionActive_SUCCESS) { EXPECT_CALL(*mock_app, is_perform_interaction_active()).WillOnce(Return(1)); EXPECT_CALL(*mock_app, perform_interaction_layout()) .WillOnce(Return(mobile_apis::LayoutMode::KEYBOARD)); - EXPECT_CALL(*mock_app, hmi_level()).Times(0); + EXPECT_CALL(*mock_app, hmi_level(kDefaultWindowId)).Times(0); EXPECT_CALL(*mock_app, app_id()).WillOnce(Return(kConnectionKey)); @@ -126,7 +128,7 @@ TEST_F(OnKeyBoardInputNotificationTest, Run_ActionNotActive_SUCCESS) { EXPECT_CALL(*mock_app, is_perform_interaction_active()) .WillRepeatedly(Return(0)); - EXPECT_CALL(*mock_app, hmi_level()) + EXPECT_CALL(*mock_app, hmi_level(kDefaultWindowId)) .WillOnce(Return(mobile_apis::HMILevel::eType::HMI_FULL)); EXPECT_CALL(*mock_app, app_id()).WillOnce(Return(kConnectionKey)); @@ -151,7 +153,7 @@ TEST_F(OnKeyBoardInputNotificationTest, Run_InvalidApp_NoNotification) { EXPECT_CALL(*mock_app, is_perform_interaction_active()) .WillRepeatedly(Return(0)); - EXPECT_CALL(*mock_app, hmi_level()) + EXPECT_CALL(*mock_app, hmi_level(kDefaultWindowId)) .WillOnce(Return(mobile_apis::HMILevel::eType::HMI_BACKGROUND)); EXPECT_CALL(mock_message_helper_, PrintSmartObject(_)).Times(0); diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/on_system_capability_updated_notification_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/on_system_capability_updated_notification_test.cc new file mode 100644 index 00000000000..349ada66a27 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/on_system_capability_updated_notification_test.cc @@ -0,0 +1,236 @@ +/* + * Copyright (c) 2019, 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 "mobile/on_system_capability_updated_notification.h" + +#include "application_manager/commands/commands_test.h" +#include "application_manager/display_capabilities_builder.h" +#include "gtest/gtest.h" +#include "sdl_rpc_plugin/extensions/system_capability_app_extension.h" +#include "sdl_rpc_plugin/sdl_rpc_plugin.h" + +namespace test { +namespace components { +namespace commands_test { +namespace mobile_commands_test { +namespace on_system_capability_updated_notification { + +using sdl_rpc_plugin::commands::mobile::OnSystemCapabilityUpdatedNotification; +using ::testing::_; +using ::testing::Return; + +typedef std::shared_ptr + OnSystemCapabilityUpdatedNotificationPtr; + +namespace strings = application_manager::strings; +namespace { +const uint32_t kConnectionKey = 1u; +const uint32_t kAppId = 2u; +} // namespace + +MATCHER_P(CheckDisplayCapabilities, display_capabilities, "") { + return *display_capabilities == + (*arg)[strings::msg_params][strings::system_capability] + [strings::display_capabilities]; +} + +class OnSystemCapabilityUpdatedNotificationTest + : public CommandsTest { + protected: + void SetUp() OVERRIDE { + message_ = CreateMessage(); + (*message_)[strings::params][strings::connection_key] = kConnectionKey; + + command_ = CreateCommand(message_); + mock_app_ = CreateMockApp(); + } + + OnSystemCapabilityUpdatedNotificationPtr command_; + MockAppPtr mock_app_; + MessageSharedPtr message_; +}; + +TEST_F( + OnSystemCapabilityUpdatedNotificationTest, + Run_AppExistSubscribedToNotification_SystemDisplayCapabilitiesSendToMobile) { + (*message_)[am::strings::msg_params][strings::system_capability] + [am::strings::system_capability_type] = + mobile_apis::SystemCapabilityType::DISPLAYS; + + smart_objects::SmartObjectSPtr system_display_capabilities = + std::make_shared( + smart_objects::SmartType_Null); + + ON_CALL(mock_hmi_capabilities_, system_display_capabilities()) + .WillByDefault(Return(system_display_capabilities)); + + sdl_rpc_plugin::SDLRPCPlugin sdl_rpc_plugin; + + std::shared_ptr + system_capability_app_extension( + std::make_shared( + sdl_rpc_plugin, *mock_app_)); + system_capability_app_extension->SubscribeTo( + mobile_apis::SystemCapabilityType::DISPLAYS); + application_manager::ApplicationSet apps({mock_app_}); + std::shared_ptr apps_lock_( + std::make_shared()); + DataAccessor apps_data( + DataAccessor(apps, apps_lock_)); + + ON_CALL(app_mngr_, applications()).WillByDefault(Return(apps_data)); + ON_CALL(*mock_app_, app_id()).WillByDefault(Return(kConnectionKey)); + ON_CALL(*mock_app_, display_capabilities()).WillByDefault(Return(nullptr)); + ON_CALL(*mock_app_, + QueryInterface(sdl_rpc_plugin::SystemCapabilityAppExtension:: + SystemCapabilityAppExtensionUID)) + .WillByDefault(Return(system_capability_app_extension)); + application_manager::DisplayCapabilitiesBuilder builder(*mock_app_); + ON_CALL(*mock_app_, display_capabilities_builder()) + .WillByDefault(ReturnRef(builder)); + + EXPECT_CALL( + mock_rpc_service_, + SendMessageToMobile(CheckDisplayCapabilities(system_display_capabilities), + false)); + + ASSERT_TRUE(command_->Init()); + command_->Run(); +} + +TEST_F( + OnSystemCapabilityUpdatedNotificationTest, + Run_AppExistConnectionKeyNotEqualWithAppId_SystemDisplayCapabilitiesNotSendToMobile) { + (*message_)[am::strings::msg_params][strings::system_capability] + [am::strings::system_capability_type] = + mobile_apis::SystemCapabilityType::DISPLAYS; + + smart_objects::SmartObjectSPtr system_display_capabilities = + std::make_shared( + smart_objects::SmartType_Null); + + ON_CALL(mock_hmi_capabilities_, system_display_capabilities()) + .WillByDefault(Return(system_display_capabilities)); + + sdl_rpc_plugin::SDLRPCPlugin sdl_rpc_plugin; + + std::shared_ptr + system_capability_app_extension( + std::make_shared( + sdl_rpc_plugin, *mock_app_)); + system_capability_app_extension->SubscribeTo( + mobile_apis::SystemCapabilityType::DISPLAYS); + application_manager::ApplicationSet apps({mock_app_}); + std::shared_ptr apps_lock_( + std::make_shared()); + DataAccessor apps_data( + DataAccessor(apps, apps_lock_)); + + ON_CALL(app_mngr_, applications()).WillByDefault(Return(apps_data)); + ON_CALL(*mock_app_, app_id()).WillByDefault(Return(kAppId)); + ON_CALL(*mock_app_, display_capabilities()).WillByDefault(Return(nullptr)); + ON_CALL(*mock_app_, + QueryInterface(sdl_rpc_plugin::SystemCapabilityAppExtension:: + SystemCapabilityAppExtensionUID)) + .WillByDefault(Return(system_capability_app_extension)); + + EXPECT_CALL(mock_rpc_service_, SendMessageToMobile(_, _)).Times(0); + + ASSERT_TRUE(command_->Init()); + command_->Run(); +} + +TEST_F( + OnSystemCapabilityUpdatedNotificationTest, + Run_AppExistNotSubscribedToNotification_SystemDisplayCapabilitiesNotSendToMobile) { + (*message_)[am::strings::msg_params][strings::system_capability] + [am::strings::system_capability_type] = + mobile_apis::SystemCapabilityType::DISPLAYS; + + smart_objects::SmartObjectSPtr system_display_capabilities = + std::make_shared( + smart_objects::SmartType_Null); + + ON_CALL(mock_hmi_capabilities_, system_display_capabilities()) + .WillByDefault(Return(system_display_capabilities)); + + sdl_rpc_plugin::SDLRPCPlugin sdl_rpc_plugin; + + std::shared_ptr + system_capability_app_extension( + std::make_shared( + sdl_rpc_plugin, *mock_app_)); + + application_manager::ApplicationSet apps({mock_app_}); + std::shared_ptr apps_lock_( + std::make_shared()); + DataAccessor apps_data( + DataAccessor(apps, apps_lock_)); + + ON_CALL(app_mngr_, applications()).WillByDefault(Return(apps_data)); + ON_CALL(*mock_app_, app_id()).WillByDefault(Return(kConnectionKey)); + ON_CALL(*mock_app_, display_capabilities()).WillByDefault(Return(nullptr)); + ON_CALL(*mock_app_, + QueryInterface(sdl_rpc_plugin::SystemCapabilityAppExtension:: + SystemCapabilityAppExtensionUID)) + .WillByDefault(Return(system_capability_app_extension)); + + EXPECT_CALL(mock_rpc_service_, SendMessageToMobile(_, _)).Times(0); + + ASSERT_TRUE(command_->Init()); + command_->Run(); +} + +TEST_F( + OnSystemCapabilityUpdatedNotificationTest, + Run_AppDataEmpty_SystemDisplayCapabilitiesUpdatedNotificationNotSendToMobile) { + (*message_)[am::strings::msg_params][strings::system_capability] + [am::strings::system_capability_type] = + mobile_apis::SystemCapabilityType::DISPLAYS; + application_manager::ApplicationSet apps; + std::shared_ptr apps_lock_( + std::make_shared()); + DataAccessor apps_data( + DataAccessor(apps, apps_lock_)); + + ON_CALL(app_mngr_, applications()).WillByDefault(Return(apps_data)); + EXPECT_CALL(mock_rpc_service_, SendMessageToMobile(_, _)).Times(0); + + ASSERT_TRUE(command_->Init()); + command_->Run(); +} + +} // namespace on_system_capability_updated_notification +} // namespace mobile_commands_test +} // namespace commands_test +} // namespace components +} // namespace test diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/on_system_request_notification_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/on_system_request_notification_test.cc index 4981301e07c..ffa7203f1f4 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/on_system_request_notification_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/on_system_request_notification_test.cc @@ -32,14 +32,13 @@ #include -#include "gtest/gtest.h" -#include "mobile/on_system_request_notification.h" +#include "application_manager/commands/command_impl.h" +#include "application_manager/commands/commands_test.h" #include "application_manager/mock_message_helper.h" #include "application_manager/policies/mock_policy_handler_interface.h" -#include "application_manager/mock_message_helper.h" -#include "application_manager/commands/commands_test.h" -#include "application_manager/commands/command_impl.h" +#include "gtest/gtest.h" #include "interfaces/MOBILE_API.h" +#include "mobile/on_system_request_notification.h" namespace test { namespace components { @@ -49,20 +48,21 @@ namespace on_system_request_notification { namespace strings = application_manager::strings; -using sdl_rpc_plugin::commands::mobile::OnSystemRequestNotification; -using application_manager::commands::CommandImpl; using application_manager::MockMessageHelper; +using application_manager::commands::CommandImpl; +using sdl_rpc_plugin::commands::mobile::OnSystemRequestNotification; using test::components::policy_test::MockPolicyHandlerInterface; using namespace mobile_apis; -using testing::SaveArg; +using testing::_; using testing::Mock; using testing::Return; using testing::ReturnRef; -using testing::_; +using testing::SaveArg; namespace { const uint32_t kConnectionKey = 1u; const std::string kPolicyAppId = "fake-app-id"; +const connection_handler::DeviceHandle kDeviceId = 1u; } // namespace class OnSystemRequestNotificationTest @@ -74,6 +74,7 @@ class OnSystemRequestNotificationTest ON_CALL(app_mngr_, application(kConnectionKey)) .WillByDefault(Return(mock_app_)); ON_CALL(*mock_app_, policy_app_id()).WillByDefault(Return(kPolicyAppId)); + ON_CALL(*mock_app_, device()).WillByDefault(Return(kDeviceId)); } protected: @@ -91,12 +92,14 @@ TEST_F(OnSystemRequestNotificationTest, Run_ProprietaryType_SUCCESS) { std::shared_ptr command = CreateCommand(msg); + PreConditions(); + EXPECT_CALL(app_mngr_, application(kConnectionKey)) .WillRepeatedly(Return(mock_app_)); EXPECT_CALL(*mock_app_, policy_app_id()).WillOnce(Return(kPolicyAppId)); EXPECT_CALL(mock_policy_handler_, - IsRequestTypeAllowed(kPolicyAppId, request_type)) + IsRequestTypeAllowed(kDeviceId, kPolicyAppId, request_type)) .WillRepeatedly(Return(true)); #ifdef PROPRIETARY_MODE @@ -131,10 +134,13 @@ TEST_F(OnSystemRequestNotificationTest, Run_HTTPType_SUCCESS) { std::shared_ptr command = CreateCommand(msg); + PreConditions(); + EXPECT_CALL(app_mngr_, application(kConnectionKey)) .WillOnce(Return(mock_app_)); EXPECT_CALL(*mock_app_, policy_app_id()).WillOnce(Return(kPolicyAppId)); - EXPECT_CALL(mock_policy_handler_, IsRequestTypeAllowed(_, _)) + EXPECT_CALL(mock_policy_handler_, + IsRequestTypeAllowed(kDeviceId, kPolicyAppId, request_type)) .WillOnce(Return(true)); EXPECT_CALL(mock_message_helper_, PrintSmartObject(_)) @@ -168,7 +174,7 @@ TEST_F(OnSystemRequestNotificationTest, Run_InvalidApp_NoNotification) { EXPECT_CALL(app_mngr_, application(kConnectionKey)) .WillOnce(Return(MockAppPtr())); EXPECT_CALL(*mock_app_, policy_app_id()).Times(0); - EXPECT_CALL(mock_policy_handler_, IsRequestTypeAllowed(_, _)).Times(0); + EXPECT_CALL(mock_policy_handler_, IsRequestTypeAllowed(_, _, _)).Times(0); EXPECT_CALL(mock_message_helper_, PrintSmartObject(_)).Times(0); @@ -188,10 +194,13 @@ TEST_F(OnSystemRequestNotificationTest, Run_RequestNotAllowed_NoNotification) { std::shared_ptr command = CreateCommand(msg); + PreConditions(); + EXPECT_CALL(app_mngr_, application(kConnectionKey)) .WillOnce(Return(mock_app_)); EXPECT_CALL(*mock_app_, policy_app_id()).WillOnce(Return(kPolicyAppId)); - EXPECT_CALL(mock_policy_handler_, IsRequestTypeAllowed(_, _)) + EXPECT_CALL(mock_policy_handler_, + IsRequestTypeAllowed(kDeviceId, kPolicyAppId, request_type)) .WillOnce(Return(false)); EXPECT_CALL(mock_message_helper_, PrintSmartObject(_)).Times(0); @@ -215,7 +224,7 @@ TEST_F( PreConditions(); EXPECT_CALL(mock_policy_handler_, - IsRequestTypeAllowed(kPolicyAppId, request_type)) + IsRequestTypeAllowed(kDeviceId, kPolicyAppId, request_type)) .WillOnce(Return(true)); EXPECT_CALL(mock_policy_handler_, IsRequestSubTypeAllowed(kPolicyAppId, request_subtype)) @@ -242,7 +251,7 @@ TEST_F(OnSystemRequestNotificationTest, PreConditions(); EXPECT_CALL(mock_policy_handler_, - IsRequestTypeAllowed(kPolicyAppId, request_type)) + IsRequestTypeAllowed(kDeviceId, kPolicyAppId, request_type)) .WillOnce(Return(true)); EXPECT_CALL(mock_policy_handler_, IsRequestSubTypeAllowed(kPolicyAppId, request_subtype)) diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/on_tbt_client_state_notification_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/on_tbt_client_state_notification_test.cc index 3d989db4784..c43dea76e1d 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/on_tbt_client_state_notification_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/on_tbt_client_state_notification_test.cc @@ -36,10 +36,10 @@ #include "gtest/gtest.h" #include "mobile/on_tbt_client_state_notification.h" -#include "smart_objects/smart_object.h" -#include "application_manager/smart_object_keys.h" -#include "application_manager/commands/commands_test.h" #include "application_manager/commands/command_impl.h" +#include "application_manager/commands/commands_test.h" +#include "application_manager/smart_object_keys.h" +#include "smart_objects/smart_object.h" #include "utils/helpers.h" namespace test { @@ -60,6 +60,8 @@ typedef std::shared_ptr NotificationPtr; namespace { const uint32_t kAppId = 1u; +const am::WindowID kDefaultWindowId = + mobile_apis::PredefinedWindows::DEFAULT_WINDOW; } // namespace class OnTBTClientStateNotificationTest @@ -79,7 +81,7 @@ TEST_F(OnTBTClientStateNotificationTest, Run_HmiLevelNone_UNSUCCESS) { EXPECT_CALL(app_mngr_, applications_with_navi()) .WillOnce(Return(applications_with_navi)); - EXPECT_CALL(*mock_app, hmi_level()) + EXPECT_CALL(*mock_app, hmi_level(kDefaultWindowId)) .WillOnce(Return(mobile_apis::HMILevel::HMI_NONE)); EXPECT_CALL(*mock_app, app_id()).Times(0); @@ -122,7 +124,7 @@ TEST_F(OnTBTClientStateNotificationTest, EXPECT_CALL(app_mngr_, applications_with_navi()) .WillOnce(Return(applications_with_navi)); - EXPECT_CALL(*mock_app, hmi_level()) + EXPECT_CALL(*mock_app, hmi_level(kDefaultWindowId)) .WillOnce(Return(mobile_apis::HMILevel::HMI_FULL)); EXPECT_CALL(*mock_app, app_id()).WillOnce(Return(kAppId)); diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/on_touch_event_notification_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/on_touch_event_notification_test.cc index f69dd5da2eb..95020328b4c 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/on_touch_event_notification_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/on_touch_event_notification_test.cc @@ -36,10 +36,10 @@ #include "gtest/gtest.h" #include "mobile/on_touch_event_notification.h" -#include "smart_objects/smart_object.h" -#include "application_manager/smart_object_keys.h" -#include "application_manager/commands/commands_test.h" #include "application_manager/commands/command_impl.h" +#include "application_manager/commands/commands_test.h" +#include "application_manager/smart_object_keys.h" +#include "smart_objects/smart_object.h" #include "utils/helpers.h" namespace test { diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/on_way_point_change_notification_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/on_way_point_change_notification_test.cc index ed0a9b07d22..83958954cdd 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/on_way_point_change_notification_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/on_way_point_change_notification_test.cc @@ -36,10 +36,10 @@ #include "gtest/gtest.h" #include "mobile/on_way_point_change_notification.h" -#include "smart_objects/smart_object.h" -#include "application_manager/smart_object_keys.h" -#include "application_manager/commands/commands_test.h" #include "application_manager/commands/command_impl.h" +#include "application_manager/commands/commands_test.h" +#include "application_manager/smart_object_keys.h" +#include "smart_objects/smart_object.h" #include "utils/helpers.h" namespace test { diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/perform_audio_pass_thru_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/perform_audio_pass_thru_test.cc index acda9b9fc7a..2915418d438 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/perform_audio_pass_thru_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/perform_audio_pass_thru_test.cc @@ -31,18 +31,18 @@ */ #include -#include #include +#include #include "mobile/perform_audio_pass_thru_request.h" -#include "gtest/gtest.h" #include "application_manager/commands/command_request_test.h" +#include "application_manager/event_engine/event.h" #include "application_manager/mock_application.h" #include "application_manager/mock_application_manager.h" -#include "application_manager/mock_message_helper.h" -#include "application_manager/event_engine/event.h" #include "application_manager/mock_hmi_interface.h" +#include "application_manager/mock_message_helper.h" +#include "gtest/gtest.h" namespace test { namespace components { @@ -51,14 +51,14 @@ namespace mobile_commands_test { namespace perform_audio_pass_thru_request { namespace am = application_manager; -using sdl_rpc_plugin::commands::PerformAudioPassThruRequest; +using am::MockMessageHelper; using am::commands::CommandImpl; using am::commands::MessageSharedPtr; -using am::MockMessageHelper; +using sdl_rpc_plugin::commands::PerformAudioPassThruRequest; using ::testing::_; +using ::testing::InSequence; using ::testing::Return; using ::testing::ReturnRef; -using ::testing::InSequence; namespace { const int32_t kCommandId = 1; @@ -72,6 +72,8 @@ const std::string kCorrectDisplayText1 = "CorrectDisplayText1"; const std::string kCorrectDisplayText2 = "CorrectDisplayText2"; const std::string kFunctionId = "FunctionId"; const uint32_t kTimeoutForTTSSpeak = 1u; +const am::WindowID kDefaultWindowId = + mobile_apis::PredefinedWindows::DEFAULT_WINDOW; } // namespace class PerformAudioPassThruRequestTest @@ -109,7 +111,7 @@ class PerformAudioPassThruRequestTest msg_params_[field] = "prompt\\n"; } - EXPECT_CALL(*application_sptr_, hmi_level()) + EXPECT_CALL(*application_sptr_, hmi_level(kDefaultWindowId)) .WillOnce(Return(am::mobile_api::HMILevel::HMI_FULL)); CallRun caller(*command_sptr_); @@ -206,7 +208,7 @@ TEST_F(PerformAudioPassThruRequestTest, (*mobile_request)[am::strings::msg_params][am::strings::initial_prompt] = initial_prompt; - EXPECT_CALL(*application_sptr_, hmi_level()) + EXPECT_CALL(*application_sptr_, hmi_level(kDefaultWindowId)) .WillOnce(Return(am::mobile_api::HMILevel::HMI_FULL)); std::shared_ptr command = CreateCommand(mobile_request); @@ -250,7 +252,8 @@ TEST_F(PerformAudioPassThruRequestTest, VerifyTtsFiles((*mobile_request)[am::strings::msg_params] [am::strings::initial_prompt], _, - _)).WillOnce(Return(mobile_apis::Result::SUCCESS)); + _)) + .WillOnce(Return(mobile_apis::Result::SUCCESS)); command->Run(); command->on_event(event_tts); @@ -285,7 +288,7 @@ TEST_F(PerformAudioPassThruRequestTest, } TEST_F(PerformAudioPassThruRequestTest, Run_HmiLevelNone_Rejected) { - EXPECT_CALL(*application_sptr_, hmi_level()) + EXPECT_CALL(*application_sptr_, hmi_level(kDefaultWindowId)) .WillOnce(Return(am::mobile_api::HMILevel::HMI_NONE)); CallRun caller(*command_sptr_); @@ -318,7 +321,7 @@ TEST_F(PerformAudioPassThruRequestTest, // First we need to call SendSpeakRequest() // to enable the "is_active_tts_speak" key - EXPECT_CALL(*application_sptr_, hmi_level()) + EXPECT_CALL(*application_sptr_, hmi_level(kDefaultWindowId)) .WillOnce(Return(am::mobile_api::HMILevel::HMI_FULL)); msg_params_[am::strings::initial_prompt][0][am::strings::text] = @@ -406,7 +409,7 @@ TEST_F(PerformAudioPassThruRequestTest, TEST_F(PerformAudioPassThruRequestTest, Run_InitPromptCorrect_SpeakAndPerformAPTRequestsSendMuteTrue) { - EXPECT_CALL(*application_sptr_, hmi_level()) + EXPECT_CALL(*application_sptr_, hmi_level(kDefaultWindowId)) .WillOnce(Return(am::mobile_api::HMILevel::HMI_FULL)); msg_params_[am::strings::initial_prompt][0][am::strings::text] = @@ -463,10 +466,12 @@ TEST_F(PerformAudioPassThruRequestTest, .asString(); const std::string result_display_text_1 = perform_msg_params[am::hmi_request::audio_pass_display_texts][0] - [am::hmi_request::field_text].asString(); + [am::hmi_request::field_text] + .asString(); const std::string result_display_text_2 = perform_msg_params[am::hmi_request::audio_pass_display_texts][1] - [am::hmi_request::field_text].asString(); + [am::hmi_request::field_text] + .asString(); EXPECT_EQ(kCorrectPrompt, result_initial_prompt); EXPECT_EQ(kCorrectType, result_prompt_type); @@ -478,7 +483,7 @@ TEST_F(PerformAudioPassThruRequestTest, TEST_F(PerformAudioPassThruRequestTest, Run_InitPromptCorrect_SpeakAndPerformAPTRequestsSendMuteFalse) { - EXPECT_CALL(*application_sptr_, hmi_level()) + EXPECT_CALL(*application_sptr_, hmi_level(kDefaultWindowId)) .WillOnce(Return(am::mobile_api::HMILevel::HMI_FULL)); msg_params_[am::strings::initial_prompt][0][am::strings::text] = @@ -533,7 +538,7 @@ TEST_F(PerformAudioPassThruRequestTest, TEST_F( PerformAudioPassThruRequestTest, Run_InitPromptEmpty_PerformAndRecordStartNotificationsAndStartRecording) { - EXPECT_CALL(*application_sptr_, hmi_level()) + EXPECT_CALL(*application_sptr_, hmi_level(kDefaultWindowId)) .WillOnce(Return(am::mobile_api::HMILevel::HMI_FULL)); MessageSharedPtr start_record_result_msg; @@ -579,7 +584,8 @@ TEST_F( const hmi_apis::FunctionID::eType start_record_result_function_id = static_cast( (*start_record_result_msg)[am::strings::params] - [am::strings::function_id].asInt()); + [am::strings::function_id] + .asInt()); EXPECT_EQ(hmi_apis::FunctionID::UI_OnRecordStart, start_record_result_function_id); } @@ -762,7 +768,7 @@ TEST_F(PerformAudioPassThruRequestTest, EXPECT_CALL(app_mngr_, EndAudioPassThru(app_id)).WillOnce(Return(true)); EXPECT_CALL(app_mngr_, StopAudioPassThru(_)); - EXPECT_CALL(*application_sptr_, hmi_level()) + EXPECT_CALL(*application_sptr_, hmi_level(kDefaultWindowId)) .WillOnce(Return(am::mobile_api::HMILevel::HMI_FULL)); msg_params_[am::strings::initial_prompt][0][am::strings::text] = @@ -831,4 +837,4 @@ TEST_F(PerformAudioPassThruRequestTest, } // namespace mobile_commands_test } // namespace commands_test } // namespace components -} // namespace tests +} // namespace test diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/perform_interaction_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/perform_interaction_test.cc index 3b68d3ea725..f1f7c4c9074 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/perform_interaction_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/perform_interaction_test.cc @@ -31,22 +31,22 @@ */ #include -#include #include +#include #include "mobile/perform_interaction_request.h" -#include "gtest/gtest.h" -#include "utils/helpers.h" -#include "smart_objects/smart_object.h" -#include "utils/custom_string.h" #include "application_manager/commands/command_request_test.h" -#include "application_manager/smart_object_keys.h" +#include "application_manager/event_engine/event.h" #include "application_manager/mock_application.h" #include "application_manager/mock_application_manager.h" -#include "application_manager/mock_message_helper.h" -#include "application_manager/event_engine/event.h" #include "application_manager/mock_hmi_interface.h" +#include "application_manager/mock_message_helper.h" +#include "application_manager/smart_object_keys.h" +#include "gtest/gtest.h" +#include "smart_objects/smart_object.h" +#include "utils/custom_string.h" +#include "utils/helpers.h" namespace test { namespace components { @@ -55,16 +55,16 @@ namespace mobile_commands_test { namespace perform_interaction_request { namespace am = application_manager; -using am::commands::CommandImpl; using am::ApplicationManager; -using am::commands::MessageSharedPtr; using am::ApplicationSharedPtr; using am::MockMessageHelper; +using am::commands::CommandImpl; +using am::commands::MessageSharedPtr; +using sdl_rpc_plugin::commands::PerformInteractionRequest; +using ::test::components::application_manager_test::MockApplication; using ::testing::_; using ::testing::Return; using ::testing::ReturnRef; -using sdl_rpc_plugin::commands::PerformInteractionRequest; -using ::test::components::application_manager_test::MockApplication; namespace strings = ::application_manager::strings; namespace hmi_response = ::application_manager::hmi_response; @@ -258,4 +258,4 @@ TEST_F(PerformInteractionRequestTest, } // namespace mobile_commands_test } // namespace commands_test } // namespace components -} // namespace tests +} // namespace test diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/put_file_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/put_file_test.cc index 415b559f827..8db533f446d 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/put_file_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/put_file_test.cc @@ -36,18 +36,18 @@ #include "gtest/gtest.h" -#include "application_manager/commands/commands_test.h" #include "application_manager/commands/command_request_test.h" +#include "application_manager/commands/commands_test.h" -#include "mobile/put_file_response.h" #include "mobile/put_file_request.h" +#include "mobile/put_file_response.h" -#include "utils/file_system.h" -#include "smart_objects/smart_object.h" -#include "interfaces/MOBILE_API.h" #include "application_manager/application.h" #include "application_manager/mock_application.h" #include "application_manager/policies/mock_policy_handler_interface.h" +#include "interfaces/MOBILE_API.h" +#include "smart_objects/smart_object.h" +#include "utils/file_system.h" namespace test { namespace components { @@ -56,16 +56,16 @@ namespace mobile_commands_test { namespace put_file { using ::testing::_; +using ::testing::AtLeast; using ::testing::Return; using ::testing::ReturnRef; -using ::testing::AtLeast; namespace am = ::application_manager; -using sdl_rpc_plugin::commands::PutFileRequest; -using sdl_rpc_plugin::commands::PutFileResponse; using am::commands::MessageSharedPtr; using policy_test::MockPolicyHandlerInterface; +using sdl_rpc_plugin::commands::PutFileRequest; +using sdl_rpc_plugin::commands::PutFileResponse; typedef std::shared_ptr PutFileRequestPtr; typedef std::shared_ptr PutFileResponsePtr; @@ -78,7 +78,9 @@ const int64_t kZeroOffset = 0u; const std::string kStorageFolder = "./storage"; const std::string kFolder = "folder"; const std::string kAppFolder = "app_folder"; -} +const am::WindowID kDefaultWindowId = + mobile_apis::PredefinedWindows::DEFAULT_WINDOW; +} // namespace class PutFileRequestTest : public CommandRequestTest { @@ -99,7 +101,7 @@ class PutFileRequestTest ON_CALL(app_mngr_, application(kConnectionKey)) .WillByDefault(Return(mock_app_)); - ON_CALL(*mock_app_, hmi_level()) + ON_CALL(*mock_app_, hmi_level(kDefaultWindowId)) .WillByDefault(Return(mobile_apis::HMILevel::HMI_FULL)); } @@ -179,7 +181,7 @@ TEST_F(PutFileRequestTest, Run_ApplicationIsNotRegistered_UNSUCCESS) { } TEST_F(PutFileRequestTest, Run_HmiLevelNone_UNSUCCESS) { - EXPECT_CALL(*mock_app_, hmi_level()) + EXPECT_CALL(*mock_app_, hmi_level(kDefaultWindowId)) .WillOnce(Return(mobile_apis::HMILevel::HMI_NONE)); const uint32_t settings_put_file_in_none = 1u; @@ -319,7 +321,8 @@ TEST_F(PutFileRequestTest, Run_SendOnPutFileNotification_SUCCESS) { mock_rpc_service_, ManageHMICommand( HMIResultCodeIs(hmi_apis::FunctionID::BasicCommunication_OnPutFile), - _)).WillOnce(Return(true)); + _)) + .WillOnce(Return(true)); ExpectManageMobileCommandWithResultCode(mobile_apis::Result::SUCCESS); PutFileRequestPtr command(CreateCommand(msg_)); 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 868d353a855..636175c56f3 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 @@ -34,25 +34,25 @@ #include #include -#include "gtest/gtest.h" -#include "mobile/register_app_interface_request.h" -#include "smart_objects/smart_object.h" -#include "application_manager/commands/commands_test.h" -#include "application_manager/commands/command_request_test.h" #include "application_manager/application.h" -#include "application_manager/mock_application_manager.h" +#include "application_manager/commands/command_request_test.h" +#include "application_manager/commands/commands_test.h" #include "application_manager/mock_application.h" #include "application_manager/mock_application_helper.h" -#include "interfaces/MOBILE_API.h" -#include "application_manager/smart_object_keys.h" -#include "application_manager/policies/mock_policy_handler_interface.h" -#include "protocol_handler/mock_session_observer.h" -#include "connection_handler/mock_connection_handler.h" +#include "application_manager/mock_application_manager.h" #include "application_manager/mock_hmi_capabilities.h" -#include "application_manager/mock_resume_ctrl.h" #include "application_manager/mock_hmi_interface.h" -#include "utils/data_accessor.h" +#include "application_manager/mock_resume_ctrl.h" +#include "application_manager/policies/mock_policy_handler_interface.h" +#include "application_manager/smart_object_keys.h" +#include "connection_handler/mock_connection_handler.h" +#include "gtest/gtest.h" +#include "interfaces/MOBILE_API.h" +#include "mobile/register_app_interface_request.h" +#include "protocol_handler/mock_session_observer.h" +#include "smart_objects/smart_object.h" #include "utils/custom_string.h" +#include "utils/data_accessor.h" #include "utils/lock.h" #include "utils/macro.h" #include "utils/semantic_version.h" @@ -64,9 +64,11 @@ namespace mobile_commands_test { namespace register_app_interface_request { using ::testing::_; +using ::testing::DoAll; using ::testing::Return; using ::testing::ReturnRef; -using ::testing::DoAll; +using ::testing::SaveArg; +using ::testing::SetArgPointee; namespace am = ::application_manager; @@ -75,12 +77,16 @@ using sdl_rpc_plugin::commands::RegisterAppInterfaceRequest; namespace { const uint32_t kConnectionKey = 1u; +const uint32_t kConnectionKey2 = 2u; +const connection_handler::DeviceHandle kDeviceHandle = 3u; const hmi_apis::Common_Language::eType kHmiLanguage = hmi_apis::Common_Language::EN_US; 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 kMacAddress1 = "test_mac_address1"; +const std::string kMacAddress2 = "test_mac_address2"; +const std::string kAppId1 = "test_app1_id"; +const std::string kAppId2 = "test_app2_id"; const std::string kFullAppId = "test_app_id_long"; const std::string kDummyString = "test_string"; const std::vector kDummyDiagModes; @@ -94,6 +100,7 @@ class RegisterAppInterfaceRequestTest : msg_(CreateMessage()) , command_(CreateCommand(msg_)) , app_name_("test_app_name_") + , app2_name_("test_app2_name_") , lock_ptr_(std::make_shared()) , mock_application_helper_( application_manager_test::MockApplicationHelper:: @@ -112,7 +119,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::app_id] = kAppId1; (*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] = @@ -130,11 +137,11 @@ class RegisterAppInterfaceRequestTest MockAppPtr CreateBasicMockedApp() { MockAppPtr mock_app = CreateMockApp(); ON_CALL(*mock_app, name()).WillByDefault(ReturnRef(app_name_)); - ON_CALL(*mock_app, mac_address()).WillByDefault(ReturnRef(kMacAddress)); + ON_CALL(*mock_app, mac_address()).WillByDefault(ReturnRef(kMacAddress1)); ON_CALL(*mock_app, app_icon_path()).WillByDefault(ReturnRef(kDummyString)); ON_CALL(*mock_app, language()).WillByDefault(ReturnRef(kMobileLanguage)); ON_CALL(*mock_app, ui_language()).WillByDefault(ReturnRef(kMobileLanguage)); - ON_CALL(*mock_app, policy_app_id()).WillByDefault(Return(kAppId)); + ON_CALL(*mock_app, policy_app_id()).WillByDefault(Return(kAppId1)); ON_CALL(*mock_app, msg_version()) .WillByDefault(ReturnRef(mock_semantic_version)); return mock_app; @@ -154,7 +161,7 @@ class RegisterAppInterfaceRequestTest void InitGetters() { ON_CALL(app_mngr_, GetCorrectMobileIDFromMessage(msg_)) - .WillByDefault(Return(kAppId)); + .WillByDefault(Return(kAppId1)); ON_CALL(app_mngr_, IsHMICooperating()).WillByDefault(Return(true)); ON_CALL(app_mngr_, resume_controller()) .WillByDefault(ReturnRef(mock_resume_crt_)); @@ -168,7 +175,7 @@ class RegisterAppInterfaceRequestTest .WillByDefault(ReturnRef(kDummyString)); ON_CALL(app_mngr_settings_, supported_diag_modes()) .WillByDefault(ReturnRef(kDummyDiagModes)); - ON_CALL(mock_policy_handler_, GetAppRequestTypes(_)) + ON_CALL(mock_policy_handler_, GetAppRequestTypes(_, _)) .WillByDefault(Return(std::vector())); ON_CALL(mock_policy_handler_, GetAppRequestTypeState(_)) .WillByDefault(Return(policy::RequestType::State::EMPTY)); @@ -180,7 +187,7 @@ class RegisterAppInterfaceRequestTest .WillByDefault(Return(policy::DeviceConsent::kDeviceAllowed)); ON_CALL(app_mngr_, GetDeviceTransportType(_)) .WillByDefault(Return(hmi_apis::Common_TransportType::WIFI)); - ON_CALL(app_mngr_, IsAppInReconnectMode(_)).WillByDefault(Return(false)); + ON_CALL(app_mngr_, IsAppInReconnectMode(_, _)).WillByDefault(Return(false)); ON_CALL(app_mngr_, application_by_policy_id(_)) .WillByDefault(Return(ApplicationSharedPtr())); ON_CALL(mock_hmi_interfaces_, GetInterfaceState(_)) @@ -201,7 +208,7 @@ class RegisterAppInterfaceRequestTest void SetCommonExpectionsOnSwitchedApplication( MockAppPtr mock_app, mobile_apis::Result::eType response_result_code) { - EXPECT_CALL(mock_policy_handler_, AddApplication(_, _)).Times(0); + EXPECT_CALL(mock_policy_handler_, AddApplication(_, _, _)).Times(0); EXPECT_CALL( mock_rpc_service_, @@ -212,13 +219,15 @@ class RegisterAppInterfaceRequestTest ManageHMICommand( HMIResultCodeIs( hmi_apis::FunctionID::BasicCommunication_OnAppRegistered), - _)).Times(0); + _)) + .Times(0); EXPECT_CALL( mock_rpc_service_, ManageHMICommand( HMIResultCodeIs(hmi_apis::FunctionID::Buttons_OnButtonSubscription), - _)).Times(0); + _)) + .Times(0); EXPECT_CALL( mock_rpc_service_, @@ -248,6 +257,7 @@ class RegisterAppInterfaceRequestTest std::shared_ptr command_; const utils::custom_string::CustomString app_name_; + const utils::custom_string::CustomString app2_name_; std::shared_ptr lock_ptr_; am::ApplicationSet app_set_; @@ -278,7 +288,7 @@ TEST_F(RegisterAppInterfaceRequestTest, Init_SUCCESS) { TEST_F(RegisterAppInterfaceRequestTest, Run_MinimalData_SUCCESS) { InitBasicMessage(); - (*msg_)[am::strings::msg_params][am::strings::hash_id] = kAppId; + (*msg_)[am::strings::msg_params][am::strings::hash_id] = kAppId1; EXPECT_CALL(app_mngr_, IsStopping()) .WillOnce(Return(false)) .WillOnce(Return(true)) @@ -287,20 +297,32 @@ TEST_F(RegisterAppInterfaceRequestTest, Run_MinimalData_SUCCESS) { EXPECT_CALL(app_mngr_, updateRequestTimeout(_, _, _)); EXPECT_CALL(app_mngr_, IsApplicationForbidden(_, _)).WillOnce(Return(false)); + connection_handler::DeviceHandle handle = 1; + ON_CALL(mock_connection_handler_, + GetDataOnSessionKey(kConnectionKey, _, _, _)) + .WillByDefault(DoAll(SetArgPointee<3>(handle), Return(0))); + ON_CALL(mock_session_observer_, GetDataOnDeviceID(handle, _, _, _, _)) + .WillByDefault(DoAll(SetArgPointee<3>(kMacAddress1), Return(0))); + MockAppPtr mock_app = CreateBasicMockedApp(); - EXPECT_CALL(app_mngr_, application(kConnectionKey)) - .WillOnce(Return(ApplicationSharedPtr())) - .WillRepeatedly(Return(mock_app)); + EXPECT_CALL(app_mngr_, reregister_application_by_policy_id(kAppId1)) + .WillOnce(Return(ApplicationSharedPtr())); + EXPECT_CALL(app_mngr_, application(kMacAddress1, kAppId1)) + .WillRepeatedly(Return(ApplicationSharedPtr())); ON_CALL(app_mngr_, applications()) .WillByDefault( Return(DataAccessor(app_set_, lock_ptr_))); + + EXPECT_CALL(app_mngr_, application(kConnectionKey)) + .WillOnce(Return(mock_app)); + ON_CALL(mock_policy_handler_, PolicyEnabled()).WillByDefault(Return(true)); - ON_CALL(mock_policy_handler_, GetInitialAppData(kAppId, _, _)) + ON_CALL(mock_policy_handler_, GetInitialAppData(kAppId1, _, _)) .WillByDefault(Return(true)); policy::StatusNotifier notify_upd_manager = std::make_shared(); - ON_CALL(mock_policy_handler_, AddApplication(_, _)) + ON_CALL(mock_policy_handler_, AddApplication(kMacAddress1, kAppId1, _)) .WillByDefault(Return(notify_upd_manager)); EXPECT_CALL(app_mngr_, RegisterApplication(msg_)).WillOnce(Return(mock_app)); @@ -309,16 +331,19 @@ TEST_F(RegisterAppInterfaceRequestTest, Run_MinimalData_SUCCESS) { ManageHMICommand( HMIResultCodeIs( hmi_apis::FunctionID::BasicCommunication_OnAppRegistered), - _)).WillOnce(Return(true)); + _)) + .WillOnce(Return(true)); EXPECT_CALL( mock_rpc_service_, ManageHMICommand( HMIResultCodeIs(hmi_apis::FunctionID::Buttons_OnButtonSubscription), - _)).WillOnce(Return(true)); + _)) + .WillOnce(Return(true)); EXPECT_CALL(mock_rpc_service_, ManageMobileCommand(_, am::commands::Command::SOURCE_SDL)) .Times(2); EXPECT_CALL(app_mngr_, SendDriverDistractionState(_)); + ASSERT_TRUE(command_->Init()); command_->Run(); } @@ -356,10 +381,21 @@ TEST_F(RegisterAppInterfaceRequestTest, EXPECT_CALL(app_mngr_, updateRequestTimeout(_, _, _)); EXPECT_CALL(app_mngr_, IsApplicationForbidden(_, _)).WillOnce(Return(false)); + connection_handler::DeviceHandle handle = 1; + ON_CALL(mock_connection_handler_, + GetDataOnSessionKey(kConnectionKey, _, _, _)) + .WillByDefault(DoAll(SetArgPointee<3>(handle), Return(0))); + ON_CALL(mock_session_observer_, GetDataOnDeviceID(_, _, _, _, _)) + .WillByDefault(DoAll(SetArgPointee<3>(kMacAddress1), Return(0))); + MockAppPtr mock_app = CreateBasicMockedApp(); + EXPECT_CALL(app_mngr_, reregister_application_by_policy_id(kAppId1)) + .WillOnce(Return(ApplicationSharedPtr())); + EXPECT_CALL(app_mngr_, application(kMacAddress1, kAppId1)) + .WillRepeatedly(Return(ApplicationSharedPtr())); + EXPECT_CALL(app_mngr_, application(kConnectionKey)) - .WillOnce(Return(ApplicationSharedPtr())) - .WillRepeatedly(Return(mock_app)); + .WillOnce(Return(mock_app)); MessageSharedPtr expected_message = CreateMessage(smart_objects::SmartType_Map); @@ -397,11 +433,11 @@ TEST_F(RegisterAppInterfaceRequestTest, .WillByDefault( Return(DataAccessor(app_set_, lock_ptr_))); ON_CALL(mock_policy_handler_, PolicyEnabled()).WillByDefault(Return(true)); - ON_CALL(mock_policy_handler_, GetInitialAppData(kAppId, _, _)) + ON_CALL(mock_policy_handler_, GetInitialAppData(kAppId1, _, _)) .WillByDefault(Return(true)); policy::StatusNotifier notify_upd_manager = std::make_shared(); - ON_CALL(mock_policy_handler_, AddApplication(_, _)) + ON_CALL(mock_policy_handler_, AddApplication(kMacAddress1, kAppId1, _)) .WillByDefault(Return(notify_upd_manager)); EXPECT_CALL(app_mngr_, RegisterApplication(msg_)).WillOnce(Return(mock_app)); @@ -413,29 +449,34 @@ TEST_F(RegisterAppInterfaceRequestTest, ManageHMICommand( HMIResultCodeIs( hmi_apis::FunctionID::BasicCommunication_OnAppRegistered), - _)).WillOnce(Return(true)); + _)) + .WillOnce(Return(true)); EXPECT_CALL( mock_rpc_service_, ManageHMICommand( HMIResultCodeIs(hmi_apis::FunctionID::Buttons_OnButtonSubscription), - _)).WillOnce(Return(true)); - EXPECT_CALL(mock_rpc_service_, - ManageHMICommand( - HMIResultCodeIs(hmi_apis::FunctionID::VR_ChangeRegistration), - _)).WillOnce(Return(true)); - EXPECT_CALL(mock_rpc_service_, - ManageHMICommand( - HMIResultCodeIs(hmi_apis::FunctionID::TTS_ChangeRegistration), - _)).WillOnce(Return(true)); - EXPECT_CALL(mock_rpc_service_, - ManageHMICommand( - HMIResultCodeIs(hmi_apis::FunctionID::UI_ChangeRegistration), - _)).WillOnce(Return(true)); + _)) + .WillOnce(Return(true)); + EXPECT_CALL( + mock_rpc_service_, + ManageHMICommand( + HMIResultCodeIs(hmi_apis::FunctionID::VR_ChangeRegistration), _)) + .WillOnce(Return(true)); + EXPECT_CALL( + mock_rpc_service_, + ManageHMICommand( + HMIResultCodeIs(hmi_apis::FunctionID::TTS_ChangeRegistration), _)) + .WillOnce(Return(true)); + EXPECT_CALL( + mock_rpc_service_, + ManageHMICommand( + HMIResultCodeIs(hmi_apis::FunctionID::UI_ChangeRegistration), _)) + .WillOnce(Return(true)); EXPECT_CALL(mock_rpc_service_, ManageMobileCommand(_, am::commands::Command::SOURCE_SDL)) .Times(2); EXPECT_CALL(app_mngr_, SendDriverDistractionState(_)); - + ASSERT_TRUE(command_->Init()); command_->Run(); } @@ -447,10 +488,19 @@ TEST_F(RegisterAppInterfaceRequestTest, (*msg_)[am::strings::msg_params][am::strings::hash_id] = request_hash_id; MockAppPtr mock_app = CreateBasicMockedApp(); - EXPECT_CALL(app_mngr_, application_by_policy_id(kAppId)) - .WillRepeatedly(Return(mock_app)); + app_set_.insert(mock_app); + EXPECT_CALL(app_mngr_, reregister_application_by_policy_id(kAppId1)) + .WillOnce(Return(mock_app)); + + connection_handler::DeviceHandle device_id = 1; + ON_CALL(mock_connection_handler_, + GetDataOnSessionKey(kConnectionKey, _, _, _)) + .WillByDefault(DoAll(SetArgPointee<3>(device_id), Return(0))); + + ON_CALL(mock_session_observer_, GetDataOnDeviceID(device_id, _, _, _, _)) + .WillByDefault(DoAll(SetArgPointee<3>(kMacAddress1), Return(0))); - EXPECT_CALL(app_mngr_, IsAppInReconnectMode(kAppId)).WillOnce(Return(true)); + EXPECT_CALL(*mock_app, device()).WillOnce(Return(kDeviceHandle)); EXPECT_CALL(app_mngr_, ProcessReconnection(_, kConnectionKey)); @@ -460,7 +510,8 @@ TEST_F(RegisterAppInterfaceRequestTest, mock_resume_crt_, CheckApplicationHash( std::static_pointer_cast(mock_app), - request_hash_id)).WillOnce(Return(true)); + request_hash_id)) + .WillOnce(Return(true)); EXPECT_CALL(mock_resume_crt_, RemoveApplicationFromSaved(_)).Times(0); @@ -472,6 +523,7 @@ TEST_F(RegisterAppInterfaceRequestTest, SetCommonExpectionsOnSwitchedApplication(mock_app, mobile_apis::Result::SUCCESS); + ASSERT_TRUE(command_->Init()); command_->Run(); } @@ -482,11 +534,18 @@ TEST_F(RegisterAppInterfaceRequestTest, const std::string request_hash_id = "abc123"; (*msg_)[am::strings::msg_params][am::strings::hash_id] = request_hash_id; - MockAppPtr mock_app = CreateBasicMockedApp(); - EXPECT_CALL(app_mngr_, application_by_policy_id(kAppId)) - .WillRepeatedly(Return(mock_app)); + connection_handler::DeviceHandle device_id = 1; + ON_CALL(mock_connection_handler_, + GetDataOnSessionKey(kConnectionKey, _, _, _)) + .WillByDefault(DoAll(SetArgPointee<3>(device_id), Return(0))); - EXPECT_CALL(app_mngr_, IsAppInReconnectMode(kAppId)).WillOnce(Return(true)); + ON_CALL(mock_session_observer_, GetDataOnDeviceID(device_id, _, _, _, _)) + .WillByDefault(DoAll(SetArgPointee<3>(kMacAddress1), Return(0))); + + MockAppPtr mock_app = CreateBasicMockedApp(); + EXPECT_CALL(app_mngr_, reregister_application_by_policy_id(kAppId1)) + .WillOnce(Return(mock_app)); + EXPECT_CALL(*mock_app, device()).WillOnce(Return(kDeviceHandle)); EXPECT_CALL(app_mngr_, ProcessReconnection(_, kConnectionKey)); @@ -494,7 +553,8 @@ TEST_F(RegisterAppInterfaceRequestTest, mock_resume_crt_, CheckApplicationHash( std::static_pointer_cast(mock_app), - request_hash_id)).WillOnce(Return(false)); + request_hash_id)) + .WillOnce(Return(false)); EXPECT_CALL( mock_application_helper_, @@ -509,7 +569,7 @@ TEST_F(RegisterAppInterfaceRequestTest, SetCommonExpectionsOnSwitchedApplication(mock_app, mobile_apis::Result::RESUME_FAILED); - + ASSERT_TRUE(command_->Init()); command_->Run(); } @@ -517,11 +577,18 @@ TEST_F(RegisterAppInterfaceRequestTest, SwitchApplication_NoHash_ExpectCleanupResumeFailed) { InitBasicMessage(); - MockAppPtr mock_app = CreateBasicMockedApp(); - EXPECT_CALL(app_mngr_, application_by_policy_id(kAppId)) - .WillRepeatedly(Return(mock_app)); + connection_handler::DeviceHandle device_id = 1; + ON_CALL(mock_connection_handler_, + GetDataOnSessionKey(kConnectionKey, _, _, _)) + .WillByDefault(DoAll(SetArgPointee<3>(device_id), Return(0))); - EXPECT_CALL(app_mngr_, IsAppInReconnectMode(kAppId)).WillOnce(Return(true)); + ON_CALL(mock_session_observer_, GetDataOnDeviceID(device_id, _, _, _, _)) + .WillByDefault(DoAll(SetArgPointee<3>(kMacAddress1), Return(0))); + + MockAppPtr mock_app = CreateBasicMockedApp(); + EXPECT_CALL(app_mngr_, reregister_application_by_policy_id(kAppId1)) + .WillOnce(Return(mock_app)); + EXPECT_CALL(*mock_app, device()).WillOnce(Return(kDeviceHandle)); EXPECT_CALL(app_mngr_, ProcessReconnection(_, kConnectionKey)); @@ -539,6 +606,137 @@ TEST_F(RegisterAppInterfaceRequestTest, SetCommonExpectionsOnSwitchedApplication(mock_app, mobile_apis::Result::RESUME_FAILED); + ASSERT_TRUE(command_->Init()); + command_->Run(); +} + +TEST_F(RegisterAppInterfaceRequestTest, + RegisterApp_SameAppId_SameDeviceFailed) { + using namespace am; + + InitBasicMessage(); + + MockAppPtr mock_app1 = CreateBasicMockedApp(); + + app_set_.insert(mock_app1); + ON_CALL(app_mngr_, applications()) + .WillByDefault( + Return(DataAccessor(app_set_, lock_ptr_))); + + MockAppPtr mock_app2 = CreateBasicMockedApp(); + + connection_handler::DeviceHandle device_id = 1; + ON_CALL(mock_connection_handler_, + GetDataOnSessionKey(kConnectionKey, _, _, _)) + .WillByDefault(DoAll(SetArgPointee<3>(device_id), Return(0))); + + ON_CALL(mock_session_observer_, GetDataOnDeviceID(device_id, _, _, _, _)) + .WillByDefault(DoAll(SetArgPointee<3>(kMacAddress1), Return(0))); + + EXPECT_CALL(app_mngr_, reregister_application_by_policy_id(kAppId1)) + .WillOnce(Return(ApplicationSharedPtr())); + EXPECT_CALL(app_mngr_, application(kMacAddress1, kAppId1)) + .WillOnce(Return(mock_app1)); + + EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_, _)).Times(0); + + EXPECT_CALL(mock_rpc_service_, + ManageMobileCommand( + MobileResultCodeIs( + mobile_apis::Result::APPLICATION_REGISTERED_ALREADY), + am::commands::Command::SOURCE_SDL)); + + ASSERT_TRUE(command_->Init()); + command_->Run(); +} + +TEST_F(RegisterAppInterfaceRequestTest, + RegisterApp_SameAppId_DifferentDevicesSuccess) { + MockAppPtr mock_app1 = CreateBasicMockedApp(); + const connection_handler::DeviceHandle device_id1 = 1u; + ON_CALL(*mock_app1, device()).WillByDefault(Return(device_id1)); + app_set_.insert(mock_app1); + ON_CALL(app_mngr_, applications()) + .WillByDefault( + Return(DataAccessor(app_set_, lock_ptr_))); + + InitBasicMessage(); + (*msg_)[am::strings::params][am::strings::connection_key] = kConnectionKey2; + EXPECT_CALL(app_mngr_, IsStopping()) + .WillOnce(Return(false)) + .WillOnce(Return(true)) + .WillOnce(Return(false)); + ON_CALL(app_mngr_, IsHMICooperating()).WillByDefault(Return(false)); + EXPECT_CALL(app_mngr_, updateRequestTimeout(kConnectionKey2, _, _)); + EXPECT_CALL(app_mngr_, IsApplicationForbidden(kConnectionKey2, kAppId1)) + .WillOnce(Return(false)); + + connection_handler::DeviceHandle device_id2 = 2u; + ON_CALL(mock_connection_handler_, + GetDataOnSessionKey(kConnectionKey2, _, _, _)) + .WillByDefault(DoAll(SetArgPointee<3>(device_id2), Return(0))); + + ON_CALL(mock_session_observer_, GetDataOnDeviceID(device_id2, _, _, _, _)) + .WillByDefault(DoAll(SetArgPointee<3>(kMacAddress2), Return(0))); + + MockAppPtr mock_app2 = CreateBasicMockedApp(); + + ON_CALL(*mock_app2, device()).WillByDefault(Return(device_id2)); + ON_CALL(*mock_app2, mac_address()).WillByDefault(ReturnRef(kMacAddress2)); + EXPECT_CALL(app_mngr_, application(kMacAddress2, kAppId1)) + .WillRepeatedly(Return(ApplicationSharedPtr())); + EXPECT_CALL(app_mngr_, reregister_application_by_policy_id(kAppId1)) + .WillOnce(Return(ApplicationSharedPtr())); + + EXPECT_CALL(app_mngr_, application(kConnectionKey2)) + .WillOnce(Return(mock_app2)); + + ON_CALL(mock_policy_handler_, PolicyEnabled()).WillByDefault(Return(true)); + ON_CALL(mock_policy_handler_, GetInitialAppData(kAppId1, _, _)) + .WillByDefault(Return(true)); + policy::StatusNotifier notify_upd_manager = + std::make_shared(); + ON_CALL(mock_policy_handler_, AddApplication(kMacAddress2, kAppId1, _)) + .WillByDefault(Return(notify_upd_manager)); + + EXPECT_CALL(app_mngr_, RegisterApplication(msg_)).WillOnce(Return(mock_app2)); + + EXPECT_CALL(mock_hmi_interfaces_, GetInterfaceState(_)) + .WillRepeatedly(Return(am::HmiInterfaces::STATE_AVAILABLE)); + + EXPECT_CALL(mock_rpc_service_, + ManageHMICommand( + HMIResultCodeIs( + hmi_apis::FunctionID::BasicCommunication_OnAppRegistered), + _)) + .WillOnce(Return(true)); + EXPECT_CALL( + mock_rpc_service_, + ManageHMICommand( + HMIResultCodeIs(hmi_apis::FunctionID::Buttons_OnButtonSubscription), + _)) + .WillOnce(Return(true)); + EXPECT_CALL( + mock_rpc_service_, + ManageHMICommand( + HMIResultCodeIs(hmi_apis::FunctionID::VR_ChangeRegistration), _)) + .WillOnce(Return(true)); + EXPECT_CALL( + mock_rpc_service_, + ManageHMICommand( + HMIResultCodeIs(hmi_apis::FunctionID::TTS_ChangeRegistration), _)) + .WillOnce(Return(true)); + EXPECT_CALL( + mock_rpc_service_, + ManageHMICommand( + HMIResultCodeIs(hmi_apis::FunctionID::UI_ChangeRegistration), _)) + .WillOnce(Return(true)); + EXPECT_CALL(mock_rpc_service_, + ManageMobileCommand(_, am::commands::Command::SOURCE_SDL)) + .Times(2); + EXPECT_CALL(app_mngr_, SendDriverDistractionState(_)); + + ASSERT_TRUE(command_->Init()); command_->Run(); } diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/reset_global_properties_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/reset_global_properties_test.cc index 38585319e45..98c0ad098aa 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/reset_global_properties_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/reset_global_properties_test.cc @@ -37,17 +37,17 @@ #include "mobile/reset_global_properties_request.h" #include "mobile/reset_global_properties_response.h" -#include "gtest/gtest.h" -#include "smart_objects/smart_object.h" -#include "interfaces/HMI_API.h" -#include "interfaces/MOBILE_API.h" -#include "application_manager/smart_object_keys.h" -#include "application_manager/commands/commands_test.h" #include "application_manager/commands/command_request_test.h" -#include "application_manager/mock_application_manager.h" +#include "application_manager/commands/commands_test.h" +#include "application_manager/event_engine/event.h" #include "application_manager/mock_application.h" +#include "application_manager/mock_application_manager.h" #include "application_manager/mock_message_helper.h" -#include "application_manager/event_engine/event.h" +#include "application_manager/smart_object_keys.h" +#include "gtest/gtest.h" +#include "interfaces/HMI_API.h" +#include "interfaces/MOBILE_API.h" +#include "smart_objects/smart_object.h" namespace test { namespace components { @@ -61,11 +61,11 @@ using ::testing::ReturnRef; namespace am = ::application_manager; -using sdl_rpc_plugin::commands::ResetGlobalPropertiesRequest; -using sdl_rpc_plugin::commands::ResetGlobalPropertiesResponse; +using am::MockMessageHelper; using am::commands::MessageSharedPtr; using am::event_engine::Event; -using am::MockMessageHelper; +using sdl_rpc_plugin::commands::ResetGlobalPropertiesRequest; +using sdl_rpc_plugin::commands::ResetGlobalPropertiesResponse; typedef std::shared_ptr ResetGlobalPropertiesRequestPtr; @@ -237,10 +237,11 @@ TEST_F(ResetGlobalPropertiesRequestTest, Run_SUCCESS) { EXPECT_CALL(*mock_app_, timeout_prompt()) .WillOnce(Return(so_help_prompt.get())); - EXPECT_CALL(mock_rpc_service_, - ManageHMICommand( - HMIResultCodeIs(hmi_apis::FunctionID::UI_SetGlobalProperties), - _)).WillOnce(Return(true)); + EXPECT_CALL( + mock_rpc_service_, + ManageHMICommand( + HMIResultCodeIs(hmi_apis::FunctionID::UI_SetGlobalProperties), _)) + .WillOnce(Return(true)); EXPECT_CALL( mock_rpc_service_, ManageHMICommand( @@ -275,10 +276,11 @@ TEST_F(ResetGlobalPropertiesRequestTest, smart_objects::SmartType_Map); EXPECT_CALL(mock_message_helper_, CreateAppVrHelp(_)) .WillOnce(Return(vr_help)); - EXPECT_CALL(mock_rpc_service_, - ManageHMICommand( - HMIResultCodeIs(hmi_apis::FunctionID::UI_SetGlobalProperties), - _)).WillOnce(Return(true)); + EXPECT_CALL( + mock_rpc_service_, + ManageHMICommand( + HMIResultCodeIs(hmi_apis::FunctionID::UI_SetGlobalProperties), _)) + .WillOnce(Return(true)); command_->Run(); @@ -321,10 +323,11 @@ TEST_F(ResetGlobalPropertiesRequestTest, (*ui_msg)[am::strings::params][am::strings::correlation_id] = kCorrelationId; (*ui_msg)[am::strings::params][am::hmi_response::code] = hmi_apis::Common_Result::eType::SUCCESS; - EXPECT_CALL(mock_rpc_service_, - ManageHMICommand( - HMIResultCodeIs(hmi_apis::FunctionID::UI_SetGlobalProperties), - _)).WillOnce(Return(true)); + EXPECT_CALL( + mock_rpc_service_, + ManageHMICommand( + HMIResultCodeIs(hmi_apis::FunctionID::UI_SetGlobalProperties), _)) + .WillOnce(Return(true)); EXPECT_CALL( mock_rpc_service_, ManageHMICommand( @@ -364,10 +367,11 @@ TEST_F(ResetGlobalPropertiesRequestTest, OnEvent_InvalidApp_NoHashUpdate) { EXPECT_CALL(*mock_app_, reset_vr_help()); EXPECT_CALL(*mock_app_, set_reset_global_properties_active(true)); - EXPECT_CALL(mock_rpc_service_, - ManageHMICommand( - HMIResultCodeIs(hmi_apis::FunctionID::UI_SetGlobalProperties), - _)).WillOnce(Return(true)); + EXPECT_CALL( + mock_rpc_service_, + ManageHMICommand( + HMIResultCodeIs(hmi_apis::FunctionID::UI_SetGlobalProperties), _)) + .WillOnce(Return(true)); smart_objects::SmartObjectSPtr vr_help = std::make_shared( smart_objects::SmartType_Map); @@ -414,10 +418,11 @@ TEST_F(ResetGlobalPropertiesRequestTest, EXPECT_CALL(*mock_app_, set_reset_global_properties_active(true)); - EXPECT_CALL(mock_rpc_service_, - ManageHMICommand( - HMIResultCodeIs(hmi_apis::FunctionID::UI_SetGlobalProperties), - _)).WillOnce(Return(true)); + EXPECT_CALL( + mock_rpc_service_, + ManageHMICommand( + HMIResultCodeIs(hmi_apis::FunctionID::UI_SetGlobalProperties), _)) + .WillOnce(Return(true)); EXPECT_CALL( mock_rpc_service_, ManageHMICommand( @@ -480,10 +485,11 @@ TEST_F(ResetGlobalPropertiesRequestTest, EXPECT_CALL(*mock_app_, set_reset_global_properties_active(true)); - EXPECT_CALL(mock_rpc_service_, - ManageHMICommand( - HMIResultCodeIs(hmi_apis::FunctionID::UI_SetGlobalProperties), - _)).WillOnce(Return(true)); + EXPECT_CALL( + mock_rpc_service_, + ManageHMICommand( + HMIResultCodeIs(hmi_apis::FunctionID::UI_SetGlobalProperties), _)) + .WillOnce(Return(true)); EXPECT_CALL( mock_rpc_service_, ManageHMICommand( @@ -545,10 +551,11 @@ TEST_F(ResetGlobalPropertiesRequestTest, EXPECT_CALL(*mock_app_, set_reset_global_properties_active(true)); - EXPECT_CALL(mock_rpc_service_, - ManageHMICommand( - HMIResultCodeIs(hmi_apis::FunctionID::UI_SetGlobalProperties), - _)).WillOnce(Return(true)); + EXPECT_CALL( + mock_rpc_service_, + ManageHMICommand( + HMIResultCodeIs(hmi_apis::FunctionID::UI_SetGlobalProperties), _)) + .WillOnce(Return(true)); EXPECT_CALL( mock_rpc_service_, ManageHMICommand( diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/scrollable_message_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/scrollable_message_test.cc index cf25a829721..6b17aa238d6 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/scrollable_message_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/scrollable_message_test.cc @@ -31,20 +31,20 @@ */ #include -#include #include +#include #include "mobile/scrollable_message_request.h" -#include "gtest/gtest.h" #include "application_manager/commands/command_request_test.h" +#include "application_manager/event_engine/event.h" #include "application_manager/mock_application.h" #include "application_manager/mock_application_manager.h" -#include "application_manager/mock_message_helper.h" -#include "application_manager/event_engine/event.h" -#include "application_manager/mock_hmi_interface.h" #include "application_manager/mock_hmi_capabilities.h" +#include "application_manager/mock_hmi_interface.h" +#include "application_manager/mock_message_helper.h" #include "application_manager/policies/mock_policy_handler_interface.h" +#include "gtest/gtest.h" namespace test { namespace components { @@ -57,10 +57,10 @@ namespace hmi_response = am::hmi_response; namespace mobile_result = mobile_apis::Result; namespace am = ::application_manager; -using sdl_rpc_plugin::commands::ScrollableMessageRequest; +using am::MockMessageHelper; using am::commands::CommandImpl; using am::commands::MessageSharedPtr; -using am::MockMessageHelper; +using sdl_rpc_plugin::commands::ScrollableMessageRequest; using ::testing::_; using ::testing::Eq; using ::testing::Ref; @@ -175,7 +175,7 @@ TEST_F(ScrollableMessageRequestTest, Init_CorrectTimeout_SUCCESS) { mobile_apis::InteractionMode::MANUAL_ONLY; EXPECT_EQ(kDefaultTimeout_, command_->default_timeout()); command_->Init(); - EXPECT_EQ(kTimeOut, command_->default_timeout()); + EXPECT_EQ(kTimeOut + kDefaultTimeout_, command_->default_timeout()); } TEST_F(ScrollableMessageRequestTest, Init_CorrectTimeout_UNSUCCESS) { @@ -183,7 +183,7 @@ TEST_F(ScrollableMessageRequestTest, Init_CorrectTimeout_UNSUCCESS) { mobile_apis::InteractionMode::MANUAL_ONLY; EXPECT_EQ(kDefaultTimeout_, command_->default_timeout()); command_->Init(); - EXPECT_EQ(kTimeOut, command_->default_timeout()); + EXPECT_EQ(kDefaultTimeout_, command_->default_timeout()); } TEST_F(ScrollableMessageRequestTest, Run_ApplicationIsNotRegistered_UNSUCCESS) { @@ -282,4 +282,4 @@ TEST_F(ScrollableMessageRequestTest, } // namespace mobile_commands_test } // namespace commands_test } // namespace components -} // namespace tests +} // namespace test diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/send_haptic_data_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/send_haptic_data_test.cc index 19f799448ad..3cb9642021d 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/send_haptic_data_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/send_haptic_data_test.cc @@ -32,15 +32,15 @@ #include "gtest/gtest.h" -#include "application_manager/commands/commands_test.h" #include "application_manager/commands/command_request_test.h" +#include "application_manager/commands/commands_test.h" #include "mobile/send_haptic_data_request.h" #include "mobile/send_haptic_data_response.h" -#include "interfaces/MOBILE_API.h" #include "application_manager/application.h" #include "application_manager/mock_application.h" +#include "interfaces/MOBILE_API.h" namespace test { namespace components { @@ -53,9 +53,9 @@ using ::testing::Return; namespace am = ::application_manager; +using am::commands::MessageSharedPtr; using sdl_rpc_plugin::commands::SendHapticDataRequest; using sdl_rpc_plugin::commands::SendHapticDataResponse; -using am::commands::MessageSharedPtr; typedef std::shared_ptr SendHapticDataRequestPtr; typedef std::shared_ptr SendHapticDataResponsePtr; 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 4cab3db2a33..5d904532780 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 @@ -32,10 +32,10 @@ #include #include -#include "gtest/gtest.h" -#include "mobile/send_location_request.h" #include "application_manager/mock_hmi_capabilities.h" #include "application_manager/mock_message_helper.h" +#include "gtest/gtest.h" +#include "mobile/send_location_request.h" #include "application_manager/commands/command_request_test.h" @@ -45,11 +45,11 @@ namespace commands_test { namespace mobile_commands_test { namespace send_location_request { +using application_manager::MockMessageHelper; using application_manager::commands::MessageSharedPtr; using sdl_rpc_plugin::commands::SendLocationRequest; -using application_manager::MockMessageHelper; -using test::components::application_manager_test::MockHMICapabilities; using smart_objects::SmartObject; +using test::components::application_manager_test::MockHMICapabilities; using testing::_; using testing::Return; diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/set_app_icon_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/set_app_icon_test.cc index d8d1faca472..116a796312e 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/set_app_icon_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/set_app_icon_test.cc @@ -31,20 +31,20 @@ */ #include -#include #include +#include #include "mobile/set_app_icon_request.h" -#include "gtest/gtest.h" #include "application_manager/commands/command_request_test.h" +#include "application_manager/event_engine/event.h" #include "application_manager/mock_application.h" #include "application_manager/mock_application_manager.h" +#include "application_manager/mock_hmi_interface.h" +#include "application_manager/mock_message_helper.h" +#include "gtest/gtest.h" #include "protocol_handler/mock_protocol_handler.h" #include "protocol_handler/mock_protocol_handler_settings.h" -#include "application_manager/mock_message_helper.h" -#include "application_manager/event_engine/event.h" -#include "application_manager/mock_hmi_interface.h" namespace test { namespace components { @@ -53,11 +53,11 @@ namespace mobile_commands_test { namespace set_app_icon_request { namespace am = application_manager; -using sdl_rpc_plugin::commands::SetAppIconRequest; +using am::MockHmiInterfaces; +using am::MockMessageHelper; using am::commands::CommandImpl; using am::commands::MessageSharedPtr; -using am::MockMessageHelper; -using am::MockHmiInterfaces; +using sdl_rpc_plugin::commands::SetAppIconRequest; using test::components::protocol_handler_test::MockProtocolHandler; using test::components::protocol_handler_test::MockProtocolHandlerSettings; using ::testing::_; @@ -170,4 +170,4 @@ TEST_F(SetAppIconRequestTest, OnEvent_UI_UNSUPPORTED_RESOURCE) { } // namespace mobile_commands_test } // namespace commands_test } // namespace components -} // namespace tests +} // namespace test diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/set_display_layout_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/set_display_layout_test.cc index 10ca9257393..cde15a23189 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/set_display_layout_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/set_display_layout_test.cc @@ -31,19 +31,19 @@ */ #include -#include #include +#include #include "mobile/set_display_layout_request.h" -#include "gtest/gtest.h" #include "application_manager/commands/command_request_test.h" +#include "application_manager/event_engine/event.h" #include "application_manager/mock_application.h" #include "application_manager/mock_application_manager.h" -#include "application_manager/mock_message_helper.h" -#include "application_manager/event_engine/event.h" -#include "application_manager/mock_hmi_interface.h" #include "application_manager/mock_hmi_capabilities.h" +#include "application_manager/mock_hmi_interface.h" +#include "application_manager/mock_message_helper.h" +#include "gtest/gtest.h" namespace test { namespace components { @@ -53,10 +53,10 @@ namespace set_display_layout_request { namespace am = application_manager; namespace mobile_result = mobile_apis::Result; -using sdl_rpc_plugin::commands::SetDisplayLayoutRequest; +using am::MockMessageHelper; using am::commands::CommandImpl; using am::commands::MessageSharedPtr; -using am::MockMessageHelper; +using sdl_rpc_plugin::commands::SetDisplayLayoutRequest; using ::testing::_; using ::testing::Return; using ::testing::ReturnRef; @@ -160,6 +160,7 @@ TEST_F(SetDisplayLayoutRequestTest, ManageMobileCommand(_, am::commands::Command::CommandSource::SOURCE_SDL)) .WillOnce(DoAll(SaveArg<0>(&ui_command_result), Return(true))); + command->Init(); command->on_event(event); ResultCommandExpectations(ui_command_result, "UI is not supported by system"); @@ -178,6 +179,7 @@ TEST_F(SetDisplayLayoutRequestTest, Run_InvalidApp_UNSUCCESS) { MobileResultCodeIs(mobile_result::APPLICATION_NOT_REGISTERED), am::commands::Command::CommandSource::SOURCE_SDL)); + command->Init(); command->Run(); } @@ -188,7 +190,7 @@ TEST_F(SetDisplayLayoutRequestTest, Run_SUCCESS) { MockAppPtr mock_app(CreateMockApp()); EXPECT_CALL(app_mngr_, application(kConnectionKey)) .WillOnce(Return(mock_app)); - EXPECT_CALL(*mock_app, display_layout()).WillOnce(ReturnRef(kLayout)); + EXPECT_CALL(*mock_app, display_layout()).WillOnce(Return(kLayout)); EXPECT_CALL(*mock_app, app_id()).WillOnce(Return(kAppId)); EXPECT_CALL(app_mngr_, GetNextHMICorrelationID()) @@ -204,20 +206,60 @@ TEST_F(SetDisplayLayoutRequestTest, Run_SUCCESS) { ManageHMICommand(CheckMshCorrId(kCorrelationKey), _)) .WillOnce(Return(true)); + command->Init(); command->Run(); } TEST_F(SetDisplayLayoutRequestTest, OnEvent_InvalidEventId_UNSUCCESS) { - CommandPtr command(CreateCommand()); + MessageSharedPtr msg(CreateMessage(smart_objects::SmartType_Map)); + (*msg)[am::strings::params][am::strings::connection_key] = kConnectionKey; + CommandPtr command(CreateCommand(msg)); + am::event_engine::Event event(hmi_apis::FunctionID::INVALID_ENUM); - SmartObject msg(smart_objects::SmartType_Map); - event.set_smart_object(msg); + event.set_smart_object(*msg); + MockAppPtr mock_app(CreateMockApp()); + EXPECT_CALL(app_mngr_, application(kConnectionKey)) + .WillOnce(Return(mock_app)); + command->Init(); + command->on_event(event); +} + +TEST_F(SetDisplayLayoutRequestTest, OnEvent_AppVersion_v6_WARNING) { + am::event_engine::Event event(hmi_apis::FunctionID::UI_SetDisplayLayout); + MessageSharedPtr msg = CreateMessage(); + + (*msg)[am::strings::params][am::hmi_response::code] = + hmi_apis::Common_Result::SUCCESS; + (*msg)[am::strings::msg_params][am::hmi_response::display_capabilities] = 0; + (*msg)[am::strings::params][am::strings::connection_key] = kConnectionKey; + event.set_smart_object(*msg); + + MessageSharedPtr dispaly_capabilities_msg = CreateMessage(); + (*dispaly_capabilities_msg)[am::hmi_response::templates_available] = + "templates_available"; + + EXPECT_CALL(mock_hmi_capabilities_, display_capabilities()) + .WillOnce(Return(dispaly_capabilities_msg.get())); + EXPECT_CALL( + mock_rpc_service_, + ManageMobileCommand(MobileResultCodeIs(mobile_result::WARNINGS), + am::commands::Command::CommandSource::SOURCE_SDL)); + + CommandPtr command(CreateCommand(msg)); + MockAppPtr mock_app(CreateMockApp()); + EXPECT_CALL(app_mngr_, application(kConnectionKey)) + .WillOnce(Return(mock_app)); + ::application_manager::Version app_version; + app_version.max_supported_api_version = + ::application_manager::APIVersion::kAPIV6; + EXPECT_CALL(*mock_app, version()).WillOnce(ReturnRef(app_version)); + command->Init(); command->on_event(event); } -TEST_F(SetDisplayLayoutRequestTest, OnEvent_SUCCESS) { +TEST_F(SetDisplayLayoutRequestTest, OnEvent_AppVersion_v5_SUCCESS) { am::event_engine::Event event(hmi_apis::FunctionID::UI_SetDisplayLayout); MessageSharedPtr msg = CreateMessage(); @@ -239,6 +281,15 @@ TEST_F(SetDisplayLayoutRequestTest, OnEvent_SUCCESS) { am::commands::Command::CommandSource::SOURCE_SDL)); CommandPtr command(CreateCommand(msg)); + MockAppPtr mock_app(CreateMockApp()); + EXPECT_CALL(app_mngr_, application(kConnectionKey)) + .WillOnce(Return(mock_app)); + ::application_manager::Version app_version; + app_version.max_supported_api_version = + ::application_manager::APIVersion::kAPIV5; + EXPECT_CALL(*mock_app, version()).WillOnce(ReturnRef(app_version)); + + command->Init(); command->on_event(event); } @@ -246,4 +297,4 @@ TEST_F(SetDisplayLayoutRequestTest, OnEvent_SUCCESS) { } // namespace mobile_commands_test } // namespace commands_test } // namespace components -} // namespace tests +} // namespace test 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 94dbbc8b44d..9b72d41f7e1 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 @@ -32,19 +32,20 @@ #include #include -#include #include +#include #include "mobile/set_global_properties_request.h" -#include "gtest/gtest.h" #include "application_manager/commands/command_request_test.h" +#include "application_manager/event_engine/event.h" +#include "application_manager/message_helper.h" #include "application_manager/mock_application.h" -#include "application_manager/mock_help_prompt_manager.h" #include "application_manager/mock_application_manager.h" -#include "application_manager/mock_message_helper.h" -#include "application_manager/event_engine/event.h" +#include "application_manager/mock_help_prompt_manager.h" #include "application_manager/mock_hmi_interface.h" +#include "application_manager/mock_message_helper.h" +#include "gtest/gtest.h" namespace test { namespace components { @@ -53,15 +54,15 @@ namespace mobile_commands_test { namespace set_global_properties_request { namespace am = application_manager; -using sdl_rpc_plugin::commands::SetGlobalPropertiesRequest; +using am::CommandsMap; +using am::MockMessageHelper; using am::commands::CommandImpl; using am::commands::MessageSharedPtr; -using am::MockMessageHelper; -using am::CommandsMap; -using utils::custom_string::CustomString; +using sdl_rpc_plugin::commands::SetGlobalPropertiesRequest; using ::testing::_; using ::testing::Return; using ::testing::ReturnRef; +using utils::custom_string::CustomString; namespace { const int32_t kCommandId = 1; @@ -70,6 +71,13 @@ const uint32_t kCmdId = 1u; const uint32_t kConnectionKey = 1u; const std::string kText = "one"; const uint32_t kPosition = 1u; + +const std::vector success_result_codes{ + hmi_apis::Common_Result::SUCCESS, + hmi_apis::Common_Result::WARNINGS, + hmi_apis::Common_Result::WRONG_LANGUAGE, + hmi_apis::Common_Result::RETRY, + hmi_apis::Common_Result::SAVED}; } // namespace class SetGlobalPropertiesRequestTest @@ -233,9 +241,16 @@ class SetGlobalPropertiesRequestTest ON_CALL(app_mngr_, application(kConnectionKey)) .WillByDefault(Return(mock_app_)); ON_CALL(*mock_app_, app_id()).WillByDefault(Return(kConnectionKey)); - ON_CALL(mock_hmi_interfaces_, - GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_UI)) + ON_CALL(mock_hmi_interfaces_, GetInterfaceState(_)) .WillByDefault(Return(am::HmiInterfaces::STATE_AVAILABLE)); + ON_CALL(mock_app_manager_, hmi_interfaces()) + .WillByDefault(ReturnRef(mock_hmi_interfaces_)); + ON_CALL(mock_message_helper_, + MobileToHMIResult(mobile_apis::Result::UNSUPPORTED_RESOURCE)) + .WillByDefault(Return(hmi_apis::Common_Result::UNSUPPORTED_RESOURCE)); + ON_CALL(mock_message_helper_, + MobileToHMIResult(mobile_apis::Result::WARNINGS)) + .WillByDefault(Return(hmi_apis::Common_Result::WARNINGS)); } void ResultCommandExpectations(MessageSharedPtr msg, @@ -243,8 +258,8 @@ class SetGlobalPropertiesRequestTest EXPECT_EQ((*msg)[am::strings::msg_params][am::strings::success].asBool(), true); EXPECT_EQ( - (*msg)[am::strings::msg_params][am::strings::result_code].asInt(), - static_cast(hmi_apis::Common_Result::UNSUPPORTED_RESOURCE)); + static_cast(hmi_apis::Common_Result::UNSUPPORTED_RESOURCE), + (*msg)[am::strings::msg_params][am::strings::result_code].asInt()); EXPECT_EQ((*msg)[am::strings::msg_params][am::strings::info].asString(), info); } @@ -265,10 +280,128 @@ class SetGlobalPropertiesRequestTest GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_TTS)) .WillByDefault(Return(am::HmiInterfaces::STATE_AVAILABLE)); } + + // Checks total result code for each properties + void PrepareResultCodeForResponse_CheckTotalCode( + const hmi_apis::Common_Result::eType& ui_result, + const hmi_apis::Common_Result::eType& tts_result, + const hmi_apis::Common_Result::eType& rc_result, + const mobile_apis::Result::eType expected_total_result_code) { + using namespace application_manager; + using namespace hmi_apis; + + commands::ResponseInfo ui_properties_info( + ui_result, HmiInterfaces::HMI_INTERFACE_UI, mock_app_manager_); + commands::ResponseInfo tts_properties_info( + tts_result, HmiInterfaces::HMI_INTERFACE_TTS, mock_app_manager_); + commands::ResponseInfo rc_properties_info( + rc_result, HmiInterfaces::HMI_INTERFACE_RC, mock_app_manager_); + + MessageSharedPtr msg = CreateMsgParams(); + std::shared_ptr command( + CreateCommand(msg)); + + auto result = command->PrepareResultCodeForResponse( + ui_properties_info, tts_properties_info, rc_properties_info); + + EXPECT_EQ(expected_total_result_code, result); + } + + // Sets in rotation for each result UNSUPPROTED result code and checks total + // result code + void PrepareResultCodeForResponse_CheckAllResultsForSpecifiedTotalResult( + mobile_apis::Result::eType expected_total_result_code) { + using namespace application_manager; + using namespace hmi_apis; + + Common_Result::eType ui_result = + MessageHelper::MobileToHMIResult(expected_total_result_code); + Common_Result::eType tts_result = Common_Result::SUCCESS; + Common_Result::eType rc_result = Common_Result::SUCCESS; + + PrepareResultCodeForResponse_CheckTotalCode( + ui_result, tts_result, rc_result, expected_total_result_code); + + ui_result = Common_Result::SUCCESS; + tts_result = MessageHelper::MobileToHMIResult(expected_total_result_code); + + PrepareResultCodeForResponse_CheckTotalCode( + ui_result, tts_result, rc_result, expected_total_result_code); + + tts_result = Common_Result::SUCCESS; + rc_result = MessageHelper::MobileToHMIResult(expected_total_result_code); + + PrepareResultCodeForResponse_CheckTotalCode( + ui_result, tts_result, rc_result, expected_total_result_code); + } + + void PrepareResultForMobileResponse_CheckTotalReault( + const hmi_apis::Common_Result::eType& ui_result, + const hmi_apis::Common_Result::eType& tts_result, + const hmi_apis::Common_Result::eType& rc_result, + const bool expected_total_result) { + using namespace application_manager; + using namespace hmi_apis; + + commands::ResponseInfo ui_properties_info( + ui_result, HmiInterfaces::HMI_INTERFACE_UI, mock_app_manager_); + commands::ResponseInfo tts_properties_info( + tts_result, HmiInterfaces::HMI_INTERFACE_TTS, mock_app_manager_); + commands::ResponseInfo rc_properties_info( + rc_result, HmiInterfaces::HMI_INTERFACE_RC, mock_app_manager_); + + MessageSharedPtr msg = CreateMsgParams(); + std::shared_ptr command( + CreateCommand(msg)); + + bool result = command->PrepareResultForMobileResponse( + ui_properties_info, tts_properties_info, rc_properties_info); + + EXPECT_EQ(expected_total_result, result); + } + + void PrepareResultForMobileResponse_CheckResultsForAllCases() { + using namespace application_manager; + using namespace hmi_apis; + + Common_Result::eType ui_result = Common_Result::SUCCESS; + Common_Result::eType tts_result = Common_Result::SUCCESS; + Common_Result::eType rc_result = Common_Result::SUCCESS; + + PrepareResultForMobileResponse_CheckTotalReault( + ui_result, tts_result, rc_result, true); + + // Result code isn't success + EXPECT_FALSE(helpers::in_range(success_result_codes, + Common_Result::UNSUPPORTED_REQUEST)); + + ui_result = Common_Result::UNSUPPORTED_REQUEST; + tts_result = Common_Result::SUCCESS; + rc_result = Common_Result::SUCCESS; + + PrepareResultForMobileResponse_CheckTotalReault( + ui_result, tts_result, rc_result, false); + + ui_result = Common_Result::SUCCESS; + tts_result = Common_Result::UNSUPPORTED_REQUEST; + rc_result = Common_Result::SUCCESS; + + PrepareResultForMobileResponse_CheckTotalReault( + ui_result, tts_result, rc_result, false); + + ui_result = Common_Result::SUCCESS; + tts_result = Common_Result::SUCCESS; + rc_result = Common_Result::UNSUPPORTED_REQUEST; + + PrepareResultForMobileResponse_CheckTotalReault( + ui_result, tts_result, rc_result, false); + } + std::shared_ptr lock_ptr_; MockAppPtr mock_app_; std::shared_ptr mock_help_prompt_manager_; + NiceMock mock_app_manager_; }; TEST_F(SetGlobalPropertiesRequestTest, @@ -314,22 +447,25 @@ TEST_F(SetGlobalPropertiesRequestTest, EXPECT_CALL(*mock_app_, help_prompt_manager()) .WillRepeatedly(ReturnRef(*mock_help_prompt_manager_.get())); EXPECT_CALL(*mock_help_prompt_manager_, - OnSetGlobalPropertiesReceived(_, false)).Times(2); + OnSetGlobalPropertiesReceived(_, false)) + .Times(2); EXPECT_CALL( mock_message_helper_, VerifyTtsFiles( (*msg_vr)[am::strings::msg_params][am::strings::help_prompt], _, _)) .WillOnce(Return(mobile_apis::Result::SUCCESS)); - EXPECT_CALL(mock_rpc_service_, - ManageHMICommand( - HMIResultCodeIs(hmi_apis::FunctionID::UI_SetGlobalProperties), - _)).WillOnce(Return(true)); + EXPECT_CALL( + mock_rpc_service_, + ManageHMICommand( + HMIResultCodeIs(hmi_apis::FunctionID::UI_SetGlobalProperties), _)) + .WillOnce(Return(true)); EXPECT_CALL( mock_rpc_service_, ManageHMICommand( HMIResultCodeIs(hmi_apis::FunctionID::TTS_SetGlobalProperties), _)) .WillOnce(Return(true)); + (*msg_vr)[am::strings::params][am::hmi_response::code] = hmi_apis::Common_Result::SUCCESS; Event event_vr(hmi_apis::FunctionID::TTS_SetGlobalProperties); @@ -414,7 +550,8 @@ TEST_F(SetGlobalPropertiesRequestTest, command->Run(); EXPECT_CALL(*mock_help_prompt_manager_, - OnSetGlobalPropertiesReceived(_, true)).Times(2); + OnSetGlobalPropertiesReceived(_, true)) + .Times(2); command->on_event(event_ui); command->on_event(event_tts); @@ -1369,6 +1506,51 @@ TEST_F(SetGlobalPropertiesRequestTest, static_cast(hmi_apis::Common_Result::WARNINGS)); } +TEST_F(SetGlobalPropertiesRequestTest, + PrepareResultCodeForResponse_AllResultsAreSUCCESS_TotalResultSUCCESS) { + using namespace application_manager; + using namespace hmi_apis; + const auto expected_total_result = mobile_apis::Result::eType::SUCCESS; + + Common_Result::eType ui_result = Common_Result::SUCCESS; + Common_Result::eType tts_result = Common_Result::SUCCESS; + Common_Result::eType rc_result = Common_Result::SUCCESS; + + app_mngr::commands::ResponseInfo ui_properties_info( + ui_result, HmiInterfaces::HMI_INTERFACE_UI, mock_app_manager_); + + app_mngr::commands::ResponseInfo tts_properties_info( + tts_result, HmiInterfaces::HMI_INTERFACE_TTS, mock_app_manager_); + + app_mngr::commands::ResponseInfo rc_properties_info( + rc_result, HmiInterfaces::HMI_INTERFACE_RC, mock_app_manager_); + + MessageSharedPtr msg = CreateMsgParams(); + std::shared_ptr command( + CreateCommand(msg)); + + auto result = command->PrepareResultCodeForResponse( + ui_properties_info, tts_properties_info, rc_properties_info); + + EXPECT_EQ(expected_total_result, result); +} + +TEST_F(SetGlobalPropertiesRequestTest, + PrepareResultCodeForResponse_UNSUPPORTED) { + PrepareResultCodeForResponse_CheckAllResultsForSpecifiedTotalResult( + mobile_apis::Result::UNSUPPORTED_RESOURCE); +} + +TEST_F(SetGlobalPropertiesRequestTest, PrepareResultCodeForResponse_WARNINGS) { + PrepareResultCodeForResponse_CheckAllResultsForSpecifiedTotalResult( + mobile_apis::Result::WARNINGS); +} + +TEST_F(SetGlobalPropertiesRequestTest, + PrepareResultForMobileResponse_AllCases) { + PrepareResultForMobileResponse_CheckResultsForAllCases(); +} + } // namespace set_global_properties_request } // namespace mobile_commands_test } // namespace commands_test diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/set_media_clock_timer_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/set_media_clock_timer_test.cc index 04a7da60cf8..86d15e76f2d 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/set_media_clock_timer_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/set_media_clock_timer_test.cc @@ -35,13 +35,13 @@ #include "mobile/set_media_clock_timer_request.h" -#include "gtest/gtest.h" #include "application_manager/commands/command_request_test.h" -#include "application_manager/mock_application_manager.h" -#include "application_manager/mock_application.h" -#include "application_manager/mock_message_helper.h" #include "application_manager/event_engine/event.h" +#include "application_manager/mock_application.h" +#include "application_manager/mock_application_manager.h" #include "application_manager/mock_hmi_interface.h" +#include "application_manager/mock_message_helper.h" +#include "gtest/gtest.h" namespace test { namespace components { @@ -50,10 +50,10 @@ namespace mobile_commands_test { namespace set_media_clock_timer_request { namespace am = ::application_manager; -using sdl_rpc_plugin::commands::SetMediaClockRequest; +using am::MockMessageHelper; using am::commands::MessageSharedPtr; using am::event_engine::Event; -using am::MockMessageHelper; +using sdl_rpc_plugin::commands::SetMediaClockRequest; using ::testing::_; using ::testing::Return; using ::testing::ReturnRef; 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 4540980b9ee..b8cfdd4bfc9 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,20 +31,21 @@ */ #include +#include #include -#include #include +#include #include "mobile/show_request.h" -#include "gtest/gtest.h" #include "application_manager/commands/command_request_test.h" +#include "application_manager/event_engine/event.h" #include "application_manager/mock_application.h" #include "application_manager/mock_application_manager.h" -#include "application_manager/mock_message_helper.h" -#include "application_manager/event_engine/event.h" #include "application_manager/mock_hmi_interface.h" +#include "application_manager/mock_message_helper.h" #include "application_manager/policies/mock_policy_handler_interface.h" +#include "gtest/gtest.h" namespace test { namespace components { @@ -53,10 +54,10 @@ namespace mobile_commands_test { namespace show_request { namespace am = application_manager; -using sdl_rpc_plugin::commands::ShowRequest; +using am::MockMessageHelper; using am::commands::CommandImpl; using am::commands::MessageSharedPtr; -using am::MockMessageHelper; +using sdl_rpc_plugin::commands::ShowRequest; using test::components::policy_test::MockPolicyHandlerInterface; using ::testing::_; using ::testing::Return; @@ -68,8 +69,28 @@ const uint32_t kAppId = 1u; const uint32_t kCmdId = 1u; const uint32_t kConnectionKey = 2u; const uint32_t kFunctionID = 3u; +const std::string kCurrentTemplatelayout = "current_template_layout"; +const std::string kNewTemplateLayout = "new_template_layout"; +const app_mngr::WindowID kCurrentWindowID = 1; +typedef std::array rgb_color_scheme; +const rgb_color_scheme kCurrentDayColorRGB = {75, 75, 75}; +const rgb_color_scheme kCurrentNightColorRGB = {200, 200, 200}; +const rgb_color_scheme kNewDayColorRGB = {80, 80, 80}; +const rgb_color_scheme kNewNightColorRGB = {222, 222, 222}; +const am::WindowID kDefaultWindowId = + mobile_apis::PredefinedWindows::DEFAULT_WINDOW; } // namespace +MATCHER_P2(CheckMessageToMobile, result_code, success, "") { + const bool is_success = + (*arg)[am::strings::msg_params][am::strings::success].asBool() == success; + + const bool is_result_code_correct = + (*arg)[am::strings::msg_params][am::strings::result_code].asInt() == + static_cast(result_code); + return is_success && is_result_code_correct; +} + class ShowRequestTest : public CommandRequestTest { public: ShowRequestTest() { @@ -104,6 +125,101 @@ class ShowRequestTest : public CommandRequestTest { return msg; } + protected: + void SetUp() OVERRIDE { + ON_CALL(app_mngr_, application(kConnectionKey)) + .WillByDefault(Return(mock_app_)); + ON_CALL(*mock_app_, app_id()).WillByDefault(Return(kConnectionKey)); + ON_CALL(*mock_app_, WindowIdExists(kCurrentWindowID)) + .WillByDefault(Return(true)); + ON_CALL(*mock_app_, window_layout(kCurrentWindowID)) + .WillByDefault(Return(kCurrentTemplatelayout)); + } + + smart_objects::SmartObject CreateColorScheme( + const rgb_color_scheme& rgb_color_scheme) { + using namespace application_manager; + + smart_objects::SmartObject primary_color(smart_objects::SmartType_Map); + smart_objects::SmartObject secondary_color(smart_objects::SmartType_Map); + smart_objects::SmartObject background_color(smart_objects::SmartType_Map); + + primary_color[strings::red] = rgb_color_scheme[0]; + primary_color[strings::green] = rgb_color_scheme[1]; + primary_color[strings::blue] = rgb_color_scheme[2]; + + secondary_color[strings::red] = rgb_color_scheme[0]; + secondary_color[strings::green] = rgb_color_scheme[1]; + secondary_color[strings::blue] = rgb_color_scheme[2]; + + background_color[strings::red] = rgb_color_scheme[0]; + background_color[strings::green] = rgb_color_scheme[1]; + background_color[strings::blue] = rgb_color_scheme[2]; + + smart_objects::SmartObject color_scheme(smart_objects::SmartType_Map); + color_scheme[strings::primary_color] = primary_color; + color_scheme[strings::secondary_color] = secondary_color; + color_scheme[strings::background_color] = background_color; + + return color_scheme; + } + + smart_objects::SmartObject CreateTemplateConfiguration( + const std::string& layout) { + using namespace application_manager; + + smart_objects::SmartObject template_configuration( + smart_objects::SmartType_Map); + + template_configuration[strings::template_layout] = layout; + + template_configuration[strings::day_color_scheme] = + CreateColorScheme(kCurrentDayColorRGB); + + template_configuration[strings::night_color_scheme] = + CreateColorScheme(kCurrentNightColorRGB); + + return template_configuration; + } + + MessageSharedPtr CreateMessageWithTemplateLayout(const std::string& layout) { + auto msg = CreateMsgParams(); + (*msg)[app_mngr::strings::msg_params][app_mngr::strings::window_id] = + kCurrentWindowID; + (*msg)[am::strings::msg_params][am::strings::template_configuration] = + CreateTemplateConfiguration(layout); + + return msg; + } + + std::shared_ptr SetupHelperLayout( + const std::string& layout, + const rgb_color_scheme& day_colors, + const rgb_color_scheme& night_colors) { + EXPECT_CALL(mock_rpc_service_, + ManageHMICommand(HMIResultCodeIs(hmi_apis::FunctionID::UI_Show), + Command::CommandSource::SOURCE_SDL_TO_HMI)) + .WillOnce(Return(true)); + EXPECT_CALL(*mock_app_, app_id()).WillOnce(Return(kConnectionKey)); + EXPECT_CALL(*mock_app_, WindowIdExists(kCurrentWindowID)) + .WillOnce(Return(true)); + EXPECT_CALL(app_mngr_, application(kConnectionKey)) + .WillOnce(Return(mock_app_)); + const auto current_day_color_scheme = CreateColorScheme(day_colors); + ON_CALL(*mock_app_, day_color_scheme(kCurrentWindowID)) + .WillByDefault(Return(current_day_color_scheme)); + const auto current_night_color_scheme = CreateColorScheme(night_colors); + ON_CALL(*mock_app_, night_color_scheme(kCurrentWindowID)) + .WillByDefault(Return(current_night_color_scheme)); + ON_CALL(*mock_app_, window_layout(kCurrentWindowID)) + .WillByDefault(Return(kCurrentTemplatelayout)); + + auto msg = CreateMessageWithTemplateLayout(layout); + + auto command(CreateCommand(msg)); + return command; + } + void TestSetupHelper(MessageSharedPtr msg, hmi_apis::Common_TextFieldName::eType field_name, const char* field) { @@ -269,9 +385,9 @@ TEST_F(ShowRequestTest, Run_SoftButtonExists_SUCCESS) { msg_params[am::hmi_request::show_strings] = smart_objects::SmartObject(smart_objects::SmartType_Array); - EXPECT_CALL( - mock_message_helper_, - SubscribeApplicationToSoftButton(creation_msg_params, _, kFunctionID)); + EXPECT_CALL(mock_message_helper_, + SubscribeApplicationToSoftButton( + creation_msg_params, _, kFunctionID, kDefaultWindowId)); EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_, _)); EXPECT_CALL(*mock_app_, set_show_command(msg_params)); @@ -319,7 +435,8 @@ TEST_F(ShowRequestTest, Run_SoftButtonExists_Canceled) { EXPECT_CALL(*mock_app_, app_id()).Times(0); - EXPECT_CALL(mock_message_helper_, SubscribeApplicationToSoftButton(_, _, _)) + EXPECT_CALL(mock_message_helper_, + SubscribeApplicationToSoftButton(_, _, _, kDefaultWindowId)) .Times(0); EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_, _)).Times(0); EXPECT_CALL(*mock_app_, set_show_command(_)).Times(0); @@ -729,10 +846,14 @@ TEST_F(ShowRequestTest, Run_MainField1_MetadataTagWithNoFieldData) { hmi_apis::Common_Result::SUCCESS; (*ev_msg)[am::strings::msg_params][am::strings::app_id] = kConnectionKey; (*ev_msg)[am::strings::msg_params][am::strings::info] = ""; + (*ev_msg)[am::strings::params][am::strings::connection_key] = kConnectionKey; Event event(hmi_apis::FunctionID::UI_Show); event.set_smart_object(*ev_msg); + EXPECT_CALL(app_mngr_, application(kConnectionKey)) + .WillOnce(Return(mock_app_)); + MessageSharedPtr ui_command_result; EXPECT_CALL( mock_rpc_service_, @@ -886,34 +1007,328 @@ TEST_F(ShowRequestTest, Run_CustomPresets_WrongSyntax) { command->Run(); } -TEST_F(ShowRequestTest, Run_InvalidApp_Canceled) { +TEST_F(ShowRequestTest, + Run_AppDoesNotExist_ExpectAppNotRegisteredResponseToMobile) { + const auto result_code = mobile_apis::Result::APPLICATION_NOT_REGISTERED; + EXPECT_CALL(mock_rpc_service_, + ManageMobileCommand(CheckMessageToMobile(result_code, false), + Command::CommandSource::SOURCE_SDL)) + .WillOnce(Return(true)); + EXPECT_CALL(app_mngr_, application(kConnectionKey)).WillOnce(Return(nullptr)); + + auto msg = CreateMsgParams(); + auto command = CreateCommand(msg); + ASSERT_TRUE(command->Init()); + command->Run(); +} + +TEST_F(ShowRequestTest, Run_EmptyParams_Canceled) { MessageSharedPtr msg = CreateMsgParams(); std::shared_ptr command(CreateCommand(msg)); EXPECT_CALL(app_mngr_, application(kConnectionKey)) - .WillOnce(Return(MockAppPtr())); + .WillOnce(Return(mock_app_)); 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(_)).Times(0); + ASSERT_TRUE(command->Init()); command->Run(); } -TEST_F(ShowRequestTest, Run_EmptyParams_Canceled) { - MessageSharedPtr msg = CreateMsgParams(); +TEST_F(ShowRequestTest, + Run_WindowWithIDDoesNotExist_ExpectInvalidIDResponseToMobile) { + const auto result_code = mobile_apis::Result::INVALID_ID; + EXPECT_CALL(mock_rpc_service_, + ManageMobileCommand(CheckMessageToMobile(result_code, false), + Command::CommandSource::SOURCE_SDL)) + .WillOnce(Return(true)); + EXPECT_CALL(app_mngr_, application(kConnectionKey)) + .WillOnce(Return(mock_app_)); + ON_CALL(*mock_app_, WindowIdExists(kCurrentWindowID)) + .WillByDefault(Return(false)); - std::shared_ptr command(CreateCommand(msg)); + auto msg = CreateMsgParams(); + (*msg)[am::strings::msg_params][am::strings::window_id] = kCurrentWindowID; + + auto command = CreateCommand(msg); + ASSERT_TRUE(command->Init()); + command->Run(); +} + +TEST_F(ShowRequestTest, + Run_NoLayoutChangeWithoutBothColorScheme_SendRequestToHMI_SUCCESS) { + auto msg = CreateMsgParams(); + (*msg)[app_mngr::strings::msg_params][app_mngr::strings::window_id] = + kCurrentWindowID; + (*msg)[am::strings::msg_params][am::strings::template_configuration] + [am::strings::template_layout] = kCurrentTemplatelayout; + + auto command(CreateCommand(msg)); + + auto message_to_hmi = CreateMessage(); + + EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_, _)) + .WillOnce(DoAll(SaveArg<0>(&message_to_hmi), Return(true))); + + ASSERT_TRUE(command->Init()); + command->Run(); + + const auto template_layout = + (*message_to_hmi)[am::strings::msg_params] + [am::strings::template_configuration] + [am::strings::template_layout] + .asString(); + EXPECT_EQ(kCurrentTemplatelayout, template_layout); +} + +TEST_F(ShowRequestTest, + Run_NoLayoutChangeDayColorSchemesNotEqual_Response_REJECTED) { + auto msg = CreateMessageWithTemplateLayout(kCurrentTemplatelayout); + + const auto current_day_color_scheme = CreateColorScheme(kNewDayColorRGB); + + auto command(CreateCommand(msg)); + + ON_CALL(*mock_app_, day_color_scheme(kCurrentWindowID)) + .WillByDefault(Return(current_day_color_scheme)); + + auto message_to_mobile = CreateMessage(); + EXPECT_CALL( + mock_rpc_service_, + ManageMobileCommand(_, am::commands::Command::CommandSource::SOURCE_SDL)) + .WillOnce(DoAll(SaveArg<0>(&message_to_mobile), Return(true))); + + ASSERT_TRUE(command->Init()); + command->Run(); + + const bool success = + (*message_to_mobile)[am::strings::msg_params][am::strings::success] + .asBool(); + EXPECT_FALSE(success); + + const auto result_code = static_cast( + (*message_to_mobile)[am::strings::msg_params][am::strings::result_code] + .asUInt()); + + EXPECT_EQ(mobile_apis::Result::REJECTED, result_code); +} + +TEST_F(ShowRequestTest, + Run_NoLayoutChangeNightColorSchemesNotEqual_Response_REJECTED) { + auto msg = CreateMessageWithTemplateLayout(kCurrentTemplatelayout); + + const auto current_night_color_scheme = CreateColorScheme(kNewNightColorRGB); + + auto command(CreateCommand(msg)); + + ON_CALL(*mock_app_, day_color_scheme(kCurrentWindowID)) + .WillByDefault(Return(current_night_color_scheme)); + + auto message_to_mobile = CreateMessage(); + EXPECT_CALL( + mock_rpc_service_, + ManageMobileCommand(_, am::commands::Command::CommandSource::SOURCE_SDL)) + .WillOnce(DoAll(SaveArg<0>(&message_to_mobile), Return(true))); + + ASSERT_TRUE(command->Init()); + command->Run(); + + const bool success = + (*message_to_mobile)[am::strings::msg_params][am::strings::success] + .asBool(); + EXPECT_FALSE(success); + const auto result_code = static_cast( + (*message_to_mobile)[am::strings::msg_params][am::strings::result_code] + .asUInt()); + + EXPECT_EQ(mobile_apis::Result::REJECTED, result_code); +} + +TEST_F(ShowRequestTest, + Run_LayoutNotChangeBothColorSchemeEqual_SendRequestToHMI_SUCCESS) { + EXPECT_CALL(mock_rpc_service_, + ManageHMICommand(HMIResultCodeIs(hmi_apis::FunctionID::UI_Show), + Command::CommandSource::SOURCE_SDL_TO_HMI)) + .WillOnce(Return(true)); + EXPECT_CALL(*mock_app_, app_id()).WillOnce(Return(kConnectionKey)); + EXPECT_CALL(*mock_app_, WindowIdExists(kCurrentWindowID)) + .WillOnce(Return(true)); EXPECT_CALL(app_mngr_, application(kConnectionKey)) .WillOnce(Return(mock_app_)); - 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(_)).Times(0); + const auto current_day_color_scheme = CreateColorScheme(kCurrentDayColorRGB); + ON_CALL(*mock_app_, day_color_scheme(kCurrentWindowID)) + .WillByDefault(Return(current_day_color_scheme)); + const auto current_night_color_scheme = + CreateColorScheme(kCurrentNightColorRGB); + ON_CALL(*mock_app_, night_color_scheme(kCurrentWindowID)) + .WillByDefault(Return(current_night_color_scheme)); + ON_CALL(*mock_app_, window_layout(kCurrentWindowID)) + .WillByDefault(Return(kCurrentTemplatelayout)); + + auto msg = CreateMessageWithTemplateLayout(kCurrentTemplatelayout); + + auto command(CreateCommand(msg)); + ASSERT_TRUE(command->Init()); + command->Run(); +} + +TEST_F(ShowRequestTest, + Run_LayoutChangeBothColorSchemeNotEqual_SendRequestToHMI_SUCCESS) { + EXPECT_CALL(mock_rpc_service_, + ManageHMICommand(HMIResultCodeIs(hmi_apis::FunctionID::UI_Show), + Command::CommandSource::SOURCE_SDL_TO_HMI)) + .WillOnce(Return(true)); + EXPECT_CALL(*mock_app_, app_id()).WillOnce(Return(kConnectionKey)); + EXPECT_CALL(*mock_app_, WindowIdExists(kCurrentWindowID)) + .WillOnce(Return(true)); + EXPECT_CALL(app_mngr_, application(kConnectionKey)) + .WillOnce(Return(mock_app_)); + const auto current_day_color_scheme = CreateColorScheme(kNewDayColorRGB); + ON_CALL(*mock_app_, day_color_scheme(kCurrentWindowID)) + .WillByDefault(Return(current_day_color_scheme)); + const auto current_night_color_scheme = CreateColorScheme(kNewNightColorRGB); + ON_CALL(*mock_app_, night_color_scheme(kCurrentWindowID)) + .WillByDefault(Return(current_night_color_scheme)); + ON_CALL(*mock_app_, window_layout(kCurrentWindowID)) + .WillByDefault(Return(kCurrentTemplatelayout)); + + auto msg = CreateMessageWithTemplateLayout(kNewTemplateLayout); + + auto command(CreateCommand(msg)); + ASSERT_TRUE(command->Init()); + command->Run(); +} + +TEST_F(ShowRequestTest, OnEvent_SuccessResultCode_ExpectSetWindowLayoutOnly) { + // Precondition + auto command = + SetupHelperLayout(kNewTemplateLayout, kNewDayColorRGB, kNewNightColorRGB); + ASSERT_TRUE(command->Init()); + command->Run(); + // Expectation + EXPECT_CALL(*mock_app_, + set_window_layout(kCurrentWindowID, kNewTemplateLayout)); + EXPECT_CALL(*mock_app_, set_day_color_scheme(_, _)); + EXPECT_CALL(*mock_app_, set_night_color_scheme(_, _)); + EXPECT_CALL(mock_rpc_service_, + ManageMobileCommand( + CheckMessageToMobile(mobile_apis::Result::SUCCESS, true), + Command::CommandSource::SOURCE_SDL)); + EXPECT_CALL(app_mngr_, application(kConnectionKey)) + .WillOnce(Return(mock_app_)); + + auto msg = CreateMessage(); + (*msg)[am::strings::params][am::hmi_response::code] = + hmi_apis::Common_Result::eType::SUCCESS; + (*msg)[am::strings::msg_params] = SmartObject(smart_objects::SmartType_Map); + + Event event(hmi_apis::FunctionID::UI_Show); + event.set_smart_object(*msg); + + command->on_event(event); +} + +TEST_F(ShowRequestTest, + OnEvent_SuccessResultCode_ExpectSetWindowLayoutAndSetDayColorScheme) { + // Precondition + auto command = SetupHelperLayout( + kNewTemplateLayout, kCurrentDayColorRGB, kNewNightColorRGB); + ASSERT_TRUE(command->Init()); + command->Run(); + // Expectation + EXPECT_CALL(*mock_app_, + set_window_layout(kCurrentWindowID, kNewTemplateLayout)); + EXPECT_CALL(*mock_app_, + set_day_color_scheme(kCurrentWindowID, + CreateColorScheme(kCurrentDayColorRGB))); + EXPECT_CALL(*mock_app_, set_night_color_scheme(_, _)); + EXPECT_CALL(mock_rpc_service_, + ManageMobileCommand( + CheckMessageToMobile(mobile_apis::Result::SUCCESS, true), + Command::CommandSource::SOURCE_SDL)); + EXPECT_CALL(app_mngr_, application(kConnectionKey)) + .WillOnce(Return(mock_app_)); + + auto msg = CreateMessage(); + (*msg)[am::strings::params][am::hmi_response::code] = + hmi_apis::Common_Result::eType::SUCCESS; + (*msg)[am::strings::msg_params] = SmartObject(smart_objects::SmartType_Map); + + Event event(hmi_apis::FunctionID::UI_Show); + event.set_smart_object(*msg); + + command->on_event(event); +} +TEST_F(ShowRequestTest, + OnEvent_SuccessResultCode_ExpectSetWindowLayoutAndBothColorScheme) { + // Precondition + auto command = SetupHelperLayout( + kNewTemplateLayout, kCurrentDayColorRGB, kCurrentNightColorRGB); + ASSERT_TRUE(command->Init()); command->Run(); + // Expectation + EXPECT_CALL(*mock_app_, + set_window_layout(kCurrentWindowID, kNewTemplateLayout)); + EXPECT_CALL(*mock_app_, + set_day_color_scheme(kCurrentWindowID, + CreateColorScheme(kCurrentDayColorRGB))); + EXPECT_CALL(*mock_app_, + set_night_color_scheme(kCurrentWindowID, + CreateColorScheme(kCurrentNightColorRGB))); + EXPECT_CALL(mock_rpc_service_, + ManageMobileCommand( + CheckMessageToMobile(mobile_apis::Result::SUCCESS, true), + Command::CommandSource::SOURCE_SDL)); + EXPECT_CALL(app_mngr_, application(kConnectionKey)) + .WillOnce(Return(mock_app_)); + + auto msg = CreateMessage(); + (*msg)[am::strings::params][am::hmi_response::code] = + hmi_apis::Common_Result::eType::SUCCESS; + (*msg)[am::strings::msg_params] = SmartObject(smart_objects::SmartType_Map); + + Event event(hmi_apis::FunctionID::UI_Show); + event.set_smart_object(*msg); + + command->on_event(event); +} + +TEST_F(ShowRequestTest, + OnEvent_SuccessResultCode_ExpectBothColorSchemeWithoutSetWindowLayout) { + // Precondition + auto command = SetupHelperLayout( + kCurrentTemplatelayout, kCurrentDayColorRGB, kCurrentNightColorRGB); + ASSERT_TRUE(command->Init()); + command->Run(); + // Expectation + EXPECT_CALL(*mock_app_, set_window_layout(_, _)).Times(0); + EXPECT_CALL(*mock_app_, + set_day_color_scheme(kCurrentWindowID, + CreateColorScheme(kCurrentDayColorRGB))); + EXPECT_CALL(*mock_app_, + set_night_color_scheme(kCurrentWindowID, + CreateColorScheme(kCurrentNightColorRGB))); + EXPECT_CALL(mock_rpc_service_, + ManageMobileCommand( + CheckMessageToMobile(mobile_apis::Result::SUCCESS, true), + Command::CommandSource::SOURCE_SDL)); + EXPECT_CALL(app_mngr_, application(kConnectionKey)) + .WillOnce(Return(mock_app_)); + + auto msg = CreateMessage(); + (*msg)[am::strings::params][am::hmi_response::code] = + hmi_apis::Common_Result::eType::SUCCESS; + (*msg)[am::strings::msg_params] = SmartObject(smart_objects::SmartType_Map); + + Event event(hmi_apis::FunctionID::UI_Show); + event.set_smart_object(*msg); + + command->on_event(event); } TEST_F(ShowRequestTest, OnEvent_SuccessResultCode_SUCCESS) { @@ -931,7 +1346,7 @@ TEST_F(ShowRequestTest, OnEvent_SuccessResultCode_SUCCESS) { event.set_smart_object(*msg); EXPECT_CALL(app_mngr_, application(_)).WillRepeatedly(Return(mock_app_)); - + ASSERT_TRUE(command->Init()); command->on_event(event); } @@ -957,6 +1372,10 @@ TEST_F(ShowRequestTest, OnEvent_WrongFunctionID_Canceled) { MessageSharedPtr msg = CreateMessage(); (*msg)[am::strings::params][am::hmi_response::code] = mobile_apis::Result::SUCCESS; + (*msg)[am::strings::params][am::strings::connection_key] = kConnectionKey; + + ON_CALL(app_mngr_, application(kConnectionKey)) + .WillByDefault(Return(mock_app_)); std::shared_ptr command(CreateCommand(msg)); EXPECT_CALL(mock_rpc_service_, ManageMobileCommand(_, _)).Times(0); @@ -971,4 +1390,4 @@ TEST_F(ShowRequestTest, OnEvent_WrongFunctionID_Canceled) { } // namespace mobile_commands_test } // namespace commands_test } // namespace components -} // namespace tests +} // namespace test diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/simple_notification_commands_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/simple_notification_commands_test.cc index d96a9d76439..6e85aff2815 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/simple_notification_commands_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/simple_notification_commands_test.cc @@ -35,16 +35,16 @@ #include "gtest/gtest.h" -#include "smart_objects/smart_object.h" -#include "application_manager/smart_object_keys.h" -#include "application_manager/mock_message_helper.h" #include "application_manager/commands/command_impl.h" #include "application_manager/commands/commands_test.h" +#include "application_manager/mock_message_helper.h" +#include "application_manager/smart_object_keys.h" #include "mobile/on_app_interface_unregistered_notification.h" #include "mobile/on_audio_pass_thru_notification.h" #include "mobile/on_driver_distraction_notification.h" #include "mobile/on_language_change_notification.h" #include "mobile/on_permissions_change_notification.h" +#include "smart_objects/smart_object.h" namespace test { namespace components { @@ -56,8 +56,8 @@ namespace am = ::application_manager; namespace commands = sdl_rpc_plugin::commands; using ::testing::_; -using ::testing::Types; using ::testing::Return; +using ::testing::Types; template class MobileNotificationCommandsTest diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/simple_response_commands_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/simple_response_commands_test.cc index bbd39874e0f..0034dcf9162 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/simple_response_commands_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/simple_response_commands_test.cc @@ -38,37 +38,36 @@ #include "application_manager/commands/commands_test.h" #include "application_manager/mock_application_manager.h" -#include "mobile/delete_command_response.h" +#include "mobile/add_command_response.h" +#include "mobile/add_sub_menu_response.h" #include "mobile/alert_maneuver_response.h" #include "mobile/alert_response.h" -#include "mobile/list_files_response.h" -#include "mobile/subscribe_button_response.h" -#include "mobile/add_sub_menu_response.h" +#include "mobile/change_registration_response.h" +#include "mobile/delete_command_response.h" #include "mobile/dial_number_response.h" #include "mobile/end_audio_pass_thru_response.h" -#include "mobile/unregister_app_interface_response.h" -#include "mobile/unsubscribe_button_response.h" -#include "mobile/unsubscribe_way_points_response.h" -#include "mobile/update_turn_list_response.h" -#include "mobile/slider_response.h" -#include "mobile/speak_response.h" -#include "mobile/subscribe_way_points_response.h" -#include "mobile/system_response.h" +#include "mobile/generic_response.h" #include "mobile/get_way_points_response.h" -#include "mobile/perform_interaction_response.h" +#include "mobile/list_files_response.h" #include "mobile/perform_audio_pass_thru_response.h" +#include "mobile/perform_interaction_response.h" +#include "mobile/scrollable_message_response.h" +#include "mobile/send_location_response.h" +#include "mobile/set_app_icon_response.h" +#include "mobile/set_display_layout_response.h" #include "mobile/set_global_properties_response.h" #include "mobile/set_media_clock_timer_response.h" #include "mobile/show_constant_tbt_response.h" #include "mobile/show_response.h" -#include "mobile/add_command_response.h" -#include "mobile/send_location_response.h" -#include "mobile/set_app_icon_response.h" -#include "mobile/set_display_layout_response.h" -#include "mobile/generic_response.h" -#include "mobile/set_app_icon_response.h" -#include "mobile/scrollable_message_response.h" -#include "mobile/change_registration_response.h" +#include "mobile/slider_response.h" +#include "mobile/speak_response.h" +#include "mobile/subscribe_button_response.h" +#include "mobile/subscribe_way_points_response.h" +#include "mobile/system_response.h" +#include "mobile/unregister_app_interface_response.h" +#include "mobile/unsubscribe_button_response.h" +#include "mobile/unsubscribe_way_points_response.h" +#include "mobile/update_turn_list_response.h" namespace test { namespace components { @@ -120,7 +119,8 @@ typedef Types ResponseCommandsList; + commands::ChangeRegistrationResponse> + ResponseCommandsList; TYPED_TEST_CASE(MobileResponseCommandsTest, ResponseCommandsList); diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/slider_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/slider_test.cc index 14e670a387d..0450f06ee18 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/slider_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/slider_test.cc @@ -31,19 +31,19 @@ */ #include -#include #include +#include #include "mobile/slider_request.h" -#include "gtest/gtest.h" #include "application_manager/commands/command_request_test.h" +#include "application_manager/event_engine/event.h" #include "application_manager/mock_application.h" #include "application_manager/mock_application_manager.h" -#include "application_manager/mock_message_helper.h" -#include "application_manager/event_engine/event.h" #include "application_manager/mock_hmi_interface.h" +#include "application_manager/mock_message_helper.h" #include "application_manager/policies/mock_policy_handler_interface.h" +#include "gtest/gtest.h" namespace test { namespace components { @@ -52,11 +52,11 @@ namespace mobile_commands_test { namespace slider_request { namespace am = application_manager; -using sdl_rpc_plugin::commands::SliderRequest; +using am::MockMessageHelper; using am::commands::CommandImpl; using am::commands::MessageSharedPtr; -using am::MockMessageHelper; using policy_test::MockPolicyHandlerInterface; +using sdl_rpc_plugin::commands::SliderRequest; using ::testing::_; using ::testing::Return; using ::testing::ReturnRef; @@ -337,4 +337,4 @@ TEST_F(SliderRequestTest, OnEvent_UISliderAborted_SUCCESS) { } // namespace mobile_commands_test } // namespace commands_test } // namespace components -} // namespace tests +} // namespace test diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/speak_request_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/speak_request_test.cc index 5dcbd7e6b92..87320d3a7a5 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/speak_request_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/speak_request_test.cc @@ -31,26 +31,26 @@ POSSIBILITY OF SUCH DAMAGE. */ +#include "mobile/speak_request.h" #include #include "gtest/gtest.h" -#include "mobile/speak_request.h" -#include "application_manager/commands/commands_test.h" #include "application_manager/commands/command_request_test.h" +#include "application_manager/commands/commands_test.h" #include "interfaces/HMI_API.h" #include "interfaces/MOBILE_API.h" #include "utils/helpers.h" -#include "smart_objects/smart_object.h" -#include "utils/custom_string.h" #include "application_manager/application.h" -#include "application_manager/smart_object_keys.h" +#include "application_manager/event_engine/event.h" #include "application_manager/mock_application.h" #include "application_manager/mock_application_manager.h" -#include "application_manager/mock_message_helper.h" -#include "application_manager/event_engine/event.h" #include "application_manager/mock_hmi_interface.h" +#include "application_manager/mock_message_helper.h" +#include "application_manager/smart_object_keys.h" +#include "smart_objects/smart_object.h" +#include "utils/custom_string.h" namespace test { namespace components { @@ -62,24 +62,24 @@ namespace am = application_manager; namespace mobile_result = mobile_apis::Result; namespace hmi_response = ::application_manager::hmi_response; namespace strings = ::application_manager::strings; -using am::commands::CommandImpl; using am::ApplicationManager; -using am::commands::MessageSharedPtr; using am::ApplicationSharedPtr; using am::MockMessageHelper; +using am::commands::CommandImpl; +using am::commands::MessageSharedPtr; using ::testing::_; -using ::testing::Return; -using ::testing::ReturnRef; using sdl_rpc_plugin::commands::SpeakRequest; using ::test::components::application_manager_test::MockApplication; +using ::testing::Return; +using ::testing::ReturnRef; typedef std::shared_ptr CommandPtr; namespace { const uint32_t kAppId = 10u; const uint32_t kConnectionKey = 5u; -} +} // namespace class SpeakRequestTest : public CommandRequestTest { public: @@ -402,5 +402,5 @@ TEST_F(SpeakRequestTest, OnEvent_ApplicationIsNotRegistered_UNSUCCESS) { } // namespace speak_request } // namespace mobile_commands_test } // namespace commands_test -} // namespace component +} // namespace components } // namespace test 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 df3e778ee68..786f2b6bd12 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 @@ -35,16 +35,16 @@ #include "gtest/gtest.h" -#include "smart_objects/smart_object.h" -#include "application_manager/commands/commands_test.h" -#include "application_manager/commands/command_request_test.h" #include "application_manager/application.h" -#include "application_manager/mock_application_manager.h" +#include "application_manager/commands/command_request_test.h" +#include "application_manager/commands/commands_test.h" #include "application_manager/mock_application.h" +#include "application_manager/mock_application_manager.h" #include "application_manager/mock_hmi_capabilities.h" -#include "mobile/subscribe_button_request.h" -#include "interfaces/MOBILE_API.h" #include "application_manager/smart_object_keys.h" +#include "interfaces/MOBILE_API.h" +#include "mobile/subscribe_button_request.h" +#include "smart_objects/smart_object.h" namespace test { namespace components { @@ -53,13 +53,13 @@ namespace mobile_commands_test { namespace subscribe_button_request { using ::testing::_; +using ::testing::DoAll; using ::testing::Return; using ::testing::ReturnRef; -using ::testing::DoAll; using ::testing::SaveArg; namespace am = ::application_manager; -using sdl_rpc_plugin::commands::SubscribeButtonRequest; using am::commands::MessageSharedPtr; +using sdl_rpc_plugin::commands::SubscribeButtonRequest; typedef std::shared_ptr CommandPtr; @@ -106,6 +106,23 @@ TEST_F(SubscribeButtonRequestTest, Run_SubscriptionNotAllowed_UNSUCCESS) { .asInt())); } +TEST_F(SubscribeButtonRequestTest, Run_NavSubscriptionNotAllowed_UNSUCCESS) { + MessageSharedPtr msg(CreateMessage()); + (*msg)[am::strings::msg_params][am::strings::button_name] = + mobile_apis::ButtonName::NAV_CENTER_LOCATION; + CommandPtr command(CreateCommand(msg)); + + MockAppPtr app(CreateMockApp()); + ON_CALL(app_mngr_, application(_)).WillByDefault(Return(app)); + ON_CALL(*app, is_navi()).WillByDefault(Return(false)); + + MessageSharedPtr result_msg(CatchMobileCommandResult(CallRun(*command))); + EXPECT_EQ(mobile_apis::Result::REJECTED, + static_cast( + (*result_msg)[am::strings::msg_params][am::strings::result_code] + .asInt())); +} + TEST_F(SubscribeButtonRequestTest, Run_UiIsNotSupported_UNSUCCESS) { CommandPtr command(CreateCommand()); @@ -199,7 +216,55 @@ TEST_F(SubscribeButtonRequestTest, Run_SUCCESS) { EXPECT_EQ(mobile_apis::Result::SUCCESS, static_cast( (*mobile_result_msg)[am::strings::msg_params] - [am::strings::result_code].asInt())); + [am::strings::result_code] + .asInt())); +} + +TEST_F(SubscribeButtonRequestTest, Run_NAV_SUCCESS) { + const mobile_apis::ButtonName::eType kButtonName = + mobile_apis::ButtonName::NAV_CENTER_LOCATION; + + 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)); + ON_CALL(*app, is_navi()).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; + + 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(mobile_apis::Result::SUCCESS, + static_cast( + (*mobile_result_msg)[am::strings::msg_params] + [am::strings::result_code] + .asInt())); } TEST_F(SubscribeButtonRequestTest, Run_SUCCESS_App_Base_RPC_Version) { @@ -252,7 +317,8 @@ TEST_F(SubscribeButtonRequestTest, Run_SUCCESS_App_Base_RPC_Version) { EXPECT_EQ(mobile_apis::Result::SUCCESS, static_cast( (*mobile_result_msg)[am::strings::msg_params] - [am::strings::result_code].asInt())); + [am::strings::result_code] + .asInt())); } } // namespace subscribe_button_request diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/subscribe_way_points_request_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/subscribe_way_points_request_test.cc index d08c13b3f34..56e4e05d489 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/subscribe_way_points_request_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/subscribe_way_points_request_test.cc @@ -32,17 +32,17 @@ #include "gtest/gtest.h" -#include "smart_objects/smart_object.h" -#include "application_manager/commands/commands_test.h" -#include "application_manager/commands/command_request_test.h" #include "application_manager/application.h" -#include "application_manager/mock_application_manager.h" +#include "application_manager/commands/command_request_test.h" +#include "application_manager/commands/commands_test.h" #include "application_manager/mock_application.h" +#include "application_manager/mock_application_manager.h" #include "application_manager/mock_hmi_capabilities.h" #include "application_manager/mock_message_helper.h" -#include "mobile/subscribe_way_points_request.h" -#include "interfaces/MOBILE_API.h" #include "application_manager/smart_object_keys.h" +#include "interfaces/MOBILE_API.h" +#include "mobile/subscribe_way_points_request.h" +#include "smart_objects/smart_object.h" namespace test { namespace components { @@ -52,14 +52,14 @@ namespace subscribe_way_points_request { using ::testing::_; using ::testing::A; +using ::testing::DoAll; +using ::testing::InSequence; using ::testing::Return; using ::testing::ReturnRef; -using ::testing::DoAll; using ::testing::SaveArg; -using ::testing::InSequence; namespace am = ::application_manager; -using sdl_rpc_plugin::commands::SubscribeWayPointsRequest; using am::commands::MessageSharedPtr; +using sdl_rpc_plugin::commands::SubscribeWayPointsRequest; typedef std::shared_ptr CommandPtr; @@ -90,7 +90,8 @@ TEST_F(SubscribeWayPointsRequestTest, Run_SUCCESS) { EXPECT_EQ(mobile_apis::Result::SUCCESS, static_cast( (*mobile_result_msg)[am::strings::msg_params] - [am::strings::result_code].asInt())); + [am::strings::result_code] + .asInt())); } TEST_F(SubscribeWayPointsRequestTest, OnEvent_SUCCESS) { diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/system_request_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/system_request_test.cc index 298661dc740..211888d6be7 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/system_request_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/system_request_test.cc @@ -31,18 +31,18 @@ */ #include -#include #include +#include #include "gtest/gtest.h" -#include "mobile/system_request.h" #include "application_manager/commands/command_request_test.h" +#include "application_manager/event_engine/event.h" #include "application_manager/mock_application.h" #include "application_manager/mock_application_manager.h" -#include "application_manager/event_engine/event.h" #include "application_manager/mock_hmi_interface.h" #include "application_manager/policies/mock_policy_handler_interface.h" +#include "mobile/system_request.h" namespace test { namespace components { @@ -51,13 +51,13 @@ namespace mobile_commands_test { namespace system_request { namespace am = application_manager; -using sdl_rpc_plugin::commands::SystemRequest; +using am::MessageType; +using am::MockHmiInterfaces; using am::commands::CommandImpl; using am::commands::MessageSharedPtr; -using am::MockHmiInterfaces; using am::event_engine::Event; -using am::MessageType; using policy_test::MockPolicyHandlerInterface; +using sdl_rpc_plugin::commands::SystemRequest; using ::testing::_; using ::testing::DoAll; @@ -74,6 +74,7 @@ const std::string kAppStorageFolder = "fake-storage"; const std::string kSystemFilesPath = "/fake/system/files"; const std::string kFileName = "Filename"; const uint32_t kHmiAppId = 3u; +const connection_handler::DeviceHandle kDeviceId = 1u; } // namespace class SystemRequestTest @@ -99,13 +100,15 @@ class SystemRequestTest ON_CALL(*mock_app_, policy_app_id()).WillByDefault(Return(kAppPolicyId)); ON_CALL(*mock_app_, folder_name()).WillByDefault(Return(kAppFolderName)); ON_CALL(*mock_app_, hmi_app_id()).WillByDefault(Return(kHmiAppId)); + ON_CALL(*mock_app_, device()).WillByDefault(Return(kDeviceId)); ON_CALL(app_mngr_settings_, system_files_path()) .WillByDefault(ReturnRef(kSystemFilesPath)); ON_CALL(app_mngr_settings_, app_storage_folder()) .WillByDefault(ReturnRef(kAppStorageFolder)); - ON_CALL(mock_policy_handler_, IsRequestTypeAllowed(kAppPolicyId, _)) + ON_CALL(mock_policy_handler_, + IsRequestTypeAllowed(kDeviceId, kAppPolicyId, _)) .WillByDefault(Return(true)); } @@ -146,9 +149,10 @@ TEST_F(SystemRequestTest, PreConditions(); - EXPECT_CALL(mock_policy_handler_, - IsRequestTypeAllowed(kAppPolicyId, - mobile_apis::RequestType::OEM_SPECIFIC)) + EXPECT_CALL( + mock_policy_handler_, + IsRequestTypeAllowed( + kDeviceId, kAppPolicyId, mobile_apis::RequestType::OEM_SPECIFIC)) .WillOnce(Return(true)); EXPECT_CALL(mock_policy_handler_, @@ -191,9 +195,10 @@ TEST_F( PreConditions(); - EXPECT_CALL(mock_policy_handler_, - IsRequestTypeAllowed(kAppPolicyId, - mobile_apis::RequestType::OEM_SPECIFIC)) + EXPECT_CALL( + mock_policy_handler_, + IsRequestTypeAllowed( + kDeviceId, kAppPolicyId, mobile_apis::RequestType::OEM_SPECIFIC)) .WillOnce(Return(true)); EXPECT_CALL(mock_policy_handler_, @@ -216,9 +221,10 @@ TEST_F(SystemRequestTest, Run_RequestTypeDisallowed_SendDisallowedResponse) { PreConditions(); - EXPECT_CALL(mock_policy_handler_, - IsRequestTypeAllowed(kAppPolicyId, - mobile_apis::RequestType::OEM_SPECIFIC)) + EXPECT_CALL( + mock_policy_handler_, + IsRequestTypeAllowed( + kDeviceId, kAppPolicyId, mobile_apis::RequestType::OEM_SPECIFIC)) .WillOnce(Return(false)); ExpectManageMobileCommandWithResultCode(mobile_apis::Result::DISALLOWED); @@ -229,6 +235,37 @@ TEST_F(SystemRequestTest, Run_RequestTypeDisallowed_SendDisallowedResponse) { command->Run(); } +TEST_F(SystemRequestTest, Run_RequestType_IconURL_Success) { + PreConditions(); + MessageSharedPtr msg = CreateIVSUMessage(); + (*msg)[am::strings::msg_params][am::strings::request_type] = + mobile_apis::RequestType::ICON_URL; + + const std::string url = "https://www.appsfakeiconurlendpoint.com/icon.png"; + + (*msg)[am::strings::msg_params][am::strings::file_name] = url; + const std::vector binary_data = {1u, 2u}; + (*msg)[am::strings::params][am::strings::binary_data] = binary_data; + + EXPECT_CALL(mock_policy_handler_, + IsRequestTypeAllowed( + kDeviceId, kAppPolicyId, mobile_apis::RequestType::ICON_URL)) + .WillOnce(Return(true)); + EXPECT_CALL(app_mngr_settings_, app_icons_folder()) + .WillOnce(ReturnRef(kAppStorageFolder)); + EXPECT_CALL(app_mngr_, PolicyIDByIconUrl(url)).WillOnce(Return(kAppPolicyId)); + + EXPECT_CALL(app_mngr_, + SaveBinary(binary_data, kAppStorageFolder, kAppPolicyId, 0u)) + .WillOnce(Return(mobile_apis::Result::SUCCESS)); + + EXPECT_CALL(app_mngr_, SetIconFileFromSystemRequest(kAppPolicyId)).Times(1); + + std::shared_ptr command(CreateCommand(msg)); + ASSERT_TRUE(command->Init()); + command->Run(); +} + } // namespace system_request } // namespace mobile_commands_test } // namespace commands_test diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/unregister_app_interface_request_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/unregister_app_interface_request_test.cc index 771374348b6..f244acb8d6d 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/unregister_app_interface_request_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/unregister_app_interface_request_test.cc @@ -51,8 +51,8 @@ namespace mobile_result = mobile_apis::Result; using ::testing::_; -using sdl_rpc_plugin::commands::UnregisterAppInterfaceRequest; using am::commands::MessageSharedPtr; +using sdl_rpc_plugin::commands::UnregisterAppInterfaceRequest; typedef std::shared_ptr CommandPtr; 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 22893b771ce..98d20dbbc4c 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 @@ -5,8 +5,8 @@ #include "application_manager/commands/command_request_test.h" #include "application_manager/mock_application_manager.h" -#include "application_manager/mock_message_helper.h" #include "application_manager/mock_hmi_capabilities.h" +#include "application_manager/mock_message_helper.h" #include "mobile/unsubscribe_button_request.h" namespace test { @@ -20,8 +20,8 @@ namespace mobile_result = mobile_apis::Result; using ::testing::_; -using sdl_rpc_plugin::commands::UnsubscribeButtonRequest; using am::commands::MessageSharedPtr; +using sdl_rpc_plugin::commands::UnsubscribeButtonRequest; typedef std::shared_ptr CommandPtr; diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/unsubscribe_way_points_request_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/unsubscribe_way_points_request_test.cc index 05e15a78af2..3165d57d446 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/unsubscribe_way_points_request_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/unsubscribe_way_points_request_test.cc @@ -34,18 +34,18 @@ #include #include "gtest/gtest.h" -#include "mobile/unsubscribe_way_points_request.h" #include "interfaces/MOBILE_API.h" +#include "mobile/unsubscribe_way_points_request.h" -#include "smart_objects/smart_object.h" -#include "application_manager/commands/commands_test.h" -#include "application_manager/commands/command_request_test.h" #include "application_manager/application.h" -#include "application_manager/mock_application_manager.h" +#include "application_manager/commands/command_request_test.h" +#include "application_manager/commands/commands_test.h" +#include "application_manager/event_engine/event.h" #include "application_manager/mock_application.h" +#include "application_manager/mock_application_manager.h" #include "application_manager/mock_message_helper.h" #include "application_manager/smart_object_keys.h" -#include "application_manager/event_engine/event.h" +#include "smart_objects/smart_object.h" namespace test { namespace components { @@ -59,8 +59,8 @@ namespace mobile_result = mobile_apis::Result; using ::testing::_; using ::testing::Return; -using sdl_rpc_plugin::commands::UnsubscribeWayPointsRequest; using am::commands::MessageSharedPtr; +using sdl_rpc_plugin::commands::UnsubscribeWayPointsRequest; namespace { const uint32_t kConnectionKey = 3u; 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 78fca8681ad..44628a8e89c 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 @@ -34,20 +34,20 @@ #include #include "gtest/gtest.h" -#include "mobile/update_turn_list_request.h" #include "interfaces/MOBILE_API.h" +#include "mobile/update_turn_list_request.h" -#include "smart_objects/smart_object.h" -#include "application_manager/commands/commands_test.h" -#include "application_manager/commands/command_request_test.h" #include "application_manager/application.h" -#include "application_manager/mock_application_manager.h" +#include "application_manager/commands/command_request_test.h" +#include "application_manager/commands/commands_test.h" +#include "application_manager/event_engine/event.h" #include "application_manager/mock_application.h" -#include "application_manager/mock_message_helper.h" +#include "application_manager/mock_application_manager.h" #include "application_manager/mock_hmi_capabilities.h" +#include "application_manager/mock_message_helper.h" #include "application_manager/policies/mock_policy_handler_interface.h" #include "application_manager/smart_object_keys.h" -#include "application_manager/event_engine/event.h" +#include "smart_objects/smart_object.h" namespace test { namespace components { @@ -59,14 +59,14 @@ namespace am = ::application_manager; namespace mobile_result = mobile_apis::Result; using ::testing::_; +using ::testing::Eq; +using ::testing::Ref; using ::testing::Return; using ::testing::ReturnRef; -using ::testing::Ref; -using ::testing::Eq; -using sdl_rpc_plugin::commands::UpdateTurnListRequest; using am::commands::MessageSharedPtr; using application_manager_test::MockHMICapabilities; +using sdl_rpc_plugin::commands::UpdateTurnListRequest; namespace { const uint32_t kConnectionKey = 3u; @@ -208,7 +208,8 @@ TEST_F(UpdateTurnListRequestTest, Run_ValidTurnList_SUCCESS) { (*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)); + Ref(app_mngr_))) + .WillOnce(Return(mobile_result::SUCCESS)); EXPECT_CALL(mock_message_helper_, SubscribeApplicationToSoftButton(_, _, kFunctionId)); @@ -223,8 +224,8 @@ TEST_F(UpdateTurnListRequestTest, Run_ValidTurnList_SUCCESS) { .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)); + [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] @@ -232,8 +233,8 @@ TEST_F(UpdateTurnListRequestTest, Run_ValidTurnList_SUCCESS) { .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)); + [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] @@ -268,7 +269,8 @@ TEST_F(UpdateTurnListRequestTest, Run_ValidTurnList_WARNINGS) { (*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)); + Ref(app_mngr_))) + .WillOnce(Return(mobile_result::WARNINGS)); EXPECT_CALL(mock_message_helper_, SubscribeApplicationToSoftButton(_, _, kFunctionId)); @@ -283,8 +285,8 @@ TEST_F(UpdateTurnListRequestTest, Run_ValidTurnList_WARNINGS) { .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)); + [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] @@ -292,8 +294,8 @@ TEST_F(UpdateTurnListRequestTest, Run_ValidTurnList_WARNINGS) { .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)); + [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] diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/CMakeLists.txt b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/CMakeLists.txt index 0e556a6993d..8c29cccfffd 100644 --- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/CMakeLists.txt +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/CMakeLists.txt @@ -45,18 +45,25 @@ collect_sources(VEHICLE_INFO_PLUGIN_SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/src") set(LIBRARIES HMI_API MOBILE_API + MessageHelper ApplicationManager v4_protocol_v1_2_no_extra SmartObjects Utils + jsoncpp + connectionHandler ) if(ENABLE_LOG) list(APPEND LIBRARIES log4cxx -L${LOG4CXX_LIBS_DIRECTORY}) endif() -add_library("vehicle_info_plugin" SHARED ${MOBILE_COMMANDS} ${HMI_COMMANDS} ${VEHICLE_INFO_PLUGIN_SOURCES}) -target_link_libraries("vehicle_info_plugin" ${LIBRARIES}) +add_library("vehicle_info_plugin_static" ${MOBILE_COMMANDS} ${HMI_COMMANDS} ${VEHICLE_INFO_PLUGIN_SOURCES}) +target_link_libraries("vehicle_info_plugin_static" ${LIBRARIES}) + +add_library(vehicle_info_plugin SHARED "src/vehicle_info_plugin.cc" ) +target_link_libraries(vehicle_info_plugin vehicle_info_plugin_static) + set(INSTALL_DESTINATION bin) diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/on_vi_vehicle_data_notification.h b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/on_vi_vehicle_data_notification.h index 1fb9c0a0080..be2f123f4a4 100644 --- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/on_vi_vehicle_data_notification.h +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/on_vi_vehicle_data_notification.h @@ -33,8 +33,9 @@ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_VI_VEHICLE_DATA_NOTIFICATION_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_VI_VEHICLE_DATA_NOTIFICATION_H_ -#include "application_manager/commands/notification_from_hmi.h" #include "application_manager/application_manager.h" +#include "application_manager/commands/notification_from_hmi.h" +#include "vehicle_info_plugin/vehicle_info_command_params.h" namespace vehicle_info_plugin { namespace app_mngr = application_manager; @@ -55,10 +56,7 @@ class OnVIVehicleDataNotification **/ OnVIVehicleDataNotification( 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); + const VehicleInfoCommandParams& params); /** * @brief OnVIVehicleDataNotification class destructor @@ -76,6 +74,6 @@ class OnVIVehicleDataNotification } // namespace commands -} // namespace application_manager +} // namespace vehicle_info_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_VI_VEHICLE_DATA_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/vi_diagnostic_message_request.h b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/vi_diagnostic_message_request.h index 0b0a9ef99ef..6ae6d1f7f6d 100644 --- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/vi_diagnostic_message_request.h +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/vi_diagnostic_message_request.h @@ -34,6 +34,7 @@ #define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_VI_DIAGNOSTIC_MESSAGE_REQUEST_H_ #include "application_manager/commands/request_to_hmi.h" +#include "vehicle_info_plugin/vehicle_info_command_params.h" namespace vehicle_info_plugin { namespace app_mngr = application_manager; @@ -52,10 +53,7 @@ class VIDiagnosticMessageRequest : public app_mngr::commands::RequestToHMI { **/ VIDiagnosticMessageRequest( 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); + const VehicleInfoCommandParams& params); /** * @brief VIDiagnosticMessageRequest class destructor @@ -73,6 +71,6 @@ class VIDiagnosticMessageRequest : public app_mngr::commands::RequestToHMI { } // namespace commands -} // namespace application_manager +} // namespace vehicle_info_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_VI_DIAGNOSTIC_MESSAGE_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/vi_diagnostic_message_response.h b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/vi_diagnostic_message_response.h index 31fc73897e3..9b172b9e740 100644 --- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/vi_diagnostic_message_response.h +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/vi_diagnostic_message_response.h @@ -34,6 +34,7 @@ #define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_VI_DIAGNOSTIC_MESSAGE_RESPONSE_H_ #include "application_manager/commands/response_from_hmi.h" +#include "vehicle_info_plugin/vehicle_info_command_params.h" namespace vehicle_info_plugin { namespace app_mngr = application_manager; @@ -52,10 +53,7 @@ class VIDiagnosticMessageResponse : public app_mngr::commands::ResponseFromHMI { **/ VIDiagnosticMessageResponse( 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); + const VehicleInfoCommandParams& params); /** * @brief VIDiagnosticMessageResponse class destructor @@ -73,6 +71,6 @@ class VIDiagnosticMessageResponse : public app_mngr::commands::ResponseFromHMI { } // namespace commands -} // namespace application_manager +} // namespace vehicle_info_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_VI_DIAGNOSTIC_MESSAGE_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/vi_get_dtcs_request.h b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/vi_get_dtcs_request.h index 67308a38987..c77464835b4 100644 --- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/vi_get_dtcs_request.h +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/vi_get_dtcs_request.h @@ -34,6 +34,7 @@ #define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_VI_GET_DTCS_REQUEST_H_ #include "application_manager/commands/request_to_hmi.h" +#include "vehicle_info_plugin/vehicle_info_command_params.h" namespace vehicle_info_plugin { namespace app_mngr = application_manager; @@ -51,10 +52,7 @@ class VIGetDTCsRequest : public app_mngr::commands::RequestToHMI { * @param message Incoming SmartObject message **/ VIGetDTCsRequest(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); + const VehicleInfoCommandParams& params); /** * @brief VIGetDTCsRequest class destructor @@ -72,6 +70,6 @@ class VIGetDTCsRequest : public app_mngr::commands::RequestToHMI { } // namespace commands -} // namespace application_manager +} // namespace vehicle_info_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_VI_GET_DTCS_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/vi_get_dtcs_response.h b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/vi_get_dtcs_response.h index 0ddf225c93f..f1ddcbe3735 100644 --- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/vi_get_dtcs_response.h +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/vi_get_dtcs_response.h @@ -34,6 +34,7 @@ #define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_VI_GET_DTCS_RESPONSE_H_ #include "application_manager/commands/response_from_hmi.h" +#include "vehicle_info_plugin/vehicle_info_command_params.h" namespace vehicle_info_plugin { namespace app_mngr = application_manager; @@ -51,10 +52,7 @@ class VIGetDTCsResponse : public app_mngr::commands::ResponseFromHMI { * @param message Incoming SmartObject message **/ VIGetDTCsResponse(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); + const VehicleInfoCommandParams& params); /** * @brief VIGetDTCsResponse class destructor @@ -72,6 +70,6 @@ class VIGetDTCsResponse : public app_mngr::commands::ResponseFromHMI { } // namespace commands -} // namespace application_manager +} // namespace vehicle_info_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_VI_GET_DTCS_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/vi_get_vehicle_data_request.h b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/vi_get_vehicle_data_request.h index 1b4669cf249..bce49f82012 100644 --- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/vi_get_vehicle_data_request.h +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/vi_get_vehicle_data_request.h @@ -34,6 +34,8 @@ #define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_VI_GET_VEHICLE_DATA_REQUEST_H_ #include "application_manager/commands/request_to_hmi.h" +#include "vehicle_info_plugin/custom_vehicle_data_manager.h" +#include "vehicle_info_plugin/vehicle_info_command_params.h" namespace vehicle_info_plugin { namespace app_mngr = application_manager; @@ -51,10 +53,7 @@ class VIGetVehicleDataRequest : public app_mngr::commands::RequestToHMI { * @param message Incoming SmartObject message **/ VIGetVehicleDataRequest(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); + const VehicleInfoCommandParams& params); /** * @brief VIGetVehicleDataRequest class destructor @@ -67,11 +66,13 @@ class VIGetVehicleDataRequest : public app_mngr::commands::RequestToHMI { virtual void Run(); private: + CustomVehicleDataManager& custom_vehicle_data_manager_; + DISALLOW_COPY_AND_ASSIGN(VIGetVehicleDataRequest); }; } // namespace commands -} // namespace application_manager +} // namespace vehicle_info_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_VI_GET_VEHICLE_DATA_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/vi_get_vehicle_data_response.h b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/vi_get_vehicle_data_response.h index df5e630aeaa..7504168aec9 100644 --- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/vi_get_vehicle_data_response.h +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/vi_get_vehicle_data_response.h @@ -33,8 +33,9 @@ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_VI_GET_VEHICLE_DATA_RESPONSE_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_VI_GET_VEHICLE_DATA_RESPONSE_H_ -#include "application_manager/commands/response_from_hmi.h" #include "application_manager/application_manager.h" +#include "application_manager/commands/response_from_hmi.h" +#include "vehicle_info_plugin/vehicle_info_command_params.h" namespace vehicle_info_plugin { namespace app_mngr = application_manager; @@ -52,10 +53,7 @@ class VIGetVehicleDataResponse : public app_mngr::commands::ResponseFromHMI { * @param message Incoming SmartObject message **/ VIGetVehicleDataResponse(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); + const VehicleInfoCommandParams& params); /** * @brief VIGetVehicleDataResponse class destructor @@ -73,6 +71,6 @@ class VIGetVehicleDataResponse : public app_mngr::commands::ResponseFromHMI { } // namespace commands -} // namespace application_manager +} // namespace vehicle_info_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_VI_GET_VEHICLE_DATA_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/vi_get_vehicle_type_request.h b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/vi_get_vehicle_type_request.h index 79a5270f8da..7f2e8389ad0 100644 --- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/vi_get_vehicle_type_request.h +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/vi_get_vehicle_type_request.h @@ -34,6 +34,7 @@ #define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_VI_GET_VEHICLE_TYPE_REQUEST_H_ #include "application_manager/commands/request_to_hmi.h" +#include "vehicle_info_plugin/vehicle_info_command_params.h" namespace vehicle_info_plugin { namespace app_mngr = application_manager; @@ -51,10 +52,7 @@ class VIGetVehicleTypeRequest : public app_mngr::commands::RequestToHMI { * @param message Incoming SmartObject message **/ VIGetVehicleTypeRequest(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); + const VehicleInfoCommandParams& params); /** * @brief VIGetVehicleTypeRequest class destructor @@ -72,6 +70,6 @@ class VIGetVehicleTypeRequest : public app_mngr::commands::RequestToHMI { } // namespace commands -} // namespace application_manager +} // namespace vehicle_info_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_VI_GET_VEHICLE_TYPE_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/vi_get_vehicle_type_response.h b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/vi_get_vehicle_type_response.h index baa4a936ae6..f71eda8077d 100644 --- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/vi_get_vehicle_type_response.h +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/vi_get_vehicle_type_response.h @@ -34,6 +34,7 @@ #define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_VI_GET_VEHICLE_TYPE_RESPONSE_H_ #include "application_manager/commands/response_from_hmi.h" +#include "vehicle_info_plugin/vehicle_info_command_params.h" namespace vehicle_info_plugin { namespace app_mngr = application_manager; @@ -50,12 +51,8 @@ class VIGetVehicleTypeResponse : public app_mngr::commands::ResponseFromHMI { * * @param message Incoming SmartObject message **/ - VIGetVehicleTypeResponse( - const app_mngr::commands::MessageSharedPtr& message, - app_mngr::ApplicationManager& application_manager, - application_manager::rpc_service::RPCService& rpc_service, - application_manager::HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handle); + VIGetVehicleTypeResponse(const app_mngr::commands::MessageSharedPtr& message, + const VehicleInfoCommandParams& params); /** * @brief VIGetVehicleTypeResponse class destructor @@ -73,6 +70,6 @@ class VIGetVehicleTypeResponse : public app_mngr::commands::ResponseFromHMI { } // namespace commands -} // namespace application_manager +} // namespace vehicle_info_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_VI_GET_VEHICLE_TYPE_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/vi_is_ready_request.h b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/vi_is_ready_request.h index 3f12a30c8d0..fa9bfebad45 100644 --- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/vi_is_ready_request.h +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/vi_is_ready_request.h @@ -34,6 +34,7 @@ #define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_VI_IS_READY_REQUEST_H_ #include "application_manager/commands/request_to_hmi.h" +#include "vehicle_info_plugin/vehicle_info_command_params.h" namespace vehicle_info_plugin { namespace app_mngr = application_manager; @@ -52,10 +53,7 @@ class VIIsReadyRequest : public app_mngr::commands::RequestToHMI, * @param message Incoming SmartObject message **/ VIIsReadyRequest(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); + const VehicleInfoCommandParams& params); /** * @brief VIIsReadyRequest class destructor @@ -88,6 +86,6 @@ class VIIsReadyRequest : public app_mngr::commands::RequestToHMI, } // namespace commands -} // namespace application_manager +} // namespace vehicle_info_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_VI_IS_READY_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/vi_is_ready_response.h b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/vi_is_ready_response.h index 3531aa03c49..f87d9370f5d 100644 --- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/vi_is_ready_response.h +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/vi_is_ready_response.h @@ -33,8 +33,9 @@ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_VI_IS_READY_RESPONSE_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_VI_IS_READY_RESPONSE_H_ -#include "application_manager/commands/response_from_hmi.h" #include "application_manager/application_manager.h" +#include "application_manager/commands/response_from_hmi.h" +#include "vehicle_info_plugin/vehicle_info_command_params.h" namespace vehicle_info_plugin { namespace app_mngr = application_manager; @@ -52,10 +53,7 @@ class VIIsReadyResponse : public app_mngr::commands::ResponseFromHMI { * @param message Incoming SmartObject message **/ VIIsReadyResponse(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); + const VehicleInfoCommandParams& params); /** * @brief VIIsReadyResponse class destructor @@ -73,6 +71,6 @@ class VIIsReadyResponse : public app_mngr::commands::ResponseFromHMI { } // namespace commands -} // namespace application_manager +} // namespace vehicle_info_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_VI_IS_READY_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/vi_read_did_request.h b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/vi_read_did_request.h index 2d10bbf11d6..63bbf10e415 100644 --- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/vi_read_did_request.h +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/vi_read_did_request.h @@ -34,6 +34,7 @@ #define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_VI_READ_DID_REQUEST_H_ #include "application_manager/commands/request_to_hmi.h" +#include "vehicle_info_plugin/vehicle_info_command_params.h" namespace vehicle_info_plugin { namespace app_mngr = application_manager; @@ -51,10 +52,7 @@ class VIReadDIDRequest : public app_mngr::commands::RequestToHMI { * @param message Incoming SmartObject message **/ VIReadDIDRequest(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); + const VehicleInfoCommandParams& params); /** * @brief VIReadDIDRequest class destructor @@ -72,6 +70,6 @@ class VIReadDIDRequest : public app_mngr::commands::RequestToHMI { } // namespace commands -} // namespace application_manager +} // namespace vehicle_info_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_VI_READ_DID_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/vi_read_did_response.h b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/vi_read_did_response.h index 5ac655b499a..307960e1456 100644 --- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/vi_read_did_response.h +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/vi_read_did_response.h @@ -34,6 +34,7 @@ #define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_VI_READ_DID_RESPONSE_H_ #include "application_manager/commands/response_from_hmi.h" +#include "vehicle_info_plugin/vehicle_info_command_params.h" namespace vehicle_info_plugin { namespace app_mngr = application_manager; @@ -51,10 +52,7 @@ class VIReadDIDResponse : public app_mngr::commands::ResponseFromHMI { * @param message Incoming SmartObject message **/ VIReadDIDResponse(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); + const VehicleInfoCommandParams& params); /** * @brief VIReadDIDResponse class destructor @@ -72,6 +70,6 @@ class VIReadDIDResponse : public app_mngr::commands::ResponseFromHMI { } // namespace commands -} // namespace application_manager +} // namespace vehicle_info_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_VI_READ_DID_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/vi_subscribe_vehicle_data_request.h b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/vi_subscribe_vehicle_data_request.h index bd22a313e77..0e91006e529 100644 --- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/vi_subscribe_vehicle_data_request.h +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/vi_subscribe_vehicle_data_request.h @@ -34,6 +34,8 @@ #define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_VI_SUBSCRIBE_VEHICLE_DATA_REQUEST_H_ #include "application_manager/commands/request_to_hmi.h" +#include "vehicle_info_plugin/custom_vehicle_data_manager.h" +#include "vehicle_info_plugin/vehicle_info_command_params.h" namespace vehicle_info_plugin { namespace app_mngr = application_manager; @@ -52,10 +54,7 @@ class VISubscribeVehicleDataRequest : public app_mngr::commands::RequestToHMI { **/ VISubscribeVehicleDataRequest( 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); + const VehicleInfoCommandParams& params); /** * @brief VISubscribeVehicleDataRequest class destructor @@ -68,11 +67,13 @@ class VISubscribeVehicleDataRequest : public app_mngr::commands::RequestToHMI { virtual void Run(); private: + CustomVehicleDataManager& custom_vehicle_data_manager_; + DISALLOW_COPY_AND_ASSIGN(VISubscribeVehicleDataRequest); }; } // namespace commands -} // namespace application_manager +} // namespace vehicle_info_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_VI_SUBSCRIBE_VEHICLE_DATA_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/vi_subscribe_vehicle_data_response.h b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/vi_subscribe_vehicle_data_response.h index 1148a8b41a1..523867d87e3 100644 --- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/vi_subscribe_vehicle_data_response.h +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/vi_subscribe_vehicle_data_response.h @@ -34,6 +34,7 @@ #define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_VI_SUBSCRIBE_VEHICLE_DATA_RESPONSE_H_ #include "application_manager/commands/response_from_hmi.h" +#include "vehicle_info_plugin/vehicle_info_command_params.h" namespace vehicle_info_plugin { namespace app_mngr = application_manager; @@ -53,10 +54,7 @@ class VISubscribeVehicleDataResponse **/ VISubscribeVehicleDataResponse( 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); + const VehicleInfoCommandParams& params); /** * @brief VISubscribeVehicleDataResponse class destructor @@ -74,6 +72,6 @@ class VISubscribeVehicleDataResponse } // namespace commands -} // namespace application_manager +} // namespace vehicle_info_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_VI_SUBSCRIBE_VEHICLE_DATA_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/vi_unsubscribe_vehicle_data_request.h b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/vi_unsubscribe_vehicle_data_request.h index 3b39835fbf2..4e3cc59c2eb 100644 --- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/vi_unsubscribe_vehicle_data_request.h +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/vi_unsubscribe_vehicle_data_request.h @@ -34,6 +34,8 @@ #define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_VI_UNSUBSCRIBE_VEHICLE_DATA_REQUEST_H_ #include "application_manager/commands/request_to_hmi.h" +#include "vehicle_info_plugin/custom_vehicle_data_manager.h" +#include "vehicle_info_plugin/vehicle_info_command_params.h" namespace vehicle_info_plugin { namespace app_mngr = application_manager; @@ -53,10 +55,7 @@ class VIUnsubscribeVehicleDataRequest **/ VIUnsubscribeVehicleDataRequest( 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); + const VehicleInfoCommandParams& params); /** * @brief VIUnsubscribeVehicleDataRequest class destructor @@ -69,11 +68,13 @@ class VIUnsubscribeVehicleDataRequest virtual void Run(); private: + CustomVehicleDataManager& custom_vehicle_data_manager_; + DISALLOW_COPY_AND_ASSIGN(VIUnsubscribeVehicleDataRequest); }; } // namespace commands -} // namespace application_manager +} // namespace vehicle_info_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_VI_UNSUBSCRIBE_VEHICLE_DATA_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/vi_unsubscribe_vehicle_data_response.h b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/vi_unsubscribe_vehicle_data_response.h index ada6896520a..e8f2267ce6d 100644 --- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/vi_unsubscribe_vehicle_data_response.h +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/vi_unsubscribe_vehicle_data_response.h @@ -34,6 +34,7 @@ #define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_VI_UNSUBSCRIBE_VEHICLE_DATA_RESPONSE_H_ #include "application_manager/commands/response_from_hmi.h" +#include "vehicle_info_plugin/vehicle_info_command_params.h" namespace vehicle_info_plugin { namespace app_mngr = application_manager; @@ -53,10 +54,7 @@ class VIUnsubscribeVehicleDataResponse **/ VIUnsubscribeVehicleDataResponse( 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); + const VehicleInfoCommandParams& params); /** * @brief VIUnsubscribeVehicleDataResponse class destructor @@ -74,6 +72,6 @@ class VIUnsubscribeVehicleDataResponse } // namespace commands -} // namespace application_manager +} // namespace vehicle_info_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_VI_UNSUBSCRIBE_VEHICLE_DATA_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/diagnostic_message_request.h b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/diagnostic_message_request.h index e2bc7c4dfd6..56f0e396218 100644 --- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/diagnostic_message_request.h +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/diagnostic_message_request.h @@ -36,6 +36,7 @@ #include "application_manager/commands/command_request_impl.h" #include "utils/macro.h" +#include "vehicle_info_plugin/vehicle_info_command_params.h" namespace vehicle_info_plugin { namespace app_mngr = application_manager; @@ -53,10 +54,7 @@ class DiagnosticMessageRequest : public app_mngr::commands::CommandRequestImpl { * @param message Incoming SmartObject message **/ DiagnosticMessageRequest(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); + const VehicleInfoCommandParams& params); /** * @brief DiagnosticMessageRequest class destructor @@ -80,6 +78,6 @@ class DiagnosticMessageRequest : public app_mngr::commands::CommandRequestImpl { }; } // namespace commands -} // namespace application_manager +} // namespace vehicle_info_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_DIAGNOSTIC_MESSAGE_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/diagnostic_message_response.h b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/diagnostic_message_response.h index d69a6a01552..5308551f5a1 100644 --- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/diagnostic_message_response.h +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/diagnostic_message_response.h @@ -36,6 +36,7 @@ #include "application_manager/commands/command_response_impl.h" #include "utils/macro.h" +#include "vehicle_info_plugin/vehicle_info_command_params.h" namespace vehicle_info_plugin { namespace app_mngr = application_manager; @@ -54,10 +55,7 @@ class DiagnosticMessageResponse * @param message Incoming SmartObject message **/ DiagnosticMessageResponse(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); + const VehicleInfoCommandParams& params); /** * @brief DiagnosticMessageResponse class destructor @@ -74,6 +72,6 @@ class DiagnosticMessageResponse }; } // namespace commands -} // namespace application_manager +} // namespace vehicle_info_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_DIAGNOSTIC_MESSAGE_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/get_dtcs_request.h b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/get_dtcs_request.h index 01f007697dc..562d7f236b2 100644 --- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/get_dtcs_request.h +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/get_dtcs_request.h @@ -36,6 +36,7 @@ #include "application_manager/commands/command_request_impl.h" #include "utils/macro.h" +#include "vehicle_info_plugin/vehicle_info_command_params.h" namespace vehicle_info_plugin { namespace app_mngr = application_manager; @@ -53,10 +54,7 @@ class GetDTCsRequest : public app_mngr::commands::CommandRequestImpl { * @param message Incoming SmartObject message **/ GetDTCsRequest(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); + const VehicleInfoCommandParams& params); /** * @brief GetDTCsRequest class destructor @@ -80,6 +78,6 @@ class GetDTCsRequest : public app_mngr::commands::CommandRequestImpl { }; } // namespace commands -} // namespace application_manager +} // namespace vehicle_info_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_GET_DTCS_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/get_dtcs_response.h b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/get_dtcs_response.h index 87024b18603..52836e895f3 100644 --- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/get_dtcs_response.h +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/get_dtcs_response.h @@ -36,6 +36,7 @@ #include "application_manager/commands/command_response_impl.h" #include "utils/macro.h" +#include "vehicle_info_plugin/vehicle_info_command_params.h" namespace vehicle_info_plugin { namespace app_mngr = application_manager; @@ -53,10 +54,7 @@ class GetDTCsResponse : public app_mngr::commands::CommandResponseImpl { * @param message Incoming SmartObject message **/ GetDTCsResponse(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); + const VehicleInfoCommandParams& params); /** * @brief GetDTCsResponse class destructor @@ -73,6 +71,6 @@ class GetDTCsResponse : public app_mngr::commands::CommandResponseImpl { }; } // namespace commands -} // namespace application_manager +} // namespace vehicle_info_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_GET_DTCS_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/get_vehicle_data_request.h b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/get_vehicle_data_request.h index 04a131da8fd..8a594b0647e 100644 --- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/get_vehicle_data_request.h +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/get_vehicle_data_request.h @@ -36,12 +36,11 @@ #include "application_manager/commands/command_request_impl.h" #include "utils/macro.h" +#include "vehicle_info_plugin/vehicle_info_command_params.h" namespace vehicle_info_plugin { namespace app_mngr = application_manager; -class SmartObject; - namespace commands { /** @@ -55,10 +54,7 @@ class GetVehicleDataRequest : public app_mngr::commands::CommandRequestImpl { * @param message Incoming SmartObject message **/ GetVehicleDataRequest(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); + const VehicleInfoCommandParams& params); /** * @brief GetVehicleDataRequest class destructor @@ -73,10 +69,22 @@ class GetVehicleDataRequest : public app_mngr::commands::CommandRequestImpl { protected: virtual void on_event(const app_mngr::event_engine::Event& event); + private: + /** + * @brief CheckFrequency check if mobile does not spam SDL with frequent + * GetVehicleData requests + * @return + */ + bool CheckFrequency(application_manager::Application& app); + + std::set pending_vehicle_data_; + + CustomVehicleDataManager& custom_vehicle_data_manager_; + DISALLOW_COPY_AND_ASSIGN(GetVehicleDataRequest); }; } // namespace commands -} // namespace application_manager +} // namespace vehicle_info_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_GET_VEHICLE_DATA_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/get_vehicle_data_response.h b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/get_vehicle_data_response.h index 22ec1a5a788..8d9722b2b60 100644 --- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/get_vehicle_data_response.h +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/get_vehicle_data_response.h @@ -36,7 +36,7 @@ #include "application_manager/commands/command_response_impl.h" #include "utils/macro.h" - +#include "vehicle_info_plugin/vehicle_info_command_params.h" namespace vehicle_info_plugin { namespace app_mngr = application_manager; @@ -53,10 +53,7 @@ class GetVehicleDataResponse : public app_mngr::commands::CommandResponseImpl { * @param message Incoming SmartObject message **/ GetVehicleDataResponse(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); + const VehicleInfoCommandParams& params); /** * @brief GetVehicleDataResponse class destructor @@ -73,6 +70,6 @@ class GetVehicleDataResponse : public app_mngr::commands::CommandResponseImpl { }; } // namespace commands -} // namespace application_manager +} // namespace vehicle_info_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_GET_VEHICLE_DATA_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/on_vehicle_data_notification.h b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/on_vehicle_data_notification.h index 57c30164e44..9163e78b5e2 100644 --- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/on_vehicle_data_notification.h +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/on_vehicle_data_notification.h @@ -34,9 +34,11 @@ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_ON_VEHICLE_DATA_NOTIFICATION_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_ON_VEHICLE_DATA_NOTIFICATION_H_ -#include "application_manager/commands/command_notification_impl.h" #include "application_manager/application.h" +#include "application_manager/commands/command_notification_impl.h" #include "utils/macro.h" +#include "vehicle_info_plugin/custom_vehicle_data_manager.h" +#include "vehicle_info_plugin/vehicle_info_command_params.h" namespace vehicle_info_plugin { namespace app_mngr = application_manager; @@ -56,10 +58,7 @@ class OnVehicleDataNotification * @param message Incoming SmartObject message **/ OnVehicleDataNotification(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); + const VehicleInfoCommandParams& params); /** * @brief OnVehicleDataNotification class destructor @@ -79,10 +78,12 @@ class OnVehicleDataNotification */ void SendVehicleData(app_mngr::ApplicationConstSharedPtr app); + CustomVehicleDataManager& custom_vehicle_data_manager_; + DISALLOW_COPY_AND_ASSIGN(OnVehicleDataNotification); }; } // namespace commands -} // namespace application_manager +} // namespace vehicle_info_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_ON_VEHICLE_DATA_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/read_did_request.h b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/read_did_request.h index 9a8fbbd62ec..8566075504c 100644 --- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/read_did_request.h +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/read_did_request.h @@ -36,7 +36,7 @@ #include "application_manager/commands/command_request_impl.h" #include "utils/macro.h" - +#include "vehicle_info_plugin/vehicle_info_command_params.h" namespace vehicle_info_plugin { namespace app_mngr = application_manager; @@ -53,10 +53,7 @@ class ReadDIDRequest : public app_mngr::commands::CommandRequestImpl { * @param message Incoming SmartObject message **/ ReadDIDRequest(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); + const VehicleInfoCommandParams& params); /** * @brief ReadDIDRequest class destructor @@ -80,6 +77,6 @@ class ReadDIDRequest : public app_mngr::commands::CommandRequestImpl { }; } // namespace commands -} // namespace application_manager +} // namespace vehicle_info_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_READ_DID_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/read_did_response.h b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/read_did_response.h index 2b7ab04768d..30e5aa45dec 100644 --- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/read_did_response.h +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/read_did_response.h @@ -36,7 +36,7 @@ #include "application_manager/commands/command_response_impl.h" #include "utils/macro.h" - +#include "vehicle_info_plugin/vehicle_info_command_params.h" namespace vehicle_info_plugin { namespace app_mngr = application_manager; @@ -53,10 +53,7 @@ class ReadDIDResponse : public app_mngr::commands::CommandResponseImpl { * @param message Incoming SmartObject message **/ ReadDIDResponse(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); + const VehicleInfoCommandParams& params); /** * @brief ReadDIDResponse class destructor @@ -73,6 +70,6 @@ class ReadDIDResponse : public app_mngr::commands::CommandResponseImpl { }; } // namespace commands -} // namespace application_manager +} // namespace vehicle_info_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_READ_DID_RESPONSE_H_ 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 7c6e1754da9..deac8a82953 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 @@ -37,10 +37,12 @@ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_SUBSCRIBE_VEHICLE_DATA_REQUEST_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_SUBSCRIBE_VEHICLE_DATA_REQUEST_H_ -#include "application_manager/commands/command_request_impl.h" #include "application_manager/application.h" +#include "application_manager/commands/command_request_impl.h" #include "utils/macro.h" +#include "vehicle_info_plugin/custom_vehicle_data_manager.h" #include "vehicle_info_plugin/vehicle_info_app_extension.h" +#include "vehicle_info_plugin/vehicle_info_command_params.h" namespace vehicle_info_plugin { namespace app_mngr = application_manager; @@ -60,10 +62,7 @@ class SubscribeVehicleDataRequest **/ SubscribeVehicleDataRequest( 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); + VehicleInfoCommandParams params); /** * @brief SubscribeButtonCommandRequest class destructor @@ -94,7 +93,7 @@ class SubscribeVehicleDataRequest * @return true, if there are registered apps subscribed for VI parameter, * otherwise - false */ - bool IsSomeoneSubscribedFor(const uint32_t param_id) const; + bool IsSomeoneSubscribedFor(const std::string& param_name) const; /** * @brief Adds VI parameters being subscribed by another or the same app to @@ -104,14 +103,14 @@ class SubscribeVehicleDataRequest void AddAlreadySubscribedVI(smart_objects::SmartObject& msg_params) const; /** - * @brief Removes subscription for VI parameters which subsription attempt - * returned an error + * @brief Actual subscription to pending vehicle data after successful + * response from HMI * @param app Pointer to application sent subscribe request * @param msg_params 'message_parameters' response section reference */ - void UnsubscribeFailedSubscriptions( + bool SubscribePendingVehicleData( app_mngr::ApplicationSharedPtr app, - const smart_objects::SmartObject& msg_params) const; + const smart_objects::SmartObject& msg_params); /** * @brief Checks if current application and other applications @@ -133,6 +132,43 @@ class SubscribeVehicleDataRequest smart_objects::SmartObject& out_request_params, bool& out_result); + /** + * @brief ConvertResponseToRequestName convert RPCSpec vehicle data names + * from response naming to request naming. + * This is workaround for cluster mode. + * Parameter named in request message as `cluster_mode` and in response + * message as `cluster_mode_status` + * @param name mobile RPCSpec vehicle data name + * @return hmi RPCSpec vehicle data name + */ + const std::string& ConvertResponseToRequestName(const std::string& name); + + /** + * @brief ConvertRequestToResponseName convert RPCSpec vehicle data names from + * request to response + * * This is workaround for cluster mode. + * Parameter named in request message as `cluster_mode` and in response + * message as `cluster_mode_status` + * @param name mobile RPCSpec vehicle data name + * @return hmi RPCSpec vehicle data name + */ + const std::string& ConvertRequestToResponseName(const std::string& name); + + /** + * @brief Appends data types for vehicle data in response to mobile + * @param msg_params 'message_parameters' response section reference + */ + void AppendDataTypesToMobileResponse( + smart_objects::SmartObject& msg_params) const; + + /** + * @brief Checks subscription status of certain vehicle_item + * @param vi_name name of vehicle item to be checked + * @param msg_params 'message_parameters' response section reference + */ + bool CheckSubscriptionStatus(std::string vi_name, + const smart_objects::SmartObject& msg_params); + /** * @brief VI parameters which had been already subscribed by another apps * befor particular app subscribed for these parameters @@ -149,10 +185,12 @@ class SubscribeVehicleDataRequest */ VehicleInfoSubscriptions vi_waiting_for_subscribe_; + CustomVehicleDataManager& custom_vehicle_data_manager_; + DISALLOW_COPY_AND_ASSIGN(SubscribeVehicleDataRequest); }; } // namespace commands -} // namespace application_manager +} // namespace vehicle_info_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_SUBSCRIBE_VEHICLE_DATA_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/subscribe_vehicle_data_response.h b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/subscribe_vehicle_data_response.h index 60670afee16..39af8b019bf 100644 --- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/subscribe_vehicle_data_response.h +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/subscribe_vehicle_data_response.h @@ -36,7 +36,7 @@ #include "application_manager/commands/command_response_impl.h" #include "utils/macro.h" - +#include "vehicle_info_plugin/vehicle_info_command_params.h" namespace vehicle_info_plugin { namespace app_mngr = application_manager; @@ -55,10 +55,7 @@ class SubscribeVehicleDataResponse **/ SubscribeVehicleDataResponse( 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); + const VehicleInfoCommandParams& params); /** * @brief UnsubscribeVehicleDataCommandRequest class destructor @@ -75,6 +72,6 @@ class SubscribeVehicleDataResponse }; } // namespace commands -} // namespace application_manager +} // namespace vehicle_info_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_SUBSCRIBE_VEHICLE_DATA_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/unsubscribe_vehicle_data_request.h b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/unsubscribe_vehicle_data_request.h index e04d1fb97a3..4f2a01244fe 100644 --- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/unsubscribe_vehicle_data_request.h +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/unsubscribe_vehicle_data_request.h @@ -34,10 +34,12 @@ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_UNSUBSCRIBE_VEHICLE_DATA_REQUEST_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_UNSUBSCRIBE_VEHICLE_DATA_REQUEST_H_ -#include "application_manager/commands/command_request_impl.h" #include "application_manager/application.h" +#include "application_manager/commands/command_request_impl.h" #include "utils/macro.h" +#include "vehicle_info_plugin/custom_vehicle_data_manager.h" #include "vehicle_info_plugin/vehicle_info_app_extension.h" +#include "vehicle_info_plugin/vehicle_info_command_params.h" namespace vehicle_info_plugin { namespace app_mngr = application_manager; @@ -57,10 +59,7 @@ class UnsubscribeVehicleDataRequest **/ UnsubscribeVehicleDataRequest( 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); + const VehicleInfoCommandParams& params); /** * @brief UnsubscribeVehicleDataRequest class destructor @@ -91,7 +90,7 @@ class UnsubscribeVehicleDataRequest * @return true, if there are registered apps subscribed for VI parameter, * otherwise - false */ - bool IsSomeoneSubscribedFor(const uint32_t param_id) const; + bool IsSomeoneSubscribedFor(const std::string& param_name) const; /** * @brief Adds VI parameters being unsubscribed by another or the same app to @@ -100,6 +99,49 @@ class UnsubscribeVehicleDataRequest */ void AddAlreadyUnsubscribedVI(smart_objects::SmartObject& response) const; + /** + * @brief Actual unsubscription from all pending vehicle data. To be called + * after successful HMI response + * @param app shared pointer to application, which initialized unsubscription + * @param msg_params 'message_params' response section reference + */ + bool UnsubscribePendingVehicleData( + app_mngr::ApplicationSharedPtr app, + const smart_objects::SmartObject& msg_params); + + /** + * @brief ConvertRequestToResponseName convert RPCSpec vehicle data names + * from hmi api to mobile api + * @param name mobile RPCSpec vehicle data name + * @return hmi RPCSpec vehicle data name + */ + const std::string& ConvertRequestToResponseName(const std::string& name); + + /** + * @brief ConvertResponseToRequestName convert RPCSpec vehicle data names + * from hmi api to mobile api + * @param name mobile RPCSpec vehicle data name + * @return hmi RPCSpec vehicle data name + */ + const std::string& ConvertResponseToRequestName(const std::string& name); + + /** + * @brief Appends data types for vehicle data in response to mobile + * @param msg_params 'message_parameters' response section reference + */ + void AppendDataTypesToMobileResponse( + smart_objects::SmartObject& msg_params) const; + + /** + * @brief Checks subscription status of certain vehicle_item + * @param key name of vehicle item to be checked + * @param msg_params 'message_parameters' response section reference + */ + bool CheckSubscriptionStatus(std::string key, + const smart_objects::SmartObject& msg_params); + + smart_objects::SmartObject response_params_; + /** * @brief VI parameters which still being subscribed by another apps after * particular app had been unsubscribed from these parameters @@ -107,14 +149,22 @@ class UnsubscribeVehicleDataRequest VehicleInfoSubscriptions vi_still_subscribed_by_another_apps_; /** - * @brief VI parameters which had been unsubscribed already by particular app + * @brief VI parameters which had been unsubscribed already by particular + * app */ VehicleInfoSubscriptions vi_already_unsubscribed_by_this_app_; + /** + * @brief VI parameters to be unsubscribed after HMI response + */ + VehicleInfoSubscriptions vi_waiting_for_unsubscribe_; + + CustomVehicleDataManager& custom_vehicle_data_manager_; + DISALLOW_COPY_AND_ASSIGN(UnsubscribeVehicleDataRequest); }; } // namespace commands -} // namespace application_manager +} // namespace vehicle_info_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_UNSUBSCRIBE_VEHICLE_DATA_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/unsubscribe_vehicle_data_response.h b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/unsubscribe_vehicle_data_response.h index 397ae3cbce6..f181e7f8c34 100644 --- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/unsubscribe_vehicle_data_response.h +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/unsubscribe_vehicle_data_response.h @@ -36,7 +36,7 @@ #include "application_manager/commands/command_response_impl.h" #include "utils/macro.h" - +#include "vehicle_info_plugin/vehicle_info_command_params.h" namespace vehicle_info_plugin { namespace app_mngr = application_manager; @@ -55,10 +55,7 @@ class UnsubscribeVehicleDataResponse **/ UnsubscribeVehicleDataResponse( 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); + const VehicleInfoCommandParams& params); /** * @brief UnsubscribeVehicleDataResponse class destructor @@ -75,6 +72,6 @@ class UnsubscribeVehicleDataResponse }; } // namespace commands -} // namespace application_manager +} // namespace vehicle_info_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_UNSUBSCRIBE_VEHICLE_DATA_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/custom_vehicle_data_manager.h b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/custom_vehicle_data_manager.h new file mode 100644 index 00000000000..9cac76b9546 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/custom_vehicle_data_manager.h @@ -0,0 +1,55 @@ +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_VEHICLE_INFO_PLUGIN_INCLUDE_VEHICLE_INFO_PLUGIN_CUSTOM_VEHICLE_DATA_MANAGER_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_VEHICLE_INFO_PLUGIN_INCLUDE_VEHICLE_INFO_PLUGIN_CUSTOM_VEHICLE_DATA_MANAGER_H_ +#include +#include + +#include "application_manager/plugin_manager/rpc_plugin.h" +#include "application_manager/rpc_handler.h" +#include "smart_objects/smart_object.h" + +namespace vehicle_info_plugin { + +namespace plugin_manager = application_manager::plugin_manager; + +class CustomVehicleDataManager { + public: + /** + * @brief Creates message params (nested if needed) to be sent to HMI + * according to vehicle data item schema + * @param item_names set of names of vehicle data items to be processed + * @return smartMap with prepared message params + */ + virtual smart_objects::SmartObject CreateHMIMessageParams( + const std::set& item_names) = 0; + + /** + * @brief Gets data type of vehicle data item + * @param vehicle_data_item_name name of vehicle data + * @return data type of vehicle_data if one found, item name otherwise + */ + virtual std::string GetVehicleDataItemType( + const std::string& vehicle_data_item_name) const = 0; + + /** + * @brief Creates message params (nested if needed) to be sent to Mobile + * according to vehicle data item schema + * @param input_params message params received from hmi + */ + virtual void CreateMobileMessageParams( + smart_objects::SmartObject& msg_params) = 0; + + virtual void OnPolicyEvent(plugin_manager::PolicyEvent policy_event) = 0; + + virtual bool IsValidCustomVehicleDataName(const std::string& name) const = 0; + + /** + * @brief Checks whether custom vehicle data name was removed after the last + * PTU or not + * @param name vehicle item name to check + * @return true if vehicle data with this name was removed after the last PTU + */ + virtual bool IsRemovedCustomVehicleDataName( + const std::string& name) const = 0; +}; +} // namespace vehicle_info_plugin +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_VEHICLE_INFO_PLUGIN_INCLUDE_VEHICLE_INFO_PLUGIN_CUSTOM_VEHICLE_DATA_MANAGER_H_ diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/custom_vehicle_data_manager_impl.h b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/custom_vehicle_data_manager_impl.h new file mode 100644 index 00000000000..239c4edb900 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/custom_vehicle_data_manager_impl.h @@ -0,0 +1,103 @@ +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_VEHICLE_DATA_VALIDATION_MANAGER_IMPL_H +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_VEHICLE_DATA_VALIDATION_MANAGER_IMPL_H + +#include + +#include "smart_objects/smart_object.h" +#include "vehicle_info_plugin/custom_vehicle_data_manager.h" + +namespace rpc { +namespace policy_table_interface_base { +class VehicleDataItem; +} +} // namespace rpc + +namespace policy { +class VehicleDataItemProvider; +} + +namespace vehicle_info_plugin { +namespace policy_table = rpc::policy_table_interface_base; +namespace plugin_manager = application_manager::plugin_manager; + +typedef boost::optional OptionalDataItem; +typedef std::set VehicleInfoSubscriptions; + +class CustomVehicleDataManagerImpl : public CustomVehicleDataManager { + public: + CustomVehicleDataManagerImpl( + policy::VehicleDataItemProvider& vehicle_data_provider, + application_manager::rpc_service::RPCService& rpc_service); + + virtual smart_objects::SmartObject CreateHMIMessageParams( + const std::set& item_names) OVERRIDE; + + std::string GetVehicleDataItemType( + const std::string& vehicle_data_item_name) const OVERRIDE; + + virtual void CreateMobileMessageParams( + smart_objects::SmartObject& msg_params) OVERRIDE; + + void OnPolicyEvent(plugin_manager::PolicyEvent policy_event) OVERRIDE; + + bool IsValidCustomVehicleDataName(const std::string& name) const OVERRIDE; + + bool IsRemovedCustomVehicleDataName(const std::string& name) const OVERRIDE; + + private: + class RPCParams { + public: + RPCParams() {} + ~RPCParams() {} + + void addBoolParam( + const std::pair& param) { + rpc_params_bool_.insert(param); + } + void addVDRParam( + const std::pair& param) { + rpc_params_vdr_.insert(param); + } + void addParam(const std::pair& param) { + rpc_params_.insert(param); + } + + const std::map& getBoolParams() { + return rpc_params_bool_; + } + const std::map& getVDRParams() { + return rpc_params_vdr_; + } + const std::map& getParams() { + return rpc_params_; + } + + private: + std::map rpc_params_bool_; + std::map rpc_params_vdr_; + std::map rpc_params_; + }; + + /** + * @brief Updates vehicle data schemas according to policy update. + */ + void UpdateVehicleDataItems(); + + const OptionalDataItem FindSchemaByNameNonRecursive( + const std::string& name) const; + const OptionalDataItem FindRemovedSchemaByNameNonRecursive( + const std::string& name) const; + const OptionalDataItem FindSchemaByKeyNonRecursive( + const std::string& key) const; + const OptionalDataItem FindSchemaByNameRecursive( + const std::string& name) const; + const OptionalDataItem FindSchemaByKeyRecursive( + const std::string& name) const; + + policy::VehicleDataItemProvider& vehicle_data_provider_; + application_manager::rpc_service::RPCService& rpc_service_; +}; + +} // namespace vehicle_info_plugin + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_VEHICLE_DATA_VALIDATION_MANAGER_IMPL_H diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/vehicle_data_item_schema.h b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/vehicle_data_item_schema.h new file mode 100644 index 00000000000..5ea73e2dec2 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/vehicle_data_item_schema.h @@ -0,0 +1,115 @@ +#ifndef VEHICLE_DATA_ITEM_SCHEMA_H +#define VEHICLE_DATA_ITEM_SCHEMA_H +#include "policy/policy_table/types.h" +#include "smart_objects/always_false_schema_item.h" +#include "smart_objects/always_true_schema_item.h" +#include "smart_objects/array_schema_item.h" +#include "smart_objects/bool_schema_item.h" +#include "smart_objects/enum_schema_item.h" +#include "smart_objects/number_schema_item.h" +#include "smart_objects/object_schema_item.h" +#include "smart_objects/schema_item.h" +#include "smart_objects/schema_item_parameter.h" +#include "smart_objects/smart_object.h" +#include "smart_objects/string_schema_item.h" +#include "utils/logger.h" + +namespace vehicle_info_plugin { +namespace smart_objects = ns_smart_device_link::ns_smart_objects; +namespace policy_table = rpc::policy_table_interface_base; + +class VehicleDataItemSchema; +typedef std::shared_ptr VehicleDataItemSchemaPtr; +typedef smart_objects::TSchemaItemParameter + PolicyDataItem; + +/** + * @brief VehicleData schema item. + **/ +class VehicleDataItemSchema : public smart_objects::ISchemaItem { + public: + enum SchemaType { MOBILE = 0, HMI }; + + /** + * @brief Create a new schema item. + * @param PolicyDataItem& SchemaItem for VehicleDataItem elements. + * @return Shared pointer to a new schema item. + **/ + static VehicleDataItemSchemaPtr create(PolicyDataItem& policy_item, + SchemaType schema_type); + + /** + * @brief Validate smart object. + * @param Object Object to validate. + * @param report__ object for reporting errors during validation + * @param MessageVersion to check mobile RPC version against RPC Spec History + * @param allow_unknown_enums + * false - unknown enum values (left as string values after applySchema) + * will be considered invalid. + * true - such values will be considered valid. + * @return ns_smart_objects::errors::eType + **/ + smart_objects::errors::eType validate( + const smart_objects::SmartObject& Object, + rpc::ValidationReport* report__, + const utils::SemanticVersion& MessageVersion = utils::SemanticVersion(), + const bool allow_unknown_enums = false) OVERRIDE; + + private: + /** + * @brief Constructor. + * @param PolicyDataItem& SchemaItem for VehicleDataItem elements. + * @param SchemaType defines api type for schema to be generated. + **/ + VehicleDataItemSchema(PolicyDataItem& policy_item, SchemaType schema_type); + + /* + * @brief Check whether provided type is POD type + * @param const std::string& type_name - name of type to check + * @return true - if type is POD type and false - if not + */ + const bool isPODType(const std::string& type_name) const; + + /* + * @brief Get Enum schema for provided type + * @param const std::string& type_name - name of enum type to provide + * @return Shared pointer to a new schema item. If no schema found - nullptr + * is returned. + */ + smart_objects::ISchemaItemPtr getEnumSchema( + const std::string& type_name) const; + + /** + * @brief Apply schema. + * @param Object Object to apply schema. + * @param remove_unknown_parameters contains true if need to remove unknown + * parameters from smart object otherwise contains false. + **/ + void applySchema(smart_objects::SmartObject& Object, + const bool remove_unknown_parameters, + const utils::SemanticVersion& MessageVersion) OVERRIDE; + + /** + * @brief Unapply schema. + * @param Object Object to unapply schema. + * @param remove_unknown_parameters contains true if need to remove unknown + * parameters + **/ + void unapplySchema(smart_objects::SmartObject& Object, + const bool remove_unknown_parameters) OVERRIDE; + + /* + * @brief Get schema for a POD type + * @param const VehicleDataItem& policy_item - item, that contains info about + * type + * @return Shared pointer to a new schema item. If no schema found - nullptr + * is returned. + */ + smart_objects::ISchemaItemPtr GetPODTypeSchema( + const policy_table::VehicleDataItem& policy_item, SchemaType schema_type); + + smart_objects::ISchemaItemPtr so_schema_item_; +}; + +} // namespace vehicle_info_plugin +#endif // VEHICLE_DATA_ITEM_SCHEMA_H diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/vehicle_info_app_extension.h b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/vehicle_info_app_extension.h index ead6af841fd..fb7c2b0f82b 100644 --- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/vehicle_info_app_extension.h +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/vehicle_info_app_extension.h @@ -47,7 +47,7 @@ typedef mobile_apis::VehicleDataType::eType VehicleDataType; /** * @brief Defines set of vehicle info types */ -typedef std::set VehicleInfoSubscriptions; +typedef std::set VehicleInfoSubscriptions; class VehicleInfoAppExtension : public app_mngr::AppExtension { public: @@ -61,12 +61,12 @@ class VehicleInfoAppExtension : public app_mngr::AppExtension { virtual ~VehicleInfoAppExtension(); /** - * @brief subscribeToVehicleInfo add vehicle_data to list of subscriptions of - * application extension - * @param vehicle_data data to subscribe - * @return true in case if subscription is successful - */ - bool subscribeToVehicleInfo(const VehicleDataType vehicle_data); + * @brief subscribeToVehicleInfo add vehicle_data to list of subscriptions of + * application extension + * @param vehicle_data data to subscribe + * @return true in case if subscription is successful + */ + bool subscribeToVehicleInfo(const std::string& vehicle_data); /** * @brief unsubscribeFromVehicleInfo remove vehicle_data from list of @@ -74,7 +74,7 @@ class VehicleInfoAppExtension : public app_mngr::AppExtension { * @param vehicle_data data to unsubscribe * @return true in case if unsubscription is successful */ - bool unsubscribeFromVehicleInfo(const VehicleDataType vehicle_data); + bool unsubscribeFromVehicleInfo(const std::string& vehicle_data); /** * @brief unsubscribeFromVehicleInfo unsubscribe from all vehicle info data */ @@ -87,7 +87,7 @@ class VehicleInfoAppExtension : public app_mngr::AppExtension { * @return true if extension is subscribed this vehicle_data_type, otherwise * return false */ - bool isSubscribedToVehicleInfo(const VehicleDataType vehicle_data_type) const; + bool isSubscribedToVehicleInfo(const std::string& vehicle_data_type) const; /** * @brief Subscriptions get list of subscriptions for application extension @@ -130,6 +130,6 @@ class VehicleInfoAppExtension : public app_mngr::AppExtension { VehicleInfoPlugin& plugin_; app_mngr::Application& app_; }; -} +} // namespace vehicle_info_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_VEHICLE_INFO_PLUGIN_INCLUDE_VEHICLE_INFO_PLUGIN_VEHICLE_INFO_APP_EXTENSION_H diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/vehicle_info_command_factory.h b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/vehicle_info_command_factory.h index e36611dfa65..3356f0f8232 100644 --- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/vehicle_info_command_factory.h +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/vehicle_info_command_factory.h @@ -34,37 +34,38 @@ #define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_VEHICLE_INFO_PLUGIN_INCLUDE_VEHICLE_INFO_PLUGIN_VEHICLE_INFO_COMMAND_FACTORY_H #include "application_manager/application_manager.h" +#include "vehicle_info_plugin/custom_vehicle_data_manager.h" #include "vehicle_info_plugin/vehicle_info_hmi_command_factory.h" #include "vehicle_info_plugin/vehicle_info_mobile_command_factory.h" namespace vehicle_info_plugin { -namespace app_mngr = application_manager; -namespace commands = application_manager::commands; - /** * @brief The Vehicle Info command factory. */ -class VehicleInfoCommandFactory : public app_mngr::CommandFactory { +class VehicleInfoCommandFactory : public application_manager::CommandFactory { public: - VehicleInfoCommandFactory(app_mngr::ApplicationManager& application_manager, - app_mngr::rpc_service::RPCService& rpc_service, - app_mngr::HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handler); + VehicleInfoCommandFactory( + application_manager::ApplicationManager& application_manager, + application_manager::rpc_service::RPCService& rpc_service, + application_manager::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handler, + CustomVehicleDataManager& custom_vehicle_data_manager); virtual ~VehicleInfoCommandFactory(); - app_mngr::CommandSharedPtr CreateCommand( - const commands::MessageSharedPtr& message, - commands::Command::CommandSource source) OVERRIDE; + application_manager::CommandSharedPtr CreateCommand( + const application_manager::commands::MessageSharedPtr& message, + application_manager::commands::Command::CommandSource source) OVERRIDE; bool IsAbleToProcess( const int32_t function_id, - const commands::Command::CommandSource source) const OVERRIDE; + const application_manager::commands::Command::CommandSource source) + const OVERRIDE; private: - std::unique_ptr hmi_command_factory_; - std::unique_ptr mob_command_factory_; + std::unique_ptr hmi_command_factory_; + std::unique_ptr mob_command_factory_; }; -} +} // namespace vehicle_info_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_VEHICLE_INFO_PLUGIN_INCLUDE_VEHICLE_INFO_PLUGIN_VEHICLE_INFO_COMMAND_FACTORY_H diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/vehicle_info_command_params.h b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/vehicle_info_command_params.h new file mode 100644 index 00000000000..df8dbfd8027 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/vehicle_info_command_params.h @@ -0,0 +1,31 @@ +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_VEHICLE_INFO_PLUGIN_INCLUDE_VEHICLE_INFO_PLUGIN_VEHICLE_INFO_COMMAND_PARAMS_H +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_VEHICLE_INFO_PLUGIN_INCLUDE_VEHICLE_INFO_PLUGIN_VEHICLE_INFO_COMMAND_PARAMS_H + +namespace application_manager { +class ApplicationManager; +class HMICapabilities; +namespace rpc_service { +class RPCService; +} +class ApplicationManager; +} // namespace application_manager + +namespace policy { +class PolicyHandlerInterface; +} + +namespace vehicle_info_plugin { +namespace app_mngr = application_manager; + +class CustomVehicleDataManager; + +struct VehicleInfoCommandParams { + app_mngr::ApplicationManager& application_manager_; + app_mngr::rpc_service::RPCService& rpc_service_; + app_mngr::HMICapabilities& hmi_capabilities_; + policy::PolicyHandlerInterface& policy_handler_; + CustomVehicleDataManager& custom_vehicle_data_manager_; +}; +} // namespace vehicle_info_plugin + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_VEHICLE_INFO_PLUGIN_INCLUDE_VEHICLE_INFO_PLUGIN_VEHICLE_INFO_COMMAND_PARAMS_H diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/vehicle_info_hmi_command_factory.h b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/vehicle_info_hmi_command_factory.h index 412949eedba..60d81b5446c 100644 --- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/vehicle_info_hmi_command_factory.h +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/vehicle_info_hmi_command_factory.h @@ -34,6 +34,8 @@ #define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_VEHICLE_INFO_PLUGIN_INCLUDE_VEHICLE_INFO_PLUGIN_VEHICLE_INFO_HMI_COMMAND_FACTORY_H #include "application_manager/application_manager.h" +#include "application_manager/command_factory.h" +#include "vehicle_info_plugin/custom_vehicle_data_manager.h" namespace vehicle_info_plugin { namespace app_mngr = application_manager; @@ -47,7 +49,8 @@ class VehicleInfoHmiCommandFactory : public app_mngr::CommandFactory { app_mngr::ApplicationManager& application_manager, app_mngr::rpc_service::RPCService& rpc_service, app_mngr::HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handler); + policy::PolicyHandlerInterface& policy_handler, + CustomVehicleDataManager& custom_vehicle_data_manager); app_mngr::CommandSharedPtr CreateCommand( const app_mngr::commands::MessageSharedPtr& message, @@ -62,12 +65,13 @@ class VehicleInfoHmiCommandFactory : public app_mngr::CommandFactory { app_mngr::rpc_service::RPCService& rpc_service_; app_mngr::HMICapabilities& hmi_capabilities_; policy::PolicyHandlerInterface& policy_handler_; + CustomVehicleDataManager& custom_vehicle_data_manager_; app_mngr::CommandCreator& buildCommandCreator( const int32_t function_id, const int32_t message_type) const; DISALLOW_COPY_AND_ASSIGN(VehicleInfoHmiCommandFactory); }; -} +} // namespace vehicle_info_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_VEHICLE_INFO_PLUGIN_INCLUDE_VEHICLE_INFO_PLUGIN_VEHICLE_INFO_HMI_COMMAND_FACTORY_H diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/vehicle_info_mobile_command_factory.h b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/vehicle_info_mobile_command_factory.h index d38ef6fb904..e3403df5e58 100644 --- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/vehicle_info_mobile_command_factory.h +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/vehicle_info_mobile_command_factory.h @@ -34,7 +34,8 @@ #define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_VEHICLE_INFO_PLUGIN_INCLUDE_VEHICLE_INFO_PLUGIN_VEHICLE_INFO_MOBILE_COMMAND_FACTORY_H #include "application_manager/application_manager.h" - +#include "application_manager/command_factory.h" +#include "vehicle_info_plugin/custom_vehicle_data_manager.h" namespace vehicle_info_plugin { namespace app_mngr = application_manager; @@ -47,7 +48,8 @@ class VehicleInfoMobileCommandFactory : public app_mngr::CommandFactory { app_mngr::ApplicationManager& application_manager, app_mngr::rpc_service::RPCService& rpc_service, app_mngr::HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handler); + policy::PolicyHandlerInterface& policy_handler, + CustomVehicleDataManager& custom_vehicle_data_manager); app_mngr::CommandSharedPtr CreateCommand( const app_mngr::commands::MessageSharedPtr& message, @@ -62,6 +64,7 @@ class VehicleInfoMobileCommandFactory : public app_mngr::CommandFactory { app_mngr::rpc_service::RPCService& rpc_service_; app_mngr::HMICapabilities& hmi_capabilities_; policy::PolicyHandlerInterface& policy_handler_; + CustomVehicleDataManager& custom_vehicle_data_manager_; app_mngr::CommandCreator& get_creator_factory( const mobile_apis::FunctionID::eType function_id, @@ -75,6 +78,6 @@ class VehicleInfoMobileCommandFactory : public app_mngr::CommandFactory { DISALLOW_COPY_AND_ASSIGN(VehicleInfoMobileCommandFactory); }; -} +} // namespace vehicle_info_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_VEHICLE_INFO_PLUGIN_INCLUDE_VEHICLE_INFO_PLUGIN_VEHICLE_INFO_MOBILE_COMMAND_FACTORY_H diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/vehicle_info_plugin.h b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/vehicle_info_plugin.h index b15b7006e6d..f0f68af298b 100644 --- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/vehicle_info_plugin.h +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/vehicle_info_plugin.h @@ -34,6 +34,7 @@ #define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_VEHICLE_INFO_PLUGIN_INCLUDE_VEHICLE_INFO_PLUGIN_VEHICLE_INFO_PLUGIN_H #include "application_manager/command_factory.h" +#include "vehicle_info_plugin/custom_vehicle_data_manager.h" namespace vehicle_info_plugin { class VehicleInfoAppExtension; @@ -47,7 +48,8 @@ class VehicleInfoPlugin : public plugins::RPCPlugin { bool Init(app_mngr::ApplicationManager& application_manager, app_mngr::rpc_service::RPCService& rpc_service, app_mngr::HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handler) OVERRIDE; + policy::PolicyHandlerInterface& policy_handler, + resumption::LastState& last_state) OVERRIDE; bool IsAbleToProcess( const int32_t function_id, @@ -70,13 +72,17 @@ class VehicleInfoPlugin : public plugins::RPCPlugin { VehicleInfoAppExtension& ext); private: + void UnsubscribeFromRemovedVDItems(); + smart_objects::SmartObjectSPtr GetUnsubscribeIVIRequest( + const std::vector& ivi_names); void DeleteSubscriptions(app_mngr::ApplicationSharedPtr app); std::unique_ptr command_factory_; + std::unique_ptr custom_vehicle_data_manager_; app_mngr::ApplicationManager* application_manager_; }; -} +} // namespace vehicle_info_plugin extern "C" application_manager::plugin_manager::RPCPlugin* Create(); - +extern "C" void Delete(application_manager::plugin_manager::RPCPlugin* data); #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_VEHICLE_INFO_PLUGIN_INCLUDE_VEHICLE_INFO_PLUGIN_VEHICLE_INFO_PLUGIN_H diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/on_vi_vehicle_data_notification.cc b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/on_vi_vehicle_data_notification.cc index 6125c4ee457..b8d1b3a100f 100644 --- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/on_vi_vehicle_data_notification.cc +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/on_vi_vehicle_data_notification.cc @@ -40,15 +40,12 @@ namespace commands { OnVIVehicleDataNotification::OnVIVehicleDataNotification( const application_manager::commands::MessageSharedPtr& message, - ApplicationManager& application_manager, - rpc_service::RPCService& rpc_service, - HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handle) + const VehicleInfoCommandParams& params) : NotificationFromHMI(message, - application_manager, - rpc_service, - hmi_capabilities, - policy_handle) {} + params.application_manager_, + params.rpc_service_, + params.hmi_capabilities_, + params.policy_handler_) {} OnVIVehicleDataNotification::~OnVIVehicleDataNotification() {} @@ -62,9 +59,8 @@ void OnVIVehicleDataNotification::Run() { const smart_objects::SmartObject& msg_params = (*message_)[strings::msg_params]; if (msg_params.keyExists(strings::odometer)) { - application_manager_.IviInfoUpdated( - mobile_apis::VehicleDataType::VEHICLEDATA_ODOMETER, - msg_params[strings::odometer].asInt()); + application_manager_.IviInfoUpdated(strings::odometer, + msg_params[strings::odometer].asInt()); } SendNotificationToMobile(message_); @@ -72,4 +68,4 @@ void OnVIVehicleDataNotification::Run() { } // namespace commands -} // namespace application_manager +} // namespace vehicle_info_plugin diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/vi_diagnostic_message_request.cc b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/vi_diagnostic_message_request.cc index 8d3b9f13fb6..ae64c74f267 100644 --- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/vi_diagnostic_message_request.cc +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/vi_diagnostic_message_request.cc @@ -38,16 +38,13 @@ using namespace application_manager; namespace commands { VIDiagnosticMessageRequest::VIDiagnosticMessageRequest( - const application_manager::commands::MessageSharedPtr& message, - ApplicationManager& application_manager, - rpc_service::RPCService& rpc_service, - HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handle) + const app_mngr::commands::MessageSharedPtr& message, + const VehicleInfoCommandParams& params) : RequestToHMI(message, - application_manager, - rpc_service, - hmi_capabilities, - policy_handle) {} + params.application_manager_, + params.rpc_service_, + params.hmi_capabilities_, + params.policy_handler_) {} VIDiagnosticMessageRequest::~VIDiagnosticMessageRequest() {} @@ -59,4 +56,4 @@ void VIDiagnosticMessageRequest::Run() { } // namespace commands -} // namespace application_manager +} // namespace vehicle_info_plugin diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/vi_diagnostic_message_response.cc b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/vi_diagnostic_message_response.cc index e22ba7ddb20..6482d97d10e 100644 --- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/vi_diagnostic_message_response.cc +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/vi_diagnostic_message_response.cc @@ -40,15 +40,12 @@ namespace commands { VIDiagnosticMessageResponse::VIDiagnosticMessageResponse( const application_manager::commands::MessageSharedPtr& message, - ApplicationManager& application_manager, - rpc_service::RPCService& rpc_service, - HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handle) + const VehicleInfoCommandParams& params) : ResponseFromHMI(message, - application_manager, - rpc_service, - hmi_capabilities, - policy_handle) {} + params.application_manager_, + params.rpc_service_, + params.hmi_capabilities_, + params.policy_handler_) {} VIDiagnosticMessageResponse::~VIDiagnosticMessageResponse() {} @@ -63,4 +60,4 @@ void VIDiagnosticMessageResponse::Run() { } // namespace commands -} // namespace application_manager +} // namespace vehicle_info_plugin diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/vi_get_dtcs_request.cc b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/vi_get_dtcs_request.cc index 71ce6331ab6..620ee4c3e4f 100644 --- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/vi_get_dtcs_request.cc +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/vi_get_dtcs_request.cc @@ -39,15 +39,12 @@ namespace commands { VIGetDTCsRequest::VIGetDTCsRequest( const application_manager::commands::MessageSharedPtr& message, - ApplicationManager& application_manager, - rpc_service::RPCService& rpc_service, - HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handle) + const VehicleInfoCommandParams& params) : RequestToHMI(message, - application_manager, - rpc_service, - hmi_capabilities, - policy_handle) {} + params.application_manager_, + params.rpc_service_, + params.hmi_capabilities_, + params.policy_handler_) {} VIGetDTCsRequest::~VIGetDTCsRequest() {} @@ -59,4 +56,4 @@ void VIGetDTCsRequest::Run() { } // namespace commands -} // namespace application_manager +} // namespace vehicle_info_plugin diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/vi_get_dtcs_response.cc b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/vi_get_dtcs_response.cc index 9d39c60796d..64e948a4e15 100644 --- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/vi_get_dtcs_response.cc +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/vi_get_dtcs_response.cc @@ -40,15 +40,12 @@ namespace commands { VIGetDTCsResponse::VIGetDTCsResponse( const application_manager::commands::MessageSharedPtr& message, - ApplicationManager& application_manager, - rpc_service::RPCService& rpc_service, - HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handle) + const VehicleInfoCommandParams& params) : ResponseFromHMI(message, - application_manager, - rpc_service, - hmi_capabilities, - policy_handle) {} + params.application_manager_, + params.rpc_service_, + params.hmi_capabilities_, + params.policy_handler_) {} VIGetDTCsResponse::~VIGetDTCsResponse() {} @@ -62,4 +59,4 @@ void VIGetDTCsResponse::Run() { } // namespace commands -} // namespace application_manager +} // namespace vehicle_info_plugin diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/vi_get_vehicle_data_request.cc b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/vi_get_vehicle_data_request.cc index 9fc48c88201..eded6c685b5 100644 --- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/vi_get_vehicle_data_request.cc +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/vi_get_vehicle_data_request.cc @@ -31,6 +31,7 @@ */ #include "vehicle_info_plugin/commands/hmi/vi_get_vehicle_data_request.h" +#include "application_manager/message_helper.h" namespace vehicle_info_plugin { using namespace application_manager; @@ -39,24 +40,39 @@ namespace commands { VIGetVehicleDataRequest::VIGetVehicleDataRequest( const application_manager::commands::MessageSharedPtr& message, - ApplicationManager& application_manager, - rpc_service::RPCService& rpc_service, - HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handle) + const VehicleInfoCommandParams& params) : RequestToHMI(message, - application_manager, - rpc_service, - hmi_capabilities, - policy_handle) {} + params.application_manager_, + params.rpc_service_, + params.hmi_capabilities_, + params.policy_handler_) + , custom_vehicle_data_manager_(params.custom_vehicle_data_manager_) {} VIGetVehicleDataRequest::~VIGetVehicleDataRequest() {} void VIGetVehicleDataRequest::Run() { LOG4CXX_AUTO_TRACE(logger_); + const auto& rpc_spec_vehicle_data = MessageHelper::vehicle_data(); + auto& msg_params = (*message_)[strings::msg_params]; + + smart_objects::SmartObject custom_data; + for (const auto& name : msg_params.enumerate()) { + const auto& found_it = rpc_spec_vehicle_data.find(name); + if (rpc_spec_vehicle_data.end() == found_it) { + custom_data[name] = msg_params[name]; + msg_params.erase(name); + } + } + + auto hmi_custom_msg_params = + custom_vehicle_data_manager_.CreateHMIMessageParams( + custom_data.enumerate()); + for (const auto& param : hmi_custom_msg_params.enumerate()) { + msg_params[param] = hmi_custom_msg_params[param]; + } SendRequest(); } } // namespace commands - -} // namespace application_manager +} // namespace vehicle_info_plugin diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/vi_get_vehicle_data_response.cc b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/vi_get_vehicle_data_response.cc index 73ba1a94feb..6a60cc968e2 100644 --- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/vi_get_vehicle_data_response.cc +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/vi_get_vehicle_data_response.cc @@ -31,6 +31,8 @@ */ #include "vehicle_info_plugin/commands/hmi/vi_get_vehicle_data_response.h" #include "application_manager/event_engine/event.h" +#include "application_manager/policies/policy_handler_interface.h" + #include "interfaces/HMI_API.h" namespace vehicle_info_plugin { @@ -39,15 +41,12 @@ namespace commands { VIGetVehicleDataResponse::VIGetVehicleDataResponse( const application_manager::commands::MessageSharedPtr& message, - ApplicationManager& application_manager, - rpc_service::RPCService& rpc_service, - HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handle) + const VehicleInfoCommandParams& params) : ResponseFromHMI(message, - application_manager, - rpc_service, - hmi_capabilities, - policy_handle) {} + params.application_manager_, + params.rpc_service_, + params.hmi_capabilities_, + params.policy_handler_) {} VIGetVehicleDataResponse::~VIGetVehicleDataResponse() {} @@ -86,4 +85,4 @@ void VIGetVehicleDataResponse::Run() { } } // namespace commands -} // namespace application_manager +} // namespace vehicle_info_plugin diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/vi_get_vehicle_type_request.cc b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/vi_get_vehicle_type_request.cc index a1a221220a7..250584bd122 100644 --- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/vi_get_vehicle_type_request.cc +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/vi_get_vehicle_type_request.cc @@ -39,15 +39,12 @@ namespace commands { VIGetVehicleTypeRequest::VIGetVehicleTypeRequest( const application_manager::commands::MessageSharedPtr& message, - ApplicationManager& application_manager, - rpc_service::RPCService& rpc_service, - HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handle) + const VehicleInfoCommandParams& params) : RequestToHMI(message, - application_manager, - rpc_service, - hmi_capabilities, - policy_handle) {} + params.application_manager_, + params.rpc_service_, + params.hmi_capabilities_, + params.policy_handler_) {} VIGetVehicleTypeRequest::~VIGetVehicleTypeRequest() {} @@ -59,4 +56,4 @@ void VIGetVehicleTypeRequest::Run() { } // namespace commands -} // namespace application_manager +} // namespace vehicle_info_plugin diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/vi_get_vehicle_type_response.cc b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/vi_get_vehicle_type_response.cc index 9f14b4e7eaa..fb6eadf747c 100644 --- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/vi_get_vehicle_type_response.cc +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/vi_get_vehicle_type_response.cc @@ -38,15 +38,12 @@ namespace commands { VIGetVehicleTypeResponse::VIGetVehicleTypeResponse( const application_manager::commands::MessageSharedPtr& message, - ApplicationManager& application_manager, - rpc_service::RPCService& rpc_service, - HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handle) + const VehicleInfoCommandParams& params) : ResponseFromHMI(message, - application_manager, - rpc_service, - hmi_capabilities, - policy_handle) {} + params.application_manager_, + params.rpc_service_, + params.hmi_capabilities_, + params.policy_handler_) {} VIGetVehicleTypeResponse::~VIGetVehicleTypeResponse() {} @@ -61,4 +58,4 @@ void VIGetVehicleTypeResponse::Run() { } // namespace commands -} // namespace application_manager +} // namespace vehicle_info_plugin diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/vi_is_ready_request.cc b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/vi_is_ready_request.cc index 04bcc435bad..93781a7420c 100644 --- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/vi_is_ready_request.cc +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/vi_is_ready_request.cc @@ -31,8 +31,9 @@ */ #include "vehicle_info_plugin/commands/hmi/vi_is_ready_request.h" -#include "application_manager/rpc_service.h" #include "application_manager/message_helper.h" +#include "application_manager/policies/policy_handler_interface.h" +#include "application_manager/rpc_service.h" namespace vehicle_info_plugin { using namespace application_manager; @@ -41,16 +42,13 @@ namespace commands { VIIsReadyRequest::VIIsReadyRequest( const application_manager::commands::MessageSharedPtr& message, - ApplicationManager& application_manager, - rpc_service::RPCService& rpc_service, - HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handle) + const VehicleInfoCommandParams& params) : RequestToHMI(message, - application_manager, - rpc_service, - hmi_capabilities, - policy_handle) - , EventObserver(application_manager.event_dispatcher()) {} + params.application_manager_, + params.rpc_service_, + params.hmi_capabilities_, + params.policy_handler_) + , EventObserver(application_manager_.event_dispatcher()) {} VIIsReadyRequest::~VIIsReadyRequest() {} @@ -109,4 +107,4 @@ void VIIsReadyRequest::SendMessageToHMI() { } // namespace commands -} // namespace application_manager +} // namespace vehicle_info_plugin diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/vi_is_ready_response.cc b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/vi_is_ready_response.cc index 35907e11d28..349a1137ce1 100644 --- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/vi_is_ready_response.cc +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/vi_is_ready_response.cc @@ -38,15 +38,12 @@ namespace commands { VIIsReadyResponse::VIIsReadyResponse( const application_manager::commands::MessageSharedPtr& message, - ApplicationManager& application_manager, - rpc_service::RPCService& rpc_service, - HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handle) + const VehicleInfoCommandParams& params) : ResponseFromHMI(message, - application_manager, - rpc_service, - hmi_capabilities, - policy_handle) {} + params.application_manager_, + params.rpc_service_, + params.hmi_capabilities_, + params.policy_handler_) {} VIIsReadyResponse::~VIIsReadyResponse() {} @@ -59,4 +56,4 @@ void VIIsReadyResponse::Run() { } // namespace commands -} // namespace application_manager +} // namespace vehicle_info_plugin diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/vi_read_did_request.cc b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/vi_read_did_request.cc index b55c9e32a0c..47373bb4bfe 100644 --- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/vi_read_did_request.cc +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/vi_read_did_request.cc @@ -39,15 +39,12 @@ namespace commands { VIReadDIDRequest::VIReadDIDRequest( const application_manager::commands::MessageSharedPtr& message, - ApplicationManager& application_manager, - rpc_service::RPCService& rpc_service, - HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handle) + const VehicleInfoCommandParams& params) : RequestToHMI(message, - application_manager, - rpc_service, - hmi_capabilities, - policy_handle) {} + params.application_manager_, + params.rpc_service_, + params.hmi_capabilities_, + params.policy_handler_) {} VIReadDIDRequest::~VIReadDIDRequest() {} @@ -59,4 +56,4 @@ void VIReadDIDRequest::Run() { } // namespace commands -} // namespace application_manager +} // namespace vehicle_info_plugin diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/vi_read_did_response.cc b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/vi_read_did_response.cc index 9d56b2aa78b..7c2db1e8755 100644 --- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/vi_read_did_response.cc +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/vi_read_did_response.cc @@ -39,15 +39,12 @@ namespace commands { VIReadDIDResponse::VIReadDIDResponse( const application_manager::commands::MessageSharedPtr& message, - ApplicationManager& application_manager, - rpc_service::RPCService& rpc_service, - HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handle) + const VehicleInfoCommandParams& params) : ResponseFromHMI(message, - application_manager, - rpc_service, - hmi_capabilities, - policy_handle) {} + params.application_manager_, + params.rpc_service_, + params.hmi_capabilities_, + params.policy_handler_) {} VIReadDIDResponse::~VIReadDIDResponse() {} @@ -61,4 +58,4 @@ void VIReadDIDResponse::Run() { } // namespace commands -} // namespace application_manager +} // namespace vehicle_info_plugin diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/vi_subscribe_vehicle_data_request.cc b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/vi_subscribe_vehicle_data_request.cc index 60e9dc88c36..4c5f067d0de 100644 --- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/vi_subscribe_vehicle_data_request.cc +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/vi_subscribe_vehicle_data_request.cc @@ -31,6 +31,7 @@ */ #include "vehicle_info_plugin/commands/hmi/vi_subscribe_vehicle_data_request.h" +#include "application_manager/message_helper.h" namespace vehicle_info_plugin { using namespace application_manager; @@ -39,24 +40,39 @@ namespace commands { VISubscribeVehicleDataRequest::VISubscribeVehicleDataRequest( const application_manager::commands::MessageSharedPtr& message, - ApplicationManager& application_manager, - rpc_service::RPCService& rpc_service, - HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handle) + const VehicleInfoCommandParams& params) : RequestToHMI(message, - application_manager, - rpc_service, - hmi_capabilities, - policy_handle) {} + params.application_manager_, + params.rpc_service_, + params.hmi_capabilities_, + params.policy_handler_) + , custom_vehicle_data_manager_(params.custom_vehicle_data_manager_) {} VISubscribeVehicleDataRequest::~VISubscribeVehicleDataRequest() {} void VISubscribeVehicleDataRequest::Run() { LOG4CXX_AUTO_TRACE(logger_); + const auto& rpc_spec_vehicle_data = MessageHelper::vehicle_data(); + auto& msg_params = (*message_)[strings::msg_params]; + + smart_objects::SmartObject custom_data; + for (const auto& name : msg_params.enumerate()) { + const auto& found_it = rpc_spec_vehicle_data.find(name); + if (rpc_spec_vehicle_data.end() == found_it) { + custom_data[name] = msg_params[name]; + msg_params.erase(name); + } + } + + auto hmi_custom_msg_params = + custom_vehicle_data_manager_.CreateHMIMessageParams( + custom_data.enumerate()); + for (const auto& item : hmi_custom_msg_params.enumerate()) { + msg_params[item] = hmi_custom_msg_params[item]; + } SendRequest(); } } // namespace commands - -} // namespace application_manager +} // namespace vehicle_info_plugin diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/vi_subscribe_vehicle_data_response.cc b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/vi_subscribe_vehicle_data_response.cc index f004d6f3cdd..061e13c766c 100644 --- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/vi_subscribe_vehicle_data_response.cc +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/vi_subscribe_vehicle_data_response.cc @@ -39,15 +39,12 @@ namespace commands { VISubscribeVehicleDataResponse::VISubscribeVehicleDataResponse( const application_manager::commands::MessageSharedPtr& message, - ApplicationManager& application_manager, - rpc_service::RPCService& rpc_service, - HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handle) + const VehicleInfoCommandParams& params) : ResponseFromHMI(message, - application_manager, - rpc_service, - hmi_capabilities, - policy_handle) {} + params.application_manager_, + params.rpc_service_, + params.hmi_capabilities_, + params.policy_handler_) {} VISubscribeVehicleDataResponse::~VISubscribeVehicleDataResponse() {} @@ -60,4 +57,4 @@ void VISubscribeVehicleDataResponse::Run() { } } // namespace commands -} // namespace application_manager +} // namespace vehicle_info_plugin diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/vi_unsubscribe_vehicle_data_request.cc b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/vi_unsubscribe_vehicle_data_request.cc index 9056538514e..aa24ac7375a 100644 --- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/vi_unsubscribe_vehicle_data_request.cc +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/vi_unsubscribe_vehicle_data_request.cc @@ -31,6 +31,7 @@ */ #include "vehicle_info_plugin/commands/hmi/vi_unsubscribe_vehicle_data_request.h" +#include "application_manager/message_helper.h" namespace vehicle_info_plugin { using namespace application_manager; @@ -39,24 +40,39 @@ namespace commands { VIUnsubscribeVehicleDataRequest::VIUnsubscribeVehicleDataRequest( const application_manager::commands::MessageSharedPtr& message, - ApplicationManager& application_manager, - rpc_service::RPCService& rpc_service, - HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handle) + const VehicleInfoCommandParams& params) : RequestToHMI(message, - application_manager, - rpc_service, - hmi_capabilities, - policy_handle) {} + params.application_manager_, + params.rpc_service_, + params.hmi_capabilities_, + params.policy_handler_) + , custom_vehicle_data_manager_(params.custom_vehicle_data_manager_) {} VIUnsubscribeVehicleDataRequest::~VIUnsubscribeVehicleDataRequest() {} void VIUnsubscribeVehicleDataRequest::Run() { LOG4CXX_AUTO_TRACE(logger_); + const auto& rpc_spec_vehicle_data = MessageHelper::vehicle_data(); + auto& msg_params = (*message_)[strings::msg_params]; + + smart_objects::SmartObject custom_data; + for (const auto& name : msg_params.enumerate()) { + const auto& found_it = rpc_spec_vehicle_data.find(name); + if (rpc_spec_vehicle_data.end() == found_it) { + custom_data[name] = msg_params[name]; + msg_params.erase(name); + } + } + + auto hmi_custom_msg_params = + custom_vehicle_data_manager_.CreateHMIMessageParams( + custom_data.enumerate()); + for (const auto& param : hmi_custom_msg_params.enumerate()) { + msg_params[param] = true; + } SendRequest(); } } // namespace commands - -} // namespace application_manager +} // namespace vehicle_info_plugin diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/vi_unsubscribe_vehicle_data_response.cc b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/vi_unsubscribe_vehicle_data_response.cc index 348bc1b2693..01fc521b10b 100644 --- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/vi_unsubscribe_vehicle_data_response.cc +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/vi_unsubscribe_vehicle_data_response.cc @@ -39,15 +39,12 @@ namespace commands { VIUnsubscribeVehicleDataResponse::VIUnsubscribeVehicleDataResponse( const application_manager::commands::MessageSharedPtr& message, - ApplicationManager& application_manager, - rpc_service::RPCService& rpc_service, - HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handle) + const VehicleInfoCommandParams& params) : ResponseFromHMI(message, - application_manager, - rpc_service, - hmi_capabilities, - policy_handle) {} + params.application_manager_, + params.rpc_service_, + params.hmi_capabilities_, + params.policy_handler_) {} VIUnsubscribeVehicleDataResponse::~VIUnsubscribeVehicleDataResponse() {} @@ -60,4 +57,4 @@ void VIUnsubscribeVehicleDataResponse::Run() { } } // namespace commands -} // namespace application_manager +} // namespace vehicle_info_plugin diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/diagnostic_message_request.cc b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/diagnostic_message_request.cc index 4eba8940252..ef6c284faf6 100644 --- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/diagnostic_message_request.cc +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/diagnostic_message_request.cc @@ -31,13 +31,13 @@ POSSIBILITY OF SUCH DAMAGE. */ -#include #include "vehicle_info_plugin/commands/mobile/diagnostic_message_request.h" +#include #include "application_manager/application_impl.h" -#include "interfaces/HMI_API.h" #include "application_manager/message_helper.h" +#include "interfaces/HMI_API.h" namespace vehicle_info_plugin { using namespace application_manager; @@ -46,15 +46,12 @@ namespace commands { DiagnosticMessageRequest::DiagnosticMessageRequest( const application_manager::commands::MessageSharedPtr& message, - ApplicationManager& application_manager, - rpc_service::RPCService& rpc_service, - HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handler) + const VehicleInfoCommandParams& params) : CommandRequestImpl(message, - application_manager, - rpc_service, - hmi_capabilities, - policy_handler) {} + params.application_manager_, + params.rpc_service_, + params.hmi_capabilities_, + params.policy_handler_) {} DiagnosticMessageRequest::~DiagnosticMessageRequest() {} @@ -127,4 +124,4 @@ void DiagnosticMessageRequest::on_event(const event_engine::Event& event) { } // namespace commands -} // namespace application_manager +} // namespace vehicle_info_plugin diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/diagnostic_message_response.cc b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/diagnostic_message_response.cc index 54d8382f5d6..f5ccc4d0a74 100644 --- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/diagnostic_message_response.cc +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/diagnostic_message_response.cc @@ -41,15 +41,12 @@ namespace commands { DiagnosticMessageResponse::DiagnosticMessageResponse( const application_manager::commands::MessageSharedPtr& message, - ApplicationManager& application_manager, - rpc_service::RPCService& rpc_service, - HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handler) + const VehicleInfoCommandParams& params) : CommandResponseImpl(message, - application_manager, - rpc_service, - hmi_capabilities, - policy_handler) {} + params.application_manager_, + params.rpc_service_, + params.hmi_capabilities_, + params.policy_handler_) {} DiagnosticMessageResponse::~DiagnosticMessageResponse() {} @@ -61,4 +58,4 @@ void DiagnosticMessageResponse::Run() { } // namespace commands -} // namespace application_manager +} // namespace vehicle_info_plugin diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/get_dtcs_request.cc b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/get_dtcs_request.cc index 6c04e874e88..dfa1cf305bc 100644 --- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/get_dtcs_request.cc +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/get_dtcs_request.cc @@ -34,8 +34,8 @@ #include "vehicle_info_plugin/commands/mobile/get_dtcs_request.h" #include "application_manager/application_impl.h" -#include "interfaces/HMI_API.h" #include "application_manager/message_helper.h" +#include "interfaces/HMI_API.h" namespace vehicle_info_plugin { using namespace application_manager; @@ -44,15 +44,12 @@ namespace commands { GetDTCsRequest::GetDTCsRequest( const application_manager::commands::MessageSharedPtr& message, - ApplicationManager& application_manager, - rpc_service::RPCService& rpc_service, - HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handler) + const VehicleInfoCommandParams& params) : CommandRequestImpl(message, - application_manager, - rpc_service, - hmi_capabilities, - policy_handler) {} + params.application_manager_, + params.rpc_service_, + params.hmi_capabilities_, + params.policy_handler_) {} GetDTCsRequest::~GetDTCsRequest() {} @@ -116,4 +113,4 @@ void GetDTCsRequest::on_event(const event_engine::Event& event) { } // namespace commands -} // namespace application_manager +} // namespace vehicle_info_plugin diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/get_dtcs_response.cc b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/get_dtcs_response.cc index 3686094b73f..33945a2f006 100644 --- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/get_dtcs_response.cc +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/get_dtcs_response.cc @@ -41,15 +41,12 @@ namespace commands { GetDTCsResponse::GetDTCsResponse( const application_manager::commands::MessageSharedPtr& message, - ApplicationManager& application_manager, - rpc_service::RPCService& rpc_service, - HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handler) + const VehicleInfoCommandParams& params) : CommandResponseImpl(message, - application_manager, - rpc_service, - hmi_capabilities, - policy_handler) {} + params.application_manager_, + params.rpc_service_, + params.hmi_capabilities_, + params.policy_handler_) {} GetDTCsResponse::~GetDTCsResponse() {} @@ -61,4 +58,4 @@ void GetDTCsResponse::Run() { } // namespace commands -} // namespace application_manager +} // namespace vehicle_info_plugin diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/get_vehicle_data_request.cc b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/get_vehicle_data_request.cc index 87a9ace377c..d15cf6a5801 100644 --- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/get_vehicle_data_request.cc +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/get_vehicle_data_request.cc @@ -31,13 +31,16 @@ POSSIBILITY OF SUCH DAMAGE. */ -#include #include "vehicle_info_plugin/commands/mobile/get_vehicle_data_request.h" +#include "vehicle_info_plugin/custom_vehicle_data_manager.h" + +#include #include "application_manager/application_impl.h" #include "application_manager/message_helper.h" -#include "interfaces/MOBILE_API.h" #include "interfaces/HMI_API.h" +#include "interfaces/MOBILE_API.h" +#include "policy/policy_table/types.h" namespace vehicle_info_plugin { using namespace application_manager; @@ -48,55 +51,57 @@ namespace str = strings; GetVehicleDataRequest::GetVehicleDataRequest( const application_manager::commands::MessageSharedPtr& message, - ApplicationManager& application_manager, - rpc_service::RPCService& rpc_service, - HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handler) + const VehicleInfoCommandParams& params) : CommandRequestImpl(message, - application_manager, - rpc_service, - hmi_capabilities, - policy_handler) {} + params.application_manager_, + params.rpc_service_, + params.hmi_capabilities_, + params.policy_handler_) + , custom_vehicle_data_manager_(params.custom_vehicle_data_manager_) {} GetVehicleDataRequest::~GetVehicleDataRequest() {} void GetVehicleDataRequest::Run() { LOG4CXX_AUTO_TRACE(logger_); - int32_t app_id = - (*message_)[strings::params][strings::connection_key].asUInt(); - ApplicationSharedPtr app = application_manager_.application(app_id); + auto app = application_manager_.application(connection_key()); if (!app) { - LOG4CXX_ERROR(logger_, "NULL pointer"); + LOG4CXX_ERROR(logger_, "No such application : " << connection_key()); SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED); return; } - if (app->AreCommandLimitsExceeded( - static_cast(function_id()), - application_manager::TLimitSource::CONFIG_FILE)) { - LOG4CXX_ERROR(logger_, "GetVehicleData frequency is too high."); + if (!CheckFrequency(*app)) { SendResponse(false, mobile_apis::Result::REJECTED); return; } - const VehicleData& vehicle_data = MessageHelper::vehicle_data(); - VehicleData::const_iterator it = vehicle_data.begin(); - smart_objects::SmartObject msg_params = + + auto hmi_msg_params = smart_objects::SmartObject(smart_objects::SmartType_Map); - msg_params[strings::app_id] = app->app_id(); - const uint32_t min_length_msg_params = 1; - for (; vehicle_data.end() != it; ++it) { - if (true == (*message_)[str::msg_params].keyExists(it->first) && - true == (*message_)[str::msg_params][it->first].asBool()) { - msg_params[it->first] = (*message_)[strings::msg_params][it->first]; + hmi_msg_params[strings::app_id] = app->app_id(); + + int params_count = 0; + auto& msg_params = (*message_)[strings::msg_params]; + for (const auto& name : msg_params.enumerate()) { + auto enabled = msg_params[name].asBool(); + if (!enabled) { + continue; } + hmi_msg_params[name] = msg_params[name]; + params_count++; } - if (msg_params.length() > min_length_msg_params) { + + const int minimal_params_count = 1; + + if (params_count >= minimal_params_count) { + for (const auto& param : msg_params.enumerate()) { + pending_vehicle_data_.insert(param); + } StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_VehicleInfo); - SendHMIRequest( - hmi_apis::FunctionID::VehicleInfo_GetVehicleData, &msg_params, true); - return; + SendHMIRequest(hmi_apis::FunctionID::VehicleInfo_GetVehicleData, + &hmi_msg_params, + true); } else if (HasDisallowedParams()) { SendResponse(false, mobile_apis::Result::DISALLOWED); } else { @@ -111,16 +116,31 @@ void GetVehicleDataRequest::on_event(const event_engine::Event& event) { switch (event.id()) { case hmi_apis::FunctionID::VehicleInfo_GetVehicleData: { EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_VehicleInfo); - hmi_apis::Common_Result::eType result_code = - static_cast( - message[strings::params][hmi_response::code].asInt()); + auto result_code = static_cast( + message[strings::params][hmi_response::code].asInt()); + auto mobile_result_code = GetMobileResultCode(result_code); bool result = PrepareResultForMobileResponse( result_code, HmiInterfaces::HMI_INTERFACE_VehicleInfo); std::string response_info; GetInfo(message, response_info); - result = result || - ((hmi_apis::Common_Result::DATA_NOT_AVAILABLE == result_code) && - (message[strings::msg_params].length() > 1)); + + auto data_not_available_with_params = [this, &result_code, &message]() { + if (hmi_apis::Common_Result::DATA_NOT_AVAILABLE != result_code) { + return false; + } + + const auto& vehicle_data = MessageHelper::vehicle_data(); + const auto& msg_params = message[strings::msg_params]; + for (const auto& item : msg_params.enumerate()) { + if (vehicle_data.end() != vehicle_data.find(item) || + custom_vehicle_data_manager_.IsValidCustomVehicleDataName(item)) { + return true; + } + } + return false; + }; + + result = result || data_not_available_with_params(); if (true == message[strings::msg_params].keyExists(hmi_response::method)) { @@ -129,8 +149,30 @@ void GetVehicleDataRequest::on_event(const event_engine::Event& event) { if (true == message[strings::params].keyExists(strings::error_msg)) { response_info = message[strings::params][strings::error_msg].asString(); } + + custom_vehicle_data_manager_.CreateMobileMessageParams( + const_cast( + message[strings::msg_params])); + + if (result) { + for (const auto& item : message[strings::msg_params].enumerate()) { + const auto& found_item = pending_vehicle_data_.find(item); + if (pending_vehicle_data_.end() == found_item) { + message[strings::msg_params].erase(item); + } + } + + if (message[strings::msg_params].empty() && + hmi_apis::Common_Result::DATA_NOT_AVAILABLE != result_code) { + response_info = "Failed to retrieve data from vehicle"; + SendResponse( + false, mobile_apis::Result::GENERIC_ERROR, response_info.c_str()); + return; + } + } + SendResponse(result, - MessageHelper::HMIToMobileResult(result_code), + mobile_result_code, response_info.empty() ? NULL : response_info.c_str(), &(message[strings::msg_params])); break; @@ -142,6 +184,15 @@ void GetVehicleDataRequest::on_event(const event_engine::Event& event) { } } -} // namespace commands +bool GetVehicleDataRequest::CheckFrequency(Application& app) { + if (app.AreCommandLimitsExceeded( + static_cast(function_id()), + application_manager::TLimitSource::CONFIG_FILE)) { + LOG4CXX_ERROR(logger_, "GetVehicleData frequency is too high."); + return false; + } + return true; +} -} // namespace application_manager +} // namespace commands +} // namespace vehicle_info_plugin diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/get_vehicle_data_response.cc b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/get_vehicle_data_response.cc index 3a7d6637562..60a44745a52 100644 --- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/get_vehicle_data_response.cc +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/get_vehicle_data_response.cc @@ -42,15 +42,12 @@ namespace commands { GetVehicleDataResponse::GetVehicleDataResponse( const application_manager::commands::MessageSharedPtr& message, - ApplicationManager& application_manager, - rpc_service::RPCService& rpc_service, - HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handler) + const VehicleInfoCommandParams& params) : CommandResponseImpl(message, - application_manager, - rpc_service, - hmi_capabilities, - policy_handler) {} + params.application_manager_, + params.rpc_service_, + params.hmi_capabilities_, + params.policy_handler_) {} GetVehicleDataResponse::~GetVehicleDataResponse() {} @@ -62,4 +59,4 @@ void GetVehicleDataResponse::Run() { } // namespace commands -} // namespace application_manager +} // namespace vehicle_info_plugin diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/on_vehicle_data_notification.cc b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/on_vehicle_data_notification.cc index f8553c84f86..79134cae402 100644 --- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/on_vehicle_data_notification.cc +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/on_vehicle_data_notification.cc @@ -34,11 +34,11 @@ #include "vehicle_info_plugin/commands/mobile/on_vehicle_data_notification.h" #include "application_manager/application_impl.h" +#include "application_manager/helpers/application_helper.h" #include "application_manager/message_helper.h" #include "interfaces/MOBILE_API.h" -#include "vehicle_info_plugin/vehicle_info_app_extension.h" -#include "application_manager/helpers/application_helper.h" #include "utils/macro.h" +#include "vehicle_info_plugin/vehicle_info_app_extension.h" namespace vehicle_info_plugin { using namespace application_manager; @@ -47,90 +47,74 @@ namespace commands { OnVehicleDataNotification::OnVehicleDataNotification( const application_manager::commands::MessageSharedPtr& message, - ApplicationManager& application_manager, - app_mngr::rpc_service::RPCService& rpc_service, - app_mngr::HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handler) + const VehicleInfoCommandParams& params) : CommandNotificationImpl(message, - application_manager, - rpc_service, - hmi_capabilities, - policy_handler) {} + params.application_manager_, + params.rpc_service_, + params.hmi_capabilities_, + params.policy_handler_) + , custom_vehicle_data_manager_(params.custom_vehicle_data_manager_) {} OnVehicleDataNotification::~OnVehicleDataNotification() {} void OnVehicleDataNotification::Run() { LOG4CXX_AUTO_TRACE(logger_); - std::vector appNotification; - std::vector::iterator appNotification_it = - appNotification.begin(); + std::vector notify_apps; + std::vector::iterator notified_app_it = + notify_apps.begin(); std::vector appSO; - const VehicleData& vehicle_data = MessageHelper::vehicle_data(); - VehicleData::const_iterator it = vehicle_data.begin(); - - for (; vehicle_data.end() != it; ++it) { - if (true == (*message_)[strings::msg_params].keyExists(it->first)) { - LOG4CXX_ERROR(logger_, "vehicle_data nanme" << it->first); - auto vehicle_data_value = - (*message_)[strings::msg_params][it->first].asInt(); - - application_manager_.IviInfoUpdated(it->second, vehicle_data_value); - - auto subscribed_to_ivi_predicate = [&it](const ApplicationSharedPtr app) { - DCHECK_OR_RETURN(app, false); - auto& ext = VehicleInfoAppExtension::ExtractVIExtension(*app); - return ext.isSubscribedToVehicleInfo(it->second); - }; - - const std::vector& applications = - application_manager::FindAllApps(application_manager_.applications(), - subscribed_to_ivi_predicate); - - std::vector::const_iterator app_it = - applications.begin(); - - for (; applications.end() != app_it; ++app_it) { - const ApplicationSharedPtr app = *app_it; - if (!app) { - LOG4CXX_ERROR(logger_, "NULL pointer"); - continue; - } - - appNotification_it = - find(appNotification.begin(), appNotification.end(), app); - if (appNotification_it == appNotification.end()) { - appNotification.push_back(app); - smart_objects::SmartObject msg_param = - smart_objects::SmartObject(smart_objects::SmartType_Map); - msg_param[it->first] = (*message_)[strings::msg_params][it->first]; - appSO.push_back(msg_param); - } else { - size_t idx = - std::distance(appNotification.begin(), appNotification_it); - appSO[idx][it->first] = (*message_)[strings::msg_params][it->first]; - } + custom_vehicle_data_manager_.CreateMobileMessageParams( + (*message_)[strings::msg_params]); + + const auto& param_names = (*message_)[strings::msg_params].enumerate(); + for (const auto& name : param_names) { + LOG4CXX_DEBUG(logger_, "vehicle_data name: " << name); + auto vehicle_data_value = (*message_)[strings::msg_params][name].asInt(); + application_manager_.IviInfoUpdated(name, vehicle_data_value); + + auto subscribed_to_ivi_predicate = [&name](const ApplicationSharedPtr app) { + DCHECK_OR_RETURN(app, false); + auto& ext = VehicleInfoAppExtension::ExtractVIExtension(*app); + return ext.isSubscribedToVehicleInfo(name); + }; + + const auto& applications = application_manager::FindAllApps( + application_manager_.applications(), subscribed_to_ivi_predicate); + for (const auto& app : applications) { + if (!app) { + LOG4CXX_ERROR(logger_, "NULL pointer"); + continue; + } + notified_app_it = find(notify_apps.begin(), notify_apps.end(), app); + if (notified_app_it == notify_apps.end()) { + notify_apps.push_back(app); + smart_objects::SmartObject msg_param = + smart_objects::SmartObject(smart_objects::SmartType_Map); + msg_param[name] = (*message_)[strings::msg_params][name]; + appSO.push_back(msg_param); + } else { + size_t idx = std::distance(notify_apps.begin(), notified_app_it); + appSO[idx][name] = (*message_)[strings::msg_params][name]; } } } - LOG4CXX_DEBUG( - logger_, - "Number of Notifications to be send: " << appNotification.size()); + LOG4CXX_DEBUG(logger_, + "Number of Notifications to be send: " << notify_apps.size()); - for (size_t idx = 0; idx < appNotification.size(); idx++) { + for (size_t idx = 0; idx < notify_apps.size(); idx++) { LOG4CXX_INFO(logger_, "Send OnVehicleData PRNDL notification to " - << appNotification[idx]->name().c_str() - << " application id " << appNotification[idx]->app_id()); + << notify_apps[idx]->name().c_str() << " application id " + << notify_apps[idx]->app_id()); (*message_)[strings::params][strings::connection_key] = - appNotification[idx]->app_id(); + notify_apps[idx]->app_id(); (*message_)[strings::msg_params] = appSO[idx]; SendNotification(); } } } // namespace commands - -} // namespace application_manager +} // namespace vehicle_info_plugin diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/read_did_request.cc b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/read_did_request.cc index 010cce4c634..c090df78520 100644 --- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/read_did_request.cc +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/read_did_request.cc @@ -30,13 +30,13 @@ POSSIBILITY OF SUCH DAMAGE. */ -#include #include "vehicle_info_plugin/commands/mobile/read_did_request.h" +#include #include "application_manager/application_impl.h" -#include "interfaces/MOBILE_API.h" -#include "interfaces/HMI_API.h" #include "application_manager/message_helper.h" +#include "interfaces/HMI_API.h" +#include "interfaces/MOBILE_API.h" namespace vehicle_info_plugin { using namespace application_manager; @@ -45,15 +45,12 @@ namespace commands { ReadDIDRequest::ReadDIDRequest( const application_manager::commands::MessageSharedPtr& message, - ApplicationManager& application_manager, - app_mngr::rpc_service::RPCService& rpc_service, - app_mngr::HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handler) + const VehicleInfoCommandParams& params) : CommandRequestImpl(message, - application_manager, - rpc_service, - hmi_capabilities, - policy_handler) {} + params.application_manager_, + params.rpc_service_, + params.hmi_capabilities_, + params.policy_handler_) {} ReadDIDRequest::~ReadDIDRequest() {} @@ -131,4 +128,4 @@ void ReadDIDRequest::on_event(const event_engine::Event& event) { } // namespace commands -} // namespace application_manager +} // namespace vehicle_info_plugin diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/read_did_response.cc b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/read_did_response.cc index 82d49574f0e..42e7fc1ba9d 100644 --- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/read_did_response.cc +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/read_did_response.cc @@ -41,15 +41,12 @@ namespace commands { ReadDIDResponse::ReadDIDResponse( const application_manager::commands::MessageSharedPtr& message, - ApplicationManager& application_manager, - app_mngr::rpc_service::RPCService& rpc_service, - app_mngr::HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handler) + const VehicleInfoCommandParams& params) : CommandResponseImpl(message, - application_manager, - rpc_service, - hmi_capabilities, - policy_handler) {} + params.application_manager_, + params.rpc_service_, + params.hmi_capabilities_, + params.policy_handler_) {} ReadDIDResponse::~ReadDIDResponse() {} @@ -61,4 +58,4 @@ void ReadDIDResponse::Run() { } // namespace commands -} // namespace application_manager +} // namespace vehicle_info_plugin 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 65f4fde0b25..b125a7de7da 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 @@ -29,8 +29,10 @@ #include "vehicle_info_plugin/commands/mobile/subscribe_vehicle_data_request.h" +#include #include "application_manager/application_impl.h" #include "application_manager/message_helper.h" +#include "smart_objects/enum_schema_item.h" #include "utils/helpers.h" #include "vehicle_info_plugin/vehicle_info_app_extension.h" @@ -40,15 +42,13 @@ namespace commands { SubscribeVehicleDataRequest::SubscribeVehicleDataRequest( const application_manager::commands::MessageSharedPtr& message, - ApplicationManager& application_manager, - app_mngr::rpc_service::RPCService& rpc_service, - app_mngr::HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handler) + VehicleInfoCommandParams params) : CommandRequestImpl(message, - application_manager, - rpc_service, - hmi_capabilities, - policy_handler) {} + params.application_manager_, + params.rpc_service_, + params.hmi_capabilities_, + params.policy_handler_) + , custom_vehicle_data_manager_(params.custom_vehicle_data_manager_) {} SubscribeVehicleDataRequest::~SubscribeVehicleDataRequest() {} @@ -73,6 +73,7 @@ void SubscribeVehicleDataRequest::Run() { app, info, result_code, response_params, msg_params, result); if (mobile_apis::Result::INVALID_ENUM != result_code) { + AppendDataTypesToMobileResponse(response_params); SendResponse(result, result_code, info.empty() ? NULL : info.c_str(), @@ -118,35 +119,103 @@ void SubscribeVehicleDataRequest::on_event(const event_engine::Event& event) { mobile_apis::Result::eType result_code = MessageHelper::HMIToMobileResult(hmi_result); + smart_objects::SmartObject converted_msg_params(message[strings::msg_params]); + custom_vehicle_data_manager_.CreateMobileMessageParams(converted_msg_params); + if (is_succeeded) { if (!vi_already_subscribed_by_this_app_.empty()) { result_code = mobile_apis::Result::IGNORED; response_info = "Already subscribed on some provided VehicleData."; } - if (!vi_waiting_for_subscribe_.empty()) { - LOG4CXX_DEBUG(logger_, "Subscribing to all pending VehicleData"); - VehicleInfoSubscriptions::const_iterator key = - vi_waiting_for_subscribe_.begin(); - for (; key != vi_waiting_for_subscribe_.end(); ++key) { - auto& ext = VehicleInfoAppExtension::ExtractVIExtension(*app); - ext.subscribeToVehicleInfo(*key); + for (const auto& param : converted_msg_params.enumerate()) { + const auto& converted_name = ConvertResponseToRequestName(param); + if (vi_waiting_for_subscribe_.end() == + vi_waiting_for_subscribe_.find(converted_name)) { + LOG4CXX_DEBUG(logger_, "erase " << converted_name); + converted_msg_params.erase(param); } } - } - UnsubscribeFailedSubscriptions(app, message[strings::msg_params]); + if (!SubscribePendingVehicleData(app, converted_msg_params)) { + result_code = mobile_apis::Result::GENERIC_ERROR; + response_info = "Subscription failed for some Vehicle data"; + SendResponse(false, result_code, response_info.c_str()); + return; + } + } if (!vi_already_subscribed_by_another_apps_.empty() || !vi_already_subscribed_by_this_app_.empty()) { - AddAlreadySubscribedVI( - const_cast(message[strings::msg_params])); + AddAlreadySubscribedVI(converted_msg_params); } + AppendDataTypesToMobileResponse(converted_msg_params); SendResponse(is_succeeded, result_code, response_info.empty() ? NULL : response_info.c_str(), - &(message[strings::msg_params])); + &converted_msg_params); +} + +void SubscribeVehicleDataRequest::AppendDataTypesToMobileResponse( + smart_objects::SmartObject& msg_params) const { + using namespace smart_objects; + + std::string oem_vehicle_data_type_str; + EnumConversionHelper::EnumToString( + VehicleDataType::VEHICLEDATA_OEM_CUSTOM_DATA, &oem_vehicle_data_type_str); + + const auto& rpc_spec_vehicle_data = MessageHelper::vehicle_data(); + for (const auto& item : msg_params.enumerate()) { + const auto& rpc_spec_vehicle_data_item = rpc_spec_vehicle_data.find(item); + if (rpc_spec_vehicle_data.end() == rpc_spec_vehicle_data_item) { + msg_params[item][strings::data_type] = oem_vehicle_data_type_str; + msg_params[item][strings::oem_custom_data_type] = + custom_vehicle_data_manager_.GetVehicleDataItemType(item); + } else { + msg_params[item][strings::data_type] = rpc_spec_vehicle_data_item->second; + } + } +} + +bool SubscribeVehicleDataRequest::CheckSubscriptionStatus( + std::string vi_name, const smart_objects::SmartObject& msg_params) { + const auto subscribed_items = msg_params.enumerate(); + if (subscribed_items.end() == subscribed_items.find(vi_name)) { + LOG4CXX_WARN(logger_, + vi_name << " is waiting to be subscribed, but missing in " + "vehicle response."); + return false; + } + + auto res_code = msg_params[vi_name][strings::result_code].asInt(); + if (hmi_apis::Common_VehicleDataResultCode::VDRC_SUCCESS != res_code && + hmi_apis::Common_VehicleDataResultCode::VDRC_DATA_ALREADY_SUBSCRIBED != + res_code) { + LOG4CXX_WARN(logger_, + "Subscription to " << vi_name << " for " << connection_key() + << " failed."); + return false; + } + return true; +} + +bool SubscribeVehicleDataRequest::SubscribePendingVehicleData( + ApplicationSharedPtr app, const smart_objects::SmartObject& msg_params) { + LOG4CXX_DEBUG(logger_, "Subscribing to all pending VehicleData"); + + for (const auto& vi_name : vi_waiting_for_subscribe_) { + const bool is_subscription_successful = CheckSubscriptionStatus( + ConvertRequestToResponseName(vi_name), msg_params); + + if (is_subscription_successful) { + auto& ext = VehicleInfoAppExtension::ExtractVIExtension(*app); + ext.subscribeToVehicleInfo(vi_name); + vi_waiting_for_subscribe_.erase(vi_name); + } + } + + return vi_waiting_for_subscribe_.empty(); } bool SubscribeVehicleDataRequest::Init() { @@ -158,76 +227,33 @@ void SubscribeVehicleDataRequest::AddAlreadySubscribedVI( smart_objects::SmartObject& msg_params) const { LOG4CXX_AUTO_TRACE(logger_); using namespace mobile_apis; - auto vi_to_string = - [](const mobile_apis::VehicleDataType::eType vehicle_data) { - for (auto& vi_str_to_int_pair : MessageHelper::vehicle_data()) { - if (vehicle_data == vi_str_to_int_pair.second) { - return vi_str_to_int_pair.first; - } - } - return std::string(); - }; - VehicleInfoSubscriptions::const_iterator it_same_app = - vi_already_subscribed_by_this_app_.begin(); - for (; vi_already_subscribed_by_this_app_.end() != it_same_app; - ++it_same_app) { - msg_params[vi_to_string(*it_same_app)][strings::result_code] = + for (const auto& item : vi_already_subscribed_by_this_app_) { + msg_params[item][strings::result_code] = VehicleDataResultCode::VDRC_DATA_ALREADY_SUBSCRIBED; - msg_params[vi_to_string(*it_same_app)][strings::data_type] = *it_same_app; } - VehicleInfoSubscriptions::const_iterator it_another_app = - vi_already_subscribed_by_another_apps_.begin(); - for (; vi_already_subscribed_by_another_apps_.end() != it_another_app; - ++it_another_app) { - msg_params[vi_to_string(*it_another_app)][strings::result_code] = + for (const auto& item : vi_already_subscribed_by_another_apps_) { + msg_params[item][strings::result_code] = VehicleDataResultCode::VDRC_SUCCESS; - msg_params[vi_to_string(*it_another_app)][strings::data_type] = - *it_another_app; - } -} - -void SubscribeVehicleDataRequest::UnsubscribeFailedSubscriptions( - ApplicationSharedPtr app, - const smart_objects::SmartObject& msg_params) const { - LOG4CXX_AUTO_TRACE(logger_); - const VehicleData& vehicle_data = MessageHelper::vehicle_data(); - VehicleData::const_iterator it = vehicle_data.begin(); - - for (; vehicle_data.end() != it; ++it) { - if (msg_params.keyExists(it->first)) { - if (msg_params[it->first][strings::result_code].asInt() != - hmi_apis::Common_VehicleDataResultCode::VDRC_SUCCESS) { - LOG4CXX_DEBUG(logger_, - "Subscription for VehicleDataType " - << it->first - << " is unsuccessfull. " - "Unsubscribing app with connection key " - << connection_key() << " from it."); - VehicleInfoAppExtension::ExtractVIExtension(*app) - .unsubscribeFromVehicleInfo(it->second); - } - } } } struct SubscribedToIVIPredicate { - int32_t vehicle_info_; - SubscribedToIVIPredicate(int32_t vehicle_info) + std::string vehicle_info_; + SubscribedToIVIPredicate(std::string vehicle_info) : vehicle_info_(vehicle_info) {} bool operator()(const ApplicationSharedPtr app) const { DCHECK_OR_RETURN(app, false); auto& ext = VehicleInfoAppExtension::ExtractVIExtension(*app); - return ext.isSubscribedToVehicleInfo( - static_cast(vehicle_info_)); + return ext.isSubscribedToVehicleInfo(vehicle_info_); } }; bool SubscribeVehicleDataRequest::IsSomeoneSubscribedFor( - const uint32_t param_id) const { + const std::string& param_name) const { LOG4CXX_AUTO_TRACE(logger_); - SubscribedToIVIPredicate finder(param_id); + SubscribedToIVIPredicate finder(param_name); DataAccessor accessor = application_manager_.applications(); ApplicationSetConstIt it = std::find_if( accessor.GetData().begin(), accessor.GetData().end(), finder); @@ -241,93 +267,101 @@ void SubscribeVehicleDataRequest::CheckVISubscriptions( smart_objects::SmartObject& out_response_params, smart_objects::SmartObject& out_request_params, bool& out_result) { - // counter for items to subscribe - VehicleInfoSubscriptions::size_type items_to_subscribe = 0; - // counter for subscribed items by application - uint32_t subscribed_items = 0; + const bool is_interface_not_available = + (HmiInterfaces::STATE_NOT_AVAILABLE == + application_manager_.hmi_interfaces().GetInterfaceState( + HmiInterfaces::HMI_INTERFACE_VehicleInfo)); + + VehicleInfoSubscriptions::size_type subscribed_items = 0; + + auto app_already_subscribed = + [this, &out_response_params]( + const std::string& key_name, + const mobile_apis::VehicleDataType::eType vd_type) { + LOG4CXX_DEBUG( + logger_, + "App with connection key " + << connection_key() + << " is subscribed already for VehicleData: " << key_name); + vi_already_subscribed_by_this_app_.insert(key_name); + out_response_params[key_name][strings::data_type] = vd_type; + out_response_params[key_name][strings::result_code] = + mobile_apis::VehicleDataResultCode::VDRC_DATA_ALREADY_SUBSCRIBED; + }; - const VehicleData& vehicle_data = MessageHelper::vehicle_data(); - VehicleData::const_iterator it = vehicle_data.begin(); + auto another_app_subscribed = + [this, &out_response_params, &subscribed_items]( + const std::string& key_name, + const mobile_apis::VehicleDataType::eType vd_type, + vehicle_info_plugin::VehicleInfoAppExtension& ext) { + LOG4CXX_DEBUG(logger_, + "There are apps subscribed already for " + "VehicleDataType: " + << key_name); + + if (!ext.subscribeToVehicleInfo(key_name)) { + LOG4CXX_ERROR( + logger_, "Unable to subscribe for VehicleDataType: " << key_name); + return; + } + LOG4CXX_DEBUG( + logger_, + "App with connection key " + << connection_key() + << " have been subscribed for VehicleDataType: " << key_name); + vi_already_subscribed_by_another_apps_.insert(key_name); + out_response_params[key_name][strings::data_type] = vd_type; + out_response_params[key_name][strings::result_code] = + mobile_apis::VehicleDataResultCode::VDRC_SUCCESS; + ++subscribed_items; + }; - HmiInterfaces::InterfaceState interface_state = - application_manager_.hmi_interfaces().GetInterfaceState( - HmiInterfaces::HMI_INTERFACE_VehicleInfo); + auto first_subscription = [this, &out_request_params, &subscribed_items]( + const std::string& vi_name) { + out_request_params[vi_name] = (*message_)[strings::msg_params][vi_name]; - const bool is_interface_not_available = - interface_state == HmiInterfaces::STATE_NOT_AVAILABLE; - - for (; vehicle_data.end() != it; ++it) { - const std::string& key_name = it->first; - if ((*message_)[strings::msg_params].keyExists(key_name)) { - const bool is_key_enabled = - (*message_)[strings::msg_params][key_name].asBool(); - if (is_key_enabled) { - ++items_to_subscribe; - } - if (!is_interface_not_available && is_key_enabled) { - mobile_apis::VehicleDataType::eType key_type = it->second; - const auto is_subscribed = - VehicleInfoAppExtension::ExtractVIExtension(*app) - .isSubscribedToVehicleInfo(key_type); - if (is_subscribed) { - LOG4CXX_DEBUG(logger_, - "App with connection key " - << connection_key() - << " is subscribed already for VehicleDataType: " - << key_type); - ++subscribed_items; - vi_already_subscribed_by_this_app_.insert(key_type); - out_response_params[key_name][strings::data_type] = key_type; - out_response_params[key_name][strings::result_code] = - mobile_apis::VehicleDataResultCode::VDRC_DATA_ALREADY_SUBSCRIBED; - continue; - } + vi_waiting_for_subscribe_.insert(vi_name); + LOG4CXX_DEBUG( + logger_, + "App with connection key " + << connection_key() + << " will be subscribed for VehicleDataType: " << vi_name); + ++subscribed_items; + return true; + }; - if (IsSomeoneSubscribedFor(key_type)) { - LOG4CXX_DEBUG(logger_, - "There are apps subscribed already for " - "VehicleDataType: " - << key_type); - auto& ext = VehicleInfoAppExtension::ExtractVIExtension(*app); - - if (!ext.subscribeToVehicleInfo(key_type)) { - LOG4CXX_ERROR( - logger_, - "Unable to subscribe for VehicleDataType: " << key_type); - continue; - } - LOG4CXX_DEBUG( - logger_, - "App with connection key " - << connection_key() - << " have been subscribed for VehicleDataType: " << key_type); - ++subscribed_items; - vi_already_subscribed_by_another_apps_.insert(key_type); - out_response_params[key_name][strings::data_type] = key_type; - out_response_params[key_name][strings::result_code] = - mobile_apis::VehicleDataResultCode::VDRC_SUCCESS; - continue; - } + auto rpc_spec_vehicle_data = MessageHelper::vehicle_data(); + auto& ext = VehicleInfoAppExtension::ExtractVIExtension(*app); - out_request_params[key_name] = is_key_enabled; + VehicleInfoSubscriptions::size_type items_to_subscribe = 0; + auto item_names = (*message_)[strings::msg_params].enumerate(); + if (!is_interface_not_available) { + for (const auto& name : item_names) { + auto enabled = (*message_)[strings::msg_params][name].asBool(); + if (!enabled) { + continue; + } - if (is_key_enabled) { - vi_waiting_for_subscribe_.insert(key_type); - LOG4CXX_DEBUG( - logger_, - "App with connection key " - << connection_key() - << " will be subscribed for VehicleDataType: " << key_type); - ++subscribed_items; - } + auto vehicle_data = rpc_spec_vehicle_data.find(name); + auto vehicle_data_type = + (vehicle_data == rpc_spec_vehicle_data.end()) + ? VehicleDataType::VEHICLEDATA_OEM_CUSTOM_DATA + : vehicle_data->second; + if (ext.isSubscribedToVehicleInfo(name)) { + app_already_subscribed(name, vehicle_data_type); + } else if (IsSomeoneSubscribedFor(name)) { + another_app_subscribed(name, vehicle_data_type, ext); + } else if (!first_subscription(name)) { + continue; } + + ++items_to_subscribe; } } const bool is_everything_already_subscribed = - items_to_subscribe == - vi_already_subscribed_by_another_apps_.size() + - vi_already_subscribed_by_this_app_.size(); + items_to_subscribe == vi_already_subscribed_by_another_apps_.size() + + vi_already_subscribed_by_this_app_.size(); if (0 == items_to_subscribe) { if (HasDisallowedParams()) { @@ -337,12 +371,14 @@ void SubscribeVehicleDataRequest::CheckVISubscriptions( out_info = "No data in the request"; } out_result = false; + return; } if (0 == subscribed_items && !is_interface_not_available) { out_result_code = mobile_apis::Result::IGNORED; out_info = "Already subscribed on provided VehicleData."; out_result = false; + return; } if (is_everything_already_subscribed) { @@ -353,8 +389,35 @@ void SubscribeVehicleDataRequest::CheckVISubscriptions( out_info = "Already subscribed on some provided VehicleData."; } out_result = true; + return; } } +const std::string& SubscribeVehicleDataRequest::ConvertResponseToRequestName( + const std::string& name) { + static std::map parameter_name_conversion_map = { + {strings::cluster_modes, strings::cluster_mode_status}}; + const auto converted_it = parameter_name_conversion_map.find(name); + auto result = parameter_name_conversion_map.end() == converted_it + ? name + : converted_it->second; + return parameter_name_conversion_map.end() == converted_it + ? name + : converted_it->second; +} + +const std::string& SubscribeVehicleDataRequest::ConvertRequestToResponseName( + const std::string& name) { + static std::map parameter_name_conversion_map = { + {strings::cluster_mode_status, strings::cluster_modes}}; + const auto converted_it = parameter_name_conversion_map.find(name); + auto result = parameter_name_conversion_map.end() == converted_it + ? name + : converted_it->second; + return parameter_name_conversion_map.end() == converted_it + ? name + : converted_it->second; +} + } // namespace commands -} // namespace application_manager +} // namespace vehicle_info_plugin diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/subscribe_vehicle_data_response.cc b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/subscribe_vehicle_data_response.cc index 2bea839320f..8330176af66 100644 --- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/subscribe_vehicle_data_response.cc +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/subscribe_vehicle_data_response.cc @@ -32,8 +32,8 @@ */ #include "vehicle_info_plugin/commands/mobile/subscribe_vehicle_data_response.h" -#include "application_manager/rpc_service.h" #include "application_manager/application_impl.h" +#include "application_manager/rpc_service.h" #include "interfaces/MOBILE_API.h" namespace vehicle_info_plugin { @@ -42,15 +42,12 @@ namespace commands { SubscribeVehicleDataResponse::SubscribeVehicleDataResponse( const application_manager::commands::MessageSharedPtr& message, - ApplicationManager& application_manager, - app_mngr::rpc_service::RPCService& rpc_service, - app_mngr::HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handler) + const VehicleInfoCommandParams& params) : CommandResponseImpl(message, - application_manager, - rpc_service, - hmi_capabilities, - policy_handler) {} + params.application_manager_, + params.rpc_service_, + params.hmi_capabilities_, + params.policy_handler_) {} SubscribeVehicleDataResponse::~SubscribeVehicleDataResponse() {} @@ -60,4 +57,4 @@ void SubscribeVehicleDataResponse::Run() { } } // namespace commands -} // namespace application_manager +} // namespace vehicle_info_plugin diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/unsubscribe_vehicle_data_request.cc b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/unsubscribe_vehicle_data_request.cc index d0152ea0c3a..32d63f0c357 100644 --- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/unsubscribe_vehicle_data_request.cc +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/unsubscribe_vehicle_data_request.cc @@ -36,9 +36,10 @@ #include "application_manager/application_impl.h" #include "application_manager/message_helper.h" -#include "interfaces/MOBILE_API.h" -#include "interfaces/HMI_API.h" #include "application_manager/smart_object_keys.h" +#include "interfaces/HMI_API.h" +#include "interfaces/MOBILE_API.h" +#include "smart_objects/enum_schema_item.h" #include "utils/helpers.h" #include "vehicle_info_plugin/vehicle_info_app_extension.h" @@ -48,15 +49,13 @@ namespace commands { UnsubscribeVehicleDataRequest::UnsubscribeVehicleDataRequest( const application_manager::commands::MessageSharedPtr& message, - ApplicationManager& application_manager, - app_mngr::rpc_service::RPCService& rpc_service, - app_mngr::HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handler) + const VehicleInfoCommandParams& params) : CommandRequestImpl(message, - application_manager, - rpc_service, - hmi_capabilities, - policy_handler) {} + params.application_manager_, + params.rpc_service_, + params.hmi_capabilities_, + params.policy_handler_) + , custom_vehicle_data_manager_(params.custom_vehicle_data_manager_) {} UnsubscribeVehicleDataRequest::~UnsubscribeVehicleDataRequest() {} @@ -74,67 +73,64 @@ void UnsubscribeVehicleDataRequest::Run() { int32_t items_to_unsubscribe = 0; int32_t unsubscribed_items = 0; - const VehicleData& vehicle_data = MessageHelper::vehicle_data(); - VehicleData::const_iterator it = vehicle_data.begin(); - smart_objects::SmartObject msg_params = smart_objects::SmartObject(smart_objects::SmartType_Map); - smart_objects::SmartObject response_params = - smart_objects::SmartObject(smart_objects::SmartType_Map); + response_params_ = smart_objects::SmartObject(smart_objects::SmartType_Map); + + auto rpc_spec_vehicle_data = MessageHelper::vehicle_data(); + std::set custom_vehicle_data; + + auto app_not_subscribed_response = [this](const std::string& key_name) { + LOG4CXX_DEBUG(logger_, + "App with connection key " + << connection_key() + << " is not subscribed for VehicleData: " << key_name); + vi_already_unsubscribed_by_this_app_.insert(key_name); + response_params_[key_name][strings::result_code] = + mobile_apis::VehicleDataResultCode::VDRC_DATA_NOT_SUBSCRIBED; + }; + + auto other_app_subscribed_response = [this](const std::string& key_name) { + LOG4CXX_DEBUG(logger_, + "There are apps still subscribed for " + "VehicleDataType: " + << key_name); + vi_still_subscribed_by_another_apps_.insert(key_name); + response_params_[key_name][strings::result_code] = + mobile_apis::VehicleDataResultCode::VDRC_SUCCESS; + }; + + auto& ext = VehicleInfoAppExtension::ExtractVIExtension(*app); + + const auto& param_names = (*message_)[strings::msg_params].enumerate(); + for (const auto& name : param_names) { + const bool enabled = (*message_)[strings::msg_params][name].asBool(); + if (!enabled) { + continue; + } - for (; vehicle_data.end() != it; ++it) { - const std::string& key_name = it->first; - if ((*message_)[strings::msg_params].keyExists(key_name)) { - bool is_key_enabled = (*message_)[strings::msg_params][key_name].asBool(); - if (is_key_enabled) { - ++items_to_unsubscribe; - - mobile_apis::VehicleDataType::eType key_type = it->second; - const auto is_subscribed = - VehicleInfoAppExtension::ExtractVIExtension(*app) - .isSubscribedToVehicleInfo(key_type); - if (!is_subscribed) { - ++unsubscribed_items; - vi_already_unsubscribed_by_this_app_.insert(key_type); - response_params[key_name][strings::data_type] = key_type; - response_params[key_name][strings::result_code] = - mobile_apis::VehicleDataResultCode::VDRC_DATA_NOT_SUBSCRIBED; - continue; - } - - if (!VehicleInfoAppExtension::ExtractVIExtension(*app) - .unsubscribeFromVehicleInfo(it->second)) { - LOG4CXX_ERROR(logger_, - "Unable to unsubscribe from " - "VehicleDataType: " - << key_type); - continue; - } - - LOG4CXX_DEBUG(logger_, - "Unsubscribed app with connection key " - << connection_key() - << " from VehicleDataType: " << key_type); - - ++unsubscribed_items; - - if (IsSomeoneSubscribedFor(key_type)) { - LOG4CXX_DEBUG(logger_, - "There are another apps still subscribed for " - "VehicleDataType: " - << key_type); - - vi_still_subscribed_by_another_apps_.insert(key_type); - response_params[key_name][strings::data_type] = key_type; - response_params[key_name][strings::result_code] = - mobile_apis::VehicleDataResultCode::VDRC_SUCCESS; - continue; - } - - msg_params[key_name] = is_key_enabled; - } + ++items_to_unsubscribe; + + if (!(ext.isSubscribedToVehicleInfo(name))) { + app_not_subscribed_response(name); + continue; } + + LOG4CXX_DEBUG(logger_, + "Unsubscribed app with connection key " + << connection_key() << " from VehicleDataType: " << name); + + ++unsubscribed_items; + + if (IsSomeoneSubscribedFor(name)) { + other_app_subscribed_response(name); + ext.unsubscribeFromVehicleInfo(name); + continue; + } + + vi_waiting_for_unsubscribe_.insert(name); + msg_params[name] = true; } bool is_everything_already_unsubscribed = @@ -142,6 +138,8 @@ void UnsubscribeVehicleDataRequest::Run() { vi_still_subscribed_by_another_apps_.size() + vi_already_unsubscribed_by_this_app_.size(); + AppendDataTypesToMobileResponse(response_params_); + if (0 == items_to_unsubscribe) { if (HasDisallowedParams()) { SendResponse(false, mobile_apis::Result::DISALLOWED); @@ -156,7 +154,7 @@ void UnsubscribeVehicleDataRequest::Run() { SendResponse(false, mobile_apis::Result::IGNORED, "Was not subscribed on any VehicleData.", - &response_params); + &response_params_); return; } @@ -165,9 +163,9 @@ void UnsubscribeVehicleDataRequest::Run() { SendResponse(false, mobile_apis::Result::IGNORED, "Some provided VehicleData was not subscribed.", - &response_params); + &response_params_); } else { - SendResponse(true, mobile_apis::Result::SUCCESS, NULL, &response_params); + SendResponse(true, mobile_apis::Result::SUCCESS, NULL, &response_params_); } return; } @@ -203,36 +201,56 @@ void UnsubscribeVehicleDataRequest::on_event(const event_engine::Event& event) { message[strings::params][hmi_response::code].asInt()); std::string response_info; GetInfo(message, response_info); - const bool result = PrepareResultForMobileResponse( + bool result = PrepareResultForMobileResponse( hmi_result, HmiInterfaces::HMI_INTERFACE_VehicleInfo); + auto hmi_response_msg_params = message[strings::msg_params]; + mobile_apis::Result::eType result_code = MessageHelper::HMIToMobileResult(hmi_result); + custom_vehicle_data_manager_.CreateMobileMessageParams( + hmi_response_msg_params); + + if (!vi_still_subscribed_by_another_apps_.empty() || + !vi_already_unsubscribed_by_this_app_.empty()) { + AddAlreadyUnsubscribedVI(hmi_response_msg_params); + } + if (result) { if (vi_already_unsubscribed_by_this_app_.size()) { result_code = mobile_apis::Result::IGNORED; response_info = "Some provided VehicleData was not subscribed."; } - } - if (!vi_still_subscribed_by_another_apps_.empty() || - !vi_already_unsubscribed_by_this_app_.empty()) { - AddAlreadyUnsubscribedVI( - const_cast(message[strings::msg_params])); - } + for (const auto& param : hmi_response_msg_params.enumerate()) { + const auto converted_param = ConvertResponseToRequestName(param); + if (vi_waiting_for_unsubscribe_.end() == + vi_waiting_for_unsubscribe_.find(converted_param)) { + hmi_response_msg_params.erase(param); + } + } - if (result) { - SetAllowedToTerminate(false); + if (!UnsubscribePendingVehicleData(app, hmi_response_msg_params)) { + result = false; + result_code = mobile_apis::Result::GENERIC_ERROR; + response_info = "Unsubscription failed for some Vehicle data"; + hmi_response_msg_params = smart_objects::SmartObject(); + } } - SendResponse(result, - result_code, - response_info.empty() ? NULL : response_info.c_str(), - &(message[strings::msg_params])); - if (result) { - application_manager_.TerminateRequest( - connection_key(), correlation_id(), function_id()); + + AppendDataTypesToMobileResponse(hmi_response_msg_params); + for (const auto& key : hmi_response_msg_params.enumerate()) { + response_params_[key] = hmi_response_msg_params[key]; } + + SendResponse( + result, + result_code, + response_info.empty() ? NULL : response_info.c_str(), + smart_objects::SmartType::SmartType_Null == response_params_.getType() + ? NULL + : &response_params_); } bool UnsubscribeVehicleDataRequest::Init() { @@ -240,25 +258,23 @@ bool UnsubscribeVehicleDataRequest::Init() { return true; } -struct SubscribedToIVIPredicate { - int32_t vehicle_info_; - SubscribedToIVIPredicate(int32_t vehicle_info) - : vehicle_info_(vehicle_info) {} - bool operator()(const ApplicationSharedPtr app) const { +bool UnsubscribeVehicleDataRequest::IsSomeoneSubscribedFor( + const std::string& param_name) const { + LOG4CXX_AUTO_TRACE(logger_); + const auto conn_key = connection_key(); + auto subscribed_to_ivi = [¶m_name, + &conn_key](const ApplicationSharedPtr app) { DCHECK_OR_RETURN(app, false); + if (conn_key == app->app_id()) { + return false; + } auto& ext = VehicleInfoAppExtension::ExtractVIExtension(*app); - return ext.isSubscribedToVehicleInfo( - static_cast(vehicle_info_)); - } -}; + return (ext.isSubscribedToVehicleInfo(param_name)); + }; -bool UnsubscribeVehicleDataRequest::IsSomeoneSubscribedFor( - const uint32_t param_id) const { - LOG4CXX_AUTO_TRACE(logger_); - SubscribedToIVIPredicate finder(param_id); DataAccessor accessor = application_manager_.applications(); ApplicationSetConstIt it = std::find_if( - accessor.GetData().begin(), accessor.GetData().end(), finder); + accessor.GetData().begin(), accessor.GetData().end(), subscribed_to_ivi); return it != accessor.GetData().end(); } @@ -266,22 +282,94 @@ void UnsubscribeVehicleDataRequest::AddAlreadyUnsubscribedVI( smart_objects::SmartObject& response) const { LOG4CXX_AUTO_TRACE(logger_); using namespace mobile_apis; - VehicleInfoSubscriptions::const_iterator it_same_app = - vi_already_unsubscribed_by_this_app_.begin(); - for (; vi_already_unsubscribed_by_this_app_.end() != it_same_app; - ++it_same_app) { - response[*it_same_app][strings::result_code] = + + for (const auto& item : vi_already_unsubscribed_by_this_app_) { + response[item][strings::result_code] = VehicleDataResultCode::VDRC_DATA_NOT_SUBSCRIBED; } - VehicleInfoSubscriptions::const_iterator it_another_app = - vi_still_subscribed_by_another_apps_.begin(); - for (; vi_still_subscribed_by_another_apps_.end() != it_another_app; - ++it_another_app) { - response[*it_another_app][strings::result_code] = - VehicleDataResultCode::VDRC_SUCCESS; + for (const auto& item : vi_still_subscribed_by_another_apps_) { + response[item][strings::result_code] = VehicleDataResultCode::VDRC_SUCCESS; + } +} + +bool UnsubscribeVehicleDataRequest::CheckSubscriptionStatus( + std::string key, const smart_objects::SmartObject& msg_params) { + const auto unsubscribed_items = msg_params.enumerate(); + if (unsubscribed_items.end() == unsubscribed_items.find(key)) { + LOG4CXX_WARN(logger_, + key << " is waiting to be unsubscribed, but missing in " + "vehicle response."); + return false; + } + + auto res_code = msg_params[key][strings::result_code].asInt(); + if (hmi_apis::Common_VehicleDataResultCode::VDRC_SUCCESS != res_code) { + LOG4CXX_WARN(logger_, + "Unubscribing from " << key << " for " << connection_key() + << " failed."); + return false; + } + return true; +} + +bool UnsubscribeVehicleDataRequest::UnsubscribePendingVehicleData( + ApplicationSharedPtr app, const smart_objects::SmartObject& msg_params) { + LOG4CXX_DEBUG(logger_, "Unsubscribing from all pending VehicleData"); + + for (const auto& vi_name : vi_waiting_for_unsubscribe_) { + const auto converted_item = ConvertRequestToResponseName(vi_name); + const bool is_unsubscription_successful = + CheckSubscriptionStatus(converted_item, msg_params); + if (is_unsubscription_successful) { + auto& ext = VehicleInfoAppExtension::ExtractVIExtension(*app); + ext.unsubscribeFromVehicleInfo(vi_name); + vi_waiting_for_unsubscribe_.erase(vi_name); + } + } + return vi_waiting_for_unsubscribe_.empty(); +} + +const std::string& UnsubscribeVehicleDataRequest::ConvertRequestToResponseName( + const std::string& name) { + static std::map parameter_name_converion_map = { + {strings::cluster_mode_status, strings::cluster_modes}}; + const auto converted_it = parameter_name_converion_map.find(name); + return parameter_name_converion_map.end() == converted_it + ? name + : converted_it->second; +} + +const std::string& UnsubscribeVehicleDataRequest::ConvertResponseToRequestName( + const std::string& name) { + static std::map parameter_name_converion_map = { + {strings::cluster_modes, strings::cluster_mode_status}}; + const auto converted_it = parameter_name_converion_map.find(name); + return parameter_name_converion_map.end() == converted_it + ? name + : converted_it->second; +} + +void UnsubscribeVehicleDataRequest::AppendDataTypesToMobileResponse( + smart_objects::SmartObject& msg_params) const { + using namespace smart_objects; + + std::string oem_vehicle_data_type_str; + EnumConversionHelper::EnumToString( + VehicleDataType::VEHICLEDATA_OEM_CUSTOM_DATA, &oem_vehicle_data_type_str); + + const auto& rpc_spec_vehicle_data = MessageHelper::vehicle_data(); + for (const auto& item : msg_params.enumerate()) { + const auto& rpc_spec_vehicle_data_item = rpc_spec_vehicle_data.find(item); + if (rpc_spec_vehicle_data.end() == rpc_spec_vehicle_data_item) { + msg_params[item][strings::data_type] = oem_vehicle_data_type_str; + msg_params[item][strings::oem_custom_data_type] = + custom_vehicle_data_manager_.GetVehicleDataItemType(item); + } else { + msg_params[item][strings::data_type] = rpc_spec_vehicle_data_item->second; + } } } } // namespace commands -} // namespace application_manager +} // namespace vehicle_info_plugin diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/unsubscribe_vehicle_data_response.cc b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/unsubscribe_vehicle_data_response.cc index 5f79785784b..352239c3311 100644 --- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/unsubscribe_vehicle_data_response.cc +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/unsubscribe_vehicle_data_response.cc @@ -40,15 +40,12 @@ namespace commands { UnsubscribeVehicleDataResponse::UnsubscribeVehicleDataResponse( const application_manager::commands::MessageSharedPtr& message, - ApplicationManager& application_manager, - app_mngr::rpc_service::RPCService& rpc_service, - app_mngr::HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handler) + const VehicleInfoCommandParams& params) : CommandResponseImpl(message, - application_manager, - rpc_service, - hmi_capabilities, - policy_handler) {} + params.application_manager_, + params.rpc_service_, + params.hmi_capabilities_, + params.policy_handler_) {} UnsubscribeVehicleDataResponse::~UnsubscribeVehicleDataResponse() {} @@ -67,4 +64,4 @@ void UnsubscribeVehicleDataResponse::Run() { } } // namespace commands -} // namespace application_manager +} // namespace vehicle_info_plugin diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/custom_vehicle_data_manager_impl.cc b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/custom_vehicle_data_manager_impl.cc new file mode 100644 index 00000000000..9df6d922aa8 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/custom_vehicle_data_manager_impl.cc @@ -0,0 +1,575 @@ +/** + * Copyright (c) 2019, 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 "vehicle_info_plugin/custom_vehicle_data_manager_impl.h" +#include +#include +#include "policy/policy_table/types.h" +#include "vehicle_info_plugin/vehicle_data_item_schema.h" + +#include "application_manager/application_manager.h" +#include "application_manager/message_helper.h" +#include "application_manager/policies/custom_vehicle_data_provider.h" +#include "interfaces/MOBILE_API_schema.h" +#include "policy/policy_table/policy_enum_schema_factory.h" +#include "smart_objects/enum_schema_item.h" +#include "utils/helpers.h" +#include "utils/optional.h" + +CREATE_LOGGERPTR_GLOBAL(logger_, "VehicleInfoPlugin") + +namespace vehicle_info_plugin { + +template +U GetOptional(const rpc::Optional& optional, U def_val) { + return optional.is_initialized() ? static_cast(*optional) : def_val; +} + +enum SearchMethod { RECURSIVE = 0, NON_RECURSIVE }; + +CustomVehicleDataManagerImpl::CustomVehicleDataManagerImpl( + policy::VehicleDataItemProvider& vehicle_data_provider, + application_manager::rpc_service::RPCService& rpc_service) + : vehicle_data_provider_(vehicle_data_provider) + , rpc_service_(rpc_service) {} + +std::string CustomVehicleDataManagerImpl::GetVehicleDataItemType( + const std::string& vehicle_data_item_name) const { + LOG4CXX_AUTO_TRACE(logger_); + const auto& schema = FindSchemaByNameNonRecursive(vehicle_data_item_name); + + return schema.is_initialized() ? std::string(schema->type) + : vehicle_data_item_name; +} + +bool CustomVehicleDataManagerImpl::IsValidCustomVehicleDataName( + const std::string& name) const { + const auto& schema = FindSchemaByNameNonRecursive(name); + return schema.is_initialized(); +} + +bool CustomVehicleDataManagerImpl::IsRemovedCustomVehicleDataName( + const std::string& name) const { + const auto& schema = FindRemovedSchemaByNameNonRecursive(name); + return schema.is_initialized(); +} + +void CustomVehicleDataManagerImpl::CreateMobileMessageParams( + smart_objects::SmartObject& msg_params) { + using namespace application_manager; + LOG4CXX_AUTO_TRACE(logger_); + + typedef std::function + MobileMsgConstructor; + + MobileMsgConstructor fill_mobile_msg = + [this, &fill_mobile_msg]( + const smart_objects::SmartObject& input_params, + SearchMethod search_method) -> smart_objects::SmartObject { + smart_objects::SmartObject out_params; + + const auto& items = input_params.enumerate(); + for (const auto& key : items) { + auto schema = search_method == SearchMethod::RECURSIVE + ? FindSchemaByKeyRecursive(key) + : FindSchemaByKeyNonRecursive(key); + if (!schema.is_initialized()) { + LOG4CXX_DEBUG(logger_, "Schema for: " << key << " cannot be found"); + continue; + } + + const auto& item_name = schema->name; + if (policy_table::VehicleDataItem::kStruct == std::string(schema->type)) { + auto& input_param = input_params[key]; + if (*schema->array && + input_param.getType() == smart_objects::SmartType_Array) { + for (size_t i = 0; i < input_param.length(); i++) { + const auto param = + fill_mobile_msg(input_param[i], SearchMethod::RECURSIVE); + out_params[item_name][i] = param; + } + continue; + } else { + const auto param = + fill_mobile_msg(input_param, SearchMethod::RECURSIVE); + if (!param.empty()) { + out_params[item_name] = param; + continue; + } + } + } + + out_params[item_name] = input_params[key]; + } + + return out_params; + }; + + const auto& rpc_spec_vehicle_data = MessageHelper::vehicle_data(); + const auto& item_names = msg_params.enumerate(); + smart_objects::SmartObject params_to_convert; + + for (const auto& item_key : item_names) { + const auto& found_it = rpc_spec_vehicle_data.find(item_key); + if (found_it == rpc_spec_vehicle_data.end()) { + params_to_convert[item_key] = msg_params[item_key]; + msg_params.erase(item_key); + } + } + + const auto& mobile_msg_params = + fill_mobile_msg(params_to_convert, SearchMethod::NON_RECURSIVE); + for (const auto& name : mobile_msg_params.enumerate()) { + msg_params[name] = mobile_msg_params[name]; + } +} + +smart_objects::SmartObject CustomVehicleDataManagerImpl::CreateHMIMessageParams( + const std::set& item_names) { + typedef std::function + ParamsConstructor; + + auto fill_param = [](ParamsConstructor& constructor, + const policy_table::VehicleDataItem& param, + smart_objects::SmartObject* out_params) { + DCHECK_OR_RETURN_VOID(out_params) + const auto param_key = std::string(param.key); + const auto param_type = std::string(param.type); + if (policy_table::VehicleDataItem::kStruct == param_type) { + (*out_params)[param_key] = constructor(param); + } else { + (*out_params)[param_key] = true; + } + }; + + ParamsConstructor fill_hmi_params = + [&fill_hmi_params, + fill_param](const policy_table::VehicleDataItem& item) { + smart_objects::SmartObject out_params; + DCHECK(policy_table::VehicleDataItem::kStruct == + std::string(item.type)); + for (auto& param : *(item.params)) { + fill_param(fill_hmi_params, param, &out_params); + } + return out_params; + }; + + smart_objects::SmartObject out_params(smart_objects::SmartType_Map); + for (const auto& name : item_names) { + auto schema = FindSchemaByNameNonRecursive(name); + if (schema.is_initialized()) { + fill_param(fill_hmi_params, *schema, &out_params); + continue; + } + + auto removed_schema = FindRemovedSchemaByNameNonRecursive(name); + if (removed_schema.is_initialized()) { + fill_param(fill_hmi_params, *removed_schema, &out_params); + } + } + + return out_params; +} + +template +const OptionalDataItem FindSchema( + const std::vector& oem_items, + SearchMethod search_method, + Comparer comparer) { + LOG4CXX_AUTO_TRACE(logger_); + + std::vector items; + for (const auto& item : oem_items) { + if (comparer(item)) { + items.push_back(item); + } + if (search_method == SearchMethod::RECURSIVE && + policy_table::VehicleDataItem::kStruct == std::string(item.type)) { + auto found_in_params = + FindSchema(*(item.params), search_method, comparer); + if (found_in_params.is_initialized()) { + items.push_back(*found_in_params); + } + } + } + std::sort(items.begin(), + items.end(), + [](const policy_table::VehicleDataItem& left, + const policy_table::VehicleDataItem& right) { + if (!right.since.is_initialized()) { + return false; + } + if (!left.since.is_initialized()) { + return true; + } + const std::string l = *left.since; + const std::string r = *right.since; + return std::stof(l.c_str()) > std::stof(r.c_str()); + }); + + if (!items.empty()) { + return OptionalDataItem(*items.begin()); + } + + return OptionalDataItem(); +} + +void CustomVehicleDataManagerImpl::UpdateVehicleDataItems() { + using namespace ns_smart_device_link::ns_smart_objects; + using namespace policy_table; + + enum class SMemberType { + SMEMBER_MOBILE, + SMEMBER_HMI, + SMEMBER_BOOL_MOBILE, + SMEMBER_BOOL_HMI, + SMEMBER_VDR_MOBILE, + SMEMBER_VDR_HMI + }; + + auto get_custom_vdi = [this]() + -> std::vector { + using namespace rpc::policy_table_interface_base; + std::vector custom_vehicle_data_items; + auto vehicle_data_items = vehicle_data_provider_.GetVehicleDataItems(); + for (const auto& item : vehicle_data_items) { + policy_table::Parameter parameter_enum; + if (!policy_table::EnumFromJsonString(item.name, ¶meter_enum)) { + custom_vehicle_data_items.push_back(item); + } + } + return custom_vehicle_data_items; + }; + + auto vehicle_data_items = get_custom_vdi(); + + auto get_ischema_item = [](const VehicleDataItem& item, + SMemberType type, + std::vector history = {}) -> SMember { + switch (type) { + case SMemberType::SMEMBER_BOOL_MOBILE: { + auto member_schema = + CBoolSchemaItem::create(TSchemaItemParameter()); + return SMember( + member_schema, + false, // root level items should not be mandatory + item.since.is_initialized() ? std::string(*item.since) : "", + item.until.is_initialized() ? std::string(*item.until) : "", + bool(*item.deprecated), + bool(*item.removed), + history); + } + case SMemberType::SMEMBER_VDR_MOBILE: { + // valid since struct_schema_items is not used in + // InitStructSchemaItem_VehicleDataResult + mobile_apis::MOBILE_API::TStructsSchemaItems mobile_struct_schema_items; + auto member_schema = + mobile_apis::MOBILE_API::InitStructSchemaItem_VehicleDataResult( + mobile_struct_schema_items); + return SMember( + member_schema, + false, // root level items should not be mandatory + item.since.is_initialized() ? std::string(*item.since) : "", + item.until.is_initialized() ? std::string(*item.until) : "", + bool(*item.deprecated), + bool(*item.removed), + history); + } + case SMemberType::SMEMBER_MOBILE: { + TSchemaItemParameter tschema_item(item); + auto member_schema = VehicleDataItemSchema::create( + tschema_item, VehicleDataItemSchema::SchemaType::MOBILE); + return SMember( + member_schema, + false, // root level items should not be mandatory + item.since.is_initialized() ? std::string(*item.since) : "", + item.until.is_initialized() ? std::string(*item.until) : "", + bool(*item.deprecated), + bool(*item.removed), + history); + } + case SMemberType::SMEMBER_BOOL_HMI: { + auto member_schema = + CBoolSchemaItem::create(TSchemaItemParameter()); + return SMember(member_schema, + false // root level items should not be mandatory + ); + } + case SMemberType::SMEMBER_VDR_HMI: { + // valid since struct_schema_items is not used in + // InitStructSchemaItem_Common_VehicleDataResult + hmi_apis::HMI_API::TStructsSchemaItems hmi_struct_schema_items; + auto member_schema = + hmi_apis::HMI_API::InitStructSchemaItem_Common_VehicleDataResult( + hmi_struct_schema_items); + return SMember( + member_schema, false // root level items should not be mandatory + ); + } + case SMemberType::SMEMBER_HMI: { + TSchemaItemParameter tschema_item(item); + auto member_schema = VehicleDataItemSchema::create( + tschema_item, VehicleDataItemSchema::SchemaType::HMI); + return SMember( + member_schema, false // root level items should not be mandatory + ); + } + default: { + auto member_schema = CAlwaysFalseSchemaItem::create(); + return SMember(member_schema, false); + } + } + }; + + auto get_vehicle_data_history = + [&vehicle_data_items](std::string name) -> std::vector { + std::vector result; + std::copy_if(vehicle_data_items.begin(), + vehicle_data_items.end(), + std::back_inserter(result), + [&name](VehicleDataItem& item) { return item.name == name; }); + + std::sort(result.begin(), + result.end(), + [](const policy_table::VehicleDataItem& left, + const policy_table::VehicleDataItem& right) { + if (!right.since.is_initialized()) { + return false; + } + if (!left.since.is_initialized()) { + return true; + } + const std::string l = *left.since; + const std::string r = *right.since; + return std::stof(l.c_str()) > std::stof(r.c_str()); + }); + + return result; + }; + + auto get_member_with_history = [&get_ischema_item]( + std::vector items, + SMemberType type) -> SMember { + std::vector history = {}; + std::vector types{SMemberType::SMEMBER_MOBILE, + SMemberType::SMEMBER_VDR_MOBILE, + SMemberType::SMEMBER_BOOL_MOBILE}; + if (helpers::in_range(types, type) && items.size() > 1) { + auto history_iterator = items.begin() + 1; + for (; history_iterator < items.end(); ++history_iterator) { + const auto& item = (*history_iterator); + history.push_back(get_ischema_item(item, type)); + } + } + + auto latest_item = (*items.begin()); + return get_ischema_item(latest_item, type, history); + }; + + CustomVehicleDataManagerImpl::RPCParams mobile_params; + CustomVehicleDataManagerImpl::RPCParams hmi_params; + + std::set vehicle_data_names; + for (const auto& item : vehicle_data_items) { + vehicle_data_names.insert(item.name); + } + + for (const auto& name : vehicle_data_names) { + auto vehicle_data_history = get_vehicle_data_history(name); + const auto& vdi = vehicle_data_history.begin(); + + SMember member_bool_hmi = get_member_with_history( + vehicle_data_history, SMemberType::SMEMBER_BOOL_HMI); + SMember member_bool_mobile = get_member_with_history( + vehicle_data_history, SMemberType::SMEMBER_BOOL_MOBILE); + + SMember member_vdr_hmi = get_member_with_history( + vehicle_data_history, SMemberType::SMEMBER_VDR_HMI); + SMember member_vdr_mobile = get_member_with_history( + vehicle_data_history, SMemberType::SMEMBER_VDR_MOBILE); + SMember member_hmi = + get_member_with_history(vehicle_data_history, SMemberType::SMEMBER_HMI); + SMember member_mobile = get_member_with_history( + vehicle_data_history, SMemberType::SMEMBER_MOBILE); + + mobile_params.addBoolParam( + std::pair(vdi->name, member_bool_mobile)); + mobile_params.addVDRParam( + std::pair(vdi->name, member_vdr_mobile)); + mobile_params.addParam( + std::pair(vdi->name, member_mobile)); + + hmi_params.addBoolParam( + std::pair(vdi->key, member_bool_hmi)); + hmi_params.addVDRParam( + std::pair(vdi->key, member_vdr_hmi)); + hmi_params.addParam(std::pair(vdi->key, member_hmi)); + } + + std::vector mobile_subscribe_functions{ + mobile_apis::FunctionID::SubscribeVehicleDataID, + mobile_apis::FunctionID::UnsubscribeVehicleDataID}; + + for (const auto& function_id : mobile_subscribe_functions) { + rpc_service_.UpdateMobileRPCParams(function_id, + mobile_apis::messageType::request, + mobile_params.getBoolParams()); + rpc_service_.UpdateMobileRPCParams(function_id, + mobile_apis::messageType::response, + mobile_params.getVDRParams()); + } + + std::vector hmi_subscribe_functions{ + hmi_apis::FunctionID::VehicleInfo_SubscribeVehicleData, + hmi_apis::FunctionID::VehicleInfo_UnsubscribeVehicleData}; + + for (const auto& function_id : hmi_subscribe_functions) { + rpc_service_.UpdateHMIRPCParams(function_id, + hmi_apis::messageType::request, + hmi_params.getBoolParams()); + rpc_service_.UpdateHMIRPCParams(function_id, + hmi_apis::messageType::response, + hmi_params.getVDRParams()); + } + + rpc_service_.UpdateMobileRPCParams(mobile_apis::FunctionID::GetVehicleDataID, + mobile_apis::messageType::request, + mobile_params.getBoolParams()); + + rpc_service_.UpdateMobileRPCParams(mobile_apis::FunctionID::GetVehicleDataID, + mobile_apis::messageType::response, + mobile_params.getParams()); + + rpc_service_.UpdateMobileRPCParams(mobile_apis::FunctionID::OnVehicleDataID, + mobile_apis::messageType::notification, + mobile_params.getParams()); + + rpc_service_.UpdateHMIRPCParams( + hmi_apis::FunctionID::VehicleInfo_GetVehicleData, + hmi_apis::messageType::request, + hmi_params.getBoolParams()); + + rpc_service_.UpdateHMIRPCParams( + hmi_apis::FunctionID::VehicleInfo_GetVehicleData, + hmi_apis::messageType::response, + hmi_params.getParams()); + + rpc_service_.UpdateHMIRPCParams( + hmi_apis::FunctionID::VehicleInfo_OnVehicleData, + hmi_apis::messageType::notification, + hmi_params.getParams()); +} + +void CustomVehicleDataManagerImpl::OnPolicyEvent( + plugin_manager::PolicyEvent policy_event) { + using namespace plugin_manager; + LOG4CXX_AUTO_TRACE(logger_); + + switch (policy_event) { + case kApplicationPolicyUpdated: + UpdateVehicleDataItems(); + break; + case kApplicationsDisabled: + default: + return; + } +} + +const OptionalDataItem +CustomVehicleDataManagerImpl::FindSchemaByNameNonRecursive( + const std::string& name) const { + LOG4CXX_AUTO_TRACE(logger_); + + auto& oem_items = vehicle_data_provider_.GetVehicleDataItems(); + auto compare_by_name = [&name](const policy_table::VehicleDataItem& item) { + return (name == std::string(item.name)); + }; + + return FindSchema(oem_items, SearchMethod::NON_RECURSIVE, compare_by_name); +} + +const OptionalDataItem +CustomVehicleDataManagerImpl::FindRemovedSchemaByNameNonRecursive( + const std::string& name) const { + LOG4CXX_AUTO_TRACE(logger_); + + const auto& removed_oem_items = + vehicle_data_provider_.GetRemovedVehicleDataItems(); + auto compare_by_name = [&name](const policy_table::VehicleDataItem& item) { + return (name == std::string(item.name)); + }; + + return FindSchema( + removed_oem_items, SearchMethod::NON_RECURSIVE, compare_by_name); +} + +const OptionalDataItem CustomVehicleDataManagerImpl::FindSchemaByNameRecursive( + const std::string& name) const { + LOG4CXX_AUTO_TRACE(logger_); + + auto& oem_items = vehicle_data_provider_.GetVehicleDataItems(); + auto compare_by_name = [&name](const policy_table::VehicleDataItem& item) { + return (name == std::string(item.name)); + }; + + return FindSchema(oem_items, SearchMethod::RECURSIVE, compare_by_name); +} + +const OptionalDataItem +CustomVehicleDataManagerImpl::FindSchemaByKeyNonRecursive( + const std::string& key) const { + LOG4CXX_AUTO_TRACE(logger_); + + auto& oem_items = vehicle_data_provider_.GetVehicleDataItems(); + auto compare_by_key = [&key](const policy_table::VehicleDataItem& item) { + return (key == std::string(item.key)); + }; + + return FindSchema(oem_items, SearchMethod::NON_RECURSIVE, compare_by_key); +} + +const OptionalDataItem CustomVehicleDataManagerImpl::FindSchemaByKeyRecursive( + const std::string& key) const { + LOG4CXX_AUTO_TRACE(logger_); + + auto& oem_items = vehicle_data_provider_.GetVehicleDataItems(); + auto compare_by_key = [&key](const policy_table::VehicleDataItem& item) { + return (key == std::string(item.key)); + }; + + return FindSchema(oem_items, SearchMethod::RECURSIVE, compare_by_key); +} + +} // namespace vehicle_info_plugin diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/vehicle_data_item_schema.cc b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/vehicle_data_item_schema.cc new file mode 100644 index 00000000000..750da9fa6e8 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/vehicle_data_item_schema.cc @@ -0,0 +1,188 @@ +#include "vehicle_info_plugin/vehicle_data_item_schema.h" +#include + +namespace vehicle_info_plugin { + +#ifdef ENABLE_LOG +CREATE_LOGGERPTR_LOCAL(vehicle_data_logger, "VehicleDataItemSchema"); +#endif // ENABLE_LOG + +VehicleDataItemSchema::VehicleDataItemSchema(PolicyDataItem& policy_item, + SchemaType schema_type) { + policy_table::VehicleDataItem policy_data_item; + policy_item.getValue(policy_data_item); + + auto get_object_schema = [&policy_data_item, + &schema_type]() -> decltype(so_schema_item_) { + smart_objects::Members members; + auto object_schema = smart_objects::CObjectSchemaItem::create(members); + + for (auto& e : *policy_data_item.params) { + auto schema_item = PolicyDataItem(e); + smart_objects::SMember member(create(schema_item, schema_type), + bool(e.mandatory), + std::string(*e.since), + std::string(*e.until), + bool(*e.deprecated), + bool(*e.removed)); + std::string name; + switch (schema_type) { + case VehicleDataItemSchema::SchemaType::HMI: + name = e.key; + break; + case VehicleDataItemSchema::SchemaType::MOBILE: + default: + name = e.name; + break; + } + object_schema->AddMemberSchemaItem(name, member); + } + + return object_schema; + }; + + auto get_schema = [&policy_data_item, + &get_object_schema, + &schema_type, + this]() -> decltype(so_schema_item_) { + // Check if policy item has POD type + if (isPODType(policy_data_item.type)) { + return GetPODTypeSchema(policy_data_item, schema_type); + } + + // Check if policy item has Struct type + if (policy_data_item.type == policy_table::VehicleDataItem::kStruct) { + return get_object_schema(); + } + + // Check if policy item has Enum type + auto enum_schema = getEnumSchema(policy_data_item.type); + if (enum_schema != nullptr) { + return enum_schema; + } + + // If an unknown type is present in the policy table, it is assumed that it + // is a future enum type. Since normal validation cannot be performed on + // this value, it is treated as a raw string instead + policy_data_item.type = "String"; + + return GetPODTypeSchema(policy_data_item, schema_type); + }; + + if (*policy_data_item.array) { + so_schema_item_ = smart_objects::CArraySchemaItem::create( + get_schema(), + policy_data_item.minsize.is_initialized() + ? smart_objects::TSchemaItemParameter( + *policy_data_item.minsize) + : smart_objects::TSchemaItemParameter(), + policy_data_item.maxsize.is_initialized() + ? smart_objects::TSchemaItemParameter( + *policy_data_item.maxsize) + : smart_objects::TSchemaItemParameter()); + } else { + so_schema_item_ = get_schema(); + } +} + +VehicleDataItemSchemaPtr VehicleDataItemSchema::create( + PolicyDataItem& policy_item, SchemaType schema_type) { + return VehicleDataItemSchemaPtr( + new VehicleDataItemSchema(policy_item, schema_type)); +} + +smart_objects::errors::eType +vehicle_info_plugin::VehicleDataItemSchema::validate( + const smart_objects::SmartObject& Object, + rpc::ValidationReport* report__, + const utils::SemanticVersion& MessageVersion, + const bool allow_unknown_enums) { + if (!so_schema_item_) { + std::string validation_info = + "Invalid type: " + + smart_objects::SmartObject::typeToString(Object.getType()); + report__->set_validation_info(validation_info); + return smart_objects::errors::eType::ERROR; + } + + return so_schema_item_->validate( + Object, report__, MessageVersion, allow_unknown_enums); +} + +smart_objects::ISchemaItemPtr VehicleDataItemSchema::GetPODTypeSchema( + const policy_table::VehicleDataItem& policy_item, SchemaType schema_type) { + using IntSchemaItem = smart_objects::TNumberSchemaItem; + using IntItemParam = smart_objects::TSchemaItemParameter; + using FloatSchemaItem = smart_objects::TNumberSchemaItem; + using FloatItemParam = smart_objects::TSchemaItemParameter; + using StringSchemaItem = smart_objects::CStringSchemaItem; + using StringItemParam = smart_objects::TSchemaItemParameter; + using BoolSchemaItem = smart_objects::CBoolSchemaItem; + using BoolItemParam = smart_objects::TSchemaItemParameter; + + if (policy_item.type == policy_table::VehicleDataItem::kInteger) { + return IntSchemaItem::create(policy_item.minvalue.is_initialized() + ? IntItemParam(*policy_item.minvalue) + : IntItemParam(), + policy_item.maxvalue.is_initialized() + ? IntItemParam(*policy_item.maxvalue) + : IntItemParam()); + } + if (policy_item.type == policy_table::VehicleDataItem::kFloat || + policy_item.type == policy_table::VehicleDataItem::kDouble) { + return FloatSchemaItem::create( + policy_item.minvalue.is_initialized() + ? FloatItemParam(double(*policy_item.minvalue)) + : FloatItemParam(), + policy_item.maxvalue.is_initialized() + ? FloatItemParam(double(*policy_item.maxvalue)) + : FloatItemParam()); + } + if (policy_item.type == policy_table::VehicleDataItem::kString) { + return StringSchemaItem::create( + StringItemParam(policy_item.minlength.is_initialized() + ? *policy_item.minlength + : 0), + policy_item.maxlength.is_initialized() + ? StringItemParam(*policy_item.maxlength) + : StringItemParam()); + } + if (policy_item.type == policy_table::VehicleDataItem::kBoolean) { + return BoolSchemaItem::create(BoolItemParam(true)); + } + + std::string error_msg = std::string("Invalid POD type provided: ") + + std::string(policy_item.type); + LOG4CXX_ERROR(vehicle_data_logger, error_msg.c_str()); + return nullptr; +} + +const bool VehicleDataItemSchema::isPODType( + const std::string& type_name) const { + return std::find(policy_table::VehicleDataItem::kPODTypes.begin(), + policy_table::VehicleDataItem::kPODTypes.end(), + type_name) != policy_table::VehicleDataItem::kPODTypes.end(); +} + +smart_objects::ISchemaItemPtr VehicleDataItemSchema::getEnumSchema( + const std::string& type_name) const { + auto enum_schema = policy_table::EnumSchemaItemFactory::Get(type_name); + if (!enum_schema) { + LOG4CXX_ERROR(vehicle_data_logger, "NULL pointer: " << type_name); + } + return enum_schema; +} + +void VehicleDataItemSchema::applySchema( + smart_objects::SmartObject& Object, + const bool remove_unknown_parameters, + const utils::SemanticVersion& MessageVersion) { + so_schema_item_->applySchema( + Object, remove_unknown_parameters, MessageVersion); +} + +void VehicleDataItemSchema::unapplySchema( + smart_objects::SmartObject& Object, const bool remove_unknown_parameters) { + so_schema_item_->unapplySchema(Object, remove_unknown_parameters); +} +} // namespace vehicle_info_plugin diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/vehicle_info_app_extension.cc b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/vehicle_info_app_extension.cc index 3b1d4118410..149299d3bb7 100644 --- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/vehicle_info_app_extension.cc +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/vehicle_info_app_extension.cc @@ -53,13 +53,13 @@ VehicleInfoAppExtension::~VehicleInfoAppExtension() { } bool VehicleInfoAppExtension::subscribeToVehicleInfo( - const VehicleDataType vehicle_data) { + const std::string& vehicle_data) { LOG4CXX_DEBUG(logger_, vehicle_data); return subscribed_data_.insert(vehicle_data).second; } bool VehicleInfoAppExtension::unsubscribeFromVehicleInfo( - const VehicleDataType vehicle_data) { + const std::string& vehicle_data) { LOG4CXX_DEBUG(logger_, vehicle_data); auto it = subscribed_data_.find(vehicle_data); if (it != subscribed_data_.end()) { @@ -75,7 +75,7 @@ void VehicleInfoAppExtension::unsubscribeFromVehicleInfo() { } bool VehicleInfoAppExtension::isSubscribedToVehicleInfo( - const VehicleDataType vehicle_data) const { + const std::string& vehicle_data) const { LOG4CXX_DEBUG(logger_, vehicle_data); return subscribed_data_.find(vehicle_data) != subscribed_data_.end(); } @@ -91,7 +91,7 @@ void VehicleInfoAppExtension::SaveResumptionData( smart_objects::SmartObject(smart_objects::SmartType_Array); int i = 0; for (const auto& subscription : subscribed_data_) { - resumption_data[application_vehicle_info][i] = subscription; + resumption_data[application_vehicle_info][i++] = subscription; } } @@ -99,13 +99,12 @@ void VehicleInfoAppExtension::ProcessResumption( const smart_objects::SmartObject& resumption_data) { const char* application_vehicle_info = "vehicleInfo"; if (resumption_data.keyExists(application_vehicle_info)) { - const smart_objects::SmartObject& subscriptions_ivi = - resumption_data[application_vehicle_info]; - for (size_t i = 0; i < subscriptions_ivi.length(); ++i) { - mobile_apis::VehicleDataType::eType ivi = - static_cast( - (resumption_data[i]).asInt()); - subscribeToVehicleInfo(ivi); + const auto* subscriptions_ivi = + resumption_data[application_vehicle_info].asArray(); + if (subscriptions_ivi) { + for (const auto& ivi : (*subscriptions_ivi)) { + subscribeToVehicleInfo(ivi.asString()); + } } plugin_.ProcessResumptionSubscription(app_, *this); } @@ -122,4 +121,4 @@ VehicleInfoAppExtension& VehicleInfoAppExtension::ExtractVIExtension( DCHECK(vi_app_extension); return *vi_app_extension; } -} +} // namespace vehicle_info_plugin diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/vehicle_info_command_factory.cc b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/vehicle_info_command_factory.cc index 0c6e0a07b12..52ee9f476d5 100644 --- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/vehicle_info_command_factory.cc +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/vehicle_info_command_factory.cc @@ -36,15 +36,27 @@ CREATE_LOGGERPTR_GLOBAL(logger_, "VehicleInfoPlugin") namespace vehicle_info_plugin { +namespace app_mngr = application_manager; +namespace commands = application_manager::commands; + VehicleInfoCommandFactory::VehicleInfoCommandFactory( app_mngr::ApplicationManager& application_manager, app_mngr::rpc_service::RPCService& rpc_service, app_mngr::HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handler) - : hmi_command_factory_(new VehicleInfoHmiCommandFactory( - application_manager, rpc_service, hmi_capabilities, policy_handler)) - , mob_command_factory_(new VehicleInfoMobileCommandFactory( - application_manager, rpc_service, hmi_capabilities, policy_handler)) { + policy::PolicyHandlerInterface& policy_handler, + CustomVehicleDataManager& custom_vehicle_data_manager) + : hmi_command_factory_( + new VehicleInfoHmiCommandFactory(application_manager, + rpc_service, + hmi_capabilities, + policy_handler, + custom_vehicle_data_manager)) + , mob_command_factory_( + new VehicleInfoMobileCommandFactory(application_manager, + rpc_service, + hmi_capabilities, + policy_handler, + custom_vehicle_data_manager)) { LOG4CXX_AUTO_TRACE(logger_); } @@ -69,4 +81,4 @@ bool VehicleInfoCommandFactory::IsAbleToProcess( ? hmi_command_factory_->IsAbleToProcess(function_id, source) : mob_command_factory_->IsAbleToProcess(function_id, source); } -} +} // namespace vehicle_info_plugin 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 9311cea6d70..e8d852b6125 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 @@ -41,6 +41,8 @@ #include "vehicle_info_plugin/commands/hmi/vi_get_dtcs_response.h" #include "vehicle_info_plugin/commands/hmi/vi_get_vehicle_data_request.h" #include "vehicle_info_plugin/commands/hmi/vi_get_vehicle_data_response.h" +#include "vehicle_info_plugin/commands/hmi/vi_get_vehicle_type_request.h" +#include "vehicle_info_plugin/commands/hmi/vi_get_vehicle_type_response.h" #include "vehicle_info_plugin/commands/hmi/vi_is_ready_request.h" #include "vehicle_info_plugin/commands/hmi/vi_is_ready_response.h" #include "vehicle_info_plugin/commands/hmi/vi_read_did_request.h" @@ -49,23 +51,81 @@ #include "vehicle_info_plugin/commands/hmi/vi_subscribe_vehicle_data_response.h" #include "vehicle_info_plugin/commands/hmi/vi_unsubscribe_vehicle_data_request.h" #include "vehicle_info_plugin/commands/hmi/vi_unsubscribe_vehicle_data_response.h" -#include "vehicle_info_plugin/commands/hmi/vi_get_vehicle_type_request.h" -#include "vehicle_info_plugin/commands/hmi/vi_get_vehicle_type_response.h" CREATE_LOGGERPTR_GLOBAL(logger_, "VehicleInfoPlugin") namespace vehicle_info_plugin { namespace strings = app_mngr::strings; +template +class VehicleInfoCommandCreator : public application_manager::CommandCreator { + public: + VehicleInfoCommandCreator(const VehicleInfoCommandParams& params) + : params_(params) {} + + private: + bool CanBeCreated() const override { + return true; + } + + application_manager::CommandSharedPtr create( + const application_manager::commands::MessageSharedPtr& message) + const override { + application_manager::CommandSharedPtr command( + new VehicleInfoCommandType(message, params_)); + return command; + } + + VehicleInfoCommandParams params_; +}; + +struct VehicleInfoInvalidCommand {}; + +template <> +class VehicleInfoCommandCreator + : public application_manager::CommandCreator { + public: + VehicleInfoCommandCreator(const VehicleInfoCommandParams& params) { + UNUSED(params); + } + + private: + bool CanBeCreated() const override { + return false; + } + + application_manager::CommandSharedPtr create( + const application_manager::commands::MessageSharedPtr& message) + const override { + UNUSED(message); + return application_manager::CommandSharedPtr(); + } +}; + +struct VehicleInfoCommandCreatorFactory { + VehicleInfoCommandCreatorFactory(const VehicleInfoCommandParams& params) + : params_(params) {} + + template + application_manager::CommandCreator& GetCreator() { + LOG4CXX_AUTO_TRACE(logger_); + static VehicleInfoCommandCreator res(params_); + return res; + } + const VehicleInfoCommandParams params_; +}; + VehicleInfoHmiCommandFactory::VehicleInfoHmiCommandFactory( application_manager::ApplicationManager& application_manager, application_manager::rpc_service::RPCService& rpc_service, application_manager::HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handler) + policy::PolicyHandlerInterface& policy_handler, + CustomVehicleDataManager& custom_vehicle_data_manager) : application_manager_(application_manager) , rpc_service_(rpc_service) , hmi_capabilities_(hmi_capabilities) - , policy_handler_(policy_handler) { + , policy_handler_(policy_handler) + , custom_vehicle_data_manager_(custom_vehicle_data_manager) { LOG4CXX_AUTO_TRACE(logger_); } @@ -107,9 +167,12 @@ bool VehicleInfoHmiCommandFactory::IsAbleToProcess( app_mngr::CommandCreator& VehicleInfoHmiCommandFactory::buildCommandCreator( const int32_t function_id, const int32_t message_type) const { - auto factory = app_mngr::CommandCreatorFactory( - application_manager_, rpc_service_, hmi_capabilities_, policy_handler_); - + VehicleInfoCommandParams params = {application_manager_, + rpc_service_, + hmi_capabilities_, + policy_handler_, + custom_vehicle_data_manager_}; + auto factory = VehicleInfoCommandCreatorFactory(params); switch (function_id) { case hmi_apis::FunctionID::VehicleInfo_GetVehicleType: return hmi_apis::messageType::request == message_type @@ -150,7 +213,7 @@ app_mngr::CommandCreator& VehicleInfoHmiCommandFactory::buildCommandCreator( : factory.GetCreator(); default: LOG4CXX_WARN(logger_, "Unsupported function_id: " << function_id); - return factory.GetCreator(); + return factory.GetCreator(); } } -} +} // namespace vehicle_info_plugin 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 41ecd451dd9..c3c8d9c8d7f 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 @@ -34,6 +34,9 @@ #include "application_manager/message.h" #include "interfaces/MOBILE_API.h" +#include "vehicle_info_plugin/vehicle_info_command_params.h" + +#include "vehicle_info_plugin/custom_vehicle_data_manager.h" #include "vehicle_info_plugin/commands/mobile/diagnostic_message_request.h" #include "vehicle_info_plugin/commands/mobile/diagnostic_message_response.h" @@ -54,21 +57,83 @@ CREATE_LOGGERPTR_GLOBAL(logger_, "VehicleInfoPlugin") namespace vehicle_info_plugin { namespace strings = app_mngr::strings; +template +class VehicleInfoCommandCreator : public application_manager::CommandCreator { + public: + VehicleInfoCommandCreator(const VehicleInfoCommandParams& params) + : params_(params) {} + + private: + bool CanBeCreated() const override { + return true; + } + + application_manager::CommandSharedPtr create( + const application_manager::commands::MessageSharedPtr& message) + const override { + application_manager::CommandSharedPtr command( + new VehicleInfoCommandType(message, params_)); + return command; + } + + VehicleInfoCommandParams params_; +}; + +struct VehicleInfoInvalidCommand {}; + +template <> +class VehicleInfoCommandCreator + : public application_manager::CommandCreator { + public: + VehicleInfoCommandCreator(const VehicleInfoCommandParams& params) { + UNUSED(params); + } + + private: + bool CanBeCreated() const override { + return false; + } + + application_manager::CommandSharedPtr create( + const application_manager::commands::MessageSharedPtr& message) + const override { + UNUSED(message); + return application_manager::CommandSharedPtr(); + } +}; + +struct VehicleInfoCommandCreatorFactory { + VehicleInfoCommandCreatorFactory(const VehicleInfoCommandParams& params) + : params_(params) {} + + template + application_manager::CommandCreator& GetCreator() { + LOG4CXX_AUTO_TRACE(logger_); + static VehicleInfoCommandCreator res(params_); + return res; + } + const VehicleInfoCommandParams params_; +}; + VehicleInfoMobileCommandFactory::VehicleInfoMobileCommandFactory( application_manager::ApplicationManager& application_manager, application_manager::rpc_service::RPCService& rpc_service, application_manager::HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handler) + policy::PolicyHandlerInterface& policy_handler, + CustomVehicleDataManager& custom_vehicle_data_manager) : application_manager_(application_manager) , rpc_service_(rpc_service) , hmi_capabilities_(hmi_capabilities) - , policy_handler_(policy_handler) { + , policy_handler_(policy_handler) + , custom_vehicle_data_manager_(custom_vehicle_data_manager) { LOG4CXX_AUTO_TRACE(logger_); } app_mngr::CommandSharedPtr VehicleInfoMobileCommandFactory::CreateCommand( const app_mngr::commands::MessageSharedPtr& message, app_mngr::commands::Command::CommandSource source) { + UNUSED(source); + const mobile_apis::FunctionID::eType function_id = static_cast( (*message)[strings::params][strings::function_id].asInt()); @@ -105,8 +170,12 @@ bool VehicleInfoMobileCommandFactory::IsAbleToProcess( app_mngr::CommandCreator& VehicleInfoMobileCommandFactory::get_command_creator( const mobile_apis::FunctionID::eType id, const mobile_apis::messageType::eType message_type) const { - auto factory = app_mngr::CommandCreatorFactory( - application_manager_, rpc_service_, hmi_capabilities_, policy_handler_); + VehicleInfoCommandParams params = {application_manager_, + rpc_service_, + hmi_capabilities_, + policy_handler_, + custom_vehicle_data_manager_}; + auto factory = VehicleInfoCommandCreatorFactory(params); switch (id) { case mobile_apis::FunctionID::GetVehicleDataID: { return mobile_apis::messageType::request == message_type @@ -141,21 +210,25 @@ app_mngr::CommandCreator& VehicleInfoMobileCommandFactory::get_command_creator( } default: {} } - return factory.GetCreator(); + return factory.GetCreator(); } app_mngr::CommandCreator& VehicleInfoMobileCommandFactory::get_notification_creator( const mobile_apis::FunctionID::eType id) const { - auto factory = app_mngr::CommandCreatorFactory( - application_manager_, rpc_service_, hmi_capabilities_, policy_handler_); + VehicleInfoCommandParams params = {application_manager_, + rpc_service_, + hmi_capabilities_, + policy_handler_, + custom_vehicle_data_manager_}; + auto factory = VehicleInfoCommandCreatorFactory(params); switch (id) { case mobile_apis::FunctionID::OnVehicleDataID: { return factory.GetCreator(); } default: {} } - return factory.GetCreator(); + return factory.GetCreator(); } app_mngr::CommandCreator& VehicleInfoMobileCommandFactory::get_creator_factory( @@ -183,8 +256,12 @@ app_mngr::CommandCreator& VehicleInfoMobileCommandFactory::get_creator_factory( } default: {} } - auto factory = app_mngr::CommandCreatorFactory( - application_manager_, rpc_service_, hmi_capabilities_, policy_handler_); - return factory.GetCreator(); -} + VehicleInfoCommandParams params = {application_manager_, + rpc_service_, + hmi_capabilities_, + policy_handler_, + custom_vehicle_data_manager_}; + auto factory = VehicleInfoCommandCreatorFactory(params); + return factory.GetCreator(); } +} // namespace vehicle_info_plugin diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/vehicle_info_plugin.cc b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/vehicle_info_plugin.cc index c9e98399295..40da7501c1f 100644 --- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/vehicle_info_plugin.cc +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/vehicle_info_plugin.cc @@ -31,18 +31,20 @@ */ #include "vehicle_info_plugin/vehicle_info_plugin.h" -#include "vehicle_info_plugin/vehicle_info_command_factory.h" -#include "vehicle_info_plugin/vehicle_info_app_extension.h" +#include "application_manager/message_helper.h" #include "application_manager/plugin_manager/plugin_keys.h" +#include "application_manager/rpc_handler.h" #include "application_manager/smart_object_keys.h" -#include "application_manager/message_helper.h" -#include "application_manager/message_helper.h" +#include "vehicle_info_plugin/custom_vehicle_data_manager_impl.h" +#include "vehicle_info_plugin/vehicle_info_app_extension.h" +#include "vehicle_info_plugin/vehicle_info_command_factory.h" namespace vehicle_info_plugin { CREATE_LOGGERPTR_GLOBAL(logger_, "VehicleInfoPlugin") namespace strings = application_manager::strings; namespace plugins = application_manager::plugin_manager; +namespace commands = application_manager::commands; VehicleInfoPlugin::VehicleInfoPlugin() : application_manager_(nullptr) {} @@ -50,10 +52,18 @@ bool VehicleInfoPlugin::Init( application_manager::ApplicationManager& app_manager, application_manager::rpc_service::RPCService& rpc_service, application_manager::HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handler) { + policy::PolicyHandlerInterface& policy_handler, + resumption::LastState& last_state) { + UNUSED(last_state); application_manager_ = &app_manager; + custom_vehicle_data_manager_.reset( + new CustomVehicleDataManagerImpl(policy_handler, rpc_service)); command_factory_.reset(new vehicle_info_plugin::VehicleInfoCommandFactory( - app_manager, rpc_service, hmi_capabilities, policy_handler)); + app_manager, + rpc_service, + hmi_capabilities, + policy_handler, + *(custom_vehicle_data_manager_.get()))); return true; } @@ -70,7 +80,10 @@ app_mngr::CommandFactory& VehicleInfoPlugin::GetCommandFactory() { return *command_factory_; } -void VehicleInfoPlugin::OnPolicyEvent(plugins::PolicyEvent event) {} +void VehicleInfoPlugin::OnPolicyEvent(plugins::PolicyEvent event) { + UnsubscribeFromRemovedVDItems(); + custom_vehicle_data_manager_->OnPolicyEvent(event); +} void VehicleInfoPlugin::OnApplicationEvent( plugins::ApplicationEvent event, @@ -78,11 +91,49 @@ void VehicleInfoPlugin::OnApplicationEvent( if (plugins::ApplicationEvent::kApplicationRegistered == event) { application->AddExtension( std::make_shared(*this, *application)); - } else if (plugins::ApplicationEvent::kDeleteApplicationData == event) { + } else if ((plugins::ApplicationEvent::kDeleteApplicationData == event) || + (plugins::ApplicationEvent::kApplicationUnregistered == event)) { DeleteSubscriptions(application); } } +void VehicleInfoPlugin::UnsubscribeFromRemovedVDItems() { + typedef std::vector StringsVector; + + auto get_items_to_unsubscribe = [this]() -> StringsVector { + StringsVector output_items_list; + auto applications = application_manager_->applications(); + for (auto& app : applications.GetData()) { + auto& ext = VehicleInfoAppExtension::ExtractVIExtension(*app); + auto subscription_names = ext.Subscriptions(); + for (auto& subscription_name : subscription_names) { + if (custom_vehicle_data_manager_->IsRemovedCustomVehicleDataName( + subscription_name)) { + ext.unsubscribeFromVehicleInfo(subscription_name); + if (!helpers::in_range(output_items_list, subscription_name)) { + LOG4CXX_DEBUG(logger_, + "Vehicle data item " + << subscription_name + << " has been removed by policy"); + output_items_list.push_back(subscription_name); + } + } + } + } + return output_items_list; + }; + + const StringsVector items_to_unsubscribe = get_items_to_unsubscribe(); + + if (items_to_unsubscribe.empty()) { + LOG4CXX_DEBUG(logger_, "There is no data to unsubscribe"); + return; + } + + auto message = GetUnsubscribeIVIRequest(items_to_unsubscribe); + application_manager_->GetRPCService().ManageHMICommand(message); +} + void VehicleInfoPlugin::ProcessResumptionSubscription( application_manager::Application& app, VehicleInfoAppExtension& ext) { LOG4CXX_AUTO_TRACE(logger_); @@ -90,13 +141,15 @@ void VehicleInfoPlugin::ProcessResumptionSubscription( smart_objects::SmartObject(smart_objects::SmartType_Map); msg_params[strings::app_id] = app.app_id(); const auto& subscriptions = ext.Subscriptions(); - for (auto& ivi_data : application_manager::MessageHelper::vehicle_data()) { - mobile_apis::VehicleDataType::eType type_id = ivi_data.second; - if (subscriptions.end() != subscriptions.find(type_id)) { - std::string key_name = ivi_data.first; - msg_params[key_name] = true; - } + if (subscriptions.empty()) { + LOG4CXX_DEBUG(logger_, "No vehicle data to subscribe. Exiting"); + return; } + + for (const auto& item : subscriptions) { + msg_params[item] = true; + } + smart_objects::SmartObjectSPtr request = application_manager::MessageHelper::CreateModuleInfoSO( hmi_apis::FunctionID::VehicleInfo_SubscribeVehicleData, @@ -106,38 +159,56 @@ void VehicleInfoPlugin::ProcessResumptionSubscription( } application_manager::ApplicationSharedPtr FindAppSubscribedToIVI( - mobile_apis::VehicleDataType::eType ivi_data, + const std::string& ivi_name, application_manager::ApplicationManager& app_mngr) { auto applications = app_mngr.applications(); for (auto& app : applications.GetData()) { auto& ext = VehicleInfoAppExtension::ExtractVIExtension(*app); - if (ext.isSubscribedToVehicleInfo(ivi_data)) { + if (ext.isSubscribedToVehicleInfo(ivi_name)) { return app; } } return application_manager::ApplicationSharedPtr(); } -smart_objects::SmartObjectSPtr GetUnsubscribeIVIRequest( - int32_t ivi_id, application_manager::ApplicationManager& app_mngr) { +smart_objects::SmartObjectSPtr VehicleInfoPlugin::GetUnsubscribeIVIRequest( + const std::vector& ivi_names) { + LOG4CXX_AUTO_TRACE(logger_); using namespace smart_objects; - auto find_ivi_name = [ivi_id]() { + auto msg_params = smart_objects::SmartObject(smart_objects::SmartType_Map); + + auto find_ivi_name = [](const std::string& ivi_name) { for (auto item : application_manager::MessageHelper::vehicle_data()) { - if (ivi_id == item.second) { + if (ivi_name == item.first) { return item.first; } } return std::string(); }; - std::string key_name = find_ivi_name(); - DCHECK_OR_RETURN(!key_name.empty(), smart_objects::SmartObjectSPtr()); - auto msg_params = smart_objects::SmartObject(smart_objects::SmartType_Map); - msg_params[key_name] = true; + + for (const auto& ivi_name : ivi_names) { + // try to find the name in vehicle data types + std::string key_name = find_ivi_name(ivi_name); + + if (key_name.empty()) { + // the name hasn't been found in vehicle data types + if (custom_vehicle_data_manager_->IsValidCustomVehicleDataName( + ivi_name) || + custom_vehicle_data_manager_->IsRemovedCustomVehicleDataName( + ivi_name)) { + key_name = ivi_name; + } + } + + DCHECK_OR_RETURN(!key_name.empty(), smart_objects::SmartObjectSPtr()); + msg_params[key_name] = true; + } auto message = application_manager::MessageHelper::CreateMessageForHMI( - hmi_apis::messageType::request, app_mngr.GetNextHMICorrelationID()); + hmi_apis::messageType::request, + application_manager_->GetNextHMICorrelationID()); DCHECK(message); SmartObject& object = *message; @@ -152,18 +223,31 @@ void VehicleInfoPlugin::DeleteSubscriptions( application_manager::ApplicationSharedPtr app) { auto& ext = VehicleInfoAppExtension::ExtractVIExtension(*app); auto subscriptions = ext.Subscriptions(); + std::vector ivi_to_unsubscribe; for (auto& ivi : subscriptions) { ext.unsubscribeFromVehicleInfo(ivi); auto still_subscribed_app = FindAppSubscribedToIVI(ivi, *application_manager_); if (!still_subscribed_app) { - auto message = GetUnsubscribeIVIRequest(ivi, *application_manager_); - application_manager_->GetRPCService().ManageHMICommand(message); + ivi_to_unsubscribe.push_back(ivi); } } + + if (!ivi_to_unsubscribe.empty()) { + auto message = GetUnsubscribeIVIRequest(ivi_to_unsubscribe); + application_manager_->GetRPCService().ManageHMICommand(message); + } } -} +} // namespace vehicle_info_plugin -extern "C" application_manager::plugin_manager::RPCPlugin* Create() { +extern "C" __attribute__((visibility("default"))) +application_manager::plugin_manager::RPCPlugin* +Create() { return new vehicle_info_plugin::VehicleInfoPlugin(); } + +extern "C" __attribute__((visibility("default"))) void Delete( + application_manager::plugin_manager::RPCPlugin* data) { + delete data; + DELETE_THREAD_LOGGER(vehicle_info_plugin::logger_); +} diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/CMakeLists.txt b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/CMakeLists.txt index 3ea4a50a8a9..95d49f9a208 100644 --- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/CMakeLists.txt +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/CMakeLists.txt @@ -31,21 +31,26 @@ include(${CMAKE_SOURCE_DIR}/tools/cmake/helpers/sources.cmake) include_directories( + include ${GMOCK_INCLUDE_DIRECTORY} ${COMPONENTS_DIR}/application_manager/rpc_plugins/vehicle_info_plugin/include - ${COMPONENTS_DIR}/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/ + ${COMPONENTS_DIR}/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands ${COMPONENTS_DIR}/application_manager/test/include/ -) - - + ${COMPONENTS_DIR}/include/test/application_manager/ + ) set(COMMANDS_TEST_DIR ${CMAKE_CURRENT_SOURCE_DIR}/commands) file(GLOB SOURCES ${COMPONENTS_DIR}/application_manager/test/mock_message_helper.cc ${COMPONENTS_DIR}/application_manager/test/mock_application_helper.cc ${COMPONENTS_DIR}/application_manager/src/smart_object_keys.cc + ${COMPONENTS_DIR}/${POLICY_PATH}/src/policy_table/types.cc + ${COMPONENTS_DIR}/${POLICY_PATH}/src/policy_table/validation.cc + ${COMPONENTS_DIR}/${POLICY_PATH}/src/policy_table/enums.cc ${COMMANDS_TEST_DIR}/hmi/* ${COMMANDS_TEST_DIR}/mobile/* + ${CMAKE_CURRENT_SOURCE_DIR}/custom_vehicle_data_manager_test.cc + ${CMAKE_CURRENT_SOURCE_DIR}/vehicle_data_item_schema_test.cc ${COMPONENTS_DIR}/application_manager/src/message.cc ${COMPONENTS_DIR}/application_manager/src/event_engine/* ) @@ -58,6 +63,8 @@ set(LIBRARIES MOBILE_API connectionHandler vehicle_info_plugin + SmartObjects + formatters jsoncpp ) diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/commands/hmi/vi_get_vehicle_data_request_test.cc b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/commands/hmi/vi_get_vehicle_data_request_test.cc new file mode 100644 index 00000000000..6bc956f65f6 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/commands/hmi/vi_get_vehicle_data_request_test.cc @@ -0,0 +1,110 @@ +/* + * Copyright (c) 2019, 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 "hmi/vi_get_vehicle_data_request.h" + +#include "gtest/gtest.h" + +#include "smart_objects/enum_schema_item.h" +#include "smart_objects/smart_object.h" +#include "vehicle_info_plugin/commands/vi_command_request_test.h" + +namespace test { +namespace components { +namespace commands_test { +namespace hmi_commands_test { +namespace vi_get_vehicle_data_request { + +using ::testing::_; +using ::testing::Return; +using ::testing::ReturnRef; + +using vehicle_info_plugin::commands::VIGetVehicleDataRequest; + +namespace { +const std::string kMobileParam = "mobile_param"; +const std::string kHMIParam = "hmi_param"; +} // namespace + +class VIGetVehicleDataRequestTest + : public VICommandRequestTest {}; + +MATCHER_P(EqualMsgParams, msg_params, "") { + using namespace app_mngr; + auto message = static_cast(*arg); + if (!message.keyExists(strings::msg_params)) { + return false; + } + + return msg_params == message[strings::msg_params]; +} + +TEST_F(VIGetVehicleDataRequestTest, Run_Success) { + using namespace app_mngr; + auto command_msg = CreateMessage(smart_objects::SmartType_Map); + (*command_msg)[strings::msg_params][strings::rpm] = true; + (*command_msg)[strings::msg_params][kMobileParam] = true; + + am::VehicleData vehicle_data; + vehicle_data.insert(am::VehicleData::value_type( + strings::rpm, mobile_apis::VehicleDataType::VEHICLEDATA_RPM)); + ON_CALL(mock_message_helper_, vehicle_data()) + .WillByDefault(ReturnRef(vehicle_data)); + + std::string oem_vehicle_data_type_str; + smart_objects::EnumConversionHelper:: + EnumToString(mobile_apis::VehicleDataType::VEHICLEDATA_OEM_CUSTOM_DATA, + &oem_vehicle_data_type_str); + + smart_objects::SmartObject hmi_params; + hmi_params[kHMIParam] = smart_objects::SmartType_Map; + hmi_params[kHMIParam][strings::data_type] = oem_vehicle_data_type_str; + ON_CALL(mock_custom_vehicle_data_manager_, CreateHMIMessageParams(_)) + .WillByDefault(Return(hmi_params)); + + smart_objects::SmartObject hmi_request_msg; + hmi_request_msg[strings::rpm] = + (*command_msg)[strings::msg_params][strings::rpm]; + hmi_request_msg[kHMIParam] = hmi_params[kHMIParam]; + + EXPECT_CALL(mock_rpc_service_, + SendMessageToHMI(EqualMsgParams(hmi_request_msg))); + + auto command = CreateCommandVI(command_msg); + command->Run(); +} + +} // namespace vi_get_vehicle_data_request +} // namespace hmi_commands_test +} // namespace commands_test +} // namespace components +} // namespace test diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/commands/hmi/vi_get_vehicle_data_response_test.cc b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/commands/hmi/vi_get_vehicle_data_response_test.cc index 0508f0cdd60..45bc748df4b 100644 --- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/commands/hmi/vi_get_vehicle_data_response_test.cc +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/commands/hmi/vi_get_vehicle_data_response_test.cc @@ -36,17 +36,17 @@ #include "gtest/gtest.h" -#include "smart_objects/smart_object.h" -#include "application_manager/smart_object_keys.h" -#include "application_manager/commands/commands_test.h" #include "application_manager/application.h" +#include "application_manager/event_engine/event.h" #include "application_manager/message_helper.h" -#include "application_manager/mock_message_helper.h" #include "application_manager/mock_application_manager.h" -#include "application_manager/event_engine/event.h" #include "application_manager/mock_event_dispatcher.h" +#include "application_manager/mock_message_helper.h" #include "application_manager/policies/mock_policy_handler_interface.h" +#include "application_manager/smart_object_keys.h" #include "hmi/vi_get_vehicle_data_response.h" +#include "smart_objects/smart_object.h" +#include "vehicle_info_plugin/commands/vi_commands_test.h" namespace test { namespace components { @@ -61,9 +61,9 @@ namespace am = ::application_manager; namespace strings = ::application_manager::strings; namespace hmi_response = am::hmi_response; using am::commands::MessageSharedPtr; -using vehicle_info_plugin::commands::VIGetVehicleDataResponse; using am::event_engine::Event; using test::components::event_engine_test::MockEventDispatcher; +using vehicle_info_plugin::commands::VIGetVehicleDataResponse; typedef std::shared_ptr VIGetVehicleDataResponsePtr; @@ -74,7 +74,7 @@ const std::string kStrNumber = "123"; } // namespace class VIGetVehicleDataResponseTest - : public CommandsTest {}; + : public VICommandsTest {}; TEST_F(VIGetVehicleDataResponseTest, RUN_SUCCESS) { MessageSharedPtr command_msg(CreateMessage(smart_objects::SmartType_Map)); @@ -84,7 +84,7 @@ TEST_F(VIGetVehicleDataResponseTest, RUN_SUCCESS) { hmi_apis::messageType::response; VIGetVehicleDataResponsePtr command( - CreateCommand(command_msg)); + CreateCommandVI(command_msg)); am::event_engine::Event event( hmi_apis::FunctionID::VehicleInfo_GetVehicleData); @@ -132,7 +132,7 @@ TEST_F(VIGetVehicleDataResponseTest, ErrorResponse_SUCCESS) { (*command_msg)[strings::params][strings::protocol_version]; VIGetVehicleDataResponsePtr command( - CreateCommand(command_msg)); + CreateCommandVI(command_msg)); am::event_engine::Event event( hmi_apis::FunctionID::VehicleInfo_GetVehicleData); diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/commands/hmi/vi_is_ready_request_test.cc b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/commands/hmi/vi_is_ready_request_test.cc index 679d9d0e581..c083bf4d603 100644 --- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/commands/hmi/vi_is_ready_request_test.cc +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/commands/hmi/vi_is_ready_request_test.cc @@ -34,16 +34,16 @@ #include "gtest/gtest.h" -#include "smart_objects/smart_object.h" -#include "application_manager/smart_object_keys.h" -#include "application_manager/commands/command_request_test.h" -#include "application_manager/mock_application_manager.h" +#include "application_manager/event_engine/event.h" #include "application_manager/hmi_interfaces.h" -#include "application_manager/mock_hmi_interface.h" +#include "application_manager/mock_application_manager.h" #include "application_manager/mock_hmi_capabilities.h" -#include "application_manager/policies/mock_policy_handler_interface.h" +#include "application_manager/mock_hmi_interface.h" #include "application_manager/mock_message_helper.h" -#include "application_manager/event_engine/event.h" +#include "application_manager/policies/mock_policy_handler_interface.h" +#include "application_manager/smart_object_keys.h" +#include "smart_objects/smart_object.h" +#include "vehicle_info_plugin/commands/vi_command_request_test.h" namespace test { namespace components { @@ -52,19 +52,19 @@ namespace hmi_commands_test { namespace vi_is_ready_request { using ::testing::_; -using ::testing::ReturnRef; using ::testing::Return; +using ::testing::ReturnRef; namespace am = ::application_manager; using am::commands::MessageSharedPtr; -using vehicle_info_plugin::commands::VIIsReadyRequest; using am::event_engine::Event; +using vehicle_info_plugin::commands::VIIsReadyRequest; typedef std::shared_ptr VIIsReadyRequestPtr; class VIIsReadyRequestTest - : public CommandRequestTest { + : public VICommandRequestTest { public: - VIIsReadyRequestTest() : command_(CreateCommand()) {} + VIIsReadyRequestTest() : command_(CreateCommandVI()) {} void SetUpExpectations(bool is_vi_cooperating_available, bool is_send_message_to_hmi, diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/commands/hmi/vi_subscribe_vehicle_data_request_test.cc b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/commands/hmi/vi_subscribe_vehicle_data_request_test.cc new file mode 100644 index 00000000000..fbaabfed06b --- /dev/null +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/commands/hmi/vi_subscribe_vehicle_data_request_test.cc @@ -0,0 +1,110 @@ +/* + * Copyright (c) 2019, 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 "hmi/vi_subscribe_vehicle_data_request.h" + +#include "gtest/gtest.h" + +#include "smart_objects/enum_schema_item.h" +#include "smart_objects/smart_object.h" +#include "vehicle_info_plugin/commands/vi_command_request_test.h" + +namespace test { +namespace components { +namespace commands_test { +namespace hmi_commands_test { +namespace vi_subscribe_vehicle_data_request { + +using ::testing::_; +using ::testing::Return; +using ::testing::ReturnRef; + +using vehicle_info_plugin::commands::VISubscribeVehicleDataRequest; + +namespace { +const std::string kMobileParam = "mobile_param"; +const std::string kHMIParam = "hmi_param"; +} // namespace + +class VISubscribeVehicleDataRequestTest + : public VICommandRequestTest {}; + +MATCHER_P(EqualMsgParams, msg_params, "") { + using namespace app_mngr; + auto message = static_cast(*arg); + if (!message.keyExists(strings::msg_params)) { + return false; + } + + return msg_params == message[strings::msg_params]; +} + +TEST_F(VISubscribeVehicleDataRequestTest, Run_Success) { + using namespace app_mngr; + auto command_msg = CreateMessage(smart_objects::SmartType_Map); + (*command_msg)[strings::msg_params][strings::rpm] = true; + (*command_msg)[strings::msg_params][kMobileParam] = true; + + am::VehicleData vehicle_data; + vehicle_data.insert(am::VehicleData::value_type( + strings::rpm, mobile_apis::VehicleDataType::VEHICLEDATA_RPM)); + ON_CALL(mock_message_helper_, vehicle_data()) + .WillByDefault(ReturnRef(vehicle_data)); + + std::string oem_vehicle_data_type_str; + smart_objects::EnumConversionHelper:: + EnumToString(mobile_apis::VehicleDataType::VEHICLEDATA_OEM_CUSTOM_DATA, + &oem_vehicle_data_type_str); + + smart_objects::SmartObject hmi_params; + hmi_params[kHMIParam] = smart_objects::SmartType_Map; + hmi_params[kHMIParam][strings::data_type] = oem_vehicle_data_type_str; + ON_CALL(mock_custom_vehicle_data_manager_, CreateHMIMessageParams(_)) + .WillByDefault(Return(hmi_params)); + + smart_objects::SmartObject hmi_request_msg; + hmi_request_msg[strings::rpm] = + (*command_msg)[strings::msg_params][strings::rpm]; + hmi_request_msg[kHMIParam] = hmi_params[kHMIParam]; + + EXPECT_CALL(mock_rpc_service_, + SendMessageToHMI(EqualMsgParams(hmi_request_msg))); + + auto command = CreateCommandVI(command_msg); + command->Run(); +} + +} // namespace vi_subscribe_vehicle_data_request +} // namespace hmi_commands_test +} // namespace commands_test +} // namespace components +} // namespace test diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/commands/hmi/vi_unsubscribe_vehicle_data_request_test.cc b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/commands/hmi/vi_unsubscribe_vehicle_data_request_test.cc new file mode 100644 index 00000000000..2ce04aa21ae --- /dev/null +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/commands/hmi/vi_unsubscribe_vehicle_data_request_test.cc @@ -0,0 +1,109 @@ +/* + * Copyright (c) 2019, 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 "hmi/vi_unsubscribe_vehicle_data_request.h" + +#include "gtest/gtest.h" + +#include "smart_objects/enum_schema_item.h" +#include "smart_objects/smart_object.h" +#include "vehicle_info_plugin/commands/vi_command_request_test.h" + +namespace test { +namespace components { +namespace commands_test { +namespace hmi_commands_test { +namespace vi_unsubscribe_vehicle_data_request { + +using ::testing::_; +using ::testing::Return; +using ::testing::ReturnRef; + +using vehicle_info_plugin::commands::VIUnsubscribeVehicleDataRequest; + +namespace { +const std::string kMobileParam = "mobile_param"; +const std::string kHMIParam = "hmi_param"; +} // namespace + +class VIUnsubscribeVehicleDataRequestTest + : public VICommandRequestTest {}; + +MATCHER_P(EqualMsgParams, msg_params, "") { + using namespace app_mngr; + auto message = static_cast(*arg); + if (!message.keyExists(strings::msg_params)) { + return false; + } + + return msg_params == message[strings::msg_params]; +} + +TEST_F(VIUnsubscribeVehicleDataRequestTest, Run_Success) { + using namespace app_mngr; + auto command_msg = CreateMessage(smart_objects::SmartType_Map); + (*command_msg)[strings::msg_params][strings::rpm] = true; + (*command_msg)[strings::msg_params][kMobileParam] = true; + + am::VehicleData vehicle_data; + vehicle_data.insert(am::VehicleData::value_type( + strings::rpm, mobile_apis::VehicleDataType::VEHICLEDATA_RPM)); + ON_CALL(mock_message_helper_, vehicle_data()) + .WillByDefault(ReturnRef(vehicle_data)); + + std::string oem_vehicle_data_type_str; + smart_objects::EnumConversionHelper:: + EnumToString(mobile_apis::VehicleDataType::VEHICLEDATA_OEM_CUSTOM_DATA, + &oem_vehicle_data_type_str); + + smart_objects::SmartObject hmi_params; + hmi_params[kHMIParam] = smart_objects::SmartType_Map; + hmi_params[kHMIParam][strings::data_type] = oem_vehicle_data_type_str; + ON_CALL(mock_custom_vehicle_data_manager_, CreateHMIMessageParams(_)) + .WillByDefault(Return(hmi_params)); + + smart_objects::SmartObject hmi_request_msg; + hmi_request_msg[strings::rpm] = true; + hmi_request_msg[kHMIParam] = true; + + EXPECT_CALL(mock_rpc_service_, + SendMessageToHMI(EqualMsgParams(hmi_request_msg))); + + auto command = CreateCommandVI(command_msg); + command->Run(); +} + +} // namespace vi_unsubscribe_vehicle_data_request +} // namespace hmi_commands_test +} // namespace commands_test +} // namespace components +} // namespace test diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/commands/mobile/diagnostic_message_request_test.cc b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/commands/mobile/diagnostic_message_request_test.cc index b27a306a5c9..afafd1c6c6a 100644 --- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/commands/mobile/diagnostic_message_request_test.cc +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/commands/mobile/diagnostic_message_request_test.cc @@ -36,17 +36,17 @@ #include "gtest/gtest.h" -#include "smart_objects/smart_object.h" -#include "application_manager/smart_object_keys.h" -#include "application_manager/commands/commands_test.h" -#include "application_manager/commands/command_request_test.h" #include "application_manager/application.h" -#include "application_manager/mock_application_manager.h" -#include "application_manager/mock_application.h" #include "application_manager/event_engine/event.h" +#include "application_manager/mock_application.h" +#include "application_manager/mock_application_manager.h" #include "application_manager/mock_message_helper.h" +#include "application_manager/smart_object_keys.h" #include "interfaces/MOBILE_API.h" +#include "smart_objects/smart_object.h" #include "vehicle_info_plugin/commands/mobile/diagnostic_message_request.h" +#include "vehicle_info_plugin/commands/vi_command_request_test.h" +#include "vehicle_info_plugin/mock_custom_vehicle_data_manager.h" namespace test { namespace components { @@ -59,8 +59,8 @@ using ::testing::Return; using ::testing::ReturnRef; namespace am = ::application_manager; using am::commands::MessageSharedPtr; -using vehicle_info_plugin::commands::DiagnosticMessageRequest; using am::event_engine::Event; +using vehicle_info_plugin::commands::DiagnosticMessageRequest; namespace mobile_result = mobile_apis::Result; typedef std::shared_ptr DiagnosticMessageRequestPtr; @@ -71,7 +71,7 @@ const uint32_t kDiagnosticMode = 5u; } // namespace class DiagnosticMessageRequestTest - : public CommandRequestTest {}; + : public VICommandRequestTest {}; TEST_F(DiagnosticMessageRequestTest, Run_ApplicationIsNotRegistered_UNSUCCESS) { MessageSharedPtr command_msg(CreateMessage(smart_objects::SmartType_Map)); @@ -79,7 +79,7 @@ TEST_F(DiagnosticMessageRequestTest, Run_ApplicationIsNotRegistered_UNSUCCESS) { kConnectionKey; DiagnosticMessageRequestPtr command( - CreateCommand(command_msg)); + CreateCommandVI(command_msg)); EXPECT_CALL(app_mngr_, application(kConnectionKey)) .WillOnce(Return(ApplicationSharedPtr())); @@ -100,7 +100,7 @@ TEST_F(DiagnosticMessageRequestTest, Run_NotSupportedDiagnosticMode_UNSUCCESS) { kConnectionKey; DiagnosticMessageRequestPtr command( - CreateCommand(command_msg)); + CreateCommandVI(command_msg)); MockAppPtr app(CreateMockApp()); EXPECT_CALL(app_mngr_, application(kConnectionKey)).WillOnce(Return(app)); @@ -127,7 +127,7 @@ TEST_F(DiagnosticMessageRequestTest, Run_SUCCESS) { kConnectionKey; DiagnosticMessageRequestPtr command( - CreateCommand(command_msg)); + CreateCommandVI(command_msg)); MockAppPtr app(CreateMockApp()); EXPECT_CALL(app_mngr_, application(kConnectionKey)).WillOnce(Return(app)); @@ -154,7 +154,7 @@ TEST_F(DiagnosticMessageRequestTest, OnEvent_UNSUCCESS) { Event event(hmi_apis::FunctionID::INVALID_ENUM); DiagnosticMessageRequestPtr command( - CreateCommand()); + CreateCommandVI()); EXPECT_CALL(mock_rpc_service_, ManageMobileCommand(_, _)).Times(0); @@ -171,7 +171,7 @@ TEST_F(DiagnosticMessageRequestTest, OnEvent_SUCCESS) { event.set_smart_object(*event_message); DiagnosticMessageRequestPtr command( - CreateCommand()); + CreateCommandVI()); EXPECT_CALL( mock_rpc_service_, diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/commands/mobile/get_dtcs_request_test.cc b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/commands/mobile/get_dtcs_request_test.cc index 981d649a941..e4613feb833 100644 --- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/commands/mobile/get_dtcs_request_test.cc +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/commands/mobile/get_dtcs_request_test.cc @@ -36,17 +36,16 @@ #include "gtest/gtest.h" -#include "smart_objects/smart_object.h" -#include "application_manager/smart_object_keys.h" -#include "application_manager/commands/commands_test.h" -#include "application_manager/commands/command_request_test.h" #include "application_manager/application.h" -#include "application_manager/mock_application_manager.h" -#include "application_manager/mock_application.h" #include "application_manager/event_engine/event.h" -#include "mobile/get_dtcs_request.h" +#include "application_manager/mock_application.h" +#include "application_manager/mock_application_manager.h" #include "application_manager/mock_message_helper.h" +#include "application_manager/smart_object_keys.h" #include "interfaces/MOBILE_API.h" +#include "mobile/get_dtcs_request.h" +#include "smart_objects/smart_object.h" +#include "vehicle_info_plugin/commands/vi_command_request_test.h" namespace test { namespace components { @@ -57,23 +56,23 @@ namespace get_dtcs_request { using ::testing::_; using ::testing::Return; namespace am = ::application_manager; +using am::MockMessageHelper; using am::commands::MessageSharedPtr; -using vehicle_info_plugin::commands::GetDTCsRequest; using am::event_engine::Event; -using am::MockMessageHelper; using testing::Mock; +using vehicle_info_plugin::commands::GetDTCsRequest; namespace mobile_result = mobile_apis::Result; typedef std::shared_ptr GetDTCsRequestPtr; class GetDTCsRequestTest - : public CommandRequestTest { + : public VICommandRequestTest { public: - GetDTCsRequestTest() : CommandRequestTest() {} + GetDTCsRequestTest() : VICommandRequestTest() {} }; TEST_F(GetDTCsRequestTest, Run_ApplicationIsNotRegistered_UNSUCCESS) { - GetDTCsRequestPtr command(CreateCommand()); + GetDTCsRequestPtr command(CreateCommandVI()); EXPECT_CALL(app_mngr_, application(_)) .WillOnce(Return(ApplicationSharedPtr())); @@ -93,7 +92,7 @@ TEST_F(GetDTCsRequestTest, Run_SUCCESS) { (*command_msg)[am::strings::params][am::strings::connection_key] = kConnectionKey; - GetDTCsRequestPtr command(CreateCommand(command_msg)); + GetDTCsRequestPtr command(CreateCommandVI(command_msg)); MockAppPtr app(CreateMockApp()); EXPECT_CALL(app_mngr_, application(kConnectionKey)).WillOnce(Return(app)); @@ -107,7 +106,7 @@ TEST_F(GetDTCsRequestTest, Run_SUCCESS) { } TEST_F(GetDTCsRequestTest, OnEvent_UnknownEvent_UNSUCCESS) { - GetDTCsRequestPtr command(CreateCommand()); + GetDTCsRequestPtr command(CreateCommandVI()); Event event(hmi_apis::FunctionID::INVALID_ENUM); @@ -132,7 +131,7 @@ TEST_F(GetDTCsRequestTest, OnEvent_SUCCESS) { MockAppPtr app(CreateMockApp()); EXPECT_CALL(app_mngr_, application(_)).WillRepeatedly(Return(app)); - GetDTCsRequestPtr command(CreateCommand()); + GetDTCsRequestPtr command(CreateCommandVI()); command->on_event(event); } diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/commands/mobile/get_vehicle_data_request_test.cc b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/commands/mobile/get_vehicle_data_request_test.cc index cb78e449042..d27e3326010 100644 --- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/commands/mobile/get_vehicle_data_request_test.cc +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/commands/mobile/get_vehicle_data_request_test.cc @@ -36,17 +36,17 @@ #include "gtest/gtest.h" -#include "smart_objects/smart_object.h" -#include "application_manager/smart_object_keys.h" -#include "application_manager/commands/commands_test.h" -#include "application_manager/commands/command_request_test.h" #include "application_manager/application.h" +#include "application_manager/event_engine/event.h" #include "application_manager/message_helper.h" -#include "application_manager/mock_message_helper.h" #include "application_manager/mock_application_manager.h" -#include "application_manager/event_engine/event.h" -#include "mobile/get_vehicle_data_request.h" +#include "application_manager/mock_message_helper.h" +#include "application_manager/smart_object_keys.h" #include "interfaces/MOBILE_API.h" +#include "mobile/get_vehicle_data_request.h" +#include "smart_objects/smart_object.h" +#include "vehicle_info_plugin/commands/vi_command_request_test.h" +#include "vehicle_info_plugin/vehicle_info_command_params.h" namespace test { namespace components { @@ -59,8 +59,8 @@ using ::testing::Return; using ::testing::ReturnRef; namespace am = ::application_manager; using am::commands::MessageSharedPtr; -using vehicle_info_plugin::commands::GetVehicleDataRequest; using am::event_engine::Event; +using vehicle_info_plugin::commands::GetVehicleDataRequest; namespace mobile_result = mobile_apis::Result; typedef std::shared_ptr GetVehicleDataRequestPtr; @@ -70,20 +70,14 @@ const uint32_t kConnectionKey = 2u; } // namespace class GetVehicleDataRequestTest - : public CommandRequestTest {}; + : public VICommandRequestTest {}; class UnwrappedGetVehicleDataRequest : public GetVehicleDataRequest { public: - UnwrappedGetVehicleDataRequest(const MessageSharedPtr& message, - am::ApplicationManager& application_manager, - app_mngr::rpc_service::RPCService& rpc_service, - app_mngr::HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handler) - : GetVehicleDataRequest(message, - application_manager, - rpc_service, - hmi_capabilities, - policy_handler) {} + UnwrappedGetVehicleDataRequest( + const MessageSharedPtr& message, + const vehicle_info_plugin::VehicleInfoCommandParams& params) + : GetVehicleDataRequest(message, params) {} policy::RPCParams& get_disallowed_params() { return removed_parameters_permissions_.disallowed_params; @@ -93,7 +87,7 @@ class UnwrappedGetVehicleDataRequest : public GetVehicleDataRequest { }; TEST_F(GetVehicleDataRequestTest, Run_ApplicationIsNotRegistered_UNSUCCESS) { - GetVehicleDataRequestPtr command(CreateCommand()); + GetVehicleDataRequestPtr command(CreateCommandVI()); EXPECT_CALL(app_mngr_, application(_)) .WillOnce(Return(ApplicationSharedPtr())); @@ -115,7 +109,7 @@ TEST_F(GetVehicleDataRequestTest, Run_TooHighFrequency_UNSUCCESS) { kConnectionKey; GetVehicleDataRequestPtr command( - CreateCommand(command_msg)); + CreateCommandVI(command_msg)); MockAppPtr app(CreateMockApp()); EXPECT_CALL(app_mngr_, application(kConnectionKey)).WillOnce(Return(app)); @@ -138,14 +132,17 @@ TEST_F(GetVehicleDataRequestTest, Run_EmptyMsgParams_UNSUCCESS) { kConnectionKey; GetVehicleDataRequestPtr command( - CreateCommand(command_msg)); + CreateCommandVI(command_msg)); const am::VehicleData kEmptyVehicleData; - EXPECT_CALL(mock_message_helper_, vehicle_data()) - .WillOnce(ReturnRef(kEmptyVehicleData)); + ON_CALL(mock_message_helper_, vehicle_data()) + .WillByDefault(ReturnRef(kEmptyVehicleData)); + smart_objects::SmartObject empty_hmi_custom_params; + ON_CALL(mock_custom_vehicle_data_manager_, CreateHMIMessageParams(_)) + .WillByDefault(Return(empty_hmi_custom_params)); MockAppPtr app(CreateMockApp()); - EXPECT_CALL(app_mngr_, application(kConnectionKey)).WillOnce(Return(app)); + ON_CALL(app_mngr_, application(kConnectionKey)).WillByDefault(Return(app)); EXPECT_CALL( mock_rpc_service_, @@ -161,11 +158,15 @@ TEST_F(GetVehicleDataRequestTest, kConnectionKey; std::shared_ptr command( - CreateCommand(command_msg)); + CreateCommandVI(command_msg)); + + smart_objects::SmartObject empty_hmi_custom_params; + ON_CALL(mock_custom_vehicle_data_manager_, CreateHMIMessageParams(_)) + .WillByDefault(Return(empty_hmi_custom_params)); const am::VehicleData kEmptyVehicleData; - EXPECT_CALL(mock_message_helper_, vehicle_data()) - .WillRepeatedly(ReturnRef(kEmptyVehicleData)); + ON_CALL(mock_message_helper_, vehicle_data()) + .WillByDefault(ReturnRef(kEmptyVehicleData)); policy::RPCParams& disallowed_params = command->get_disallowed_params(); disallowed_params.insert("test_param"); @@ -189,13 +190,13 @@ TEST_F(GetVehicleDataRequestTest, Run_SUCCESS) { (*command_msg)[am::strings::msg_params][kMsgParamKey] = true; GetVehicleDataRequestPtr command( - CreateCommand(command_msg)); + CreateCommandVI(command_msg)); am::VehicleData vehicle_data; vehicle_data.insert(am::VehicleData::value_type( kMsgParamKey, mobile_apis::VehicleDataType::VEHICLEDATA_SPEED)); - EXPECT_CALL(mock_message_helper_, vehicle_data()) - .WillOnce(ReturnRef(vehicle_data)); + ON_CALL(mock_message_helper_, vehicle_data()) + .WillByDefault(ReturnRef(vehicle_data)); MockAppPtr app(CreateMockApp()); EXPECT_CALL(app_mngr_, application(kConnectionKey)).WillOnce(Return(app)); @@ -215,7 +216,7 @@ TEST_F(GetVehicleDataRequestTest, OnEvent_UnknownEvent_UNSUCCESS) { kConnectionKey; std::shared_ptr command( - CreateCommand(command_msg)); + CreateCommandVI(command_msg)); Event event(hmi_apis::FunctionID::INVALID_ENUM); @@ -228,14 +229,18 @@ TEST_F(GetVehicleDataRequestTest, OnEvent_DataNotAvailable_SUCCESS) { const hmi_apis::Common_Result::eType hmi_response_code = hmi_apis::Common_Result::DATA_NOT_AVAILABLE; const mobile_result::eType mobile_response_code = - mobile_result::DATA_NOT_AVAILABLE; + mobile_result::VEHICLE_DATA_NOT_AVAILABLE; + + am::VehicleData vehicle_data; + ON_CALL(mock_message_helper_, vehicle_data()) + .WillByDefault(ReturnRef(vehicle_data)); MessageSharedPtr command_msg(CreateMessage(smart_objects::SmartType_Map)); (*command_msg)[am::strings::params][am::strings::connection_key] = kConnectionKey; std::shared_ptr command( - CreateCommand(command_msg)); + CreateCommandVI(command_msg)); MessageSharedPtr event_msg(CreateMessage(smart_objects::SmartType_Map)); (*event_msg)[am::strings::params][am::hmi_response::code] = hmi_response_code; diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/commands/mobile/get_vehicle_data_response_test.cc b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/commands/mobile/get_vehicle_data_response_test.cc new file mode 100644 index 00000000000..ad7a14ce40f --- /dev/null +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/commands/mobile/get_vehicle_data_response_test.cc @@ -0,0 +1,69 @@ +/* + * Copyright (c) 2019, 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 "application_manager/commands/commands_test.h" +#include "vehicle_info_plugin/commands/vi_commands_test.h" + +#include "mobile/get_vehicle_data_response.h" +#include "smart_objects/smart_object.h" + +namespace test { +namespace components { +namespace commands_test { +namespace mobile_commands_test { +namespace get_vehicle_data_response { + +namespace am = ::application_manager; +using am::commands::MessageSharedPtr; +using vehicle_info_plugin::commands::GetVehicleDataResponse; + +typedef std::shared_ptr GetVehicleDataResponsePtr; + +class GetVehicleDataResponseTest + : public VICommandsTest {}; + +TEST_F(GetVehicleDataResponseTest, GetVehicleDataResponse_SUCCESS) { + MessageSharedPtr message(CreateMessage(smart_objects::SmartType_Map)); + GetVehicleDataResponsePtr command( + CreateCommandVI(message)); + + EXPECT_CALL(mock_rpc_service_, SendMessageToMobile(message, _)); + command->Run(); +} + +} // namespace get_vehicle_data_response +} // namespace mobile_commands_test +} // namespace commands_test +} // namespace components +} // namespace test diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/commands/mobile/on_vehicle_data_notification_test.cc b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/commands/mobile/on_vehicle_data_notification_test.cc index 1e8a2896375..82eb19c45f9 100644 --- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/commands/mobile/on_vehicle_data_notification_test.cc +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/commands/mobile/on_vehicle_data_notification_test.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Ford Motor Company + * Copyright (c) 2019, Ford Motor Company * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -30,21 +30,22 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include -#include -#include +#include #include "gtest/gtest.h" #include "mobile/on_vehicle_data_notification.h" -#include "utils/custom_string.h" -#include "smart_objects/smart_object.h" -#include "application_manager/smart_object_keys.h" -#include "application_manager/commands/commands_test.h" #include "application_manager/commands/command_impl.h" +#include "application_manager/commands/commands_test.h" #include "application_manager/message_helper.h" #include "application_manager/mock_message_helper.h" +#include "application_manager/smart_object_keys.h" +#include "smart_objects/smart_object.h" +#include "utils/custom_string.h" #include "utils/helpers.h" +#include "vehicle_info_plugin/commands/vi_commands_test.h" +#include "vehicle_info_plugin/vehicle_info_app_extension.h" +#include "vehicle_info_plugin/vehicle_info_plugin.h" namespace test { namespace components { @@ -62,49 +63,75 @@ using am::commands::MessageSharedPtr; using vehicle_info_plugin::commands::OnVehicleDataNotification; typedef std::shared_ptr NotificationPtr; +typedef std::shared_ptr + VehicleInfoAppExtensionPtr; +typedef DataAccessor ApplicationSetDA; namespace { const uint32_t kAppId = 1u; +const utils::custom_string::CustomString kAppName("test_app"); } // namespace class OnVehicleDataNotificationTest - : public CommandsTest { + : public VICommandsTest { public: - OnVehicleDataNotificationTest() - : command_msg_(CreateMessage(smart_objects::SmartType_Map)) - , command_(CreateCommand(command_msg_)) {} + OnVehicleDataNotificationTest() : mock_app_(CreateMockApp()) {} + + protected: + void SetUp() OVERRIDE { + ON_CALL(*mock_app_, app_id()).WillByDefault(Return(kAppId)); + ON_CALL(*mock_app_, name()).WillByDefault(ReturnRef(kAppName)); - MessageSharedPtr command_msg_; - NotificationPtr command_; + ON_CALL(mock_message_helper_, PrintSmartObject(_)) + .WillByDefault(Return(false)); + } + MockAppPtr mock_app_; }; -MATCHER_P2(CheckMessageData, key, value, "") { - const bool kIsMobileProtocolTypeCorrect = - (*arg)[am::strings::params][am::strings::protocol_type].asInt() == - am::commands::CommandImpl::mobile_protocol_type_; - - const bool kIsProtocolVersionCorrect = - (*arg)[am::strings::params][am::strings::protocol_version].asInt() == - am::commands::CommandImpl::protocol_version_; - - const bool kIsNotificationCorrect = - (*arg)[am::strings::params][am::strings::message_type].asInt() == - am::MessageType::kNotification; - - const bool kIsConnectionKeyCorrect = - (*arg)[am::strings::params][am::strings::connection_key].asUInt() == - kAppId; - - const bool kAreMsgParamsCorrect = - (*arg)[am::strings::msg_params][key].asInt() == value; - - using namespace helpers; - return Compare(true, - kIsMobileProtocolTypeCorrect, - kIsProtocolVersionCorrect, - kIsNotificationCorrect, - kIsConnectionKeyCorrect, - kAreMsgParamsCorrect); +MATCHER_P(SmartObjectCheck, checker, "") { + return checker(arg); +} + +TEST_F(OnVehicleDataNotificationTest, OnVehicleDataNotification_SUCCESS) { + am::VehicleData vehicle_data; + vehicle_data.insert(am::VehicleData::value_type( + am::strings::gps, mobile_apis::VehicleDataType::VEHICLEDATA_GPS)); + vehicle_data.insert(am::VehicleData::value_type( + am::strings::speed, mobile_apis::VehicleDataType::VEHICLEDATA_SPEED)); + ON_CALL(mock_message_helper_, vehicle_data()) + .WillByDefault(ReturnRef(vehicle_data)); + + application_manager::ApplicationSet apps; + apps.insert(mock_app_); + std::shared_ptr apps_lock = + std::make_shared(); + ApplicationSetDA apps_da(apps, apps_lock); + ON_CALL(app_mngr_, applications()).WillByDefault(Return(apps_da)); + + vehicle_info_plugin::VehicleInfoPlugin vi_plugin; + VehicleInfoAppExtensionPtr vi_app_extention_ptr = + std::make_shared( + vi_plugin, *mock_app_); + vi_app_extention_ptr->subscribeToVehicleInfo("gps"); + vi_app_extention_ptr->subscribeToVehicleInfo("speed"); + ON_CALL(*mock_app_, + QueryInterface(vehicle_info_plugin::VehicleInfoAppExtension:: + VehicleInfoAppExtensionUID)) + .WillByDefault(Return(vi_app_extention_ptr)); + + MessageSharedPtr message(CreateMessage(smart_objects::SmartType_Map)); + smart_objects::SmartObject gps_data; + gps_data[am::strings::longitude_degrees] = 1.0; + gps_data[am::strings::latitude_degrees] = 1.0; + gps_data[am::strings::shifted] = true; + + (*message)[am::strings::msg_params][am::strings::gps] = gps_data; + (*message)[am::strings::msg_params][am::strings::speed] = 0; + + NotificationPtr command(CreateCommandVI(message)); + EXPECT_CALL(mock_rpc_service_, SendMessageToMobile(message, _)); + + command->Run(); } } // namespace on_vehicle_data_notification diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/commands/mobile/read_did_request_test.cc b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/commands/mobile/read_did_request_test.cc index c0a07fb57ca..372d5629657 100644 --- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/commands/mobile/read_did_request_test.cc +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/commands/mobile/read_did_request_test.cc @@ -35,18 +35,17 @@ #include "gtest/gtest.h" -#include "smart_objects/smart_object.h" -#include "application_manager/commands/commands_test.h" -#include "application_manager/commands/command_request_test.h" #include "application_manager/application.h" -#include "application_manager/mock_application_manager.h" +#include "application_manager/event_engine/event.h" #include "application_manager/mock_application.h" +#include "application_manager/mock_application_manager.h" #include "application_manager/mock_message_helper.h" -#include "interfaces/MOBILE_API.h" -#include "interfaces/HMI_API.h" #include "application_manager/smart_object_keys.h" -#include "application_manager/event_engine/event.h" +#include "interfaces/HMI_API.h" +#include "interfaces/MOBILE_API.h" +#include "smart_objects/smart_object.h" #include "vehicle_info_plugin/commands/mobile/read_did_request.h" +#include "vehicle_info_plugin/commands/vi_command_request_test.h" namespace test { namespace components { @@ -59,16 +58,16 @@ using ::testing::DoAll; using ::testing::Return; using ::testing::SaveArg; namespace am = ::application_manager; -using vehicle_info_plugin::commands::ReadDIDRequest; using am::commands::MessageSharedPtr; using am::event_engine::Event; +using vehicle_info_plugin::commands::ReadDIDRequest; class ReadDIDRequestTest - : public CommandRequestTest {}; + : public VICommandRequestTest {}; TEST_F(ReadDIDRequestTest, OnEvent_WrongEventId_UNSUCCESS) { Event event(Event::EventID::INVALID_ENUM); - std::shared_ptr command(CreateCommand()); + std::shared_ptr command(CreateCommandVI()); EXPECT_CALL(mock_rpc_service_, ManageMobileCommand(_, _)).Times(0); command->on_event(event); } @@ -76,7 +75,7 @@ TEST_F(ReadDIDRequestTest, OnEvent_WrongEventId_UNSUCCESS) { TEST_F(ReadDIDRequestTest, OnEvent_SUCCESS) { Event event(Event::EventID::VehicleInfo_ReadDID); - std::shared_ptr command(CreateCommand()); + std::shared_ptr command(CreateCommandVI()); const hmi_apis::Common_Result::eType hmi_response_code = hmi_apis::Common_Result::SUCCESS; @@ -98,7 +97,7 @@ TEST_F(ReadDIDRequestTest, OnEvent_SUCCESS) { } TEST_F(ReadDIDRequestTest, Run_AppNotRegistered_UNSUCCESS) { - std::shared_ptr command(CreateCommand()); + std::shared_ptr command(CreateCommandVI()); ON_CALL(app_mngr_, application(_)) .WillByDefault(Return(std::shared_ptr())); @@ -111,7 +110,7 @@ TEST_F(ReadDIDRequestTest, Run_AppNotRegistered_UNSUCCESS) { } TEST_F(ReadDIDRequestTest, Run_CommandLimitsExceeded_UNSUCCESS) { - std::shared_ptr command(CreateCommand()); + std::shared_ptr command(CreateCommandVI()); MockAppPtr app(CreateMockApp()); ON_CALL(app_mngr_, application(_)).WillByDefault(Return(app)); @@ -127,7 +126,7 @@ TEST_F(ReadDIDRequestTest, Run_CommandLimitsExceeded_UNSUCCESS) { TEST_F(ReadDIDRequestTest, Run_EmptyDidLocation_UNSUCCESS) { MockAppPtr app(CreateMockApp()); - std::shared_ptr command(CreateCommand()); + std::shared_ptr command(CreateCommandVI()); ON_CALL(app_mngr_, application(_)).WillByDefault(Return(app)); @@ -144,7 +143,7 @@ TEST_F(ReadDIDRequestTest, Run_SUCCESS) { MockAppPtr app(CreateMockApp()); MessageSharedPtr msg(CreateMessage(smart_objects::SmartType_Map)); (*msg)[am::strings::msg_params][am::strings::did_location]["SomeData"] = 0; - std::shared_ptr command(CreateCommand(msg)); + std::shared_ptr command(CreateCommandVI(msg)); ON_CALL(app_mngr_, application(_)).WillByDefault(Return(app)); diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/commands/mobile/unsubscribe_vehicle_request_test.cc b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/commands/mobile/unsubscribe_vehicle_request_test.cc index 165c7694b13..3a200ff2825 100644 --- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/commands/mobile/unsubscribe_vehicle_request_test.cc +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/commands/mobile/unsubscribe_vehicle_request_test.cc @@ -39,8 +39,12 @@ #include "application_manager/mock_application_manager.h" #include "application_manager/mock_message_helper.h" #include "mobile/unsubscribe_vehicle_data_request.h" -#include "vehicle_info_plugin/vehicle_info_plugin.h" +#include "resumption/mock_last_state.h" +#include "vehicle_info_plugin/commands/vi_command_request_test.h" #include "vehicle_info_plugin/vehicle_info_app_extension.h" +#include "vehicle_info_plugin/vehicle_info_plugin.h" + +#include "application_manager/mock_rpc_handler.h" namespace test { namespace components { @@ -53,8 +57,8 @@ namespace mobile_result = mobile_apis::Result; using ::testing::_; -using vehicle_info_plugin::commands::UnsubscribeVehicleDataRequest; using am::commands::MessageSharedPtr; +using vehicle_info_plugin::commands::UnsubscribeVehicleDataRequest; typedef std::shared_ptr CommandPtr; @@ -63,10 +67,11 @@ const uint32_t kConnectionKey = 1u; const std::string kMsgParamKey = "test_key"; const mobile_apis::VehicleDataType::eType kVehicleType = mobile_apis::VehicleDataType::VEHICLEDATA_SPEED; +const std::string kVehicleTypeStr = am::strings::speed; } // namespace class UnsubscribeVehicleRequestTest - : public CommandRequestTest { + : public VICommandRequestTest { public: UnsubscribeVehicleRequestTest() : mock_app_(CreateMockApp()) @@ -78,10 +83,14 @@ class UnsubscribeVehicleRequestTest protected: void UnsubscribeSuccessfully(); void SetUp() OVERRIDE { + ON_CALL(app_mngr_, GetRPCHandler()) + .WillByDefault(ReturnRef(mock_rpc_handler_)); + vi_plugin_.Init(app_mngr_, mock_rpc_service_, mock_hmi_capabilities_, - mock_policy_handler_); + mock_policy_handler_, + mock_last_state_); ON_CALL(*mock_app_, AddExtension(vi_app_extension_ptr_)); vi_plugin_.OnApplicationEvent(application_manager::plugin_manager:: ApplicationEvent::kApplicationRegistered, @@ -90,16 +99,19 @@ class UnsubscribeVehicleRequestTest QueryInterface(vehicle_info_plugin::VehicleInfoAppExtension:: VehicleInfoAppExtensionUID)) .WillByDefault(Return(vi_app_extension_ptr_)); + ON_CALL(*mock_app_, app_id()).WillByDefault(Return(kConnectionKey)); } MockAppPtr mock_app_; application_manager::AppExtensionPtr vi_app_extension_ptr_; std::shared_ptr app_set_lock_ptr_; vehicle_info_plugin::VehicleInfoPlugin vi_plugin_; + application_manager_test::MockRPCHandler mock_rpc_handler_; + resumption_test::MockLastState mock_last_state_; }; TEST_F(UnsubscribeVehicleRequestTest, Run_AppNotRegistered_UNSUCCESS) { - CommandPtr command(CreateCommand()); + CommandPtr command(CreateCommandVI()); EXPECT_CALL(app_mngr_, application(_)) .WillOnce(Return(ApplicationSharedPtr())); @@ -117,11 +129,18 @@ TEST_F(UnsubscribeVehicleRequestTest, (*command_msg)[am::strings::params][am::strings::connection_key] = kConnectionKey; (*command_msg)[am::strings::msg_params][am::strings::button_name] = - kVehicleType; + kVehicleTypeStr; am::VehicleData data; - EXPECT_CALL(mock_message_helper_, vehicle_data()).WillOnce(ReturnRef(data)); - CommandPtr command(CreateCommand(command_msg)); + EXPECT_CALL(mock_message_helper_, vehicle_data()) + .WillRepeatedly(ReturnRef(data)); + + smart_objects::SmartObject empty_hmi_custom_params; + ON_CALL(mock_custom_vehicle_data_manager_, CreateHMIMessageParams(_)) + .WillByDefault(Return(empty_hmi_custom_params)); + + CommandPtr command( + CreateCommandVI(command_msg)); EXPECT_CALL(app_mngr_, application(kConnectionKey)) .WillOnce(Return(mock_app_)); @@ -138,12 +157,15 @@ TEST_F(UnsubscribeVehicleRequestTest, MessageSharedPtr command_msg(CreateMessage(smart_objects::SmartType_Map)); (*command_msg)[am::strings::params][am::strings::connection_key] = kConnectionKey; - (*command_msg)[am::strings::msg_params][kMsgParamKey] = true; + (*command_msg)[am::strings::msg_params][kVehicleTypeStr] = true; am::VehicleData vehicle_data; vehicle_data.insert(am::VehicleData::value_type(kMsgParamKey, kVehicleType)); - EXPECT_CALL(mock_message_helper_, vehicle_data()) - .WillOnce(ReturnRef(vehicle_data)); + ON_CALL(mock_message_helper_, vehicle_data()) + .WillByDefault(ReturnRef(vehicle_data)); + + smart_objects::SmartObject hmi_custom_params(smart_objects::SmartType_Map); + hmi_custom_params[kVehicleTypeStr] = true; EXPECT_CALL(app_mngr_, application(kConnectionKey)) .WillOnce(Return(mock_app_)); @@ -152,17 +174,19 @@ TEST_F(UnsubscribeVehicleRequestTest, ManageHMICommand( HMIResultCodeIs( hmi_apis::FunctionID::VehicleInfo_UnsubscribeVehicleData), - _)).WillOnce(Return(true)); + _)) + .WillOnce(Return(true)); vehicle_info_plugin::VehicleInfoAppExtension* vi_app_extension = dynamic_cast( vi_app_extension_ptr_.get()); - ASSERT_TRUE(vi_app_extension->subscribeToVehicleInfo(kVehicleType)); + ASSERT_TRUE(vi_app_extension->subscribeToVehicleInfo(kVehicleTypeStr)); application_manager::ApplicationSet app_set = {mock_app_}; DataAccessor accessor(app_set, app_set_lock_ptr_); // Expectations EXPECT_CALL(app_mngr_, applications()).WillRepeatedly(Return(accessor)); - CommandPtr command(CreateCommand(command_msg)); + CommandPtr command( + CreateCommandVI(command_msg)); command->Run(); } @@ -170,9 +194,12 @@ TEST_F(UnsubscribeVehicleRequestTest, Run_EmptyVehicleData_INVALID_DATA_SentToMobile) { am::VehicleData vehicle_data; EXPECT_CALL(mock_message_helper_, vehicle_data()) - .WillOnce(ReturnRef(vehicle_data)); + .WillRepeatedly(ReturnRef(vehicle_data)); + + smart_objects::SmartObject empty_hmi_custom_params; + ON_CALL(mock_custom_vehicle_data_manager_, CreateHMIMessageParams(_)) + .WillByDefault(Return(empty_hmi_custom_params)); - MockAppPtr mock_app(CreateMockApp()); EXPECT_CALL(app_mngr_, application(kConnectionKey)) .WillOnce(Return(mock_app_)); @@ -184,17 +211,21 @@ TEST_F(UnsubscribeVehicleRequestTest, (*command_msg)[am::strings::params][am::strings::connection_key] = kConnectionKey; (*command_msg)[am::strings::msg_params][kMsgParamKey] = false; - CommandPtr command(CreateCommand(command_msg)); + CommandPtr command( + CreateCommandVI(command_msg)); command->Run(); } TEST_F(UnsubscribeVehicleRequestTest, Run_UnsubscribeFromNotSubscribedBeforeData_UNSUCCESS) { + smart_objects::SmartObject empty_hmi_custom_params; + ON_CALL(mock_custom_vehicle_data_manager_, CreateHMIMessageParams(_)) + .WillByDefault(Return(empty_hmi_custom_params)); + am::VehicleData vehicle_data; vehicle_data.insert(am::VehicleData::value_type(kMsgParamKey, kVehicleType)); EXPECT_CALL(mock_message_helper_, vehicle_data()) - .WillOnce(ReturnRef(vehicle_data)); - + .WillRepeatedly(ReturnRef(vehicle_data)); EXPECT_CALL(app_mngr_, application(kConnectionKey)) .WillOnce(Return(mock_app_)); @@ -206,7 +237,8 @@ TEST_F(UnsubscribeVehicleRequestTest, (*command_msg)[am::strings::params][am::strings::connection_key] = kConnectionKey; (*command_msg)[am::strings::msg_params][kMsgParamKey] = true; - CommandPtr command(CreateCommand(command_msg)); + CommandPtr command( + CreateCommandVI(command_msg)); command->Run(); } @@ -215,15 +247,19 @@ TEST_F(UnsubscribeVehicleRequestTest, Run_UnsubscribeDataDisabled_UNSUCCESS) { (*command_msg)[am::strings::params][am::strings::connection_key] = kConnectionKey; + smart_objects::SmartObject empty_hmi_custom_params; + ON_CALL(mock_custom_vehicle_data_manager_, CreateHMIMessageParams(_)) + .WillByDefault(Return(empty_hmi_custom_params)); + + CommandPtr command( + CreateCommandVI(command_msg)); + am::VehicleData vehicle_data; vehicle_data.insert(am::VehicleData::value_type(kMsgParamKey, kVehicleType)); EXPECT_CALL(mock_message_helper_, vehicle_data()) - .WillOnce(ReturnRef(vehicle_data)); - CommandPtr command(CreateCommand(command_msg)); - - MockAppPtr mock_app(CreateMockApp()); + .WillRepeatedly(ReturnRef(vehicle_data)); EXPECT_CALL(app_mngr_, application(kConnectionKey)) - .WillOnce(Return(mock_app)); + .WillOnce(Return(mock_app_)); EXPECT_CALL( mock_rpc_service_, @@ -237,7 +273,8 @@ TEST_F(UnsubscribeVehicleRequestTest, OnEvent_DataNotSubscribed_IGNORED) { (*command_msg)[am::strings::params][am::strings::connection_key] = kConnectionKey; (*command_msg)[am::strings::msg_params][kMsgParamKey] = true; - CommandPtr command(CreateCommand(command_msg)); + CommandPtr command( + CreateCommandVI(command_msg)); am::VehicleData vehicle_data; @@ -245,7 +282,11 @@ TEST_F(UnsubscribeVehicleRequestTest, OnEvent_DataNotSubscribed_IGNORED) { .WillRepeatedly(Return(mock_app_)); vehicle_data.insert(am::VehicleData::value_type(kMsgParamKey, kVehicleType)); EXPECT_CALL(mock_message_helper_, vehicle_data()) - .WillOnce(ReturnRef(vehicle_data)); + .WillRepeatedly(ReturnRef(vehicle_data)); + + smart_objects::SmartObject empty_hmi_custom_params; + ON_CALL(mock_custom_vehicle_data_manager_, CreateHMIMessageParams(_)) + .WillByDefault(Return(empty_hmi_custom_params)); EXPECT_CALL( mock_rpc_service_, @@ -275,7 +316,8 @@ TEST_F(UnsubscribeVehicleRequestTest, OnEvent_DataUnsubscribed_SUCCESS) { (*command_msg)[am::strings::params][am::strings::connection_key] = kConnectionKey; (*command_msg)[am::strings::msg_params][kMsgParamKey] = true; - CommandPtr command(CreateCommand(command_msg)); + CommandPtr command( + CreateCommandVI(command_msg)); EXPECT_CALL(app_mngr_, application(kConnectionKey)) .WillRepeatedly(Return(mock_app_)); @@ -288,6 +330,11 @@ TEST_F(UnsubscribeVehicleRequestTest, OnEvent_DataUnsubscribed_SUCCESS) { message[am::strings::msg_params][kMsgParamKey] = true; test_event.set_smart_object(message); + am::VehicleData vehicle_data; + vehicle_data.insert(am::VehicleData::value_type(kMsgParamKey, kVehicleType)); + EXPECT_CALL(mock_message_helper_, vehicle_data()) + .WillRepeatedly(ReturnRef(vehicle_data)); + EXPECT_CALL( mock_rpc_service_, ManageMobileCommand(MobileResultCodeIs(mobile_result::SUCCESS), _)); diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/commands/mobile/unsubscribe_vehicle_response_test.cc b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/commands/mobile/unsubscribe_vehicle_response_test.cc index a0d4699de8d..7c610c8adbf 100644 --- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/commands/mobile/unsubscribe_vehicle_response_test.cc +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/commands/mobile/unsubscribe_vehicle_response_test.cc @@ -30,13 +30,15 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include "mobile/unsubscribe_vehicle_data_response.h" #include #include +#include "application_manager/mock_application_manager.h" #include "gtest/gtest.h" +#include "mobile/unsubscribe_vehicle_data_response.h" -#include "application_manager/commands/commands_test.h" -#include "application_manager/mock_application_manager.h" +#include "vehicle_info_plugin/commands/vi_commands_test.h" +#include "vehicle_info_plugin/mock_custom_vehicle_data_manager.h" +#include "vehicle_info_plugin/vehicle_info_command_factory.h" namespace test { namespace components { @@ -50,12 +52,12 @@ using ::testing::_; using ::testing::NotNull; using ::testing::Types; -using vehicle_info_plugin::commands::UnsubscribeVehicleDataResponse; using commands::MessageSharedPtr; +using vehicle_info_plugin::commands::UnsubscribeVehicleDataResponse; namespace am = ::application_manager; class UnsubscribeVehicleResponseTest - : public CommandsTest {}; + : public VICommandsTest {}; MATCHER_P(ResultCodeIs, result_code, "") { return result_code == @@ -70,7 +72,7 @@ TEST_F(UnsubscribeVehicleResponseTest, (*command_msg)[am::strings::msg_params][am::strings::success] = false; std::shared_ptr command = - CreateCommand(command_msg); + CreateCommandVI(command_msg); EXPECT_CALL( mock_rpc_service_, @@ -84,7 +86,7 @@ TEST_F(UnsubscribeVehicleResponseTest, std::make_shared(smart_objects::SmartType_Map); (*command_msg)[am::strings::msg_params][am::strings::success] = true; std::shared_ptr command = - CreateCommand(command_msg); + CreateCommandVI(command_msg); EXPECT_CALL( mock_rpc_service_, @@ -102,7 +104,7 @@ TEST_F(UnsubscribeVehicleResponseTest, (*command_msg)[am::strings::msg_params][am::strings::result_code] = result_type; std::shared_ptr command = - CreateCommand(command_msg); + CreateCommandVI(command_msg); command->Run(); } diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/custom_vehicle_data_manager_test.cc b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/custom_vehicle_data_manager_test.cc new file mode 100644 index 00000000000..7d65d989bfd --- /dev/null +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/custom_vehicle_data_manager_test.cc @@ -0,0 +1,318 @@ +/* + * 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 "application_manager/mock_message_helper.h" +#include "application_manager/mock_rpc_service.h" +#include "application_manager/policies/mock_custom_vehicle_data_provider.h" +#include "gtest/gtest.h" +#include "test/application_manager/mock_application_manager.h" +#include "vehicle_info_plugin/custom_vehicle_data_manager_impl.h" + +namespace vehicle_info_plugin_test { + +using ::testing::NiceMock; +using ::testing::Return; +using ::testing::ReturnRef; + +using application_manager::MockMessageHelper; +namespace { +std::string kName = "rpm"; +std::string kKey = "VD_RPM"; +} // namespace +class CustomVehicleDataManagerTest : public ::testing::Test { + public: + CustomVehicleDataManagerTest() + : mock_message_helper_( + *application_manager::MockMessageHelper::message_helper_mock()) {} + + void SetUp() OVERRIDE {} + + void InitValidationManager(const policy_table::VehicleDataItems& items) { + using vehicle_info_plugin::CustomVehicleDataManagerImpl; + + ON_CALL(mock_custom_vehicle_data_provider_, GetVehicleDataItems()) + .WillByDefault(Return(items)); + ON_CALL(mock_custom_vehicle_data_provider_, GetRemovedVehicleDataItems()) + .WillByDefault(Return(policy_table::VehicleDataItems())); + custom_vd_manager_.reset(new CustomVehicleDataManagerImpl( + mock_custom_vehicle_data_provider_, mock_rpc_service_)); + } + + test::components::application_manager_test::MockApplicationManager + app_manager_mock_; + std::unique_ptr + custom_vd_manager_; + NiceMock + mock_custom_vehicle_data_provider_; + NiceMock + mock_rpc_service_; + MockMessageHelper& mock_message_helper_; +}; + +TEST_F(CustomVehicleDataManagerTest, CreateHMIMessageParamsEmptyItems) { + policy_table::VehicleDataItems schema_items; + InitValidationManager(schema_items); + const std::set items; + const auto msg_params = custom_vd_manager_->CreateHMIMessageParams(items); + EXPECT_EQ(msg_params.getType(), smart_objects::SmartType_Map); + EXPECT_TRUE(msg_params.empty()); +} + +TEST_F(CustomVehicleDataManagerTest, CreateHMIMessageParamsOnePODItem) { + policy_table::VehicleDataItem rpm; + rpm.mark_initialized(); + rpm.name = kName; + rpm.type = "Integer"; + rpm.key = "OEM_REF_RPM"; + rpm.mandatory = false; + *rpm.array = false; + rpm.params->mark_initialized(); + + policy_table::VehicleDataItems schema_items; + schema_items.push_back(rpm); + InitValidationManager(schema_items); + + const std::set items = {kName}; + const auto msg_params = custom_vd_manager_->CreateHMIMessageParams(items); + EXPECT_EQ(msg_params.getType(), smart_objects::SmartType_Map); + EXPECT_EQ(msg_params.length(), 1u); + EXPECT_TRUE(msg_params.keyExists("OEM_REF_RPM")); + auto key_value = msg_params["OEM_REF_RPM"]; + EXPECT_TRUE(key_value.asBool()); +} + +TEST_F(CustomVehicleDataManagerTest, CreateHMIMessageParamsSeveralPODItems) { + policy_table::VehicleDataItem rpm; + rpm.mark_initialized(); + rpm.name = kName; + rpm.type = "Integer"; + rpm.key = "OEM_REF_RPM"; + rpm.mandatory = false; + *rpm.array = false; + rpm.params->mark_initialized(); + + policy_table::VehicleDataItem speed; + speed.mark_initialized(); + speed.name = "speed"; + speed.type = "float"; + speed.key = "OEM_REF_SPEED"; + speed.mandatory = false; + *speed.array = false; + speed.params->mark_initialized(); + + policy_table::VehicleDataItems schema_items; + schema_items.push_back(rpm); + schema_items.push_back(speed); + InitValidationManager(schema_items); + + const std::set items = {kName, "speed"}; + + const auto msg_params = custom_vd_manager_->CreateHMIMessageParams(items); + EXPECT_EQ(msg_params.getType(), smart_objects::SmartType_Map); + EXPECT_EQ(msg_params.length(), 2u); + + EXPECT_TRUE(msg_params.keyExists("OEM_REF_RPM")); + auto rpm_key_value = msg_params["OEM_REF_RPM"]; + EXPECT_TRUE(rpm_key_value.asBool()); + + EXPECT_TRUE(msg_params.keyExists("OEM_REF_SPEED")); + auto speed_key_value = msg_params["OEM_REF_SPEED"]; + EXPECT_TRUE(speed_key_value.asBool()); +} + +TEST_F(CustomVehicleDataManagerTest, + CreateHMIMessageParamsSchemaWithSeveralItemsRequestWithOneItem) { + policy_table::VehicleDataItem rpm; + rpm.mark_initialized(); + rpm.name = kName; + rpm.type = "Integer"; + rpm.key = "OEM_REF_RPM"; + rpm.mandatory = false; + *rpm.array = false; + rpm.params->mark_initialized(); + + policy_table::VehicleDataItem speed; + speed.mark_initialized(); + speed.name = "speed"; + speed.type = "float"; + speed.key = "OEM_REF_SPEED"; + speed.mandatory = false; + *speed.array = false; + speed.params->mark_initialized(); + + policy_table::VehicleDataItems schema_items; + schema_items.push_back(rpm); + schema_items.push_back(speed); + InitValidationManager(schema_items); + + const std::set items = {kName}; + + const auto msg_params = custom_vd_manager_->CreateHMIMessageParams(items); + EXPECT_EQ(msg_params.getType(), smart_objects::SmartType_Map); + EXPECT_EQ(msg_params.length(), 1u); + + EXPECT_TRUE(msg_params.keyExists("OEM_REF_RPM")); + auto rpm_key_value = msg_params["OEM_REF_RPM"]; + EXPECT_TRUE(rpm_key_value.asBool()); +} + +TEST_F(CustomVehicleDataManagerTest, CreateHMIMessageParamsStructType) { + policy_table::VehicleDataItem alss; + alss.mark_initialized(); + alss.name = "ambientLightSensorStatus"; + alss.type = "AmbientLightStatus"; + alss.key = "OEM_REF_AMB_LIGHT"; + alss.mandatory = false; + alss.params->mark_initialized(); + + policy_table::VehicleDataItem lss; + lss.mark_initialized(); + lss.name = "LightSensorStatus"; + lss.type = "Struct"; + lss.key = "OEM_REF_SEN_LIGHT"; + lss.mandatory = false; + lss.params->mark_initialized(); + lss.params->push_back(alss); + + policy_table::VehicleDataItem hbo; + hbo.mark_initialized(); + hbo.name = "highBeamsOn"; + hbo.type = "Boolean"; + hbo.key = "OEM_REF_HIGH_BEAM"; + hbo.mandatory = true; + hbo.params->mark_initialized(); + + policy_table::VehicleDataItem lbo; + lbo.mark_initialized(); + lbo.name = "lowBeamsOn"; + lbo.type = "Boolean"; + lbo.key = "OEM_REF_LOW_BEAM"; + lbo.mandatory = false; + lbo.params->mark_initialized(); + + policy_table::VehicleDataItem hls; + hls.mark_initialized(); + hls.name = "headLampStatus"; + hls.type = "Struct"; + hls.key = "OEM_REF_HLSTATUS"; + hls.mandatory = false; + hls.params->mark_initialized(); + hls.params->push_back(lss); + hls.params->push_back(lbo); + hls.params->push_back(hbo); + + policy_table::VehicleDataItems schema_items; + schema_items.push_back(hls); + InitValidationManager(schema_items); + + const std::set items = {"headLampStatus"}; + + const auto msg_params = custom_vd_manager_->CreateHMIMessageParams(items); + EXPECT_EQ(msg_params.getType(), smart_objects::SmartType_Map); + EXPECT_EQ(msg_params.length(), 1u); + + EXPECT_TRUE(msg_params.keyExists("OEM_REF_HLSTATUS")); + const auto head_lamp_status = msg_params["OEM_REF_HLSTATUS"]; + EXPECT_EQ(head_lamp_status.getType(), smart_objects::SmartType_Map); + + EXPECT_EQ(head_lamp_status.length(), 3u); + + EXPECT_TRUE(head_lamp_status.keyExists("OEM_REF_HIGH_BEAM")); + EXPECT_TRUE(head_lamp_status.keyExists("OEM_REF_LOW_BEAM")); + EXPECT_TRUE(head_lamp_status.keyExists("OEM_REF_SEN_LIGHT")); + + EXPECT_TRUE(head_lamp_status["OEM_REF_HIGH_BEAM"].asBool()); + EXPECT_TRUE(head_lamp_status["OEM_REF_LOW_BEAM"].asBool()); + auto light_sensor_status = head_lamp_status["OEM_REF_SEN_LIGHT"]; + + EXPECT_EQ(light_sensor_status.length(), 1u); + EXPECT_TRUE(light_sensor_status.keyExists("OEM_REF_AMB_LIGHT")); + EXPECT_TRUE(light_sensor_status["OEM_REF_AMB_LIGHT"].asBool()); +} + +TEST_F(CustomVehicleDataManagerTest, CreateHMIMessageParamsNoSchemaForItem) { + policy_table::VehicleDataItems schema_items; + InitValidationManager(schema_items); + + const std::set items = {kName}; + + const auto msg_params = custom_vd_manager_->CreateHMIMessageParams(items); + EXPECT_EQ(msg_params.getType(), smart_objects::SmartType_Map); + EXPECT_TRUE(msg_params.empty()); +} + +TEST_F(CustomVehicleDataManagerTest, CreateMobileMessageParamsStruct) { + const application_manager::VehicleData kEmptyVehicleData; + ON_CALL(mock_message_helper_, vehicle_data()) + .WillByDefault(ReturnRef(kEmptyVehicleData)); + + policy_table::VehicleDataItems schema_items; + + policy_table::VehicleDataItem custom_vd_item11_struct; + custom_vd_item11_struct.mark_initialized(); + custom_vd_item11_struct.name = "custom_vd_item11_struct"; + custom_vd_item11_struct.type = "Struct"; + custom_vd_item11_struct.key = "OEM_REF_STRUCT"; + custom_vd_item11_struct.mandatory = false; + custom_vd_item11_struct.params->mark_initialized(); + + policy_table::VehicleDataItem struct_element_1_int; + struct_element_1_int.mark_initialized(); + struct_element_1_int.name = "struct_element_1_int"; + struct_element_1_int.type = "Integer"; + struct_element_1_int.key = "OEM_REF_STRUCT_1_INT"; + struct_element_1_int.mandatory = false; + struct_element_1_int.params->mark_initialized(); + custom_vd_item11_struct.params->push_back(struct_element_1_int); + schema_items.push_back(custom_vd_item11_struct); + InitValidationManager(schema_items); + + smart_objects::SmartObject msg_params(smart_objects::SmartType_Map); + msg_params["OEM_REF_STRUCT"] = + smart_objects::SmartObject(smart_objects::SmartType_Map); + auto& oem_ref_struct = msg_params["OEM_REF_STRUCT"]; + oem_ref_struct["OEM_REF_STRUCT_1_INT"] = 100; + custom_vd_manager_->CreateMobileMessageParams(msg_params); + + EXPECT_EQ(msg_params.getType(), smart_objects::SmartType_Map); + EXPECT_TRUE(msg_params.keyExists("custom_vd_item11_struct")); + + auto& mobile_response_vd_item_11 = msg_params["custom_vd_item11_struct"]; + EXPECT_EQ(mobile_response_vd_item_11.getType(), smart_objects::SmartType_Map); + EXPECT_TRUE(mobile_response_vd_item_11.keyExists("struct_element_1_int")); + + auto& mobile_response_element1 = + mobile_response_vd_item_11["struct_element_1_int"]; + EXPECT_EQ(mobile_response_element1.getType(), + smart_objects::SmartType_Integer); + EXPECT_EQ(mobile_response_element1.asInt(), 100); +} +} // namespace vehicle_info_plugin_test diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/include/vehicle_info_plugin/commands/vi_command_request_test.h b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/include/vehicle_info_plugin/commands/vi_command_request_test.h new file mode 100644 index 00000000000..a6eac01e1c4 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/include/vehicle_info_plugin/commands/vi_command_request_test.h @@ -0,0 +1,99 @@ +/* + * Copyright (c) 2019, 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_VEHICLE_INFO_PLUGIN_TEST_INCLUDE_VIHICLE_INFO_PLUGIN_COMMANDS_VI_COMMAND_REQUEST_TEST_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_VEHICLE_INFO_PLUGIN_TEST_INCLUDE_VIHICLE_INFO_PLUGIN_COMMANDS_VI_COMMAND_REQUEST_TEST_H_ + +#include + +#include "gtest/gtest.h" + +#include "application_manager/commands/command_request_impl.h" +#include "application_manager/commands/command_request_test.h" +#include "application_manager/event_engine/event.h" +#include "application_manager/smart_object_keys.h" +#include "smart_objects/smart_object.h" +#include "vehicle_info_plugin/mock_custom_vehicle_data_manager.h" +#include "vehicle_info_plugin/vehicle_info_command_params.h" + +namespace test { +namespace components { +namespace commands_test { + +using ::test::components::event_engine_test::MockEventDispatcher; +using ::testing::NiceMock; +using ::testing::Return; +using ::testing::SaveArg; +namespace am = ::application_manager; +using am::commands::Command; +using am::commands::CommandRequestImpl; +using am::event_engine::Event; + +template +class VICommandRequestTest : public CommandRequestTest { + public: + enum { kDefaultTimeout_ = 100 }; + + template + std::shared_ptr CreateCommandVI() { + auto msg = CommandsTest::CreateMessage(); + return CreateCommandVI(msg); + } + + template + std::shared_ptr CreateCommandVI(MessageSharedPtr& msg) { + InitCommandVI(kDefaultTimeout_); + vehicle_info_plugin::VehicleInfoCommandParams params = { + CommandsTest::app_mngr_, + CommandsTest::mock_rpc_service_, + CommandsTest::mock_hmi_capabilities_, + CommandsTest::mock_policy_handler_, + mock_custom_vehicle_data_manager_}; + return std::make_shared(msg, params); + } + + testing::NiceMock + mock_custom_vehicle_data_manager_; + + protected: + VICommandRequestTest() : CommandRequestTest() {} + + void InitCommandVI(const uint32_t& timeout) { + CommandRequestTest::InitCommand(kDefaultTimeout_); + } +}; + +} // namespace commands_test +} // namespace components +} // namespace test + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_VEHICLE_INFO_PLUGIN_TEST_INCLUDE_VIHICLE_INFO_PLUGIN_COMMANDS_VI_COMMAND_REQUEST_TEST_H_ diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/include/vehicle_info_plugin/commands/vi_commands_test.h b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/include/vehicle_info_plugin/commands/vi_commands_test.h new file mode 100644 index 00000000000..ae25acea87c --- /dev/null +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/include/vehicle_info_plugin/commands/vi_commands_test.h @@ -0,0 +1,104 @@ +/* + * Copyright (c) 2019, 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_VEHICLE_INFO_PLUGIN_TEST_INCLUDE_VI_COMMAND_TEST_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_VEHICLE_INFO_PLUGIN_TEST_INCLUDE_VI_COMMAND_TEST_H_ + +#include +#include "gtest/gtest.h" + +#include "application_manager/commands/command.h" +#include "smart_objects/smart_object.h" + +#include "application_manager/commands/commands_test.h" +#include "application_manager/mock_application.h" +#include "application_manager/mock_application_manager_settings.h" +#include "application_manager/mock_hmi_interface.h" +#include "application_manager/mock_message_helper.h" +#include "application_manager/policies/mock_policy_handler_interface.h" +#include "vehicle_info_plugin/mock_custom_vehicle_data_manager.h" +#include "vehicle_info_plugin/vehicle_info_command_params.h" + +namespace test { +namespace components { +namespace commands_test { + +namespace am = ::application_manager; + +using ::testing::_; +using ::testing::Mock; +using ::testing::NiceMock; +using ::testing::Return; +using ::testing::ReturnRef; + +using am::commands::MessageSharedPtr; +using ::smart_objects::SmartObject; + +template +class VICommandsTest : public CommandsTest { + public: + enum { kDefaultTimeout_ = 100 }; + + template + std::shared_ptr CreateCommandVI() { + auto msg = CommandsTest::CreateMessage(); + return CreateCommandVI(msg); + } + + template + std::shared_ptr CreateCommandVI(MessageSharedPtr& msg) { + InitCommandVI(kDefaultTimeout_); + vehicle_info_plugin::VehicleInfoCommandParams params = { + CommandsTest::app_mngr_, + CommandsTest::mock_rpc_service_, + CommandsTest::mock_hmi_capabilities_, + CommandsTest::mock_policy_handler_, + mock_custom_vehicle_data_manager_}; + return std::make_shared(msg, params); + } + + testing::NiceMock + mock_custom_vehicle_data_manager_; + + protected: + void InitCommandVI(const uint32_t& timeout) { + ON_CALL(CommandsTest::app_mngr_, get_settings()) + .WillByDefault(ReturnRef(CommandsTest::app_mngr_settings_)); + ON_CALL(CommandsTest::app_mngr_settings_, default_timeout()) + .WillByDefault(ReturnRef(timeout)); + } +}; +} // namespace commands_test +} // namespace components +} // namespace test + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_VEHICLE_INFO_PLUGIN_TEST_INCLUDE_VI_COMMAND_TEST_H_ diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/include/vehicle_info_plugin/mock_custom_vehicle_data_manager.h b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/include/vehicle_info_plugin/mock_custom_vehicle_data_manager.h new file mode 100644 index 00000000000..9a7435f9802 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/include/vehicle_info_plugin/mock_custom_vehicle_data_manager.h @@ -0,0 +1,26 @@ +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_VEHICLE_INFO_PLUGIN_TEST_INCLUDE_VEHICLE_INFO_PLUGIN_MOCK_CUSTOM_VEHICLE_DATA_MANAGER_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_VEHICLE_INFO_PLUGIN_TEST_INCLUDE_VEHICLE_INFO_PLUGIN_MOCK_CUSTOM_VEHICLE_DATA_MANAGER_H_ + +#include "gmock/gmock.h" +#include "vehicle_info_plugin/custom_vehicle_data_manager.h" + +namespace vehicle_info_plugin { +namespace plugin_manager = application_manager::plugin_manager; +class MockCustomVehicleDataManager : public CustomVehicleDataManager { + public: + MOCK_METHOD1( + CreateHMIMessageParams, + smart_objects::SmartObject(const std::set& msg_params)); + MOCK_METHOD1(CreateMobileMessageParams, + void(smart_objects::SmartObject& msg_params)); + MOCK_CONST_METHOD1(GetVehicleDataItemType, + std::string(const std::string& vehicle_data_item_name)); + MOCK_METHOD1(OnPolicyEvent, void(plugin_manager::PolicyEvent policy_event)); + MOCK_CONST_METHOD1(IsValidCustomVehicleDataName, + bool(const std::string& name)); + MOCK_CONST_METHOD1(IsRemovedCustomVehicleDataName, + bool(const std::string& name)); +}; + +} // namespace vehicle_info_plugin +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_VEHICLE_INFO_PLUGIN_TEST_INCLUDE_VEHICLE_INFO_PLUGIN_MOCK_CUSTOM_VEHICLE_DATA_MANAGER_H_ diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/vehicle_data_item_schema_test.cc b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/vehicle_data_item_schema_test.cc new file mode 100644 index 00000000000..2443310409b --- /dev/null +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/vehicle_data_item_schema_test.cc @@ -0,0 +1,396 @@ +/* + * Copyright (c) 2019, 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 "vehicle_info_plugin/vehicle_data_item_schema.h" +#include +#include +#include +#include "formatters/formatter_json_rpc.h" +#include "formatters/generic_json_formatter.h" +#include "gmock/gmock.h" +#include "gtest/gtest.h" +#include "interfaces/HMI_API.h" +#include "smart_objects/smart_object.h" + +namespace vehicle_info_plugin_test { +using namespace vehicle_info_plugin; +using namespace rpc; +namespace smart_objects = ns_smart_device_link::ns_smart_objects; +namespace policy_table = rpc::policy_table_interface_base; + +using namespace ns_smart_device_link::ns_json_handler::strings; +using namespace hmi_apis; + +using ::testing::NiceMock; +using ::testing::Return; +using ::testing::ReturnRef; + +using ErrorCode = smart_objects::errors::eType; + +namespace { +const int kInvalidValue = std::numeric_limits::max(); +const int kDefaultInteger = 20; +const double kDefaultFloat = 10.05; +const bool kDefaultBoolean = true; +const std::string kDefaultString = "string value"; +const std::string kVehicleDataKey = "key"; +} // namespace + +typedef Common_ComponentVolumeStatus::eType TestEnumType; + +class VehicleDataItemSchemaTest : public ::testing::Test { + public: + /* + * @brief + * Specifies whether user wants to generate valid value of SmartObject or not. + */ + enum class SetValidItemValue { NO = 0, YES = 1 }; + + /* + * @brief + * VehicleDataTestObject struct combines schema and data structures for test + * object. + */ + struct VehicleDataTestObject { + VehicleDataTestObject(const int& key_number) { + schema.mark_initialized(); + schema.params->mark_initialized(); + schema.mandatory = true; + *schema.array = false; + // default value bounds + *schema.minvalue = 10; + *schema.maxvalue = 100; + // default string length + *schema.minlength = 5; + *schema.maxlength = 30; + // default array length + *schema.minsize = 5; + *schema.maxsize = 30; + // generate schema unique key + schema.key = kVehicleDataKey + std::to_string(key_number); + } + + policy_table::VehicleDataItem schema; + smart_objects::SmartObject data; + }; + + public: + VehicleDataItemSchemaTest() : key_number_(1) { + test_enum_.insert(TestEnumType::CVS_UNKNOWN); + test_enum_.insert(TestEnumType::CVS_NORMAL); + test_enum_.insert(TestEnumType::CVS_LOW); + test_enum_.insert(TestEnumType::CVS_FAULT); + test_enum_.insert(TestEnumType::CVS_ALERT); + test_enum_.insert(TestEnumType::CVS_NOT_SUPPORTED); + } + + void assertSmartObjectSize(const size_t& expected_size, + const size_t& actual_size) { + ASSERT_EQ(expected_size, actual_size); + } + + std::vector generatePODObjects( + const SetValidItemValue& set_valid_item) { + std::vector generated_objects; + VehicleDataTestObject custom_object(key_number_++); + + // Integer item + custom_object.schema.type = policy_table::VehicleDataItem::kInteger; + if (set_valid_item == SetValidItemValue::YES) { + custom_object.data = kDefaultInteger; + } else { + custom_object.data = kInvalidValue; + } + generated_objects.push_back(custom_object); + + // Float item + custom_object.schema.type = policy_table::VehicleDataItem::kFloat; + if (set_valid_item == SetValidItemValue::YES) { + custom_object.data = kDefaultFloat; + } else { + custom_object.data = kInvalidValue; + } + generated_objects.push_back(custom_object); + + // String item + custom_object.schema.type = policy_table::VehicleDataItem::kString; + if (set_valid_item == SetValidItemValue::YES) { + custom_object.data = kDefaultString; + } else { + custom_object.data = kInvalidValue; + } + generated_objects.push_back(custom_object); + + // Boolean item + custom_object.schema.type = policy_table::VehicleDataItem::kBoolean; + if (set_valid_item == SetValidItemValue::YES) { + custom_object.data = kDefaultBoolean; + } else { + custom_object.data = kInvalidValue; + } + generated_objects.push_back(custom_object); + + return generated_objects; + } + + VehicleDataTestObject generateTestObject( + const SetValidItemValue& set_valid_item) { + // Enum parameter + VehicleDataTestObject enum_object(key_number_++); + enum_object.schema.type = "ComponentVolumeStatus"; + enum_object.data = (set_valid_item == SetValidItemValue::YES) + ? TestEnumType::CVS_LOW + : kInvalidValue; + + // Integer parameter + VehicleDataTestObject int_object(key_number_++); + int_object.schema.type = policy_table::VehicleDataItem::kInteger; + int_object.data = (set_valid_item == SetValidItemValue::YES) + ? kDefaultInteger + : kInvalidValue; + + // Main object + VehicleDataTestObject main_object(key_number_++); + main_object.schema.type = policy_table::VehicleDataItem::kStruct; + *main_object.schema.params = std::vector{ + enum_object.schema, int_object.schema}; + main_object.data[enum_object.schema.key] = enum_object.data; + main_object.data[int_object.schema.key] = int_object.data; + + assertSmartObjectSize(2u, main_object.data.length()); + return main_object; + } + + VehicleDataTestObject generateRecursiveTestObject( + const SetValidItemValue& set_valid_item) { + // Float item + VehicleDataTestObject float_object(key_number_++); + float_object.schema.type = policy_table::VehicleDataItem::kFloat; + if (set_valid_item == SetValidItemValue::YES) { + float_object.data = kDefaultFloat; + } else { + float_object.data = kInvalidValue; + } + + // String item + VehicleDataTestObject string_object(key_number_++); + string_object.schema.type = policy_table::VehicleDataItem::kString; + if (set_valid_item == SetValidItemValue::YES) { + string_object.data = kDefaultString; + } else { + string_object.data = kInvalidValue; + } + + // Sub Object + VehicleDataTestObject sub_object = generateTestObject(set_valid_item); + + // Main Object + VehicleDataTestObject main_object(key_number_++); + main_object.schema.type = policy_table::VehicleDataItem::kStruct; + *main_object.schema.params = std::vector{ + float_object.schema, string_object.schema, sub_object.schema}; + main_object.data[float_object.schema.key] = float_object.data; + main_object.data[string_object.schema.key] = string_object.data; + main_object.data[sub_object.schema.key] = sub_object.data; + + assertSmartObjectSize(3u, main_object.data.length()); + return main_object; + } + + protected: + std::set test_enum_; + int key_number_; +}; + +TEST_F(VehicleDataItemSchemaTest, ValidatePOD_SUCCESS) { + rpc::ValidationReport report("RPC"); + auto valid_pod_objects = generatePODObjects(SetValidItemValue::YES); + + for (auto& object : valid_pod_objects) { + auto test_param = PolicyDataItem(object.schema); + auto result = VehicleDataItemSchema::create( + test_param, VehicleDataItemSchema::SchemaType::HMI); + EXPECT_EQ(ErrorCode::OK, result->validate(object.data, &report)); + EXPECT_EQ(std::string(""), rpc::PrettyFormat(report)); + } +} + +TEST_F(VehicleDataItemSchemaTest, ValidatePOD_FAIL) { + rpc::ValidationReport report("RPC"); + std::vector valid_pod_objects = + generatePODObjects(SetValidItemValue::NO); + + for (auto& object : valid_pod_objects) { + auto test_param = PolicyDataItem(object.schema); + auto result = VehicleDataItemSchema::create( + test_param, VehicleDataItemSchema::SchemaType::MOBILE); + EXPECT_NE(ErrorCode::OK, result->validate(object.data, &report)); + EXPECT_NE(std::string(""), rpc::PrettyFormat(report)); + } +} + +TEST_F(VehicleDataItemSchemaTest, ValidateEnum_SUCCESS) { + rpc::ValidationReport report("RPC"); + + VehicleDataTestObject test_enum_object(key_number_++); + test_enum_object.schema.type = "ComponentVolumeStatus"; + test_enum_object.data = TestEnumType::CVS_NORMAL; + + auto test_schema = PolicyDataItem(test_enum_object.schema); + + for (auto& enum_value : test_enum_) { + test_enum_object.data = enum_value; + auto result = VehicleDataItemSchema::create( + test_schema, VehicleDataItemSchema::SchemaType::HMI); + EXPECT_EQ(ErrorCode::OK, result->validate(test_enum_object.data, &report)); + EXPECT_EQ(std::string(""), rpc::PrettyFormat(report)); + } +} + +TEST_F(VehicleDataItemSchemaTest, ValidateEnum_FAIL) { + rpc::ValidationReport report("RPC"); + + VehicleDataTestObject test_enum_object(key_number_++); + test_enum_object.schema.type = "ComponentVolumeStatus"; + test_enum_object.data = kInvalidValue; + + auto test_schema = PolicyDataItem(test_enum_object.schema); + auto result = VehicleDataItemSchema::create( + test_schema, VehicleDataItemSchema::SchemaType::HMI); + EXPECT_EQ(ErrorCode::OUT_OF_RANGE, + result->validate(test_enum_object.data, &report)); + EXPECT_NE(std::string(""), rpc::PrettyFormat(report)); +} + +TEST_F(VehicleDataItemSchemaTest, ValidateObject_SUCCESS) { + rpc::ValidationReport report("RPC"); + VehicleDataTestObject complex_object = + generateTestObject(SetValidItemValue::YES); + auto test_schema = PolicyDataItem(complex_object.schema); + auto result = VehicleDataItemSchema::create( + test_schema, VehicleDataItemSchema::SchemaType::HMI); + EXPECT_EQ(ErrorCode::OK, result->validate(complex_object.data, &report)); + EXPECT_EQ(std::string(""), rpc::PrettyFormat(report)); +} + +TEST_F(VehicleDataItemSchemaTest, ValidateObject_FAIL) { + rpc::ValidationReport report("RPC"); + VehicleDataTestObject complex_object = + generateTestObject(SetValidItemValue::NO); + auto test_schema = PolicyDataItem(complex_object.schema); + auto result = VehicleDataItemSchema::create( + test_schema, VehicleDataItemSchema::SchemaType::HMI); + EXPECT_NE(ErrorCode::OK, result->validate(complex_object.data, &report)); + EXPECT_NE(std::string(""), rpc::PrettyFormat(report)); +} + +TEST_F(VehicleDataItemSchemaTest, ValidateRecursiveObject_SUCCESS) { + rpc::ValidationReport report("RPC"); + VehicleDataTestObject complex_recursive_object = + generateRecursiveTestObject(SetValidItemValue::YES); + auto test_schema = PolicyDataItem(complex_recursive_object.schema); + auto result = VehicleDataItemSchema::create( + test_schema, VehicleDataItemSchema::SchemaType::HMI); + EXPECT_EQ(ErrorCode::OK, + result->validate(complex_recursive_object.data, &report)); + EXPECT_EQ(std::string(""), rpc::PrettyFormat(report)); +} + +TEST_F(VehicleDataItemSchemaTest, ValidateRecursiveObject_FAIL) { + rpc::ValidationReport report("RPC"); + VehicleDataTestObject complex_recursive_object = + generateRecursiveTestObject(SetValidItemValue::NO); + auto test_schema = PolicyDataItem(complex_recursive_object.schema); + auto result = VehicleDataItemSchema::create( + test_schema, VehicleDataItemSchema::SchemaType::HMI); + EXPECT_NE(ErrorCode::OK, + result->validate(complex_recursive_object.data, &report)); + EXPECT_NE(std::string(""), rpc::PrettyFormat(report)); +} + +TEST_F(VehicleDataItemSchemaTest, ValidateArray_SUCCESS) { + rpc::ValidationReport report("RPC"); + VehicleDataTestObject array_object(key_number_++); + *array_object.schema.array = true; + array_object.schema.type = policy_table::VehicleDataItem::kInteger; + array_object.data = + smart_objects::SmartObject(smart_objects::SmartType_Array); + array_object.data.asArray()->push_back(smart_objects::SmartObject(10)); + array_object.data.asArray()->push_back(smart_objects::SmartObject(20)); + array_object.data.asArray()->push_back(smart_objects::SmartObject(30)); + array_object.data.asArray()->push_back(smart_objects::SmartObject(40)); + array_object.data.asArray()->push_back(smart_objects::SmartObject(50)); + array_object.data.asArray()->push_back(smart_objects::SmartObject(60)); + array_object.data.asArray()->push_back(smart_objects::SmartObject(70)); + + auto test_schema = PolicyDataItem(array_object.schema); + auto result = VehicleDataItemSchema::create( + test_schema, VehicleDataItemSchema::SchemaType::HMI); + EXPECT_EQ(ErrorCode::OK, result->validate(array_object.data, &report)); + EXPECT_EQ(std::string(""), rpc::PrettyFormat(report)); +} + +TEST_F(VehicleDataItemSchemaTest, ValidateArray_FAIL) { + rpc::ValidationReport report("RPC"); + VehicleDataTestObject array_object(key_number_++); + *array_object.schema.array = true; + array_object.schema.type = policy_table::VehicleDataItem::kInteger; + array_object.data = + smart_objects::SmartObject(smart_objects::SmartType_Array); + array_object.data.asArray()->push_back(smart_objects::SmartObject(10)); + array_object.data.asArray()->push_back(smart_objects::SmartObject(20)); + array_object.data.asArray()->push_back(smart_objects::SmartObject(30)); + + auto test_schema = PolicyDataItem(array_object.schema); + auto result = VehicleDataItemSchema::create( + test_schema, VehicleDataItemSchema::SchemaType::HMI); + EXPECT_NE(ErrorCode::OK, result->validate(array_object.data, &report)); + EXPECT_NE(std::string(""), rpc::PrettyFormat(report)); +} + +TEST_F(VehicleDataItemSchemaTest, ValidateUnknownType) { + rpc::ValidationReport report("RPC"); + + VehicleDataTestObject test_object_with_invalid_type(key_number_++); + // Set invalid name of type + test_object_with_invalid_type.schema.type = "omponentolumetatus"; + test_object_with_invalid_type.data = TestEnumType::CVS_NORMAL; + + auto test_schema = PolicyDataItem(test_object_with_invalid_type.schema); + auto result = VehicleDataItemSchema::create( + test_schema, VehicleDataItemSchema::SchemaType::HMI); + test_object_with_invalid_type.data = "CVS_NORMAL"; + EXPECT_EQ(ErrorCode::OK, + result->validate(test_object_with_invalid_type.data, &report)); + EXPECT_EQ(std::string(""), rpc::PrettyFormat(report)); +} + +} // namespace vehicle_info_plugin_test diff --git a/src/components/application_manager/src/app_launch/app_launch_ctrl_impl.cc b/src/components/application_manager/src/app_launch/app_launch_ctrl_impl.cc index 8df3d436bd4..691f8d32597 100644 --- a/src/components/application_manager/src/app_launch/app_launch_ctrl_impl.cc +++ b/src/components/application_manager/src/app_launch/app_launch_ctrl_impl.cc @@ -29,14 +29,14 @@ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ -#include +#include "application_manager/app_launch/app_launch_ctrl_impl.h" #include +#include #include #include -#include "application_manager/app_launch/app_launch_ctrl_impl.h" +#include "application_manager/application.h" #include "application_manager/resumption/resume_ctrl.h" #include "connection_handler/connection_handler.h" -#include "application_manager/application.h" #include "utils/timer_task_impl.h" namespace app_launch { diff --git a/src/components/application_manager/src/app_launch/app_launch_data_db.cc b/src/components/application_manager/src/app_launch/app_launch_data_db.cc index 22d2790183c..a931b96fa1d 100644 --- a/src/components/application_manager/src/app_launch/app_launch_data_db.cc +++ b/src/components/application_manager/src/app_launch/app_launch_data_db.cc @@ -29,14 +29,14 @@ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ -#include #include +#include #include "application_manager/app_launch/app_launch_data_db.h" -#include "application_manager/application_manager.h" #include "application_manager/app_launch/app_launch_sql_queries.h" -#include "application_manager/smart_object_keys.h" +#include "application_manager/application_manager.h" #include "application_manager/message_helper.h" +#include "application_manager/smart_object_keys.h" namespace app_launch { CREATE_LOGGERPTR_GLOBAL(logger_, "AppLaunch") @@ -332,9 +332,9 @@ uint32_t AppLaunchDataDB::GetCurentNumberOfAppData() const { "Values of ignition off counts were updated successfully"); number_of_app_data = query.GetInteger(result_query); - LOG4CXX_DEBUG(logger_, - "Total cout saved mobile applications is " - << number_of_app_data); + LOG4CXX_DEBUG( + logger_, + "Total cout saved mobile applications is " << number_of_app_data); } else { LOG4CXX_WARN(logger_, "Failed execute query 'kGetNumberOfApplicationData'. Reson: " @@ -392,4 +392,4 @@ utils::dbms::SQLDatabase* AppLaunchDataDB::db() const { #endif // __QNX__ } -} // namespace resumption +} // namespace app_launch 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 d3e3b7d4455..984997e4243 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 @@ -29,13 +29,13 @@ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ -#include #include "application_manager/app_launch/app_launch_data_json.h" +#include #include "application_manager/smart_object_keys.h" #include "smart_objects/smart_object.h" -#include "utils/date_time.h" #include "json/json.h" +#include "utils/date_time.h" namespace app_launch { @@ -277,4 +277,4 @@ bool AppLaunchDataJson::Persist() { return true; } -} // app_launch +} // namespace app_launch diff --git a/src/components/application_manager/src/app_launch/app_launch_sql_queries.cc b/src/components/application_manager/src/app_launch/app_launch_sql_queries.cc index cc4765e6c90..7a9402d35e4 100644 --- a/src/components/application_manager/src/app_launch/app_launch_sql_queries.cc +++ b/src/components/application_manager/src/app_launch/app_launch_sql_queries.cc @@ -75,4 +75,4 @@ const std::string kRefreshApplicationDataSessionTime = "SET `last_session` = STRFTIME('%Y-%m-%d %H:%M:%f', 'NOW')" "WHERE `deviceMac` = ? AND appID = ? AND bundleID = ?;"; -} // namespace resumption +} // namespace app_launch diff --git a/src/components/application_manager/src/app_launch/apps_launcher.cc b/src/components/application_manager/src/app_launch/apps_launcher.cc index f3851482c1c..993a57364e4 100644 --- a/src/components/application_manager/src/app_launch/apps_launcher.cc +++ b/src/components/application_manager/src/app_launch/apps_launcher.cc @@ -1,8 +1,8 @@ -#include #include "application_manager/app_launch/apps_launcher.h" +#include -#include "utils/timer_task_impl.h" #include +#include "utils/timer_task_impl.h" namespace app_launch { struct LauncherGenerator { diff --git a/src/components/application_manager/src/app_launch/device_apps_launcher.cc b/src/components/application_manager/src/app_launch/device_apps_launcher.cc index a4468d87bca..9a7a6658fe1 100644 --- a/src/components/application_manager/src/app_launch/device_apps_launcher.cc +++ b/src/components/application_manager/src/app_launch/device_apps_launcher.cc @@ -1,15 +1,15 @@ +#include #include #include -#include -#include "application_manager/app_launch/device_apps_launcher.h" #include "application_manager/app_launch/app_launch_data.h" #include "application_manager/app_launch/apps_launcher.h" +#include "application_manager/app_launch/device_apps_launcher.h" #include "application_manager/resumption/resume_ctrl.h" +#include #include "utils/timer.h" #include "utils/timer_task_impl.h" -#include namespace app_launch { CREATE_LOGGERPTR_GLOBAL(logger_, "AppLaunch") @@ -58,9 +58,9 @@ class Launcher { device_launcher_.settings().wait_time_between_apps(), timer::kSingleShot); } else { - LOG4CXX_DEBUG(logger_, - "All Apps on " << apps_on_device_->first - << " postponed launched"); + LOG4CXX_DEBUG( + logger_, + "All Apps on " << apps_on_device_->first << " postponed launched"); device_launcher_.StopLaunchingAppsOnDevice(apps_on_device_->first); } } diff --git a/src/components/application_manager/src/app_service_manager.cc b/src/components/application_manager/src/app_service_manager.cc index bab8147d9fc..afcc7ae1ddf 100644 --- a/src/components/application_manager/src/app_service_manager.cc +++ b/src/components/application_manager/src/app_service_manager.cc @@ -72,10 +72,44 @@ smart_objects::SmartObject AppServiceManager::PublishAppService( std::string service_type = manifest[strings::service_type].asString(); - if (FindServiceByProvider(connection_key, service_type)) { - LOG4CXX_WARN(logger_, - "Service already exists for this provider, rejecting"); - return smart_objects::SmartObject(); + AppService* found_service = + FindServiceByProvider(connection_key, service_type); + if (found_service) { + // Check if there is a different existing service with the same updated + // name. + if (manifest.keyExists(strings::service_name)) { + auto service_by_name = + FindServiceByName(manifest[strings::service_name].asString()); + if (service_by_name) { + auto service_by_name_id = + service_by_name->record[strings::service_id].asString(); + auto found_service_id = + found_service->record[strings::service_id].asString(); + if (service_by_name_id != found_service_id) { + LOG4CXX_WARN(logger_, + "A service already exists with this name, rejecting"); + return smart_objects::SmartObject(); + } + } + } + LOG4CXX_WARN(logger_, "Service already exists for this provider, updating"); + published_services_lock_.Acquire(); + found_service->record[strings::service_manifest] = manifest; + found_service->record[strings::service_published] = true; + smart_objects::SmartObject updated_service_record = found_service->record; + published_services_lock_.Release(); + + smart_objects::SmartObject msg_params; + msg_params[strings::system_capability][strings::system_capability_type] = + mobile_apis::SystemCapabilityType::APP_SERVICES; + + AppServiceUpdated(updated_service_record, + mobile_apis::ServiceUpdateReason::MANIFEST_UPDATE, + msg_params); + + MessageHelper::BroadcastCapabilityUpdate(msg_params, app_manager_); + + return updated_service_record; } if (manifest.keyExists(strings::service_name) && @@ -131,10 +165,16 @@ smart_objects::SmartObject AppServiceManager::PublishAppService( MessageHelper::BroadcastCapabilityUpdate(msg_params, app_manager_); - // Activate the new service if it is the default for its service type, or if - // no service is active of its service type + // Activate the new service if it is the default for its service type, if + // no service is active of its service type, or it is a mobile app in full. AppService* active_service = ActiveServiceForType(service_type); - if (!active_service || app_service.default_service) { + ApplicationSharedPtr app = NULL; + if (mobile_service && connection_key) { + app = app_manager_.application(connection_key); + } + + if (!active_service || app_service.default_service || + (app && app->IsFullscreen())) { ActivateAppService(service_id); } @@ -163,7 +203,9 @@ bool AppServiceManager::UnpublishAppService(const std::string service_id) { // Activate embedded service, if available auto embedded_service = EmbeddedServiceForType( record[strings::service_manifest][strings::service_type].asString()); - if (embedded_service) { + if (embedded_service && + (embedded_service->record[strings::service_id].asString() != + service_id)) { embedded_service->record[strings::service_active] = true; AppServiceUpdated(embedded_service->record, mobile_apis::ServiceUpdateReason::ACTIVATED, @@ -181,13 +223,21 @@ bool AppServiceManager::UnpublishAppService(const std::string service_id) { void AppServiceManager::UnpublishServices(const uint32_t connection_key) { LOG4CXX_AUTO_TRACE(logger_); LOG4CXX_DEBUG(logger_, "Unpublishing all app services: " << connection_key); - sync_primitives::AutoLock lock(published_services_lock_); - for (auto it = published_services_.begin(); it != published_services_.end(); - ++it) { - if (it->second.connection_key == connection_key) { - UnpublishAppService(it->first); + + std::list app_published_services; + { + sync_primitives::AutoLock lock(published_services_lock_); + for (auto it = published_services_.begin(); it != published_services_.end(); + ++it) { + if (it->second.connection_key == connection_key) { + app_published_services.push_back(it->first); + } } } + + for (auto& service_id : app_published_services) { + UnpublishAppService(service_id); + } } void AppServiceManager::OnAppActivated(ApplicationConstSharedPtr app) { diff --git a/src/components/application_manager/src/application_data_impl.cc b/src/components/application_manager/src/application_data_impl.cc index 0636748977c..2bef887901c 100644 --- a/src/components/application_manager/src/application_data_impl.cc +++ b/src/components/application_manager/src/application_data_impl.cc @@ -173,19 +173,16 @@ InitialApplicationDataImpl::perform_interaction_layout() const { } DynamicApplicationDataImpl::DynamicApplicationDataImpl() - : help_prompt_(NULL) - , timeout_prompt_(NULL) - , vr_help_title_(NULL) - , vr_help_(NULL) + : help_prompt_(nullptr) + , timeout_prompt_(nullptr) + , vr_help_title_(nullptr) + , vr_help_(nullptr) , tbt_state_(mobile_api::TBTState::INVALID_ENUM) - , show_command_(NULL) - , keyboard_props_(NULL) - , menu_title_(NULL) - , menu_icon_(NULL) - , tbt_show_command_(NULL) - , day_color_scheme_(NULL) - , night_color_scheme_(NULL) - , display_layout_("") + , show_command_(nullptr) + , keyboard_props_(nullptr) + , menu_title_(nullptr) + , menu_icon_(nullptr) + , tbt_show_command_(nullptr) , commands_() , commands_lock_ptr_(std::make_shared()) , sub_menu_() @@ -195,9 +192,12 @@ DynamicApplicationDataImpl::DynamicApplicationDataImpl() , performinteraction_choice_set_map_() , performinteraction_choice_set_lock_ptr_( std::make_shared()) + , window_params_map_() + , window_params_map_lock_ptr_(std::make_shared()) , is_perform_interaction_active_(false) , is_reset_global_properties_active_(false) - , perform_interaction_mode_(-1) {} + , perform_interaction_mode_(-1) + , display_capabilities_builder_(*this) {} DynamicApplicationDataImpl::~DynamicApplicationDataImpl() { if (help_prompt_) { @@ -230,16 +230,6 @@ DynamicApplicationDataImpl::~DynamicApplicationDataImpl() { tbt_show_command_ = NULL; } - if (day_color_scheme_) { - delete day_color_scheme_; - day_color_scheme_ = NULL; - } - - if (night_color_scheme_) { - delete night_color_scheme_; - night_color_scheme_ = NULL; - } - for (CommandsMap::iterator command_it = commands_.begin(); commands_.end() != command_it; ++command_it) { @@ -265,6 +255,8 @@ DynamicApplicationDataImpl::~DynamicApplicationDataImpl() { performinteraction_choice_set_map_[it->first].clear(); } performinteraction_choice_set_map_.clear(); + + window_params_map_.clear(); } const smart_objects::SmartObject* DynamicApplicationDataImpl::help_prompt() @@ -316,18 +308,93 @@ const smart_objects::SmartObject* DynamicApplicationDataImpl::menu_icon() return menu_icon_; } -const smart_objects::SmartObject* DynamicApplicationDataImpl::day_color_scheme() +smart_objects::SmartObject DynamicApplicationDataImpl::day_color_scheme() const { - return day_color_scheme_; + using namespace mobile_apis::PredefinedWindows; + auto default_window_it = window_templates_.find(DEFAULT_WINDOW); + + if (window_templates_.end() != default_window_it) { + const smart_objects::SmartObject template_config = + default_window_it->second; + if (template_config.keyExists(strings::day_color_scheme)) { + return template_config[strings::day_color_scheme]; + } + } + + return smart_objects::SmartObject(smart_objects::SmartType::SmartType_Null); } -const smart_objects::SmartObject* -DynamicApplicationDataImpl::night_color_scheme() const { - return night_color_scheme_; +smart_objects::SmartObject DynamicApplicationDataImpl::night_color_scheme() + const { + using namespace mobile_apis::PredefinedWindows; + auto default_window_it = window_templates_.find(DEFAULT_WINDOW); + + if (window_templates_.end() != default_window_it) { + const smart_objects::SmartObject template_config = + default_window_it->second; + if (template_config.keyExists(strings::night_color_scheme)) { + return template_config[strings::night_color_scheme]; + } + } + + return smart_objects::SmartObject(smart_objects::SmartType::SmartType_Null); +} + +std::string DynamicApplicationDataImpl::display_layout() const { + using namespace mobile_apis::PredefinedWindows; + auto default_window_it = window_templates_.find(DEFAULT_WINDOW); + + if (window_templates_.end() != default_window_it) { + smart_objects::SmartObject template_config = default_window_it->second; + if (template_config.keyExists(strings::template_layout)) { + return template_config[strings::template_layout].asString(); + } + } + + return std::string(); } -const std::string& DynamicApplicationDataImpl::display_layout() const { - return display_layout_; +smart_objects::SmartObjectSPtr +DynamicApplicationDataImpl::display_capabilities() const { + return display_capabilities_; +} + +smart_objects::SmartObjectSPtr DynamicApplicationDataImpl::display_capabilities( + const WindowID window_id) const { + LOG4CXX_AUTO_TRACE(logger_); + + auto result_display_caps = std::make_shared( + smart_objects::SmartType_Array); + const auto window_caps = + (*display_capabilities_)[0][strings::window_capabilities].asArray(); + if (!window_caps) { + LOG4CXX_WARN(logger_, "Current window capabilities are empty"); + // SDL still needs to retreive display capabilities + return display_capabilities_; + } + auto find_res = + std::find_if(window_caps->begin(), + window_caps->end(), + [&window_id](const smart_objects::SmartObject& element) { + if (window_id == element[strings::window_id].asInt()) { + return true; + } + + return false; + }); + + DCHECK(find_res != window_caps->end()); + const auto disp_caps_keys = (*display_capabilities_)[0].enumerate(); + for (const auto& key : disp_caps_keys) { + if (strings::window_capabilities == key) { + continue; + } + (*result_display_caps)[0][key] = (*display_capabilities_)[0][key]; + } + + (*result_display_caps)[0][strings::window_capabilities][0] = *find_res; + + return result_display_caps; } void DynamicApplicationDataImpl::load_global_properties( @@ -447,24 +514,198 @@ void DynamicApplicationDataImpl::set_menu_icon( void DynamicApplicationDataImpl::set_day_color_scheme( const smart_objects::SmartObject& color_scheme) { - if (day_color_scheme_) { - delete day_color_scheme_; + using namespace mobile_apis::PredefinedWindows; + DCHECK(color_scheme.getType() == smart_objects::SmartType_Map); + window_templates_[DEFAULT_WINDOW][strings::day_color_scheme] = color_scheme; +} + +void DynamicApplicationDataImpl::set_night_color_scheme( + const smart_objects::SmartObject& color_scheme) { + using namespace mobile_apis::PredefinedWindows; + DCHECK(color_scheme.getType() == smart_objects::SmartType_Map); + window_templates_[DEFAULT_WINDOW][strings::night_color_scheme] = color_scheme; +} + +void DynamicApplicationDataImpl::set_display_layout(const std::string& layout) { + LOG4CXX_AUTO_TRACE(logger_); + using namespace mobile_apis::PredefinedWindows; + smart_objects::SmartObject template_config(smart_objects::SmartType_Map); + template_config[strings::template_layout] = layout; + window_templates_[DEFAULT_WINDOW] = template_config; +} + +void DynamicApplicationDataImpl::set_display_capabilities( + const smart_objects::SmartObject& display_capabilities) { + LOG4CXX_AUTO_TRACE(logger_); + const auto& incoming_window_capabilities = + display_capabilities[0][strings::window_capabilities]; + + smart_objects::SmartObject tmp_window_capabilities; + if (display_capabilities_) { + tmp_window_capabilities = + (*display_capabilities_)[0][strings::window_capabilities]; } - day_color_scheme_ = new smart_objects::SmartObject(color_scheme); + display_capabilities_.reset( + new smart_objects::SmartObject(display_capabilities)); + + auto has_window_id = [&tmp_window_capabilities](const WindowID window_id) { + const auto tmp_window_capabilities_arr = tmp_window_capabilities.asArray(); + if (!tmp_window_capabilities_arr) { + return false; + } + + for (auto element : *tmp_window_capabilities_arr) { + if (element.keyExists(strings::window_id)) { + if (window_id == element[strings::window_id].asInt()) + return true; + } else if (window_id == 0) { + return true; + } + } + + return false; + }; + + for (uint32_t i = 0; i < incoming_window_capabilities.length(); ++i) { + const auto window_id = + incoming_window_capabilities[i][strings::window_id].asInt(); + if (!has_window_id(window_id)) { + tmp_window_capabilities[tmp_window_capabilities.length()] = + incoming_window_capabilities[i]; + } + } + + (*display_capabilities_)[0][strings::window_capabilities] = + tmp_window_capabilities; +} + +void DynamicApplicationDataImpl::remove_window_capability( + const WindowID window_id) { + LOG4CXX_AUTO_TRACE(logger_); + + auto window_capabilities = + (*display_capabilities_)[0][strings::window_capabilities].asArray(); + DCHECK_OR_RETURN_VOID(window_capabilities); + + for (auto it = window_capabilities->begin(); it != window_capabilities->end(); + ++it) { + const auto cur_window_id = (*it).keyExists(strings::window_id) + ? (*it)[strings::window_id].asInt() + : 0; + if (window_id == cur_window_id) { + window_capabilities->erase(it); + return; + } + } + + LOG4CXX_WARN( + logger_, + "No window id " << window_id << " found in display capabilities"); +} + +bool DynamicApplicationDataImpl::menu_layout_supported( + const mobile_apis::MenuLayout::eType layout) const { + if (!display_capabilities_) + return false; + + const auto tmp_window_capabilities_arr = + (*display_capabilities_)[0][strings::window_capabilities].asArray(); + + if (!tmp_window_capabilities_arr) + return false; + + for (auto element : *tmp_window_capabilities_arr) { + if ((!element.keyExists(strings::window_id) || + element[strings::window_id].asInt() == 0) && + element.keyExists(strings::menu_layouts_available)) { + for (uint32_t i = 0; + i < element[strings::menu_layouts_available].length(); + ++i) { + if (static_cast( + element[strings::menu_layouts_available][i].asUInt()) == + layout) { + return true; + } + } + } + } + + return false; +} + +void DynamicApplicationDataImpl::set_window_layout(const WindowID window_id, + const std::string& layout) { + LOG4CXX_AUTO_TRACE(logger_); + smart_objects::SmartObject template_config(smart_objects::SmartType_Map); + + template_config[strings::template_layout] = layout; + window_templates_[window_id] = template_config; +} + +void DynamicApplicationDataImpl::set_day_color_scheme( + const WindowID window_id, const smart_objects::SmartObject& color_scheme) { + LOG4CXX_AUTO_TRACE(logger_); + DCHECK(color_scheme.getType() == smart_objects::SmartType_Map); + window_templates_[window_id][strings::day_color_scheme] = color_scheme; } void DynamicApplicationDataImpl::set_night_color_scheme( - const smart_objects::SmartObject& color_scheme) { - if (night_color_scheme_) { - delete night_color_scheme_; + const WindowID window_id, const smart_objects::SmartObject& color_scheme) { + LOG4CXX_AUTO_TRACE(logger_); + DCHECK(color_scheme.getType() == smart_objects::SmartType_Map); + window_templates_[window_id][strings::night_color_scheme] = color_scheme; +} + +std::string DynamicApplicationDataImpl::window_layout( + const WindowID window_id) const { + LOG4CXX_AUTO_TRACE(logger_); + AppWindowsTemplates::const_iterator window_template_it = + window_templates_.find(window_id); + + if (window_templates_.end() != window_template_it) { + const smart_objects::SmartObject template_config = + window_template_it->second; + if (template_config.keyExists(strings::template_layout)) { + return template_config[strings::template_layout].asString(); + } } - night_color_scheme_ = new smart_objects::SmartObject(color_scheme); + return std::string(); } -void DynamicApplicationDataImpl::set_display_layout(const std::string& layout) { - display_layout_ = layout; +smart_objects::SmartObject DynamicApplicationDataImpl::day_color_scheme( + const WindowID window_id) const { + LOG4CXX_AUTO_TRACE(logger_); + AppWindowsTemplates::const_iterator window_template_it = + window_templates_.find(window_id); + + if (window_templates_.end() != window_template_it) { + const smart_objects::SmartObject template_config = + window_template_it->second; + if (template_config.keyExists(strings::day_color_scheme)) { + return template_config[strings::day_color_scheme]; + } + } + + return smart_objects::SmartObject(smart_objects::SmartType::SmartType_Null); +} + +smart_objects::SmartObject DynamicApplicationDataImpl::night_color_scheme( + const WindowID window_id) const { + LOG4CXX_AUTO_TRACE(logger_); + AppWindowsTemplates::const_iterator window_template_it = + window_templates_.find(window_id); + + if (window_templates_.end() != window_template_it) { + const smart_objects::SmartObject template_config = + window_template_it->second; + if (template_config.keyExists(strings::night_color_scheme)) { + return template_config[strings::night_color_scheme]; + } + } + + return smart_objects::SmartObject(smart_objects::SmartType::SmartType_Null); } void DynamicApplicationDataImpl::SetGlobalProperties( @@ -555,6 +796,33 @@ bool DynamicApplicationDataImpl::IsSubMenuNameAlreadyExist( return false; } +DataAccessor +DynamicApplicationDataImpl::window_optional_params_map() const { + return DataAccessor(window_params_map_, + window_params_map_lock_ptr_); +} + +void DynamicApplicationDataImpl::SetWindowInfo( + const WindowID window_id, const smart_objects::SmartObject& window_info) { + LOG4CXX_AUTO_TRACE(logger_); + const auto it = window_params_map_.find(window_id); + if (window_params_map_.end() == it) { + window_params_map_[window_id] = + std::make_shared(window_info); + } +} + +DisplayCapabilitiesBuilder& +DynamicApplicationDataImpl::display_capabilities_builder() { + LOG4CXX_AUTO_TRACE(logger_); + return display_capabilities_builder_; +} + +void DynamicApplicationDataImpl::RemoveWindowInfo(const WindowID window_id) { + LOG4CXX_AUTO_TRACE(logger_); + window_params_map_.erase(window_id); +} + void DynamicApplicationDataImpl::AddChoiceSet( uint32_t choice_set_id, const smart_objects::SmartObject& choice_set) { sync_primitives::AutoLock lock(choice_set_map_lock_ptr_); diff --git a/src/components/application_manager/src/application_impl.cc b/src/components/application_manager/src/application_impl.cc index 615d3c72cdd..2b328ae9a10 100644 --- a/src/components/application_manager/src/application_impl.cc +++ b/src/components/application_manager/src/application_impl.cc @@ -31,21 +31,21 @@ */ #include "application_manager/application_impl.h" -#include #include -#include "application_manager/message_helper.h" -#include "protocol_handler/protocol_handler.h" +#include #include "application_manager/application_manager.h" +#include "application_manager/message_helper.h" #include "config_profile/profile.h" #include "interfaces/MOBILE_API.h" +#include "protocol_handler/protocol_handler.h" #include "utils/file_system.h" -#include "utils/logger.h" #include "utils/gen_hash.h" +#include "utils/logger.h" -#include "utils/timer_task_impl.h" #include "application_manager/policies/policy_handler_interface.h" #include "application_manager/resumption/resume_ctrl.h" #include "transport_manager/common.h" +#include "utils/timer_task_impl.h" namespace { @@ -113,6 +113,7 @@ ApplicationImpl::ApplicationImpl( , video_streaming_suspended_(true) , audio_streaming_suspended_(true) , is_app_allowed_(true) + , is_app_data_resumption_allowed_(false) , has_been_activated_(false) , tts_properties_in_none_(false) , tts_properties_in_full_(false) @@ -187,7 +188,8 @@ void ApplicationImpl::CloseActiveMessage() { } bool ApplicationImpl::IsFullscreen() const { - return mobile_api::HMILevel::HMI_FULL == hmi_level(); + return mobile_api::HMILevel::HMI_FULL == + hmi_level(mobile_apis::PredefinedWindows::DEFAULT_WINDOW); } bool ApplicationImpl::is_audio() const { @@ -265,19 +267,21 @@ bool ApplicationImpl::IsVideoApplication() const { return is_video_app; } -void ApplicationImpl::SetRegularState(HmiStatePtr state) { +void ApplicationImpl::SetRegularState(const WindowID window_id, + HmiStatePtr state) { LOG4CXX_AUTO_TRACE(logger_); - state_.AddState(state); + state_.AddState(window_id, state); } -void ApplicationImpl::RemovePostponedState() { +void ApplicationImpl::RemovePostponedState(const WindowID window_id) { LOG4CXX_AUTO_TRACE(logger_); - state_.RemoveState(HmiState::STATE_ID_POSTPONED); + state_.RemoveState(window_id, HmiState::STATE_ID_POSTPONED); } -void ApplicationImpl::SetPostponedState(HmiStatePtr state) { +void ApplicationImpl::SetPostponedState(const WindowID window_id, + HmiStatePtr state) { LOG4CXX_AUTO_TRACE(logger_); - state_.AddState(state); + state_.AddState(window_id, state); } void ApplicationImpl::set_mobile_projection_enabled(bool option) { @@ -297,22 +301,56 @@ struct StateIDComparator { } }; -void ApplicationImpl::AddHMIState(HmiStatePtr state) { +void ApplicationImpl::AddHMIState(const WindowID window_id, HmiStatePtr state) { LOG4CXX_AUTO_TRACE(logger_); - state_.AddState(state); + state_.AddState(window_id, state); } -void ApplicationImpl::RemoveHMIState(HmiState::StateID state_id) { +void ApplicationImpl::RemoveHMIState(const WindowID window_id, + HmiState::StateID state_id) { LOG4CXX_AUTO_TRACE(logger_); - state_.RemoveState(state_id); + state_.RemoveState(window_id, state_id); +} + +const HmiStatePtr ApplicationImpl::CurrentHmiState( + const WindowID window_id) const { + return state_.GetState(window_id, HmiState::STATE_ID_CURRENT); } -const HmiStatePtr ApplicationImpl::CurrentHmiState() const { - return state_.GetState(HmiState::STATE_ID_CURRENT); +const HmiStatePtr ApplicationImpl::RegularHmiState( + const WindowID window_id) const { + return state_.GetState(window_id, HmiState::STATE_ID_REGULAR); } -const HmiStatePtr ApplicationImpl::RegularHmiState() const { - return state_.GetState(HmiState::STATE_ID_REGULAR); +WindowNames ApplicationImpl::GetWindowNames() const { + LOG4CXX_DEBUG(logger_, + "Collecting window names for application " << app_id()); + + WindowNames window_names; + std::string stringified_window_names; + + sync_primitives::AutoLock auto_lock(window_params_map_lock_ptr_); + for (const auto& window_info_item : window_params_map_) { + const auto window_name = + (*window_info_item.second)[strings::window_name].asString(); + window_names.push_back(window_name); + stringified_window_names += + (stringified_window_names.empty() ? "" : ",") + window_name; + } + + LOG4CXX_DEBUG(logger_, + "Existing window names: [" + stringified_window_names + "]"); + return window_names; +} + +WindowIds ApplicationImpl::GetWindowIds() const { + LOG4CXX_DEBUG(logger_, "Collecting window IDs for application " << app_id()); + return state_.GetWindowIds(); +} + +bool ApplicationImpl::WindowIdExists(const WindowID window_id) const { + const WindowIds window_ids = GetWindowIds(); + return helpers::in_range(window_ids, window_id); } bool ApplicationImpl::IsAllowedToChangeAudioSource() const { @@ -322,8 +360,9 @@ bool ApplicationImpl::IsAllowedToChangeAudioSource() const { return false; } -const HmiStatePtr ApplicationImpl::PostponedHmiState() const { - return state_.GetState(HmiState::STATE_ID_POSTPONED); +const HmiStatePtr ApplicationImpl::PostponedHmiState( + const WindowID window_id) const { + return state_.GetState(window_id, HmiState::STATE_ID_POSTPONED); } const smart_objects::SmartObject* ApplicationImpl::active_message() const { @@ -354,9 +393,10 @@ bool ApplicationImpl::is_media_application() const { return is_media_; } -const mobile_api::HMILevel::eType ApplicationImpl::hmi_level() const { +const mobile_api::HMILevel::eType ApplicationImpl::hmi_level( + const WindowID window_id) const { using namespace mobile_apis; - const HmiStatePtr hmi_state = CurrentHmiState(); + const HmiStatePtr hmi_state = CurrentHmiState(window_id); return hmi_state ? hmi_state->hmi_level() : HMILevel::INVALID_ENUM; } @@ -380,9 +420,10 @@ const uint32_t ApplicationImpl::list_files_in_none_count() const { return list_files_in_none_count_; } -const mobile_api::SystemContext::eType ApplicationImpl::system_context() const { +const mobile_api::SystemContext::eType ApplicationImpl::system_context( + const WindowID window_id) const { using namespace mobile_apis; - const HmiStatePtr hmi_state = CurrentHmiState(); + const HmiStatePtr hmi_state = CurrentHmiState(window_id); return hmi_state ? hmi_state->system_context() : SystemContext::INVALID_ENUM; ; } @@ -593,7 +634,7 @@ void ApplicationImpl::SuspendStreaming( } void ApplicationImpl::WakeUpStreaming( - protocol_handler::ServiceType service_type) { + protocol_handler::ServiceType service_type, uint32_t timer_len) { using namespace protocol_handler; LOG4CXX_AUTO_TRACE(logger_); @@ -609,8 +650,9 @@ void ApplicationImpl::WakeUpStreaming( ServiceType::kMobileNav, true, application_manager_); video_streaming_suspended_ = false; } - video_stream_suspend_timer_.Start(video_stream_suspend_timeout_, - timer::kPeriodic); + video_stream_suspend_timer_.Start( + timer_len == 0 ? video_stream_suspend_timeout_ : timer_len, + timer::kPeriodic); } else if (ServiceType::kAudio == service_type) { sync_primitives::AutoLock lock(audio_streaming_suspended_lock_); if (audio_streaming_suspended_) { @@ -619,8 +661,9 @@ void ApplicationImpl::WakeUpStreaming( ServiceType::kAudio, true, application_manager_); audio_streaming_suspended_ = false; } - audio_stream_suspend_timer_.Start(audio_stream_suspend_timeout_, - timer::kPeriodic); + audio_stream_suspend_timer_.Start( + timer_len == 0 ? audio_stream_suspend_timeout_ : timer_len, + timer::kPeriodic); } } @@ -680,6 +723,14 @@ void ApplicationImpl::set_app_allowed(const bool allowed) { is_app_allowed_ = allowed; } +bool ApplicationImpl::is_app_data_resumption_allowed() const { + return is_app_data_resumption_allowed_; +} + +void ApplicationImpl::set_app_data_resumption_allowance(const bool allowed) { + is_app_data_resumption_allowed_ = allowed; +} + void ApplicationImpl::set_secondary_device( connection_handler::DeviceHandle secondary_device) { secondary_device_id_ = secondary_device; @@ -849,8 +900,9 @@ bool ApplicationImpl::AreCommandLimitsExceeded( "Time Info: " << "\n Current: " << date_time::getSecs(current) << "\n Limit: (" << date_time::getSecs(limit.first) - << "," << limit.second << ")" - "\n frequency_restrictions: (" + << "," << limit.second + << ")" + "\n frequency_restrictions: (" << frequency_restrictions.first << "," << frequency_restrictions.second << ")"); if (date_time::getSecs(current) < @@ -929,8 +981,10 @@ bool ApplicationImpl::is_application_data_changed() const { return is_application_data_changed_; } -void ApplicationImpl::SetInitialState(HmiStatePtr state) { - state_.InitState(state); +void ApplicationImpl::SetInitialState(const WindowID window_id, + const std::string& window_name, + HmiStatePtr state) { + state_.InitState(window_id, window_name, state); } void ApplicationImpl::set_is_application_data_changed( @@ -1073,21 +1127,58 @@ void ApplicationImpl::SubscribeToSoftButtons( cmd_softbuttonid_[cmd_id] = softbuttons_id; } } else { - cmd_softbuttonid_[cmd_id] = softbuttons_id; + auto& soft_button_ids = cmd_softbuttonid_[cmd_id]; + for (auto& softbutton_item : softbuttons_id) { + soft_button_ids.insert(softbutton_item); + } } } +struct FindSoftButtonId { + uint32_t soft_button_id_; + + FindSoftButtonId(const uint32_t soft_button_id) + : soft_button_id_(soft_button_id) {} + + bool operator()(const std::pair& element) { + return soft_button_id_ == element.first; + } +}; + bool ApplicationImpl::IsSubscribedToSoftButton(const uint32_t softbutton_id) { + LOG4CXX_AUTO_TRACE(logger_); sync_primitives::AutoLock lock(cmd_softbuttonid_lock_); CommandSoftButtonID::iterator it = cmd_softbuttonid_.begin(); for (; it != cmd_softbuttonid_.end(); ++it) { - if ((it->second).find(softbutton_id) != (it->second).end()) { + const auto& soft_button_ids = (*it).second; + FindSoftButtonId finder(softbutton_id); + const auto find_res = + std::find_if(soft_button_ids.begin(), soft_button_ids.end(), finder); + if ((soft_button_ids.end() != find_res)) { return true; } } return false; } +WindowID ApplicationImpl::GetSoftButtonWindowID(const uint32_t softbutton_id) { + LOG4CXX_AUTO_TRACE(logger_); + + sync_primitives::AutoLock lock(cmd_softbuttonid_lock_); + CommandSoftButtonID::iterator it = cmd_softbuttonid_.begin(); + for (; it != cmd_softbuttonid_.end(); ++it) { + const auto& soft_button_ids = (*it).second; + FindSoftButtonId finder(softbutton_id); + const auto find_res = + std::find_if(soft_button_ids.begin(), soft_button_ids.end(), finder); + if ((soft_button_ids.end() != find_res)) { + return find_res->second; + } + } + + return mobile_apis::PredefinedWindows::DEFAULT_WINDOW; +} + void ApplicationImpl::UnsubscribeFromSoftButtons(int32_t cmd_id) { sync_primitives::AutoLock lock(cmd_softbuttonid_lock_); CommandSoftButtonID::iterator it = cmd_softbuttonid_.find(cmd_id); @@ -1097,8 +1188,9 @@ void ApplicationImpl::UnsubscribeFromSoftButtons(int32_t cmd_id) { } void ApplicationImpl::set_system_context( + const WindowID window_id, const mobile_api::SystemContext::eType& system_context) { - const HmiStatePtr hmi_state = CurrentHmiState(); + HmiStatePtr hmi_state = CurrentHmiState(window_id); hmi_state->set_system_context(system_context); } @@ -1111,13 +1203,20 @@ void ApplicationImpl::set_audio_streaming_state( " for non-media application to different from NOT_AUDIBLE"); return; } - CurrentHmiState()->set_audio_streaming_state(state); + + // According to proposal SDL-0216 audio streaming state should + // be applied for all windows to keep consistency + HmiStates hmi_states = state_.GetStates(HmiState::STATE_ID_CURRENT); + for (const auto& hmi_state : hmi_states) { + hmi_state->set_audio_streaming_state(state); + } } void ApplicationImpl::set_hmi_level( + const WindowID window_id, const mobile_api::HMILevel::eType& new_hmi_level) { using namespace mobile_apis; - const HMILevel::eType current_hmi_level = hmi_level(); + const HMILevel::eType current_hmi_level = hmi_level(window_id); if (HMILevel::HMI_NONE != current_hmi_level && HMILevel::HMI_NONE == new_hmi_level) { put_file_in_none_count_ = 0; @@ -1126,7 +1225,8 @@ void ApplicationImpl::set_hmi_level( } ApplicationSharedPtr app = application_manager_.application(app_id()); DCHECK_OR_RETURN_VOID(app) - application_manager_.state_controller().SetRegularState(app, new_hmi_level); + application_manager_.state_controller().SetRegularState( + app, window_id, new_hmi_level); LOG4CXX_INFO(logger_, "hmi_level = " << new_hmi_level); usage_report_.RecordHmiStateChanged(new_hmi_level); } @@ -1152,9 +1252,9 @@ bool ApplicationImpl::AddExtension(AppExtensionPtr extension) { bool ApplicationImpl::RemoveExtension(AppExtensionUID uid) { auto it = std::find_if( - extensions_.begin(), - extensions_.end(), - [uid](AppExtensionPtr extension) { return extension->uid() == uid; }); + extensions_.begin(), extensions_.end(), [uid](AppExtensionPtr extension) { + return extension->uid() == uid; + }); return it != extensions_.end(); } @@ -1215,6 +1315,15 @@ void ApplicationImpl::set_cloud_app_certificate( certificate_ = certificate; } +void ApplicationImpl::set_user_location( + const smart_objects::SmartObject& user_location) { + user_location_ = user_location; +} + +const smart_objects::SmartObject& ApplicationImpl::get_user_location() const { + return user_location_; +} + void ApplicationImpl::PushMobileMessage( smart_objects::SmartObjectSPtr mobile_message) { sync_primitives::AutoLock lock(mobile_message_lock_); diff --git a/src/components/application_manager/src/application_manager_impl.cc b/src/components/application_manager/src/application_manager_impl.cc index a071edbbfca..8044e8b6cd1 100644 --- a/src/components/application_manager/src/application_manager_impl.cc +++ b/src/components/application_manager/src/application_manager_impl.cc @@ -32,48 +32,49 @@ #include // for rand() +#include #include -#include #include +#include #include -#include +#include "application_manager/app_launch/app_launch_ctrl_impl.h" +#include "application_manager/app_launch/app_launch_data_db.h" +#include "application_manager/app_launch/app_launch_data_json.h" #include "application_manager/application_manager_impl.h" +#include "application_manager/command_holder_impl.h" #include "application_manager/commands/command_impl.h" #include "application_manager/commands/command_notification_impl.h" +#include "application_manager/helpers/application_helper.h" +#include "application_manager/hmi_capabilities_impl.h" #include "application_manager/message_helper.h" -#include "application_manager/rpc_service_impl.h" -#include "application_manager/rpc_handler_impl.h" #include "application_manager/mobile_message_handler.h" +#include "application_manager/plugin_manager/rpc_plugin_manager_impl.h" #include "application_manager/policies/policy_handler.h" -#include "application_manager/hmi_capabilities_impl.h" #include "application_manager/resumption/resume_ctrl_impl.h" -#include "application_manager/app_launch/app_launch_ctrl_impl.h" -#include "application_manager/app_launch/app_launch_data_db.h" -#include "application_manager/app_launch/app_launch_data_json.h" -#include "application_manager/helpers/application_helper.h" -#include "application_manager/plugin_manager/rpc_plugin_manager_impl.h" -#include "protocol_handler/protocol_handler.h" -#include "hmi_message_handler/hmi_message_handler.h" -#include "application_manager/command_holder_impl.h" +#include "application_manager/rpc_handler_impl.h" +#include "application_manager/rpc_protection_manager_impl.h" +#include "application_manager/rpc_service_impl.h" #include "connection_handler/connection_handler_impl.h" -#include "formatters/formatter_json_rpc.h" -#include "formatters/CFormatterJsonSDLRPCv2.h" #include "formatters/CFormatterJsonSDLRPCv1.h" +#include "formatters/CFormatterJsonSDLRPCv2.h" +#include "formatters/formatter_json_rpc.h" +#include "hmi_message_handler/hmi_message_handler.h" #include "protocol/bson_object_keys.h" +#include "protocol_handler/protocol_handler.h" -#include "utils/threads/thread.h" -#include "utils/file_system.h" -#include "utils/helpers.h" -#include "utils/timer_task_impl.h" -#include "smart_objects/enum_schema_item.h" -#include "interfaces/HMI_API_schema.h" +#include +#include #include "application_manager/application_impl.h" +#include "interfaces/HMI_API_schema.h" #include "media_manager/media_manager.h" #include "policy/usage_statistics/counter.h" +#include "smart_objects/enum_schema_item.h" #include "utils/custom_string.h" -#include -#include +#include "utils/file_system.h" +#include "utils/helpers.h" +#include "utils/threads/thread.h" +#include "utils/timer_task_impl.h" namespace { int get_rand_from_range(uint32_t from = 0, int to = RAND_MAX) { @@ -121,17 +122,26 @@ bool device_id_comparator(const std::string& device_id, } /** - * @brief policy_app_id_comparator is predicate to compare policy application - * ids - * @param policy_app_id Policy id of application - * @param app Application pointer - * @return True if policy id of application matches to policy id passed + * @brief PolicyAppIdComparator is struct predicate to compare policy + * application ids & device + * @param device_handle of application + * @param id of application + * @return True if policy id & device_handle of application matches to policy id + * & device_handle passed */ -bool policy_app_id_comparator(const std::string& policy_app_id, - ApplicationSharedPtr app) { - DCHECK_OR_RETURN(app, false); - return app->policy_app_id() == policy_app_id; -} +struct PolicyAppIdComparator { + PolicyAppIdComparator(const connection_handler::DeviceHandle& device_handle, + const std::string& policy_app_id) + : device_handle_(device_handle), policy_app_id_(policy_app_id) {} + bool operator()(const ApplicationSharedPtr app) const { + return app && app->device() == device_handle_ && + app->policy_app_id() == policy_app_id_; + } + + private: + const connection_handler::DeviceHandle& device_handle_; + const std::string& policy_app_id_; +}; uint32_t ApplicationManagerImpl::mobile_corelation_id_ = 0; uint32_t ApplicationManagerImpl::corelation_id_ = 0; @@ -149,6 +159,7 @@ ApplicationManagerImpl::ApplicationManagerImpl( , applications_list_lock_ptr_( std::make_shared()) , apps_to_register_list_lock_ptr_(std::make_shared()) + , reregister_wait_list_lock_ptr_(std::make_shared()) , audio_pass_thru_active_(false) , audio_pass_thru_app_id_(0) , driver_distraction_state_(hmi_apis::Common_DriverDistractionState::DD_OFF) @@ -198,13 +209,20 @@ ApplicationManagerImpl::ApplicationManagerImpl( const uint32_t timeout_ms = 10000u; clearing_timer->Start(timeout_ms, timer::kSingleShot); timer_pool_.push_back(clearing_timer); - rpc_handler_.reset(new rpc_handler::RPCHandlerImpl(*this)); + rpc_handler_.reset(new rpc_handler::RPCHandlerImpl( + *this, hmi_so_factory(), mobile_so_factory())); commands_holder_.reset(new CommandHolderImpl(*this)); + std::shared_ptr rpc_protection_manager = + std::make_shared(*policy_handler_); + policy_handler_->add_listener(rpc_protection_manager.get()); rpc_service_.reset(new rpc_service::RPCServiceImpl(*this, request_ctrl_, protocol_handler_, hmi_handler_, - *commands_holder_)); + *commands_holder_, + rpc_protection_manager, + hmi_so_factory(), + mobile_so_factory())); } ApplicationManagerImpl::~ApplicationManagerImpl() { @@ -249,6 +267,13 @@ ApplicationManagerImpl::pending_applications() const { return accessor; } +DataAccessor +ApplicationManagerImpl::reregister_applications() const { + DataAccessor accessor(reregister_wait_list_, + reregister_wait_list_lock_ptr_); + return accessor; +} + ApplicationSharedPtr ApplicationManagerImpl::application( uint32_t app_id) const { AppIdPredicate finder(app_id); @@ -284,6 +309,14 @@ ApplicationSharedPtr ApplicationManagerImpl::pending_application_by_policy_id( return FindPendingApp(accessor, finder); } +ApplicationSharedPtr +ApplicationManagerImpl::reregister_application_by_policy_id( + const std::string& policy_app_id) const { + PolicyAppIdPredicate finder(policy_app_id); + DataAccessor accessor = reregister_applications(); + return FindReregisterApp(accessor, finder); +} + bool ActiveAppPredicate(const ApplicationSharedPtr app) { return app ? app->IsFullscreen() : false; } @@ -295,7 +328,9 @@ ApplicationSharedPtr ApplicationManagerImpl::active_application() const { } bool LimitedAppPredicate(const ApplicationSharedPtr app) { - return app ? app->hmi_level() == mobile_api::HMILevel::HMI_LIMITED : false; + return app ? app->hmi_level(mobile_api::PredefinedWindows::DEFAULT_WINDOW) == + mobile_api::HMILevel::HMI_LIMITED + : false; } ApplicationSharedPtr ApplicationManagerImpl::get_limited_media_application() @@ -306,7 +341,8 @@ ApplicationSharedPtr ApplicationManagerImpl::get_limited_media_application() bool LimitedNaviAppPredicate(const ApplicationSharedPtr app) { return app ? (app->is_navi() && - app->hmi_level() == mobile_api::HMILevel::HMI_LIMITED) + app->hmi_level(mobile_api::PredefinedWindows::DEFAULT_WINDOW) == + mobile_api::HMILevel::HMI_LIMITED) : false; } @@ -318,7 +354,8 @@ ApplicationSharedPtr ApplicationManagerImpl::get_limited_navi_application() bool LimitedVoiceAppPredicate(const ApplicationSharedPtr app) { return app ? (app->is_voice_communication_supported() && - app->hmi_level() == mobile_api::HMILevel::HMI_LIMITED) + app->hmi_level(mobile_api::PredefinedWindows::DEFAULT_WINDOW) == + mobile_api::HMILevel::HMI_LIMITED) : false; } @@ -340,7 +377,8 @@ ApplicationManagerImpl::applications_with_navi() { bool LimitedMobileProjectionPredicate(const ApplicationSharedPtr app) { return app ? (app->mobile_projection_enabled() && - app->hmi_level() == mobile_api::HMILevel::HMI_LIMITED) + app->hmi_level(mobile_api::PredefinedWindows::DEFAULT_WINDOW) == + mobile_api::HMILevel::HMI_LIMITED) : false; } @@ -381,16 +419,12 @@ struct IsApplication { connection_handler::DeviceHandle device_handle_; const std::string& policy_app_id_; }; -void ApplicationManagerImpl::IviInfoUpdated( - mobile_apis::VehicleDataType::eType vehicle_info, int value) { +void ApplicationManagerImpl::IviInfoUpdated(const std::string& vehicle_info, + int value) { // Notify Policy Manager if available about info it's interested in, // i.e. odometer etc - switch (vehicle_info) { - case mobile_apis::VehicleDataType::VEHICLEDATA_ODOMETER: - GetPolicyHandler().KmsChanged(value); - break; - default: - break; + if (strings::odometer == vehicle_info) { + GetPolicyHandler().KmsChanged(value); } } @@ -565,12 +599,16 @@ ApplicationSharedPtr ApplicationManagerImpl::RegisterApplication( HmiStatePtr initial_state = CreateRegularState(std::shared_ptr(application), + mobile_apis::WindowType::MAIN, mobile_apis::HMILevel::INVALID_ENUM, mobile_apis::AudioStreamingState::INVALID_ENUM, mobile_apis::VideoStreamingState::INVALID_ENUM, mobile_api::SystemContext::SYSCTXT_MAIN); - application->SetInitialState(initial_state); + application->SetInitialState( + mobile_apis::PredefinedWindows::DEFAULT_WINDOW, + std::string(), // should not be tracked for main window + initial_state); application->set_folder_name(policy_app_id + "_" + application->mac_address()); @@ -595,11 +633,13 @@ ApplicationSharedPtr ApplicationManagerImpl::RegisterApplication( Version version; int32_t min_version = message[strings::msg_params][strings::sync_msg_version] - [strings::minor_version].asInt(); + [strings::minor_version] + .asInt(); version.min_supported_api_version = static_cast(min_version); int32_t max_version = message[strings::msg_params][strings::sync_msg_version] - [strings::major_version].asInt(); + [strings::major_version] + .asInt(); version.max_supported_api_version = static_cast(max_version); application->set_version(version); @@ -724,18 +764,15 @@ bool ApplicationManagerImpl::ActivateApplication(ApplicationSharedPtr app) { LOG4CXX_DEBUG(logger_, "Activating application with id:" << app->app_id()); - // remove from resumption if app was activated by user + // Remove from resumption if app was activated by user resume_controller().OnAppActivated(app); + // Activate any app services published by the app GetAppServiceManager().OnAppActivated(app); - const HMILevel::eType hmi_level = HMILevel::HMI_FULL; - const AudioStreamingState::eType audio_state = - app->IsAudioApplication() ? AudioStreamingState::AUDIBLE - : AudioStreamingState::NOT_AUDIBLE; - const VideoStreamingState::eType video_state = - app->IsVideoApplication() ? VideoStreamingState::STREAMABLE - : VideoStreamingState::NOT_STREAMABLE; - state_ctrl_.SetRegularState(app, hmi_level, audio_state, video_state, false); + + // Activate main window in state controller + state_ctrl_.ActivateDefaultWindow(app); + return true; } @@ -1061,9 +1098,9 @@ void ApplicationManagerImpl::RefreshCloudAppInformation() { ApplicationSet::iterator it = std::find_if( apps_to_register_.begin(), apps_to_register_.end(), finder); if (it == apps_to_register_.end()) { - LOG4CXX_DEBUG(logger_, - "Unable to find app to remove (" << policy_app_id - << "), skipping"); + LOG4CXX_DEBUG( + logger_, + "Unable to find app to remove (" << policy_app_id << "), skipping"); continue; } app = *it; @@ -1303,11 +1340,13 @@ void ApplicationManagerImpl::SetAllAppsAllowed(const bool allowed) { HmiStatePtr ApplicationManagerImpl::CreateRegularState( std::shared_ptr app, - mobile_apis::HMILevel::eType hmi_level, - mobile_apis::AudioStreamingState::eType audio_state, - mobile_apis::VideoStreamingState::eType video_state, - mobile_apis::SystemContext::eType system_context) const { + const mobile_apis::WindowType::eType window_type, + const mobile_apis::HMILevel::eType hmi_level, + const mobile_apis::AudioStreamingState::eType audio_state, + const mobile_apis::VideoStreamingState::eType video_state, + const mobile_apis::SystemContext::eType system_context) const { HmiStatePtr state(new HmiState(app, *this)); + state->set_window_type(window_type); state->set_hmi_level(hmi_level); state->set_audio_streaming_state(audio_state); state->set_video_streaming_state(video_state); @@ -1531,7 +1570,7 @@ void ApplicationManagerImpl::OnDeviceSwitchingStart( { // During sending of UpdateDeviceList this lock is acquired also so making // it scoped - sync_primitives::AutoLock lock(reregister_wait_list_lock_); + sync_primitives::AutoLock lock(reregister_wait_list_lock_ptr_); for (auto i = reregister_wait_list_.begin(); reregister_wait_list_.end() != i; ++i) { @@ -1571,7 +1610,7 @@ void ApplicationManagerImpl::OnDeviceSwitchingFinish( const std::string& device_uid) { LOG4CXX_AUTO_TRACE(logger_); UNUSED(device_uid); - sync_primitives::AutoLock lock(reregister_wait_list_lock_); + sync_primitives::AutoLock lock(reregister_wait_list_lock_ptr_); const bool unexpected_disonnect = true; const bool is_resuming = true; @@ -1629,7 +1668,8 @@ mobile_apis::HMILevel::eType ApplicationManagerImpl::GetDefaultHmiLevel( if (GetPolicyHandler().PolicyEnabled()) { const std::string policy_app_id = application->policy_app_id(); std::string default_hmi_string = ""; - if (GetPolicyHandler().GetDefaultHmi(policy_app_id, &default_hmi_string)) { + if (GetPolicyHandler().GetDefaultHmi( + application->mac_address(), policy_app_id, &default_hmi_string)) { if ("BACKGROUND" == default_hmi_string) { default_hmi = HMILevel::HMI_BACKGROUND; } else if ("FULL" == default_hmi_string) { @@ -1887,21 +1927,21 @@ void ApplicationManagerImpl::OnServiceStartedCallback( using namespace helpers; using namespace protocol_handler; LOG4CXX_AUTO_TRACE(logger_); - LOG4CXX_DEBUG(logger_, - "ServiceType = " << type << ". Session = " << std::hex - << session_key); + LOG4CXX_DEBUG( + logger_, + "ServiceType = " << type << ". Session = " << std::hex << session_key); std::vector empty; - if (type == kRpc) { + if (kRpc == type) { LOG4CXX_DEBUG(logger_, "RPC service is about to be started."); connection_handler().NotifyServiceStartedResult(session_key, true, empty); return; } ApplicationSharedPtr app = application(session_key); if (!app) { - LOG4CXX_WARN(logger_, - "The application with id:" << session_key - << " doesn't exists."); + LOG4CXX_WARN( + logger_, + "The application with id:" << session_key << " doesn't exists."); connection_handler().NotifyServiceStartedResult(session_key, false, empty); return; } @@ -1919,6 +1959,7 @@ void ApplicationManagerImpl::OnServiceStartedCallback( } else { LOG4CXX_WARN(logger_, "Refuse unknown service"); } + connection_handler().NotifyServiceStartedResult(session_key, false, empty); } @@ -1941,7 +1982,7 @@ void ApplicationManagerImpl::OnServiceEndedCallback( return; } - if (IsAppInReconnectMode(app->policy_app_id())) { + if (IsAppInReconnectMode(app->device(), app->policy_app_id())) { LOG4CXX_DEBUG(logger_, "Application is in reconnection list and won't be closed."); return; @@ -2001,6 +2042,79 @@ void ApplicationManagerImpl::OnServiceEndedCallback( } } +void ApplicationManagerImpl::ProcessServiceStatusUpdate( + const uint32_t connection_key, + hmi_apis::Common_ServiceType::eType service_type, + hmi_apis::Common_ServiceEvent::eType service_event, + utils::Optional + service_update_reason) { + LOG4CXX_AUTO_TRACE(logger_); + + LOG4CXX_DEBUG(logger_, + "Processing status update with connection key: " + << connection_key << " service type: " << service_type + << " service_event " << service_event + << " service_update_reason " << service_update_reason); + + const auto app = application(connection_key); + + const uint32_t app_id = app ? app->app_id() : 0u; + + auto reason = service_update_reason + ? *service_update_reason + : hmi_apis::Common_ServiceStatusUpdateReason::INVALID_ENUM; + + auto notification = MessageHelper::CreateOnServiceUpdateNotification( + service_type, service_event, reason, app_id); + + rpc_service_->ManageHMICommand(notification); + + if (hmi_apis::Common_ServiceEvent::REQUEST_REJECTED == service_event && + HandleRejectedServiceStatus(app, service_type)) { + state_ctrl_.SetRegularState(app, + mobile_apis::PredefinedWindows::DEFAULT_WINDOW, + mobile_apis::HMILevel::HMI_NONE, + true); + } +} + +bool ApplicationManagerImpl::HandleRejectedServiceStatus( + ApplicationSharedPtr app, + const hmi_apis::Common_ServiceType::eType service_type) { + LOG4CXX_AUTO_TRACE(logger_); + if (!app) { + LOG4CXX_WARN(logger_, "Received invalid app"); + return false; + } + + switch (service_type) { + case hmi_apis::Common_ServiceType::VIDEO: + case hmi_apis::Common_ServiceType::AUDIO: { + { + sync_primitives::AutoLock lock(navi_service_status_lock_); + auto app_services = navi_service_status_.find(app->app_id()); + if (navi_service_status_.end() != app_services) { + navi_service_status_.erase(app_services); + } + } + LOG4CXX_DEBUG(logger_, + "The start of service" + << service_type << " for appID: " << app + << " is failed. Service info has been removed"); + return true; + } + case hmi_apis::Common_ServiceType::RPC: { + connection_handler().SendEndService(app->app_id(), + protocol_handler::ServiceType::kRpc); + LOG4CXX_DEBUG(logger_, "RPC service for appID: " << app << " is stopped"); + return true; + } + default: + LOG4CXX_DEBUG(logger_, "Unknown service type: " << service_type); + return false; + } +} + void ApplicationManagerImpl::OnSecondaryTransportStartedCallback( const connection_handler::DeviceHandle device_handle, const int32_t session_key) { @@ -2061,9 +2175,9 @@ void ApplicationManagerImpl::OnSecondaryTransportEndedCallback( connection_handler::DeviceHandle device_handle = app->secondary_device(); if (device_handle == 0) { - LOG4CXX_WARN(logger_, - "Secondary transport of app " << session_key - << " is not found"); + LOG4CXX_WARN( + logger_, + "Secondary transport of app " << session_key << " is not found"); return; } @@ -2093,7 +2207,12 @@ bool ApplicationManagerImpl::OnHandshakeDone( using namespace helpers; ApplicationSharedPtr app = application(connection_key); - DCHECK_OR_RETURN(app, false); + if (!app) { + LOG4CXX_WARN(logger_, + "Application for connection key: " << connection_key + << " was not found"); + return false; + } if (Compare( result, SSLContext::Handshake_Result_CertExpired, @@ -2105,8 +2224,14 @@ bool ApplicationManagerImpl::OnHandshakeDone( } return false; } +#ifdef ENABLE_SECURITY +bool ApplicationManagerImpl::OnPTUFailed() { + LOG4CXX_AUTO_TRACE(logger_); + return false; +} +#endif // ENABLE_SECURITY -bool ApplicationManagerImpl::OnHandshakeFailed() { +bool ApplicationManagerImpl::OnGetSystemTimeFailed() { LOG4CXX_AUTO_TRACE(logger_); return false; } @@ -2194,7 +2319,7 @@ bool ApplicationManagerImpl::Init(resumption::LastState& last_state, media_manager::MediaManager* media_manager) { LOG4CXX_TRACE(logger_, "Init application manager"); plugin_manager_.reset(new plugin_manager::RPCPluginManagerImpl( - *this, *rpc_service_, *hmi_capabilities_, *policy_handler_)); + *this, *rpc_service_, *hmi_capabilities_, *policy_handler_, last_state)); if (!plugin_manager_->LoadPlugins(get_settings().plugins_folder())) { LOG4CXX_ERROR(logger_, "Plugins are not loaded"); return false; @@ -2257,6 +2382,13 @@ bool ApplicationManagerImpl::Init(resumption::LastState& last_state, app_service_manager_.reset( new application_manager::AppServiceManager(*this, last_state)); + + auto on_app_policy_updated = [](plugin_manager::RPCPlugin& plugin) { + plugin.OnPolicyEvent(plugin_manager::kApplicationPolicyUpdated); + }; + + plugin_manager_->ForEachPlugin(on_app_policy_updated); + return true; } @@ -2280,6 +2412,8 @@ bool ApplicationManagerImpl::Stop() { LOG4CXX_DEBUG(logger_, "Unloading policy library."); GetPolicyHandler().UnloadPolicyLibrary(); + rpc_service_->Stop(); + return true; } @@ -2488,8 +2622,24 @@ void ApplicationManagerImpl::CreateApplications(SmartArray& obj_array, } const std::string policy_app_id(app_data[json::appId].asString()); - ApplicationSharedPtr registered_app = - application_by_policy_id(policy_app_id); + + connection_handler::DeviceHandle device_handle; + if (-1 == connection_handler().get_session_observer().GetDataOnSessionKey( + connection_key, nullptr, nullptr, &device_handle)) { + LOG4CXX_ERROR(logger_, + "Failed to create application: no connection info."); + continue; + } + + std::string device_id; + if (-1 == connection_handler().get_session_observer().GetDataOnDeviceID( + device_handle, nullptr, nullptr, &device_id)) { + LOG4CXX_ERROR(logger_, + "Failed to create application: no connection info."); + continue; + } + + ApplicationSharedPtr registered_app = application(device_id, policy_app_id); if (registered_app) { LOG4CXX_DEBUG(logger_, "Application with the same id: " @@ -2528,23 +2678,9 @@ void ApplicationManagerImpl::CreateApplications(SmartArray& obj_array, const std::string app_icon_dir(settings_.app_icons_folder()); const std::string full_icon_path(app_icon_dir + "/" + policy_app_id); - connection_handler::DeviceHandle device_id = 0; - - if (-1 == - connection_handler().get_session_observer().GetDataOnSessionKey( - connection_key, NULL, NULL, &device_id)) { - LOG4CXX_ERROR(logger_, - "Failed to create application: no connection info."); - continue; - } - - std::string device_mac; - connection_handler().get_session_observer().GetDataOnDeviceID( - device_id, NULL, NULL, &device_mac, NULL); - const uint32_t hmi_app_id = - resume_controller().IsApplicationSaved(policy_app_id, device_mac) - ? resume_controller().GetHMIApplicationID(policy_app_id, device_mac) + resume_controller().IsApplicationSaved(policy_app_id, device_id) + ? resume_controller().GetHMIApplicationID(policy_app_id, device_id) : GenerateNewHMIAppID(); // AppId = 0 because this is query_app(provided by hmi for download, but not @@ -2552,8 +2688,8 @@ void ApplicationManagerImpl::CreateApplications(SmartArray& obj_array, ApplicationSharedPtr app( new ApplicationImpl(0, policy_app_id, - device_mac, device_id, + device_handle, appName, GetPolicyHandler().GetStatisticManager(), *this)); @@ -2871,9 +3007,9 @@ void ApplicationManagerImpl::RemoveAppsWaitingForRegistration( apps_to_register_.begin(), apps_to_register_.end(), device_finder); while (apps_to_register_.end() != it_app) { - LOG4CXX_DEBUG(logger_, - "Waiting app: " << (*it_app)->name().c_str() - << " is removed."); + LOG4CXX_DEBUG( + logger_, + "Waiting app: " << (*it_app)->name().c_str() << " is removed."); apps_to_register_.erase(it_app); it_app = std::find_if( apps_to_register_.begin(), apps_to_register_.end(), device_finder); @@ -3019,6 +3155,9 @@ void ApplicationManagerImpl::UnregisterApplication( MessageHelper::SendOnAppUnregNotificationToHMI( app_to_remove, is_unexpected_disconnect, *this); request_ctrl_.terminateAppRequests(app_id); + if (applications_.empty()) { + policy_handler_->StopRetrySequence(); + } return; } @@ -3029,6 +3168,7 @@ void ApplicationManagerImpl::OnAppUnauthorized(const uint32_t& app_id) { mobile_apis::Result::eType ApplicationManagerImpl::CheckPolicyPermissions( const ApplicationSharedPtr app, + const WindowID window_id, const std::string& function_id, const RPCParams& rpc_params, CommandParametersPermissions* params_permissions) { @@ -3041,7 +3181,8 @@ mobile_apis::Result::eType ApplicationManagerImpl::CheckPolicyPermissions( DCHECK(app); policy::CheckPermissionResult result; - GetPolicyHandler().CheckPermissions(app, function_id, rpc_params, result); + GetPolicyHandler().CheckPermissions( + app, window_id, function_id, rpc_params, result); if (NULL != params_permissions) { params_permissions->allowed_params = result.list_of_allowed_params; @@ -3049,7 +3190,9 @@ mobile_apis::Result::eType ApplicationManagerImpl::CheckPolicyPermissions( params_permissions->undefined_params = result.list_of_undefined_params; } - if (app->hmi_level() == mobile_apis::HMILevel::HMI_NONE && + // Record statistics for default window only + if (app->hmi_level(mobile_apis::PredefinedWindows::DEFAULT_WINDOW) == + mobile_apis::HMILevel::HMI_NONE && function_id != MessageHelper::StringifiedFunctionID( mobile_apis::FunctionID::UnregisterAppInterfaceID)) { if (result.hmi_level_permitted != policy::kRpcAllowed) { @@ -3060,7 +3203,8 @@ mobile_apis::Result::eType ApplicationManagerImpl::CheckPolicyPermissions( #ifdef ENABLE_LOG const std::string log_msg = "Application: " + app->policy_app_id() + ", RPC: " + function_id + - ", HMI status: " + MessageHelper::StringifiedHMILevel(app->hmi_level()); + ", window_id: " + std::to_string(window_id) + ", HMI status: " + + MessageHelper::StringifiedHMILevel(app->hmi_level(window_id)); #endif // ENABLE_LOG if (result.hmi_level_permitted != policy::kRpcAllowed) { LOG4CXX_WARN(logger_, "Request is blocked by policies. " << log_msg); @@ -3104,10 +3248,10 @@ bool ApplicationManagerImpl::IsLowVoltage() const { void ApplicationManagerImpl::OnWakeUp() { LOG4CXX_AUTO_TRACE(logger_); - is_low_voltage_ = false; resume_ctrl_->SaveWakeUpTime(); resume_ctrl_->StartSavePersistentDataTimer(); request_ctrl_.OnWakeUp(); + is_low_voltage_ = false; } std::string ApplicationManagerImpl::GetHashedAppID( @@ -3133,7 +3277,10 @@ bool ApplicationManagerImpl::HMILevelAllowsStreaming( LOG4CXX_WARN(logger_, "An application is not registered."); return false; } - return Compare(app->hmi_level(), HMI_FULL, HMI_LIMITED); + return Compare( + app->hmi_level(mobile_api::PredefinedWindows::DEFAULT_WINDOW), + HMI_FULL, + HMI_LIMITED); } bool ApplicationManagerImpl::CanAppStream( @@ -3263,6 +3410,7 @@ void ApplicationManagerImpl::EndNaviServices(uint32_t app_id) { connection_handler().SendEndService(app_id, ServiceType::kAudio); app->StopStreamingForce(ServiceType::kAudio); } + DisallowStreaming(app_id); navi_app_to_stop_.push_back(app_id); @@ -3297,14 +3445,16 @@ void ApplicationManagerImpl::ProcessPostponedMessages(const uint32_t app_id) { } MobileMessageQueue messages; app->SwapMobileMessageQueue(messages); - auto push_allowed_messages = [this, &app]( - smart_objects::SmartObjectSPtr message) { + auto push_allowed_messages = [this, + &app](smart_objects::SmartObjectSPtr message) { const std::string function_id = MessageHelper::StringifiedFunctionID( static_cast( (*message)[strings::params][strings::function_id].asUInt())); + const WindowID window_id = MessageHelper::ExtractWindowIdFromSmartObject( + (*message)[strings::msg_params]); const RPCParams params; const mobile_apis::Result::eType check_result = - CheckPolicyPermissions(app, function_id, params); + CheckPolicyPermissions(app, window_id, function_id, params); if (mobile_api::Result::SUCCESS == check_result) { rpc_service_->ManageMobileCommand(message, commands::Command::SOURCE_SDL); } else { @@ -3359,39 +3509,6 @@ void ApplicationManagerImpl::ProcessApp(const uint32_t app_id, } } -void ApplicationManagerImpl::SendHMIStatusNotification( - const std::shared_ptr app) { - LOG4CXX_AUTO_TRACE(logger_); - DCHECK_OR_RETURN_VOID(app); - smart_objects::SmartObjectSPtr notification = - std::make_shared(); - smart_objects::SmartObject& message = *notification; - - message[strings::params][strings::function_id] = - static_cast(mobile_api::FunctionID::OnHMIStatusID); - - message[strings::params][strings::message_type] = - static_cast(application_manager::MessageType::kNotification); - - message[strings::params][strings::connection_key] = - static_cast(app->app_id()); - - message[strings::msg_params][strings::hmi_level] = - static_cast(app->hmi_level()); - - message[strings::msg_params][strings::audio_streaming_state] = - static_cast(app->audio_streaming_state()); - - message[strings::msg_params][strings::video_streaming_state] = - static_cast(app->video_streaming_state()); - - message[strings::msg_params][strings::system_context] = - static_cast(app->system_context()); - - rpc_service_->ManageMobileCommand(notification, - commands::Command::SOURCE_SDL); -} - void ApplicationManagerImpl::ClearTimerPool() { LOG4CXX_AUTO_TRACE(logger_); @@ -3513,14 +3630,14 @@ bool ApplicationManagerImpl::IsApplicationForbidden( } bool ApplicationManagerImpl::IsAppInReconnectMode( + const connection_handler::DeviceHandle& device_id, const std::string& policy_app_id) const { LOG4CXX_AUTO_TRACE(logger_); - sync_primitives::AutoLock lock(reregister_wait_list_lock_); + sync_primitives::AutoLock lock(reregister_wait_list_lock_ptr_); return reregister_wait_list_.end() != std::find_if(reregister_wait_list_.begin(), reregister_wait_list_.end(), - std::bind1st(std::ptr_fun(&policy_app_id_comparator), - policy_app_id)); + PolicyAppIdComparator(device_id, policy_app_id)); } policy::DeviceConsent ApplicationManagerImpl::GetUserConsentForDevice( @@ -3822,13 +3939,18 @@ void ApplicationManagerImpl::OnUpdateHMIAppType( if (flag_diffirence_app_hmi_type) { (*it)->set_app_types(transform_app_hmi_types); (*it)->ChangeSupportingAppHMIType(); - if ((*it)->hmi_level() == mobile_api::HMILevel::HMI_BACKGROUND) { + const mobile_apis::HMILevel::eType app_hmi_level = + (*it)->hmi_level(mobile_apis::PredefinedWindows::DEFAULT_WINDOW); + if (app_hmi_level == mobile_api::HMILevel::HMI_BACKGROUND) { MessageHelper::SendUIChangeRegistrationRequestToHMI(*it, *this); - } else if (((*it)->hmi_level() == mobile_api::HMILevel::HMI_FULL) || - ((*it)->hmi_level() == mobile_api::HMILevel::HMI_LIMITED)) { + } else if ((app_hmi_level == mobile_api::HMILevel::HMI_FULL) || + (app_hmi_level == mobile_api::HMILevel::HMI_LIMITED)) { MessageHelper::SendUIChangeRegistrationRequestToHMI(*it, *this); state_controller().SetRegularState( - *it, mobile_apis::HMILevel::HMI_BACKGROUND, true); + *it, + mobile_apis::PredefinedWindows::DEFAULT_WINDOW, + mobile_apis::HMILevel::HMI_BACKGROUND, + true); } } } @@ -3844,11 +3966,11 @@ void ApplicationManagerImpl::EraseAppFromReconnectionList( } const auto policy_app_id = app->policy_app_id(); - sync_primitives::AutoLock lock(reregister_wait_list_lock_); - auto app_it = std::find_if( - reregister_wait_list_.begin(), - reregister_wait_list_.end(), - std::bind1st(std::ptr_fun(&policy_app_id_comparator), policy_app_id)); + sync_primitives::AutoLock lock(reregister_wait_list_lock_ptr_); + auto app_it = + std::find_if(reregister_wait_list_.begin(), + reregister_wait_list_.end(), + PolicyAppIdComparator(app->device(), policy_app_id)); if (reregister_wait_list_.end() != app_it) { reregister_wait_list_.erase(app_it); } @@ -3880,6 +4002,7 @@ void ApplicationManagerImpl::ProcessReconnection( void ApplicationManagerImpl::OnPTUFinished(const bool ptu_result) { LOG4CXX_AUTO_TRACE(logger_); if (!ptu_result) { + protocol_handler_->ProcessFailedPTU(); return; } @@ -3898,6 +4021,25 @@ void ApplicationManagerImpl::OnPTUFinished(const bool ptu_result) { plugin_manager_->ForEachPlugin(on_app_policy_updated); } +#if defined(EXTERNAL_PROPRIETARY_MODE) && defined(ENABLE_SECURITY) +void ApplicationManagerImpl::OnCertDecryptFinished(const bool decrypt_result) { + LOG4CXX_AUTO_TRACE(logger_); + if (!decrypt_result) { + protocol_handler_->ProcessFailedCertDecrypt(); + } +} + +bool ApplicationManagerImpl::OnCertDecryptFailed() { + LOG4CXX_AUTO_TRACE(logger_); + return false; +} +#endif + +void ApplicationManagerImpl::OnPTUTimeoutExceeded() { + LOG4CXX_AUTO_TRACE(logger_); + protocol_handler_->ProcessFailedPTU(); +} + void ApplicationManagerImpl::SendDriverDistractionState( ApplicationSharedPtr application) { LOG4CXX_AUTO_TRACE(logger_); @@ -3906,30 +4048,72 @@ void ApplicationManagerImpl::SendDriverDistractionState( LOG4CXX_WARN(logger_, "DriverDistractionState is INVALID_ENUM"); return; } - smart_objects::SmartObjectSPtr on_driver_distraction = - std::make_shared(); - (*on_driver_distraction)[strings::params][strings::message_type] = - static_cast(application_manager::MessageType::kNotification); - (*on_driver_distraction)[strings::params][strings::function_id] = - mobile_api::FunctionID::OnDriverDistractionID; - (*on_driver_distraction)[strings::msg_params][mobile_notification::state] = - driver_distraction_state(); - (*on_driver_distraction)[strings::params][strings::connection_key] = - application->app_id(); + auto create_notification = [application, this]() { + auto notification = std::make_shared(); + auto& msg_params = (*notification)[strings::msg_params]; + auto& params = (*notification)[strings::params]; + + params[strings::message_type] = + static_cast(application_manager::MessageType::kNotification); + params[strings::function_id] = + static_cast(mobile_apis::FunctionID::OnDriverDistractionID); + msg_params[mobile_notification::state] = driver_distraction_state(); + const auto lock_screen_dismissal = + policy_handler_->LockScreenDismissalEnabledState(); + + if (lock_screen_dismissal && + hmi_apis::Common_DriverDistractionState::DD_ON == + driver_distraction_state()) { + bool dismissal_enabled = *lock_screen_dismissal; + if (dismissal_enabled) { + const auto language = + MessageHelper::MobileLanguageToString(application->ui_language()); + + const auto warning_message = + policy_handler_->LockScreenDismissalWarningMessage(language); + // Only allow lock screen dismissal if a warning message is available + if (warning_message && !warning_message->empty()) { + msg_params[mobile_notification::lock_screen_dismissal_warning] = + *warning_message; + } else { + dismissal_enabled = false; + } + } + msg_params[mobile_notification::lock_screen_dismissal_enabled] = + dismissal_enabled; + } + + params[strings::connection_key] = application->app_id(); + return notification; + }; - const std::string function_id = MessageHelper::StringifiedFunctionID( - static_cast( - (*on_driver_distraction)[strings::params][strings::function_id] - .asUInt())); const RPCParams params; + const std::string function_id = MessageHelper::StringifiedFunctionID( + mobile_api::FunctionID::OnDriverDistractionID); const mobile_apis::Result::eType check_result = - CheckPolicyPermissions(application, function_id, params); + CheckPolicyPermissions(application, + mobile_apis::PredefinedWindows::DEFAULT_WINDOW, + function_id, + params); if (mobile_api::Result::SUCCESS == check_result) { - rpc_service_->ManageMobileCommand(on_driver_distraction, + rpc_service_->ManageMobileCommand(create_notification(), commands::Command::SOURCE_SDL); } else { - application->PushMobileMessage(on_driver_distraction); + MobileMessageQueue messages; + application->SwapMobileMessageQueue(messages); + messages.erase( + std::remove_if( + messages.begin(), + messages.end(), + [](smart_objects::SmartObjectSPtr message) { + return (*message)[strings::params][strings::function_id] + .asUInt() == + mobile_apis::FunctionID::OnDriverDistractionID; + }), + messages.end()); + application->SwapMobileMessageQueue(messages); + application->PushMobileMessage(create_notification()); } } @@ -4016,9 +4200,9 @@ bool ApplicationManagerImpl::InitDirectory( LOG4CXX_WARN(logger_, directory_type << " directory doesn't exist."); // if storage directory doesn't exist try to create it if (!file_system::CreateDirectoryRecursively(path)) { - LOG4CXX_ERROR(logger_, - "Unable to create " << directory_type << " directory " - << path); + LOG4CXX_ERROR( + logger_, + "Unable to create " << directory_type << " directory " << path); return false; } LOG4CXX_DEBUG(logger_, @@ -4033,9 +4217,9 @@ bool ApplicationManagerImpl::IsReadWriteAllowed(const std::string& path, const std::string directory_type = DirectoryTypeToString(type); if (!(file_system::IsWritingAllowed(path) && file_system::IsReadingAllowed(path))) { - LOG4CXX_ERROR(logger_, - directory_type - << " directory doesn't have read/write permissions."); + LOG4CXX_ERROR( + logger_, + directory_type << " directory doesn't have read/write permissions."); return false; } @@ -4202,16 +4386,11 @@ bool ApplicationManagerImpl::IsSOStructValid( const smart_objects::SmartObject& display_capabilities) { smart_objects::SmartObject display_capabilities_so = display_capabilities; if (hmi_so_factory().AttachSchema(struct_id, display_capabilities_so)) { - if (display_capabilities_so.isValid()) { - return true; - } else { - return false; - } - } else { - LOG4CXX_ERROR(logger_, "Could not find struct id: " << struct_id); - return false; + return display_capabilities_so.isValid(); } - return true; + + LOG4CXX_ERROR(logger_, "Could not find struct id: " << struct_id); + return false; } #ifdef BUILD_TESTS @@ -4294,9 +4473,10 @@ void ApplicationManagerImpl::ChangeAppsHMILevel( LOG4CXX_ERROR(logger_, "There is no app with id: " << app_id); return; } - const mobile_apis::HMILevel::eType old_level = app->hmi_level(); + const mobile_apis::HMILevel::eType old_level = + app->hmi_level(mobile_api::PredefinedWindows::DEFAULT_WINDOW); if (old_level != level) { - app->set_hmi_level(level); + app->set_hmi_level(mobile_apis::PredefinedWindows::DEFAULT_WINDOW, level); OnHMILevelChanged(app_id, old_level, level); } else { LOG4CXX_WARN(logger_, "Redundant changing HMI level: " << level); diff --git a/src/components/application_manager/src/application_state.cc b/src/components/application_manager/src/application_state.cc index 3f775ee4e2e..6ed784424a4 100644 --- a/src/components/application_manager/src/application_state.cc +++ b/src/components/application_manager/src/application_state.cc @@ -31,7 +31,10 @@ */ #include "application_manager/application_state.h" + #include +#include + #include "utils/logger.h" #include "utils/macro.h" @@ -45,7 +48,7 @@ struct StateIDComparator { return cur->state_id() == state_id_; } }; -} +} // namespace namespace application_manager { @@ -53,193 +56,293 @@ CREATE_LOGGERPTR_GLOBAL(logger_, "ApplicationManager") ApplicationState::ApplicationState() {} -void ApplicationState::InitState(HmiStatePtr state) { +void ApplicationState::InitState(const WindowID window_id, + const std::string& window_name, + HmiStatePtr state) { LOG4CXX_AUTO_TRACE(logger_); DCHECK_OR_RETURN_VOID(state); - sync_primitives::AutoLock auto_lock(hmi_states_lock_); - hmi_states_.clear(); - hmi_states_.push_back(state); + LOG4CXX_DEBUG(logger_, + "Initing state " << state << " for window " << window_id + << " with name " << window_name); + { + sync_primitives::AutoLock auto_lock(hmi_states_map_lock_); + HmiStates& states = hmi_states_map_[window_id]; + states.push_back(state); + } } -void ApplicationState::AddState(HmiStatePtr state) { +void ApplicationState::AddState(const WindowID window_id, HmiStatePtr state) { LOG4CXX_AUTO_TRACE(logger_); DCHECK_OR_RETURN_VOID(state); switch (state->state_id()) { case HmiState::StateID::STATE_ID_REGULAR: - SetRegularState(state); + SetRegularState(window_id, state); return; case HmiState::StateID::STATE_ID_POSTPONED: - SetPostponedState(state); + SetPostponedState(window_id, state); return; case HmiState::StateID::STATE_ID_CURRENT: - LOG4CXX_ERROR(logger_, "State of type '" << state << "' can't be added."); + LOG4CXX_ERROR(logger_, + "State of type '" << state << "' can't be added for window " + << window_id); return; default: - AddHMIState(state); + AddHMIState(window_id, state); break; } return; } -void ApplicationState::RemoveState(HmiState::StateID state) { +void ApplicationState::RemoveState(const WindowID window_id, + HmiState::StateID state) { LOG4CXX_AUTO_TRACE(logger_); DCHECK_OR_RETURN_VOID(state); switch (state) { case HmiState::StateID::STATE_ID_CURRENT: case HmiState::StateID::STATE_ID_REGULAR: - LOG4CXX_ERROR(logger_, - "State of type '" << state << "'can't be removed."); + if (mobile_apis::PredefinedWindows::DEFAULT_WINDOW == window_id) { + LOG4CXX_ERROR(logger_, + "State of type '" << state + << "' can't be removed for window " + << window_id); + return; + } + + RemoveWindowHMIStates(window_id); break; case HmiState::StateID::STATE_ID_POSTPONED: - RemovePostponedState(); + RemovePostponedState(window_id); break; default: - RemoveHMIState(state); + RemoveHMIState(window_id, state); break; } } -HmiStatePtr ApplicationState::GetState(HmiState::StateID state_id) const { +HmiStatePtr ApplicationState::GetState(const WindowID window_id, + HmiState::StateID state_id) const { switch (state_id) { case HmiState::StateID::STATE_ID_REGULAR: - LOG4CXX_DEBUG(logger_, "Getting regular state."); - return RegularHmiState(); + LOG4CXX_DEBUG(logger_, "Getting regular state for window " << window_id); + return RegularHmiState(window_id); case HmiState::StateID::STATE_ID_POSTPONED: - LOG4CXX_DEBUG(logger_, "Getting postponed state."); - return PostponedHmiState(); + LOG4CXX_DEBUG(logger_, + "Getting postponed state for window " << window_id); + return PostponedHmiState(window_id); default: - LOG4CXX_DEBUG(logger_, "Getting current state."); - return CurrentHmiState(); + LOG4CXX_DEBUG(logger_, "Getting current state for window " << window_id); + return CurrentHmiState(window_id); } } -void ApplicationState::AddHMIState(HmiStatePtr state) { +HmiStates ApplicationState::GetStates(const HmiState::StateID state_id) const { + LOG4CXX_DEBUG(logger_, "Collecting all states of type " << state_id); + + HmiStates hmi_states; + sync_primitives::AutoLock auto_lock(hmi_states_map_lock_); + for (const auto& hmi_state_pair : hmi_states_map_) { + hmi_states.push_back(GetState(hmi_state_pair.first, state_id)); + } + + return hmi_states; +} + +WindowIds ApplicationState::GetWindowIds() const { + LOG4CXX_DEBUG(logger_, "Collecting available window ID's"); + + WindowIds window_ids; + std::string stringified_window_ids; + + sync_primitives::AutoLock auto_lock(hmi_states_map_lock_); + for (const auto& hmi_state_pair : hmi_states_map_) { + window_ids.push_back(hmi_state_pair.first); + stringified_window_ids += (stringified_window_ids.empty() ? "" : ", ") + + std::to_string(hmi_state_pair.first); + } + + LOG4CXX_DEBUG(logger_, + "Existing window IDs: [" + stringified_window_ids + "]"); + return window_ids; +} + +void ApplicationState::AddHMIState(const WindowID window_id, + HmiStatePtr state) { LOG4CXX_AUTO_TRACE(logger_); DCHECK_OR_RETURN_VOID(state); - sync_primitives::AutoLock auto_lock(hmi_states_lock_); - HmiStates::iterator it = std::find_if(hmi_states_.begin(), - hmi_states_.end(), + sync_primitives::AutoLock auto_lock(hmi_states_map_lock_); + HmiStates& hmi_states = hmi_states_map_[window_id]; + HmiStates::iterator it = std::find_if(hmi_states.begin(), + hmi_states.end(), StateIDComparator(state->state_id())); - if (hmi_states_.end() != it) { - LOG4CXX_WARN( - logger_, - "Hmi state with ID " - << state->state_id() - << "has been already applied to this application. Ignoring"); + if (hmi_states.end() != it) { + LOG4CXX_WARN(logger_, + "Hmi state with ID " << state->state_id() + << "has been already applied for window " + << window_id + << " of this application. Ignoring"); return; } - hmi_states_.push_back(state); + hmi_states.push_back(state); } -void ApplicationState::RemoveHMIState(HmiState::StateID state_id) { +void ApplicationState::RemoveHMIState(const WindowID window_id, + HmiState::StateID state_id) { LOG4CXX_AUTO_TRACE(logger_); - sync_primitives::AutoLock auto_lock(hmi_states_lock_); + sync_primitives::AutoLock auto_lock(hmi_states_map_lock_); + HmiStates& hmi_states = hmi_states_map_[window_id]; HmiStates::iterator it = std::find_if( - hmi_states_.begin(), hmi_states_.end(), StateIDComparator(state_id)); - if (it == hmi_states_.end()) { - LOG4CXX_ERROR(logger_, "Unsuccesful remove HmiState: " << state_id); + hmi_states.begin(), hmi_states.end(), StateIDComparator(state_id)); + if (hmi_states.end() == it) { + LOG4CXX_ERROR(logger_, + "Unsuccesful remove HmiState: " << state_id << " for window " + << window_id); return; } // unable to remove regular state - DCHECK_OR_RETURN_VOID(it != hmi_states_.begin()); + DCHECK_OR_RETURN_VOID(hmi_states.begin() != it); HmiStates::iterator next = it; HmiStates::iterator prev = it; next++; prev--; - if (next != hmi_states_.end()) { + + if (next != hmi_states.end()) { HmiStatePtr next_state = *next; HmiStatePtr prev_state = *prev; next_state->set_parent(prev_state); } - hmi_states_.erase(it); + + hmi_states.erase(it); } -void ApplicationState::RemovePostponedState() { +void ApplicationState::RemoveWindowHMIStates(const WindowID window_id) { LOG4CXX_AUTO_TRACE(logger_); - sync_primitives::AutoLock auto_lock(hmi_states_lock_); - DCHECK_OR_RETURN_VOID(!hmi_states_.empty()); + DCHECK_OR_RETURN_VOID(mobile_apis::PredefinedWindows::DEFAULT_WINDOW != + window_id); + + LOG4CXX_DEBUG(logger_, + "Removing HMI states for window with id #" << window_id); + { + sync_primitives::AutoLock auto_lock(hmi_states_map_lock_); + hmi_states_map_.erase(window_id); + } +} + +void ApplicationState::RemovePostponedState(const WindowID window_id) { + LOG4CXX_AUTO_TRACE(logger_); + sync_primitives::AutoLock auto_lock(hmi_states_map_lock_); + HmiStates& hmi_states = hmi_states_map_[window_id]; + DCHECK_OR_RETURN_VOID(!hmi_states.empty()); StateIDComparator finder(HmiState::StateID::STATE_ID_POSTPONED); HmiStates::iterator postponed_state = - std::find_if(hmi_states_.begin(), hmi_states_.end(), finder); + std::find_if(hmi_states.begin(), hmi_states.end(), finder); - if (hmi_states_.end() == postponed_state) { - LOG4CXX_ERROR(logger_, "No postponed state is set for app."); + if (hmi_states.end() == postponed_state) { + LOG4CXX_ERROR(logger_, + "No postponed state is set for window " << window_id); return; } - hmi_states_.erase(postponed_state); + + hmi_states.erase(postponed_state); } -void ApplicationState::SetRegularState(HmiStatePtr state) { +void ApplicationState::SetRegularState(const WindowID window_id, + HmiStatePtr state) { LOG4CXX_AUTO_TRACE(logger_); DCHECK_OR_RETURN_VOID(state); DCHECK_OR_RETURN_VOID(state->state_id() == HmiState::StateID::STATE_ID_REGULAR); - sync_primitives::AutoLock auto_lock(hmi_states_lock_); - DCHECK_OR_RETURN_VOID(!hmi_states_.empty()); + sync_primitives::AutoLock auto_lock(hmi_states_map_lock_); + HmiStates& hmi_states = hmi_states_map_[window_id]; + DCHECK_OR_RETURN_VOID(!hmi_states.empty()); - HmiStatePtr front_state = hmi_states_.front(); + HmiStatePtr front_state = hmi_states.front(); HmiState::StateID front_state_id = front_state->state_id(); if (HmiState::StateID::STATE_ID_POSTPONED == front_state_id) { // Drop postponed state - hmi_states_.erase(hmi_states_.begin()); + hmi_states.erase(hmi_states.begin()); } // Drop regular state - hmi_states_.erase(hmi_states_.begin()); + hmi_states.erase(hmi_states.begin()); - if (!hmi_states_.empty()) { - HmiStatePtr front_state = hmi_states_.front(); + if (!hmi_states.empty()) { + HmiStatePtr front_state = hmi_states.front(); front_state->set_parent(state); } - hmi_states_.insert(hmi_states_.begin(), state); + + // Insert new regular state + hmi_states.insert(hmi_states.begin(), state); if (HmiState::StateID::STATE_ID_POSTPONED == front_state_id) { - hmi_states_.insert(hmi_states_.begin(), front_state); + // Restore postponed state if it was before + hmi_states.insert(hmi_states.begin(), front_state); } } -void ApplicationState::SetPostponedState(HmiStatePtr state) { +void ApplicationState::SetPostponedState(const WindowID window_id, + HmiStatePtr state) { LOG4CXX_AUTO_TRACE(logger_); DCHECK_OR_RETURN_VOID(state); DCHECK_OR_RETURN_VOID(state->state_id() == HmiState::StateID::STATE_ID_POSTPONED); - sync_primitives::AutoLock auto_lock(hmi_states_lock_); - DCHECK_OR_RETURN_VOID(!hmi_states_.empty()); - HmiStatePtr front_state = hmi_states_.front(); + + sync_primitives::AutoLock auto_lock(hmi_states_map_lock_); + HmiStates& hmi_states = hmi_states_map_[window_id]; + DCHECK_OR_RETURN_VOID(!hmi_states.empty()); + HmiStatePtr front_state = hmi_states.front(); if (front_state->state_id() == HmiState::StateID::STATE_ID_POSTPONED) { - hmi_states_.erase(hmi_states_.begin()); + hmi_states.erase(hmi_states.begin()); } - hmi_states_.insert(hmi_states_.begin(), state); + + hmi_states.insert(hmi_states.begin(), state); } -HmiStatePtr ApplicationState::CurrentHmiState() const { - sync_primitives::AutoLock auto_lock(hmi_states_lock_); - DCHECK_OR_RETURN(!hmi_states_.empty(), HmiStatePtr()); - HmiStatePtr back_state = hmi_states_.back(); +HmiStatePtr ApplicationState::CurrentHmiState(const WindowID window_id) const { + sync_primitives::AutoLock auto_lock(hmi_states_map_lock_); + auto it_states = hmi_states_map_.find(window_id); + DCHECK_OR_RETURN(it_states != hmi_states_map_.end(), HmiStatePtr()); + + const HmiStates& hmi_states = it_states->second; + DCHECK_OR_RETURN(!hmi_states.empty(), HmiStatePtr()); + + HmiStatePtr back_state = hmi_states.back(); DCHECK_OR_RETURN( back_state->state_id() != HmiState::StateID::STATE_ID_POSTPONED, HmiStatePtr()); + return back_state; } -HmiStatePtr ApplicationState::RegularHmiState() const { - sync_primitives::AutoLock auto_lock(hmi_states_lock_); - DCHECK_OR_RETURN(!hmi_states_.empty(), HmiStatePtr()); - HmiStates::const_iterator front_itr = hmi_states_.begin(); +HmiStatePtr ApplicationState::RegularHmiState(const WindowID window_id) const { + sync_primitives::AutoLock auto_lock(hmi_states_map_lock_); + auto it_states = hmi_states_map_.find(window_id); + DCHECK_OR_RETURN(it_states != hmi_states_map_.end(), HmiStatePtr()); + + const HmiStates& hmi_states = it_states->second; + DCHECK_OR_RETURN(!hmi_states.empty(), HmiStatePtr()); + + HmiStates::const_iterator front_itr = hmi_states.begin(); if ((*front_itr)->state_id() == HmiState::StateID::STATE_ID_POSTPONED) { ++front_itr; } + return *front_itr; } -HmiStatePtr ApplicationState::PostponedHmiState() const { - sync_primitives::AutoLock auto_lock(hmi_states_lock_); - DCHECK_OR_RETURN(!hmi_states_.empty(), HmiStatePtr()); - HmiStatePtr front_state = hmi_states_.front(); +HmiStatePtr ApplicationState::PostponedHmiState( + const WindowID window_id) const { + sync_primitives::AutoLock auto_lock(hmi_states_map_lock_); + auto it_states = hmi_states_map_.find(window_id); + DCHECK_OR_RETURN(it_states != hmi_states_map_.end(), HmiStatePtr()); + + const HmiStates& hmi_states = it_states->second; + DCHECK_OR_RETURN(!hmi_states.empty(), HmiStatePtr()); + + HmiStatePtr front_state = hmi_states.front(); return front_state->state_id() == HmiState::StateID::STATE_ID_POSTPONED ? front_state : HmiStatePtr(); diff --git a/src/components/application_manager/src/command_holder_impl.cc b/src/components/application_manager/src/command_holder_impl.cc index ea74e78f4e4..1c336ac64fd 100644 --- a/src/components/application_manager/src/command_holder_impl.cc +++ b/src/components/application_manager/src/command_holder_impl.cc @@ -43,20 +43,23 @@ CommandHolderImpl::CommandHolderImpl(ApplicationManager& app_manager) void CommandHolderImpl::Suspend( ApplicationSharedPtr application, CommandType type, + commands::Command::CommandSource source, std::shared_ptr command) { LOG4CXX_AUTO_TRACE(logger_); DCHECK_OR_RETURN_VOID(application); LOG4CXX_DEBUG(logger_, "Suspending command(s) for application: " << application->policy_app_id()); - sync_primitives::AutoLock lock(commands_lock_); + AppCommandInfo info = {command, source}; + + sync_primitives::AutoLock lock(commands_lock_); if (CommandType::kHmiCommand == type) { - app_hmi_commands_[application].push_back(command); + app_hmi_commands_[application].push_back(info); LOG4CXX_DEBUG(logger_, "Suspended HMI command(s): " << app_hmi_commands_.size()); } else { - app_mobile_commands_[application].push_back(command); + app_mobile_commands_[application].push_back(info); LOG4CXX_DEBUG( logger_, "Suspended mobile command(s): " << app_mobile_commands_.size()); @@ -113,8 +116,10 @@ void CommandHolderImpl::ResumeHmiCommand(ApplicationSharedPtr application) { "Resuming HMI command(s): " << app_hmi_commands_.size()); for (auto cmd : app_commands->second) { - (*cmd)[strings::msg_params][strings::app_id] = application->hmi_app_id(); - app_manager_.GetRPCService().ManageHMICommand(cmd); + (*cmd.command_ptr_)[strings::msg_params][strings::app_id] = + application->hmi_app_id(); + app_manager_.GetRPCService().ManageHMICommand(cmd.command_ptr_, + cmd.command_source_); } app_hmi_commands_.erase(app_commands); @@ -132,11 +137,12 @@ void CommandHolderImpl::ResumeMobileCommand(ApplicationSharedPtr application) { "Resuming mobile command(s): " << app_mobile_commands_.size()); for (auto cmd : app_commands->second) { - (*cmd)[strings::params][strings::connection_key] = application->app_id(); - app_manager_.GetRPCService().ManageMobileCommand( - cmd, commands::Command::CommandSource::SOURCE_MOBILE); + (*cmd.command_ptr_)[strings::params][strings::connection_key] = + application->app_id(); + app_manager_.GetRPCService().ManageMobileCommand(cmd.command_ptr_, + cmd.command_source_); } app_mobile_commands_.erase(app_commands); } -} // application_manager +} // namespace application_manager diff --git a/src/components/application_manager/src/commands/command_impl.cc b/src/components/application_manager/src/commands/command_impl.cc index 04fabfb2ecd..8875895cb7e 100644 --- a/src/components/application_manager/src/commands/command_impl.cc +++ b/src/components/application_manager/src/commands/command_impl.cc @@ -1,4 +1,4 @@ -/* +/* Copyright (c) 2014, Ford Motor Company All rights reserved. @@ -43,7 +43,7 @@ struct AppExtensionPredicate { return app ? (app->QueryInterface(uid).use_count() != 0) : false; } }; -} +} // namespace namespace commands { @@ -96,6 +96,15 @@ int32_t CommandImpl::function_id() const { return (*message_)[strings::params][strings::function_id].asInt(); } +WindowID CommandImpl::window_id() const { + if ((*message_).keyExists(strings::msg_params)) { + if ((*message_)[strings::msg_params].keyExists(strings::window_id)) { + return (*message_)[strings::msg_params][strings::window_id].asInt(); + } + } + return mobile_apis::PredefinedWindows::DEFAULT_WINDOW; +} + uint32_t CommandImpl::connection_key() const { return (*message_)[strings::params][strings::connection_key].asUInt(); } diff --git a/src/components/application_manager/src/commands/command_notification_from_mobile_impl.cc b/src/components/application_manager/src/commands/command_notification_from_mobile_impl.cc index 26b43856f76..bd4fa58c8f3 100644 --- a/src/components/application_manager/src/commands/command_notification_from_mobile_impl.cc +++ b/src/components/application_manager/src/commands/command_notification_from_mobile_impl.cc @@ -32,8 +32,8 @@ #include "application_manager/commands/command_notification_from_mobile_impl.h" #include "application_manager/application_manager.h" -#include "application_manager/rpc_service.h" #include "application_manager/message_helper.h" +#include "application_manager/rpc_service.h" namespace application_manager { diff --git a/src/components/application_manager/src/commands/command_notification_impl.cc b/src/components/application_manager/src/commands/command_notification_impl.cc index 70df95986b3..cc2606ab6f2 100644 --- a/src/components/application_manager/src/commands/command_notification_impl.cc +++ b/src/components/application_manager/src/commands/command_notification_impl.cc @@ -32,8 +32,8 @@ #include "application_manager/commands/command_notification_impl.h" #include "application_manager/application_manager.h" -#include "application_manager/rpc_service.h" #include "application_manager/message_helper.h" +#include "application_manager/rpc_service.h" namespace application_manager { diff --git a/src/components/application_manager/src/commands/command_request_impl.cc b/src/components/application_manager/src/commands/command_request_impl.cc index f67fde22a0f..257ccfd9c31 100644 --- a/src/components/application_manager/src/commands/command_request_impl.cc +++ b/src/components/application_manager/src/commands/command_request_impl.cc @@ -112,7 +112,8 @@ const std::string CreateInfoForUnsupportedResult( } } -bool CheckResultCode(const ResponseInfo& first, const ResponseInfo& second) { +bool CommandRequestImpl::CheckResult(const ResponseInfo& first, + const ResponseInfo& second) const { if (first.is_ok && second.is_unsupported_resource) { return true; } @@ -144,19 +145,21 @@ struct DisallowedParamsInserter { : response_(response), code_(code) {} bool operator()(const std::string& param) { - const VehicleData& vehicle_data = - application_manager::MessageHelper::vehicle_data(); - VehicleData::const_iterator it = vehicle_data.find(param); - if (vehicle_data.end() != it) { - smart_objects::SmartObjectSPtr disallowed_param = - std::make_shared( - smart_objects::SmartType_Map); - (*disallowed_param)[strings::data_type] = (*it).second; - (*disallowed_param)[strings::result_code] = code_; - response_[strings::msg_params][param.c_str()] = *disallowed_param; - return true; - } - return false; + smart_objects::SmartObjectSPtr disallowed_param = + std::make_shared( + smart_objects::SmartType_Map); + + auto rpc_spec_vehicle_data = MessageHelper::vehicle_data(); + auto vehicle_data = rpc_spec_vehicle_data.find(param); + auto vehicle_data_type = + vehicle_data == rpc_spec_vehicle_data.end() + ? mobile_apis::VehicleDataType::VEHICLEDATA_OEM_CUSTOM_DATA + : vehicle_data->second; + + (*disallowed_param)[strings::data_type] = vehicle_data_type; + (*disallowed_param)[strings::result_code] = code_; + response_[strings::msg_params][param.c_str()] = *disallowed_param; + return true; } private: @@ -186,13 +189,7 @@ ResponseInfo::ResponseInfo(const hmi_apis::Common_Result::eType result, interface_state = application_manager.hmi_interfaces().GetInterfaceState(hmi_interface); - is_ok = Compare( - result_code, - hmi_apis::Common_Result::SUCCESS, - hmi_apis::Common_Result::WARNINGS, - hmi_apis::Common_Result::WRONG_LANGUAGE, - hmi_apis::Common_Result::RETRY, - hmi_apis::Common_Result::SAVED); + is_ok = CommandRequestImpl::IsHMIResultSuccess(result_code); is_not_used = hmi_apis::Common_Result::INVALID_ENUM == result_code; @@ -306,9 +303,9 @@ void CommandRequestImpl::SendResponse( } // Add disallowed parameters and info from request back to response with - // appropriate - // reasons (VehicleData result codes) - if (result_code != mobile_apis::Result::APPLICATION_NOT_REGISTERED) { + // appropriate reasons (VehicleData result codes) + if (result_code != mobile_apis::Result::APPLICATION_NOT_REGISTERED && + result_code != mobile_apis::Result::INVALID_DATA) { const mobile_apis::FunctionID::eType& id = static_cast(function_id()); if ((id == mobile_apis::FunctionID::SubscribeVehicleDataID) || @@ -725,12 +722,17 @@ bool CommandRequestImpl::CheckAllowedParameters() { } mobile_apis::Result::eType check_result = - application_manager_.CheckPolicyPermissions( - app, - MessageHelper::StringifiedFunctionID( - static_cast(function_id())), - params, - ¶meters_permissions_); + mobile_apis::Result::eType::INVALID_ID; + const auto current_window_id = window_id(); + if (app->WindowIdExists(current_window_id)) { + check_result = application_manager_.CheckPolicyPermissions( + app, + current_window_id, + MessageHelper::StringifiedFunctionID( + static_cast(function_id())), + params, + ¶meters_permissions_); + } // Check, if RPC is allowed by policy if (mobile_apis::Result::SUCCESS != check_result) { @@ -799,49 +801,28 @@ void CommandRequestImpl::RemoveDisallowedParameters() { smart_objects::SmartObject& params = (*message_)[strings::msg_params]; - // Remove from request all disallowed parameters - RPCParams::const_iterator it_disallowed = - parameters_permissions_.disallowed_params.begin(); - RPCParams::const_iterator it_disallowed_end = - parameters_permissions_.disallowed_params.end(); - for (; it_disallowed != it_disallowed_end; ++it_disallowed) { - if (params.keyExists(*it_disallowed)) { - const std::string key = *it_disallowed; + for (const auto& key : params.enumerate()) { + if (parameters_permissions_.disallowed_params.end() != + parameters_permissions_.disallowed_params.find(key)) { + // Remove from request all disallowed parameters params.erase(key); removed_parameters_permissions_.disallowed_params.insert(key); LOG4CXX_INFO(logger_, "Following parameter is disallowed by user: " << key); } - } - // Remove from request all undefined yet parameters - RPCParams::const_iterator it_undefined = - parameters_permissions_.undefined_params.begin(); - RPCParams::const_iterator it_undefined_end = - parameters_permissions_.undefined_params.end(); - for (; it_undefined != it_undefined_end; ++it_undefined) { - if (params.keyExists(*it_undefined)) { - const std::string key = *it_undefined; + else if (removed_parameters_permissions_.undefined_params.end() != + removed_parameters_permissions_.undefined_params.find(key)) { + // Remove from request all undefined yet parameters params.erase(key); removed_parameters_permissions_.undefined_params.insert(key); LOG4CXX_INFO(logger_, "Following parameter is disallowed by policy: " << key); } - } - // Remove from request all parameters missed in allowed - const VehicleData& vehicle_data = - application_manager::MessageHelper::vehicle_data(); - - VehicleData::const_iterator it_vehicle_data = vehicle_data.begin(); - VehicleData::const_iterator it_vehicle_data_end = vehicle_data.end(); - for (; it_vehicle_data != it_vehicle_data_end; ++it_vehicle_data) { - const std::string key = it_vehicle_data->first; - if (params.keyExists(key) && - parameters_permissions_.allowed_params.end() == - std::find(parameters_permissions_.allowed_params.begin(), - parameters_permissions_.allowed_params.end(), - key)) { + else if (parameters_permissions_.allowed_params.end() == + parameters_permissions_.allowed_params.find(key)) { + // Remove from request all parameters missed in allowed params.erase(key); removed_parameters_permissions_.undefined_params.insert(key); LOG4CXX_INFO(logger_, @@ -910,7 +891,7 @@ bool CommandRequestImpl::HasDisallowedParams() const { } bool CommandRequestImpl::IsMobileResultSuccess( - mobile_apis::Result::eType result_code) const { + const mobile_apis::Result::eType result_code) { LOG4CXX_AUTO_TRACE(logger_); using namespace helpers; return Compare( @@ -922,18 +903,24 @@ bool CommandRequestImpl::IsMobileResultSuccess( mobile_apis::Result::SAVED); } +bool CommandRequestImpl::IsHMIResultSuccess( + const hmi_apis::Common_Result::eType result_code) { + LOG4CXX_AUTO_TRACE(logger_); + using namespace helpers; + return Compare( + result_code, + hmi_apis::Common_Result::SUCCESS, + hmi_apis::Common_Result::WARNINGS, + hmi_apis::Common_Result::WRONG_LANGUAGE, + hmi_apis::Common_Result::RETRY, + hmi_apis::Common_Result::SAVED); +} + bool CommandRequestImpl::PrepareResultForMobileResponse( hmi_apis::Common_Result::eType result_code, HmiInterfaces::InterfaceID interface) const { LOG4CXX_AUTO_TRACE(logger_); - using namespace helpers; - if (Compare( - result_code, - hmi_apis::Common_Result::SUCCESS, - hmi_apis::Common_Result::WARNINGS, - hmi_apis::Common_Result::WRONG_LANGUAGE, - hmi_apis::Common_Result::RETRY, - hmi_apis::Common_Result::SAVED)) { + if (IsHMIResultSuccess(result_code)) { return true; } @@ -949,8 +936,8 @@ bool CommandRequestImpl::PrepareResultForMobileResponse( bool CommandRequestImpl::PrepareResultForMobileResponse( ResponseInfo& out_first, ResponseInfo& out_second) const { LOG4CXX_AUTO_TRACE(logger_); - bool result = CheckResultCode(out_first, out_second) || - CheckResultCode(out_second, out_first); + bool result = + CheckResult(out_first, out_second) || CheckResult(out_second, out_first); return result; } diff --git a/src/components/application_manager/src/commands/request_from_hmi.cc b/src/components/application_manager/src/commands/request_from_hmi.cc index 873d9a844fc..576287286f0 100644 --- a/src/components/application_manager/src/commands/request_from_hmi.cc +++ b/src/components/application_manager/src/commands/request_from_hmi.cc @@ -199,7 +199,7 @@ void RequestFromHMI::SendProviderRequest( if (hmi_destination) { LOG4CXX_DEBUG(logger_, "Sending Request to HMI Provider"); application_manager_.IncreaseForwardedRequestTimeout( - application_manager::request_controller::RequestInfo::HmiConnectoinKey, + application_manager::request_controller::RequestInfo::HmiConnectionKey, correlation_id()); SendHMIRequest(hmi_function_id, &(*msg)[strings::msg_params], use_events); return; @@ -217,7 +217,7 @@ void RequestFromHMI::SendProviderRequest( LOG4CXX_DEBUG(logger_, "Sending Request to Mobile Provider"); application_manager_.IncreaseForwardedRequestTimeout( - application_manager::request_controller::RequestInfo::HmiConnectoinKey, + application_manager::request_controller::RequestInfo::HmiConnectionKey, correlation_id()); SendMobileRequest( mobile_function_id, app, &(*msg)[strings::msg_params], use_events); diff --git a/src/components/application_manager/src/display_capabilities_builder.cc b/src/components/application_manager/src/display_capabilities_builder.cc new file mode 100644 index 00000000000..82341282802 --- /dev/null +++ b/src/components/application_manager/src/display_capabilities_builder.cc @@ -0,0 +1,128 @@ +/* + * Copyright (c) 2019, 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/display_capabilities_builder.h" +#include "application_manager/message_helper.h" +#include "application_manager/smart_object_keys.h" +namespace application_manager { + +CREATE_LOGGERPTR_GLOBAL(logger_, "DisplayCapabilitiesBuilder") + +const WindowID kDefaultWindowID = 0; + +DisplayCapabilitiesBuilder::DisplayCapabilitiesBuilder(Application& application) + : owner_(application) { + LOG4CXX_AUTO_TRACE(logger_); +} + +void DisplayCapabilitiesBuilder::InitBuilder( + DisplayCapabilitiesBuilder::ResumeCallback resume_callback, + const smart_objects::SmartObject& windows_info) { + LOG4CXX_AUTO_TRACE(logger_); + sync_primitives::AutoLock lock(display_capabilities_lock_); + resume_callback_ = resume_callback; + window_ids_to_resume_.insert(kDefaultWindowID); + for (size_t i = 0; i < windows_info.length(); ++i) { + auto window_id = windows_info[i][strings::window_id].asInt(); + LOG4CXX_DEBUG(logger_, + "Inserting " << window_id << " to waiting container"); + window_ids_to_resume_.insert(window_id); + } +} + +void DisplayCapabilitiesBuilder::UpdateDisplayCapabilities( + const smart_objects::SmartObject& incoming_display_capabilities) { + LOG4CXX_AUTO_TRACE(logger_); + using namespace smart_objects; + sync_primitives::AutoLock lock(display_capabilities_lock_); + + if (!display_capabilities_) { + display_capabilities_ = std::make_shared(SmartType_Array); + } + + // As per v6.0, only single display is supported + auto cur_window_caps = + (*display_capabilities_)[0][strings::window_capabilities]; + + const auto& inc_window_caps = + incoming_display_capabilities[0][strings::window_capabilities]; + + for (size_t i = 0; i < inc_window_caps.length(); ++i) { + const WindowID window_id = + inc_window_caps[i].keyExists(strings::window_id) + ? inc_window_caps[i][strings::window_id].asInt() + : kDefaultWindowID; + if (window_ids_to_resume_.end() != window_ids_to_resume_.find(window_id)) { + cur_window_caps[cur_window_caps.length()] = inc_window_caps[i]; + LOG4CXX_DEBUG(logger_, "Stop waiting for: " << window_id); + window_ids_to_resume_.erase(window_id); + } + } + + *display_capabilities_ = incoming_display_capabilities; + (*display_capabilities_)[0][strings::window_capabilities] = cur_window_caps; + + if (window_ids_to_resume_.empty()) { + LOG4CXX_TRACE(logger_, "Invoking resume callback"); + resume_callback_(owner_, *display_capabilities_); + display_capabilities_.reset(); + } +} // namespace application_manager + +const smart_objects::SmartObjectSPtr +DisplayCapabilitiesBuilder::display_capabilities() const { + LOG4CXX_AUTO_TRACE(logger_); + return display_capabilities_; +} + +void DisplayCapabilitiesBuilder::ResetDisplayCapabilities() { + LOG4CXX_AUTO_TRACE(logger_); + sync_primitives::AutoLock lock(display_capabilities_lock_); + display_capabilities_.reset(); +} + +void DisplayCapabilitiesBuilder::StopWaitingForWindow( + const WindowID window_id) { + LOG4CXX_AUTO_TRACE(logger_); + sync_primitives::AutoLock lock(display_capabilities_lock_); + LOG4CXX_DEBUG(logger_, + "Window id " << window_id << " will be erased due to failure"); + window_ids_to_resume_.erase(window_id); + if (window_ids_to_resume_.empty()) { + LOG4CXX_TRACE(logger_, + window_id << " was the last window pending resumption. " + "Invoking resume callback"); + resume_callback_(owner_, *display_capabilities_); + display_capabilities_.reset(); + } +} +} // namespace application_manager diff --git a/src/components/application_manager/src/event_engine/event_dispatcher_impl.cc b/src/components/application_manager/src/event_engine/event_dispatcher_impl.cc index 3f3cfae1d3f..30b1b83e798 100644 --- a/src/components/application_manager/src/event_engine/event_dispatcher_impl.cc +++ b/src/components/application_manager/src/event_engine/event_dispatcher_impl.cc @@ -31,9 +31,9 @@ */ #include "application_manager/event_engine/event_dispatcher_impl.h" -#include "interfaces/HMI_API.h" -#include "application_manager/event_engine/event_observer.h" #include +#include "application_manager/event_engine/event_observer.h" +#include "interfaces/HMI_API.h" namespace application_manager { namespace event_engine { @@ -137,8 +137,9 @@ void EventDispatcherImpl::raise_mobile_event(const MobileEvent& event) { } if (mobile_apis::messageType::response == event.smart_object_type()) { - mobile_observers_ = mobile_observers_event_ - [event.id()][event.smart_object_correlation_id()]; + mobile_observers_ = + mobile_observers_event_[event.id()] + [event.smart_object_correlation_id()]; } } diff --git a/src/components/application_manager/src/event_engine/event_observer.cc b/src/components/application_manager/src/event_engine/event_observer.cc index fc252d3125d..e17203f2f24 100644 --- a/src/components/application_manager/src/event_engine/event_observer.cc +++ b/src/components/application_manager/src/event_engine/event_observer.cc @@ -57,10 +57,6 @@ void EventObserver::unsubscribe_from_event(const Event::EventID& event_id) { event_dispatcher_.remove_observer(event_id, *this); } -void EventObserver::unsubscribe_from_all_events() { - event_dispatcher_.remove_observer(*this); -} - void EventObserver::unsubscribe_from_all_hmi_events() { event_dispatcher_.remove_observer(*this); } diff --git a/src/components/application_manager/src/help_prompt_manager_impl.cc b/src/components/application_manager/src/help_prompt_manager_impl.cc index 016e09635b8..ec883e5fc24 100644 --- a/src/components/application_manager/src/help_prompt_manager_impl.cc +++ b/src/components/application_manager/src/help_prompt_manager_impl.cc @@ -28,7 +28,7 @@ * 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/help_prompt_manager_impl.h" @@ -90,9 +90,9 @@ bool HelpPromptManagerImpl::AddCommand( const bool limit_exceeded = kLimitCommand <= GetCommandsCount(vr_commands_.end()); - LOG4CXX_DEBUG(logger_, - "Will be added first command from array " - << strings::vr_commands); + LOG4CXX_DEBUG( + logger_, + "Will be added first command from array " << strings::vr_commands); smart_objects::SmartObjectSPtr vr_item = std::make_shared(commands.asArray()->front()); diff --git a/src/components/application_manager/src/helpers/application_helper.cc b/src/components/application_manager/src/helpers/application_helper.cc index 59f1c6caf2e..fc86eb5e62e 100644 --- a/src/components/application_manager/src/helpers/application_helper.cc +++ b/src/components/application_manager/src/helpers/application_helper.cc @@ -1,9 +1,9 @@ -#include -#include #include "application_manager/helpers/application_helper.h" +#include +#include #include "application_manager/message_helper.h" -#include "utils/logger.h" #include "utils/file_system.h" +#include "utils/logger.h" namespace { using namespace application_manager; diff --git a/src/components/application_manager/src/hmi_capabilities_impl.cc b/src/components/application_manager/src/hmi_capabilities_impl.cc index 060eaf011c9..6f95e435458 100644 --- a/src/components/application_manager/src/hmi_capabilities_impl.cc +++ b/src/components/application_manager/src/hmi_capabilities_impl.cc @@ -32,16 +32,16 @@ #include -#include "utils/logger.h" -#include "application_manager/hmi_capabilities_impl.h" #include "application_manager/application_manager.h" -#include "smart_objects/smart_object.h" +#include "application_manager/hmi_capabilities_impl.h" #include "application_manager/message_helper.h" #include "application_manager/smart_object_keys.h" #include "config_profile/profile.h" #include "formatters/CFormatterJsonBase.h" #include "interfaces/HMI_API.h" +#include "smart_objects/smart_object.h" #include "utils/file_system.h" +#include "utils/logger.h" namespace application_manager { namespace formatters = ns_smart_device_link::ns_json_handler::formatters; @@ -135,6 +135,46 @@ void InitCapabilities() { hmi_apis::Common_ButtonName::CUSTOM_BUTTON)); button_enum_name.insert(std::make_pair(std::string("SEARCH"), hmi_apis::Common_ButtonName::SEARCH)); + button_enum_name.insert( + std::make_pair(std::string("NAV_CENTER_LOCATION"), + hmi_apis::Common_ButtonName::NAV_CENTER_LOCATION)); + button_enum_name.insert(std::make_pair( + std::string("NAV_ZOOM_IN"), hmi_apis::Common_ButtonName::NAV_ZOOM_IN)); + button_enum_name.insert(std::make_pair( + std::string("NAV_ZOOM_OUT"), hmi_apis::Common_ButtonName::NAV_ZOOM_OUT)); + button_enum_name.insert(std::make_pair( + std::string("NAV_PAN_UP"), hmi_apis::Common_ButtonName::NAV_PAN_UP)); + button_enum_name.insert( + std::make_pair(std::string("NAV_PAN_UP_RIGHT"), + hmi_apis::Common_ButtonName::NAV_PAN_UP_RIGHT)); + button_enum_name.insert( + std::make_pair(std::string("NAV_PAN_RIGHT"), + hmi_apis::Common_ButtonName::NAV_PAN_RIGHT)); + button_enum_name.insert( + std::make_pair(std::string("NAV_PAN_DOWN_RIGHT"), + hmi_apis::Common_ButtonName::NAV_PAN_DOWN_RIGHT)); + button_enum_name.insert(std::make_pair( + std::string("NAV_PAN_DOWN"), hmi_apis::Common_ButtonName::NAV_PAN_DOWN)); + button_enum_name.insert( + std::make_pair(std::string("NAV_PAN_DOWN_LEFT"), + hmi_apis::Common_ButtonName::NAV_PAN_DOWN_LEFT)); + button_enum_name.insert(std::make_pair( + std::string("NAV_PAN_LEFT"), hmi_apis::Common_ButtonName::NAV_PAN_LEFT)); + button_enum_name.insert( + std::make_pair(std::string("NAV_PAN_UP_LEFT"), + hmi_apis::Common_ButtonName::NAV_PAN_UP_LEFT)); + button_enum_name.insert( + std::make_pair(std::string("NAV_TILT_TOGGLE"), + hmi_apis::Common_ButtonName::NAV_TILT_TOGGLE)); + button_enum_name.insert( + std::make_pair(std::string("NAV_ROTATE_CLOCKWISE"), + hmi_apis::Common_ButtonName::NAV_ROTATE_CLOCKWISE)); + button_enum_name.insert( + std::make_pair(std::string("NAV_ROTATE_COUNTERCLOCKWISE"), + hmi_apis::Common_ButtonName::NAV_ROTATE_COUNTERCLOCKWISE)); + button_enum_name.insert( + std::make_pair(std::string("NAV_HEADING_TOGGLE"), + hmi_apis::Common_ButtonName::NAV_HEADING_TOGGLE)); text_fields_enum_name.insert(std::make_pair( std::string("mainField1"), hmi_apis::Common_TextFieldName::mainField1)); @@ -337,6 +377,8 @@ void InitCapabilities() { std::make_pair(std::string("MFD5"), hmi_apis::Common_DisplayType::MFD5)); display_type_enum.insert(std::make_pair( std::string("GEN3_8_INCH"), hmi_apis::Common_DisplayType::GEN3_8_INCH)); + display_type_enum.insert(std::make_pair( + std::string("SDL_GENERIC"), hmi_apis::Common_DisplayType::SDL_GENERIC)); character_set_enum.insert(std::make_pair( std::string("TYPE2SET"), hmi_apis::Common_CharacterSet::TYPE2SET)); @@ -405,6 +447,7 @@ HMICapabilitiesImpl::HMICapabilitiesImpl(ApplicationManager& app_mngr) , phone_capability_(NULL) , video_streaming_capability_(NULL) , rc_capability_(NULL) + , seat_location_capability_(NULL) , app_mngr_(app_mngr) , hmi_language_handler_(app_mngr) { InitCapabilities(); @@ -568,6 +611,12 @@ void HMICapabilitiesImpl::set_display_capabilities( } } +void HMICapabilitiesImpl::set_system_display_capabilities( + const smart_objects::SmartObject& display_capabilities) { + system_display_capabilities_.reset( + new smart_objects::SmartObject(display_capabilities)); +} + void HMICapabilitiesImpl::set_hmi_zone_capabilities( const smart_objects::SmartObject& hmi_zone_capabilities) { if (hmi_zone_capabilities_) { @@ -703,6 +752,15 @@ void HMICapabilitiesImpl::set_rc_capability( rc_capability_ = new smart_objects::SmartObject(rc_capability); } +void HMICapabilitiesImpl::set_seat_location_capability( + const smart_objects::SmartObject& seat_location_capability) { + if (seat_location_capability_) { + delete seat_location_capability_; + } + seat_location_capability_ = + new smart_objects::SmartObject(seat_location_capability); +} + void HMICapabilitiesImpl::Init(resumption::LastState* last_state) { hmi_language_handler_.Init(last_state); if (false == load_capabilities_from_file()) { @@ -758,6 +816,11 @@ const smart_objects::SmartObject* HMICapabilitiesImpl::display_capabilities() return display_capabilities_; } +const smart_objects::SmartObjectSPtr +HMICapabilitiesImpl::system_display_capabilities() const { + return system_display_capabilities_; +} + const smart_objects::SmartObject* HMICapabilitiesImpl::hmi_zone_capabilities() const { return hmi_zone_capabilities_; @@ -845,6 +908,11 @@ const smart_objects::SmartObject* HMICapabilitiesImpl::rc_capability() const { return rc_capability_; } +const smart_objects::SmartObject* +HMICapabilitiesImpl::seat_location_capability() const { + return seat_location_capability_; +} + bool HMICapabilitiesImpl::load_capabilities_from_file() { std::string json_string; std::string file_name = app_mngr_.get_settings().hmi_capabilities_file_name(); @@ -914,7 +982,8 @@ bool HMICapabilitiesImpl::load_capabilities_from_file() { hmi_apis::Common_TextFieldName::eType>::const_iterator it_text_field_name = text_fields_enum_name.find( display_capabilities_so[hmi_response::text_fields][i] - [strings::name].asString()); + [strings::name] + .asString()); display_capabilities_so[hmi_response::text_fields][i].erase( strings::name); if (text_fields_enum_name.end() != it_text_field_name) { @@ -1025,25 +1094,16 @@ bool HMICapabilitiesImpl::load_capabilities_from_file() { if (check_existing_json_member(ui, "audioPassThruCapabilities")) { Json::Value audio_capabilities = ui.get("audioPassThruCapabilities", ""); - smart_objects::SmartObject audio_capabilities_so = - smart_objects::SmartObject(smart_objects::SmartType_Array); - audio_capabilities_so = - smart_objects::SmartObject(smart_objects::SmartType_Map); - if (check_existing_json_member(audio_capabilities, "samplingRate")) { - audio_capabilities_so["samplingRate"] = - sampling_rate_enum.find(audio_capabilities.get("samplingRate", "") - .asString())->second; - } - if (check_existing_json_member(audio_capabilities, "bitsPerSample")) { - audio_capabilities_so["bitsPerSample"] = - bit_per_sample_enum.find(audio_capabilities.get("bitsPerSample", - "").asString()) - ->second; - } - if (check_existing_json_member(audio_capabilities, "audioType")) { - audio_capabilities_so["audioType"] = - audio_type_enum.find(audio_capabilities.get("audioType", "") - .asString())->second; + smart_objects::SmartObject audio_capabilities_so( + smart_objects::SmartType_Array); + if (audio_capabilities.type() == Json::arrayValue) { + for (uint32_t i = 0; i < audio_capabilities.size(); i++) { + convert_audio_capability_to_obj(audio_capabilities[i], + audio_capabilities_so[i]); + } + } else if (audio_capabilities.type() == Json::objectValue) { + convert_audio_capability_to_obj(audio_capabilities, + audio_capabilities_so[0]); } set_audio_pass_thru_capabilities(audio_capabilities_so); } @@ -1052,23 +1112,7 @@ bool HMICapabilitiesImpl::load_capabilities_from_file() { Json::Value pcm_capabilities = ui.get("pcmStreamCapabilities", ""); smart_objects::SmartObject pcm_capabilities_so = smart_objects::SmartObject(smart_objects::SmartType_Map); - - if (check_existing_json_member(pcm_capabilities, "samplingRate")) { - pcm_capabilities_so["samplingRate"] = - sampling_rate_enum.find(pcm_capabilities.get("samplingRate", "") - .asString())->second; - } - if (check_existing_json_member(pcm_capabilities, "bitsPerSample")) { - pcm_capabilities_so["bitsPerSample"] = - bit_per_sample_enum.find(pcm_capabilities.get("bitsPerSample", "") - .asString())->second; - } - if (check_existing_json_member(pcm_capabilities, "audioType")) { - pcm_capabilities_so["audioType"] = - audio_type_enum.find(pcm_capabilities.get("audioType", "") - .asString())->second; - } - + convert_audio_capability_to_obj(pcm_capabilities, pcm_capabilities_so); set_pcm_stream_capabilities(pcm_capabilities_so); } @@ -1089,6 +1133,7 @@ bool HMICapabilitiesImpl::load_capabilities_from_file() { soft_button_capabilities, soft_button_capabilities_so); set_soft_button_capabilities(soft_button_capabilities_so); } + if (check_existing_json_member(ui, "systemCapabilities")) { Json::Value system_capabilities = ui.get("systemCapabilities", ""); if (check_existing_json_member(system_capabilities, @@ -1191,6 +1236,15 @@ bool HMICapabilitiesImpl::load_capabilities_from_file() { set_rc_supported(true); } } + if (check_existing_json_member(system_capabilities, + "seatLocationCapability")) { + Json::Value seat_location_capability = + system_capabilities.get("seatLocationCapability", ""); + smart_objects::SmartObject seat_location_capability_so; + formatters::CFormatterJsonBase::jsonValueToObj( + seat_location_capability, seat_location_capability_so); + set_seat_location_capability(seat_location_capability_so); + } } } // UI end @@ -1325,6 +1379,27 @@ void HMICapabilitiesImpl::convert_json_languages_to_obj( } } +void HMICapabilitiesImpl::convert_audio_capability_to_obj( + const Json::Value& capability, + smart_objects::SmartObject& output_so) const { + if (check_existing_json_member(capability, "samplingRate")) { + output_so[strings::sampling_rate] = + sampling_rate_enum.find(capability.get("samplingRate", "").asString()) + ->second; + } + if (check_existing_json_member(capability, "bitsPerSample")) { + output_so[strings::bits_per_sample] = + bit_per_sample_enum + .find(capability.get("bitsPerSample", "").asString()) + ->second; + } + if (check_existing_json_member(capability, "audioType")) { + output_so[strings::audio_type] = + audio_type_enum.find(capability.get("audioType", "").asString()) + ->second; + } +} + HMILanguageHandler& HMICapabilitiesImpl::get_hmi_language_handler() { return hmi_language_handler_; } diff --git a/src/components/application_manager/src/hmi_interfaces_impl.cc b/src/components/application_manager/src/hmi_interfaces_impl.cc index 9aff403e098..0c33ea4b114 100644 --- a/src/components/application_manager/src/hmi_interfaces_impl.cc +++ b/src/components/application_manager/src/hmi_interfaces_impl.cc @@ -103,8 +103,12 @@ generate_function_to_interface_convert_map() { HmiInterfaces::HMI_INTERFACE_BasicCommunication; convert_map[BasicCommunication_OnEventChanged] = HmiInterfaces::HMI_INTERFACE_BasicCommunication; + convert_map[BasicCommunication_OnServiceUpdate] = + HmiInterfaces::HMI_INTERFACE_BasicCommunication; convert_map[BasicCommunication_GetFilePath] = HmiInterfaces::HMI_INTERFACE_BasicCommunication; + convert_map[BasicCommunication_CloseApplication] = + HmiInterfaces::HMI_INTERFACE_BasicCommunication; convert_map[VR_IsReady] = HmiInterfaces::HMI_INTERFACE_VR; convert_map[VR_Started] = HmiInterfaces::HMI_INTERFACE_VR; convert_map[VR_Stopped] = HmiInterfaces::HMI_INTERFACE_VR; @@ -135,12 +139,16 @@ generate_function_to_interface_convert_map() { convert_map[UI_DeleteCommand] = HmiInterfaces::HMI_INTERFACE_UI; convert_map[UI_AddSubMenu] = HmiInterfaces::HMI_INTERFACE_UI; convert_map[UI_DeleteSubMenu] = HmiInterfaces::HMI_INTERFACE_UI; + convert_map[UI_ShowAppMenu] = HmiInterfaces::HMI_INTERFACE_UI; + convert_map[UI_CreateWindow] = HmiInterfaces::HMI_INTERFACE_UI; + convert_map[UI_DeleteWindow] = HmiInterfaces::HMI_INTERFACE_UI; convert_map[UI_PerformInteraction] = HmiInterfaces::HMI_INTERFACE_UI; convert_map[UI_SetMediaClockTimer] = HmiInterfaces::HMI_INTERFACE_UI; convert_map[UI_SetGlobalProperties] = HmiInterfaces::HMI_INTERFACE_UI; convert_map[UI_OnCommand] = HmiInterfaces::HMI_INTERFACE_UI; convert_map[UI_OnSystemContext] = HmiInterfaces::HMI_INTERFACE_UI; convert_map[UI_GetCapabilities] = HmiInterfaces::HMI_INTERFACE_UI; + convert_map[UI_CancelInteraction] = HmiInterfaces::HMI_INTERFACE_UI; convert_map[UI_ChangeRegistration] = HmiInterfaces::HMI_INTERFACE_UI; convert_map[UI_OnLanguageChange] = HmiInterfaces::HMI_INTERFACE_UI; convert_map[UI_GetSupportedLanguages] = HmiInterfaces::HMI_INTERFACE_UI; @@ -148,7 +156,6 @@ generate_function_to_interface_convert_map() { convert_map[UI_OnDriverDistraction] = HmiInterfaces::HMI_INTERFACE_UI; convert_map[UI_SetAppIcon] = HmiInterfaces::HMI_INTERFACE_UI; convert_map[UI_SetDisplayLayout] = HmiInterfaces::HMI_INTERFACE_UI; - convert_map[UI_ShowCustomForm] = HmiInterfaces::HMI_INTERFACE_UI; convert_map[UI_OnKeyboardInput] = HmiInterfaces::HMI_INTERFACE_UI; convert_map[UI_OnTouchEvent] = HmiInterfaces::HMI_INTERFACE_UI; convert_map[UI_Slider] = HmiInterfaces::HMI_INTERFACE_UI; @@ -219,7 +226,6 @@ generate_function_to_interface_convert_map() { convert_map[SDL_OnStatusUpdate] = HmiInterfaces::HMI_INTERFACE_SDL; convert_map[SDL_OnSystemError] = HmiInterfaces::HMI_INTERFACE_SDL; convert_map[SDL_AddStatisticsInfo] = HmiInterfaces::HMI_INTERFACE_SDL; - convert_map[SDL_GetURLS] = HmiInterfaces::HMI_INTERFACE_SDL; convert_map[RC_IsReady] = HmiInterfaces::HMI_INTERFACE_RC; convert_map[RC_GetCapabilities] = HmiInterfaces::HMI_INTERFACE_RC; convert_map[Buttons_ButtonPress] = HmiInterfaces::HMI_INTERFACE_RC; @@ -229,8 +235,11 @@ generate_function_to_interface_convert_map() { HmiInterfaces::HMI_INTERFACE_RC; convert_map[RC_OnInteriorVehicleData] = HmiInterfaces::HMI_INTERFACE_RC; convert_map[RC_OnRemoteControlSettings] = HmiInterfaces::HMI_INTERFACE_RC; + convert_map[RC_SetGlobalProperties] = HmiInterfaces::HMI_INTERFACE_RC; convert_map[AppService_PublishAppService] = HmiInterfaces::HMI_INTERFACE_AppService; + convert_map[AppService_UnpublishAppService] = + HmiInterfaces::HMI_INTERFACE_AppService; convert_map[AppService_GetAppServiceData] = HmiInterfaces::HMI_INTERFACE_AppService; convert_map[AppService_PerformAppServiceInteraction] = diff --git a/src/components/application_manager/src/hmi_language_handler.cc b/src/components/application_manager/src/hmi_language_handler.cc index 647df242dfd..e206633ae2f 100644 --- a/src/components/application_manager/src/hmi_language_handler.cc +++ b/src/components/application_manager/src/hmi_language_handler.cc @@ -28,16 +28,16 @@ * 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/hmi_language_handler.h" #include "application_manager/application_manager.h" +#include "application_manager/hmi_capabilities.h" #include "application_manager/message_helper.h" #include "application_manager/rpc_service.h" -#include "application_manager/hmi_capabilities.h" -#include "utils/helpers.h" #include "resumption/last_state.h" #include "smart_objects/smart_object.h" +#include "utils/helpers.h" static const std::string LanguagesKey = "Languages"; static const std::string UIKey = "UI"; @@ -78,9 +78,9 @@ void HMILanguageHandler::set_language_for( LOG4CXX_WARN(logger_, "Unknown interface has been passed " << interface); return; } - LOG4CXX_DEBUG(logger_, - "Setting language " << language << " for interface " - << interface); + LOG4CXX_DEBUG( + logger_, + "Setting language " << language << " for interface " << interface); Json::Value& dictionary = last_state_->get_dictionary(); dictionary[LanguagesKey][key] = language; return; @@ -273,8 +273,9 @@ void HMILanguageHandler::VerifyWithPersistedLanguages() { LOG4CXX_INFO(logger_, "Application with app_id " - << app->app_id() << " will be unregistered because of " - "HMI language(s) mismatch."); + << app->app_id() + << " will be unregistered because of " + "HMI language(s) mismatch."); CheckApplication(std::make_pair(app->app_id(), false)); } diff --git a/src/components/application_manager/src/hmi_state.cc b/src/components/application_manager/src/hmi_state.cc index e220988f0ed..844d0254cfa 100644 --- a/src/components/application_manager/src/hmi_state.cc +++ b/src/components/application_manager/src/hmi_state.cc @@ -32,9 +32,9 @@ */ #include "application_manager/hmi_state.h" -#include #include #include +#include #include "application_manager/application_manager.h" #include "utils/helpers.h" @@ -48,6 +48,7 @@ HmiState::HmiState(std::shared_ptr app, : hmi_app_id_(app->hmi_app_id()) , state_id_(state_id) , app_mngr_(app_mngr) + , window_type_(mobile_apis::WindowType::INVALID_ENUM) , hmi_level_(mobile_apis::HMILevel::INVALID_ENUM) , audio_streaming_state_(mobile_apis::AudioStreamingState::INVALID_ENUM) , video_streaming_state_(mobile_apis::VideoStreamingState::INVALID_ENUM) @@ -60,6 +61,7 @@ HmiState::HmiState(std::shared_ptr app, : hmi_app_id_(app->hmi_app_id()) , state_id_(STATE_ID_REGULAR) , app_mngr_(app_mngr) + , window_type_(mobile_apis::WindowType::INVALID_ENUM) , hmi_level_(mobile_apis::HMILevel::INVALID_ENUM) , audio_streaming_state_(mobile_apis::AudioStreamingState::INVALID_ENUM) , video_streaming_state_(mobile_apis::VideoStreamingState::INVALID_ENUM) @@ -96,6 +98,15 @@ bool HmiState::is_mobile_projection_app() const { return app ? app->mobile_projection_enabled() : false; } +mobile_apis::WindowType::eType HmiState::window_type() const { + return window_type_; +} + +void HmiState::set_window_type( + const mobile_apis::WindowType::eType window_type) { + window_type_ = window_type; +} + mobile_apis::AudioStreamingState::eType VRHmiState::audio_streaming_state() const { using namespace mobile_apis; @@ -173,17 +184,25 @@ PhoneCallHmiState::PhoneCallHmiState(std::shared_ptr app, mobile_apis::HMILevel::eType PhoneCallHmiState::hmi_level() const { using namespace helpers; using namespace mobile_apis; + + if (WindowType::WIDGET == window_type()) { + return parent()->hmi_level(); + } + if (Compare(parent()->hmi_level(), HMILevel::HMI_BACKGROUND, HMILevel::HMI_NONE)) { return parent()->hmi_level(); } + if (is_navi_app() || is_mobile_projection_app()) { return HMILevel::HMI_LIMITED; } + if (!is_media_app()) { return parent()->hmi_level(); } + return HMILevel::HMI_BACKGROUND; } @@ -198,6 +217,11 @@ DeactivateHMI::DeactivateHMI(std::shared_ptr app, mobile_apis::HMILevel::eType DeactivateHMI::hmi_level() const { using namespace helpers; using namespace mobile_apis; + + if (WindowType::WIDGET == window_type()) { + return parent()->hmi_level(); + } + if (Compare(parent()->hmi_level(), HMILevel::HMI_BACKGROUND, HMILevel::HMI_NONE)) { @@ -215,14 +239,19 @@ AudioSource::AudioSource(std::shared_ptr app, } mobile_apis::HMILevel::eType AudioSource::hmi_level() const { + using namespace mobile_apis; + + if (WindowType::WIDGET == window_type()) { + return parent()->hmi_level(); + } + // Checking for NONE is necessary to avoid issue during // calculation of HMI level during setting default HMI level - if (keep_context_ || - mobile_apis::HMILevel::HMI_NONE == parent()->hmi_level()) { + if (keep_context_ || HMILevel::HMI_NONE == parent()->hmi_level()) { return parent()->hmi_level(); } - return mobile_apis::HMILevel::HMI_BACKGROUND; + return HMILevel::HMI_BACKGROUND; } EmbeddedNavi::EmbeddedNavi(std::shared_ptr app, @@ -232,11 +261,17 @@ EmbeddedNavi::EmbeddedNavi(std::shared_ptr app, mobile_apis::HMILevel::eType EmbeddedNavi::hmi_level() const { using namespace mobile_apis; using namespace helpers; + + if (WindowType::WIDGET == window_type()) { + return parent()->hmi_level(); + } + if (Compare(parent()->hmi_level(), HMILevel::HMI_BACKGROUND, HMILevel::HMI_NONE)) { return parent()->hmi_level(); } + return HMILevel::HMI_BACKGROUND; } @@ -278,7 +313,8 @@ std::ostream& operator<<(std::ostream& os, const HmiState& src) { } else { os << "(none)"; } - os << ", hmi app id:" << src.hmi_app_id_ << ", state:" << src.state_id() + os << ", hmi app id:" << src.hmi_app_id_ + << ", window_type:" << src.window_type_ << ", state:" << src.state_id() << ", hmi_level:" << src.hmi_level() << ", audio:" << src.audio_streaming_state() << ", video:" << src.video_streaming_state() diff --git a/src/components/application_manager/src/message.cc b/src/components/application_manager/src/message.cc index 332d68adbfc..b75428780d8 100644 --- a/src/components/application_manager/src/message.cc +++ b/src/components/application_manager/src/message.cc @@ -36,7 +36,7 @@ namespace { bool BinaryDataPredicate(uint8_t i, uint8_t j) { return (i == j); } -} +} // namespace namespace application_manager { @@ -64,8 +64,8 @@ Message::Message(protocol_handler::MessagePriority priority) , binary_data_(NULL) , data_size_(0) , payload_size_(0) - , version_( - protocol_handler::MajorProtocolVersion::PROTOCOL_VERSION_UNKNOWN) {} + , version_(protocol_handler::MajorProtocolVersion::PROTOCOL_VERSION_UNKNOWN) + , is_message_encrypted_(false) {} Message::Message(const Message& message) : function_id_(0) @@ -76,8 +76,8 @@ Message::Message(const Message& message) , binary_data_(NULL) , data_size_(0) , payload_size_(0) - , version_( - protocol_handler::MajorProtocolVersion::PROTOCOL_VERSION_UNKNOWN) { + , version_(protocol_handler::MajorProtocolVersion::PROTOCOL_VERSION_UNKNOWN) + , is_message_encrypted_(false) { *this = message; } @@ -142,6 +142,10 @@ int32_t Message::connection_key() const { return connection_key_; } +bool Message::is_message_encrypted() const { + return is_message_encrypted_; +} + MessageType Message::type() const { return type_; } @@ -228,6 +232,10 @@ void Message::set_payload_size(size_t payload_size) { payload_size_ = payload_size; } +void Message::set_message_encryption(const bool protection) { + is_message_encrypted_ = protection; +} + bool Message::is_sufficient_version( protocol_handler::MajorProtocolVersion minVersion, protocol_handler::MajorProtocolVersion version) { 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 0e44a53c6f8..fb0c9f15bff 100644 --- a/src/components/application_manager/src/message_helper/message_helper.cc +++ b/src/components/application_manager/src/message_helper/message_helper.cc @@ -39,13 +39,13 @@ #include #undef __STDC_FORMAT_MACROS -#include -#include #include #include -#include -#include #include +#include +#include +#include +#include #include "application_manager/application.h" #include "application_manager/application_manager.h" @@ -55,18 +55,18 @@ #include "application_manager/resumption/resume_ctrl.h" #include "application_manager/rpc_service.h" #include "connection_handler/connection_handler_impl.h" -#include "transport_manager/common.h" #include "interfaces/MOBILE_API.h" #include "smart_objects/enum_schema_item.h" +#include "transport_manager/common.h" #include "utils/file_system.h" -#include "utils/macro.h" #include "utils/logger.h" +#include "utils/macro.h" -#include "formatters/formatter_json_rpc.h" -#include "formatters/CFormatterJsonSDLRPCv2.h" +#include "formatters/CFormatterJsonBase.h" #include "formatters/CFormatterJsonSDLRPCv1.h" +#include "formatters/CFormatterJsonSDLRPCv2.h" +#include "formatters/formatter_json_rpc.h" #include "json/json.h" -#include "formatters/CFormatterJsonBase.h" CREATE_LOGGERPTR_GLOBAL(logger_, "ApplicationManager") @@ -162,71 +162,84 @@ struct ExternalConsentStatusAppender } // namespace -std::pair kVehicleDataInitializer[] = { - std::make_pair(strings::gps, mobile_apis::VehicleDataType::VEHICLEDATA_GPS), - std::make_pair(strings::speed, - mobile_apis::VehicleDataType::VEHICLEDATA_SPEED), - std::make_pair(strings::rpm, mobile_apis::VehicleDataType::VEHICLEDATA_RPM), - std::make_pair(strings::fuel_level, - mobile_apis::VehicleDataType::VEHICLEDATA_FUELLEVEL), - std::make_pair(strings::fuel_level_state, - mobile_apis::VehicleDataType::VEHICLEDATA_FUELLEVEL_STATE), - std::make_pair(strings::instant_fuel_consumption, - mobile_apis::VehicleDataType::VEHICLEDATA_FUELCONSUMPTION), - std::make_pair(strings::fuel_range, - mobile_apis::VehicleDataType::VEHICLEDATA_FUELRANGE), - std::make_pair(strings::cloud_app_vehicle_id, - mobile_apis::VehicleDataType::VEHICLEDATA_CLOUDAPPVEHICLEID), - std::make_pair(strings::external_temp, - mobile_apis::VehicleDataType::VEHICLEDATA_EXTERNTEMP), - std::make_pair(strings::turn_signal, - mobile_apis::VehicleDataType::VEHICLEDATA_TURNSIGNAL), - std::make_pair(strings::vin, mobile_apis::VehicleDataType::VEHICLEDATA_VIN), - std::make_pair(strings::prndl, - mobile_apis::VehicleDataType::VEHICLEDATA_PRNDL), - std::make_pair(strings::tire_pressure, - mobile_apis::VehicleDataType::VEHICLEDATA_TIREPRESSURE), - std::make_pair(strings::odometer, - mobile_apis::VehicleDataType::VEHICLEDATA_ODOMETER), - std::make_pair(strings::belt_status, - mobile_apis::VehicleDataType::VEHICLEDATA_BELTSTATUS), - std::make_pair( - strings::electronic_park_brake_status, - mobile_apis::VehicleDataType::VEHICLEDATA_ELECTRONICPARKBRAKESTATUS), - std::make_pair(strings::body_information, - mobile_apis::VehicleDataType::VEHICLEDATA_BODYINFO), - std::make_pair(strings::device_status, - mobile_apis::VehicleDataType::VEHICLEDATA_DEVICESTATUS), - std::make_pair(strings::driver_braking, - mobile_apis::VehicleDataType::VEHICLEDATA_BRAKING), - std::make_pair(strings::wiper_status, - mobile_apis::VehicleDataType::VEHICLEDATA_WIPERSTATUS), - std::make_pair(strings::head_lamp_status, - mobile_apis::VehicleDataType::VEHICLEDATA_HEADLAMPSTATUS), - std::make_pair(strings::e_call_info, - mobile_apis::VehicleDataType::VEHICLEDATA_ECALLINFO), - std::make_pair(strings::airbag_status, - mobile_apis::VehicleDataType::VEHICLEDATA_AIRBAGSTATUS), - std::make_pair(strings::emergency_event, - mobile_apis::VehicleDataType::VEHICLEDATA_EMERGENCYEVENT), - std::make_pair(strings::cluster_mode_status, - mobile_apis::VehicleDataType::VEHICLEDATA_CLUSTERMODESTATUS), - std::make_pair(strings::my_key, - mobile_apis::VehicleDataType::VEHICLEDATA_MYKEY), - /* - NOT DEFINED in mobile API - std::make_pair(strings::gps, - BATTVOLTAGE), - */ - std::make_pair(strings::engine_torque, - mobile_apis::VehicleDataType::VEHICLEDATA_ENGINETORQUE), - std::make_pair(strings::acc_pedal_pos, - mobile_apis::VehicleDataType::VEHICLEDATA_ACCPEDAL), - std::make_pair(strings::steering_wheel_angle, - mobile_apis::VehicleDataType::VEHICLEDATA_STEERINGWHEEL), - std::make_pair(strings::engine_oil_life, - mobile_apis::VehicleDataType::VEHICLEDATA_ENGINEOILLIFE)}; +std::pair + kVehicleDataInitializer[] = { + std::make_pair(strings::gps, + mobile_apis::VehicleDataType::VEHICLEDATA_GPS), + std::make_pair(strings::speed, + mobile_apis::VehicleDataType::VEHICLEDATA_SPEED), + std::make_pair(strings::rpm, + mobile_apis::VehicleDataType::VEHICLEDATA_RPM), + std::make_pair(strings::fuel_level, + mobile_apis::VehicleDataType::VEHICLEDATA_FUELLEVEL), + std::make_pair( + strings::fuel_level_state, + mobile_apis::VehicleDataType::VEHICLEDATA_FUELLEVEL_STATE), + std::make_pair( + strings::instant_fuel_consumption, + mobile_apis::VehicleDataType::VEHICLEDATA_FUELCONSUMPTION), + std::make_pair(strings::fuel_range, + mobile_apis::VehicleDataType::VEHICLEDATA_FUELRANGE), + std::make_pair( + strings::cloud_app_vehicle_id, + mobile_apis::VehicleDataType::VEHICLEDATA_CLOUDAPPVEHICLEID), + std::make_pair(strings::external_temp, + mobile_apis::VehicleDataType::VEHICLEDATA_EXTERNTEMP), + std::make_pair(strings::turn_signal, + mobile_apis::VehicleDataType::VEHICLEDATA_TURNSIGNAL), + std::make_pair(strings::vin, + mobile_apis::VehicleDataType::VEHICLEDATA_VIN), + std::make_pair(strings::prndl, + mobile_apis::VehicleDataType::VEHICLEDATA_PRNDL), + std::make_pair(strings::tire_pressure, + mobile_apis::VehicleDataType::VEHICLEDATA_TIREPRESSURE), + std::make_pair(strings::odometer, + mobile_apis::VehicleDataType::VEHICLEDATA_ODOMETER), + std::make_pair(strings::belt_status, + mobile_apis::VehicleDataType::VEHICLEDATA_BELTSTATUS), + std::make_pair(strings::electronic_park_brake_status, + mobile_apis::VehicleDataType:: + VEHICLEDATA_ELECTRONICPARKBRAKESTATUS), + std::make_pair(strings::body_information, + mobile_apis::VehicleDataType::VEHICLEDATA_BODYINFO), + std::make_pair(strings::device_status, + mobile_apis::VehicleDataType::VEHICLEDATA_DEVICESTATUS), + std::make_pair(strings::driver_braking, + mobile_apis::VehicleDataType::VEHICLEDATA_BRAKING), + std::make_pair(strings::wiper_status, + mobile_apis::VehicleDataType::VEHICLEDATA_WIPERSTATUS), + std::make_pair( + strings::head_lamp_status, + mobile_apis::VehicleDataType::VEHICLEDATA_HEADLAMPSTATUS), + std::make_pair(strings::e_call_info, + mobile_apis::VehicleDataType::VEHICLEDATA_ECALLINFO), + std::make_pair(strings::airbag_status, + mobile_apis::VehicleDataType::VEHICLEDATA_AIRBAGSTATUS), + std::make_pair( + strings::emergency_event, + mobile_apis::VehicleDataType::VEHICLEDATA_EMERGENCYEVENT), + std::make_pair( + strings::cluster_mode_status, + mobile_apis::VehicleDataType::VEHICLEDATA_CLUSTERMODESTATUS), + std::make_pair( + strings::cluster_modes, + mobile_apis::VehicleDataType::VEHICLEDATA_CLUSTERMODESTATUS), + std::make_pair(strings::my_key, + mobile_apis::VehicleDataType::VEHICLEDATA_MYKEY), + /* + NOT DEFINED in mobile API + std::make_pair(strings::gps, + BATTVOLTAGE), + */ + std::make_pair(strings::engine_torque, + mobile_apis::VehicleDataType::VEHICLEDATA_ENGINETORQUE), + std::make_pair(strings::acc_pedal_pos, + mobile_apis::VehicleDataType::VEHICLEDATA_ACCPEDAL), + std::make_pair(strings::steering_wheel_angle, + mobile_apis::VehicleDataType::VEHICLEDATA_STEERINGWHEEL), + std::make_pair( + strings::engine_oil_life, + mobile_apis::VehicleDataType::VEHICLEDATA_ENGINEOILLIFE)}; const VehicleData MessageHelper::vehicle_data_( kVehicleDataInitializer, @@ -322,6 +335,15 @@ std::string MessageHelper::CommonLanguageToString( return std::string(); } +std::string MessageHelper::MobileLanguageToString( + mobile_apis::Language::eType language) { + using namespace ns_smart_device_link::ns_smart_objects; + const char* str = 0; + EnumConversionHelper::EnumToCString(language, + &str); + return str ? str : std::string(); +} + smart_objects::SmartObjectSPtr MessageHelper::CreateMessageForHMI( hmi_apis::messageType::eType message_type, const uint32_t correlation_id) { using namespace smart_objects; @@ -338,6 +360,33 @@ smart_objects::SmartObjectSPtr MessageHelper::CreateMessageForHMI( return message; } +smart_objects::SmartObjectSPtr +MessageHelper::CreateDisplayCapabilityUpdateToMobile( + const smart_objects::SmartObject& display_capabilities, Application& app) { + LOG4CXX_AUTO_TRACE(logger_); + auto message = std::make_shared( + smart_objects::SmartType_Map); + + (*message)[strings::params][strings::message_type] = + MessageType::kNotification; + (*message)[strings::params][strings::function_id] = + mobile_apis::FunctionID::OnSystemCapabilityUpdatedID; + (*message)[strings::params][strings::connection_key] = app.app_id(); + (*message)[strings::params][strings::protocol_type] = + commands::CommandImpl::mobile_protocol_type_; + (*message)[strings::params][strings::protocol_version] = + commands::CommandImpl::protocol_version_; + + smart_objects::SmartObject system_capability(smart_objects::SmartType_Map); + system_capability[strings::system_capability_type] = + static_cast(mobile_apis::SystemCapabilityType::DISPLAYS); + system_capability[strings::display_capabilities] = display_capabilities; + (*message)[strings::msg_params][strings::system_capability] = + system_capability; + + return message; +} + void MessageHelper::BroadcastCapabilityUpdate( smart_objects::SmartObject& msg_params, ApplicationManager& app_mngr) { LOG4CXX_AUTO_TRACE(logger_); @@ -359,7 +408,8 @@ void MessageHelper::BroadcastCapabilityUpdate( hmi_apis::FunctionID::BasicCommunication_OnSystemCapabilityUpdated; smart_objects::SmartObjectSPtr hmi_notification = std::make_shared(message); - app_mngr.GetRPCService().ManageHMICommand(hmi_notification); + app_mngr.GetRPCService().ManageHMICommand( + hmi_notification, commands::Command::CommandSource::SOURCE_SDL_TO_HMI); } smart_objects::SmartObject MessageHelper::CreateAppServiceCapabilities( @@ -613,15 +663,16 @@ void MessageHelper::SendResetPropertiesRequest(ApplicationSharedPtr application, msg_params = *MessageHelper::CreateAppVrHelp(application); msg_params[hmi_request::menu_title] = ""; - smart_objects::SmartObject key_board_properties = + smart_objects::SmartObject keyboard_properties = smart_objects::SmartObject(smart_objects::SmartType_Map); - key_board_properties[strings::language] = + keyboard_properties[strings::language] = static_cast(hmi_apis::Common_Language::EN_US); - key_board_properties[hmi_request::keyboard_layout] = + keyboard_properties[hmi_request::keyboard_layout] = static_cast(hmi_apis::Common_KeyboardLayout::QWERTY); - key_board_properties[hmi_request::auto_complete_text] = ""; - msg_params[hmi_request::keyboard_properties] = key_board_properties; + keyboard_properties[hmi_request::auto_complete_list] = + smart_objects::SmartObject(smart_objects::SmartType_Array); + msg_params[hmi_request::keyboard_properties] = keyboard_properties; msg_params[strings::app_id] = application->app_id(); @@ -751,7 +802,8 @@ hmi_apis::Common_Result::eType MessageHelper::MobileToHMIResult( } void MessageHelper::SendHMIStatusNotification( - const Application& application_impl, + ApplicationSharedPtr application, + const WindowID window_id, ApplicationManager& application_manager) { LOG4CXX_AUTO_TRACE(logger_); smart_objects::SmartObjectSPtr notification = @@ -769,16 +821,21 @@ void MessageHelper::SendHMIStatusNotification( static_cast(application_manager::MessageType::kNotification); message[strings::params][strings::connection_key] = - static_cast(application_impl.app_id()); + static_cast(application->app_id()); + + message[strings::msg_params][strings::window_id] = window_id; message[strings::msg_params][strings::hmi_level] = - static_cast(application_impl.hmi_level()); + static_cast(application->hmi_level(window_id)); message[strings::msg_params][strings::audio_streaming_state] = - static_cast(application_impl.audio_streaming_state()); + static_cast(application->audio_streaming_state()); + + message[strings::msg_params][strings::video_streaming_state] = + static_cast(application->video_streaming_state()); message[strings::msg_params][strings::system_context] = - static_cast(application_impl.system_context()); + static_cast(application->system_context(window_id)); application_manager.GetRPCService().ManageMobileCommand( notification, commands::Command::SOURCE_SDL); @@ -1130,12 +1187,11 @@ MessageHelper::CreateGlobalPropertiesRequestsToHMI( auto& help_prompt_manager = const_cast(app.get())->help_prompt_manager(); - const bool can_send_ui = helpers::Compare( - help_prompt_manager.GetSendingType(), - HelpPromptManager::SendingType::kSendVRHelp, - HelpPromptManager::SendingType::kSendBoth); + const bool can_send_ui = helpers:: + Compare( + help_prompt_manager.GetSendingType(), + HelpPromptManager::SendingType::kSendVRHelp, + HelpPromptManager::SendingType::kSendBoth); // UI global properties @@ -1173,12 +1229,11 @@ MessageHelper::CreateGlobalPropertiesRequestsToHMI( requests.push_back(ui_global_properties); } - const bool can_send_vr = helpers::Compare( - help_prompt_manager.GetSendingType(), - HelpPromptManager::SendingType::kSendHelpPrompt, - HelpPromptManager::SendingType::kSendBoth); + const bool can_send_vr = helpers:: + Compare( + help_prompt_manager.GetSendingType(), + HelpPromptManager::SendingType::kSendHelpPrompt, + HelpPromptManager::SendingType::kSendBoth); // TTS global properties if (can_send_vr && (app->help_prompt() || app->timeout_prompt())) { @@ -1539,6 +1594,67 @@ smart_objects::SmartObjectSPtr MessageHelper::CreateAddVRCommandToHMI( return vr_command; } +smart_objects::SmartObjectSPtr MessageHelper::CreateUICreateWindowRequestToHMI( + ApplicationSharedPtr application, + ApplicationManager& app_mngr, + const smart_objects::SmartObject& window_info) { + LOG4CXX_AUTO_TRACE(logger_); + auto ui_request = CreateMessageForHMI(hmi_apis::messageType::request, + app_mngr.GetNextHMICorrelationID()); + + (*ui_request)[strings::params][strings::function_id] = + static_cast(hmi_apis::FunctionID::UI_CreateWindow); + + (*ui_request)[strings::correlation_id] = + (*ui_request)[strings::params][strings::correlation_id]; + (*ui_request)[strings::function_id] = + (*ui_request)[strings::params][strings::function_id]; + + smart_objects::SmartObject msg_params( + smart_objects::SmartObject(smart_objects::SmartType_Map)); + + msg_params[strings::window_id] = window_info[strings::window_id].asInt(); + msg_params[strings::window_type] = window_info[strings::window_type].asInt(); + msg_params[strings::window_name] = + window_info[strings::window_name].asString(); + + if (window_info.keyExists(strings::associated_service_type)) { + msg_params[strings::associated_service_type] = + window_info[strings::associated_service_type].asString(); + } + if (window_info.keyExists(strings::duplicate_updates_from_window_id)) { + msg_params[strings::duplicate_updates_from_window_id] = + window_info[strings::duplicate_updates_from_window_id].asInt(); + } + + msg_params[strings::app_id] = application->hmi_app_id(); + + (*ui_request)[strings::msg_params] = msg_params; + + return ui_request; +} + +smart_objects::SmartObjectList MessageHelper::CreateUICreateWindowRequestsToHMI( + application_manager::ApplicationSharedPtr application, + ApplicationManager& app_mngr, + const smart_objects::SmartObject& windows_info) { + smart_objects::SmartObjectList requests; + DCHECK_OR_RETURN(application, requests); + + for (size_t i = 0; i < windows_info.length(); ++i) { + const auto& info = windows_info[i]; + + const auto ui_request = + CreateUICreateWindowRequestToHMI(application, app_mngr, info); + + DCHECK_OR_RETURN(ui_request, requests); + + requests.push_back(ui_request); + } + + return requests; +} + bool MessageHelper::CreateDeviceInfo( connection_handler::DeviceHandle device_handle, const protocol_handler::SessionObserver& session_observer, @@ -1591,8 +1707,8 @@ bool MessageHelper::CreateHMIApplicationStruct( const smart_objects::SmartObject* app_types = app->app_types(); const smart_objects::SmartObject* ngn_media_screen_name = app->ngn_media_screen_name(); - const smart_objects::SmartObject* day_color_scheme = app->day_color_scheme(); - const smart_objects::SmartObject* night_color_scheme = + const smart_objects::SmartObject day_color_scheme = app->day_color_scheme(); + const smart_objects::SmartObject night_color_scheme = app->night_color_scheme(); message = smart_objects::SmartObject(smart_objects::SmartType_Map); @@ -1630,7 +1746,8 @@ bool MessageHelper::CreateHMIApplicationStruct( const policy::RequestType::State app_request_types_state = policy_handler.GetAppRequestTypeState(policy_app_id); if (policy::RequestType::State::AVAILABLE == app_request_types_state) { - const auto request_types = policy_handler.GetAppRequestTypes(policy_app_id); + const auto request_types = + policy_handler.GetAppRequestTypes(app->device(), policy_app_id); message[strings::request_type] = SmartObject(smart_objects::SmartType_Array); smart_objects::SmartObject& request_types_array = @@ -1667,12 +1784,12 @@ bool MessageHelper::CreateHMIApplicationStruct( SmartObject(smart_objects::SmartType_Array); } - if (day_color_scheme) { - message[strings::day_color_scheme] = *day_color_scheme; + if (day_color_scheme.getType() == smart_objects::SmartType_Map) { + message[strings::day_color_scheme] = day_color_scheme; } - if (night_color_scheme) { - message[strings::night_color_scheme] = *night_color_scheme; + if (night_color_scheme.getType() == smart_objects::SmartType_Map) { + message[strings::night_color_scheme] = night_color_scheme; } message[strings::device_info] = @@ -1781,12 +1898,16 @@ void MessageHelper::SendOnAppUnregNotificationToHMI( smart_objects::SmartObjectSPtr MessageHelper::GetBCActivateAppRequestToHMI( ApplicationConstSharedPtr app, - const protocol_handler::SessionObserver& session_observer, const policy::PolicyHandlerInterface& policy_handler, hmi_apis::Common_HMILevel::eType level, bool send_policy_priority, ApplicationManager& app_mngr) { DCHECK_OR_RETURN(app, smart_objects::SmartObjectSPtr()); + if (hmi_apis::Common_HMILevel::NONE == level) { + LOG4CXX_WARN(logger_, + "BC.ActivateApp cannot be used to deactivate an application"); + return NULL; + } const uint32_t correlation_id = app_mngr.GetNextHMICorrelationID(); smart_objects::SmartObjectSPtr message = @@ -1823,6 +1944,23 @@ smart_objects::SmartObjectSPtr MessageHelper::GetBCActivateAppRequestToHMI( return message; } +smart_objects::SmartObjectSPtr MessageHelper::GetBCCloseApplicationRequestToHMI( + ApplicationConstSharedPtr app, ApplicationManager& app_mngr) { + DCHECK_OR_RETURN(app, smart_objects::SmartObjectSPtr()); + + const uint32_t correlation_id = app_mngr.GetNextHMICorrelationID(); + smart_objects::SmartObjectSPtr message = + std::make_shared( + smart_objects::SmartType_Map); + (*message)[strings::params][strings::function_id] = + hmi_apis::FunctionID::BasicCommunication_CloseApplication; + (*message)[strings::params][strings::message_type] = MessageType::kRequest; + (*message)[strings::params][strings::correlation_id] = correlation_id; + (*message)[strings::msg_params][strings::app_id] = app->app_id(); + + return message; +} + void MessageHelper::SendOnResumeAudioSourceToHMI(const uint32_t app_id, ApplicationManager& app_mngr) { LOG4CXX_WARN(logger_, "SendOnResumeAudioSourceToHMI app_id: " << app_id); @@ -2099,6 +2237,34 @@ smart_objects::SmartObjectSPtr MessageHelper::CreateNegativeResponse( return std::make_shared(response_data); } +smart_objects::SmartObjectSPtr MessageHelper::CreateOnServiceUpdateNotification( + const hmi_apis::Common_ServiceType::eType service_type, + const hmi_apis::Common_ServiceEvent::eType service_event, + const hmi_apis::Common_ServiceStatusUpdateReason::eType + service_update_reason, + const uint32_t app_id) { + LOG4CXX_AUTO_TRACE(logger_); + auto notification = MessageHelper::CreateHMINotification( + hmi_apis::FunctionID::BasicCommunication_OnServiceUpdate); + + (*notification)[strings::msg_params][hmi_notification::service_type] = + service_type; + (*notification)[strings::msg_params][hmi_notification::service_event] = + service_event; + + if (0 != app_id) { + (*notification)[strings::msg_params][strings::app_id] = app_id; + } + + if (hmi_apis::Common_ServiceStatusUpdateReason::INVALID_ENUM != + service_update_reason) { + (*notification)[strings::msg_params][hmi_notification::reason] = + service_update_reason; + } + + return notification; +} + void MessageHelper::SendNaviSetVideoConfig( int32_t app_id, ApplicationManager& app_mngr, @@ -2295,6 +2461,14 @@ void MessageHelper::SendPolicySnapshotNotification( const std::string& url, ApplicationManager& app_mngr) { smart_objects::SmartObject content(smart_objects::SmartType_Map); + const auto request_type = +#if defined(PROPRIETARY_MODE) || defined(EXTERNAL_PROPRIETARY_MODE) + mobile_apis::RequestType::PROPRIETARY; +#else + mobile_apis::RequestType::HTTP; +#endif // PROPRIETARY || EXTERNAL_PROPRIETARY_MODE + + content[strings::msg_params][strings::request_type] = request_type; if (!url.empty()) { content[strings::msg_params][strings::url] = @@ -2305,13 +2479,6 @@ void MessageHelper::SendPolicySnapshotNotification( content[strings::params][strings::binary_data] = smart_objects::SmartObject(policy_data); -#if defined(PROPRIETARY_MODE) || defined(EXTERNAL_PROPRIETARY_MODE) - content[strings::msg_params][strings::request_type] = - mobile_apis::RequestType::PROPRIETARY; -#else - content[strings::msg_params][strings::request_type] = - mobile_apis::RequestType::HTTP; -#endif // PROPRIETARY || EXTERNAL_PROPRIETARY_MODE SendSystemRequestNotification(connection_key, content, app_mngr); } @@ -2393,7 +2560,8 @@ void MessageHelper::SendQueryApps(const uint32_t connection_key, void MessageHelper::SendOnPermissionsChangeNotification( uint32_t connection_key, const policy::Permissions& permissions, - ApplicationManager& app_mngr) { + ApplicationManager& app_mngr, + const policy::EncryptionRequired encryprion_required) { LOG4CXX_AUTO_TRACE(logger_); smart_objects::SmartObject content(smart_objects::SmartType_Map); @@ -2410,8 +2578,10 @@ void MessageHelper::SendOnPermissionsChangeNotification( content[strings::msg_params] = smart_objects::SmartObject(smart_objects::SmartType_Map); - // content[strings::msg_params][strings::app_id] = connection_key; - + if (encryprion_required.is_initialized()) { + content[strings::msg_params][strings::require_encryption] = + static_cast(*encryprion_required); + } content[strings::msg_params]["permissionItem"] = smart_objects::SmartObject(smart_objects::SmartType_Array); @@ -2421,6 +2591,41 @@ void MessageHelper::SendOnPermissionsChangeNotification( policy::Permissions::const_iterator it_permissions = permissions.begin(); policy::Permissions::const_iterator it_permissions_end = permissions.end(); + using policy::EncryptionRequired; + auto permission_item_encryption_flag_state = + [](const EncryptionRequired& app_flag, + const EncryptionRequired& groups_flag) -> EncryptionRequired { + enum EncryptionFlagState { TRUE, FALSE, MISSING }; + auto enum_from_optional_bool = [](const EncryptionRequired& flag) { + if (!flag.is_initialized()) { + return MISSING; + } + return *flag ? TRUE : FALSE; + }; + + typedef std::pair + EnctyptionStatePair; + typedef std::map + PermissionItemEncryptionTable; + static PermissionItemEncryptionTable encryption_state_table = { + {{TRUE, TRUE}, EncryptionRequired(true)}, + {{TRUE, FALSE}, EncryptionRequired()}, + {{TRUE, MISSING}, EncryptionRequired()}, + {{FALSE, TRUE}, EncryptionRequired()}, + {{FALSE, FALSE}, EncryptionRequired()}, + {{FALSE, MISSING}, EncryptionRequired()}, + {{MISSING, TRUE}, EncryptionRequired(true)}, + {{MISSING, FALSE}, EncryptionRequired()}, + {{MISSING, MISSING}, EncryptionRequired()}, + }; + const auto app_flag_state = enum_from_optional_bool(app_flag); + const auto groups_flag_state = enum_from_optional_bool(groups_flag); + auto it = encryption_state_table.find( + EnctyptionStatePair(app_flag_state, groups_flag_state)); + DCHECK_OR_RETURN(it != encryption_state_table.end(), EncryptionRequired()); + return it->second; + }; + for (size_t index_pi = 0; it_permissions != it_permissions_end; ++it_permissions, ++index_pi) { permissions_item_array[index_pi] = @@ -2429,9 +2634,14 @@ void MessageHelper::SendOnPermissionsChangeNotification( smart_objects::SmartObject& permission_item = permissions_item_array[index_pi]; - // Filling the rpcName of PermissionItem permission_item["rpcName"] = (*it_permissions).first; const policy::RpcPermissions& rpc_permissions = (*it_permissions).second; + auto item_require_encryption = permission_item_encryption_flag_state( + encryprion_required, rpc_permissions.require_encryption); + if (item_require_encryption.is_initialized()) { + const bool require_encryption = *item_require_encryption; + permission_item[strings::require_encryption] = require_encryption; + } // Creating SO for hmiPermissions permission_item["hmiPermissions"] = @@ -2930,7 +3140,7 @@ mobile_apis::Result::eType MessageHelper::ProcessSoftButtons( } if ((!request_soft_buttons[i].keyExists(strings::text)) || (!VerifyString( - request_soft_buttons[i][strings::text].asString()))) { + request_soft_buttons[i][strings::text].asString()))) { return Result::INVALID_DATA; } break; @@ -2939,7 +3149,7 @@ mobile_apis::Result::eType MessageHelper::ProcessSoftButtons( if ((!request_soft_buttons[i].keyExists(strings::text)) || ((request_soft_buttons[i][strings::text].length()) && (!VerifyString( - request_soft_buttons[i][strings::text].asString())))) { + request_soft_buttons[i][strings::text].asString())))) { return Result::INVALID_DATA; } @@ -2971,17 +3181,32 @@ mobile_apis::Result::eType MessageHelper::ProcessSoftButtons( void MessageHelper::SubscribeApplicationToSoftButton( smart_objects::SmartObject& message_params, ApplicationSharedPtr app, - int32_t function_id) { + int32_t function_id, + const WindowID window_id) { SoftButtonID softbuttons_id; smart_objects::SmartObject& soft_buttons = message_params[strings::soft_buttons]; unsigned int length = soft_buttons.length(); for (unsigned int i = 0; i < length; ++i) { - softbuttons_id.insert(soft_buttons[i][strings::soft_button_id].asUInt()); + const auto button_id = std::make_pair( + soft_buttons[i][strings::soft_button_id].asUInt(), window_id); + softbuttons_id.insert(button_id); } app->SubscribeToSoftButtons(function_id, softbuttons_id); } +void MessageHelper::SubscribeApplicationToSoftButton( + smart_objects::SmartObject& message_params, + ApplicationSharedPtr app, + int32_t function_id) { + LOG4CXX_AUTO_TRACE(logger_); + SubscribeApplicationToSoftButton( + message_params, + app, + function_id, + mobile_apis::PredefinedWindows::DEFAULT_WINDOW); +} + bool MessageHelper::PrintSmartObject(const smart_objects::SmartObject& object) { #ifdef DEBUG Json::Value tmp; @@ -2992,4 +3217,14 @@ bool MessageHelper::PrintSmartObject(const smart_objects::SmartObject& object) { return true; } +WindowID MessageHelper::ExtractWindowIdFromSmartObject( + const smart_objects::SmartObject& s_map) { + if (smart_objects::SmartType_Map == s_map.getType()) { + if (s_map.keyExists(strings::window_id)) { + return s_map[strings::window_id].asInt(); + } + } + return mobile_apis::PredefinedWindows::DEFAULT_WINDOW; +} + } // namespace application_manager diff --git a/src/components/application_manager/src/mobile_message_handler.cc b/src/components/application_manager/src/mobile_message_handler.cc index 1ee368a212a..d3e7c782f7a 100644 --- a/src/components/application_manager/src/mobile_message_handler.cc +++ b/src/components/application_manager/src/mobile_message_handler.cc @@ -32,12 +32,12 @@ #include -#include "utils/macro.h" #include "application_manager/mobile_message_handler.h" -#include "protocol_handler/protocol_payload.h" #include "protocol_handler/protocol_packet.h" +#include "protocol_handler/protocol_payload.h" #include "utils/bitstream.h" #include "utils/logger.h" +#include "utils/macro.h" #include #include @@ -48,7 +48,7 @@ const uint8_t kRequest = 0x0; const uint8_t kResponse = 0x1; const uint8_t kNotification = 0x2; const uint8_t kUnknown = 0xF; -} +} // namespace namespace application_manager { using protocol_handler::Extract; @@ -58,7 +58,7 @@ typedef std::map MessageTypeMap; MessageTypeMap message_types = {std::make_pair(kRequest, "Request"), std::make_pair(kResponse, "Response"), std::make_pair(kNotification, "Notification")}; -} +} // namespace CREATE_LOGGERPTR_GLOBAL(logger_, "ApplicationManager") application_manager::Message* @@ -195,6 +195,7 @@ MobileMessageHandler::HandleIncomingMessageProtocolV2( message->protocol_version())); outgoing_message->set_data_size(message->data_size()); outgoing_message->set_payload_size(message->payload_size()); + outgoing_message->set_message_encryption(message->protection_flag()); if (!payload.data.empty()) { const BinaryData binary_payload_data(payload.data); @@ -220,7 +221,8 @@ MobileMessageHandler::HandleOutgoingMessageProtocolV1( new protocol_handler::RawMessage(message->connection_key(), 1, &raw_message[0], - message_string.length() + 1); + message_string.length() + 1, + false); return result; } @@ -298,6 +300,7 @@ MobileMessageHandler::HandleOutgoingMessageProtocolV2( message->protocol_version(), &data_for_sending[0], data_for_sending_size, + false, type); return msg_to_protocol_handler; diff --git a/src/components/application_manager/src/plugin_manager/plugin_keys.cc b/src/components/application_manager/src/plugin_manager/plugin_keys.cc index 9eabc67c091..80be2d13898 100644 --- a/src/components/application_manager/src/plugin_manager/plugin_keys.cc +++ b/src/components/application_manager/src/plugin_manager/plugin_keys.cc @@ -8,7 +8,7 @@ const char* vehicle_info_rpc_plugin = "Vehicle Info RPC Plugin"; const char* app_service_rpc_plugin = "App Service RPC Plugin"; const char* rc_rpc_plugin = "RC RPC Plugin"; const char* sdl_rpc_plugin = "SDL RPC Plugin"; -} +} // namespace plugin_names } // namespace plugin_manager } // namespace application_manager \ No newline at end of file diff --git a/src/components/application_manager/src/plugin_manager/rpc_plugin_manager_impl.cc b/src/components/application_manager/src/plugin_manager/rpc_plugin_manager_impl.cc index bbd0011298c..0c7ec9838bc 100644 --- a/src/components/application_manager/src/plugin_manager/rpc_plugin_manager_impl.cc +++ b/src/components/application_manager/src/plugin_manager/rpc_plugin_manager_impl.cc @@ -1,6 +1,6 @@ -#include "application_manager/plugin_manager/rpc_plugin_manager_impl.h" #include +#include "application_manager/plugin_manager/rpc_plugin_manager_impl.h" #include "utils/file_system.h" namespace application_manager { @@ -12,11 +12,13 @@ RPCPluginManagerImpl::RPCPluginManagerImpl( ApplicationManager& app_manager, rpc_service::RPCService& rpc_service, HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handler) + policy::PolicyHandlerInterface& policy_handler, + resumption::LastState& last_state) : app_manager_(app_manager) , rpc_service_(rpc_service) , hmi_capabilities_(hmi_capabilities) - , policy_handler_(policy_handler) {} + , policy_handler_(policy_handler) + , last_state_(last_state) {} bool IsLibraryFile(const std::string& file_path) { size_t pos = file_path.find_last_of("."); @@ -29,32 +31,57 @@ bool IsLibraryFile(const std::string& file_path) { return true; } -RPCPluginPtr LoadPlugin(const std::string& full_plugin_path) { +template +T GetFuncFromLib(void* dl_handle, const std::string& function_name) { + T exported_func = + reinterpret_cast(dlsym(dl_handle, function_name.c_str())); + char* error_string = dlerror(); + if (nullptr != error_string) { + LOG4CXX_ERROR(logger_, "Failed to export symbols : " << error_string); + return nullptr; + } + return exported_func; +} + +RPCPluginManagerImpl::RPCPluginPtr RPCPluginManagerImpl::LoadPlugin( + const std::string& full_plugin_path) const { if (!IsLibraryFile(full_plugin_path)) { LOG4CXX_DEBUG(logger_, "Skip loading " << full_plugin_path); - return RPCPluginPtr(); + return RPCPluginPtr(nullptr, [](RPCPlugin*) {}); } void* plugin_dll = dlopen(full_plugin_path.c_str(), RTLD_LAZY); if (nullptr == plugin_dll) { - LOG4CXX_ERROR(logger_, - "Failed to open dll " << full_plugin_path << " : " - << dlerror()); - return RPCPluginPtr(); + LOG4CXX_ERROR( + logger_, + "Failed to open dll " << full_plugin_path << " : " << dlerror()); + return RPCPluginPtr(nullptr, [](RPCPlugin*) {}); } typedef RPCPlugin* (*Create)(); - Create create_plugin = reinterpret_cast(dlsym(plugin_dll, "Create")); - char* error_string = dlerror(); - if (nullptr != error_string) { - LOG4CXX_ERROR(logger_, - "Failed to export dll's " << full_plugin_path - << " symbols : " << error_string); + Create create_plugin = GetFuncFromLib(plugin_dll, "Create"); + if (!create_plugin) { + LOG4CXX_ERROR(logger_, "No Create function in " << full_plugin_path); + dlclose(plugin_dll); + return RPCPluginPtr(nullptr, [](RPCPlugin*) {}); + } + + typedef void (*Delete)(RPCPlugin*); + Delete delete_plugin = GetFuncFromLib(plugin_dll, "Delete"); + if (!delete_plugin) { + LOG4CXX_ERROR(logger_, "No Delete function in " << full_plugin_path); dlclose(plugin_dll); - return RPCPluginPtr(); + return RPCPluginPtr(nullptr, [](RPCPlugin*) {}); } + + auto plugin_destroyer = [delete_plugin, plugin_dll](RPCPlugin* plugin) { + LOG4CXX_DEBUG(logger_, "Delete plugin " << plugin->PluginName()); + delete_plugin(plugin); + dlclose(plugin_dll); + return RPCPluginPtr(nullptr, [](RPCPlugin*) {}); + }; RPCPlugin* plugin = create_plugin(); - return RPCPluginPtr(plugin); + return RPCPluginPtr(plugin, plugin_destroyer); } uint32_t RPCPluginManagerImpl::LoadPlugins(const std::string& plugins_path) { @@ -66,11 +93,14 @@ uint32_t RPCPluginManagerImpl::LoadPlugins(const std::string& plugins_path) { if (!plugin) { continue; } - LOG4CXX_DEBUG(logger_, - "Loaded " << plugin->PluginName() << " plugin from " - << full_name); - if (plugin->Init( - app_manager_, rpc_service_, hmi_capabilities_, policy_handler_)) { + LOG4CXX_DEBUG( + logger_, + "Loaded " << plugin->PluginName() << " plugin from " << full_name); + if (plugin->Init(app_manager_, + rpc_service_, + hmi_capabilities_, + policy_handler_, + last_state_)) { loaded_plugins_.push_back(std::move(plugin)); } else { LOG4CXX_ERROR(logger_, @@ -82,10 +112,6 @@ uint32_t RPCPluginManagerImpl::LoadPlugins(const std::string& plugins_path) { return loaded_plugins_.size(); } -std::vector& RPCPluginManagerImpl::GetPlugins() { - return loaded_plugins_; -} - utils::Optional RPCPluginManagerImpl::FindPluginToProcess( const int32_t function_id, const commands::Command::CommandSource message_source) { diff --git a/src/components/application_manager/src/policies/policy_event_observer.cc b/src/components/application_manager/src/policies/policy_event_observer.cc index ea8935c8c5e..afe909fee41 100644 --- a/src/components/application_manager/src/policies/policy_event_observer.cc +++ b/src/components/application_manager/src/policies/policy_event_observer.cc @@ -31,10 +31,10 @@ */ #include "application_manager/policies/policy_event_observer.h" -#include "application_manager/smart_object_keys.h" #include "application_manager/policies/policy_handler.h" -#include "utils/date_time.h" +#include "application_manager/smart_object_keys.h" #include "smart_objects/smart_object.h" +#include "utils/date_time.h" namespace policy { using namespace application_manager; diff --git a/src/components/application_manager/src/policies/policy_handler.cc b/src/components/application_manager/src/policies/policy_handler.cc index aeb5a8bd012..09dcb2c7adf 100644 --- a/src/components/application_manager/src/policies/policy_handler.cc +++ b/src/components/application_manager/src/policies/policy_handler.cc @@ -30,34 +30,37 @@ POSSIBILITY OF SUCH DAMAGE. */ #include "application_manager/policies/policy_handler.h" -#include #include +#include #include -#include #include #include -#include "application_manager/smart_object_keys.h" -#include "application_manager/policies/delegates/app_permission_delegate.h" -#include "policy/status.h" +#include #include "application_manager/application_manager.h" -#include "application_manager/state_controller.h" #include "application_manager/message_helper.h" +#include "application_manager/policies/delegates/app_permission_delegate.h" #include "application_manager/rpc_service.h" -#include "policy/policy_manager_impl.h" +#include "application_manager/smart_object_keys.h" +#include "application_manager/state_controller.h" +#include "application_manager/usage_statistics.h" #include "connection_handler/connection_handler.h" -#include "utils/macro.h" -#include "utils/date_time.h" +#include "interfaces/MOBILE_API.h" #include "json/value.h" #include "json/writer.h" -#include "application_manager/usage_statistics.h" +#include "policy/policy_manager_impl.h" #include "policy/policy_types.h" -#include "interfaces/MOBILE_API.h" +#include "policy/status.h" +#include "smart_objects/enum_schema_item.h" +#include "utils/date_time.h" #include "utils/file_system.h" +#include "utils/macro.h" #include "utils/scope_guard.h" -#include "smart_objects/enum_schema_item.h" -#include "utils/helpers.h" #include "policy/policy_manager.h" +#include "utils/helpers.h" +#ifdef EXTERNAL_PROPRIETARY_MODE +#include "policy/ptu_retry_handler.h" +#endif // EXTERNAL_PROPRIETARY_MODE namespace policy { @@ -107,13 +110,12 @@ const policy::DeviceParams GetDeviceParams( const protocol_handler::SessionObserver& session_observer) { CREATE_LOGGERPTR_LOCAL(logger_, "PolicyHandler"); policy::DeviceParams device_params; - if (-1 == - session_observer.GetDataOnDeviceID( - device_handle, - &device_params.device_name, - NULL, - &device_params.device_mac_address, - &device_params.device_connection_type)) { + if (-1 == session_observer.GetDataOnDeviceID( + device_handle, + &device_params.device_name, + NULL, + &device_params.device_mac_address, + &device_params.device_connection_type)) { LOG4CXX_ERROR(logger_, "Failed to extract information for device " << device_handle); } @@ -127,7 +129,10 @@ struct HMILevelPredicate : level_(level) {} bool operator()(const ApplicationSharedPtr app) const { - return level_ == app->hmi_level() ? true : false; + return level_ == app->hmi_level( + mobile_apis::PredefinedWindows::DEFAULT_WINDOW) + ? true + : false; } private: @@ -166,6 +171,7 @@ struct DeactivateApplication { if (device_id_ == app->device()) { state_ctrl_.SetRegularState( app, + mobile_apis::PredefinedWindows::DEFAULT_WINDOW, mobile_apis::HMILevel::HMI_NONE, mobile_apis::AudioStreamingState::NOT_AUDIBLE, mobile_apis::VideoStreamingState::NOT_STREAMABLE, @@ -178,41 +184,6 @@ struct DeactivateApplication { StateController& state_ctrl_; }; -struct SDLAllowedNotification { - SDLAllowedNotification(const connection_handler::DeviceHandle& device_id, - PolicyManager* policy_manager, - StateController& state_controller) - : device_id_(device_id) - , policy_manager_(policy_manager) - , state_controller_(state_controller) {} - - void operator()(const ApplicationSharedPtr& app) { - DCHECK_OR_RETURN_VOID(policy_manager_); - if (device_id_ == app->device()) { - std::string hmi_level = "NONE"; - mobile_apis::HMILevel::eType default_mobile_hmi; - policy_manager_->GetDefaultHmi(app->policy_app_id(), &hmi_level); - if ("BACKGROUND" == hmi_level) { - default_mobile_hmi = mobile_apis::HMILevel::HMI_BACKGROUND; - } else if ("FULL" == hmi_level) { - default_mobile_hmi = mobile_apis::HMILevel::HMI_FULL; - } else if ("LIMITED" == hmi_level) { - default_mobile_hmi = mobile_apis::HMILevel::HMI_LIMITED; - } else if ("NONE" == hmi_level) { - default_mobile_hmi = mobile_apis::HMILevel::HMI_NONE; - } else { - return; - } - state_controller_.SetRegularState(app, default_mobile_hmi, true); - } - } - - private: - connection_handler::DeviceHandle device_id_; - PolicyManager* policy_manager_; - StateController& state_controller_; -}; - /** * @brief Gets from system list of currently registered applications and * create collection of links device-to-application @@ -327,7 +298,6 @@ const std::string PolicyHandler::kLibrary = "libPolicy.so"; PolicyHandler::PolicyHandler(const PolicySettings& settings, ApplicationManager& application_manager) : AsyncRunner("PolicyHandler async runner thread") - , dl_handle_(0) , last_activated_app_id_(0) , statistic_manager_impl_(std::make_shared(this)) , settings_(settings) @@ -335,6 +305,11 @@ PolicyHandler::PolicyHandler(const PolicySettings& settings, PolicyHandler::~PolicyHandler() {} +PolicyEncryptionFlagGetterInterfaceSPtr +PolicyHandler::PolicyEncryptionFlagGetter() const { + return policy_manager_; +} + bool PolicyHandler::PolicyEnabled() const { return get_settings().enable_policy(); } @@ -349,36 +324,46 @@ bool PolicyHandler::LoadPolicyLibrary() { policy_manager_.reset(); return false; } - dl_handle_ = dlopen(kLibrary.c_str(), RTLD_LAZY); - const char* error = dlerror(); - if (!error) { - if (CreateManager()) { - policy_manager_->set_listener(this); - event_observer_ = - std::shared_ptr(new PolicyEventObserver( - this, application_manager_.event_dispatcher())); - } - } else { - LOG4CXX_ERROR(logger_, error); + if (CreateManager()) { + policy_manager_->set_listener(this); + event_observer_ = std::shared_ptr( + new PolicyEventObserver(this, application_manager_.event_dispatcher())); } return (policy_manager_.use_count() != 0); } bool PolicyHandler::CreateManager() { + void* policy_handle = dlopen(kLibrary.c_str(), RTLD_LAZY); + const char* error = dlerror(); + if (!policy_handle) { + LOG4CXX_ERROR( + logger_, + (error == NULL ? "Unknown error in dlopen while loading policy table" + : error)); + return false; + } + typedef PolicyManager* (*CreateManager)(); typedef void (*DeleteManager)(PolicyManager*); CreateManager create_manager = - reinterpret_cast(dlsym(dl_handle_, "CreateManager")); + reinterpret_cast(dlsym(policy_handle, "CreateManager")); DeleteManager delete_manager = - reinterpret_cast(dlsym(dl_handle_, "DeleteManager")); + reinterpret_cast(dlsym(policy_handle, "DeleteManager")); + auto policy_destroyer = [delete_manager, + policy_handle](PolicyManager* policy_manager) { + LOG4CXX_DEBUG(logger_, "Delete Policy Manager"); + delete_manager(policy_manager); + dlclose(policy_handle); + }; char* error_string = dlerror(); if (NULL == error_string) { policy_manager_ = - std::shared_ptr(create_manager(), delete_manager); + std::shared_ptr(create_manager(), policy_destroyer); } else { LOG4CXX_WARN(logger_, error_string); + dlclose(policy_handle); } return (policy_manager_.use_count() != 0); } @@ -396,12 +381,31 @@ bool PolicyHandler::InitPolicyTable() { hmi_apis::FunctionID::BasicCommunication_OnReady); std::string preloaded_file = get_settings().preloaded_pt_file(); if (file_system::FileExists(preloaded_file)) { - return policy_manager_->InitPT(preloaded_file, &get_settings()); + const bool pt_inited = + policy_manager_->InitPT(preloaded_file, &get_settings()); + OnPTInited(); + return pt_inited; } LOG4CXX_FATAL(logger_, "The file which contains preloaded PT is not exist"); return false; } +void PolicyHandler::OnPTInited() { + LOG4CXX_AUTO_TRACE(logger_); + + sync_primitives::AutoLock lock(listeners_lock_); + + std::for_each(listeners_.begin(), + listeners_.end(), + std::mem_fun(&PolicyHandlerObserver::OnPTInited)); +} + +void PolicyHandler::StopRetrySequence() { + LOG4CXX_AUTO_TRACE(logger_); + + policy_manager_->StopRetrySequence(); +} + bool PolicyHandler::ResetPolicyTable() { LOG4CXX_TRACE(logger_, "Reset policy table."); POLICY_LIB_CHECK(false); @@ -453,10 +457,20 @@ uint32_t PolicyHandler::GetAppIdForSending() const { logger_, "Number of apps with NONE level: " << apps_with_none_level.size()); + if (apps_with_none_level.empty()) { + LOG4CXX_WARN(logger_, "There is no registered application"); + return 0; + } + return ChooseRandomAppForPolicyUpdate(apps_with_none_level); } #ifdef EXTERNAL_PROPRIETARY_MODE +PTURetryHandler& PolicyHandler::ptu_retry_handler() const { + LOG4CXX_AUTO_TRACE(logger_); + return *policy_manager_; +} + void PolicyHandler::OnAppPermissionConsent( const uint32_t connection_key, const PermissionConsent& permissions, @@ -476,6 +490,7 @@ void PolicyHandler::OnAppPermissionConsent( void PolicyHandler::OnDeviceConsentChanged(const std::string& device_id, const bool is_allowed) { + LOG4CXX_AUTO_TRACE(logger_); POLICY_LIB_CHECK_VOID(); connection_handler::DeviceHandle device_handle; if (!application_manager_.connection_handler().GetDeviceID(device_id, @@ -506,21 +521,25 @@ void PolicyHandler::OnDeviceConsentChanged(const std::string& device_id, continue; } - policy_manager_->ReactOnUserDevConsentForApp(policy_app_id, is_allowed); + policy_manager_->ReactOnUserDevConsentForApp( + device_handle, policy_app_id, is_allowed); - policy_manager_->SendNotificationOnPermissionsUpdated(policy_app_id); + policy_manager_->SendNotificationOnPermissionsUpdated(device_id, + policy_app_id); } } } void PolicyHandler::SendOnAppPermissionsChanged( - const AppPermissions& permissions, const std::string& policy_app_id) const { + const AppPermissions& permissions, + const std::string& device_id, + const std::string& policy_app_id) const { LOG4CXX_AUTO_TRACE(logger_); - LOG4CXX_DEBUG(logger_, - "PolicyHandler::SendOnAppPermissionsChanged for " - << policy_app_id); + LOG4CXX_DEBUG( + logger_, + "PolicyHandler::SendOnAppPermissionsChanged for " << policy_app_id); ApplicationSharedPtr app = - application_manager_.application_by_policy_id(policy_app_id); + application_manager_.application(device_id, policy_app_id); if (app.use_count() == 0) { LOG4CXX_WARN(logger_, "No app found for policy app id = " << policy_app_id); return; @@ -554,10 +573,11 @@ struct SmartObjectToInt { }; StatusNotifier PolicyHandler::AddApplication( + const std::string& device_id, const std::string& application_id, const rpc::policy_table_interface_base::AppHmiTypes& hmi_types) { POLICY_LIB_CHECK(std::make_shared()); - return policy_manager_->AddApplication(application_id, hmi_types); + return policy_manager_->AddApplication(device_id, application_id, hmi_types); } void PolicyHandler::AddDevice(const std::string& device_id, @@ -609,13 +629,9 @@ void PolicyHandler::OnAppPermissionConsentInternal( #endif } } else if (!app_to_device_link_.empty()) { - sync_primitives::AutoLock lock(app_to_device_link_lock_); - std::map::const_iterator it = - app_to_device_link_.begin(); - for (; app_to_device_link_.end() != it; ++it) { - ApplicationSharedPtr app = - application_manager_.application_by_policy_id(it->second); - + const ApplicationSet& accessor = + application_manager_.applications().GetData(); + for (const auto& app : accessor) { // If list of apps sent to HMI for user consents is not the same as // current, // permissions should be set only for coincident to registered apps @@ -626,19 +642,26 @@ void PolicyHandler::OnAppPermissionConsentInternal( continue; } + if (!app->IsRegistered()) { + LOG4CXX_DEBUG(logger_, + "Application " << app->policy_app_id() + << " is not marked as registered."); + continue; + } + DeviceParams device_params = GetDeviceParams( app->device(), application_manager_.connection_handler().get_session_observer()); - if (device_params.device_mac_address != it->first) { + if (device_params.device_mac_address != app->mac_address()) { LOG4CXX_WARN(logger_, "Device_id of application is changed." "Permissions setting skipped."); continue; } - out_permissions.policy_app_id = it->second; - out_permissions.device_id = it->first; + out_permissions.policy_app_id = app->policy_app_id(); + out_permissions.device_id = app->mac_address(); #ifdef EXTERNAL_PROPRIETARY_MODE policy_manager_->SetUserConsentForApp(out_permissions, mode); #else @@ -812,9 +835,9 @@ bool PolicyHandler::IsAppSuitableForPolicyUpdate( LOG4CXX_AUTO_TRACE(logger_); if (!value->IsRegistered()) { - LOG4CXX_DEBUG(logger_, - "Application " << value->app_id() - << " is not marked as registered."); + LOG4CXX_DEBUG( + logger_, + "Application " << value->app_id() << " is not marked as registered."); return false; } @@ -827,9 +850,9 @@ bool PolicyHandler::IsAppSuitableForPolicyUpdate( value->device(), application_manager_.connection_handler().get_session_observer()); - const bool is_device_allowed = (kDeviceAllowed == - policy_manager_->GetUserConsentForDevice( - device_params.device_mac_address)); + const bool is_device_allowed = + (kDeviceAllowed == policy_manager_->GetUserConsentForDevice( + device_params.device_mac_address)); LOG4CXX_DEBUG(logger_, "Is device " << device_params.device_mac_address << " allowed " @@ -862,6 +885,15 @@ void PolicyHandler::OnDeviceSwitching(const std::string& device_id_from, policy_manager_->OnDeviceSwitching(device_id_from, device_id_to); } +void PolicyHandler::OnLockScreenDismissalStateChanged() { + LOG4CXX_AUTO_TRACE(logger_); + const auto accessor = application_manager_.applications(); + const auto apps = accessor.GetData(); + for (auto& app : apps) { + application_manager_.SendDriverDistractionState(app); + } +} + void PolicyHandler::OnGetStatusUpdate(const uint32_t correlation_id) { LOG4CXX_AUTO_TRACE(logger_); POLICY_LIB_CHECK_VOID(); @@ -879,10 +911,15 @@ void PolicyHandler::OnUpdateStatusChanged(const std::string& status) { } std::string PolicyHandler::OnCurrentDeviceIdUpdateRequired( + const transport_manager::DeviceHandle& device_handle, const std::string& policy_app_id) { LOG4CXX_AUTO_TRACE(logger_); - ApplicationSharedPtr app = - application_manager_.application_by_policy_id(policy_app_id); + DeviceParams device_params = GetDeviceParams( + device_handle, + application_manager_.connection_handler().get_session_observer()); + + ApplicationSharedPtr app = application_manager_.application( + device_params.device_mac_address, policy_app_id); if (app.use_count() == 0) { LOG4CXX_WARN(logger_, @@ -890,11 +927,8 @@ std::string PolicyHandler::OnCurrentDeviceIdUpdateRequired( << policy_app_id << "' " "not found within registered applications."); - return ""; + return std::string(); } - DeviceParams device_params = GetDeviceParams( - app->device(), - application_manager_.connection_handler().get_session_observer()); return device_params.device_mac_address; } @@ -936,9 +970,9 @@ void PolicyHandler::OnVehicleDataUpdated( POLICY_LIB_CHECK_VOID(); #ifdef EXTERNAL_PROPRIETARY_MODE if (!message.keyExists(strings::msg_params)) { - LOG4CXX_ERROR(logger_, - "Message does not contains mandatory section " - << strings::msg_params); + LOG4CXX_ERROR( + logger_, + "Message does not contains mandatory section " << strings::msg_params); return; } if (message[strings::msg_params].keyExists(strings::vin)) { @@ -952,14 +986,14 @@ void PolicyHandler::OnVehicleDataUpdated( } void PolicyHandler::OnPendingPermissionChange( - const std::string& policy_app_id) { + const std::string& device_id, const std::string& policy_app_id) { LOG4CXX_AUTO_TRACE(logger_); - LOG4CXX_DEBUG(logger_, - "PolicyHandler::OnPendingPermissionChange for " - << policy_app_id); + LOG4CXX_DEBUG( + logger_, + "PolicyHandler::OnPendingPermissionChange for " << policy_app_id); POLICY_LIB_CHECK_VOID(); ApplicationSharedPtr app = - application_manager_.application_by_policy_id(policy_app_id); + application_manager_.application(device_id, policy_app_id); if (app.use_count() == 0) { LOG4CXX_WARN(logger_, "No app found for " << policy_app_id << " policy app id."); @@ -967,7 +1001,7 @@ void PolicyHandler::OnPendingPermissionChange( } AppPermissions permissions = - policy_manager_->GetAppPermissionsChanges(policy_app_id); + policy_manager_->GetAppPermissionsChanges(device_id, policy_app_id); const uint32_t app_id = app->app_id(); @@ -976,6 +1010,7 @@ void PolicyHandler::OnPendingPermissionChange( app_id, permissions, application_manager_); application_manager_.state_controller().SetRegularState( app, + mobile_apis::PredefinedWindows::DEFAULT_WINDOW, mobile_apis::HMILevel::HMI_NONE, mobile_apis::AudioStreamingState::NOT_AUDIBLE, mobile_apis::VideoStreamingState::NOT_STREAMABLE, @@ -984,7 +1019,8 @@ void PolicyHandler::OnPendingPermissionChange( return; } - mobile_apis::HMILevel::eType app_hmi_level = app->hmi_level(); + mobile_apis::HMILevel::eType app_hmi_level = + app->hmi_level(mobile_apis::PredefinedWindows::DEFAULT_WINDOW); switch (app_hmi_level) { case mobile_apis::HMILevel::eType::HMI_FULL: @@ -1051,14 +1087,17 @@ bool PolicyHandler::SendMessageToSDK(const BinaryMessage& pt_string, if (mobile_app_id.empty()) { LOG4CXX_WARN(logger_, "Application with connection key '" - << app_id << "'" - " has no application id."); + << app_id + << "'" + " has no application id."); return false; } LOG4CXX_DEBUG(logger_, - "Update url is " << url << " for application " - "with connection key " << app_id); + "Update url is " << url + << " for application " + "with connection key " + << app_id); MessageHelper::SendPolicySnapshotNotification( app_id, pt_string, url, application_manager_); @@ -1070,15 +1109,21 @@ bool PolicyHandler::ReceiveMessageFromSDK(const std::string& file, const BinaryMessage& pt_string) { POLICY_LIB_CHECK(false); - bool ret = policy_manager_->LoadPT(file, pt_string); - LOG4CXX_INFO(logger_, "Policy table is saved: " << std::boolalpha << ret); - if (ret) { + const auto load_pt_result = policy_manager_->LoadPT(file, pt_string); + + LOG4CXX_INFO(logger_, "Load policy table result code: " << load_pt_result); + + const bool is_ptu_successful = + load_pt_result == PolicyManager::PtProcessingResult::kSuccess; + OnPTUFinished(is_ptu_successful); + + if (is_ptu_successful) { LOG4CXX_INFO(logger_, "PTU was successful."); policy_manager_->CleanupUnpairedDevices(); - int32_t correlation_id = application_manager_.GetNextHMICorrelationID(); - SetDaysAfterEpoch(); + policy_manager_->OnPTUFinished(load_pt_result); + uint32_t correlation_id = application_manager_.GetNextHMICorrelationID(); event_observer_->subscribe_on_event( hmi_apis::FunctionID::VehicleInfo_GetVehicleData, correlation_id); std::vector vehicle_data_args; @@ -1087,9 +1132,10 @@ bool PolicyHandler::ReceiveMessageFromSDK(const std::string& file, correlation_id, vehicle_data_args, application_manager_); } else { LOG4CXX_WARN(logger_, "Exchange wasn't successful"); + policy_manager_->OnPTUFinished(load_pt_result); } - OnPTUFinished(ret); - return ret; + + return is_ptu_successful; } bool PolicyHandler::UnloadPolicyLibrary() { @@ -1101,10 +1147,6 @@ bool PolicyHandler::UnloadPolicyLibrary() { if (policy_manager_) { policy_manager_.reset(); } - if (dl_handle_) { - ret = (dlclose(dl_handle_) == 0); - dl_handle_ = 0; - } LOG4CXX_TRACE(logger_, "exit"); return ret; } @@ -1123,7 +1165,8 @@ struct SDLAlowedNotification { if (app->device() == device_id_) { std::string hmi_level; mobile_apis::HMILevel::eType default_mobile_hmi; - policy_manager_->GetDefaultHmi(app->policy_app_id(), &hmi_level); + policy_manager_->GetDefaultHmi( + app->mac_address(), app->policy_app_id(), &hmi_level); if ("BACKGROUND" == hmi_level) { default_mobile_hmi = mobile_apis::HMILevel::HMI_BACKGROUND; } else if ("FULL" == hmi_level) { @@ -1135,7 +1178,11 @@ struct SDLAlowedNotification { } else { return; } - state_controller_.SetRegularState(app, default_mobile_hmi, true); + state_controller_.SetRegularState( + app, + mobile_apis::PredefinedWindows::DEFAULT_WINDOW, + default_mobile_hmi, + true); } } @@ -1173,9 +1220,9 @@ void PolicyHandler::OnAllowSDLFunctionalityNotification( policy_manager_->SetUserConsentForDevice(device_id, is_allowed); connection_handler::DeviceHandle device_handle = 0; if (!connection_handler.GetDeviceID(device_id, &device_handle)) { - LOG4CXX_WARN(logger_, - "Device handle with mac " << device_id - << " wasn't found."); + LOG4CXX_WARN( + logger_, + "Device handle with mac " << device_id << " wasn't found."); } #ifdef EXTERNAL_PROPRIETARY_MODE @@ -1244,7 +1291,12 @@ void PolicyHandler::OnAllowSDLFunctionalityNotification( : VideoStreamingState::NOT_STREAMABLE; application_manager_.state_controller().SetRegularState( - app, mobile_apis::HMILevel::HMI_FULL, audio_state, video_state, true); + app, + mobile_apis::PredefinedWindows::DEFAULT_WINDOW, + mobile_apis::HMILevel::HMI_FULL, + audio_state, + video_state, + true); last_activated_app_id_ = 0; } else { DeactivateApplication deactivate_notification( @@ -1280,7 +1332,8 @@ void PolicyHandler::OnActivateApp(uint32_t connection_key, permissions.isSDLAllowed = true; } } else { - permissions = policy_manager_->GetAppPermissionsChanges(policy_app_id); + permissions = policy_manager_->GetAppPermissionsChanges(app->mac_address(), + policy_app_id); #ifdef EXTERNAL_PROPRIETARY_MODE UsageStatistics& usage = app->usage_report(); @@ -1351,31 +1404,33 @@ void PolicyHandler::PTExchangeAtUserRequest(uint32_t correlation_id) { update_status, correlation_id, application_manager_); } -void PolicyHandler::OnPermissionsUpdated(const std::string& policy_app_id, +void PolicyHandler::OnPermissionsUpdated(const std::string& device_id, + const std::string& policy_app_id, const Permissions& permissions, const HMILevel& default_hmi) { LOG4CXX_AUTO_TRACE(logger_); - OnPermissionsUpdated(policy_app_id, permissions); + OnPermissionsUpdated(device_id, policy_app_id, permissions); ApplicationSharedPtr app = - application_manager_.application_by_policy_id(policy_app_id); + application_manager_.application(device_id, policy_app_id); if (app.use_count() == 0) { LOG4CXX_WARN( logger_, - "Connection_key not found for application_id:" << policy_app_id); + "Connection_key not found for application_id: " << policy_app_id); return; } // The application currently not running (i.e. in NONE) should change HMI // level to default - mobile_apis::HMILevel::eType current_hmi_level = app->hmi_level(); + mobile_apis::HMILevel::eType current_hmi_level = + app->hmi_level(mobile_apis::PredefinedWindows::DEFAULT_WINDOW); mobile_apis::HMILevel::eType hmi_level = MessageHelper::StringToHMILevel(default_hmi); if (mobile_apis::HMILevel::INVALID_ENUM == hmi_level) { - LOG4CXX_WARN(logger_, - "Couldn't convert default hmi level " << default_hmi - << " to enum."); + LOG4CXX_WARN( + logger_, + "Couldn't convert default hmi level " << default_hmi << " to enum."); return; } if (current_hmi_level == hmi_level) { @@ -1391,10 +1446,16 @@ void PolicyHandler::OnPermissionsUpdated(const std::string& policy_app_id, if (hmi_level == mobile_apis::HMILevel::HMI_FULL) { application_manager_.state_controller().SetRegularState( - app, hmi_level, true); + app, + mobile_apis::PredefinedWindows::DEFAULT_WINDOW, + hmi_level, + true); } else { application_manager_.state_controller().SetRegularState( - app, hmi_level, false); + app, + mobile_apis::PredefinedWindows::DEFAULT_WINDOW, + hmi_level, + false); } break; } @@ -1407,26 +1468,35 @@ void PolicyHandler::OnPermissionsUpdated(const std::string& policy_app_id, } } -void PolicyHandler::OnPermissionsUpdated(const std::string& policy_app_id, +void PolicyHandler::OnPermissionsUpdated(const std::string& device_id, + const std::string& policy_app_id, const Permissions& permissions) { LOG4CXX_AUTO_TRACE(logger_); ApplicationSharedPtr app = - application_manager_.application_by_policy_id(policy_app_id); + application_manager_.application(device_id, policy_app_id); if (app.use_count() == 0) { LOG4CXX_WARN( logger_, - "Connection_key not found for application_id:" << policy_app_id); + "Connection_key not found for application_id: " << policy_app_id); return; } + const auto require_encryption = + policy_manager_->GetAppEncryptionRequired(policy_app_id); + MessageHelper::SendOnPermissionsChangeNotification( - app->app_id(), permissions, application_manager_); + app->app_id(), permissions, application_manager_, require_encryption); LOG4CXX_DEBUG(logger_, - "Notification sent for application_id:" + "Notification sent for application_id: " << policy_app_id << " and connection_key " << app->app_id()); } +#ifndef EXTERNAL_PROPRIETARY_MODE +void PolicyHandler::OnPTUTimeOut() { + application_manager_.protocol_handler().ProcessFailedPTU(); +} +#endif bool PolicyHandler::SaveSnapshot(const BinaryMessage& pt_string, std::string& snap_path) { @@ -1463,7 +1533,8 @@ void PolicyHandler::OnSnapshotCreated( } } #else // EXTERNAL_PROPRIETARY_MODE -void PolicyHandler::OnSnapshotCreated(const BinaryMessage& pt_string) { +void PolicyHandler::OnSnapshotCreated(const BinaryMessage& pt_string, + const PTUIterationType iteration_type) { LOG4CXX_AUTO_TRACE(logger_); POLICY_LIB_CHECK_VOID(); #ifdef PROPRIETARY_MODE @@ -1472,10 +1543,22 @@ void PolicyHandler::OnSnapshotCreated(const BinaryMessage& pt_string) { LOG4CXX_ERROR(logger_, "Snapshot processing skipped."); return; } - MessageHelper::SendPolicyUpdate(policy_snapshot_full_path, - TimeoutExchangeSec(), - policy_manager_->RetrySequenceDelaysSeconds(), - application_manager_); + + if (PTUIterationType::RetryIteration == iteration_type) { + uint32_t app_id_for_sending = GetAppIdForSending(); + + if (0 != app_id_for_sending) { + MessageHelper::SendPolicySnapshotNotification( + app_id_for_sending, pt_string, std::string(), application_manager_); + } + + } else { + MessageHelper::SendPolicyUpdate( + policy_snapshot_full_path, + TimeoutExchangeSec(), + policy_manager_->RetrySequenceDelaysSeconds(), + application_manager_); + } #else // PROPRIETARY_MODE LOG4CXX_ERROR(logger_, "HTTP policy"); EndpointUrls urls; @@ -1506,12 +1589,13 @@ bool PolicyHandler::GetPriority(const std::string& policy_app_id, void PolicyHandler::CheckPermissions( const application_manager::ApplicationSharedPtr app, + const application_manager::WindowID window_id, const PTString& rpc, const RPCParams& rpc_params, CheckPermissionResult& result) { POLICY_LIB_CHECK_VOID(); const std::string hmi_level = - MessageHelper::StringifiedHMILevel(app->hmi_level()); + MessageHelper::StringifiedHMILevel(app->hmi_level(window_id)); if (hmi_level.empty()) { LOG4CXX_WARN(logger_, "HMI level for " << app->policy_app_id() << " is invalid, rpc " @@ -1525,13 +1609,8 @@ void PolicyHandler::CheckPermissions( "Checking permissions for " << app->policy_app_id() << " in " << hmi_level << " on device " << device_id << " rpc " << rpc); -#ifdef EXTERNAL_PROPRIETARY_MODE - policy_manager_->CheckPermissions( - app->policy_app_id(), hmi_level, rpc, rpc_params, result); -#else // EXTERNAL_PROPRIETARY_MODE policy_manager_->CheckPermissions( device_id, app->policy_app_id(), hmi_level, rpc, rpc_params, result); -#endif // EXTERNAL_PROPRIETARY_MODE } uint32_t PolicyHandler::GetNotificationsNumber( @@ -1546,10 +1625,15 @@ DeviceConsent PolicyHandler::GetUserConsentForDevice( return policy_manager_->GetUserConsentForDevice(device_id); } -bool PolicyHandler::GetDefaultHmi(const std::string& policy_app_id, +Json::Value PolicyHandler::GetPolicyTableData() const { + return policy_manager_->GetPolicyTableData(); +} + +bool PolicyHandler::GetDefaultHmi(const std::string& device_id, + const std::string& policy_app_id, std::string* default_hmi) const { POLICY_LIB_CHECK(false); - return policy_manager_->GetDefaultHmi(policy_app_id, default_hmi); + return policy_manager_->GetDefaultHmi(device_id, policy_app_id, default_hmi); } bool PolicyHandler::GetInitialAppData(const std::string& application_id, @@ -1598,7 +1682,13 @@ uint32_t PolicyHandler::TimeoutExchangeMSec() const { } void PolicyHandler::OnExceededTimeout() { + LOG4CXX_AUTO_TRACE(logger_); POLICY_LIB_CHECK_VOID(); + + std::for_each(listeners_.begin(), + listeners_.end(), + std::mem_fn(&PolicyHandlerObserver::OnPTUTimeoutExceeded)); + policy_manager_->OnExceededTimeout(); } @@ -1607,6 +1697,19 @@ void PolicyHandler::OnSystemReady() { policy_manager_->OnSystemReady(); } +const boost::optional PolicyHandler::LockScreenDismissalEnabledState() + const { + POLICY_LIB_CHECK(boost::optional()); + return policy_manager_->LockScreenDismissalEnabledState(); +} + +const boost::optional +PolicyHandler::LockScreenDismissalWarningMessage( + const std::string& language) const { + POLICY_LIB_CHECK(boost::optional()); + return policy_manager_->LockScreenDismissalWarningMessage(language); +} + void PolicyHandler::PTUpdatedAt(Counters counter, int value) { POLICY_LIB_CHECK_VOID(); policy_manager_->PTUpdatedAt(counter, value); @@ -1673,7 +1776,7 @@ custom_str::CustomString PolicyHandler::GetAppName( if (app.use_count() == 0) { LOG4CXX_WARN( logger_, - "Connection_key not found for application_id:" << policy_app_id); + "Connection_key not found for application_id: " << policy_app_id); return custom_str::CustomString(""); } return app->name(); @@ -1703,9 +1806,9 @@ void PolicyHandler::OnCertificateUpdated(const std::string& certificate_data) { const bool is_written = file_system::Write( file_name, std::vector(certificate_data.begin(), certificate_data.end())); - LOG4CXX_DEBUG(logger_, - "Saving encrypted certificate data: \"" << certificate_data - << '"'); + LOG4CXX_DEBUG( + logger_, + "Saving encrypted certificate data: \"" << certificate_data << '"'); if (!is_written) { LOG4CXX_ERROR(logger_, "Unable to save encrypted certificate to file " << file_name); @@ -1743,6 +1846,7 @@ void PolicyHandler::OnCertificateDecrypted(bool is_succeeded) { if (!is_succeeded) { LOG4CXX_ERROR(logger_, "Couldn't delete file " << file_name); + ProcessCertDecryptFailed(); return; } @@ -1752,9 +1856,9 @@ void PolicyHandler::OnCertificateDecrypted(bool is_succeeded) { "Unable to read certificate from file " << file_name); return; } - LOG4CXX_DEBUG(logger_, - "Loaded decrypted certificate data: \"" << certificate_data - << '"'); + LOG4CXX_DEBUG( + logger_, + "Loaded decrypted certificate data: \"" << certificate_data << '"'); policy_manager_->SetDecryptedCertificate(certificate_data); @@ -1765,6 +1869,18 @@ void PolicyHandler::OnCertificateDecrypted(bool is_succeeded) { std::bind2nd(std::mem_fun(&PolicyHandlerObserver::OnCertificateUpdated), certificate_data)); } + +void PolicyHandler::ProcessCertDecryptFailed() { + LOG4CXX_AUTO_TRACE(logger_); + sync_primitives::AutoLock lock(listeners_lock_); + + std::for_each( + listeners_.begin(), + listeners_.end(), + std::bind2nd(std::mem_fn(&PolicyHandlerObserver::OnCertDecryptFinished), + false)); +} + #else // EXTERNAL_PROPRIETARY_MODE void PolicyHandler::OnCertificateUpdated(const std::string& certificate_data) { LOG4CXX_AUTO_TRACE(logger_); @@ -1910,24 +2026,24 @@ void PolicyHandler::OnSetCloudAppProperties( const smart_objects::SmartObject& message) { POLICY_LIB_CHECK_VOID(); if (!message.keyExists(strings::msg_params)) { - LOG4CXX_ERROR(logger_, - "Message does not contain mandatory section " - << strings::msg_params); + LOG4CXX_ERROR( + logger_, + "Message does not contain mandatory section " << strings::msg_params); return; } if (!message[strings::msg_params].keyExists(strings::properties)) { - LOG4CXX_ERROR(logger_, - "Message does not contain app properties " - << strings::msg_params); + LOG4CXX_ERROR( + logger_, + "Message does not contain app properties " << strings::msg_params); return; } const smart_objects::SmartObject& properties = message[strings::msg_params][strings::properties]; if (!properties.keyExists(strings::app_id)) { - LOG4CXX_ERROR(logger_, - "Message does not contain mandatory parameter " - << strings::app_id); + LOG4CXX_ERROR( + logger_, + "Message does not contain mandatory parameter " << strings::app_id); return; } std::string policy_app_id(properties[strings::app_id].asString()); @@ -2089,9 +2205,10 @@ void PolicyHandler::OnAppsSearchCompleted(const bool trigger_ptu) { policy_manager_->OnAppsSearchCompleted(trigger_ptu); } -void PolicyHandler::OnAppRegisteredOnMobile(const std::string& application_id) { +void PolicyHandler::OnAppRegisteredOnMobile(const std::string& device_id, + const std::string& application_id) { POLICY_LIB_CHECK_VOID(); - policy_manager_->OnAppRegisteredOnMobile(application_id); + policy_manager_->OnAppRegisteredOnMobile(device_id, application_id); } RequestType::State PolicyHandler::GetAppRequestTypeState( @@ -2107,12 +2224,13 @@ RequestSubType::State PolicyHandler::GetAppRequestSubTypeState( } bool PolicyHandler::IsRequestTypeAllowed( + const transport_manager::DeviceHandle& device_id, const std::string& policy_app_id, mobile_apis::RequestType::eType type) const { POLICY_LIB_CHECK(false); using namespace mobile_apis; - std::string stringified_type = RequestTypeToString(type); + const std::string stringified_type = RequestTypeToString(type); if (stringified_type.empty()) { LOG4CXX_ERROR(logger_, "Unknown request type."); return false; @@ -2135,7 +2253,11 @@ bool PolicyHandler::IsRequestTypeAllowed( case RequestType::State::AVAILABLE: { // If any of request types is available for current application - get them const auto request_types = +#ifdef EXTERNAL_PROPRIETARY_MODE + policy_manager_->GetAppRequestTypes(device_id, policy_app_id); +#else policy_manager_->GetAppRequestTypes(policy_app_id); +#endif return helpers::in_range(request_types, stringified_type); } default: @@ -2181,9 +2303,14 @@ bool PolicyHandler::IsRequestSubTypeAllowed( } const std::vector PolicyHandler::GetAppRequestTypes( + const transport_manager::DeviceHandle& device_handle, const std::string& policy_app_id) const { POLICY_LIB_CHECK(std::vector()); +#ifdef EXTERNAL_PROPRIETARY_MODE + return policy_manager_->GetAppRequestTypes(device_handle, policy_app_id); +#else return policy_manager_->GetAppRequestTypes(policy_app_id); +#endif } const std::vector PolicyHandler::GetAppRequestSubTypes( @@ -2192,9 +2319,15 @@ const std::vector PolicyHandler::GetAppRequestSubTypes( return policy_manager_->GetAppRequestSubTypes(policy_app_id); } -const VehicleInfo policy::PolicyHandler::GetVehicleInfo() const { - POLICY_LIB_CHECK(VehicleInfo()); - return policy_manager_->GetVehicleInfo(); +const std::vector +policy::PolicyHandler::GetVehicleDataItems() const { + POLICY_LIB_CHECK(std::vector()); + return policy_manager_->GetVehicleDataItems(); +} + +std::vector +policy::PolicyHandler::GetRemovedVehicleDataItems() const { + return policy_manager_->GetRemovedVehicleDataItems(); } #ifdef EXTERNAL_PROPRIETARY_MODE @@ -2236,15 +2369,31 @@ bool PolicyHandler::IsUrlAppIdValid(const uint32_t app_idx, const ApplicationSharedPtr app = application_manager_.application_by_policy_id(app_data.app_id); - const bool is_registered = (app && (app->IsRegistered())); - const bool is_default = (app_data.app_id == policy::kDefaultId); - const bool is_empty_urls = app_urls.empty(); + if (policy::kDefaultId == app_data.app_id) { + return true; + } + + if (app_urls.empty()) { + return false; + } - return ((is_registered && !is_empty_urls) || is_default); + const auto devices_ids = GetDevicesIds(app_data.app_id); + LOG4CXX_TRACE(logger_, + "Count devices: " << devices_ids.size() + << " for app_id: " << app_data.app_id); + for (const auto& device_id : devices_ids) { + ApplicationSharedPtr app = + application_manager_.application(device_id, app_data.app_id); + if (app && (app->IsRegistered())) { + return true; + } + } + + return false; } std::vector PolicyHandler::GetDevicesIds( - const std::string& policy_app_id) { + const std::string& policy_app_id) const { return application_manager_.devices(policy_app_id); } @@ -2252,7 +2401,8 @@ void PolicyHandler::UpdateHMILevel(ApplicationSharedPtr app, mobile_apis::HMILevel::eType level) { LOG4CXX_AUTO_TRACE(logger_); DCHECK_OR_RETURN_VOID(app); - if (app->hmi_level() == mobile_apis::HMILevel::HMI_NONE) { + if (app->hmi_level(mobile_apis::PredefinedWindows::DEFAULT_WINDOW) == + mobile_apis::HMILevel::HMI_NONE) { // If default is FULL, send request to HMI. Notification to mobile will be // sent on response receiving. if (mobile_apis::HMILevel::HMI_FULL == level) { @@ -2264,7 +2414,10 @@ void PolicyHandler::UpdateHMILevel(ApplicationSharedPtr app, // Set application hmi level application_manager_.ChangeAppsHMILevel(app->app_id(), level); // If hmi Level is full, it will be seted after ActivateApp response - MessageHelper::SendHMIStatusNotification(*app, application_manager_); + MessageHelper::SendHMIStatusNotification( + app, + mobile_apis::PredefinedWindows::DEFAULT_WINDOW, + application_manager_); } } } @@ -2288,17 +2441,17 @@ void PolicyHandler::OnUpdateHMIStatus(const std::string& device_id, ApplicationSharedPtr app = application_manager_.application(device_id, policy_app_id); if (!app) { - LOG4CXX_WARN(logger_, - "Could not find application: " << device_id << " - " - << policy_app_id); + LOG4CXX_WARN( + logger_, + "Could not find application: " << device_id << " - " << policy_app_id); return; } mobile_apis::HMILevel::eType level = MessageHelper::StringToHMILevel(hmi_level); if (mobile_apis::HMILevel::INVALID_ENUM == level) { - LOG4CXX_WARN(logger_, - "Couldn't convert default hmi level " << hmi_level - << " to enum."); + LOG4CXX_WARN( + logger_, + "Couldn't convert default hmi level " << hmi_level << " to enum."); return; } @@ -2307,7 +2460,10 @@ void PolicyHandler::OnUpdateHMIStatus(const std::string& device_id, << app->app_id() << " to default hmi level " << level); // Set application hmi level application_manager_.ChangeAppsHMILevel(app->app_id(), level); - MessageHelper::SendHMIStatusNotification(*app, application_manager_); + MessageHelper::SendHMIStatusNotification( + app, + mobile_apis::PredefinedWindows::DEFAULT_WINDOW, + application_manager_); } bool PolicyHandler::GetModuleTypes(const std::string& policy_app_id, @@ -2318,6 +2474,7 @@ bool PolicyHandler::GetModuleTypes(const std::string& policy_app_id, } void PolicyHandler::SetDefaultHmiTypes( + const transport_manager::DeviceHandle& device_handle, const std::string& application_id, const smart_objects::SmartObject* app_types) { LOG4CXX_AUTO_TRACE(logger_); @@ -2330,7 +2487,7 @@ void PolicyHandler::SetDefaultHmiTypes( std::back_inserter(hmi_types), SmartObjectToInt()); } - policy_manager_->SetDefaultHmiTypes(application_id, hmi_types); + policy_manager_->SetDefaultHmiTypes(device_handle, application_id, hmi_types); } bool PolicyHandler::CheckHMIType(const std::string& application_id, @@ -2361,17 +2518,17 @@ void PolicyHandler::OnUpdateHMILevel(const std::string& device_id, ApplicationSharedPtr app = application_manager_.application(device_id, policy_app_id); if (!app) { - LOG4CXX_WARN(logger_, - "Could not find application: " << device_id << " - " - << policy_app_id); + LOG4CXX_WARN( + logger_, + "Could not find application: " << device_id << " - " << policy_app_id); return; } mobile_apis::HMILevel::eType level = MessageHelper::StringToHMILevel(hmi_level); if (mobile_apis::HMILevel::INVALID_ENUM == level) { - LOG4CXX_WARN(logger_, - "Couldn't convert default hmi level " << hmi_level - << " to enum."); + LOG4CXX_WARN( + logger_, + "Couldn't convert default hmi level " << hmi_level << " to enum."); return; } UpdateHMILevel(app, level); diff --git a/src/components/application_manager/src/request_controller.cc b/src/components/application_manager/src/request_controller.cc index 315cf6fdf81..eaebaf48614 100644 --- a/src/components/application_manager/src/request_controller.cc +++ b/src/components/application_manager/src/request_controller.cc @@ -32,9 +32,9 @@ #include "utils/logger.h" -#include "application_manager/request_controller.h" #include "application_manager/commands/command_request_impl.h" #include "application_manager/commands/request_to_hmi.h" +#include "application_manager/request_controller.h" #include "utils/timer_task_impl.h" @@ -126,6 +126,12 @@ RequestController::TResult RequestController::CheckPosibilitytoAdd( return RequestController::TOO_MANY_REQUESTS; } + if (IsLowVoltage()) { + LOG4CXX_ERROR(logger_, + "Impossible to add request due to Low Voltage is active"); + return RequestController::INVALID_DATA; + } + return SUCCESS; } @@ -192,6 +198,13 @@ RequestController::TResult RequestController::addHMIRequest( "Default timeout was set to 0." "RequestController will not track timeout of this request."); } + + if (IsLowVoltage()) { + LOG4CXX_ERROR(logger_, + "Impossible to add request due to Low Voltage is active"); + return RequestController::INVALID_DATA; + } + waiting_for_response_.Add(request_info_ptr); LOG4CXX_DEBUG(logger_, "Waiting for response count:" << waiting_for_response_.Size()); @@ -202,6 +215,11 @@ RequestController::TResult RequestController::addHMIRequest( void RequestController::addNotification(const RequestPtr ptr) { LOG4CXX_AUTO_TRACE(logger_); + if (IsLowVoltage()) { + LOG4CXX_ERROR( + logger_, "Impossible to add notification due to Low Voltage is active"); + return; + } notification_list_.push_back(ptr); } @@ -274,7 +292,7 @@ void RequestController::OnMobileResponse(const uint32_t mobile_correlation_id, void RequestController::OnHMIResponse(const uint32_t correlation_id, const int32_t function_id) { LOG4CXX_AUTO_TRACE(logger_); - TerminateRequest(correlation_id, RequestInfo::HmiConnectoinKey, function_id); + TerminateRequest(correlation_id, RequestInfo::HmiConnectionKey, function_id); } void RequestController::terminateWaitingForExecutionAppRequests( @@ -321,7 +339,7 @@ void RequestController::terminateAppRequests(const uint32_t& app_id) { void RequestController::terminateAllHMIRequests() { LOG4CXX_AUTO_TRACE(logger_); - terminateWaitingForResponseAppRequests(RequestInfo::HmiConnectoinKey); + terminateWaitingForResponseAppRequests(RequestInfo::HmiConnectionKey); } void RequestController::terminateAllMobileRequests() { @@ -430,7 +448,7 @@ void RequestController::TimeoutThread() { const uint32_t experied_app_id = probably_expired->app_id(); probably_expired->request()->onTimeOut(); - if (RequestInfo::HmiConnectoinKey == probably_expired->app_id()) { + if (RequestInfo::HmiConnectionKey == probably_expired->app_id()) { LOG4CXX_DEBUG(logger_, "Erase HMI request: " << probably_expired->requestId()); waiting_for_response_.RemoveRequest(probably_expired); diff --git a/src/components/application_manager/src/request_info.cc b/src/components/application_manager/src/request_info.cc index bbcda06b438..4f1e0a8f072 100644 --- a/src/components/application_manager/src/request_info.cc +++ b/src/components/application_manager/src/request_info.cc @@ -42,12 +42,12 @@ namespace request_controller { CREATE_LOGGERPTR_GLOBAL(logger_, "RequestController") -uint32_t RequestInfo::HmiConnectoinKey = 0; +uint32_t RequestInfo::HmiConnectionKey = 0; HMIRequestInfo::HMIRequestInfo(RequestPtr request, const uint64_t timeout_msec) : RequestInfo(request, HMIRequest, timeout_msec) { correlation_id_ = request_->correlation_id(); - app_id_ = RequestInfo::HmiConnectoinKey; + app_id_ = RequestInfo::HmiConnectionKey; } HMIRequestInfo::HMIRequestInfo(RequestPtr request, @@ -55,7 +55,7 @@ HMIRequestInfo::HMIRequestInfo(RequestPtr request, const uint64_t timeout_msec) : RequestInfo(request, HMIRequest, start_time, timeout_msec) { correlation_id_ = request_->correlation_id(); - app_id_ = RequestInfo::HmiConnectoinKey; + app_id_ = RequestInfo::HmiConnectionKey; } MobileRequestInfo::MobileRequestInfo(RequestPtr request, @@ -252,7 +252,7 @@ uint32_t RequestInfoSet::RemoveByConnectionKey(uint32_t connection_key) { uint32_t RequestInfoSet::RemoveMobileRequests() { LOG4CXX_AUTO_TRACE(logger_); return RemoveRequests(AppIdCompararator(AppIdCompararator::NotEqual, - RequestInfo::HmiConnectoinKey)); + RequestInfo::HmiConnectionKey)); } const size_t RequestInfoSet::Size() { diff --git a/src/components/application_manager/src/request_tracker.cc b/src/components/application_manager/src/request_tracker.cc index c047c825796..052667dc3ff 100644 --- a/src/components/application_manager/src/request_tracker.cc +++ b/src/components/application_manager/src/request_tracker.cc @@ -30,10 +30,10 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include "utils/logger.h" -#include "utils/macro.h" #include "application_manager/request_tracker.h" #include "application_manager/message_helper.h" +#include "utils/logger.h" +#include "utils/macro.h" namespace application_manager { 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 6af8826491d..0e1840e8678 100644 --- a/src/components/application_manager/src/resumption/resume_ctrl_impl.cc +++ b/src/components/application_manager/src/resumption/resume_ctrl_impl.cc @@ -30,24 +30,25 @@ POSSIBILITY OF SUCH DAMAGE. */ #include "application_manager/resumption/resume_ctrl_impl.h" +#include "application_manager/display_capabilities_builder.h" -#include #include +#include #include "application_manager/application_manager.h" #include "application_manager/rpc_service.h" -#include "utils/file_system.h" -#include "connection_handler/connection_handler_impl.h" -#include "application_manager/message_helper.h" -#include "connection_handler/connection.h" #include "application_manager/commands/command_impl.h" -#include "policy/policy_manager_impl.h" +#include "application_manager/message_helper.h" #include "application_manager/policies/policy_handler.h" -#include "application_manager/state_controller.h" -#include "utils/helpers.h" #include "application_manager/resumption/resumption_data_db.h" #include "application_manager/resumption/resumption_data_json.h" +#include "application_manager/state_controller.h" +#include "connection_handler/connection.h" +#include "connection_handler/connection_handler_impl.h" +#include "policy/policy_manager_impl.h" +#include "utils/file_system.h" +#include "utils/helpers.h" #include "utils/timer_task_impl.h" @@ -152,14 +153,20 @@ void ResumeCtrlImpl::SaveApplication(ApplicationSharedPtr application) { LOG4CXX_DEBUG(logger_, "Low Voltage state is active"); return; } - LOG4CXX_DEBUG(logger_, - "application with appID " << application->app_id() - << " will be saved"); + LOG4CXX_DEBUG( + logger_, + "application with appID " << application->app_id() << " will be saved"); resumption_storage_->SaveApplication(application); } void ResumeCtrlImpl::on_event(const event_engine::Event& event) { - LOG4CXX_DEBUG(logger_, "Event received" << event.id()); + LOG4CXX_DEBUG(logger_, "Event received: " << event.id()); + + if (hmi_apis::FunctionID::UI_CreateWindow == event.id()) { + LOG4CXX_INFO(logger_, "Received UI_CreateWindow event"); + const auto& response_message = event.smart_object(); + RestoreWidgetsHMIState(response_message); + } } bool ResumeCtrlImpl::RestoreAppHMIState(ApplicationSharedPtr application) { @@ -208,7 +215,12 @@ bool ResumeCtrlImpl::RestoreAppHMIState(ApplicationSharedPtr application) { << saved_hmi_level); } - return SetAppHMIState(application, saved_hmi_level, true); + const bool app_hmi_state_is_set = + SetAppHMIState(application, saved_hmi_level, true); + if (app_hmi_state_is_set && + application->is_app_data_resumption_allowed()) { + RestoreAppWidgets(application, saved_app); + } } else { result = false; LOG4CXX_ERROR(logger_, "saved app data corrupted"); @@ -219,6 +231,89 @@ bool ResumeCtrlImpl::RestoreAppHMIState(ApplicationSharedPtr application) { return result; } +void ResumeCtrlImpl::RestoreWidgetsHMIState( + const smart_objects::SmartObject& response_message) { + LOG4CXX_AUTO_TRACE(logger_); + const auto correlation_id = + response_message[strings::params][strings::correlation_id].asInt(); + const auto& request = requests_msg_.find(correlation_id); + if (requests_msg_.end() == request) { + LOG4CXX_ERROR(logger_, + "Request UI_CreateWindow for correlation id: " + << correlation_id << " not found"); + return; + } + + const auto& msg_params = (*request->second)[strings::msg_params]; + const auto hmi_app_id = msg_params[strings::app_id].asInt(); + auto application = application_manager_.application_by_hmi_app(hmi_app_id); + if (!application) { + LOG4CXX_ERROR(logger_, + "Application is not registered by hmi id: " << hmi_app_id); + requests_msg_.erase(request); + return; + } + const WindowID window_id = msg_params[strings::window_id].asInt(); + + const auto result_code = static_cast( + response_message[strings::params][hmi_response::code].asInt()); + if (hmi_apis::Common_Result::SUCCESS != result_code) { + LOG4CXX_ERROR(logger_, + "UI_CreateWindow for correlation id: " + << correlation_id + << " failed with code: " << result_code); + requests_msg_.erase(request); + auto& builder = application->display_capabilities_builder(); + builder.StopWaitingForWindow(window_id); + return; + } + + smart_objects::SmartObject window_info(smart_objects::SmartType_Map); + auto fill_optional_param = [&window_info, + &msg_params](const std::string& key) { + if (msg_params.keyExists(key)) { + window_info[key] = msg_params[key].asString(); + } + }; + fill_optional_param(strings::associated_service_type); + fill_optional_param(strings::duplicate_updates_from_window_id); + + const auto window_name = msg_params[strings::window_name].asString(); + window_info[strings::window_name] = window_name; + application->SetWindowInfo(window_id, window_info); + + const auto window_type = static_cast( + msg_params[strings::window_type].asInt()); + // State should be initialized with INVALID_ENUM value to let state controller + // trigger OnHmiStatus notifiation sending + auto initial_state = application_manager_.CreateRegularState( + application, + window_type, + mobile_apis::HMILevel::INVALID_ENUM, + mobile_apis::AudioStreamingState::INVALID_ENUM, + mobile_apis::VideoStreamingState::INVALID_ENUM, + mobile_api::SystemContext::INVALID_ENUM); + application->SetInitialState(window_id, window_name, initial_state); + + // Default HMI level for all windows except the main one is always NONE + application_manager_.state_controller().OnAppWindowAdded( + application, window_id, window_type, mobile_apis::HMILevel::HMI_NONE); + + requests_msg_.erase(request); +} + +void ResumeCtrlImpl::ProcessSystemCapabilityUpdated( + Application& app, const smart_objects::SmartObject& display_capabilities) { + LOG4CXX_AUTO_TRACE(logger_); + + auto notification = MessageHelper::CreateDisplayCapabilityUpdateToMobile( + display_capabilities, app); + + application_manager_.GetRPCService().ManageMobileCommand( + notification, commands::Command::SOURCE_SDL); + app.set_is_resuming(false); +} + bool ResumeCtrlImpl::SetupDefaultHMILevel(ApplicationSharedPtr application) { LOG4CXX_AUTO_TRACE(logger_); DCHECK_OR_RETURN(application, false); @@ -252,7 +347,9 @@ void ResumeCtrlImpl::ApplicationResumptiOnTimer() { LOG4CXX_ERROR(logger_, "Invalid app_id = " << *it); continue; } - StartAppHmiStateResumption(app); + if (!StartAppHmiStateResumption(app)) { + app->set_is_resuming(false); + } } is_resumption_active_ = false; waiting_for_timer_.clear(); @@ -262,6 +359,7 @@ void ResumeCtrlImpl::ApplicationResumptiOnTimer() { void ResumeCtrlImpl::OnAppActivated(ApplicationSharedPtr application) { if (is_resumption_active_) { RemoveFromResumption(application->app_id()); + application->set_is_resuming(false); } } @@ -291,15 +389,38 @@ bool ResumeCtrlImpl::SetAppHMIState( SetupDefaultHMILevel(application); return false; } - application->set_is_resuming(true); - application_manager_.state_controller().SetRegularState(application, - hmi_level); + + application_manager_.state_controller().SetRegularState( + application, mobile_apis::PredefinedWindows::DEFAULT_WINDOW, hmi_level); LOG4CXX_INFO(logger_, "Application with policy id " << application->policy_app_id() << " got HMI level " << hmi_level); + return true; } +void ResumeCtrlImpl::RestoreAppWidgets( + application_manager::ApplicationSharedPtr application, + const smart_objects::SmartObject& saved_app) { + using namespace mobile_apis; + LOG4CXX_AUTO_TRACE(logger_); + DCHECK(application); + if (!saved_app.keyExists(strings::windows_info)) { + LOG4CXX_ERROR(logger_, "windows_info section does not exist"); + return; + } + const auto& windows_info = saved_app[strings::windows_info]; + auto request_list = MessageHelper::CreateUICreateWindowRequestsToHMI( + application, application_manager_, windows_info); + + requests_msg_.clear(); + for (auto& request : request_list) { + requests_msg_.insert(std::make_pair( + (*request)[strings::params][strings::correlation_id].asInt(), request)); + } + ProcessHMIRequests(request_list); +} + bool ResumeCtrlImpl::IsHMIApplicationIdExist(uint32_t hmi_app_id) { LOG4CXX_DEBUG(logger_, "hmi_app_id :" << hmi_app_id); return resumption_storage_->IsHMIApplicationIdExist(hmi_app_id); @@ -399,6 +520,8 @@ bool ResumeCtrlImpl::StartResumption(ApplicationSharedPtr application, << " hmi_app_id = " << application->hmi_app_id() << " policy_id = " << application->policy_app_id() << " received hash = " << hash); + application->set_is_resuming(true); + if (!application->is_cloud_app()) { // Default HMI Level is already set before resumption in // ApplicationManager::OnApplicationRegistered, and handling low bandwidth @@ -421,17 +544,18 @@ bool ResumeCtrlImpl::StartResumption(ApplicationSharedPtr application, bool ResumeCtrlImpl::StartResumptionOnlyHMILevel( ApplicationSharedPtr application) { - // sync_primitives::AutoLock lock(resumtion_lock_); LOG4CXX_AUTO_TRACE(logger_); if (!application) { LOG4CXX_WARN(logger_, "Application does not exist."); return false; } + + application->set_is_resuming(true); LOG4CXX_DEBUG(logger_, - "HMI level resumption requested for application id " - << application->app_id() << "with hmi_app_id " - << application->hmi_app_id() << ", policy_app_id " - << application->policy_app_id()); + "HMI level resumption requested for application id: " + << application->app_id() + << " with hmi_app_id: " << application->hmi_app_id() + << ", policy_app_id " << application->policy_app_id()); if (!application->is_cloud_app()) { // Default HMI Level is already set before resumption in // ApplicationManager::OnApplicationRegistered, and handling low bandwidth @@ -444,7 +568,6 @@ bool ResumeCtrlImpl::StartResumptionOnlyHMILevel( bool result = resumption_storage_->GetSavedApplication( application->policy_app_id(), device_mac, saved_app); if (result) { - // sync_primitives::AutoUnlock unlock(lock); AddToResumptionTimerQueue(application->app_id()); } LOG4CXX_INFO(logger_, "StartResumptionOnlyHMILevel::Result = " << result); @@ -473,18 +596,18 @@ void ResumeCtrlImpl::RetryResumption(const uint32_t app_id) { AddToResumptionTimerQueue(app_id); } -void ResumeCtrlImpl::StartAppHmiStateResumption( +bool ResumeCtrlImpl::StartAppHmiStateResumption( ApplicationSharedPtr application) { using namespace date_time; LOG4CXX_AUTO_TRACE(logger_); - DCHECK_OR_RETURN_VOID(application); + DCHECK_OR_RETURN(application, false); smart_objects::SmartObject saved_app; const std::string& device_mac = application->mac_address(); - const bool result = resumption_storage_->GetSavedApplication( + const bool get_saved_app_result = resumption_storage_->GetSavedApplication( application->policy_app_id(), device_mac, saved_app); - if (!result) { + if (!get_saved_app_result) { LOG4CXX_ERROR(logger_, "Application was not saved"); - return; + return false; } const bool is_hmi_level_applicable_to_resume = @@ -492,7 +615,7 @@ void ResumeCtrlImpl::StartAppHmiStateResumption( if (!is_hmi_level_applicable_to_resume) { LOG4CXX_DEBUG(logger_, "No applicable HMI level found for resuming"); - return; + return false; } const bool is_resume_allowed_by_low_voltage = @@ -507,18 +630,20 @@ void ResumeCtrlImpl::StartAppHmiStateResumption( if (restore_hmi_level_allowed) { LOG4CXX_INFO(logger_, "Resume application " << application->policy_app_id()); - RestoreAppHMIState(application); + const bool hmi_state_restore_result = RestoreAppHMIState(application); if (mobile_apis::HMILevel::eType::INVALID_ENUM != application->deferred_resumption_hmi_level()) { // the application has not been fully resumed - return; + return false; } RemoveApplicationFromSaved(application); + return hmi_state_restore_result; } else { - LOG4CXX_INFO(logger_, - "Do not need to resume application " - << application->policy_app_id()); + LOG4CXX_INFO( + logger_, + "Do not need to resume application " << application->policy_app_id()); } + return true; } void ResumeCtrlImpl::ResetLaunchTime() { @@ -561,9 +686,14 @@ bool ResumeCtrlImpl::CheckApplicationHash(ApplicationSharedPtr application, "app_id : " << application->app_id() << " hash : " << hash); smart_objects::SmartObject saved_app; const std::string& device_mac = application->mac_address(); - bool result = resumption_storage_->GetSavedApplication( + const bool get_app_result = resumption_storage_->GetSavedApplication( application->policy_app_id(), device_mac, saved_app); - return result ? saved_app[strings::hash_id].asString() == hash : false; + const bool check_result = + get_app_result ? saved_app[strings::hash_id].asString() == hash : false; + if (check_result) { + application->set_app_data_resumption_allowance(true); + } + return check_result; } void ResumeCtrlImpl::SaveDataOnTimer() { @@ -628,6 +758,27 @@ bool ResumeCtrlImpl::RestoreApplicationData(ApplicationSharedPtr application) { return result; } +void ResumeCtrlImpl::StartWaitingForDisplayCapabilitiesUpdate( + app_mngr::ApplicationSharedPtr application) { + LOG4CXX_AUTO_TRACE(logger_); + smart_objects::SmartObject saved_app(smart_objects::SmartType_Map); + resumption_storage_->GetSavedApplication( + application->policy_app_id(), application->mac_address(), saved_app); + auto resume_callback = + [this](Application& app, + const smart_objects::SmartObject& display_capabilities) -> void { + LOG4CXX_AUTO_TRACE(logger_); + ProcessSystemCapabilityUpdated(app, display_capabilities); + }; + auto& builder = application->display_capabilities_builder(); + + smart_objects::SmartObject windows_info(smart_objects::SmartType_Null); + if (saved_app.keyExists(strings::windows_info)) { + windows_info = saved_app[strings::windows_info]; + } + builder.InitBuilder(resume_callback, windows_info); +} + void ResumeCtrlImpl::AddFiles(ApplicationSharedPtr application, const smart_objects::SmartObject& saved_app) { LOG4CXX_AUTO_TRACE(logger_); @@ -1006,7 +1157,8 @@ bool ResumeCtrlImpl::ProcessHMIRequest(smart_objects::SmartObjectSPtr request, (*request)[strings::correlation_id].asInt(); subscribe_on_event(function_id, hmi_correlation_id); } - if (!application_manager_.GetRPCService().ManageHMICommand(request)) { + if (!application_manager_.GetRPCService().ManageHMICommand( + request, commands::Command::SOURCE_SDL_TO_HMI)) { LOG4CXX_ERROR(logger_, "Unable to send request"); return false; } @@ -1035,8 +1187,9 @@ void ResumeCtrlImpl::AddToResumptionTimerQueue(const uint32_t app_id) { } queue_lock_.Release(); LOG4CXX_DEBUG(logger_, - "Application ID " << app_id << " have been added" - " to resumption queue."); + "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"); @@ -1197,4 +1350,4 @@ static mobile_api::HMILevel::eType ConvertHmiLevelString( } } -} // namespce resumption +} // namespace resumption diff --git a/src/components/application_manager/src/resumption/resumption_data.cc b/src/components/application_manager/src/resumption/resumption_data.cc index 856fb03750f..9046fe35adb 100644 --- a/src/components/application_manager/src/resumption/resumption_data.cc +++ b/src/components/application_manager/src/resumption/resumption_data.cc @@ -31,9 +31,9 @@ */ #include "application_manager/resumption/resumption_data.h" -#include "utils/logger.h" -#include "application_manager/smart_object_keys.h" #include "application_manager/application_manager_settings.h" +#include "application_manager/smart_object_keys.h" +#include "utils/logger.h" namespace resumption { @@ -198,6 +198,52 @@ smart_objects::SmartObject ResumptionData::GetApplicationFiles( return files; } +smart_objects::SmartObject ResumptionData::GetApplicationWidgetsInfo( + app_mngr::ApplicationConstSharedPtr application) const { + using namespace app_mngr; + LOG4CXX_AUTO_TRACE(logger_); + smart_objects::SmartObject windows_info = + smart_objects::SmartObject(smart_objects::SmartType_Array); + DCHECK_OR_RETURN(application, windows_info); + const auto window_ids = application->GetWindowIds(); + const auto& window_optional_params_map = + application->window_optional_params_map().GetData(); + for (const auto& window_id : window_ids) { + const HmiStatePtr hmi_state = application->CurrentHmiState(window_id); + if (mobile_apis::WindowType::WIDGET != hmi_state->window_type()) { + continue; + } + auto info = CreateWindowInfoSO( + window_id, hmi_state->window_type(), window_optional_params_map); + + windows_info[windows_info.length()] = info; + } + return windows_info; +} + +smart_objects::SmartObject ResumptionData::CreateWindowInfoSO( + const app_mngr::WindowID window_id, + const mobile_apis::WindowType::eType window_type, + const app_mngr::WindowParamsMap& window_optional_params_map) const { + using namespace app_mngr; + LOG4CXX_AUTO_TRACE(logger_); + auto window_info = smart_objects::SmartObject(smart_objects::SmartType_Map); + + window_info[strings::window_id] = window_id; + window_info[strings::window_type] = window_type; + + const auto& it_info = window_optional_params_map.find(window_id); + if (window_optional_params_map.end() != it_info) { + const auto keys = it_info->second->enumerate(); + + for (const auto& key : keys) { + window_info[key] = (*it_info->second)[key]; + } + } + + return window_info; +} + smart_objects::SmartObject ResumptionData::PointerToSmartObj( const smart_objects::SmartObject* ptr) const { LOG4CXX_AUTO_TRACE(logger_); 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 1591ce566ab..9188a47bf9b 100644 --- a/src/components/application_manager/src/resumption/resumption_data_db.cc +++ b/src/components/application_manager/src/resumption/resumption_data_db.cc @@ -29,18 +29,18 @@ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ -#include #include +#include #include "application_manager/application_manager_impl.h" +#include "application_manager/application_manager_settings.h" +#include "application_manager/message_helper.h" #include "application_manager/resumption/resumption_data_db.h" #include "application_manager/resumption/resumption_sql_queries.h" #include "application_manager/smart_object_keys.h" -#include "application_manager/message_helper.h" -#include "utils/helpers.h" #include "utils/gen_hash.h" +#include "utils/helpers.h" #include "utils/scope_guard.h" -#include "application_manager/application_manager_settings.h" namespace { const std::string kDatabaseName = "resumption"; @@ -2731,7 +2731,8 @@ bool ResumptionDataDB::UpdateApplicationData( utils::dbms::SQLQuery query(db()); const int64_t time_stamp = static_cast(time(NULL)); - const mobile_apis::HMILevel::eType hmi_level = application->hmi_level(); + const mobile_apis::HMILevel::eType hmi_level = + application->hmi_level(mobile_apis::PredefinedWindows::DEFAULT_WINDOW); if (!query.Prepare(kUpdateApplicationData)) { LOG4CXX_WARN(logger_, @@ -2843,7 +2844,8 @@ ApplicationParams::ApplicationParams(app_mngr::ApplicationSharedPtr application) m_grammar_id = application->get_grammar_id(); m_connection_key = application->app_id(); m_hmi_app_id = application->hmi_app_id(); - m_hmi_level = application->hmi_level(); + m_hmi_level = + application->hmi_level(mobile_apis::PredefinedWindows::DEFAULT_WINDOW); m_is_media_application = application->IsAudioApplication(); app_ptr = application; } 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 584fb4e6976..5da47d31cef 100644 --- a/src/components/application_manager/src/resumption/resumption_data_json.cc +++ b/src/components/application_manager/src/resumption/resumption_data_json.cc @@ -30,14 +30,14 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include "application_manager/application_manager.h" #include "application_manager/resumption/resumption_data_json.h" -#include "smart_objects/smart_object.h" -#include "json/json.h" -#include "formatters/CFormatterJsonBase.h" +#include "application_manager/application_manager.h" +#include "application_manager/application_manager_settings.h" #include "application_manager/message_helper.h" #include "application_manager/smart_object_keys.h" -#include "application_manager/application_manager_settings.h" +#include "formatters/CFormatterJsonBase.h" +#include "json/json.h" +#include "smart_objects/smart_object.h" namespace resumption { @@ -64,7 +64,8 @@ void ResumptionDataJson::SaveApplication( const uint32_t grammar_id = application->get_grammar_id(); const uint32_t time_stamp = (uint32_t)time(NULL); const std::string device_mac = application->mac_address(); - const mobile_apis::HMILevel::eType hmi_level = application->hmi_level(); + const mobile_apis::HMILevel::eType hmi_level = + application->hmi_level(mobile_apis::PredefinedWindows::DEFAULT_WINDOW); const bool is_subscribed_for_way_points = application_manager_.IsAppSubscribedForWayPoints(application); @@ -99,6 +100,9 @@ void ResumptionDataJson::SaveApplication( formatters::CFormatterJsonBase::objToJsonValue( GetApplicationFiles(application), tmp); json_app[strings::application_files] = tmp; + formatters::CFormatterJsonBase::objToJsonValue( + GetApplicationWidgetsInfo(application), tmp); + json_app[strings::windows_info] = tmp; json_app[strings::time_stamp] = time_stamp; json_app[strings::subscribed_for_way_points] = is_subscribed_for_way_points; @@ -531,4 +535,4 @@ void ResumptionDataJson::Persist() { last_state().SaveStateToFileSystem(); } -} // resumption +} // namespace resumption diff --git a/src/components/application_manager/src/rpc_handler_impl.cc b/src/components/application_manager/src/rpc_handler_impl.cc index 28b3779dade..695d94628d3 100644 --- a/src/components/application_manager/src/rpc_handler_impl.cc +++ b/src/components/application_manager/src/rpc_handler_impl.cc @@ -43,12 +43,14 @@ namespace formatters = ns_smart_device_link::ns_json_handler::formatters; namespace jhs = ns_smart_device_link::ns_json_handler::strings; namespace plugin_names = application_manager::plugin_manager::plugin_names; -RPCHandlerImpl::RPCHandlerImpl(ApplicationManager& app_manager) +RPCHandlerImpl::RPCHandlerImpl(ApplicationManager& app_manager, + hmi_apis::HMI_API& hmi_so_factory, + mobile_apis::MOBILE_API& mobile_so_factory) : app_manager_(app_manager) , messages_from_mobile_("AM FromMobile", this) , messages_from_hmi_("AM FromHMI", this) - , hmi_so_factory_(hmi_apis::HMI_API()) - , mobile_so_factory_(mobile_apis::MOBILE_API()) + , hmi_so_factory_(hmi_so_factory) + , mobile_so_factory_(mobile_so_factory) #ifdef TELEMETRY_MONITOR , metric_observer_(NULL) #endif // TELEMETRY_MONITOR @@ -159,23 +161,19 @@ void RPCHandlerImpl::ProcessMessageFromHMI( smart_objects::SmartObjectSPtr smart_object = std::make_shared(); bool allow_unknown_parameters = false; - if (!smart_object) { - LOG4CXX_ERROR(logger_, "Null pointer"); - return; - } smart_objects::SmartObject converted_result; formatters::FormatterJsonRpc::FromString( message->json_message(), converted_result); + const auto function_id = static_cast( + converted_result[jhs::S_PARAMS][jhs::S_FUNCTION_ID].asInt()); if (app_manager_.GetRPCService().IsAppServiceRPC( - converted_result[jhs::S_PARAMS][jhs::S_FUNCTION_ID].asInt(), - commands::Command::SOURCE_HMI)) { + function_id, commands::Command::SOURCE_HMI)) { LOG4CXX_DEBUG( logger_, - "Allowing unknown parameters for request function " - << converted_result[jhs::S_PARAMS][jhs::S_FUNCTION_ID].asInt()); + "Allowing unknown parameters for request function " << function_id); allow_unknown_parameters = true; } @@ -198,6 +196,7 @@ void RPCHandlerImpl::ProcessMessageFromHMI( LOG4CXX_ERROR(logger_, "Received command didn't run successfully"); } } + void RPCHandlerImpl::Handle(const impl::MessageFromMobile message) { LOG4CXX_AUTO_TRACE(logger_); @@ -209,6 +208,10 @@ void RPCHandlerImpl::Handle(const impl::MessageFromMobile message) { LOG4CXX_INFO(logger_, "Application manager is stopping"); return; } + if (app_manager_.IsLowVoltage()) { + LOG4CXX_ERROR(logger_, "Low Voltage is active."); + return; + } ProcessMessageFromMobile(message); } @@ -220,6 +223,11 @@ void RPCHandlerImpl::Handle(const impl::MessageFromHmi message) { LOG4CXX_ERROR(logger_, "Null-pointer message received."); return; } + if (app_manager_.IsLowVoltage()) { + LOG4CXX_ERROR(logger_, "Low Voltage is active."); + return; + } + ProcessMessageFromHMI(message); } @@ -227,6 +235,11 @@ void RPCHandlerImpl::OnMessageReceived( const protocol_handler::RawMessagePtr message) { LOG4CXX_AUTO_TRACE(logger_); + if (app_manager_.IsLowVoltage()) { + LOG4CXX_ERROR(logger_, "Low Voltage is active."); + return; + } + if (!message) { LOG4CXX_ERROR(logger_, "Null-pointer message received."); NOTREACHED(); @@ -415,11 +428,12 @@ bool RPCHandlerImpl::ConvertMessageToSO( utils::SemanticVersion empty_version; if (validate_params && - output.validate(&report, empty_version, allow_unknown_parameters) != - smart_objects::errors::OK) { - LOG4CXX_ERROR(logger_, - "Incorrect parameter from HMI - " - << rpc::PrettyFormat(report)); + smart_objects::errors::OK != + output.validate( + &report, empty_version, allow_unknown_parameters)) { + LOG4CXX_ERROR( + logger_, + "Incorrect parameter from HMI - " << rpc::PrettyFormat(report)); output.erase(strings::msg_params); output[strings::params][hmi_response::code] = @@ -472,6 +486,7 @@ bool RPCHandlerImpl::ConvertMessageToSO( << message.protocol_version() << "."); return false; } + output[strings::params][strings::protection] = message.is_message_encrypted(); LOG4CXX_DEBUG(logger_, "Successfully parsed message into smart object"); return true; @@ -513,6 +528,7 @@ std::shared_ptr RPCHandlerImpl::ConvertRawMsgToMessage( } else { LOG4CXX_ERROR(logger_, "Received invalid message"); } + return outgoing_message; } @@ -523,5 +539,5 @@ hmi_apis::HMI_API& RPCHandlerImpl::hmi_so_factory() { mobile_apis::MOBILE_API& RPCHandlerImpl::mobile_so_factory() { return mobile_so_factory_; } -} -} +} // namespace rpc_handler +} // namespace application_manager diff --git a/src/components/application_manager/src/rpc_passing_handler.cc b/src/components/application_manager/src/rpc_passing_handler.cc index 32eda4b9e8f..7f72632bb17 100644 --- a/src/components/application_manager/src/rpc_passing_handler.cc +++ b/src/components/application_manager/src/rpc_passing_handler.cc @@ -40,6 +40,7 @@ #include "application_manager/application_manager.h" #include "application_manager/commands/command_impl.h" #include "application_manager/message_helper.h" +#include "application_manager/policies/policy_handler_interface.h" #include "application_manager/rpc_handler.h" #include "application_manager/rpc_passing_handler.h" #include "application_manager/smart_object_keys.h" @@ -108,9 +109,11 @@ bool RPCPassingHandler::ExtractRPCParams( } CommandParametersPermissions parameters_permissions; + const WindowID window_id = + MessageHelper::ExtractWindowIdFromSmartObject(s_map); mobile_apis::Result::eType check_result = app_manager_.CheckPolicyPermissions( - app, function_id_str, params, ¶meters_permissions); + app, window_id, function_id_str, params, ¶meters_permissions); // Check if RPC is allowed by policy (since we are allowing unknown params, // check should pass if only undefined parameters exist) @@ -141,7 +144,7 @@ bool RPCPassingHandler::IsPassthroughAllowed( rpc_message[strings::params][strings::function_id].asInt()); std::string function_id_str = MessageHelper::StringifiedFunctionID(function_id); - PolicyHandlerInterface& policy_handler = app_manager_.GetPolicyHandler(); + auto& policy_handler = app_manager_.GetPolicyHandler(); if (function_id_str.empty()) { // Unknown RPC, just do basic revoked and user consent checks @@ -397,9 +400,9 @@ void RPCPassingHandler::ClearCompletedTimers() { for (auto it = timeout_queue_.begin(); it != timeout_queue_.end();) { TimerSPtr timer = it->first; if (timer->is_completed()) { - LOG4CXX_DEBUG(logger_, - "Removing completed timer for correlation id " - << it->second); + LOG4CXX_DEBUG( + logger_, + "Removing completed timer for correlation id " << it->second); it = timeout_queue_.erase(it); } else { ++it; @@ -415,9 +418,9 @@ void RPCPassingHandler::AddRequestTimer(uint32_t correlation_id) { const uint32_t timeout_ms = app_manager_.get_settings().rpc_pass_through_timeout(); rpc_passing_timer->Start(timeout_ms, timer::kSingleShot); - LOG4CXX_DEBUG(logger_, - "Adding and starting timer for correlation id " - << correlation_id); + LOG4CXX_DEBUG( + logger_, + "Adding and starting timer for correlation id " << correlation_id); sync_primitives::AutoLock lock(timeout_queue_lock_); timeout_queue_.push_back(std::make_pair(rpc_passing_timer, correlation_id)); } diff --git a/src/components/application_manager/src/rpc_protection_manager_impl.cc b/src/components/application_manager/src/rpc_protection_manager_impl.cc new file mode 100644 index 00000000000..4afceb9e5b6 --- /dev/null +++ b/src/components/application_manager/src/rpc_protection_manager_impl.cc @@ -0,0 +1,222 @@ +/* + * Copyright (c) 2019, 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/rpc_protection_manager_impl.h" +#include "application_manager/application.h" +#include "application_manager/message_helper.h" +#include "utils/helpers.h" + +CREATE_LOGGERPTR_LOCAL(logger_, "RPCProtectionManagerImpl"); + +namespace application_manager { + +namespace rpc_encryption_exceptions { +std::vector kExceptionRPCs = {"RegisterAppInterface", + "SystemRequest", + "OnPermissionsChange", + "OnSystemRequest", + "PutFile", + "OnHMIStatus"}; +} + +RPCProtectionManagerImpl::RPCProtectionManagerImpl( + policy::PolicyHandlerInterface& policy_handler) + : policy_handler_(policy_handler) { + LOG4CXX_AUTO_TRACE(logger_); +} + +bool RPCProtectionManagerImpl::CheckPolicyEncryptionFlag( + const uint32_t function_id, + const ApplicationSharedPtr app, + const bool is_rpc_service_secure) const { + LOG4CXX_AUTO_TRACE(logger_); + const auto& policy_encryption_flag_getter = + policy_handler_.PolicyEncryptionFlagGetter(); + if (!policy_encryption_flag_getter) { + LOG4CXX_ERROR(logger_, "Policy Encryption Flag getter is not inited"); + return false; + } + const std::string function_name = + policy_encryption_flag_getter->GetPolicyFunctionName(function_id); + LOG4CXX_DEBUG(logger_, "Function for check is " << function_name); + + if (!is_rpc_service_secure && IsExceptionRPC(function_id)) { + LOG4CXX_WARN(logger_, + "Exception RPC can be sent in an non secure service despite " + "encryption required flag"); + return false; + } + + if (!app) { + LOG4CXX_WARN(logger_, "Received app nullptr"); + return false; + } + + const auto policy_app_id = app->policy_app_id(); + + return IsEncryptionRequiredByPolicy(policy_app_id, function_name); +} + +bool RPCProtectionManagerImpl::IsEncryptionRequiredByPolicy( + const std::string& policy_app_id, const std::string& function_name) const { + LOG4CXX_AUTO_TRACE(logger_); + + auto it = encrypted_rpcs_.find(policy_app_id); + + if (encrypted_rpcs_.end() == it) { + LOG4CXX_WARN( + logger_, + "App specific policies for app: " << policy_app_id << " not found"); + it = encrypted_rpcs_.find(policy_table::kDefaultApp); + return encrypted_rpcs_.end() != it + ? (*it).second.find(function_name) != (*it).second.end() + : false; + } + + return (*it).second.find(function_name) != (*it).second.end(); +} + +bool RPCProtectionManagerImpl::IsInEncryptionNeededCache( + const uint32_t app_id, const uint32_t correlation_id) const { + LOG4CXX_AUTO_TRACE(logger_); + LOG4CXX_DEBUG(logger_, "correlation_id is " << correlation_id); + + return encryption_needed_cache_.find(std::make_pair( + app_id, correlation_id)) != encryption_needed_cache_.end(); +} + +bool RPCProtectionManagerImpl::IsExceptionRPC( + const uint32_t function_id) const { + using namespace rpc_encryption_exceptions; + const std::string policy_fucntion_id = policy_table::EnumToJsonString( + static_cast(function_id)); + return helpers::in_range(kExceptionRPCs, policy_fucntion_id); +} + +void RPCProtectionManagerImpl::AddToEncryptionNeededCache( + const uint32_t app_id, const uint32_t correlation_id) { + LOG4CXX_AUTO_TRACE(logger_); + sync_primitives::AutoLock lock(message_needed_encryption_lock_); + + LOG4CXX_DEBUG(logger_, "Adding rpc with correlation id: " << correlation_id); + + encryption_needed_cache_.insert(std::make_pair(app_id, correlation_id)); +} + +void RPCProtectionManagerImpl::RemoveFromEncryptionNeededCache( + const uint32_t app_id, const uint32_t correlation_id) { + LOG4CXX_AUTO_TRACE(logger_); + sync_primitives::AutoLock lock(message_needed_encryption_lock_); + + LOG4CXX_DEBUG(logger_, + "Removing rpc with correlation id: " << correlation_id); + + encryption_needed_cache_.erase(std::make_pair(app_id, correlation_id)); +} + +void RPCProtectionManagerImpl::OnPTUFinished(const bool ptu_result) { + LOG4CXX_AUTO_TRACE(logger_); + sync_primitives::AutoLock lock(encrypted_rpcs_lock_); + + if (ptu_result) { + LOG4CXX_TRACE(logger_, + "PTU finished successfully, commencing internal encrypted " + "RPC cache update"); + encrypted_rpcs_.clear(); + SaveEncryptedRPC(); + } else { + LOG4CXX_WARN(logger_, + "PTU was unsuccessful. Keeping internal RPC cache from " + "current snapshot"); + } +} + +void RPCProtectionManagerImpl::SaveEncryptedRPC() { + LOG4CXX_AUTO_TRACE(logger_); + + const auto policy_encryption_flag_getter = + policy_handler_.PolicyEncryptionFlagGetter(); + + const auto policy_policy_app_ids = + policy_encryption_flag_getter->GetApplicationPolicyIDs(); + + for (const auto& app : policy_policy_app_ids) { + LOG4CXX_DEBUG(logger_, "Processing app name: " << app); + + encrypted_rpcs_[app] = GetEncryptedRPCsForApp(app); + } +} + +void RPCProtectionManagerImpl::OnPTInited() { + LOG4CXX_AUTO_TRACE(logger_); + + encrypted_rpcs_.clear(); + + SaveEncryptedRPC(); +} + +RPCProtectionManagerImpl::FunctionNames +RPCProtectionManagerImpl::GetEncryptedRPCsForApp( + const std::string& policy_app_id) { + LOG4CXX_AUTO_TRACE(logger_); + FunctionNames encrypted_rpcs; + + const auto policy_encryption_flag_getter = + policy_handler_.PolicyEncryptionFlagGetter(); + + if (!policy_encryption_flag_getter->AppNeedEncryption(policy_app_id)) { + return encrypted_rpcs; + } + + const auto function_groups = + policy_encryption_flag_getter->GetFunctionalGroupsForApp(policy_app_id); + + auto fill_encrypted_rpcs = [&encrypted_rpcs]( + const std::string& function_name) { + LOG4CXX_DEBUG(logger_, "Adding required encryprion rpc: " << function_name); + encrypted_rpcs.insert(function_name); + }; + + for (const auto& function_group : function_groups) { + if (policy_encryption_flag_getter->FunctionGroupNeedEncryption( + function_group)) { + auto rpcs = policy_encryption_flag_getter->GetRPCsForFunctionGroup( + function_group); + + std::for_each(rpcs.begin(), rpcs.end(), fill_encrypted_rpcs); + } + } + + return encrypted_rpcs; +} + +} // namespace application_manager diff --git a/src/components/application_manager/src/rpc_service_impl.cc b/src/components/application_manager/src/rpc_service_impl.cc index daa8cb2ac5b..79b2cbd752e 100644 --- a/src/components/application_manager/src/rpc_service_impl.cc +++ b/src/components/application_manager/src/rpc_service_impl.cc @@ -31,8 +31,11 @@ */ #include "application_manager/rpc_service_impl.h" +#include "application_manager/rpc_protection_manager_impl.h" #include "application_manager/app_service_manager.h" +#include "application_manager/command_factory.h" +#include "application_manager/commands/command.h" #include "application_manager/plugin_manager/plugin_keys.h" namespace application_manager { @@ -48,19 +51,68 @@ RPCServiceImpl::RPCServiceImpl( request_controller::RequestController& request_ctrl, protocol_handler::ProtocolHandler* protocol_handler, hmi_message_handler::HMIMessageHandler* hmi_handler, - CommandHolder& commands_holder) + CommandHolder& commands_holder, + RPCProtectionManagerSPtr rpc_protection_manager, + hmi_apis::HMI_API& hmi_so_factory, + mobile_apis::MOBILE_API& mobile_so_factory) : app_manager_(app_manager) , request_ctrl_(request_ctrl) , protocol_handler_(protocol_handler) , hmi_handler_(hmi_handler) + , rpc_protection_manager_(rpc_protection_manager) , commands_holder_(commands_holder) , messages_to_mobile_("AM ToMobile", this) , messages_to_hmi_("AM ToHMI", this) - , hmi_so_factory_(hmi_apis::HMI_API()) - , mobile_so_factory_(mobile_apis::MOBILE_API()) {} + , hmi_so_factory_(hmi_so_factory) + , mobile_so_factory_(mobile_so_factory) {} RPCServiceImpl::~RPCServiceImpl() {} +void RPCServiceImpl::Stop() { + LOG4CXX_AUTO_TRACE(logger_); + + messages_to_mobile_.Shutdown(); + messages_to_hmi_.Shutdown(); +} + +EncryptionFlagCheckResult RPCServiceImpl::IsEncryptionRequired( + const smart_objects::SmartObject& message, + std::shared_ptr app, + const bool is_rpc_service_secure) const { + LOG4CXX_AUTO_TRACE(logger_); + const auto function_id = + message[strings::params][strings::function_id].asUInt(); + const auto correlation_id = + message[strings::params][strings::correlation_id].asUInt(); + + const auto message_type = + message[strings::params][strings::message_type].asUInt(); + const bool policy_encryption_flag = + rpc_protection_manager_->CheckPolicyEncryptionFlag( + function_id, app, is_rpc_service_secure); + if (MessageType::kRequest == message_type) { + const bool message_protected = + message[strings::params][strings::protection].asBool(); + + if (!message_protected) { + return policy_encryption_flag + ? EncryptionFlagCheckResult::kError_EncryptionNeeded + : EncryptionFlagCheckResult::kSuccess_NotProtected; + } + + // request is encrypted, so we need to encrypt response regardless of + // policy flag + const auto connection_key = + message[strings::params][strings::connection_key].asUInt(); + rpc_protection_manager_->AddToEncryptionNeededCache(connection_key, + correlation_id); + return EncryptionFlagCheckResult::kSuccess_Protected; + } + return policy_encryption_flag + ? EncryptionFlagCheckResult::kSuccess_Protected + : EncryptionFlagCheckResult::kSuccess_NotProtected; +} + bool RPCServiceImpl::ManageMobileCommand( const commands::MessageSharedPtr message, commands::Command::CommandSource source) { @@ -82,9 +134,10 @@ bool RPCServiceImpl::ManageMobileCommand( (*message)[strings::params][strings::connection_key].asUInt()); auto app_ptr = app_manager_.application(connection_key); - if (app_ptr && app_manager_.IsAppInReconnectMode(app_ptr->policy_app_id())) { + if (app_ptr && app_manager_.IsAppInReconnectMode(app_ptr->device(), + app_ptr->policy_app_id())) { commands_holder_.Suspend( - app_ptr, CommandHolder::CommandType::kMobileCommand, message); + app_ptr, CommandHolder::CommandType::kMobileCommand, source, message); return true; } mobile_apis::FunctionID::eType function_id = @@ -118,6 +171,21 @@ bool RPCServiceImpl::ManageMobileCommand( SendMessageToMobile(response); return false; } +#ifdef ENABLE_SECURITY + if (EncryptionFlagCheckResult::kError_EncryptionNeeded == + IsEncryptionRequired( + *message, + app, + protocol_handler_->IsRPCServiceSecure(connection_key))) { + const auto response = MessageHelper::CreateNegativeResponse( + connection_key, + function_id, + correlation_id, + static_cast(mobile_apis::Result::ENCRYPTION_NEEDED)); + SendMessageToMobile(response); + return false; + } +#endif // ENABLE_SECURITY // Message for "CheckPermission" must be with attached schema mobile_so_factory().attachSchema(*message, false); @@ -176,7 +244,8 @@ bool RPCServiceImpl::ManageMobileCommand( mobile_apis::HMILevel::eType app_hmi_level = mobile_apis::HMILevel::INVALID_ENUM; if (app) { - app_hmi_level = app->hmi_level(); + app_hmi_level = + app->hmi_level(mobile_apis::PredefinedWindows::DEFAULT_WINDOW); } // commands will be launched from request_ctrl @@ -296,9 +365,10 @@ bool RPCServiceImpl::ManageHMICommand(const commands::MessageSharedPtr message, (*message)[strings::msg_params][strings::app_id].asUInt(); auto app = app_manager_.application(static_cast(connection_key)); - if (app && app_manager_.IsAppInReconnectMode(app->policy_app_id())) { + if (app && app_manager_.IsAppInReconnectMode(app->device(), + app->policy_app_id())) { commands_holder_.Suspend( - app, CommandHolder::CommandType::kHmiCommand, message); + app, CommandHolder::CommandType::kHmiCommand, source, message); return true; } } @@ -337,6 +407,7 @@ void RPCServiceImpl::Handle(const impl::MessageToHmi message) { } void RPCServiceImpl::Handle(const impl::MessageToMobile message) { + LOG4CXX_AUTO_TRACE(logger_); if (!protocol_handler_) { LOG4CXX_WARN(logger_, "Protocol Handler is not set; cannot send message to mobile."); @@ -361,7 +432,32 @@ void RPCServiceImpl::Handle(const impl::MessageToMobile message) { } } - protocol_handler_->SendMessageToMobileApp(rawMessage, is_final); + const auto correlation_id = message->correlation_id(); + const auto app_id = message->connection_key(); + + const bool is_service_secure = + protocol_handler_->IsRPCServiceSecure(message->connection_key()); + + const bool needs_encryption = + MessageType::kNotification == message->type() + ? rpc_protection_manager_->CheckPolicyEncryptionFlag( + message->function_id(), + app_manager_.application(app_id), + is_service_secure) + : rpc_protection_manager_->IsInEncryptionNeededCache(app_id, + correlation_id); + + if (needs_encryption && !is_service_secure) { + LOG4CXX_WARN(logger_, + "Unable to send rpc that requires encryption without secure " + "rpc service"); + return; + }; + + protocol_handler_->SendMessageToMobileApp( + rawMessage, needs_encryption, is_final); + rpc_protection_manager_->RemoveFromEncryptionNeededCache(app_id, + correlation_id); LOG4CXX_INFO(logger_, "Message for mobile given away"); if (close_session) { @@ -431,9 +527,9 @@ void RPCServiceImpl::SendMessageToMobile( if (IsAppServiceRPC(function_id, commands::Command::CommandSource::SOURCE_SDL) || rpc_passing) { - LOG4CXX_DEBUG(logger_, - "Allowing unknown parameters for response function " - << function_id); + LOG4CXX_DEBUG( + logger_, + "Allowing unknown parameters for response function " << function_id); allow_unknown_parameters = true; } @@ -451,6 +547,8 @@ void RPCServiceImpl::SendMessageToMobile( LOG4CXX_WARN(logger_, "Can't send msg to Mobile: failed to create string"); return; } + const auto api_function_id = static_cast( + (*message)[strings::params][strings::function_id].asUInt()); smart_objects::SmartObject& msg_to_mobile = *message; // If correlation_id is not present, it is from-HMI message which should be @@ -461,12 +559,11 @@ void RPCServiceImpl::SendMessageToMobile( msg_to_mobile[strings::params][strings::connection_key].asUInt(), msg_to_mobile[strings::params][strings::function_id].asInt()); } else if (app) { - mobile_apis::FunctionID::eType function_id = - static_cast( - (*message)[strings::params][strings::function_id].asUInt()); RPCParams params; const smart_objects::SmartObject& s_map = (*message)[strings::msg_params]; + const WindowID window_id = + MessageHelper::ExtractWindowIdFromSmartObject(s_map); if (smart_objects::SmartType_Map == s_map.getType()) { smart_objects::SmartMap::iterator iter = s_map.map_begin(); smart_objects::SmartMap::iterator iter_end = s_map.map_end(); @@ -479,18 +576,20 @@ void RPCServiceImpl::SendMessageToMobile( } } const std::string string_functionID = - MessageHelper::StringifiedFunctionID(function_id); + MessageHelper::StringifiedFunctionID(api_function_id); const mobile_apis::Result::eType check_result = - app_manager_.CheckPolicyPermissions(app, string_functionID, params); + app_manager_.CheckPolicyPermissions( + app, window_id, string_functionID, params); if (mobile_apis::Result::SUCCESS != check_result) { LOG4CXX_WARN(logger_, - "Function \"" << string_functionID << "\" (#" << function_id + "Function \"" << string_functionID << "\" (#" + << api_function_id << ") not allowed by policy"); return; } #ifdef EXTERNAL_PROPRIETARY_MODE - if (function_id == mobile_apis::FunctionID::OnSystemRequestID) { + if (api_function_id == mobile_apis::FunctionID::OnSystemRequestID) { mobile_apis::RequestType::eType request_type = static_cast( (*message)[strings::msg_params][strings::request_type].asUInt()); @@ -514,7 +613,6 @@ void RPCServiceImpl::SendMessageToMobile( void RPCServiceImpl::SendMessageToHMI( const commands::MessageSharedPtr message) { LOG4CXX_AUTO_TRACE(logger_); - if (!message) { LOG4CXX_WARN(logger_, "Null-pointer message received."); NOTREACHED(); @@ -555,7 +653,6 @@ void RPCServiceImpl::SendMessageToHMI( "Cannot send message to HMI: failed to create string"); return; } - messages_to_hmi_.PostMessage(impl::MessageToHmi(message_to_send)); } @@ -707,6 +804,28 @@ bool RPCServiceImpl::ConvertSOtoMessage( return true; } +void RPCServiceImpl::UpdateMobileRPCParams( + const mobile_apis::FunctionID::eType& function_id, + const mobile_apis::messageType::eType& message_type, + const std::map& members) { + mobile_so_factory().ResetFunctionSchema(function_id, message_type); + for (const auto& item : members) { + mobile_so_factory().AddCustomMember( + function_id, message_type, item.first, item.second); + } +} + +void RPCServiceImpl::UpdateHMIRPCParams( + const hmi_apis::FunctionID::eType& function_id, + const hmi_apis::messageType::eType& message_type, + const std::map& members) { + hmi_so_factory().ResetFunctionSchema(function_id, message_type); + for (const auto& item : members) { + hmi_so_factory().AddCustomMember( + function_id, message_type, item.first, item.second); + } +} + hmi_apis::HMI_API& RPCServiceImpl::hmi_so_factory() { return hmi_so_factory_; } diff --git a/src/components/application_manager/src/smart_object_keys.cc b/src/components/application_manager/src/smart_object_keys.cc index 48e293a7829..fe0f878e6c4 100644 --- a/src/components/application_manager/src/smart_object_keys.cc +++ b/src/components/application_manager/src/smart_object_keys.cc @@ -5,6 +5,8 @@ namespace application_manager { namespace strings { const char* params = "params"; +const char* require_encryption = "requireEncryption"; +const char* protection = "protection"; const char* message_type = "message_type"; const char* correlation_id = "correlation_id"; const char* function_id = "function_id"; @@ -20,6 +22,7 @@ const char* info = "info"; const char* app_id = "appID"; const char* full_app_id = "fullAppID"; const char* bundle_id = "appBundleID"; +const char* window_id = "windowID"; const char* app_info = "appInfo"; const char* app_launch = "app_launch"; const char* app_launch_list = "app_launch_list"; @@ -59,6 +62,7 @@ const char* main_field_1 = "mainField1"; const char* main_field_2 = "mainField2"; const char* main_field_3 = "mainField3"; const char* main_field_4 = "mainField4"; +const char* template_title = "templateTitle"; const char* metadata_tags = "metadataTags"; const char* eta = "eta"; const char* time_to_destination = "timeToDestination"; @@ -77,10 +81,13 @@ const char* menu_icon = "menuIcon"; const char* keyboard_properties = "keyboardProperties"; const char* vr_commands = "vrCommands"; const char* position = "position"; +const char* user_location = "userLocation"; const char* num_ticks = "numTicks"; const char* slider_footer = "sliderFooter"; const char* menu_id = "menuID"; const char* menu_name = "menuName"; +const char* menu_layout = "menuLayout"; +const char* menu_layouts_available = "menuLayoutsAvailable"; const char* interaction_choice_set_id = "interactionChoiceSetID"; const char* interaction_choice_set_id_list = "interactionChoiceSetIDList"; const char* choice_set = "choiceSet"; @@ -96,7 +103,10 @@ const char* initial_prompt = "initialPrompt"; const char* initial_text = "initialText"; const char* duration = "duration"; const char* progress_indicator = "progressIndicator"; +const char* func_id = "functionID"; +const char* cancel_id = "cancelID"; const char* alert_type = "alertType"; +const char* alert_icon = "alertIcon"; const char* play_tone = "playTone"; const char* soft_buttons = "softButtons"; const char* soft_button_id = "softButtonID"; @@ -133,9 +143,17 @@ const char* activate_app_hmi_level = "level"; const char* audio_streaming_state = "audioStreamingState"; const char* video_streaming_state = "videoStreamingState"; const char* system_context = "systemContext"; +const char* window_name = "windowName"; +const char* window_type = "type"; +const char* window_type_supported = "windowTypeSupported"; +const char* maximum_number_of_windows = "maximumNumberOfWindows"; +const char* window_capabilities = "windowCapabilities"; +const char* associated_service_type = "associatedServiceType"; +const char* duplicate_updates_from_window_id = "duplicateUpdatesFromWindowID"; const char* speech_capabilities = "speechCapabilities"; const char* vr_capabilities = "vrCapabilities"; const char* audio_pass_thru_capabilities = "audioPassThruCapabilities"; +const char* audio_pass_thru_capabilities_list = "audioPassThruCapabilitiesList"; const char* pcm_stream_capabilities = "pcmStreamCapabilities"; const char* audio_pass_thru_icon = "audioPassThruIcon"; const char* way_points = "wayPoints"; @@ -146,6 +164,7 @@ const char* navigation_capability = "navigationCapability"; const char* phone_capability = "phoneCapability"; const char* video_streaming_capability = "videoStreamingCapability"; const char* rc_capability = "remoteControlCapability"; +const char* seat_location_capability = "seatLocationCapability"; const char* app_services_capabilities = "appServicesCapabilities"; const char* day_color_scheme = "dayColorScheme"; const char* night_color_scheme = "nightColorScheme"; @@ -156,6 +175,8 @@ const char* red = "red"; const char* green = "green"; const char* blue = "blue"; const char* display_layout = "displayLayout"; +const char* template_configuration = "templateConfiguration"; +const char* template_layout = "template"; const char* icon_resumed = "iconResumed"; const char* nicknames = "nicknames"; const char* enabled = "enabled"; @@ -165,6 +186,11 @@ const char* hybrid_app_preference = "hybridAppPreference"; const char* is_cloud_application = "isCloudApplication"; const char* cloud_connection_status = "cloudConnectionStatus"; const char* endpoint = "endpoint"; +const char* display_capabilities = "displayCapabilities"; +const char* policy_type = "policyType"; +const char* property = "property"; +const char* displays = "displays"; +const char* seat_location = "seatLocation"; // PutFile const char* sync_file_name = "syncFileName"; @@ -183,6 +209,7 @@ const char* is_template = "isTemplate"; const char* image = "image"; const char* type = "type"; const char* system_file = "systemFile"; +const char* is_system_file = "isSystemFile"; const char* offset = "offset"; const char* length = "length"; const char* secondary_image = "secondaryImage"; @@ -221,6 +248,7 @@ const char* key_press_mode = "keypressMode"; // duplicate names from hmi_request const char* limited_character_list = "limitedCharacterList"; const char* auto_complete_text = "autoCompleteText"; +const char* auto_complete_list = "autoCompleteList"; const char* navigation_text = "navigationText"; // vehicle info @@ -252,6 +280,7 @@ const char* e_call_info = "eCallInfo"; const char* airbag_status = "airbagStatus"; const char* emergency_event = "emergencyEvent"; const char* cluster_mode_status = "clusterModeStatus"; +const char* cluster_modes = "clusterModes"; const char* my_key = "myKey"; const char* help_prompt = "helpPrompt"; const char* scroll_message_body = "scrollableMessageBody"; @@ -271,6 +300,7 @@ const char* sdl_version = "sdlVersion"; const char* system_software_version = "systemSoftwareVersion"; const char* priority = "priority"; const char* engine_oil_life = "engineOilLife"; +const char* oem_custom_data_type = "oemCustomDataType"; // app services const char* app_service_manifest = "appServiceManifest"; @@ -289,6 +319,7 @@ const char* service_active = "serviceActive"; const char* app_service_id = "appServiceId"; const char* service_data = "serviceData"; const char* media_service_data = "mediaServiceData"; +const char* media_image = "mediaImage"; const char* weather_service_data = "weatherServiceData"; const char* location = "location"; const char* current_forecast = "currentForecast"; @@ -310,6 +341,10 @@ const char* activate = "activate"; const char* set_as_default = "setAsDefault"; const char* origin_app = "originApp"; +// sis data +const char* station_short_name = "stationShortName"; +const char* station_location = "stationLocation"; + // resuming const char* application_commands = "applicationCommands"; const char* application_submenus = "applicationSubMenus"; @@ -338,8 +373,12 @@ const char* time_stamp = "timeStamp"; const char* manual_text_entry = "manualTextEntry"; const char* image_type_supported = "imageTypeSupported"; const char* unexpected_disconnect = "unexpectedDisconnect"; + +const char* shifted = "shifted"; +const char* altitude = "altitude"; const char* longitude_degrees = "longitudeDegrees"; const char* latitude_degrees = "latitudeDegrees"; + const char* address = "address"; const char* country_name = "countryName"; const char* country_code = "countryCode"; @@ -362,13 +401,14 @@ const char* delivery_mode = "deliveryMode"; const char* audio_streaming_indicator = "audioStreamingIndicator"; +const char* windows_info = "windowsInfo"; + const char* const keyboard_properties_supported = "keyboardPropertiesSupported"; const char* const language_supported = "languageSupported"; const char* const keyboard_layout_supported = "keyboardLayoutSupported"; const char* const keypress_mode_supported = "keypressModeSupported"; const char* const limited_characters_list_supported = "limitedCharactersListSupported"; -const char* const auto_complete_text_supported = "autoCompleteTextSupported"; const char* const send_location_enabled = "sendLocationEnabled"; const char* const get_way_points_enabled = "getWayPointsEnabled"; const char* const entity_type = "entityType"; @@ -389,6 +429,9 @@ const char* const resolution_height = "resolutionHeight"; const char* const max_bitrate = "maxBitrate"; const char* const supported_formats = "supportedFormats"; const char* const haptic_spatial_data_supported = "hapticSpatialDataSupported"; +const char* const diagonal_screen_size = "diagonalScreenSize"; +const char* const pixel_per_inch = "pixelPerInch"; +const char* const scale = "scale"; const char* const haptic_rect_data = "hapticRectData"; const char* const rect = "rect"; const char* const x = "x"; @@ -431,6 +474,8 @@ namespace mobile_notification { const char* state = "state"; const char* syncp_timeout = "Timeout"; const char* syncp_url = "URL"; +const char* lock_screen_dismissal_enabled = "lockScreenDismissalEnabled"; +const char* lock_screen_dismissal_warning = "lockScreenDismissalWarning"; } // namespace mobile_notification namespace hmi_levels { @@ -475,7 +520,7 @@ const char* keyboard_properties = "keyboardProperties"; const char* method_name = "methodName"; const char* keyboard_layout = "keyboardLayout"; const char* limited_character_list = "limitedCharacterList"; -const char* auto_complete_text = "autoCompleteText"; +const char* auto_complete_list = "autoCompleteList"; const char* file = "file"; const char* file_name = "fileName"; const char* retry = "retry"; @@ -536,6 +581,9 @@ const char* policyfile = "policyfile"; const char* is_active = "isActive"; const char* is_deactivated = "isDeactivated"; const char* event_name = "eventName"; +const char* service_type = "serviceType"; +const char* service_event = "serviceEvent"; +const char* reason = "reason"; } // namespace hmi_notification } // namespace application_manager diff --git a/src/components/application_manager/src/state_controller_impl.cc b/src/components/application_manager/src/state_controller_impl.cc index f4852c532ce..8368597370f 100644 --- a/src/components/application_manager/src/state_controller_impl.cc +++ b/src/components/application_manager/src/state_controller_impl.cc @@ -32,8 +32,8 @@ #include "application_manager/state_controller_impl.h" #include -#include "application_manager/usage_statistics.h" #include "application_manager/rpc_service.h" +#include "application_manager/usage_statistics.h" #include "utils/helpers.h" #include "connection_handler/connection_handler.h" @@ -67,14 +67,16 @@ StateControllerImpl::StateControllerImpl(ApplicationManager& app_mngr) } void StateControllerImpl::SetRegularState(ApplicationSharedPtr app, + const WindowID window_id, HmiStatePtr state, - const bool send_activate_app) { + const bool request_hmi_state_change) { LOG4CXX_AUTO_TRACE(logger_); DCHECK_OR_RETURN_VOID(app); DCHECK_OR_RETURN_VOID(state); DCHECK_OR_RETURN_VOID(HmiState::STATE_ID_REGULAR == state->state_id()); - LOG4CXX_DEBUG(logger_, "Set regular state " << *state); + LOG4CXX_DEBUG(logger_, + "Set window #" << window_id << " regular state " << *state); if (state->hmi_level() == mobile_apis::HMILevel::INVALID_ENUM || state->audio_streaming_state() == @@ -93,37 +95,44 @@ void StateControllerImpl::SetRegularState(ApplicationSharedPtr app, HmiStatePtr resolved_state = ResolveHmiState(app, state); if (!resolved_state) { state->set_state_id(HmiState::STATE_ID_POSTPONED); - app->SetPostponedState(state); + app->SetPostponedState(window_id, state); return; } + LOG4CXX_DEBUG(logger_, "Resolved state: " << *resolved_state); const hmi_apis::Common_HMILevel::eType hmi_level = static_cast( resolved_state->hmi_level()); - if (send_activate_app) { - const int64_t corr_id = SendBCActivateApp(app, hmi_level, true); - if (-1 != corr_id) { - subscribe_on_event(hmi_apis::FunctionID::BasicCommunication_ActivateApp, - corr_id); - waiting_for_activate_[app->app_id()] = resolved_state; + if (request_hmi_state_change) { + const int64_t result = RequestHMIStateChange(app, hmi_level, true); + if (-1 != result) { + const uint32_t corr_id = static_cast(result); + subscribe_on_event( + hmi_apis::Common_HMILevel::NONE == hmi_level + ? hmi_apis::FunctionID::BasicCommunication_CloseApplication + : hmi_apis::FunctionID::BasicCommunication_ActivateApp, + corr_id); + waiting_for_response_[app->app_id()] = resolved_state; + app_mngr_.set_application_id(corr_id, app->hmi_app_id()); return; } LOG4CXX_ERROR(logger_, "Unable to send BC.ActivateApp"); return; } - ApplyRegularState(app, resolved_state); + ApplyRegularState(app, window_id, resolved_state); } void StateControllerImpl::SetRegularState( ApplicationSharedPtr app, + const WindowID window_id, const mobile_apis::HMILevel::eType hmi_level, const mobile_apis::AudioStreamingState::eType audio_state, const mobile_apis::VideoStreamingState::eType video_state, - const bool send_activate_app) { + const bool request_hmi_state_change) { LOG4CXX_AUTO_TRACE(logger_); DCHECK_OR_RETURN_VOID(app); - HmiStatePtr prev_regular = app->RegularHmiState(); + HmiStatePtr prev_regular = app->RegularHmiState(window_id); DCHECK_OR_RETURN_VOID(prev_regular); HmiStatePtr hmi_state = CreateHmiState(app, HmiState::StateID::STATE_ID_REGULAR); @@ -132,16 +141,22 @@ void StateControllerImpl::SetRegularState( hmi_state->set_audio_streaming_state(audio_state); hmi_state->set_video_streaming_state(video_state); hmi_state->set_system_context(prev_regular->system_context()); - SetRegularState(app, hmi_state, send_activate_app); + hmi_state->set_window_type(prev_regular->window_type()); + SetRegularState(app, window_id, hmi_state, request_hmi_state_change); } void StateControllerImpl::SetRegularState( ApplicationSharedPtr app, + const WindowID window_id, const mobile_apis::HMILevel::eType hmi_level, - const bool send_activate_app) { + const bool request_hmi_state_change) { using namespace mobile_apis; LOG4CXX_AUTO_TRACE(logger_); DCHECK_OR_RETURN_VOID(app); + + HmiStatePtr prev_regular = app->RegularHmiState(window_id); + DCHECK_OR_RETURN_VOID(prev_regular); + const HmiStatePtr hmi_state = CreateHmiState(app, HmiState::StateID::STATE_ID_REGULAR); @@ -150,33 +165,43 @@ void StateControllerImpl::SetRegularState( hmi_state->set_audio_streaming_state(CalcAudioState(app, hmi_level)); hmi_state->set_video_streaming_state(CalcVideoState(app, hmi_level)); hmi_state->set_system_context(SystemContext::SYSCTXT_MAIN); - SetRegularState(app, hmi_state, send_activate_app); + hmi_state->set_window_type(prev_regular->window_type()); + SetRegularState(app, window_id, hmi_state, request_hmi_state_change); } void StateControllerImpl::SetRegularState( ApplicationSharedPtr app, + const WindowID window_id, const mobile_apis::HMILevel::eType hmi_level, const mobile_apis::AudioStreamingState::eType audio_state, const mobile_apis::VideoStreamingState::eType video_state, const mobile_apis::SystemContext::eType system_context, - const bool send_activate_app) { + const bool request_hmi_state_change) { LOG4CXX_AUTO_TRACE(logger_); DCHECK_OR_RETURN_VOID(app); + + HmiStatePtr prev_regular = app->RegularHmiState(window_id); + DCHECK_OR_RETURN_VOID(prev_regular); + HmiStatePtr hmi_state = CreateHmiState(app, HmiState::StateID::STATE_ID_REGULAR); DCHECK_OR_RETURN_VOID(hmi_state); + hmi_state->set_hmi_level(hmi_level); hmi_state->set_audio_streaming_state(audio_state); hmi_state->set_video_streaming_state(video_state); hmi_state->set_system_context(system_context); - SetRegularState(app, hmi_state, send_activate_app); + hmi_state->set_window_type(prev_regular->window_type()); + SetRegularState(app, window_id, hmi_state, request_hmi_state_change); } void StateControllerImpl::SetRegularState( - ApplicationSharedPtr app, const mobile_apis::HMILevel::eType hmi_level) { + ApplicationSharedPtr app, + const WindowID window_id, + const mobile_apis::HMILevel::eType hmi_level) { LOG4CXX_AUTO_TRACE(logger_); DCHECK_OR_RETURN_VOID(app); - HmiStatePtr prev_state = app->RegularHmiState(); + HmiStatePtr prev_state = app->RegularHmiState(window_id); HmiStatePtr hmi_state = CreateHmiState(app, HmiState::StateID::STATE_ID_REGULAR); DCHECK_OR_RETURN_VOID(hmi_state); @@ -186,15 +211,16 @@ void StateControllerImpl::SetRegularState( hmi_state->set_system_context(prev_state ? prev_state->system_context() : mobile_apis::SystemContext::SYSCTXT_MAIN); - SetRegularState(app, hmi_state); + SetRegularState(app, window_id, hmi_state); } void StateControllerImpl::SetRegularState( ApplicationSharedPtr app, + const WindowID window_id, const mobile_apis::SystemContext::eType system_context) { LOG4CXX_AUTO_TRACE(logger_); DCHECK_OR_RETURN_VOID(app); - HmiStatePtr prev_regular = app->RegularHmiState(); + HmiStatePtr prev_regular = app->RegularHmiState(window_id); DCHECK_OR_RETURN_VOID(prev_regular); HmiStatePtr hmi_state = CreateHmiState(app, HmiState::StateID::STATE_ID_REGULAR); @@ -205,16 +231,18 @@ void StateControllerImpl::SetRegularState( hmi_state->set_video_streaming_state( CalcVideoState(app, prev_regular->hmi_level())); hmi_state->set_system_context(system_context); - SetRegularState(app, hmi_state, false); + hmi_state->set_window_type(prev_regular->window_type()); + SetRegularState(app, window_id, hmi_state, false); } void StateControllerImpl::SetRegularState( ApplicationSharedPtr app, + const WindowID window_id, const mobile_apis::AudioStreamingState::eType audio_state, const mobile_apis::VideoStreamingState::eType video_state) { LOG4CXX_AUTO_TRACE(logger_); DCHECK_OR_RETURN_VOID(app); - HmiStatePtr prev_state = app->RegularHmiState(); + HmiStatePtr prev_state = app->RegularHmiState(window_id); DCHECK_OR_RETURN_VOID(prev_state); HmiStatePtr hmi_state = CreateHmiState(app, HmiState::StateID::STATE_ID_REGULAR); @@ -223,18 +251,23 @@ void StateControllerImpl::SetRegularState( hmi_state->set_audio_streaming_state(audio_state); hmi_state->set_video_streaming_state(video_state); hmi_state->set_system_context(prev_state->system_context()); - SetRegularState(app, hmi_state, false); + hmi_state->set_window_type(prev_state->window_type()); + SetRegularState(app, window_id, hmi_state, false); } void StateControllerImpl::SetRegularState(ApplicationSharedPtr app, + const WindowID window_id, HmiStatePtr state) { LOG4CXX_AUTO_TRACE(logger_); DCHECK_OR_RETURN_VOID(app); DCHECK_OR_RETURN_VOID(state); - if (mobile_apis::HMILevel::HMI_FULL == state->hmi_level()) { - SetRegularState(app, state, true); + + // SDL should send BC.ActivateApp for main window during resumption + if (mobile_apis::PredefinedWindows::DEFAULT_WINDOW == window_id && + mobile_apis::HMILevel::HMI_FULL == state->hmi_level()) { + SetRegularState(app, window_id, state, true); } else { - SetRegularState(app, state, false); + SetRegularState(app, window_id, state, false); } } @@ -295,7 +328,8 @@ void StateControllerImpl::HmiLevelConflictResolver::operator()( return; } - const HmiStatePtr state_to_resolve = app_to_resolve->RegularHmiState(); + const HmiStatePtr state_to_resolve = + app_to_resolve->RegularHmiState(window_id_); DCHECK_OR_RETURN_VOID(state_to_resolve); // If applied HMI state is FULL: @@ -379,22 +413,23 @@ void StateControllerImpl::HmiLevelConflictResolver::operator()( std::make_tuple( result_hmi_level, result_audio_state, result_video_state)) { LOG4CXX_DEBUG(logger_, - "Application " - << app_to_resolve->app_id() << " will change state to: " - << "HMI level " << to_resolve_hmi_level << " --> " - << result_hmi_level << ", audio " - << state_to_resolve->audio_streaming_state() << " --> " - << result_audio_state << ", video " - << state_to_resolve->video_streaming_state() << " --> " - << result_video_state); + "Application " << app_to_resolve->app_id() << " window " + << window_id_ << " will change state to: " + << "HMI level " << to_resolve_hmi_level + << " --> " << result_hmi_level << ", audio " + << state_to_resolve->audio_streaming_state() + << " --> " << result_audio_state << ", video " + << state_to_resolve->video_streaming_state() + << " --> " << result_video_state); state_ctrl_->SetupRegularHmiState(app_to_resolve, + window_id_, result_hmi_level, result_audio_state, result_video_state); } else { LOG4CXX_DEBUG(logger_, - "Application " << app_to_resolve->app_id() - << " will NOT change HMI level"); + "Application " << app_to_resolve->app_id() << " window " + << window_id_ << " will NOT change HMI level"); } } @@ -408,6 +443,7 @@ HmiStatePtr StateControllerImpl::ResolveHmiState(ApplicationSharedPtr app, CreateHmiState(app, HmiState::StateID::STATE_ID_REGULAR); DCHECK_OR_RETURN(available_state, HmiStatePtr()); available_state->set_hmi_level(state->hmi_level()); + available_state->set_window_type(state->window_type()); available_state->set_audio_streaming_state(state->audio_streaming_state()); available_state->set_video_streaming_state(state->video_streaming_state()); available_state->set_system_context(state->system_context()); @@ -565,12 +601,14 @@ bool StateControllerImpl::IsStateAvailableForResumption( } void StateControllerImpl::SetupRegularHmiState(ApplicationSharedPtr app, + const WindowID window_id, HmiStatePtr state) { using namespace mobile_apis; LOG4CXX_AUTO_TRACE(logger_); DCHECK_OR_RETURN_VOID(state); - LOG4CXX_DEBUG(logger_, "Setup regular state: " << *state); - HmiStatePtr curr_state = app->CurrentHmiState(); + LOG4CXX_DEBUG(logger_, + "Setup window #" << window_id << " regular state: " << *state); + HmiStatePtr curr_state = app->CurrentHmiState(window_id); HmiStatePtr old_state = CreateHmiState(app, HmiState::StateID::STATE_ID_REGULAR); DCHECK_OR_RETURN_VOID(old_state); @@ -578,28 +616,30 @@ void StateControllerImpl::SetupRegularHmiState(ApplicationSharedPtr app, old_state->set_audio_streaming_state(curr_state->audio_streaming_state()); old_state->set_video_streaming_state(curr_state->video_streaming_state()); old_state->set_system_context(curr_state->system_context()); - app->SetRegularState(state); + old_state->set_window_type(curr_state->window_type()); + app->SetRegularState(window_id, state); - if (HMILevel::HMI_LIMITED == state->hmi_level() && app->is_resuming()) { + if (mobile_apis::PredefinedWindows::DEFAULT_WINDOW == window_id && + HMILevel::HMI_LIMITED == state->hmi_level() && app->is_resuming()) { LOG4CXX_DEBUG(logger_, "Resuming to LIMITED level. " << "Send OnResumeAudioSource notification"); MessageHelper::SendOnResumeAudioSourceToHMI(app->app_id(), app_mngr_); } - app->set_is_resuming(false); - HmiStatePtr new_state = app->CurrentHmiState(); - OnStateChanged(app, old_state, new_state); + HmiStatePtr new_state = app->CurrentHmiState(window_id); + OnStateChanged(app, window_id, old_state, new_state); } void StateControllerImpl::SetupRegularHmiState( ApplicationSharedPtr app, + const WindowID window_id, const mobile_apis::HMILevel::eType hmi_level, const mobile_apis::AudioStreamingState::eType audio_state, const mobile_apis::VideoStreamingState::eType video_state) { LOG4CXX_AUTO_TRACE(logger_); DCHECK_OR_RETURN_VOID(app); - HmiStatePtr prev_state = app->RegularHmiState(); + HmiStatePtr prev_state = app->RegularHmiState(window_id); DCHECK_OR_RETURN_VOID(prev_state); HmiStatePtr new_state = CreateHmiState(app, HmiState::StateID::STATE_ID_REGULAR); @@ -608,27 +648,69 @@ void StateControllerImpl::SetupRegularHmiState( new_state->set_audio_streaming_state(audio_state); new_state->set_video_streaming_state(video_state); new_state->set_system_context(prev_state->system_context()); - SetupRegularHmiState(app, new_state); + new_state->set_window_type(prev_state->window_type()); + SetupRegularHmiState(app, window_id, new_state); } void StateControllerImpl::ApplyRegularState(ApplicationSharedPtr app, + const WindowID window_id, HmiStatePtr state) { LOG4CXX_AUTO_TRACE(logger_); DCHECK_OR_RETURN_VOID(app); DCHECK_OR_RETURN_VOID(state); DCHECK_OR_RETURN_VOID(state->state_id() == HmiState::STATE_ID_REGULAR); LOG4CXX_DEBUG(logger_, - "Applying to app " << app->app_id() << " state " << *state); - SetupRegularHmiState(app, state); + "Applying to app " << app->app_id() << " window #" << window_id + << " state " << *state); + SetupRegularHmiState(app, window_id, state); + + if (mobile_apis::PredefinedWindows::DEFAULT_WINDOW != window_id) { + LOG4CXX_DEBUG(logger_, "No need to resolve conflicts for a widget"); + return; + } + LOG4CXX_DEBUG(logger_, "Resolving HMI level conflicts for app " << app->app_id()); - ForEachApplication(HmiLevelConflictResolver(app, state, this)); + ForEachApplication(HmiLevelConflictResolver(app, window_id, state, this)); } + +void StateControllerImpl::UpdateAppWindowsStreamingState( + ApplicationSharedPtr app, HmiStatePtr state) { + LOG4CXX_AUTO_TRACE(logger_); + const auto window_ids = app->GetWindowIds(); + for (auto window_id : window_ids) { + HmiStatePtr window_hmi_state = app->RegularHmiState(window_id); + LOG4CXX_DEBUG( + logger_, "State: " << *state << " window state: " << *window_hmi_state); + if (window_hmi_state->audio_streaming_state() != + state->audio_streaming_state() || + window_hmi_state->video_streaming_state() != + state->video_streaming_state()) { + LOG4CXX_DEBUG(logger_, + "Updating streaming state for window #" << window_id); + + HmiStatePtr new_window_state = + CreateHmiState(app, HmiState::StateID::STATE_ID_REGULAR); + DCHECK_OR_RETURN_VOID(new_window_state); + new_window_state->set_hmi_level(window_hmi_state->hmi_level()); + new_window_state->set_audio_streaming_state( + state->audio_streaming_state()); + new_window_state->set_video_streaming_state( + state->video_streaming_state()); + new_window_state->set_system_context(window_hmi_state->system_context()); + new_window_state->set_window_type(window_hmi_state->window_type()); + app->SetRegularState(window_id, new_window_state); + + MessageHelper::SendHMIStatusNotification(app, window_id, app_mngr_); + } + } +} + void StateControllerImpl::on_event(const event_engine::MobileEvent& event) {} void StateControllerImpl::on_event(const event_engine::Event& event) { - using smart_objects::SmartObject; using event_engine::Event; + using smart_objects::SmartObject; using namespace hmi_apis; namespace FunctionID = hmi_apis::FunctionID; @@ -636,8 +718,9 @@ void StateControllerImpl::on_event(const event_engine::Event& event) { const SmartObject& message = event.smart_object(); const FunctionID::eType id = static_cast(event.id()); switch (id) { - case FunctionID::BasicCommunication_ActivateApp: { - OnActivateAppResponse(message); + case FunctionID::BasicCommunication_ActivateApp: + case FunctionID::BasicCommunication_CloseApplication: { + OnHMIResponse(message); break; } case FunctionID::BasicCommunication_OnAppActivated: { @@ -725,26 +808,82 @@ void StateControllerImpl::on_event(const event_engine::Event& event) { } } +void StateControllerImpl::ActivateDefaultWindow(ApplicationSharedPtr app) { + LOG4CXX_AUTO_TRACE(logger_); + using namespace mobile_apis; + + const WindowID window_id = PredefinedWindows::DEFAULT_WINDOW; + const HMILevel::eType hmi_level = HMILevel::HMI_FULL; + const AudioStreamingState::eType audio_state = + app->IsAudioApplication() ? AudioStreamingState::AUDIBLE + : AudioStreamingState::NOT_AUDIBLE; + const VideoStreamingState::eType video_state = + app->IsVideoApplication() ? VideoStreamingState::STREAMABLE + : VideoStreamingState::NOT_STREAMABLE; + + SetRegularState(app, window_id, hmi_level, audio_state, video_state, false); + + // After main window activation, streaming state should be updated for another + // windows of the app + HmiStatePtr new_state = + app->RegularHmiState(PredefinedWindows::DEFAULT_WINDOW); + UpdateAppWindowsStreamingState(app, new_state); +} + +void StateControllerImpl::ExitDefaultWindow(ApplicationSharedPtr app) { + LOG4CXX_AUTO_TRACE(logger_); + using namespace mobile_apis; + + const WindowID window_id = PredefinedWindows::DEFAULT_WINDOW; + const HMILevel::eType hmi_level = HMILevel::HMI_NONE; + const AudioStreamingState::eType audio_state = + AudioStreamingState::NOT_AUDIBLE; + const VideoStreamingState::eType video_state = + VideoStreamingState::NOT_STREAMABLE; + + SetRegularState(app, window_id, hmi_level, audio_state, video_state, false); + + // After main window exiting, streaming state should be updated for another + // windows of the app + HmiStatePtr new_state = + app->RegularHmiState(PredefinedWindows::DEFAULT_WINDOW); + UpdateAppWindowsStreamingState(app, new_state); +} + void StateControllerImpl::OnStateChanged(ApplicationSharedPtr app, + const WindowID window_id, HmiStatePtr old_state, HmiStatePtr new_state) { LOG4CXX_AUTO_TRACE(logger_); DCHECK_OR_RETURN_VOID(app); DCHECK_OR_RETURN_VOID(old_state); DCHECK_OR_RETURN_VOID(new_state); - LOG4CXX_DEBUG(logger_, "Old state: " << *old_state); - LOG4CXX_DEBUG(logger_, "New state: " << *new_state); - if (IsStateChanged(*old_state, *new_state)) { - app_mngr_.SendHMIStatusNotification(app); - if (new_state->hmi_level() == mobile_apis::HMILevel::HMI_NONE) { - app->ResetDataInNone(); - } - app_mngr_.OnHMILevelChanged( - app->app_id(), old_state->hmi_level(), new_state->hmi_level()); - app->usage_report().RecordHmiStateChanged(new_state->hmi_level()); - } else { - LOG4CXX_ERROR(logger_, "State has NOT been changed."); + LOG4CXX_DEBUG(logger_, + "Window #" << window_id << " old state: " << *old_state); + LOG4CXX_DEBUG(logger_, + "Window #" << window_id << " new state: " << *new_state); + + if (!IsStateChanged(*old_state, *new_state)) { + LOG4CXX_DEBUG(logger_, "State has NOT been changed."); + return; + } + + MessageHelper::SendHMIStatusNotification(app, window_id, app_mngr_); + + if (mobile_apis::PredefinedWindows::DEFAULT_WINDOW != window_id) { + LOG4CXX_DEBUG(logger_, + "State was changed not for a main application window. No " + "additional actions required"); + return; } + + if (new_state->hmi_level() == mobile_apis::HMILevel::HMI_NONE) { + app->ResetDataInNone(); + } + + app_mngr_.OnHMILevelChanged( + app->app_id(), old_state->hmi_level(), new_state->hmi_level()); + app->usage_report().RecordHmiStateChanged(new_state->hmi_level()); } bool StateControllerImpl::IsTempStateActive(HmiState::StateID id) const { @@ -755,6 +894,20 @@ bool StateControllerImpl::IsTempStateActive(HmiState::StateID id) const { void StateControllerImpl::OnApplicationRegistered( ApplicationSharedPtr app, const mobile_apis::HMILevel::eType default_level) { + LOG4CXX_AUTO_TRACE(logger_); + + // After app registration HMI level should be set for DEFAUL_WINDOW only + OnAppWindowAdded(app, + mobile_apis::PredefinedWindows::DEFAULT_WINDOW, + mobile_apis::WindowType::MAIN, + default_level); +} + +void StateControllerImpl::OnAppWindowAdded( + ApplicationSharedPtr app, + const WindowID window_id, + const mobile_apis::WindowType::eType window_type, + const mobile_apis::HMILevel::eType default_level) { namespace HMILevel = mobile_apis::HMILevel; namespace AudioStreamingState = mobile_apis::AudioStreamingState; namespace SystemContext = mobile_apis::SystemContext; @@ -768,9 +921,10 @@ void StateControllerImpl::OnApplicationRegistered( DCHECK_OR_RETURN_VOID(new_state); DCHECK_OR_RETURN_VOID(new_state->state_id() != HmiState::STATE_ID_REGULAR); - HmiStatePtr old_hmi_state = app->CurrentHmiState(); + HmiStatePtr old_hmi_state = app->CurrentHmiState(window_id); new_state->set_parent(old_hmi_state); - app->AddHMIState(new_state); + new_state->set_window_type(old_hmi_state->window_type()); + app->AddHMIState(window_id, new_state); } } @@ -781,50 +935,57 @@ void StateControllerImpl::OnApplicationRegistered( default_state->set_audio_streaming_state(CalcAudioState(app, default_level)); default_state->set_video_streaming_state(CalcVideoState(app, default_level)); default_state->set_system_context(SystemContext::SYSCTXT_MAIN); + default_state->set_window_type(window_type); - HmiStatePtr initial_state = app->RegularHmiState(); + HmiStatePtr initial_state = app->RegularHmiState(window_id); - app->SetRegularState(default_state); + app->SetRegularState(window_id, default_state); - HmiStatePtr new_state = app->CurrentHmiState(); + HmiStatePtr new_state = app->CurrentHmiState(window_id); - OnStateChanged(app, initial_state, new_state); + OnStateChanged(app, window_id, initial_state, new_state); } -int64_t StateControllerImpl::SendBCActivateApp( +int64_t StateControllerImpl::RequestHMIStateChange( ApplicationConstSharedPtr app, hmi_apis::Common_HMILevel::eType level, bool send_policy_priority) { LOG4CXX_AUTO_TRACE(logger_); - smart_objects::SmartObjectSPtr bc_activate_app_request = - MessageHelper::GetBCActivateAppRequestToHMI( - app, - app_mngr_.connection_handler().get_session_observer(), - app_mngr_.GetPolicyHandler(), - level, - send_policy_priority, - app_mngr_); - if (!bc_activate_app_request) { - LOG4CXX_ERROR(logger_, "Unable to create BC.ActivateAppRequest"); + smart_objects::SmartObjectSPtr request = NULL; + if (hmi_apis::Common_HMILevel::NONE == level) { + request = MessageHelper::GetBCCloseApplicationRequestToHMI(app, app_mngr_); + } else { + request = MessageHelper::GetBCActivateAppRequestToHMI( + app, + app_mngr_.GetPolicyHandler(), + level, + send_policy_priority, + app_mngr_); + } + if (!request) { + LOG4CXX_ERROR(logger_, "Unable to create request"); return -1; } - if (!app_mngr_.GetRPCService().ManageHMICommand(bc_activate_app_request)) { - LOG4CXX_ERROR(logger_, "Unable to send BC.ActivateAppRequest"); + if (!app_mngr_.GetRPCService().ManageHMICommand(request)) { + LOG4CXX_ERROR(logger_, "Unable to send request"); return -1; } - const int64_t corr_id = - (*bc_activate_app_request)[strings::params][strings::correlation_id] - .asInt(); - return corr_id; + const uint32_t corr_id = + (*request)[strings::params][strings::correlation_id].asUInt(); + return static_cast(corr_id); } void StateControllerImpl::ApplyPostponedStateForApp(ApplicationSharedPtr app) { LOG4CXX_AUTO_TRACE(logger_); - HmiStatePtr state = app->PostponedHmiState(); - if (state) { - app->RemovePostponedState(); - state->set_state_id(HmiState::STATE_ID_REGULAR); - SetRegularState(app, state); + const WindowIds window_ids = app->GetWindowIds(); + + for (const auto& window_id : window_ids) { + HmiStatePtr state = app->PostponedHmiState(window_id); + if (state) { + app->RemovePostponedState(window_id); + state->set_state_id(HmiState::STATE_ID_REGULAR); + SetRegularState(app, window_id, state); + } } } @@ -852,16 +1013,19 @@ void StateControllerImpl::TempStateStopped(HmiState::StateID ID) { std::mem_fun(&StateControllerImpl::ApplyPostponedStateForApp), this)); } -void StateControllerImpl::DeactivateApp(ApplicationSharedPtr app) { +void StateControllerImpl::DeactivateApp(ApplicationSharedPtr app, + const WindowID window_id) { using namespace mobile_apis; LOG4CXX_AUTO_TRACE(logger_); DCHECK_OR_RETURN_VOID(app); - const HmiStatePtr regular = app->RegularHmiState(); + const HmiStatePtr regular = app->RegularHmiState(window_id); DCHECK_OR_RETURN_VOID(regular); HmiStatePtr new_regular = std::make_shared(*regular); - LOG4CXX_DEBUG(logger_, "Current HMI level: '" << app->hmi_level() << "'"); + LOG4CXX_DEBUG(logger_, + "Window #" << window_id << " current HMI level: '" + << app->hmi_level(window_id) << "'"); const bool is_audio_app = app->IsAudioApplication(); const bool is_video_app = app->IsVideoApplication(); @@ -887,23 +1051,25 @@ void StateControllerImpl::DeactivateApp(ApplicationSharedPtr app) { new_regular->set_video_streaming_state(VideoStreamingState::NOT_STREAMABLE); } - SetRegularState(app, new_regular, false); + SetRegularState(app, window_id, new_regular, false); } -void StateControllerImpl::OnActivateAppResponse( +void StateControllerImpl::OnHMIResponse( const smart_objects::SmartObject& message) { const hmi_apis::Common_Result::eType code = static_cast( message[strings::params][hmi_response::code].asInt()); - const int32_t correlation_id = - message[strings::params][strings::correlation_id].asInt(); + const uint32_t correlation_id = + message[strings::params][strings::correlation_id].asUInt(); const uint32_t hmi_app_id = app_mngr_.application_id(correlation_id); ApplicationSharedPtr application = app_mngr_.application_by_hmi_app(hmi_app_id); if (application && hmi_apis::Common_Result::SUCCESS == code) { - HmiStatePtr pending_state = waiting_for_activate_[application->app_id()]; + HmiStatePtr pending_state = waiting_for_response_[application->app_id()]; DCHECK_OR_RETURN_VOID(pending_state); - ApplyRegularState(application, pending_state); + ApplyRegularState(application, + mobile_apis::PredefinedWindows::DEFAULT_WINDOW, + pending_state); } } @@ -919,7 +1085,33 @@ void StateControllerImpl::OnAppActivated( return; } - SetRegularState(app, HMILevel::HMI_FULL, true); + WindowID window_id = mobile_apis::PredefinedWindows::DEFAULT_WINDOW; + if (message[strings::msg_params].keyExists(strings::window_id)) { + window_id = message[strings::msg_params][strings::window_id].asInt(); + } + + const auto window_ids = app->GetWindowIds(); + if (!helpers::in_range(window_ids, window_id)) { + LOG4CXX_ERROR( + logger_, + "Application " << app_id << " does not contain window #" << window_id); + return; + } + + if (PredefinedWindows::DEFAULT_WINDOW != window_id) { + const auto window_hmi_level = app->hmi_level(window_id); + const HMILevel::eType new_hmi_level = HMILevel::HMI_NONE == window_hmi_level + ? HMILevel::HMI_BACKGROUND + : HMILevel::HMI_FULL; + const AudioStreamingState::eType audio_state = app->audio_streaming_state(); + const VideoStreamingState::eType video_state = app->video_streaming_state(); + + SetRegularState( + app, window_id, new_hmi_level, audio_state, video_state, false); + return; + } + + SetRegularState(app, window_id, HMILevel::HMI_FULL, true); } void StateControllerImpl::OnAppDeactivated( @@ -934,13 +1126,39 @@ void StateControllerImpl::OnAppDeactivated( return; } - if (HMILevel::HMI_FULL != app->hmi_level()) { + WindowID window_id = mobile_apis::PredefinedWindows::DEFAULT_WINDOW; + if (message[strings::msg_params].keyExists(strings::window_id)) { + window_id = message[strings::msg_params][strings::window_id].asInt(); + } + + const auto window_ids = app->GetWindowIds(); + if (!helpers::in_range(window_ids, window_id)) { + LOG4CXX_ERROR( + logger_, + "Application " << app_id << " does not contain window #" << window_id); + return; + } + + const auto window_hmi_level = app->hmi_level(window_id); + if (PredefinedWindows::DEFAULT_WINDOW != window_id) { + const HMILevel::eType new_hmi_level = HMILevel::HMI_FULL == window_hmi_level + ? HMILevel::HMI_BACKGROUND + : HMILevel::HMI_NONE; + const AudioStreamingState::eType audio_state = app->audio_streaming_state(); + const VideoStreamingState::eType video_state = app->video_streaming_state(); + + SetRegularState( + app, window_id, new_hmi_level, audio_state, video_state, false); + return; + } + + if (HMILevel::HMI_FULL != window_hmi_level) { return; } // TODO(AOleynik): Need to delete DeactivateReason and modify OnAppDeactivated // when HMI will support that, otherwise won't be testable - DeactivateApp(app); + DeactivateApp(app, window_id); } void StateControllerImpl::OnVideoStreamingStarted( diff --git a/src/components/application_manager/src/system_time/system_time_handler_impl.cc b/src/components/application_manager/src/system_time/system_time_handler_impl.cc index f5d08a8ebfd..deb92d5d812 100644 --- a/src/components/application_manager/src/system_time/system_time_handler_impl.cc +++ b/src/components/application_manager/src/system_time/system_time_handler_impl.cc @@ -82,6 +82,13 @@ void SystemTimeHandlerImpl::DoSubscribe(utils::SystemTimeListener* listener) { system_time_listener_ = listener; } +void SystemTimeHandlerImpl::ResetPendingSystemTimeRequests() { + LOG4CXX_AUTO_TRACE(logger_); + unsubscribe_from_event( + hmi_apis::FunctionID::BasicCommunication_GetSystemTime); + awaiting_get_system_time_ = false; +} + void SystemTimeHandlerImpl::DoUnsubscribe(utils::SystemTimeListener* listener) { LOG4CXX_AUTO_TRACE(logger_); sync_primitives::AutoLock lock(system_time_listener_lock_); @@ -145,6 +152,14 @@ void SystemTimeHandlerImpl::ProcessSystemTimeResponse( const application_manager::event_engine::Event& event) { LOG4CXX_AUTO_TRACE(logger_); const smart_objects::SmartObject& message = event.smart_object(); + + const auto result = static_cast( + message[strings::params][hmi_response::code].asInt()); + + if (hmi_apis::Common_Result::SUCCESS != result) { + system_time_listener_->OnSystemTimeFailed(); + } + const smart_objects::SmartObject& system_time_so = message[strings::msg_params][hmi_response::system_time]; diff --git a/src/components/application_manager/src/usage_statistics.cc b/src/components/application_manager/src/usage_statistics.cc index 1cfccd816e3..3f1831f449e 100644 --- a/src/components/application_manager/src/usage_statistics.cc +++ b/src/components/application_manager/src/usage_statistics.cc @@ -31,9 +31,9 @@ */ #include "application_manager/usage_statistics.h" -#include "smart_objects/smart_object.h" -#include "smart_objects/enum_schema_item.h" #include "policy/usage_statistics/statistics_manager.h" +#include "smart_objects/enum_schema_item.h" +#include "smart_objects/smart_object.h" #include "utils/macro.h" using namespace mobile_apis; diff --git a/src/components/application_manager/test/CMakeLists.txt b/src/components/application_manager/test/CMakeLists.txt index 4851a6b37ed..f6146f96f93 100755 --- a/src/components/application_manager/test/CMakeLists.txt +++ b/src/components/application_manager/test/CMakeLists.txt @@ -46,6 +46,7 @@ include_directories( ${COMPONENTS_DIR}/security_manager/include/ ${COMPONENTS_DIR}/application_manager/test/include/ ${COMPONENTS_DIR}/application_manager/rpc_plugins/sdl_rpc_plugin/include/ + ${COMPONENTS_DIR}/application_manager/rpc_plugins/vehicle_info_plugin/include/ ${BSON_INCLUDE_DIRECTORY} ) @@ -56,6 +57,7 @@ set(testSources ${AM_TEST_DIR}/request_info_test.cc ${AM_TEST_DIR}/resumption_sql_queries_test.cc ${AM_TEST_DIR}/event_engine_test.cc + ${AM_TEST_DIR}/mobile_event_engine_test.cc ${AM_TEST_DIR}/policy_event_observer_test.cc ${AM_TEST_DIR}/application_impl_test.cc ${AM_TEST_DIR}/hmi_capabilities_test.cc @@ -64,6 +66,7 @@ set(testSources ${AM_TEST_DIR}/usage_statistics_test.cc ${AM_TEST_DIR}/policy_handler_test.cc ${AM_TEST_DIR}/app_service_manager_test.cc + ${AM_TEST_DIR}/rpc_passing_handler_test.cc ${AM_TEST_DIR}/application_manager_impl_test.cc ${AM_TEST_DIR}/application_helper_test.cc ${AM_TEST_DIR}/command_holder_test.cc @@ -86,7 +89,7 @@ set (RequestController_SOURCES set(LIBRARIES Utils ApplicationManager - sdl_rpc_plugin + sdl_rpc_plugin_static jsoncpp Policy connectionHandler @@ -152,6 +155,7 @@ set(ResumptionData_SOURCES file(COPY hmi_capabilities.json DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) file(COPY hmi_capabilities_sc1.json DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) file(COPY hmi_capabilities_sc2.json DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) +file(COPY hmi_capabilities_old_apt.json DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) file(COPY smartDeviceLink_test.ini DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/resumption) diff --git a/src/components/application_manager/test/app_launch/app_launch_ctrl_test.cc b/src/components/application_manager/test/app_launch/app_launch_ctrl_test.cc index 3293a8908d0..b3bb8dd705e 100644 --- a/src/components/application_manager/test/app_launch/app_launch_ctrl_test.cc +++ b/src/components/application_manager/test/app_launch/app_launch_ctrl_test.cc @@ -30,16 +30,16 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include "gtest/gtest.h" #include -#include "utils/macro.h" #include "application_manager/app_launch/app_launch_ctrl_impl.h" #include "application_manager/mock_app_launch_data.h" #include "application_manager/mock_app_launch_settings.h" -#include "application_manager/mock_resume_ctrl.h" #include "application_manager/mock_application.h" #include "application_manager/mock_application_manager.h" +#include "application_manager/mock_resume_ctrl.h" #include "connection_handler/mock_connection_handler.h" +#include "gtest/gtest.h" +#include "utils/macro.h" #include "utils/test_async_waiter.h" @@ -47,14 +47,14 @@ namespace test { namespace components { namespace app_launch_test { +using ::testing::AtLeast; +using ::testing::DoAll; +using ::testing::InSequence; +using ::testing::Invoke; +using ::testing::NiceMock; using ::testing::Return; using ::testing::ReturnRef; using ::testing::Truly; -using ::testing::NiceMock; -using ::testing::Invoke; -using ::testing::AtLeast; -using ::testing::InSequence; -using ::testing::DoAll; namespace ch_test = test::components::connection_handler_test; namespace am_test = test::components::application_manager_test; diff --git a/src/components/application_manager/test/app_launch/app_launch_data_db_test.cc b/src/components/application_manager/test/app_launch/app_launch_data_db_test.cc index dc96fcf176e..d0f2e21f4cd 100644 --- a/src/components/application_manager/test/app_launch/app_launch_data_db_test.cc +++ b/src/components/application_manager/test/app_launch/app_launch_data_db_test.cc @@ -31,18 +31,18 @@ */ #include +#include #include #include -#include #include "gtest/gtest.h" -#include "utils/macro.h" #include "sql_database.h" #include "sql_query.h" +#include "utils/macro.h" -#include "utils/file_system.h" -#include "application_manager/mock_app_launch_settings.h" #include "application_manager/app_launch/app_launch_data_db.h" #include "application_manager/app_launch/app_launch_sql_queries.h" +#include "application_manager/mock_app_launch_settings.h" +#include "utils/file_system.h" namespace test { namespace components { @@ -51,9 +51,9 @@ namespace app_launch_test { using namespace file_system; using namespace app_launch; -using ::testing::ReturnRef; -using ::testing::Return; using ::testing::NiceMock; +using ::testing::Return; +using ::testing::ReturnRef; namespace { const std::string kEmptyString = ""; 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 4541970c704..12a375685ee 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 @@ -30,27 +30,27 @@ * POSSIBILITY OF SUCH DAMAGE. */ +#include "application_manager/app_launch/app_launch_data_json.h" #include -#include #include -#include "json/json.h" +#include +#include "application_manager/mock_app_launch_settings.h" +#include "application_manager/smart_object_keys.h" #include "gtest/gtest.h" -#include "utils/macro.h" -#include "utils/file_system.h" -#include "utils/date_time.h" +#include "json/json.h" #include "resumption/last_state_impl.h" #include "smart_objects/smart_object.h" -#include "application_manager/smart_object_keys.h" -#include "application_manager/mock_app_launch_settings.h" -#include "application_manager/app_launch/app_launch_data_json.h" +#include "utils/date_time.h" +#include "utils/file_system.h" +#include "utils/macro.h" namespace test { namespace components { namespace test_app_launch { using ::testing::_; -using ::testing::Return; using ::testing::NiceMock; +using ::testing::Return; namespace am = application_manager; using namespace Json; @@ -339,6 +339,6 @@ TEST_F(AppLaunchDataJsonTest, SelectMultipleData) { } } -} // namespace app_launch +} // namespace test_app_launch } // namespace components } // namespace test diff --git a/src/components/application_manager/test/app_service_manager_test.cc b/src/components/application_manager/test/app_service_manager_test.cc index 526bbbdb7d0..daabdeedf41 100644 --- a/src/components/application_manager/test/app_service_manager_test.cc +++ b/src/components/application_manager/test/app_service_manager_test.cc @@ -60,6 +60,7 @@ const std::string kServiceType = "MEDIA"; const std::string kServiceName = "service_name"; const std::string kServiceId = "service_id"; const std::string kPolicyAppId = "p_app_id"; +const std::string kPolicyAppId2 = "p_app_id2"; const uint32_t kConnectionKey = 43629; const uint32_t kHMIConnectionKey = 0; @@ -83,6 +84,7 @@ class AppServiceManagerTest : public testing::Test { public: AppServiceManagerTest() : mock_app_ptr_(new MockApplication) + , mock_app_ptr2_(new MockApplication) , app_service_manager_(mock_app_manager_, mock_last_state_) , mock_message_helper_( application_manager::MockMessageHelper::message_helper_mock()) { @@ -101,10 +103,15 @@ class AppServiceManagerTest : public testing::Test { .WillByDefault(ReturnRef(mock_settings_)); ON_CALL(*mock_app_ptr_, policy_app_id()) .WillByDefault(Return(kPolicyAppId)); + ON_CALL(*mock_app_ptr2_, policy_app_id()) + .WillByDefault(Return(kPolicyAppId2)); ON_CALL(mock_last_state_, get_dictionary()).WillByDefault(ReturnRef(dict_)); auto app_ptr = std::static_pointer_cast(mock_app_ptr_); + auto app_ptr2 = std::static_pointer_cast(mock_app_ptr2_); ON_CALL(mock_app_manager_, application(kConnectionKey)) .WillByDefault(Return(app_ptr)); + ON_CALL(mock_app_manager_, application(kConnectionKey + 1)) + .WillByDefault(Return(app_ptr2)); } protected: @@ -134,13 +141,15 @@ class AppServiceManagerTest : public testing::Test { BroadcastCapabilityUpdate( CapabilityUpdateMatcher( mobile_apis::ServiceUpdateReason::PUBLISHED), - _)).WillOnce(Return()); + _)) + .WillOnce(Return()); if (first_run) { EXPECT_CALL(*mock_message_helper_, BroadcastCapabilityUpdate( CapabilityUpdateMatcher( mobile_apis::ServiceUpdateReason::ACTIVATED), - _)).WillOnce(Return()); + _)) + .WillOnce(Return()); } bool mobile_service = connection_key != kHMIConnectionKey; return app_service_manager_.PublishAppService( @@ -153,16 +162,17 @@ class AppServiceManagerTest : public testing::Test { mobile_apis::ServiceUpdateReason::eType reason, bool published, bool active) { - smart_objects::SmartObject& services_updated = msg_params - [am::strings::system_capability][am::strings::app_services_capabilities] - [am::strings::app_services]; + smart_objects::SmartObject& services_updated = + msg_params[am::strings::system_capability] + [am::strings::app_services_capabilities] + [am::strings::app_services]; ASSERT_EQ(smart_objects::SmartType_Array, services_updated.getType()); EXPECT_EQ(length, services_updated.length()); for (size_t i = 0; i < services_updated.length(); i++) { smart_objects::SmartObject& service_cap = services_updated[i]; - if (service_id == - service_cap[am::strings::updated_app_service_record] - [am::strings::service_id].asString()) { + if (service_id == service_cap[am::strings::updated_app_service_record] + [am::strings::service_id] + .asString()) { CheckCapability(service_cap, service_id, reason, published, active); return; } @@ -189,6 +199,7 @@ class AppServiceManagerTest : public testing::Test { Json::Value dict_; std::vector embedded_services_; std::shared_ptr mock_app_ptr_; + std::shared_ptr mock_app_ptr2_; MockApplicationManager mock_app_manager_; resumption_test::MockLastState mock_last_state_; MockApplicationManagerSettings mock_settings_; @@ -208,14 +219,16 @@ TEST_F(AppServiceManagerTest, PublishAppService_Mobile_SUCCESS) { *mock_message_helper_, BroadcastCapabilityUpdate( CapabilityUpdateMatcher(mobile_apis::ServiceUpdateReason::PUBLISHED), - _)).WillOnce(DoAll(SaveArg<0>(&syscap_update_published), Return())); + _)) + .WillOnce(DoAll(SaveArg<0>(&syscap_update_published), Return())); smart_objects::SmartObject syscap_update_activated; EXPECT_CALL( *mock_message_helper_, BroadcastCapabilityUpdate( CapabilityUpdateMatcher(mobile_apis::ServiceUpdateReason::ACTIVATED), - _)).WillOnce(DoAll(SaveArg<0>(&syscap_update_activated), Return())); + _)) + .WillOnce(DoAll(SaveArg<0>(&syscap_update_activated), Return())); auto record = app_service_manager_.PublishAppService(manifest, true, kConnectionKey); @@ -255,14 +268,16 @@ TEST_F(AppServiceManagerTest, PublishAppService_HMI_SUCCESS) { *mock_message_helper_, BroadcastCapabilityUpdate( CapabilityUpdateMatcher(mobile_apis::ServiceUpdateReason::PUBLISHED), - _)).WillOnce(DoAll(SaveArg<0>(&syscap_update_published), Return())); + _)) + .WillOnce(DoAll(SaveArg<0>(&syscap_update_published), Return())); smart_objects::SmartObject syscap_update_activated; EXPECT_CALL( *mock_message_helper_, BroadcastCapabilityUpdate( CapabilityUpdateMatcher(mobile_apis::ServiceUpdateReason::ACTIVATED), - _)).WillOnce(DoAll(SaveArg<0>(&syscap_update_activated), Return())); + _)) + .WillOnce(DoAll(SaveArg<0>(&syscap_update_activated), Return())); auto record = app_service_manager_.PublishAppService(manifest, false); @@ -297,7 +312,8 @@ TEST_F(AppServiceManagerTest, UnpublishAppService_SUCCESS) { *mock_message_helper_, BroadcastCapabilityUpdate( CapabilityUpdateMatcher(mobile_apis::ServiceUpdateReason::REMOVED), - _)).WillOnce(DoAll(SaveArg<0>(&syscap_update_unpublished), Return())); + _)) + .WillOnce(DoAll(SaveArg<0>(&syscap_update_unpublished), Return())); std::string service_id = record[am::strings::service_id].asString(); EXPECT_TRUE(app_service_manager_.UnpublishAppService(service_id)); @@ -319,7 +335,8 @@ TEST_F(AppServiceManagerTest, ActivateAppService_AlreadyActivated) { *mock_message_helper_, BroadcastCapabilityUpdate( CapabilityUpdateMatcher(mobile_apis::ServiceUpdateReason::ACTIVATED), - _)).Times(0); + _)) + .Times(0); std::string service_id = record[am::strings::service_id].asString(); EXPECT_TRUE(app_service_manager_.ActivateAppService(service_id)); @@ -337,7 +354,8 @@ TEST_F(AppServiceManagerTest, ActivateAppService_TwoApps_SUCCESS) { *mock_message_helper_, BroadcastCapabilityUpdate( CapabilityUpdateMatcher(mobile_apis::ServiceUpdateReason::ACTIVATED), - _)).WillOnce(DoAll(SaveArg<0>(&syscap_update_activated), Return())); + _)) + .WillOnce(DoAll(SaveArg<0>(&syscap_update_activated), Return())); std::string service_id = record[am::strings::service_id].asString(); std::string service_id2 = record2[am::strings::service_id].asString(); diff --git a/src/components/application_manager/test/application_helper_test.cc b/src/components/application_manager/test/application_helper_test.cc index 3203839fc26..d9d590a171b 100644 --- a/src/components/application_manager/test/application_helper_test.cc +++ b/src/components/application_manager/test/application_helper_test.cc @@ -36,42 +36,42 @@ #include "application_manager/mock_application_manager_settings.h" #include "application_manager/mock_message_helper.h" -#include "policy/usage_statistics/mock_statistics_manager.h" #include "policy/mock_policy_settings.h" +#include "policy/usage_statistics/mock_statistics_manager.h" #include "application_manager/application.h" #include "application_manager/application_impl.h" #include "application_manager/application_manager_impl.h" -#include "application_manager/usage_statistics.h" #include "application_manager/helpers/application_helper.h" #include "application_manager/smart_object_keys.h" -#include "interfaces/MOBILE_API.h" +#include "application_manager/usage_statistics.h" #include "connection_handler/device.h" +#include "interfaces/MOBILE_API.h" #include "smart_objects/smart_object.h" #include "utils/custom_string.h" #include "utils/macro.h" -#include "test/resumption/mock_last_state.h" #include "media_manager/mock_media_manager.h" +#include "test/resumption/mock_last_state.h" namespace { const uint8_t expected_tread_pool_size = 2u; const uint8_t stop_streaming_timeout = 1u; const std::string kDirectoryName = "./test_storage"; const std::vector kTimeoutPrompt{"timeoutPrompt"}; -} +} // namespace namespace test { namespace components { namespace application_manager_test { +using resumption_test::MockLastState; +using test::components::media_manager_test::MockMediaManager; using testing::_; using ::testing::Mock; using ::testing::NiceMock; using ::testing::Return; using ::testing::ReturnRef; -using resumption_test::MockLastState; -using test::components::media_manager_test::MockMediaManager; using namespace application_manager; using namespace policy_handler_test; @@ -255,6 +255,6 @@ TEST_F(ApplicationHelperTest, RecallApplicationData_ExpectHMICleanupRequests) { application_manager::DeleteApplicationData(app_impl_, app_manager_impl_); } -} // application_manager_test -} // components -} // test +} // namespace application_manager_test +} // namespace components +} // namespace test diff --git a/src/components/application_manager/test/application_impl_test.cc b/src/components/application_manager/test/application_impl_test.cc index 437f567538e..7b45d387f7a 100644 --- a/src/components/application_manager/test/application_impl_test.cc +++ b/src/components/application_manager/test/application_impl_test.cc @@ -35,23 +35,23 @@ #include #include -#include "gtest/gtest.h" #include "application_manager/hmi_state.h" +#include "gtest/gtest.h" #include "utils/file_system.h" -#include "application_manager/mock_message_helper.h" -#include "utils/custom_string.h" +#include "application_manager/event_engine/event_dispatcher.h" #include "application_manager/mock_application_manager.h" #include "application_manager/mock_application_manager_settings.h" +#include "application_manager/mock_message_helper.h" #include "application_manager/mock_request_controller_settings.h" -#include "application_manager/event_engine/event_dispatcher.h" -#include "application_manager/state_controller.h" -#include "resumption/last_state.h" -#include "application_manager/resumption/resume_ctrl.h" -#include "application_manager/policies/mock_policy_handler_interface.h" #include "application_manager/mock_resume_ctrl.h" +#include "application_manager/policies/mock_policy_handler_interface.h" +#include "application_manager/resumption/resume_ctrl.h" +#include "application_manager/state_controller.h" #include "policy/usage_statistics/mock_statistics_manager.h" +#include "resumption/last_state.h" #include "smart_objects/smart_object.h" +#include "utils/custom_string.h" namespace test { namespace components { @@ -63,13 +63,20 @@ using namespace mobile_apis; namespace custom_str = utils::custom_string; using ::testing::_; +using ::testing::AtLeast; using ::testing::Mock; using ::testing::Return; using ::testing::ReturnRef; -using ::testing::AtLeast; using usage_statistics_test::MockStatisticsManager; -typedef void (ApplicationImpl::*AddSet)(HmiStatePtr args); +typedef void (ApplicationImpl::*AddSet)(const WindowID window_id, + HmiStatePtr args); + +namespace { +const WindowID kDefaultWindowId = + mobile_apis::PredefinedWindows::DEFAULT_WINDOW; +const std::string kDefaultWindowName = "DefaultName"; +} // namespace class ApplicationImplTest : public ::testing::Test { protected: @@ -91,9 +98,11 @@ class ApplicationImplTest : public ::testing::Test { EXPECT_CALL(mock_application_manager_settings_, app_storage_folder()) .WillRepeatedly(ReturnRef(directory_name)); EXPECT_CALL(mock_application_manager_settings_, - audio_data_stopped_timeout()).WillOnce(Return(0)); + audio_data_stopped_timeout()) + .WillOnce(Return(0)); EXPECT_CALL(mock_application_manager_settings_, - video_data_stopped_timeout()).WillOnce(Return(0)); + video_data_stopped_timeout()) + .WillOnce(Return(0)); app_impl.reset( new ApplicationImpl(app_id, policy_app_id, @@ -104,7 +113,8 @@ class ApplicationImplTest : public ::testing::Test { mock_application_manager_)); HmiStatePtr initial_state = CreateTestHmiState(); - app_impl->SetInitialState(initial_state); + app_impl->SetInitialState( + kDefaultWindowId, kDefaultWindowName, initial_state); } virtual void TearDown() OVERRIDE { @@ -157,12 +167,12 @@ HmiStatePtr ApplicationImplTest::TestAddHmiState(HMILevel::eType hmi_lvl, test_lvl = hmi_lvl; state_id = id_state; HmiStatePtr state = CreateTestHmiState(); - ((app_impl.get())->*hmi_action)(state); + ((app_impl.get())->*hmi_action)(kDefaultWindowId, state); return state; } void ApplicationImplTest::CheckCurrentHMIState() { - HmiStatePtr current_state = app_impl->CurrentHmiState(); + HmiStatePtr current_state = app_impl->CurrentHmiState(kDefaultWindowId); EXPECT_EQ(test_lvl, current_state->hmi_level()); EXPECT_EQ(state_id, current_state->state_id()); } @@ -205,7 +215,7 @@ TEST_F(ApplicationImplTest, AddStateAddRegularState_GetRegularState) { HmiState::STATE_ID_VIDEO_STREAMING, &ApplicationImpl::AddHMIState); - HmiStatePtr current_state = app_impl->RegularHmiState(); + HmiStatePtr current_state = app_impl->RegularHmiState(kDefaultWindowId); EXPECT_EQ(HMILevel::HMI_FULL, current_state->hmi_level()); EXPECT_EQ(HmiState::STATE_ID_REGULAR, current_state->state_id()); EXPECT_EQ(app_id, app_impl->app_id()); @@ -226,8 +236,8 @@ TEST_F(ApplicationImplTest, AddStates_RemoveLastState) { CheckCurrentHMIState(); // Remove last state - app_impl->RemoveHMIState(state3->state_id()); - HmiStatePtr current_state = app_impl->CurrentHmiState(); + app_impl->RemoveHMIState(kDefaultWindowId, state3->state_id()); + HmiStatePtr current_state = app_impl->CurrentHmiState(kDefaultWindowId); EXPECT_EQ(state2, current_state); EXPECT_EQ(HMILevel::HMI_NONE, current_state->hmi_level()); EXPECT_EQ(HmiState::STATE_ID_VIDEO_STREAMING, current_state->state_id()); @@ -247,8 +257,8 @@ TEST_F(ApplicationImplTest, AddStates_RemoveNotLastNotFirstState) { CheckCurrentHMIState(); // Remove not last state - app_impl->RemoveHMIState(state2->state_id()); - HmiStatePtr current_state = app_impl->CurrentHmiState(); + app_impl->RemoveHMIState(kDefaultWindowId, state2->state_id()); + HmiStatePtr current_state = app_impl->CurrentHmiState(kDefaultWindowId); EXPECT_EQ(state3, current_state); // HMI level is equal to parent hmi_level EXPECT_EQ(HMILevel::HMI_FULL, current_state->hmi_level()); @@ -270,8 +280,8 @@ TEST_F(ApplicationImplTest, AddStates_RemoveFirstState) { CheckCurrentHMIState(); // Remove first added state - app_impl->RemoveHMIState(state1->state_id()); - HmiStatePtr current_state = app_impl->CurrentHmiState(); + app_impl->RemoveHMIState(kDefaultWindowId, state1->state_id()); + HmiStatePtr current_state = app_impl->CurrentHmiState(kDefaultWindowId); EXPECT_EQ(state3, current_state); // Last state does not have a parent EXPECT_EQ(HMILevel::HMI_LIMITED, current_state->hmi_level()); @@ -293,8 +303,8 @@ TEST_F(ApplicationImplTest, SetRegularState_RemoveFirstState) { CheckCurrentHMIState(); // Remove first state - app_impl->RemoveHMIState(state1->state_id()); - HmiStatePtr current_state = app_impl->CurrentHmiState(); + app_impl->RemoveHMIState(kDefaultWindowId, state1->state_id()); + HmiStatePtr current_state = app_impl->CurrentHmiState(kDefaultWindowId); EXPECT_EQ(state3, current_state); // Last state has a parent EXPECT_EQ(HMILevel::HMI_FULL, current_state->hmi_level()); @@ -309,12 +319,12 @@ TEST_F(ApplicationImplTest, SetPostponedState_RemovePostponedState) { &ApplicationImpl::SetPostponedState); // Check that state was setted correctly - HmiStatePtr state2 = app_impl->PostponedHmiState(); + HmiStatePtr state2 = app_impl->PostponedHmiState(kDefaultWindowId); EXPECT_EQ(state1, state2); // Check that state was correctly removed - app_impl->RemovePostponedState(); - state2 = app_impl->PostponedHmiState(); + app_impl->RemovePostponedState(kDefaultWindowId); + state2 = app_impl->PostponedHmiState(kDefaultWindowId); EXPECT_EQ(nullptr, state2); } @@ -325,9 +335,9 @@ TEST_F(ApplicationImplTest, AddStateAddRegularState_GetHmiLvlAudioSystemState) { HmiState::STATE_ID_REGULAR, &ApplicationImpl::SetRegularState); - EXPECT_EQ(test_lvl, app_impl->hmi_level()); + EXPECT_EQ(test_lvl, app_impl->hmi_level(kDefaultWindowId)); EXPECT_EQ(audiostate, app_impl->audio_streaming_state()); - EXPECT_EQ(syst_context, app_impl->system_context()); + EXPECT_EQ(syst_context, app_impl->system_context(kDefaultWindowId)); audiostate = AudioStreamingState::AUDIBLE; syst_context = SystemContext::SYSCTXT_MENU; @@ -335,9 +345,9 @@ TEST_F(ApplicationImplTest, AddStateAddRegularState_GetHmiLvlAudioSystemState) { HmiState::STATE_ID_VIDEO_STREAMING, &ApplicationImpl::AddHMIState); - EXPECT_EQ(test_lvl, app_impl->hmi_level()); + EXPECT_EQ(test_lvl, app_impl->hmi_level(kDefaultWindowId)); EXPECT_EQ(audiostate, app_impl->audio_streaming_state()); - EXPECT_EQ(syst_context, app_impl->system_context()); + EXPECT_EQ(syst_context, app_impl->system_context(kDefaultWindowId)); } TEST_F(ApplicationImplTest, IsAudioApplication) { @@ -563,7 +573,9 @@ TEST_F(ApplicationImplTest, SubscribeToSoftButton_UnsubscribeFromSoftButton) { SoftButtonID test_button; for (uint i = 0; i < btn_count; i++) { - test_button.insert(i); + test_button.insert(std::make_pair( + i, + static_cast(mobile_apis::PredefinedWindows::DEFAULT_WINDOW))); } app_impl->SubscribeToSoftButtons(FunctionID::ScrollableMessageID, test_button); @@ -666,7 +678,8 @@ TEST_F(ApplicationImplTest, TEST_F(ApplicationImplTest, UpdateHash_AppMngrNotSuspended) { EXPECT_CALL(*MockMessageHelper::message_helper_mock(), - SendHashUpdateNotification(app_id, _)).Times(1); + SendHashUpdateNotification(app_id, _)) + .Times(1); resumprion_test::MockResumeCtrl mock_resume_ctrl; EXPECT_CALL(mock_application_manager_, resume_controller()) .WillOnce(ReturnRef(mock_resume_ctrl)); @@ -678,7 +691,8 @@ TEST_F(ApplicationImplTest, UpdateHash_AppMngrNotSuspended) { TEST_F(ApplicationImplTest, UpdateHash_AppMngrSuspended) { EXPECT_CALL(*MockMessageHelper::message_helper_mock(), - SendHashUpdateNotification(app_id, _)).Times(0); + SendHashUpdateNotification(app_id, _)) + .Times(0); resumprion_test::MockResumeCtrl mock_resume_ctrl; EXPECT_CALL(mock_application_manager_, resume_controller()) .WillOnce(ReturnRef(mock_resume_ctrl)); @@ -699,7 +713,8 @@ TEST_F(ApplicationImplTest, SetVideoConfig_MobileNavi_StreamingNotApproved) { TEST_F(ApplicationImplTest, SetVideoConfig_MobileNavi_StreamingApproved) { app_impl->set_video_streaming_approved(true); EXPECT_CALL(*MockMessageHelper::message_helper_mock(), - SendNaviSetVideoConfig(app_id, _, _)).Times(0); + SendNaviSetVideoConfig(app_id, _, _)) + .Times(0); smart_objects::SmartObject params; app_impl->SetVideoConfig(protocol_handler::ServiceType::kMobileNav, params); @@ -707,7 +722,8 @@ TEST_F(ApplicationImplTest, SetVideoConfig_MobileNavi_StreamingApproved) { TEST_F(ApplicationImplTest, SetVideoConfig_NotMobileNavi) { EXPECT_CALL(*MockMessageHelper::message_helper_mock(), - SendNaviSetVideoConfig(app_id, _, _)).Times(0); + SendNaviSetVideoConfig(app_id, _, _)) + .Times(0); smart_objects::SmartObject params; app_impl->SetVideoConfig(protocol_handler::ServiceType::kAudio, params); @@ -732,13 +748,15 @@ TEST_F(ApplicationImplTest, StartStreaming_Audio_StreamingNotApproved) { TEST_F(ApplicationImplTest, StartStreaming_StreamingApproved) { app_impl->set_video_streaming_approved(true); EXPECT_CALL(*MockMessageHelper::message_helper_mock(), - SendNaviStartStream(app_id, _)).Times(0); + SendNaviStartStream(app_id, _)) + .Times(0); app_impl->StartStreaming(protocol_handler::ServiceType::kMobileNav); app_impl->set_audio_streaming_approved(true); EXPECT_CALL(*MockMessageHelper::message_helper_mock(), - SendAudioStartStream(app_id, _)).Times(0); + SendAudioStartStream(app_id, _)) + .Times(0); app_impl->StartStreaming(protocol_handler::ServiceType::kAudio); } diff --git a/src/components/application_manager/test/application_manager_impl_mock_hmi_test.cc b/src/components/application_manager/test/application_manager_impl_mock_hmi_test.cc index 8ab852779a3..939ef986201 100644 --- a/src/components/application_manager/test/application_manager_impl_mock_hmi_test.cc +++ b/src/components/application_manager/test/application_manager_impl_mock_hmi_test.cc @@ -33,25 +33,25 @@ #include #include -#include "gtest/gtest.h" #include "application_manager/application.h" #include "application_manager/application_impl.h" #include "application_manager/application_manager_impl.h" +#include "gtest/gtest.h" #include "utils/custom_string.h" #include "encryption/hashing.h" #include "application_manager/mock_application_manager_settings.h" -#include "application_manager/mock_resumption_data.h" #include "application_manager/mock_command_factory.h" #include "application_manager/mock_request.h" +#include "application_manager/mock_resumption_data.h" +#include "application_manager/mock_rpc_plugin.h" +#include "application_manager/mock_rpc_plugin_manager.h" #include "connection_handler/mock_connection_handler.h" #include "policy/mock_policy_settings.h" #include "policy/usage_statistics/mock_statistics_manager.h" -#include "protocol_handler/mock_session_observer.h" #include "protocol_handler/mock_protocol_handler.h" -#include "application_manager/mock_rpc_plugin_manager.h" -#include "application_manager/mock_rpc_plugin.h" +#include "protocol_handler/mock_session_observer.h" #include "utils/optional.h" namespace test { @@ -63,9 +63,9 @@ namespace am = application_manager; using testing::_; using ::testing::DoAll; using ::testing::Mock; +using ::testing::NiceMock; using ::testing::Return; using ::testing::ReturnRef; -using ::testing::NiceMock; using ::testing::SetArgPointee; using namespace application_manager; @@ -269,6 +269,6 @@ TEST_F(ApplicationManagerImplMockHmiTest, Mock::VerifyAndClearExpectations(&mock_command_factory); } -} // application_manager_test +} // namespace application_manager_test } // namespace components } // namespace test 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 83e7717b7cb..152d577cdad 100644 --- a/src/components/application_manager/test/application_manager_impl_test.cc +++ b/src/components/application_manager/test/application_manager_impl_test.cc @@ -39,12 +39,14 @@ #include "application_manager/application.h" #include "application_manager/application_impl.h" #include "application_manager/application_manager_impl.h" +#include "application_manager/hmi_state.h" +#include "application_manager/mock_app_service_manager.h" #include "application_manager/mock_application.h" #include "application_manager/mock_application_manager_settings.h" #include "application_manager/mock_resumption_data.h" -#include "application_manager/mock_app_service_manager.h" #include "application_manager/mock_rpc_plugin_manager.h" #include "application_manager/mock_rpc_service.h" +#include "application_manager/mock_state_controller.h" #include "application_manager/policies/mock_policy_handler_interface.h" #include "application_manager/resumption/resume_ctrl_impl.h" #include "application_manager/test/include/application_manager/mock_message_helper.h" @@ -88,6 +90,9 @@ using ::testing::SaveArg; using ::testing::SetArgPointee; using ::testing::SetArgReferee; +using test::components::application_manager_test::MockStateController; +using test::components::policy_test::MockPolicyHandlerInterface; + using namespace application_manager; // custom action to call a member function with 4 arguments @@ -96,12 +101,21 @@ ACTION_P6(InvokeMemberFuncWithArg4, ptr, memberFunc, a, b, c, d) { } namespace { +const uint32_t kCorrelationID = 54321u; const std::string kDirectoryName = "./test_storage"; const uint32_t kTimeout = 10000u; connection_handler::DeviceHandle kDeviceId = 12345u; const std::string kAppId = "someID"; const uint32_t kConnectionKey = 1232u; const std::string kAppName = "appName"; +const WindowID kDefaultWindowId = + mobile_apis::PredefinedWindows::DEFAULT_WINDOW; + +typedef hmi_apis::Common_ServiceStatusUpdateReason::eType + ServiceStatusUpdateReason; +typedef hmi_apis::Common_ServiceType::eType ServiceType; +typedef hmi_apis::Common_ServiceEvent::eType ServiceEvent; +typedef utils::Optional UpdateReasonOptional; #if defined(CLOUD_APP_WEBSOCKET_TRANSPORT_SUPPORT) // Cloud application params @@ -117,7 +131,20 @@ const bool kEnabled = true; #endif // CLOUD_APP_WEBSOCKET_TRANSPORT_SUPPORT } // namespace -class ApplicationManagerImplTest : public ::testing::Test { +struct ServiceStatus { + ServiceType service_type_; + ServiceEvent service_event_; + UpdateReasonOptional reason_; + + ServiceStatus(ServiceType type, + ServiceEvent event, + UpdateReasonOptional reason) + : service_type_(type), service_event_(event), reason_(reason) {} +}; + +class ApplicationManagerImplTest + : public ::testing::Test, + public ::testing::WithParamInterface { public: ApplicationManagerImplTest() : app_id_(0u) @@ -125,12 +152,14 @@ class ApplicationManagerImplTest : public ::testing::Test { std::make_shared >( mock_app_mngr_)) , mock_rpc_service_(new MockRPCService) - , mock_policy_handler_( - new test::components::policy_test::MockPolicyHandlerInterface) + , mock_policy_handler_(new NiceMock) , mock_app_service_manager_( new MockAppServiceManager(mock_app_mngr_, mock_last_state_)) , mock_message_helper_( application_manager::MockMessageHelper::message_helper_mock()) + , mock_statistics_manager_( + std::make_shared< + NiceMock >()) { #ifdef ENABLE_LOG @@ -138,17 +167,35 @@ class ApplicationManagerImplTest : public ::testing::Test { #endif Mock::VerifyAndClearExpectations(mock_message_helper_); } - ~ApplicationManagerImplTest() { + ~ApplicationManagerImplTest() OVERRIDE { Mock::VerifyAndClearExpectations(mock_message_helper_); } protected: void SetUp() OVERRIDE { CreateAppManager(); + ON_CALL(mock_state_ctrl_, + SetRegularState(_, + mobile_apis::PredefinedWindows::DEFAULT_WINDOW, + mobile_apis::HMILevel::HMI_NONE, + true)); + ON_CALL(*mock_app_ptr_, app_id()).WillByDefault(Return(kConnectionKey)); + ON_CALL(*mock_app_ptr_, device()).WillByDefault(Return(kDeviceId)); + + HmiStatePtr hmi_state(std::make_shared( + mock_app_ptr_, mock_app_mngr_, HmiState::STATE_ID_REGULAR)); + + ON_CALL(*mock_app_ptr_, + RegularHmiState(mobile_apis::PredefinedWindows::DEFAULT_WINDOW)) + .WillByDefault(Return(hmi_state)); + ON_CALL(mock_session_observer_, GetDataOnSessionKey(_, _, _, _)) .WillByDefault(DoAll(SetArgPointee<3u>(kDeviceId), Return(0))); + ON_CALL(mock_connection_handler_, GetDataOnSessionKey(_, _, _, &kDeviceId)) + .WillByDefault(DoAll(SetArgPointee<3u>(app_id_), Return(0))); ON_CALL(mock_connection_handler_, get_session_observer()) .WillByDefault(ReturnRef(mock_session_observer_)); + app_manager_impl_->SetMockRPCService(mock_rpc_service_); app_manager_impl_->resume_controller().set_resumption_storage( mock_storage_); @@ -160,6 +207,16 @@ class ApplicationManagerImplTest : public ::testing::Test { app_manager_impl_->SetAppServiceManager(mock_app_service_manager_); Json::Value empty; ON_CALL(mock_last_state_, get_dictionary()).WillByDefault(ReturnRef(empty)); + + auto request = std::make_shared( + smart_objects::SmartType_Map); + ON_CALL(*mock_message_helper_, CreateModuleInfoSO(_, _)) + .WillByDefault(Return(request)); + ON_CALL(*mock_message_helper_, GetBCCloseApplicationRequestToHMI(_, _)) + .WillByDefault(Return(std::make_shared( + smart_objects::SmartType_Map))); + ON_CALL(*mock_policy_handler_, GetStatisticManager()) + .WillByDefault(Return(mock_statistics_manager_)); } void CreateAppManager() { @@ -179,16 +236,35 @@ class ApplicationManagerImplTest : public ::testing::Test { ON_CALL(mock_application_manager_settings_, default_timeout()) .WillByDefault(ReturnRef(kTimeout)); ON_CALL(mock_application_manager_settings_, - application_list_update_timeout()).WillByDefault(Return(kTimeout)); + application_list_update_timeout()) + .WillByDefault(Return(kTimeout)); app_manager_impl_.reset(new am::ApplicationManagerImpl( mock_application_manager_settings_, mock_policy_settings_)); - mock_app_ptr_ = std::shared_ptr(new MockApplication()); + mock_app_ptr_ = std::shared_ptr >( + new NiceMock()); app_manager_impl_->set_protocol_handler(&mock_protocol_handler_); + app_manager_impl_->SetMockPolicyHandler(mock_policy_handler_); ASSERT_TRUE(app_manager_impl_.get()); ASSERT_TRUE(mock_app_ptr_.get()); } + application_manager::commands::MessageSharedPtr CreateCloseAppMessage() { + using namespace application_manager; + + smart_objects::SmartObjectSPtr message = + std::make_shared( + smart_objects::SmartType_Map); + (*message)[application_manager::strings::params] + [application_manager::strings::function_id] = + hmi_apis::FunctionID::BasicCommunication_CloseApplication; + (*message)[strings::params][strings::message_type] = MessageType::kRequest; + (*message)[strings::params][strings::correlation_id] = kCorrelationID; + (*message)[strings::msg_params][strings::app_id] = kAppId; + + return message; + } + void AddMockApplication() { app_manager_impl_->AddMockApplication(mock_app_ptr_); } @@ -228,27 +304,101 @@ class ApplicationManagerImplTest : public ::testing::Test { #if defined(CLOUD_APP_WEBSOCKET_TRANSPORT_SUPPORT) void AddCloudAppToPendingDeviceMap(); + void CreatePendingApplication(); #endif uint32_t app_id_; NiceMock mock_policy_settings_; std::shared_ptr > mock_storage_; + MockStateController mock_state_ctrl_; MockRPCService* mock_rpc_service_; resumption_test::MockLastState mock_last_state_; NiceMock mock_connection_handler_; NiceMock mock_session_observer_; NiceMock mock_application_manager_settings_; - test::components::policy_test::MockPolicyHandlerInterface* - mock_policy_handler_; + NiceMock* mock_policy_handler_; application_manager_test::MockApplicationManager mock_app_mngr_; std::unique_ptr app_manager_impl_; MockAppServiceManager* mock_app_service_manager_; application_manager::MockMessageHelper* mock_message_helper_; - std::shared_ptr mock_app_ptr_; + std::shared_ptr > mock_app_ptr_; NiceMock mock_protocol_handler_; + std::shared_ptr > + mock_statistics_manager_; }; +INSTANTIATE_TEST_CASE_P( + ProcessServiceStatusUpdate_REQUEST_ACCEPTED, + ApplicationManagerImplTest, + ::testing::Values(ServiceStatus(ServiceType::AUDIO, + ServiceEvent::REQUEST_ACCEPTED, + UpdateReasonOptional::EMPTY), + ServiceStatus(ServiceType::VIDEO, + ServiceEvent::REQUEST_ACCEPTED, + UpdateReasonOptional::EMPTY), + ServiceStatus(ServiceType::RPC, + ServiceEvent::REQUEST_ACCEPTED, + UpdateReasonOptional::EMPTY))); + +INSTANTIATE_TEST_CASE_P( + ProcessServiceStatusUpdate_REQUEST_RECEIVED, + ApplicationManagerImplTest, + ::testing::Values(ServiceStatus(ServiceType::AUDIO, + ServiceEvent::REQUEST_RECEIVED, + UpdateReasonOptional::EMPTY), + ServiceStatus(ServiceType::VIDEO, + ServiceEvent::REQUEST_RECEIVED, + UpdateReasonOptional::EMPTY), + ServiceStatus(ServiceType::RPC, + ServiceEvent::REQUEST_RECEIVED, + UpdateReasonOptional::EMPTY))); + +INSTANTIATE_TEST_CASE_P( + ProcessServiceStatusUpdate_REQUEST_REJECTED, + ApplicationManagerImplTest, + ::testing::Values(ServiceStatus(ServiceType::AUDIO, + ServiceEvent::REQUEST_REJECTED, + UpdateReasonOptional::EMPTY), + ServiceStatus(ServiceType::VIDEO, + ServiceEvent::REQUEST_REJECTED, + UpdateReasonOptional::EMPTY), + ServiceStatus(ServiceType::RPC, + ServiceEvent::REQUEST_REJECTED, + UpdateReasonOptional::EMPTY))); + +TEST_P(ApplicationManagerImplTest, + ProcessServiceStatusUpdate_SendMessageToHMI) { + smart_objects::SmartObjectSPtr notification_ = + std::make_shared( + smart_objects::SmartType_Map); + (*notification_)[strings::msg_params][hmi_notification::service_type] = + GetParam().service_type_; + (*notification_)[strings::msg_params][hmi_notification::service_event] = + GetParam().service_event_; + (*notification_)[strings::msg_params][strings::app_id] = kConnectionKey; + + AddMockApplication(); + + ON_CALL(*mock_app_ptr_, app_id()).WillByDefault(Return(kConnectionKey)); + + auto close_message = CreateCloseAppMessage(); + ON_CALL(*mock_message_helper_, GetBCCloseApplicationRequestToHMI(_, _)) + .WillByDefault(Return(close_message)); + ON_CALL(*mock_message_helper_, CreateOnServiceUpdateNotification(_, _, _, _)) + .WillByDefault(Return(notification_)); + + ON_CALL(*mock_rpc_service_, ManageHMICommand(notification_, _)) + .WillByDefault(Return(true)); + ON_CALL(*mock_rpc_service_, ManageHMICommand(close_message, _)) + .WillByDefault(Return(true)); + + app_manager_impl_->ProcessServiceStatusUpdate(kConnectionKey, + GetParam().service_type_, + GetParam().service_event_, + GetParam().reason_); +} + TEST_F(ApplicationManagerImplTest, ProcessQueryApp_ExpectSuccess) { using namespace ns_smart_device_link::ns_smart_objects; SmartObject app_data; @@ -382,7 +532,7 @@ TEST_F(ApplicationManagerImplTest, OnServiceStartedCallback_VideoServiceStart) { const int32_t session_key = 123; EXPECT_CALL(*mock_app_ptr_, app_id()).WillRepeatedly(Return(session_key)); EXPECT_CALL(*mock_app_ptr_, is_navi()).WillRepeatedly(Return(true)); - EXPECT_CALL(*mock_app_ptr_, hmi_level()) + EXPECT_CALL(*mock_app_ptr_, hmi_level(kDefaultWindowId)) .WillRepeatedly(Return(mobile_apis::HMILevel::HMI_FULL)); bool result = false; @@ -413,7 +563,7 @@ TEST_F(ApplicationManagerImplTest, EXPECT_CALL(*mock_app_ptr_, app_id()).WillRepeatedly(Return(session_key)); // is_navi() is false EXPECT_CALL(*mock_app_ptr_, is_navi()).WillRepeatedly(Return(false)); - EXPECT_CALL(*mock_app_ptr_, hmi_level()) + EXPECT_CALL(*mock_app_ptr_, hmi_level(kDefaultWindowId)) .WillRepeatedly(Return(mobile_apis::HMILevel::HMI_FULL)); bool result = false; @@ -444,7 +594,7 @@ TEST_F(ApplicationManagerImplTest, EXPECT_CALL(*mock_app_ptr_, app_id()).WillRepeatedly(Return(session_key)); EXPECT_CALL(*mock_app_ptr_, is_navi()).WillRepeatedly(Return(true)); // HMI level is not FULL nor LIMITED - EXPECT_CALL(*mock_app_ptr_, hmi_level()) + EXPECT_CALL(*mock_app_ptr_, hmi_level(kDefaultWindowId)) .WillRepeatedly(Return(mobile_apis::HMILevel::HMI_BACKGROUND)); bool result = false; @@ -474,7 +624,7 @@ TEST_F(ApplicationManagerImplTest, const int32_t session_key = 123; EXPECT_CALL(*mock_app_ptr_, app_id()).WillRepeatedly(Return(session_key)); EXPECT_CALL(*mock_app_ptr_, is_navi()).WillRepeatedly(Return(true)); - EXPECT_CALL(*mock_app_ptr_, hmi_level()) + EXPECT_CALL(*mock_app_ptr_, hmi_level(kDefaultWindowId)) .WillRepeatedly(Return(mobile_apis::HMILevel::HMI_LIMITED)); bool result = false; @@ -558,7 +708,7 @@ TEST_F(ApplicationManagerImplTest, const int32_t session_key = 123; EXPECT_CALL(*mock_app_ptr_, app_id()).WillRepeatedly(Return(session_key)); EXPECT_CALL(*mock_app_ptr_, is_navi()).WillRepeatedly(Return(true)); - EXPECT_CALL(*mock_app_ptr_, hmi_level()) + EXPECT_CALL(*mock_app_ptr_, hmi_level(kDefaultWindowId)) .WillRepeatedly(Return(mobile_apis::HMILevel::HMI_FULL)); bool result = false; @@ -632,7 +782,7 @@ TEST_F(ApplicationManagerImplTest, const int32_t session_key = 123; EXPECT_CALL(*mock_app_ptr_, app_id()).WillRepeatedly(Return(session_key)); EXPECT_CALL(*mock_app_ptr_, is_navi()).WillRepeatedly(Return(true)); - EXPECT_CALL(*mock_app_ptr_, hmi_level()) + EXPECT_CALL(*mock_app_ptr_, hmi_level(kDefaultWindowId)) .WillRepeatedly(Return(mobile_apis::HMILevel::HMI_FULL)); bool result = false; @@ -667,7 +817,7 @@ TEST_F(ApplicationManagerImplTest, OnServiceStartedCallback_AudioServiceStart) { const int32_t session_key = 123; EXPECT_CALL(*mock_app_ptr_, app_id()).WillRepeatedly(Return(session_key)); EXPECT_CALL(*mock_app_ptr_, is_navi()).WillRepeatedly(Return(true)); - EXPECT_CALL(*mock_app_ptr_, hmi_level()) + EXPECT_CALL(*mock_app_ptr_, hmi_level(kDefaultWindowId)) .WillRepeatedly(Return(mobile_apis::HMILevel::HMI_FULL)); bool result = false; @@ -697,7 +847,7 @@ TEST_F(ApplicationManagerImplTest, const int32_t session_key = 123; EXPECT_CALL(*mock_app_ptr_, app_id()).WillRepeatedly(Return(session_key)); EXPECT_CALL(*mock_app_ptr_, is_navi()).WillRepeatedly(Return(true)); - EXPECT_CALL(*mock_app_ptr_, hmi_level()) + EXPECT_CALL(*mock_app_ptr_, hmi_level(kDefaultWindowId)) .WillRepeatedly(Return(mobile_apis::HMILevel::HMI_FULL)); bool result = false; @@ -818,6 +968,9 @@ TEST_F(ApplicationManagerImplTest, std::shared_ptr switching_app_ptr = std::make_shared(); + ON_CALL(*switching_app_ptr, app_id()).WillByDefault(Return(kConnectionKey)); + ON_CALL(*switching_app_ptr, device()).WillByDefault(Return(kDeviceId)); + const std::string switching_device_id = "switching"; const std::string switching_device_id_hash = encryption::MakeHash(switching_device_id); @@ -830,7 +983,7 @@ TEST_F(ApplicationManagerImplTest, .WillRepeatedly(Return(policy_app_id_switch)); const auto hmi_level_switching_app = mobile_apis::HMILevel::HMI_FULL; - EXPECT_CALL(*switching_app_ptr, hmi_level()) + EXPECT_CALL(*switching_app_ptr, hmi_level(kDefaultWindowId)) .WillRepeatedly(Return(hmi_level_switching_app)); std::shared_ptr nonswitching_app_ptr = @@ -848,7 +1001,7 @@ TEST_F(ApplicationManagerImplTest, .WillRepeatedly(Return(policy_app_id_nonswitch)); const auto hmi_level_nonswitching_app = mobile_apis::HMILevel::HMI_LIMITED; - EXPECT_CALL(*nonswitching_app_ptr, hmi_level()) + EXPECT_CALL(*nonswitching_app_ptr, hmi_level(kDefaultWindowId)) .WillRepeatedly(Return(hmi_level_nonswitching_app)); // Act @@ -866,15 +1019,18 @@ TEST_F(ApplicationManagerImplTest, .WillOnce(Return(smart_objects::SmartObjectSPtr())); app_manager_impl_->OnDeviceSwitchingStart(switching_device, non_switching_device); - EXPECT_TRUE(app_manager_impl_->IsAppInReconnectMode(policy_app_id_switch)); - EXPECT_FALSE( - app_manager_impl_->IsAppInReconnectMode(policy_app_id_nonswitch)); + EXPECT_TRUE( + app_manager_impl_->IsAppInReconnectMode(kDeviceId, policy_app_id_switch)); + EXPECT_FALSE(app_manager_impl_->IsAppInReconnectMode( + kDeviceId, policy_app_id_nonswitch)); } TEST_F(ApplicationManagerImplTest, OnDeviceSwitchingFinish_ExpectUnregisterAppsInWaitList) { std::shared_ptr switching_app_ptr = std::make_shared(); + ON_CALL(*switching_app_ptr, app_id()).WillByDefault(Return(kConnectionKey)); + ON_CALL(*switching_app_ptr, device()).WillByDefault(Return(kDeviceId)); plugin_manager::MockRPCPluginManager* mock_rpc_plugin_manager = new plugin_manager::MockRPCPluginManager; @@ -894,7 +1050,7 @@ TEST_F(ApplicationManagerImplTest, .WillRepeatedly(Return(policy_app_id_switch)); const auto hmi_level_switching_app = mobile_apis::HMILevel::HMI_FULL; - EXPECT_CALL(*switching_app_ptr, hmi_level()) + EXPECT_CALL(*switching_app_ptr, hmi_level(kDefaultWindowId)) .WillRepeatedly(Return(hmi_level_switching_app)); std::shared_ptr nonswitching_app_ptr = @@ -911,8 +1067,12 @@ TEST_F(ApplicationManagerImplTest, EXPECT_CALL(*nonswitching_app_ptr, policy_app_id()) .WillRepeatedly(Return(policy_app_id_nonswitch)); + ON_CALL(*nonswitching_app_ptr, protocol_version()) + .WillByDefault( + Return(protocol_handler::MajorProtocolVersion::PROTOCOL_VERSION_4)); + const auto hmi_level_nonswitching_app = mobile_apis::HMILevel::HMI_LIMITED; - EXPECT_CALL(*nonswitching_app_ptr, hmi_level()) + EXPECT_CALL(*nonswitching_app_ptr, hmi_level(kDefaultWindowId)) .WillRepeatedly(Return(hmi_level_nonswitching_app)); // Act @@ -931,7 +1091,8 @@ TEST_F(ApplicationManagerImplTest, app_manager_impl_->OnDeviceSwitchingStart(switching_device, non_switching_device); - EXPECT_TRUE(app_manager_impl_->IsAppInReconnectMode(policy_app_id_switch)); + EXPECT_TRUE( + app_manager_impl_->IsAppInReconnectMode(kDeviceId, policy_app_id_switch)); app_manager_impl_->OnDeviceSwitchingFinish(switching_device_id); EXPECT_FALSE( @@ -1010,6 +1171,15 @@ TEST_F(ApplicationManagerImplTest, StartStopAudioPassThru) { } } +TEST_F(ApplicationManagerImplTest, + StopApplicationManager_ExpectStopRPCService) { + EXPECT_CALL(*mock_policy_handler_, UnloadPolicyLibrary()); + + EXPECT_CALL(*mock_rpc_service_, Stop()); + + app_manager_impl_->Stop(); +} + TEST_F(ApplicationManagerImplTest, UnregisterAnotherAppDuringAudioPassThru) { std::string dummy_file_name; ON_CALL(mock_application_manager_settings_, recording_file_name()) @@ -1157,9 +1327,10 @@ bool ApplicationManagerImplTest::CheckResumptionRequiredTransportAvailableTest( TransportTypeProfileStringFromDeviceHandle(secondary_device_handle)) .WillOnce(Return(secondary_transport_device_string)); } else { - EXPECT_CALL(mock_session_observer_, - TransportTypeProfileStringFromDeviceHandle( - secondary_device_handle)).WillOnce(Return(std::string(""))); + EXPECT_CALL( + mock_session_observer_, + TransportTypeProfileStringFromDeviceHandle(secondary_device_handle)) + .WillOnce(Return(std::string(""))); } return app_manager_impl_->CheckResumptionRequiredTransportAvailable( @@ -1452,7 +1623,6 @@ TEST_F(ApplicationManagerImplTest, #if defined(CLOUD_APP_WEBSOCKET_TRANSPORT_SUPPORT) void ApplicationManagerImplTest::AddCloudAppToPendingDeviceMap() { - app_manager_impl_->SetMockPolicyHandler(mock_policy_handler_); std::vector enabled_apps{"1234"}; EXPECT_CALL(*mock_policy_handler_, GetEnabledCloudApps(_)) .WillOnce(SetArgReferee<0>(enabled_apps)); @@ -1474,8 +1644,7 @@ void ApplicationManagerImplTest::AddCloudAppToPendingDeviceMap() { app_manager_impl_->RefreshCloudAppInformation(); } -TEST_F(ApplicationManagerImplTest, CreatePendingApplication) { - // Add to pending device map. Calls refresh cloud app +void ApplicationManagerImplTest::CreatePendingApplication() { AddCloudAppToPendingDeviceMap(); // CreatePendingApplication @@ -1505,6 +1674,10 @@ TEST_F(ApplicationManagerImplTest, CreatePendingApplication) { EXPECT_EQ(1u, app_list.size()); } +TEST_F(ApplicationManagerImplTest, CreatePendingApplication) { + CreatePendingApplication(); +} + TEST_F(ApplicationManagerImplTest, SetPendingState) { AddCloudAppToPendingDeviceMap(); AddMockApplication(); @@ -1576,7 +1749,8 @@ TEST_F(ApplicationManagerImplTest, testing::An())) .WillOnce(DoAll(SetArgPointee<3u>(kDeviceId), Return(0))); EXPECT_CALL(*mock_rpc_service_, - ManageMobileCommand(_, commands::Command::SOURCE_SDL)).Times(0); + ManageMobileCommand(_, commands::Command::SOURCE_SDL)) + .Times(0); smart_objects::SmartObject request_for_registration( smart_objects::SmartType_Map); @@ -1663,6 +1837,61 @@ TEST_F(ApplicationManagerImplTest, app_manager_impl_->RegisterApplication(request_for_registration_ptr); EXPECT_EQ(0, application.use_count()); } + +TEST_F(ApplicationManagerImplTest, PolicyIDByIconUrl_Success) { + std::vector enabled_apps{"1234"}; + EXPECT_CALL(*mock_policy_handler_, GetEnabledCloudApps(_)) + .WillOnce(SetArgReferee<0>(enabled_apps)); + EXPECT_CALL(*mock_policy_handler_, GetCloudAppParameters(_, _, _, _, _, _, _)) + .WillOnce(DoAll(SetArgReferee<1>(kEnabled), + SetArgReferee<2>(kEndpoint2), + SetArgReferee<3>(kCertificate), + SetArgReferee<4>(kAuthToken), + SetArgReferee<5>(kTransportType), + SetArgReferee<6>(kHybridAppPreferenceStr), + Return(true))); + + std::vector nicknames{"CloudApp"}; + EXPECT_CALL(*mock_policy_handler_, GetInitialAppData(_, _, _)) + .WillOnce(DoAll(SetArgPointee<1>(nicknames), Return(true))); + + const std::string url = "https://www.fakeiconurl.com/icon.png"; + EXPECT_CALL(*mock_policy_handler_, GetIconUrl("1234")) + .WillRepeatedly(Return(url)); + + app_manager_impl_->RefreshCloudAppInformation(); + + std::string result = app_manager_impl_->PolicyIDByIconUrl(url); + EXPECT_EQ(result, "1234"); +} + +TEST_F(ApplicationManagerImplTest, SetIconFileFromSystemRequest_Success) { + CreatePendingApplication(); + Mock::VerifyAndClearExpectations(mock_message_helper_); + + file_system::CreateDirectory(kDirectoryName); + const std::string full_icon_path = kDirectoryName + "/1234"; + ASSERT_TRUE(file_system::CreateFile(full_icon_path)); + + const std::string url = "https://www.fakeiconurl.com/icon.png"; + EXPECT_CALL(*mock_policy_handler_, GetIconUrl("1234")) + .WillRepeatedly(Return(url)); + + smart_objects::SmartObject dummy_object(smart_objects::SmartType_Map); + smart_objects::SmartObjectSPtr sptr = + std::make_shared(dummy_object); + + EXPECT_CALL(*mock_message_helper_, + CreateModuleInfoSO( + hmi_apis::FunctionID::BasicCommunication_UpdateAppList, _)) + .WillOnce(Return(sptr)); + EXPECT_CALL(*mock_rpc_service_, ManageHMICommand(sptr, _)).Times(1); + EXPECT_CALL(mock_application_manager_settings_, app_icons_folder()) + .WillOnce(ReturnRef(kDirectoryName)); + app_manager_impl_->SetIconFileFromSystemRequest("1234"); + EXPECT_TRUE(file_system::RemoveDirectory(kDirectoryName, true)); +} + #endif // CLOUD_APP_WEBSOCKET_TRANSPORT_SUPPORT } // namespace application_manager_test } // namespace components diff --git a/src/components/application_manager/test/application_state_test.cc b/src/components/application_manager/test/application_state_test.cc index a0bfa2890fa..22d111f9264 100644 --- a/src/components/application_manager/test/application_state_test.cc +++ b/src/components/application_manager/test/application_state_test.cc @@ -31,15 +31,15 @@ */ #include "application_manager/application_state.h" -#include "gtest/gtest.h" +#include "application_manager/event_engine/event_dispatcher.h" #include "application_manager/hmi_state.h" -#include "application_manager/mock_application_manager.h" #include "application_manager/mock_application.h" -#include "application_manager/event_engine/event_dispatcher.h" -#include "resumption/last_state.h" +#include "application_manager/mock_application_manager.h" #include "application_manager/policies/policy_handler.h" -#include "application_manager/state_controller.h" #include "application_manager/resumption/resume_ctrl.h" +#include "application_manager/state_controller.h" +#include "gtest/gtest.h" +#include "resumption/last_state.h" namespace test { namespace components { @@ -50,6 +50,11 @@ using namespace mobile_apis; typedef HmiState::StateID StateID; namespace { + +const WindowID kDefaultWindowId = + mobile_apis::PredefinedWindows::DEFAULT_WINDOW; +const std::string kDefaultWindowName = "DefaultName"; + std::vector GenerateCurrentStates() { std::vector states; states.push_back(StateID::STATE_ID_PHONE_CALL); @@ -60,7 +65,7 @@ std::vector GenerateCurrentStates() { states.push_back(StateID::STATE_ID_DEACTIVATE_HMI); return states; } -} +} // namespace class ApplicationStateTest : public ::testing::Test { public: @@ -87,8 +92,8 @@ TEST_F(ApplicationStateTest, AddStates_GetCurrentStates) { static_cast >(mock_app_), app_mngr_, *new_state); - app_state.AddState(state); - EXPECT_EQ(state, app_state.GetState(current_id)); + app_state.AddState(kDefaultWindowId, state); + EXPECT_EQ(state, app_state.GetState(kDefaultWindowId, current_id)); } } @@ -99,16 +104,16 @@ TEST_F(ApplicationStateTest, AddStates_RemoveStates_GetCurrentState) { static_cast >(mock_app_), app_mngr_, *new_state); - app_state.AddState(state); + app_state.AddState(kDefaultWindowId, state); - HmiStatePtr curr_state = app_state.GetState(current_id); + HmiStatePtr curr_state = app_state.GetState(kDefaultWindowId, current_id); ASSERT_EQ(*new_state, curr_state->state_id()); } new_state = added_states_.end() - 1; while (new_state != added_states_.begin()) { - app_state.RemoveState(*new_state); - HmiStatePtr curr_state = app_state.GetState(current_id); + app_state.RemoveState(kDefaultWindowId, *new_state); + HmiStatePtr curr_state = app_state.GetState(kDefaultWindowId, current_id); --new_state; EXPECT_EQ(*new_state, curr_state->state_id()); } @@ -122,19 +127,20 @@ TEST_F(ApplicationStateTest, AddStatesAddPostponedState_GetPostponedState) { static_cast >(mock_app_), app_mngr_, *new_state); - app_state.AddState(state); + app_state.AddState(kDefaultWindowId, state); } // Postponed state wasn't added - HmiStatePtr get_postponed_id = app_state.GetState(postponed_id); + HmiStatePtr get_postponed_id = + app_state.GetState(kDefaultWindowId, postponed_id); EXPECT_EQ(nullptr, get_postponed_id); // Add posponed state HmiStatePtr state = std::make_shared( static_cast >(mock_app_), app_mngr_, postponed_id); - app_state.AddState(state); + app_state.AddState(kDefaultWindowId, state); // Postponed state exists - get_postponed_id = app_state.GetState(postponed_id); + get_postponed_id = app_state.GetState(kDefaultWindowId, postponed_id); EXPECT_EQ(state, get_postponed_id); } @@ -146,7 +152,7 @@ TEST_F(ApplicationStateTest, AddStates_GetRegularState) { app_mngr_, *new_state); state->set_hmi_level(HMILevel::HMI_FULL); - app_state.AddState(state); + app_state.AddState(kDefaultWindowId, state); ++new_state; // Add some other for (; new_state != added_states_.end(); ++new_state) { @@ -154,13 +160,14 @@ TEST_F(ApplicationStateTest, AddStates_GetRegularState) { static_cast >(mock_app_), app_mngr_, *new_state); - app_state.AddState(state); + app_state.AddState(kDefaultWindowId, state); state->set_hmi_level(HMILevel::HMI_LIMITED); } // Regular state will be the first added state new_state = added_states_.begin(); - HmiStatePtr reg_state = app_state.GetState(StateID::STATE_ID_REGULAR); + HmiStatePtr reg_state = + app_state.GetState(kDefaultWindowId, StateID::STATE_ID_REGULAR); EXPECT_EQ(*new_state, reg_state->state_id()); EXPECT_EQ(HMILevel::HMI_FULL, reg_state->hmi_level()); } @@ -171,7 +178,7 @@ TEST_F(ApplicationStateTest, AddRegularState_RemoveFirstState_GetRegularState) { static_cast >(mock_app_), app_mngr_, *new_state); - app_state.AddState(state); + app_state.AddState(kDefaultWindowId, state); ++new_state; // Add postponed state @@ -179,10 +186,10 @@ TEST_F(ApplicationStateTest, AddRegularState_RemoveFirstState_GetRegularState) { static_cast >(mock_app_), app_mngr_, postponed_id); - app_state.AddState(state); + app_state.AddState(kDefaultWindowId, state); // Make sure that the state was added - HmiStatePtr post_state = app_state.GetState(postponed_id); + HmiStatePtr post_state = app_state.GetState(kDefaultWindowId, postponed_id); ASSERT_EQ(state, post_state); for (; new_state != added_states_.end(); ++new_state) { @@ -190,19 +197,20 @@ TEST_F(ApplicationStateTest, AddRegularState_RemoveFirstState_GetRegularState) { static_cast >(mock_app_), app_mngr_, *new_state); - app_state.AddState(state); + app_state.AddState(kDefaultWindowId, state); } // Regular state will be the first added state new_state = added_states_.begin(); - HmiStatePtr reg_state = app_state.GetState(StateID::STATE_ID_REGULAR); + HmiStatePtr reg_state = + app_state.GetState(kDefaultWindowId, StateID::STATE_ID_REGULAR); ASSERT_EQ(*new_state, reg_state->state_id()); - app_state.RemoveState(*new_state); + app_state.RemoveState(kDefaultWindowId, *new_state); ++new_state; // Now regular state is the next state except postponed - reg_state = app_state.GetState(StateID::STATE_ID_REGULAR); + reg_state = app_state.GetState(kDefaultWindowId, StateID::STATE_ID_REGULAR); EXPECT_EQ(*new_state, reg_state->state_id()); } @@ -213,14 +221,14 @@ TEST_F(ApplicationStateTest, AddRegularState_PreviousStatePostponed) { static_cast >(mock_app_), app_mngr_, first_state); - app_state.AddState(state); + app_state.AddState(kDefaultWindowId, state); // Add postponed state state = std::make_shared( static_cast >(mock_app_), app_mngr_, postponed_id); - app_state.AddState(state); + app_state.AddState(kDefaultWindowId, state); // Add new postponed state std::shared_ptr mock_app_2(new MockApplication); @@ -228,21 +236,22 @@ TEST_F(ApplicationStateTest, AddRegularState_PreviousStatePostponed) { static_cast >(mock_app_), app_mngr_, postponed_id); - app_state.AddState(state); + app_state.AddState(kDefaultWindowId, state); // Add regular state state = std::make_shared( static_cast >(mock_app_), app_mngr_, StateID::STATE_ID_REGULAR); - app_state.AddState(state); + app_state.AddState(kDefaultWindowId, state); // Postponed state is the first - HmiStatePtr reg_state = app_state.GetState(StateID::STATE_ID_POSTPONED); + HmiStatePtr reg_state = + app_state.GetState(kDefaultWindowId, StateID::STATE_ID_POSTPONED); ASSERT_EQ(postponed_id, reg_state->state_id()); // Regular state is the second one - reg_state = app_state.GetState(StateID::STATE_ID_REGULAR); + reg_state = app_state.GetState(kDefaultWindowId, StateID::STATE_ID_REGULAR); EXPECT_EQ(StateID::STATE_ID_REGULAR, reg_state->state_id()); } @@ -253,12 +262,14 @@ TEST_F(ApplicationStateTest, InitState_GetRegularState) { app_mngr_, init_state); - app_state.InitState(state); + app_state.InitState(kDefaultWindowId, kDefaultWindowName, state); - HmiStatePtr reg_state = app_state.GetState(StateID::STATE_ID_REGULAR); + HmiStatePtr reg_state = + app_state.GetState(kDefaultWindowId, StateID::STATE_ID_REGULAR); EXPECT_EQ(state, reg_state); - HmiStatePtr curr_state = app_state.GetState(StateID::STATE_ID_CURRENT); + HmiStatePtr curr_state = + app_state.GetState(kDefaultWindowId, StateID::STATE_ID_CURRENT); EXPECT_EQ(state, curr_state); } @@ -271,23 +282,24 @@ TEST_F(ApplicationStateTest, AddPosponedState_DeletePosponedState) { init_state); state->set_hmi_level(mobile_apis::HMILevel::HMI_FULL); - app_state.InitState(state); + app_state.InitState(kDefaultWindowId, kDefaultWindowName, state); // Add postponed state state = std::make_shared( static_cast >(mock_app_), app_mngr_, postponed_id); - app_state.AddState(state); + app_state.AddState(kDefaultWindowId, state); // Make sure that state was added - HmiStatePtr get_postponed_state = app_state.GetState(postponed_id); + HmiStatePtr get_postponed_state = + app_state.GetState(kDefaultWindowId, postponed_id); ASSERT_EQ(state, get_postponed_state); // Remove postponed state - app_state.RemoveState(postponed_id); + app_state.RemoveState(kDefaultWindowId, postponed_id); - get_postponed_state = app_state.GetState(postponed_id); + get_postponed_state = app_state.GetState(kDefaultWindowId, postponed_id); EXPECT_EQ(nullptr, get_postponed_state); } @@ -298,13 +310,13 @@ TEST_F(ApplicationStateTest, static_cast >(mock_app_), app_mngr_, reg_state); - app_state.InitState(state); + app_state.InitState(kDefaultWindowId, kDefaultWindowName, state); // Try deleting regular state - app_state.RemoveState(reg_state); + app_state.RemoveState(kDefaultWindowId, reg_state); // Get regular state - HmiStatePtr get_reg_state = app_state.GetState(reg_state); + HmiStatePtr get_reg_state = app_state.GetState(kDefaultWindowId, reg_state); EXPECT_EQ(state, get_reg_state); } diff --git a/src/components/application_manager/test/command_holder_test.cc b/src/components/application_manager/test/command_holder_test.cc index 9496e379240..acde0bfd86f 100644 --- a/src/components/application_manager/test/command_holder_test.cc +++ b/src/components/application_manager/test/command_holder_test.cc @@ -36,8 +36,8 @@ #include "application_manager/commands/command.h" #include "smart_objects/smart_object.h" -#include "application_manager/mock_application_manager.h" #include "application_manager/mock_application.h" +#include "application_manager/mock_application_manager.h" #include "application_manager/mock_rpc_service.h" namespace test { @@ -80,8 +80,10 @@ class CommandHolderImplTest : public testing::Test { TEST_F(CommandHolderImplTest, HoldOne_ExpectReleaseOne) { am::CommandHolderImpl cmd_holder(mock_app_manager_); - cmd_holder.Suspend( - mock_app_ptr_, am::CommandHolder::CommandType::kHmiCommand, cmd_ptr_); + cmd_holder.Suspend(mock_app_ptr_, + am::CommandHolder::CommandType::kHmiCommand, + am::commands::Command::CommandSource::SOURCE_HMI, + cmd_ptr_); // Act EXPECT_CALL(mock_rpc_service_, ManageHMICommand(cmd_ptr_, _)); @@ -93,8 +95,10 @@ TEST_F(CommandHolderImplTest, HoldMany_ExpectReleaseSame) { int32_t iterations = 0; do { - cmd_holder.Suspend( - mock_app_ptr_, am::CommandHolder::CommandType::kHmiCommand, cmd_ptr_); + cmd_holder.Suspend(mock_app_ptr_, + am::CommandHolder::CommandType::kHmiCommand, + am::commands::Command::CommandSource::SOURCE_HMI, + cmd_ptr_); ++iterations; } while (iterations < 5); @@ -106,10 +110,14 @@ TEST_F(CommandHolderImplTest, HoldMany_ExpectReleaseSame) { TEST_F(CommandHolderImplTest, Hold_Drop_ExpectNoReleased) { am::CommandHolderImpl cmd_holder(mock_app_manager_); - cmd_holder.Suspend( - mock_app_ptr_, am::CommandHolder::CommandType::kHmiCommand, cmd_ptr_); - cmd_holder.Suspend( - mock_app_ptr_, am::CommandHolder::CommandType::kHmiCommand, cmd_ptr_); + cmd_holder.Suspend(mock_app_ptr_, + am::CommandHolder::CommandType::kHmiCommand, + am::commands::Command::CommandSource::SOURCE_HMI, + cmd_ptr_); + cmd_holder.Suspend(mock_app_ptr_, + am::CommandHolder::CommandType::kHmiCommand, + am::commands::Command::CommandSource::SOURCE_HMI, + cmd_ptr_); // Act cmd_holder.Clear(mock_app_ptr_); @@ -119,10 +127,14 @@ TEST_F(CommandHolderImplTest, Hold_Drop_ExpectNoReleased) { TEST_F(CommandHolderImplTest, Hold_ReleaseAnotherId_ExpectNoReleased) { am::CommandHolderImpl cmd_holder(mock_app_manager_); - cmd_holder.Suspend( - mock_app_ptr_, am::CommandHolder::CommandType::kHmiCommand, cmd_ptr_); - cmd_holder.Suspend( - mock_app_ptr_, am::CommandHolder::CommandType::kHmiCommand, cmd_ptr_); + cmd_holder.Suspend(mock_app_ptr_, + am::CommandHolder::CommandType::kHmiCommand, + am::commands::Command::CommandSource::SOURCE_HMI, + cmd_ptr_); + cmd_holder.Suspend(mock_app_ptr_, + am::CommandHolder::CommandType::kHmiCommand, + am::commands::Command::CommandSource::SOURCE_HMI, + cmd_ptr_); // Act std::shared_ptr another_app = @@ -137,8 +149,10 @@ TEST_F(CommandHolderImplTest, Hold_DropAnotherId_ExpectReleased) { int32_t iterations = 0; do { - cmd_holder.Suspend( - mock_app_ptr_, am::CommandHolder::CommandType::kHmiCommand, cmd_ptr_); + cmd_holder.Suspend(mock_app_ptr_, + am::CommandHolder::CommandType::kHmiCommand, + am::commands::Command::CommandSource::SOURCE_HMI, + cmd_ptr_); ++iterations; } while (iterations < 3); @@ -155,11 +169,15 @@ TEST_F(CommandHolderImplTest, Hold_DropAnotherId_ExpectReleased) { TEST_F(CommandHolderImplTest, Hold_Mobile_and_HMI_commands_ExpectReleased) { am::CommandHolderImpl cmd_holder(mock_app_manager_); - cmd_holder.Suspend( - mock_app_ptr_, am::CommandHolder::CommandType::kHmiCommand, cmd_ptr_); + cmd_holder.Suspend(mock_app_ptr_, + am::CommandHolder::CommandType::kHmiCommand, + am::commands::Command::CommandSource::SOURCE_HMI, + cmd_ptr_); - cmd_holder.Suspend( - mock_app_ptr_, am::CommandHolder::CommandType::kMobileCommand, cmd_ptr_); + cmd_holder.Suspend(mock_app_ptr_, + am::CommandHolder::CommandType::kMobileCommand, + am::commands::Command::CommandSource::SOURCE_MOBILE, + cmd_ptr_); // Act EXPECT_CALL(mock_rpc_service_, ManageHMICommand(cmd_ptr_, _)); @@ -173,6 +191,6 @@ TEST_F(CommandHolderImplTest, Hold_Mobile_and_HMI_commands_ExpectReleased) { am::CommandHolder::CommandType::kMobileCommand); } -} // application_manager_test -} // components -} // test +} // namespace application_manager_test +} // namespace components +} // namespace test diff --git a/src/components/application_manager/test/commands/CMakeLists.txt b/src/components/application_manager/test/commands/CMakeLists.txt index 556f3a50329..ec7f454c478 100644 --- a/src/components/application_manager/test/commands/CMakeLists.txt +++ b/src/components/application_manager/test/commands/CMakeLists.txt @@ -58,7 +58,7 @@ set(LIBRARIES connectionHandler ApplicationManager jsoncpp - Policy + PolicyStatic Resumption ) diff --git a/src/components/application_manager/test/commands/command_impl_test.cc b/src/components/application_manager/test/commands/command_impl_test.cc index 53e8534c2bf..734a7d91b81 100644 --- a/src/components/application_manager/test/commands/command_impl_test.cc +++ b/src/components/application_manager/test/commands/command_impl_test.cc @@ -31,35 +31,35 @@ */ #include -#include #include #include #include +#include #include "gtest/gtest.h" -#include "smart_objects/smart_object.h" -#include "application_manager/smart_object_keys.h" -#include "application_manager/commands/commands_test.h" +#include "application_manager/application_manager.h" #include "application_manager/commands/command.h" #include "application_manager/commands/command_impl.h" -#include "application_manager/application_manager.h" +#include "application_manager/commands/commands_test.h" #include "application_manager/mock_application.h" +#include "application_manager/smart_object_keys.h" +#include "smart_objects/smart_object.h" namespace test { namespace components { namespace commands_test { namespace command_impl { -using ::testing::Return; -using ::testing::AtLeast; using ::testing::_; +using ::testing::AtLeast; +using ::testing::Return; namespace strings = ::application_manager::strings; -using ::application_manager::commands::CommandImpl; using ::application_manager::ApplicationManager; -using ::application_manager::commands::MessageSharedPtr; using ::application_manager::ApplicationSharedPtr; +using ::application_manager::commands::CommandImpl; +using ::application_manager::commands::MessageSharedPtr; using ::test::components::application_manager_test::MockApplication; typedef std::shared_ptr MockAppPtr; @@ -82,8 +82,8 @@ class CommandImplTest : public CommandsTest { public: class UnwrappedCommandImpl : CommandImpl { public: - using CommandImpl::ReplaceMobileWithHMIAppId; using CommandImpl::ReplaceHMIWithMobileAppId; + using CommandImpl::ReplaceMobileWithHMIAppId; UnwrappedCommandImpl( const MessageSharedPtr& message, diff --git a/src/components/application_manager/test/commands/command_request_impl_test.cc b/src/components/application_manager/test/commands/command_request_impl_test.cc index 6d80a114405..86dba1c5ac8 100644 --- a/src/components/application_manager/test/commands/command_request_impl_test.cc +++ b/src/components/application_manager/test/commands/command_request_impl_test.cc @@ -31,25 +31,25 @@ */ #include -#include #include +#include -#include "gtest/gtest.h" #include "application_manager/commands/command_impl.h" #include "application_manager/commands/command_request_impl.h" -#include "application_manager/commands/commands_test.h" #include "application_manager/commands/command_request_test.h" +#include "application_manager/commands/commands_test.h" +#include "gtest/gtest.h" #include "utils/lock.h" -#include "utils/data_accessor.h" -#include "smart_objects/smart_object.h" -#include "application_manager/smart_object_keys.h" #include "application_manager/application_manager.h" -#include "application_manager/mock_application.h" #include "application_manager/event_engine/event.h" -#include "application_manager/mock_message_helper.h" +#include "application_manager/mock_application.h" #include "application_manager/mock_hmi_interface.h" +#include "application_manager/mock_message_helper.h" +#include "application_manager/smart_object_keys.h" #include "interfaces/MOBILE_API.h" +#include "smart_objects/smart_object.h" +#include "utils/data_accessor.h" #include "application_manager/mock_app_service_manager.h" #include "resumption/last_state_impl.h" @@ -64,20 +64,20 @@ namespace strings = am::strings; namespace hmi_response = am::hmi_response; using ::testing::_; +using ::testing::DoAll; using ::testing::Return; using ::testing::SaveArg; -using ::testing::DoAll; using ::testing::SetArgReferee; -using am::commands::MessageSharedPtr; -using am::CommandParametersPermissions; -using am::event_engine::EventObserver; -using am::commands::CommandImpl; -using am::commands::CommandRequestImpl; using am::ApplicationManager; using am::ApplicationSet; -using am::RPCParams; +using am::CommandParametersPermissions; using am::MockHmiInterfaces; +using am::RPCParams; +using am::commands::CommandImpl; +using am::commands::CommandRequestImpl; +using am::commands::MessageSharedPtr; +using am::event_engine::EventObserver; using test::components::application_manager_test::MockAppServiceManager; typedef am::commands::CommandRequestImpl::RequestState RequestState; @@ -105,10 +105,10 @@ class CommandRequestImplTest class UnwrappedCommandRequestImpl : public CommandRequestImpl { public: - using CommandRequestImpl::CheckAllowedParameters; - using CommandRequestImpl::RemoveDisallowedParameters; using CommandRequestImpl::AddDisallowedParameters; + using CommandRequestImpl::CheckAllowedParameters; using CommandRequestImpl::HasDisallowedParams; + using CommandRequestImpl::RemoveDisallowedParameters; UnwrappedCommandRequestImpl(const MessageSharedPtr& message, ApplicationManager& am, @@ -154,6 +154,13 @@ class CommandRequestImplTest typedef CommandRequestImplTest::UnwrappedCommandRequestImpl UCommandRequestImpl; typedef std::shared_ptr CommandPtr; +TEST_F(CommandRequestImplTest, WindowID_ExpectDefaultWindowID) { + auto msg = CreateMessage(); + const auto command = CreateCommand(msg); + EXPECT_EQ(mobile_apis::PredefinedWindows::DEFAULT_WINDOW, + command->window_id()); +} + TEST_F(CommandRequestImplTest, OnTimeOut_StateCompleted_UNSUCCESS) { CommandPtr command = CreateCommand(); @@ -311,13 +318,6 @@ TEST_F(CommandRequestImplTest, SendHMIRequest_UseEvent_SUCCESS) { } TEST_F(CommandRequestImplTest, RemoveDisallowedParameters_SUCCESS) { - am::VehicleData vehicle_data; - vehicle_data.insert(am::VehicleData::value_type( - kMissedParam, mobile_apis::VehicleDataType::VEHICLEDATA_MYKEY)); - - EXPECT_CALL(mock_message_helper_, vehicle_data()) - .WillOnce(ReturnRef(vehicle_data)); - MessageSharedPtr msg = CreateMessage(); (*msg)[strings::msg_params][kDisallowedParam1] = 0u; (*msg)[strings::msg_params][kDisallowedParam2] = 0u; @@ -326,7 +326,6 @@ TEST_F(CommandRequestImplTest, RemoveDisallowedParameters_SUCCESS) { (*msg)[strings::msg_params][kMissedParam] = 0u; CommandPtr command = CreateCommand(msg); - CommandParametersPermissions& permission = command->parameters_permissions(); permission.disallowed_params.insert(kDisallowedParam1); permission.disallowed_params.insert(kDisallowedParam2); @@ -366,6 +365,12 @@ TEST_F(CommandRequestImplTest, TEST_F(CommandRequestImplTest, CheckAllowedParameters_NoMsgParamsMap_SUCCESS) { MockAppPtr mock_app = CreateMockApp(); ON_CALL(app_mngr_, application(_)).WillByDefault(Return(mock_app)); + ON_CALL(*mock_app, GetWindowIds()) + .WillByDefault(Return( + am::WindowIds(1, mobile_apis::PredefinedWindows::DEFAULT_WINDOW))); + ON_CALL(*mock_app, + WindowIdExists(mobile_apis::PredefinedWindows::DEFAULT_WINDOW)) + .WillByDefault(Return(true)); MessageSharedPtr message = CreateMessage(); (*message)[strings::msg_params] = @@ -373,7 +378,7 @@ TEST_F(CommandRequestImplTest, CheckAllowedParameters_NoMsgParamsMap_SUCCESS) { CommandPtr command = CreateCommand(message); - EXPECT_CALL(app_mngr_, CheckPolicyPermissions(_, _, _, _)) + EXPECT_CALL(app_mngr_, CheckPolicyPermissions(_, _, _, _, _)) .WillOnce(Return(kMobResultSuccess)); EXPECT_TRUE(command->CheckPermissions()); @@ -383,6 +388,12 @@ TEST_F(CommandRequestImplTest, CheckAllowedParameters_WrongPolicyPermissions_UNSUCCESS) { MockAppPtr mock_app = CreateMockApp(); ON_CALL(app_mngr_, application(_)).WillByDefault(Return(mock_app)); + ON_CALL(*mock_app, GetWindowIds()) + .WillByDefault(Return( + am::WindowIds(1, mobile_apis::PredefinedWindows::DEFAULT_WINDOW))); + ON_CALL(*mock_app, + WindowIdExists(mobile_apis::PredefinedWindows::DEFAULT_WINDOW)) + .WillByDefault(Return(true)); MessageSharedPtr message = CreateMessage(); (*message)[strings::msg_params] = @@ -394,7 +405,7 @@ TEST_F(CommandRequestImplTest, .Times(1) .WillRepeatedly(Return(kConnectionKey)); - EXPECT_CALL(app_mngr_, CheckPolicyPermissions(_, _, _, _)) + EXPECT_CALL(app_mngr_, CheckPolicyPermissions(_, _, _, _, _)) .WillOnce(Return(mobile_apis::Result::INVALID_ENUM)); EXPECT_CALL(mock_message_helper_, CreateBlockedByPoliciesResponse(_, _, _, _)) @@ -405,7 +416,7 @@ TEST_F(CommandRequestImplTest, } ACTION_P(GetArg3, output) { - *output = arg2; + *output = arg3; } TEST_F(CommandRequestImplTest, CheckAllowedParameters_MsgParamsMap_SUCCESS) { @@ -417,9 +428,14 @@ TEST_F(CommandRequestImplTest, CheckAllowedParameters_MsgParamsMap_SUCCESS) { MockAppPtr app = CreateMockApp(); ON_CALL(app_mngr_, application(_)).WillByDefault(Return(app)); + ON_CALL(*app, GetWindowIds()) + .WillByDefault(Return( + am::WindowIds(1, mobile_apis::PredefinedWindows::DEFAULT_WINDOW))); + ON_CALL(*app, WindowIdExists(mobile_apis::PredefinedWindows::DEFAULT_WINDOW)) + .WillByDefault(Return(true)); RPCParams params; - EXPECT_CALL(app_mngr_, CheckPolicyPermissions(_, _, _, _)) + EXPECT_CALL(app_mngr_, CheckPolicyPermissions(_, _, _, _, _)) .WillOnce(DoAll(GetArg3(¶ms), Return(kMobResultSuccess))); EXPECT_TRUE(command->CheckPermissions()); @@ -432,13 +448,13 @@ TEST_F(CommandRequestImplTest, AddDisallowedParameters_SUCCESS) { vehicle_data.insert(am::VehicleData::value_type( kDisallowedParam1, mobile_apis::VehicleDataType::VEHICLEDATA_MYKEY)); - EXPECT_CALL(mock_message_helper_, vehicle_data()) - .WillOnce(ReturnRef(vehicle_data)); - MessageSharedPtr msg; CommandPtr command = CreateCommand(msg); + ON_CALL(mock_message_helper_, vehicle_data()) + .WillByDefault(ReturnRef(vehicle_data)); + command->removed_parameters_permissions().disallowed_params.insert( kDisallowedParam1); @@ -485,9 +501,6 @@ TEST_F(CommandRequestImplTest, vehicle_data.insert(am::VehicleData::value_type( kDisallowedParam1, mobile_apis::VehicleDataType::VEHICLEDATA_MYKEY)); - EXPECT_CALL(mock_message_helper_, vehicle_data()) - .WillOnce(ReturnRef(vehicle_data)); - MessageSharedPtr msg = CreateMessage(); (*msg)[strings::params][strings::function_id] = mobile_apis::FunctionID::SubscribeVehicleDataID; @@ -499,6 +512,9 @@ TEST_F(CommandRequestImplTest, MessageSharedPtr result; + ON_CALL(mock_message_helper_, vehicle_data()) + .WillByDefault(ReturnRef(vehicle_data)); + EXPECT_CALL(mock_rpc_service_, ManageMobileCommand(_, _)) .WillOnce(DoAll(SaveArg<0>(&result), Return(true))); diff --git a/src/components/application_manager/test/commands/command_response_impl_test.cc b/src/components/application_manager/test/commands/command_response_impl_test.cc index 41cc654a244..6362ea702ef 100644 --- a/src/components/application_manager/test/commands/command_response_impl_test.cc +++ b/src/components/application_manager/test/commands/command_response_impl_test.cc @@ -35,12 +35,12 @@ #include "gtest/gtest.h" -#include "smart_objects/smart_object.h" -#include "application_manager/smart_object_keys.h" -#include "application_manager/commands/commands_test.h" #include "application_manager/commands/command.h" #include "application_manager/commands/command_response_impl.h" +#include "application_manager/commands/commands_test.h" #include "application_manager/mock_application.h" +#include "application_manager/smart_object_keys.h" +#include "smart_objects/smart_object.h" namespace test { namespace components { @@ -50,8 +50,8 @@ namespace command_response_impl { namespace strings = ::application_manager::strings; namespace hmi_response = ::application_manager::hmi_response; -using ::application_manager::commands::MessageSharedPtr; using ::application_manager::commands::CommandResponseImpl; +using ::application_manager::commands::MessageSharedPtr; class CommandResponseImplTest : public CommandsTest {}; diff --git a/src/components/application_manager/test/event_engine_test.cc b/src/components/application_manager/test/event_engine_test.cc index de0b5afb3c8..6746e0d5ec8 100644 --- a/src/components/application_manager/test/event_engine_test.cc +++ b/src/components/application_manager/test/event_engine_test.cc @@ -32,11 +32,11 @@ #include "gtest/gtest.h" -#include "application_manager/event_engine/event_observer.h" #include "application_manager/event_engine/event.h" #include "application_manager/event_engine/event_dispatcher_impl.h" -#include "application_manager/mock_event_observer.h" +#include "application_manager/event_engine/event_observer.h" #include "application_manager/mock_event_dispatcher.h" +#include "application_manager/mock_event_observer.h" #include "smart_objects/smart_object.h" #include "interfaces/HMI_API.h" @@ -45,10 +45,12 @@ namespace test { namespace components { namespace event_engine_test { -using application_manager::event_engine::EventDispatcherImpl; using application_manager::event_engine::Event; +using application_manager::event_engine::EventDispatcherImpl; using application_manager::event_engine::EventObserver; using testing::_; +using ::testing::An; +using ::testing::Matcher; class EventEngineTest : public testing::Test { public: @@ -122,7 +124,9 @@ class EventEngineTest : public testing::Test { event_dispatcher_instance_->add_observer( event_id, correlation_id, event_observer_mock_); event_->set_smart_object(so); - EXPECT_CALL(event_observer_mock_, on_event(_)).Times(calls_number); + + EXPECT_CALL(event_observer_mock_, on_event(An())) + .Times(calls_number); event_dispatcher_instance_->raise_event(*event_); } }; diff --git a/src/components/application_manager/test/help_prompt_manager_test.cc b/src/components/application_manager/test/help_prompt_manager_test.cc index dc6635b049b..caff56f675d 100644 --- a/src/components/application_manager/test/help_prompt_manager_test.cc +++ b/src/components/application_manager/test/help_prompt_manager_test.cc @@ -1,4 +1,4 @@ -/* +/* * Copyright (c) 2018, Ford Motor Company * All rights reserved. * @@ -65,6 +65,9 @@ const std::string kDirectoryName = "./test_storage"; const uint8_t expected_tread_pool_size = 2u; const uint8_t stop_streaming_timeout = 1u; const std::vector kTimeoutPrompt{"timeoutPrompt"}; +const WindowID kDefaultWindowId = + mobile_apis::PredefinedWindows::DEFAULT_WINDOW; +const std::string kDefaultWindowName = "DefaultName"; } // namespace using namespace application_manager; @@ -177,8 +180,10 @@ void HelpPromptManagerTest::SetUp() { mock_help_prompt_manager_ = std::shared_ptr(new MockHelpPromptManager()); - std::string path = file_system::CreateDirectory("storage"); - file_system::CreateFile(path + "/" + "certificate"); + const std::string path("storage"); + if (file_system::CreateDirectory(path)) { + file_system::CreateFile(path + "/" + "certificate"); + } mock_app_ = std::make_shared(); } @@ -244,7 +249,8 @@ void HelpPromptManagerTest::CreateApplication( app_mngr_, mock_help_prompt_manager)); HmiStatePtr initial_state = CreateTestHmiState(); - app_impl_->SetInitialState(initial_state); + app_impl_->SetInitialState( + kDefaultWindowId, kDefaultWindowName, initial_state); } TEST_F(HelpPromptManagerTest, AddCommand_OnVrCommandAdded) { diff --git a/src/components/application_manager/test/hmi_capabilities.json b/src/components/application_manager/test/hmi_capabilities.json index ca67d81d8cc..afa5fa6056d 100644 --- a/src/components/application_manager/test/hmi_capabilities.json +++ b/src/components/application_manager/test/hmi_capabilities.json @@ -355,11 +355,11 @@ "STATIC" ] }, - "audioPassThruCapabilities": { + "audioPassThruCapabilities": [{ "samplingRate": "44KHZ", "bitsPerSample": "RATE_8_BIT", "audioType": "PCM" - }, + }], "pcmStreamCapabilities": { "samplingRate": "16KHZ", "bitsPerSample": "RATE_16_BIT", diff --git a/src/components/application_manager/test/hmi_capabilities_old_apt.json b/src/components/application_manager/test/hmi_capabilities_old_apt.json new file mode 100644 index 00000000000..5a5af37e2fa --- /dev/null +++ b/src/components/application_manager/test/hmi_capabilities_old_apt.json @@ -0,0 +1,9 @@ +{ + "UI": { + "audioPassThruCapabilities": { + "samplingRate": "22KHZ", + "bitsPerSample": "RATE_16_BIT", + "audioType": "PCM" + } + } +} diff --git a/src/components/application_manager/test/hmi_capabilities_test.cc b/src/components/application_manager/test/hmi_capabilities_test.cc index d67dfebaa52..3d47c717e10 100644 --- a/src/components/application_manager/test/hmi_capabilities_test.cc +++ b/src/components/application_manager/test/hmi_capabilities_test.cc @@ -36,32 +36,32 @@ #include #include "application_manager/hmi_capabilities.h" -#include "gtest/gtest.h" -#include "smart_objects/smart_object.h" #include "application_manager/mock_message_helper.h" -#include "smart_objects/enum_schema_item.h" +#include "gtest/gtest.h" #include "interfaces/HMI_API.h" +#include "smart_objects/enum_schema_item.h" +#include "smart_objects/smart_object.h" #include "application_manager/hmi_capabilities_for_testing.h" -#include "utils/file_system.h" #include "application_manager/mock_application_manager.h" #include "application_manager/mock_application_manager_settings.h" #include "application_manager/mock_event_dispatcher.h" #include "application_manager/mock_rpc_service.h" +#include "application_manager/resumption/resume_ctrl.h" #include "application_manager/state_controller.h" #include "resumption/last_state_impl.h" -#include "application_manager/resumption/resume_ctrl.h" +#include "utils/file_system.h" namespace test { namespace components { namespace application_manager_test { using ::testing::_; -using ::testing::Return; -using ::testing::ReturnRef; using ::testing::AtLeast; -using ::testing::Invoke; using ::testing::InSequence; +using ::testing::Invoke; +using ::testing::Return; +using ::testing::ReturnRef; using namespace application_manager; @@ -76,7 +76,8 @@ class HMICapabilitiesTest : public ::testing::Test { EXPECT_CALL(app_mngr_, get_settings()) .WillRepeatedly(ReturnRef(mock_application_manager_settings_)); EXPECT_CALL(mock_application_manager_settings_, - hmi_capabilities_file_name()).WillOnce(ReturnRef(file_name_)); + hmi_capabilities_file_name()) + .WillOnce(ReturnRef(file_name_)); EXPECT_CALL(mock_event_dispatcher, add_observer(_, _, _)).Times(1); EXPECT_CALL(mock_event_dispatcher, remove_observer(_)).Times(1); EXPECT_CALL(mock_application_manager_settings_, launch_hmi()) @@ -140,9 +141,9 @@ struct CStringComparator { } }; -typedef std::map CStringToEnumMap; +typedef std:: + map + CStringToEnumMap; CStringToEnumMap InitCStringToEnumMap() { size_t value = sizeof(cstring_values_) / sizeof(cstring_values_[0]); @@ -335,15 +336,18 @@ TEST_F(HMICapabilitiesTest, LoadCapabilitiesFromFile) { // Check audio pass thru const smart_objects::SmartObject audio_pass_thru_capabilities_so = *(hmi_capabilities_test->audio_pass_thru_capabilities()); + EXPECT_EQ(smart_objects::SmartType_Array, + audio_pass_thru_capabilities_so.getType()); + EXPECT_EQ(1u, audio_pass_thru_capabilities_so.length()); EXPECT_EQ(hmi_apis::Common_SamplingRate::RATE_44KHZ, static_cast( - audio_pass_thru_capabilities_so["samplingRate"].asInt())); + audio_pass_thru_capabilities_so[0]["samplingRate"].asInt())); EXPECT_EQ(hmi_apis::Common_BitsPerSample::RATE_8_BIT, static_cast( - audio_pass_thru_capabilities_so["bitsPerSample"].asInt())); + audio_pass_thru_capabilities_so[0]["bitsPerSample"].asInt())); EXPECT_EQ(hmi_apis::Common_AudioType::PCM, static_cast( - audio_pass_thru_capabilities_so["audioType"].asInt())); + audio_pass_thru_capabilities_so[0]["audioType"].asInt())); // Check hmi zone capabilities const smart_objects::SmartObject hmi_zone_capabilities_so = @@ -407,7 +411,8 @@ TEST_F(HMICapabilitiesTest, LoadCapabilitiesFromFile) { .asInt()); EXPECT_EQ(350, vs_capability_so[strings::preferred_resolution] - [strings::resolution_height].asInt()); + [strings::resolution_height] + .asInt()); EXPECT_TRUE(vs_capability_so.keyExists(strings::max_bitrate)); EXPECT_EQ(10000, vs_capability_so[strings::max_bitrate].asInt()); EXPECT_TRUE(vs_capability_so.keyExists(strings::supported_formats)); @@ -454,7 +459,8 @@ TEST_F(HMICapabilitiesTest, LoadCapabilitiesFromFile) { rc_capability_so["climateControlCapabilities"][0]["fanSpeedAvailable"] .asBool()); EXPECT_TRUE(rc_capability_so["climateControlCapabilities"][0] - ["desiredTemperatureAvailable"].asBool()); + ["desiredTemperatureAvailable"] + .asBool()); EXPECT_TRUE( rc_capability_so["climateControlCapabilities"][0]["acEnableAvailable"] .asBool()); @@ -566,6 +572,57 @@ TEST_F(HMICapabilitiesTest, EXPECT_FALSE(navigation_capability_so["getWayPointsEnabled"].asBool()); } +TEST_F(HMICapabilitiesTest, + LoadCapabilitiesFromFileAndVerifyOldAudioPassThruCapabilities) { + MockApplicationManager mock_app_mngr; + event_engine_test::MockEventDispatcher mock_dispatcher; + MockApplicationManagerSettings mock_application_manager_settings; + + const std::string hmi_capabilities_file = "hmi_capabilities_old_apt.json"; + + EXPECT_CALL(mock_app_mngr, event_dispatcher()) + .WillOnce(ReturnRef(mock_dispatcher)); + EXPECT_CALL(mock_app_mngr, get_settings()) + .WillRepeatedly(ReturnRef(mock_application_manager_settings)); + EXPECT_CALL(mock_application_manager_settings, hmi_capabilities_file_name()) + .WillOnce(ReturnRef(hmi_capabilities_file)); + EXPECT_CALL(mock_dispatcher, add_observer(_, _, _)).Times(1); + EXPECT_CALL(mock_dispatcher, remove_observer(_)).Times(1); + EXPECT_CALL(mock_application_manager_settings, launch_hmi()) + .WillOnce(Return(false)); + EXPECT_CALL(*(MockMessageHelper::message_helper_mock()), + CommonLanguageFromString(_)) + .WillRepeatedly(Invoke(TestCommonLanguageFromString)); + + if (file_system::FileExists("./app_info_data")) { + EXPECT_TRUE(::file_system::DeleteFile("./app_info_data")); + } + + std::shared_ptr hmi_capabilities = + std::make_shared(mock_app_mngr); + hmi_capabilities->Init(&last_state_); + + // with old audio pass thru format, the object is an array containing a single + // object + smart_objects::SmartObject audio_pass_thru_capabilities_so = + *(hmi_capabilities->audio_pass_thru_capabilities()); + EXPECT_EQ(smart_objects::SmartType_Array, + audio_pass_thru_capabilities_so.getType()); + EXPECT_EQ(1u, audio_pass_thru_capabilities_so.length()); + EXPECT_TRUE(audio_pass_thru_capabilities_so[0].keyExists("samplingRate")); + EXPECT_EQ(hmi_apis::Common_SamplingRate::RATE_22KHZ, + static_cast( + audio_pass_thru_capabilities_so[0]["samplingRate"].asInt())); + EXPECT_TRUE(audio_pass_thru_capabilities_so[0].keyExists("bitsPerSample")); + EXPECT_EQ(hmi_apis::Common_BitsPerSample::RATE_16_BIT, + static_cast( + audio_pass_thru_capabilities_so[0]["bitsPerSample"].asInt())); + EXPECT_TRUE(audio_pass_thru_capabilities_so[0].keyExists("audioType")); + EXPECT_EQ(hmi_apis::Common_AudioType::PCM, + static_cast( + audio_pass_thru_capabilities_so[0]["audioType"].asInt())); +} + TEST_F(HMICapabilitiesTest, VerifyImageType) { const int32_t image_type = 1; smart_objects::SmartObject sm_obj; @@ -582,7 +639,8 @@ TEST_F(HMICapabilitiesTest, VerifyImageType) { void HMICapabilitiesTest::SetCooperating() { smart_objects::SmartObjectSPtr test_so; EXPECT_CALL(*(MockMessageHelper::message_helper_mock()), - CreateModuleInfoSO(_, _)).WillRepeatedly(Return(test_so)); + CreateModuleInfoSO(_, _)) + .WillRepeatedly(Return(test_so)); EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_, _)) .WillRepeatedly(Return(true)); } diff --git a/src/components/application_manager/test/hmi_language_handler_test.cc b/src/components/application_manager/test/hmi_language_handler_test.cc index ec880752120..5f07c1b9d1a 100644 --- a/src/components/application_manager/test/hmi_language_handler_test.cc +++ b/src/components/application_manager/test/hmi_language_handler_test.cc @@ -32,18 +32,18 @@ #include -#include "gtest/gtest.h" #include "application_manager/application_manager.h" #include "application_manager/hmi_language_handler.h" -#include "application_manager/state_controller.h" +#include "application_manager/mock_application.h" #include "application_manager/mock_application_manager.h" #include "application_manager/mock_event_dispatcher.h" -#include "application_manager/mock_message_helper.h" -#include "application_manager/resumption/resume_ctrl_impl.h" #include "application_manager/mock_hmi_capabilities.h" -#include "application_manager/mock_application.h" +#include "application_manager/mock_message_helper.h" #include "application_manager/mock_rpc_service.h" +#include "application_manager/resumption/resume_ctrl_impl.h" #include "application_manager/smart_object_keys.h" +#include "application_manager/state_controller.h" +#include "gtest/gtest.h" #include "test/resumption/mock_last_state.h" #include "utils/lock.h" @@ -54,13 +54,13 @@ namespace hmi_language_handler { namespace am = ::application_manager; -using am::event_engine::Event; using am::ApplicationSet; +using am::event_engine::Event; +using ::testing::_; +using ::testing::NiceMock; using ::testing::Return; using ::testing::ReturnRef; -using ::testing::NiceMock; -using ::testing::_; typedef NiceMock< ::test::components::application_manager_test::MockApplicationManager> diff --git a/src/components/application_manager/test/include/application_manager/commands/command_request_test.h b/src/components/application_manager/test/include/application_manager/commands/command_request_test.h index 8dd29ce2447..3a44d7b3ff6 100644 --- a/src/components/application_manager/test/include/application_manager/commands/command_request_test.h +++ b/src/components/application_manager/test/include/application_manager/commands/command_request_test.h @@ -37,11 +37,11 @@ #include "gtest/gtest.h" -#include "smart_objects/smart_object.h" +#include "application_manager/commands/command_request_impl.h" #include "application_manager/smart_object_keys.h" #include "application_manager/test/include/application_manager/commands/commands_test.h" -#include "application_manager/commands/command_request_impl.h" #include "application_manager/test/include/application_manager/mock_event_dispatcher.h" +#include "smart_objects/smart_object.h" #include "application_manager/event_engine/event.h" @@ -49,12 +49,12 @@ namespace test { namespace components { namespace commands_test { +using ::test::components::event_engine_test::MockEventDispatcher; using ::testing::_; -using ::testing::Return; -using ::testing::SaveArg; using ::testing::DoAll; using ::testing::NiceMock; -using ::test::components::event_engine_test::MockEventDispatcher; +using ::testing::Return; +using ::testing::SaveArg; namespace am = ::application_manager; using am::commands::Command; using am::commands::CommandRequestImpl; 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 9a961ea1a94..a047de81b9a 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 @@ -30,44 +30,44 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_TEST_INCLUDE_APPLICATION_MANAGER_COMMANDS_TEST_H_ -#define SRC_COMPONENTS_APPLICATION_MANAGER_TEST_INCLUDE_APPLICATION_MANAGER_COMMANDS_TEST_H_ +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_TEST_INCLUDE_APPLICATION_MANAGER_COMMANDS_COMMANDS_TEST_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_TEST_INCLUDE_APPLICATION_MANAGER_COMMANDS_COMMANDS_TEST_H_ #include #include "gtest/gtest.h" -#include "smart_objects/smart_object.h" #include "application_manager/commands/command.h" +#include "smart_objects/smart_object.h" #include "application_manager/mock_application_manager.h" -#include "test/application_manager/mock_application_manager_settings.h" -#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/mock_rpc_service.h" #include "application_manager/policies/mock_policy_handler_interface.h" +#include "application_manager/test/include/application_manager/mock_application.h" +#include "application_manager/test/include/application_manager/mock_hmi_interface.h" +#include "application_manager/test/include/application_manager/mock_message_helper.h" +#include "test/application_manager/mock_application_manager_settings.h" namespace test { namespace components { namespace commands_test { namespace am = ::application_manager; -using ::testing::ReturnRef; -using ::testing::Return; -using ::testing::NiceMock; -using ::testing::Mock; using ::testing::_; +using ::testing::Mock; +using ::testing::NiceMock; +using ::testing::Return; +using ::testing::ReturnRef; -using ::smart_objects::SmartObject; +using am::ApplicationSharedPtr; +using am::MockMessageHelper; using am::commands::MessageSharedPtr; +using ::smart_objects::SmartObject; +using ::test::components::application_manager_test::MockApplication; using ::test::components::application_manager_test::MockApplicationManager; using ::test::components::application_manager_test:: MockApplicationManagerSettings; -using am::ApplicationSharedPtr; -using am::MockMessageHelper; -using ::test::components::application_manager_test::MockApplication; // Depending on the value type will be selected template @@ -100,9 +100,8 @@ class CommandsTest : public ::testing::Test { typedef typename TypeIf, MockApplicationManager>::Result MockAppManager; - typedef typename TypeIf, - MockApplication>::Result MockApp; + typedef typename TypeIf, MockApplication>:: + Result MockApp; typedef std::shared_ptr MockAppPtr; virtual ~CommandsTest() { @@ -183,11 +182,11 @@ class CommandsTest : public ::testing::Test { void InitHMIToMobileResultConverter() { namespace MobileResult = mobile_apis::Result; namespace HMIResult = hmi_apis::Common_Result; - auto link_hmi_to_mob_result = - [this](HMIResult::eType hmi_result, MobileResult::eType mobile_result) { - ON_CALL(mock_message_helper_, HMIToMobileResult(hmi_result)) - .WillByDefault(Return(mobile_result)); - }; + auto link_hmi_to_mob_result = [this](HMIResult::eType hmi_result, + MobileResult::eType mobile_result) { + ON_CALL(mock_message_helper_, HMIToMobileResult(hmi_result)) + .WillByDefault(Return(mobile_result)); + }; link_hmi_to_mob_result(HMIResult::INVALID_ENUM, MobileResult::INVALID_ENUM); link_hmi_to_mob_result(HMIResult::SUCCESS, MobileResult::SUCCESS); link_hmi_to_mob_result(HMIResult::UNSUPPORTED_REQUEST, @@ -233,17 +232,17 @@ class CommandsTest : public ::testing::Test { }; MATCHER_P(MobileResultCodeIs, result_code, "") { - return result_code == - static_cast( - (*arg)[application_manager::strings::msg_params] - [application_manager::strings::result_code].asInt()); + return result_code == static_cast( + (*arg)[application_manager::strings::msg_params] + [application_manager::strings::result_code] + .asInt()); } MATCHER_P(HMIResultCodeIs, result_code, "") { - return result_code == - static_cast( - (*arg)[application_manager::strings::params] - [application_manager::strings::function_id].asInt()); + return result_code == static_cast( + (*arg)[application_manager::strings::params] + [application_manager::strings::function_id] + .asInt()); } MATCHER_P3(MobileResponseIs, result_code, result_info, result_success, "") { @@ -260,4 +259,4 @@ MATCHER_P3(MobileResponseIs, result_code, result_info, result_success, "") { } // namespace components } // namespace test -#endif // SRC_COMPONENTS_APPLICATION_MANAGER_TEST_INCLUDE_APPLICATION_MANAGER_COMMANDS_TEST_H_ +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_TEST_INCLUDE_APPLICATION_MANAGER_COMMANDS_COMMANDS_TEST_H_ diff --git a/src/components/application_manager/test/include/application_manager/mock_app_launch_data.h b/src/components/application_manager/test/include/application_manager/mock_app_launch_data.h index 881ebb25756..9f50a730755 100644 --- a/src/components/application_manager/test/include/application_manager/mock_app_launch_data.h +++ b/src/components/application_manager/test/include/application_manager/mock_app_launch_data.h @@ -33,8 +33,8 @@ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_TEST_INCLUDE_APPLICATION_MANAGER_MOCK_APP_LAUNCH_DATA_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_TEST_INCLUDE_APPLICATION_MANAGER_MOCK_APP_LAUNCH_DATA_H_ -#include "gmock/gmock.h" #include "application_manager/app_launch/app_launch_data.h" +#include "gmock/gmock.h" namespace test { namespace components { 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 36d20f227d8..362dda4efb6 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 @@ -1,43 +1,45 @@ /* * 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. -*/ + * 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_TEST_INCLUDE_APPLICATION_MANAGER_MOCK_APPLICATION_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_TEST_INCLUDE_APPLICATION_MANAGER_MOCK_APPLICATION_H_ #include -#include "gmock/gmock.h" -#include "application_manager/application.h" #include "application_manager/app_extension.h" +#include "application_manager/application.h" +#include "application_manager/display_capabilities_builder.h" +#include "application_manager/hmi_state.h" +#include "application_manager/usage_statistics.h" +#include "gmock/gmock.h" #include "smart_objects/smart_object.h" #include "utils/custom_string.h" -#include "application_manager/usage_statistics.h" #include "utils/semantic_version.h" namespace test { @@ -56,6 +58,8 @@ class MockApplication : public ::application_manager::Application { MOCK_CONST_METHOD0(is_application_data_changed, bool()); MOCK_METHOD1(set_is_application_data_changed, void(bool state_application_data)); + MOCK_CONST_METHOD0(is_app_data_resumption_allowed, bool()); + MOCK_METHOD1(set_app_data_resumption_allowance, void(bool allowed)); MOCK_METHOD0(CloseActiveMessage, void()); MOCK_CONST_METHOD0(IsFullscreen, bool()); MOCK_METHOD0(ChangeSupportingAppHMIType, void()); @@ -82,8 +86,9 @@ class MockApplication : public ::application_manager::Application { void(protocol_handler::ServiceType service_type)); MOCK_METHOD1(SuspendStreaming, void(protocol_handler::ServiceType service_type)); - MOCK_METHOD1(WakeUpStreaming, - void(protocol_handler::ServiceType service_type)); + MOCK_METHOD2(WakeUpStreaming, + void(protocol_handler::ServiceType service_type, + uint32_t timer_len)); MOCK_CONST_METHOD0(is_voice_communication_supported, bool()); MOCK_METHOD1(set_voice_communication_supported, void(bool is_voice_communication_supported)); @@ -97,11 +102,15 @@ class MockApplication : public ::application_manager::Application { MOCK_METHOD1(set_folder_name, void(const std::string& folder_name)); MOCK_CONST_METHOD0(folder_name, const std::string()); MOCK_CONST_METHOD0(is_media_application, bool()); - MOCK_CONST_METHOD0(hmi_level, const mobile_apis::HMILevel::eType()); + MOCK_CONST_METHOD1(hmi_level, + const mobile_apis::HMILevel::eType( + const application_manager::WindowID window_id)); MOCK_CONST_METHOD0(put_file_in_none_count, const uint32_t()); MOCK_CONST_METHOD0(delete_file_in_none_count, const uint32_t()); MOCK_CONST_METHOD0(list_files_in_none_count, const uint32_t()); - MOCK_CONST_METHOD0(system_context, const mobile_apis::SystemContext::eType()); + MOCK_CONST_METHOD1(system_context, + const mobile_apis::SystemContext::eType( + const application_manager::WindowID window_id)); MOCK_CONST_METHOD0(audio_streaming_state, const mobile_apis::AudioStreamingState::eType()); MOCK_CONST_METHOD0(video_streaming_state, @@ -109,11 +118,20 @@ class MockApplication : public ::application_manager::Application { MOCK_CONST_METHOD0(app_icon_path, const std::string&()); MOCK_CONST_METHOD0(device, connection_handler::DeviceHandle()); 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_METHOD1(CurrentHmiState, + const application_manager::HmiStatePtr( + const application_manager::WindowID window_id)); + MOCK_CONST_METHOD1(RegularHmiState, + const application_manager::HmiStatePtr( + const application_manager::WindowID window_id)); + MOCK_CONST_METHOD0(GetWindowIds, application_manager::WindowIds()); + MOCK_CONST_METHOD0(GetWindowNames, application_manager::WindowNames()); + MOCK_CONST_METHOD1(WindowIdExists, + bool(const application_manager::WindowID window_id)); MOCK_CONST_METHOD0(IsAllowedToChangeAudioSource, bool()); - MOCK_CONST_METHOD0(PostponedHmiState, - const application_manager::HmiStatePtr()); + MOCK_CONST_METHOD1(PostponedHmiState, + const application_manager::HmiStatePtr( + const application_manager::WindowID window_id)); MOCK_METHOD1(set_tts_properties_in_none, void(bool active)); MOCK_METHOD0(tts_properties_in_none, bool()); MOCK_METHOD1(set_tts_properties_in_full, void(bool active)); @@ -167,14 +185,24 @@ class MockApplication : public ::application_manager::Application { ::application_manager::HelpPromptManager&()); MOCK_CONST_METHOD0(help_prompt_manager, const ::application_manager::HelpPromptManager&()); - MOCK_METHOD1(SetInitialState, void(::application_manager::HmiStatePtr state)); - MOCK_METHOD1(SetRegularState, void(::application_manager::HmiStatePtr state)); - MOCK_METHOD1(SetPostponedState, - void(::application_manager::HmiStatePtr state)); - MOCK_METHOD0(RemovePostponedState, void()); - MOCK_METHOD1(AddHMIState, void(::application_manager::HmiStatePtr state)); - MOCK_METHOD1(RemoveHMIState, - void(::application_manager::HmiState::StateID state_id)); + MOCK_METHOD3(SetInitialState, + void(const application_manager::WindowID window_id, + const std::string& window_name, + application_manager::HmiStatePtr state)); + MOCK_METHOD2(SetRegularState, + void(const application_manager::WindowID window_id, + application_manager::HmiStatePtr state)); + MOCK_METHOD2(SetPostponedState, + void(const application_manager::WindowID window_id, + ::application_manager::HmiStatePtr state)); + MOCK_METHOD1(RemovePostponedState, + void(const application_manager::WindowID window_id)); + MOCK_METHOD2(AddHMIState, + void(const application_manager::WindowID window_id, + application_manager::HmiStatePtr state)); + MOCK_METHOD2(RemoveHMIState, + void(const application_manager::WindowID window_id, + ::application_manager::HmiState::StateID state_id)); MOCK_METHOD2(SubscribeToSoftButtons, void(int32_t cmd_id, const ::application_manager::SoftButtonID& softbuttons_id)); @@ -220,9 +248,35 @@ class MockApplication : public ::application_manager::Application { MOCK_CONST_METHOD0(keyboard_props, const smart_objects::SmartObject*()); MOCK_CONST_METHOD0(menu_title, const smart_objects::SmartObject*()); MOCK_CONST_METHOD0(menu_icon, const smart_objects::SmartObject*()); - MOCK_CONST_METHOD0(day_color_scheme, const smart_objects::SmartObject*()); - MOCK_CONST_METHOD0(night_color_scheme, const smart_objects::SmartObject*()); - MOCK_CONST_METHOD0(display_layout, const std::string&()); + MOCK_CONST_METHOD0(day_color_scheme, smart_objects::SmartObject()); + MOCK_CONST_METHOD0(night_color_scheme, smart_objects::SmartObject()); + MOCK_CONST_METHOD0(display_layout, std::string()); + MOCK_CONST_METHOD0(display_capabilities, smart_objects::SmartObjectSPtr()); + MOCK_CONST_METHOD1(display_capabilities, + smart_objects::SmartObjectSPtr( + const application_manager::WindowID window_id)); + + MOCK_METHOD2(set_window_layout, + void(const application_manager::WindowID window_id, + const std::string& layout)); + MOCK_METHOD2(set_day_color_scheme, + void(const application_manager::WindowID window_id, + const smart_objects::SmartObject& color_scheme)); + MOCK_METHOD2(set_night_color_scheme, + void(const application_manager::WindowID window_id, + const smart_objects::SmartObject& color_scheme)); + MOCK_CONST_METHOD1( + window_layout, + std::string(const application_manager::WindowID window_id)); + MOCK_CONST_METHOD1(day_color_scheme, + smart_objects::SmartObject( + const application_manager::WindowID window_id)); + MOCK_CONST_METHOD1(night_color_scheme, + smart_objects::SmartObject( + const application_manager::WindowID window_id)); + MOCK_METHOD1(set_display_capabilities, + void(const smart_objects::SmartObject& display_capabilities)); + MOCK_METHOD1(load_global_properties, void(const smart_objects::SmartObject& so)); MOCK_METHOD1(set_help_prompt, @@ -316,9 +370,10 @@ class MockApplication : public ::application_manager::Application { SwapMobileMessageQueue, void(::application_manager::MobileMessageQueue& mobile_messages)); - MOCK_METHOD1( + MOCK_METHOD2( set_system_context, - void(const application_manager::mobile_api::SystemContext::eType&)); + void(const application_manager::WindowID window_id, + const application_manager::mobile_api::SystemContext::eType&)); MOCK_METHOD1( set_audio_streaming_state, void(const application_manager::mobile_api::AudioStreamingState::eType& @@ -329,9 +384,10 @@ class MockApplication : public ::application_manager::Application { bool(smart_objects::SmartObject module)); MOCK_METHOD1(UnsubscribeFromInteriorVehicleData, bool(smart_objects::SmartObject module)); - MOCK_METHOD1( + MOCK_METHOD2( set_hmi_level, - void(const application_manager::mobile_api::HMILevel::eType& hmi_level)); + void(const application_manager::WindowID window_id, + const application_manager::mobile_api::HMILevel::eType& hmi_level)); MOCK_METHOD1(QueryInterface, application_manager::AppExtensionPtr( application_manager::AppExtensionUID uid)); @@ -357,6 +413,24 @@ class MockApplication : public ::application_manager::Application { void(const mobile_apis::HybridAppPreference::eType& hybrid_app_preference)); MOCK_METHOD1(set_cloud_app_certificate, void(const std::string& certificate)); + MOCK_METHOD2(SetWindowInfo, + void(const ::application_manager::WindowID windowID, + const smart_objects::SmartObject& window_info)); + MOCK_METHOD1(RemoveWindowInfo, + void((const ::application_manager::WindowID window_id))); + MOCK_CONST_METHOD0(window_optional_params_map, + DataAccessor< ::application_manager::WindowParamsMap>()); + MOCK_METHOD0(display_capabilities_builder, + application_manager::DisplayCapabilitiesBuilder&()); + MOCK_METHOD1(GetSoftButtonWindowID, + application_manager::WindowID(const uint32_t button_id)); + MOCK_METHOD1(remove_window_capability, + void(const application_manager::WindowID window_id)); + MOCK_CONST_METHOD1(menu_layout_supported, + bool(const mobile_apis::MenuLayout::eType layout)); + MOCK_METHOD1(set_user_location, + void(const smart_objects::SmartObject& user_location)); + MOCK_CONST_METHOD0(get_user_location, const smart_objects::SmartObject&()); }; } // namespace application_manager_test diff --git a/src/components/application_manager/test/include/application_manager/mock_event_dispatcher.h b/src/components/application_manager/test/include/application_manager/mock_event_dispatcher.h index c5aedba029c..b345f53c1ca 100644 --- a/src/components/application_manager/test/include/application_manager/mock_event_dispatcher.h +++ b/src/components/application_manager/test/include/application_manager/mock_event_dispatcher.h @@ -37,6 +37,7 @@ #include "application_manager/event_engine/event.h" #include "application_manager/event_engine/event_dispatcher.h" #include "application_manager/event_engine/event_observer.h" +#include "gmock/gmock.h" namespace test { namespace components { diff --git a/src/components/application_manager/test/include/application_manager/mock_event_observer.h b/src/components/application_manager/test/include/application_manager/mock_event_observer.h index 8af31c1998b..1357d67a655 100644 --- a/src/components/application_manager/test/include/application_manager/mock_event_observer.h +++ b/src/components/application_manager/test/include/application_manager/mock_event_observer.h @@ -33,8 +33,8 @@ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_TEST_INCLUDE_APPLICATION_MANAGER_MOCK_EVENT_OBSERVER_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_TEST_INCLUDE_APPLICATION_MANAGER_MOCK_EVENT_OBSERVER_H_ -#include "application_manager/event_engine/event_observer.h" #include "application_manager/event_engine/event.h" +#include "application_manager/event_engine/event_observer.h" #include "gmock/gmock.h" namespace test { @@ -49,6 +49,9 @@ class MockEventObserver : application_manager::event_engine::EventObserver(event_dispatcher) {} MOCK_METHOD1(on_event, void(const application_manager::event_engine::Event& event)); + MOCK_METHOD1( + on_event, + void(const application_manager::event_engine::MobileEvent& event)); }; } // namespace event_engine_test diff --git a/src/components/application_manager/test/include/application_manager/mock_help_prompt_manager.h b/src/components/application_manager/test/include/application_manager/mock_help_prompt_manager.h index a415f94d567..b44345deff2 100644 --- a/src/components/application_manager/test/include/application_manager/mock_help_prompt_manager.h +++ b/src/components/application_manager/test/include/application_manager/mock_help_prompt_manager.h @@ -1,34 +1,34 @@ /* * 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. -*/ + * 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_TEST_INCLUDE_APPLICATION_MANAGER_MOCK_HELP_PROMPT_MANAGER_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_TEST_INCLUDE_APPLICATION_MANAGER_MOCK_HELP_PROMPT_MANAGER_H_ diff --git a/src/components/application_manager/test/include/application_manager/mock_hmi_capabilities.h b/src/components/application_manager/test/include/application_manager/mock_hmi_capabilities.h index 468bdbe5eb9..5e5f2eb4a47 100644 --- a/src/components/application_manager/test/include/application_manager/mock_hmi_capabilities.h +++ b/src/components/application_manager/test/include/application_manager/mock_hmi_capabilities.h @@ -103,6 +103,11 @@ class MockHMICapabilities : public ::application_manager::HMICapabilities { MOCK_METHOD1(set_display_capabilities, void(const smart_objects::SmartObject& display_capabilities)); + MOCK_CONST_METHOD0(system_display_capabilities, + const smart_objects::SmartObjectSPtr()); + MOCK_METHOD1(set_system_display_capabilities, + void(const smart_objects::SmartObject& display_capabilities)); + MOCK_CONST_METHOD0(hmi_zone_capabilities, const smart_objects::SmartObject*()); MOCK_METHOD1(set_hmi_zone_capabilities, @@ -181,6 +186,12 @@ class MockHMICapabilities : public ::application_manager::HMICapabilities { MOCK_METHOD1(set_rc_capability, void(const smart_objects::SmartObject& rc_capability)); + MOCK_CONST_METHOD0(seat_location_capability, + const smart_objects::SmartObject*()); + MOCK_METHOD1( + set_seat_location_capability, + void(const smart_objects::SmartObject& seat_location_capability)); + MOCK_METHOD1(Init, void(resumption::LastState* last_state)); MOCK_CONST_METHOD0(ccpu_version, const std::string&()); @@ -198,6 +209,9 @@ class MockHMICapabilities : public ::application_manager::HMICapabilities { MOCK_CONST_METHOD2(convert_json_languages_to_obj, void(const Json::Value& json_languages, smart_objects::SmartObject& languages)); + MOCK_CONST_METHOD2(convert_audio_capability_to_obj, + void(const Json::Value& capability, + smart_objects::SmartObject& output_so)); }; } // namespace application_manager_test 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 ac39c39f223..072199082e6 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 @@ -32,13 +32,14 @@ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_TEST_INCLUDE_APPLICATION_MANAGER_MOCK_MESSAGE_HELPER_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_TEST_INCLUDE_APPLICATION_MANAGER_MOCK_MESSAGE_HELPER_H_ -#include "gmock/gmock.h" #include "application_manager/application.h" +#include "application_manager/application_manager.h" +#include "application_manager/hmi_capabilities.h" #include "application_manager/message_helper.h" +#include "application_manager/policies/policy_handler_interface.h" +#include "gmock/gmock.h" #include "interfaces/HMI_API.h" #include "policy/policy_types.h" -#include "application_manager/policies/policy_handler_interface.h" -#include "application_manager/application_manager.h" #include "smart_objects/smart_object.h" #include "transport_manager/common.h" @@ -128,8 +129,9 @@ class MockMessageHelper { MOCK_METHOD2(CreateMessageForHMI, smart_objects::SmartObjectSPtr(hmi_apis::messageType::eType, const uint32_t)); - MOCK_METHOD2(SendHMIStatusNotification, - void(const Application& application_impl, + MOCK_METHOD3(SendHMIStatusNotification, + void(ApplicationSharedPtr application, + const WindowID window_id, ApplicationManager& application_manager)); MOCK_METHOD4(SendPolicyUpdate, void(const std::string& file_path, @@ -153,10 +155,11 @@ class MockMessageHelper { uint32_t correlation_id, ApplicationManager& app_mngr)); #endif // #ifdef EXTERNAL_PROPRIETARY_MODE - MOCK_METHOD3(SendOnPermissionsChangeNotification, + MOCK_METHOD4(SendOnPermissionsChangeNotification, void(uint32_t connection_key, const policy::Permissions& permissions, - ApplicationManager& app_mngr)); + ApplicationManager& app_mngr, + const bool require_encryption)); MOCK_METHOD4(SendPolicySnapshotNotification, void(uint32_t connection_key, const std::vector& policy_data, @@ -168,6 +171,8 @@ class MockMessageHelper { hmi_apis::Common_LightName::eType(const std::string& lightName)); MOCK_METHOD1(CommonLanguageToString, std::string(hmi_apis::Common_Language::eType)); + MOCK_METHOD1(MobileLanguageToString, + std::string(mobile_apis::Language::eType)); MOCK_METHOD2(CreateModuleInfoSO, smart_objects::SmartObjectSPtr(uint32_t function_id, ApplicationManager& app_mngr)); @@ -201,14 +206,16 @@ class MockMessageHelper { MessageHelper::ChoiceSetVRCommandsStatus( const smart_objects::SmartObject&)); - MOCK_METHOD6(GetBCActivateAppRequestToHMI, + MOCK_METHOD5(GetBCActivateAppRequestToHMI, smart_objects::SmartObjectSPtr( ApplicationConstSharedPtr app, - const protocol_handler::SessionObserver& session_observer, const policy::PolicyHandlerInterface& policy_handler, hmi_apis::Common_HMILevel::eType level, bool send_policy_priority, ApplicationManager& app_mngr)); + MOCK_METHOD2(GetBCCloseApplicationRequestToHMI, + smart_objects::SmartObjectSPtr(ApplicationConstSharedPtr app, + ApplicationManager& app_mngr)); MOCK_METHOD2(GetOnAppInterfaceUnregisteredNotificationToMobile, ns_smart_device_link::ns_smart_objects::SmartObjectSPtr( int32_t connection_key, @@ -219,6 +226,11 @@ class MockMessageHelper { ApplicationConstSharedPtr app, const policy::PolicyHandlerInterface& policy_handler, ApplicationManager& app_mngr)); + MOCK_METHOD4(SubscribeApplicationToSoftButton, + void(smart_objects::SmartObject& message_params, + ApplicationSharedPtr app, + int32_t function_id, + const application_manager::WindowID window_id)); MOCK_METHOD3(SubscribeApplicationToSoftButton, void(smart_objects::SmartObject& message_params, ApplicationSharedPtr app, @@ -278,6 +290,10 @@ class MockMessageHelper { MOCK_METHOD1(PrintSmartObject, bool(const smart_objects::SmartObject& object)); + + MOCK_METHOD1(ExtractWindowIdFromSmartObject, + WindowID(const smart_objects::SmartObject& s_map)); + MOCK_METHOD3(SendTTSGlobalProperties, void(ApplicationSharedPtr app, const bool default_help_prompt, @@ -316,6 +332,22 @@ class MockMessageHelper { MOCK_METHOD2(BroadcastCapabilityUpdate, void(smart_objects::SmartObject& msg_params, ApplicationManager& app_mngr)); + MOCK_METHOD3(CreateUICreateWindowRequestsToHMI, + smart_objects::SmartObjectList( + ApplicationSharedPtr application, + ApplicationManager& app_manager, + const smart_objects::SmartObject& windows_info)); + MOCK_METHOD2( + CreateDisplayCapabilityUpdateToMobile, + smart_objects::SmartObjectSPtr(const smart_objects::SmartObject&, + application_manager::Application&)); + MOCK_METHOD4(CreateOnServiceUpdateNotification, + smart_objects::SmartObjectSPtr( + const hmi_apis::Common_ServiceType::eType service_type, + const hmi_apis::Common_ServiceEvent::eType service_event, + const hmi_apis::Common_ServiceStatusUpdateReason::eType + service_update_reason, + const uint32_t app_id)); static MockMessageHelper* message_helper_mock(); }; diff --git a/src/components/application_manager/test/include/application_manager/mock_request.h b/src/components/application_manager/test/include/application_manager/mock_request.h index e4cfa848417..77b5bb7c38a 100644 --- a/src/components/application_manager/test/include/application_manager/mock_request.h +++ b/src/components/application_manager/test/include/application_manager/mock_request.h @@ -33,8 +33,8 @@ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_TEST_INCLUDE_APPLICATION_MANAGER_MOCK_REQUEST_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_TEST_INCLUDE_APPLICATION_MANAGER_MOCK_REQUEST_H_ -#include "gmock/gmock.h" #include "application_manager/commands/command.h" +#include "gmock/gmock.h" namespace test { namespace components { @@ -55,6 +55,7 @@ class MockRequest : public application_manager::commands::Command { MOCK_METHOD0(CleanUp, bool()); MOCK_CONST_METHOD0(default_timeout, uint32_t()); MOCK_CONST_METHOD0(function_id, int32_t()); + MOCK_CONST_METHOD0(window_id, application_manager::WindowID()); MOCK_METHOD0(onTimeOut, void()); MOCK_METHOD0(AllowedToTerminate, bool()); MOCK_METHOD1(SetAllowedToTerminate, void(bool is_allowed)); 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 0fa7a898bea..56c2ae3cd46 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 @@ -31,9 +31,9 @@ */ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_TEST_INCLUDE_APPLICATION_MANAGER_MOCK_RESUME_CTRL_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_TEST_INCLUDE_APPLICATION_MANAGER_MOCK_RESUME_CTRL_H_ -#include "gmock/gmock.h" -#include "application_manager/resumption/resume_ctrl.h" #include "application_manager/application.h" +#include "application_manager/resumption/resume_ctrl.h" +#include "gmock/gmock.h" #include "resumption/last_state.h" namespace test { @@ -94,13 +94,23 @@ class MockResumeCtrl : public resumption::ResumeCtrl { MOCK_METHOD1(SetupDefaultHMILevel, bool(application_manager::ApplicationSharedPtr application)); MOCK_METHOD1(StartAppHmiStateResumption, - void(application_manager::ApplicationSharedPtr application)); + bool(application_manager::ApplicationSharedPtr application)); MOCK_METHOD3(SetAppHMIState, bool(application_manager::ApplicationSharedPtr application, const mobile_apis::HMILevel::eType hmi_level, bool check_policy)); MOCK_CONST_METHOD0(LaunchTime, time_t()); + MOCK_METHOD2(RestoreAppWidgets, + void(app_mngr::ApplicationSharedPtr application, + const smart_objects::SmartObject& saved_app)); + + MOCK_METHOD1(RestoreWidgetsHMIState, + void(const smart_objects::SmartObject& response_message)); + + MOCK_METHOD1(StartWaitingForDisplayCapabilitiesUpdate, + void(application_manager::ApplicationSharedPtr application)); + #ifdef BUILD_TESTS MOCK_METHOD1(set_resumption_storage, void(std::shared_ptr mock_storage)); 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 38d1944dba4..7cabc120863 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 @@ -1,42 +1,42 @@ /* -* 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. -*/ + * 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_TEST_INCLUDE_APPLICATION_MANAGER_MOCK_RESUMPTION_DATA_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_TEST_INCLUDE_APPLICATION_MANAGER_MOCK_RESUMPTION_DATA_H_ #include -#include "gmock/gmock.h" -#include "application_manager/resumption/resumption_data.h" #include "application_manager/application.h" -#include "application_manager/mock_application_manager_settings.h" #include "application_manager/mock_application_manager.h" +#include "application_manager/mock_application_manager_settings.h" +#include "application_manager/resumption/resumption_data.h" +#include "gmock/gmock.h" #include "smart_objects/smart_object.h" namespace test { diff --git a/src/components/application_manager/test/include/application_manager/mock_rpc_protection_manager.h b/src/components/application_manager/test/include/application_manager/mock_rpc_protection_manager.h new file mode 100644 index 00000000000..112de0fea59 --- /dev/null +++ b/src/components/application_manager/test/include/application_manager/mock_rpc_protection_manager.h @@ -0,0 +1,65 @@ +/* + * Copyright (c) 2019, 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_TEST_INCLUDE_APPLICATION_MANAGER_MOCK_RPC_PROTECTION_MANAGER_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_TEST_INCLUDE_APPLICATION_MANAGER_MOCK_RPC_PROTECTION_MANAGER_H_ + +#include "application_manager/rpc_protection_manager.h" +#include "gmock/gmock.h" + +namespace application_manager { +class MockRPCProtectionManager : public RPCProtectionManager { + public: + MOCK_CONST_METHOD3(CheckPolicyEncryptionFlag, + bool(const uint32_t function_id, + const ApplicationSharedPtr app, + const bool is_rpc_service_secure)); + + MOCK_METHOD3(CreateEncryptionNeededResponse, + std::shared_ptr( + const uint32_t connection_key, + const uint32_t function_id, + const uint32_t conrrelation_id)); + + MOCK_CONST_METHOD2(IsInEncryptionNeededCache, + bool(const uint32_t app_id, + const uint32_t conrrelation_id)); + + MOCK_METHOD2(AddToEncryptionNeededCache, + void(const uint32_t app_id, const uint32_t correlation_id)); + + MOCK_METHOD2(RemoveFromEncryptionNeededCache, + void(const uint32_t app_id, const uint32_t correlation_id)); +}; +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_TEST_INCLUDE_APPLICATION_MANAGER_MOCK_RPC_PROTECTION_MANAGER_H_ diff --git a/src/components/application_manager/test/include/application_manager/mock_rpc_protection_mediator.h b/src/components/application_manager/test/include/application_manager/mock_rpc_protection_mediator.h new file mode 100644 index 00000000000..858673e3b35 --- /dev/null +++ b/src/components/application_manager/test/include/application_manager/mock_rpc_protection_mediator.h @@ -0,0 +1,22 @@ +#pragma once + +#include "application_manager/rpc_protection_mediator.h" +#include "gmock/gmock.h" + +namespace application_manager { +class MockRPCProtectionMediator : public RPCProtectionMediator { + public: + MOCK_METHOD4(DoesRPCNeedEncryption, + bool(const uint32_t function_id, + std::shared_ptr app, + const uint32_t conrrelation_id, + const bool is_rpc_service_secure)); + MOCK_METHOD1(DoesRPCNeedEncryption, bool(const uint32_t conrrelation_id)); + MOCK_METHOD1(EncryptResponseByForce, void(const uint32_t conrrelation_id)); + MOCK_METHOD3(CreateNegativeResponse, + std::shared_ptr( + const uint32_t connection_key, + const uint32_t function_id, + const uint32_t conrrelation_id)); +}; +} // namespace application_manager diff --git a/src/components/application_manager/test/include/application_manager/mock_telemetry_observer.h b/src/components/application_manager/test/include/application_manager/mock_telemetry_observer.h index cd4632965c7..c79a31817e6 100644 --- a/src/components/application_manager/test/include/application_manager/mock_telemetry_observer.h +++ b/src/components/application_manager/test/include/application_manager/mock_telemetry_observer.h @@ -33,8 +33,8 @@ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_TEST_INCLUDE_APPLICATION_MANAGER_MOCK_TELEMETRY_OBSERVER_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_TEST_INCLUDE_APPLICATION_MANAGER_MOCK_TELEMETRY_OBSERVER_H_ -#include "gmock/gmock.h" #include "application_manager/telemetry_observer.h" +#include "gmock/gmock.h" namespace test { namespace components { diff --git a/src/components/application_manager/test/include/application_manager/resumption_data_test.h b/src/components/application_manager/test/include/application_manager/resumption_data_test.h index 4e614c4d9fe..e3134275470 100644 --- a/src/components/application_manager/test/include/application_manager/resumption_data_test.h +++ b/src/components/application_manager/test/include/application_manager/resumption_data_test.h @@ -33,20 +33,20 @@ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_TEST_INCLUDE_APPLICATION_MANAGER_RESUMPTION_DATA_TEST_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_TEST_INCLUDE_APPLICATION_MANAGER_RESUMPTION_DATA_TEST_H_ -#include #include -#include "gtest/gtest.h" -#include "application_manager/usage_statistics.h" +#include +#include "application_manager/event_engine/event_dispatcher.h" +#include "application_manager/mock_app_extension.h" #include "application_manager/mock_application.h" #include "application_manager/mock_application_manager.h" -#include "application_manager/mock_app_extension.h" -#include "utils/data_accessor.h" -#include "config_profile/profile.h" +#include "application_manager/mock_application_manager_settings.h" #include "application_manager/policies/policy_handler.h" -#include "application_manager/state_controller.h" #include "application_manager/resumption/resume_ctrl.h" -#include "application_manager/event_engine/event_dispatcher.h" -#include "application_manager/mock_application_manager_settings.h" +#include "application_manager/state_controller.h" +#include "application_manager/usage_statistics.h" +#include "config_profile/profile.h" +#include "gtest/gtest.h" +#include "utils/data_accessor.h" namespace test { namespace components { @@ -74,7 +74,9 @@ class ResumptionDataTest : public ::testing::Test { , comlock_ptr_(std::make_shared()) , setlock_ptr_(std::make_shared()) , btnlock_ptr_(std::make_shared()) - , ivilock_ptr_(std::make_shared()) {} + , ivilock_ptr_(std::make_shared()) + , window_params_map_lock_ptr_(std::make_shared()) { + } // Check structure in saved application void CheckSavedApp(sm::SmartObject& saved_data); // Set data for resumption @@ -114,6 +116,9 @@ class ResumptionDataTest : public ::testing::Test { void SetHelpAndTimeoutPrompt(); void SetVRHelpTitle(); void SetSubscriptions(); + void SetWindowsInfo(); + void SetDefaultCurrentHmiState(); + void SetDefaultWindowIds(); void CheckCommands(sm::SmartObject& res_list); void CheckGlobalProporties(sm::SmartObject& res_list); @@ -129,6 +134,7 @@ class ResumptionDataTest : public ::testing::Test { ns_smart_device_link::ns_smart_objects::SmartObject& res_list); void CheckVRTitle(sm::SmartObject& res_list); void CheckSubscriptions(sm::SmartObject& res_list); + void CheckWindowsInfo(sm::SmartObject& res_list); const size_t kCountOfCommands_; const size_t kCountOfChoice_; @@ -145,11 +151,14 @@ class ResumptionDataTest : public ::testing::Test { am::ButtonSubscriptions btn_subscr; + am::WindowParamsMap test_window_params_map_; + std::shared_ptr sublock_ptr_; std::shared_ptr comlock_ptr_; std::shared_ptr setlock_ptr_; std::shared_ptr btnlock_ptr_; std::shared_ptr ivilock_ptr_; + std::shared_ptr window_params_map_lock_ptr_; application_manager_test::MockApplicationManagerSettings mock_application_manager_settings_; application_manager_test::MockApplicationManager mock_application_manager_; diff --git a/src/components/application_manager/test/include/application_manager/test_resumption_data_db.h b/src/components/application_manager/test/include/application_manager/test_resumption_data_db.h index e10f60afac1..3f5802cb5a3 100644 --- a/src/components/application_manager/test/include/application_manager/test_resumption_data_db.h +++ b/src/components/application_manager/test/include/application_manager/test_resumption_data_db.h @@ -33,10 +33,10 @@ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_TEST_INCLUDE_APPLICATION_MANAGER_TEST_RESUMPTION_DATA_DB_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_TEST_INCLUDE_APPLICATION_MANAGER_TEST_RESUMPTION_DATA_DB_H_ -#include "utils/sqlite_wrapper/sql_database.h" -#include "application_manager/resumption/resumption_data_db.h" -#include "application_manager/mock_application_manager_settings.h" #include "application_manager/mock_application_manager.h" +#include "application_manager/mock_application_manager_settings.h" +#include "application_manager/resumption/resumption_data_db.h" +#include "utils/sqlite_wrapper/sql_database.h" using ::resumption::ResumptionDataDB; diff --git a/src/components/application_manager/test/message_helper/CMakeLists.txt b/src/components/application_manager/test/message_helper/CMakeLists.txt index 99031849f60..31b175cbf0f 100755 --- a/src/components/application_manager/test/message_helper/CMakeLists.txt +++ b/src/components/application_manager/test/message_helper/CMakeLists.txt @@ -40,7 +40,7 @@ set(LIBRARIES ApplicationManager MessageHelper jsoncpp - Policy + PolicyStatic connectionHandler MediaManager Resumption 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 92be221ec93..a174d74d5db 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 @@ -36,18 +36,18 @@ #include "gmock/gmock.h" #include "utils/macro.h" -#include "application_manager/policies/policy_handler.h" -#include "application_manager/mock_application.h" -#include "application_manager/mock_help_prompt_manager.h" -#include "utils/custom_string.h" -#include "utils/lock.h" -#include "policy/mock_policy_settings.h" #include "application_manager/commands/command_impl.h" +#include "application_manager/event_engine/event_dispatcher.h" +#include "application_manager/mock_application.h" #include "application_manager/mock_application_manager.h" +#include "application_manager/mock_help_prompt_manager.h" #include "application_manager/mock_rpc_service.h" -#include "application_manager/event_engine/event_dispatcher.h" -#include "application_manager/state_controller.h" +#include "application_manager/policies/policy_handler.h" #include "application_manager/resumption/resume_ctrl.h" +#include "application_manager/state_controller.h" +#include "policy/mock_policy_settings.h" +#include "utils/custom_string.h" +#include "utils/lock.h" #include "policy/policy_table/types.h" #include "rpc_base/rpc_base_json_inl.h" @@ -70,12 +70,12 @@ typedef std::shared_ptr MockApplicationSharedPtr; typedef std::vector StringArray; typedef std::shared_ptr ApplicationSharedPtr; +using testing::_; using testing::AtLeast; -using testing::ReturnRefOfCopy; -using testing::ReturnRef; using testing::Return; +using testing::ReturnRef; +using testing::ReturnRefOfCopy; using testing::SaveArg; -using testing::_; TEST(MessageHelperTestCreate, CreateBlockedByPoliciesResponse_SmartObject_Equal) { @@ -951,7 +951,8 @@ TEST_F(MessageHelperTest, SubscribeApplicationToSoftButton_CallFromApp) { size_t function_id = 1; // EXPECT_CALL(*appSharedPtr, - SubscribeToSoftButtons(function_id, SoftButtonID())).Times(1); + SubscribeToSoftButtons(function_id, SoftButtonID())) + .Times(1); MessageHelper::SubscribeApplicationToSoftButton( message_params, appSharedPtr, function_id); } @@ -1083,6 +1084,27 @@ TEST_F(MessageHelperTest, SendNaviSetVideoConfigRequest) { EXPECT_EQ(480, msg_params[strings::config][strings::height].asInt()); } +TEST_F(MessageHelperTest, ExtractWindowIdFromSmartObject_SUCCESS) { + const WindowID window_id = 145; + smart_objects::SmartObject message(smart_objects::SmartType_Map); + message[strings::msg_params][strings::window_id] = window_id; + EXPECT_EQ(window_id, + MessageHelper::ExtractWindowIdFromSmartObject( + message[strings::msg_params])); +} + +TEST_F(MessageHelperTest, ExtractWindowIdFromSmartObject_FromEmptyMessage) { + smart_objects::SmartObject message(smart_objects::SmartType_Map); + EXPECT_EQ(mobile_apis::PredefinedWindows::DEFAULT_WINDOW, + MessageHelper::ExtractWindowIdFromSmartObject(message)); +} + +TEST_F(MessageHelperTest, ExtractWindowIdFromSmartObject_FromWrongType) { + smart_objects::SmartObject message(smart_objects::SmartType_Array); + EXPECT_EQ(mobile_apis::PredefinedWindows::DEFAULT_WINDOW, + MessageHelper::ExtractWindowIdFromSmartObject(message)); +} + } // namespace application_manager_test } // namespace components } // namespace test diff --git a/src/components/application_manager/test/mobile_event_engine_test.cc b/src/components/application_manager/test/mobile_event_engine_test.cc new file mode 100644 index 00000000000..cad1ff14ff0 --- /dev/null +++ b/src/components/application_manager/test/mobile_event_engine_test.cc @@ -0,0 +1,171 @@ +/* + * 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. + */ + +#include "gtest/gtest.h" + +#include "application_manager/event_engine/event.h" +#include "application_manager/event_engine/event_dispatcher_impl.h" +#include "application_manager/event_engine/event_observer.h" +#include "application_manager/message.h" +#include "application_manager/mock_event_dispatcher.h" +#include "application_manager/mock_event_observer.h" +#include "smart_objects/smart_object.h" + +#include "interfaces/MOBILE_API.h" + +namespace test { +namespace components { +namespace event_engine_test { + +using application_manager::event_engine::Event; +using application_manager::event_engine::EventDispatcherImpl; +using application_manager::event_engine::EventObserver; +using application_manager::event_engine::MobileEvent; +using testing::_; +using ::testing::An; +using ::testing::Matcher; + +class MobileEventEngineTest : public testing::Test { + public: + MobileEventEngineTest() + : event_id(MobileEvent::MobileEventID::GetAppServiceDataID) + , event_observer_mock_(mock_event_dispatcher_) {} + + protected: + EventDispatcherImpl* event_dispatcher_instance_; + MobileEvent* event_; + const MobileEvent::MobileEventID event_id; + MockEventDispatcher mock_event_dispatcher_; + MockEventObserver event_observer_mock_; + const int32_t correlation_id = 1121; + smart_objects::SmartObject smart_object_with_type_notification; + smart_objects::SmartObject smart_object_with_type_response; + smart_objects::SmartObject smart_object_with_type_error_response; + smart_objects::SmartObject smart_object_with_type_request; + smart_objects::SmartObject smart_object_with_invalid_type; + + virtual void SetUp() OVERRIDE { + event_dispatcher_instance_ = new EventDispatcherImpl(); + event_ = + new MobileEvent(mobile_apis::FunctionID::eType::GetAppServiceDataID); + smart_object_with_type_notification["params"]["message_type"] = + application_manager::MessageType::kNotification; + smart_object_with_type_notification["params"]["correlation_id"] = + correlation_id; + smart_object_with_type_notification["params"]["function_id"] = + mobile_apis::FunctionID::eType::GetAppServiceDataID; + + smart_object_with_type_response["params"]["message_type"] = + application_manager::MessageType::kResponse; + smart_object_with_type_response["params"]["correlation_id"] = + correlation_id; + smart_object_with_type_response["params"]["function_id"] = + mobile_apis::FunctionID::eType::GetAppServiceDataID; + + smart_object_with_type_request["params"]["message_type"] = + application_manager::MessageType::kRequest; + smart_object_with_type_request["params"]["correlation_id"] = correlation_id; + smart_object_with_type_request["params"]["function_id"] = + mobile_apis::FunctionID::eType::GetAppServiceDataID; + + smart_object_with_invalid_type["params"]["message_type"] = + application_manager::MessageType::kUnknownType; + smart_object_with_invalid_type["params"]["correlation_id"] = correlation_id; + smart_object_with_invalid_type["params"]["function_id"] = + mobile_apis::FunctionID::eType::GetAppServiceDataID; + } + + void TearDown() OVERRIDE { + delete event_dispatcher_instance_; + delete event_; + } + + void CheckRaiseMobileEvent(const MobileEvent::MobileEventID& event_id, + const uint32_t calls_number, + const smart_objects::SmartObject& so) { + // Arrange + event_dispatcher_instance_->add_mobile_observer( + event_id, correlation_id, event_observer_mock_); + event_->set_smart_object(so); + EXPECT_CALL(event_observer_mock_, on_event(An())) + .Times(calls_number); + event_dispatcher_instance_->raise_mobile_event(*event_); + } +}; + +TEST_F(MobileEventEngineTest, EventObserverTest_ExpectObserversEmpty) { + // Arrange + EventObserver* event_observer_ptr = + static_cast(&event_observer_mock_); + // Check + EXPECT_EQ(reinterpret_cast(event_observer_ptr), + event_observer_mock_.id()); +} + +TEST_F(MobileEventEngineTest, + EventDispatcherImpl_RaiseEvent_EventSOTypeResponse_ExpectEventRaised) { + CheckRaiseMobileEvent(event_id, 1u, smart_object_with_type_response); +} + +TEST_F(MobileEventEngineTest, + EventDispatcherImpl_RaiseEvent_EventSOTypeInvalid_ExpectEventNotRaised) { + CheckRaiseMobileEvent(event_id, 0u, smart_object_with_invalid_type); +} + +TEST_F(MobileEventEngineTest, + EventDispatcherImpl_RaiseEvent_EventSOTypeRequest_ExpectEventNotRaised) { + CheckRaiseMobileEvent(event_id, 0u, smart_object_with_type_request); +} + +TEST_F( + MobileEventEngineTest, + EventDispatcherImpl_RaiseEvent_EventSOTypeNotification_ExpectEventNotRaised) { + CheckRaiseMobileEvent(event_id, 0u, smart_object_with_type_notification); +} + +TEST_F(MobileEventEngineTest, Event_set_smart_object_ExpectObjectSet) { + // Act + event_->set_smart_object(smart_object_with_type_response); + const int32_t obj_type = + static_cast(application_manager::MessageType::kResponse); + const int32_t function_id = + static_cast(mobile_apis::FunctionID::eType::GetAppServiceDataID); + // Checks + EXPECT_EQ(obj_type, event_->smart_object_type()); + EXPECT_EQ(function_id, event_->smart_object_function_id()); + EXPECT_EQ(correlation_id, event_->smart_object_correlation_id()); + EXPECT_EQ(smart_object_with_type_response, event_->smart_object()); +} + +} // namespace event_engine_test +} // namespace components +} // namespace test diff --git a/src/components/application_manager/test/mobile_message_handler_test.cc b/src/components/application_manager/test/mobile_message_handler_test.cc index 23957b61fbf..3ae79ce8ce3 100644 --- a/src/components/application_manager/test/mobile_message_handler_test.cc +++ b/src/components/application_manager/test/mobile_message_handler_test.cc @@ -32,30 +32,30 @@ #include "application_manager/mobile_message_handler.h" -#include -#include #include +#include #include +#include #include -#include "gmock/gmock.h" #include "application_manager/message.h" +#include "gmock/gmock.h" #include "protocol/raw_message.h" namespace test { namespace components { namespace application_manager_test { +using ::application_manager::Message; +using ::application_manager::MobileMessage; +using application_manager::MobileMessageHandler; +using protocol_handler::MajorProtocolVersion; +using protocol_handler::MessagePriority; +using protocol_handler::PROTOCOL_HEADER_V2_SIZE; using protocol_handler::RawMessage; using protocol_handler::RawMessagePtr; using protocol_handler::ServiceType; -using protocol_handler::MessagePriority; -using protocol_handler::PROTOCOL_HEADER_V2_SIZE; -using application_manager::MobileMessageHandler; -using protocol_handler::MajorProtocolVersion; using ::testing::_; -using ::application_manager::Message; -using ::application_manager::MobileMessage; using testing::Return; @@ -109,6 +109,7 @@ class MobileMessageHandlerTest : public testing::Test { protocol_version, &full_data[0], full_size, + false, ServiceType::kRpc, payload_size); diff --git a/src/components/application_manager/test/mobile_message_handler_v1_test.cc b/src/components/application_manager/test/mobile_message_handler_v1_test.cc index 5cbc28b20c1..ab37694c282 100644 --- a/src/components/application_manager/test/mobile_message_handler_v1_test.cc +++ b/src/components/application_manager/test/mobile_message_handler_v1_test.cc @@ -32,19 +32,19 @@ #include "application_manager/mobile_message_handler.h" -#include -#include #include #include +#include +#include -#include "gmock/gmock.h" #include "application_manager/message.h" +#include "gmock/gmock.h" #include "protocol/raw_message.h" +using application_manager::MobileMessageHandler; +using protocol_handler::PROTOCOL_HEADER_V1_SIZE; using protocol_handler::RawMessage; using protocol_handler::RawMessagePtr; -using protocol_handler::PROTOCOL_HEADER_V1_SIZE; -using application_manager::MobileMessageHandler; namespace test { namespace components { @@ -69,8 +69,11 @@ const unsigned char* data_v1 = TEST(MobileMessageHandlerTestV1Test, HandleIncomingMessageProtocolV1_SendJSONData_ExpectEqual) { - RawMessagePtr message = std::make_shared( - connection_key_p1, protocol_version_1, data_v1, data_json.length()); + RawMessagePtr message = std::make_shared(connection_key_p1, + protocol_version_1, + data_v1, + data_json.length(), + false); application_manager::Message* ptr = MobileMessageHandler::HandleIncomingMessageProtocol(message); @@ -89,8 +92,11 @@ TEST(MobileMessageHandlerTestV1Test, const unsigned char* data_v1 = reinterpret_cast(full_data.c_str()); - RawMessagePtr message = std::make_shared( - connection_key_p1, protocol_version_1, data_v1, full_data.length()); + RawMessagePtr message = std::make_shared(connection_key_p1, + protocol_version_1, + data_v1, + full_data.length(), + false); application_manager::Message* ptr = MobileMessageHandler::HandleIncomingMessageProtocol(message); diff --git a/src/components/application_manager/test/mock_application_helper.cc b/src/components/application_manager/test/mock_application_helper.cc index c64a56e53e4..ea57709a734 100644 --- a/src/components/application_manager/test/mock_application_helper.cc +++ b/src/components/application_manager/test/mock_application_helper.cc @@ -41,15 +41,16 @@ MockApplicationHelper& MockApplicationHelper::application_helper_mock() { return application_helper_mock; } -} // application_manager_test -} // components -} // test +} // namespace application_manager_test +} // namespace components +} // namespace test namespace application_manager { void DeleteApplicationData(ApplicationSharedPtr app, ApplicationManager& app_manager) { test::components::application_manager_test::MockApplicationHelper:: - application_helper_mock().RecallApplicationData(app, app_manager); + application_helper_mock() + .RecallApplicationData(app, app_manager); } -} // application_managers +} // namespace application_manager diff --git a/src/components/application_manager/test/mock_hmi_command_factory.cc b/src/components/application_manager/test/mock_hmi_command_factory.cc index 375da26067f..5f76a9300b8 100644 --- a/src/components/application_manager/test/mock_hmi_command_factory.cc +++ b/src/components/application_manager/test/mock_hmi_command_factory.cc @@ -30,9 +30,9 @@ POSSIBILITY OF SUCH DAMAGE. */ +#include "application_manager/mock_hmi_command_factory.h" #include #include "application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/hmi_command_factory.h" -#include "application_manager/mock_hmi_command_factory.h" namespace test { namespace components { @@ -43,9 +43,9 @@ MockHMICommandFactory* MockHMICommandFactory::mock_hmi_command_factory() { return &mock_hmi_command_factory; } -} // application_manager_test -} // components -} // test +} // namespace application_manager_test +} // namespace components +} // namespace test namespace sdl_rpc_plugin { namespace app_mngr = application_manager; @@ -53,6 +53,7 @@ app_mngr::CommandSharedPtr HMICommandFactory::CreateCommand( const app_mngr::commands::MessageSharedPtr& message, app_mngr::ApplicationManager& application_manager) { return test::components::application_manager_test::MockHMICommandFactory:: - mock_hmi_command_factory()->CreateCommand(message, application_manager); + mock_hmi_command_factory() + ->CreateCommand(message, application_manager); } -} // application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/test/mock_message_helper.cc b/src/components/application_manager/test/mock_message_helper.cc old mode 100644 new mode 100755 index 518761c3150..628fd97ae85 --- a/src/components/application_manager/test/mock_message_helper.cc +++ b/src/components/application_manager/test/mock_message_helper.cc @@ -30,12 +30,12 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include "application_manager/message_helper.h" #include "application_manager/mock_message_helper.h" +#include "application_manager/message_helper.h" #include "application_manager/policies/policy_handler_interface.h" -#include "transport_manager/common.h" -#include "gtest/gtest.h" #include "gmock/gmock.h" +#include "gtest/gtest.h" +#include "transport_manager/common.h" namespace application_manager { @@ -212,9 +212,10 @@ void MessageHelper::SendGetListOfPermissionsResponse( void MessageHelper::SendOnPermissionsChangeNotification( uint32_t connection_key, const policy::Permissions& permissions, - ApplicationManager& app_mngr) { + ApplicationManager& app_mngr, + const policy::EncryptionRequired require_encryption) { MockMessageHelper::message_helper_mock()->SendOnPermissionsChangeNotification( - connection_key, permissions, app_mngr); + connection_key, permissions, app_mngr, require_encryption); } void MessageHelper::SendPolicySnapshotNotification( @@ -258,10 +259,11 @@ smart_objects::SmartObjectSPtr MessageHelper::CreateMessageForHMI( } void MessageHelper::SendHMIStatusNotification( - const Application& application_impl, + ApplicationSharedPtr application, + const WindowID window_id, ApplicationManager& application_manager) { MockMessageHelper::message_helper_mock()->SendHMIStatusNotification( - application_impl, application_manager); + application, window_id, application_manager); } void MessageHelper::SendUpdateSDLResponse(const std::string& result, @@ -366,20 +368,25 @@ std::string MessageHelper::CommonLanguageToString( return MockMessageHelper::message_helper_mock()->CommonLanguageToString(lang); } +std::string MessageHelper::MobileLanguageToString( + mobile_apis::Language::eType lang) { + return MockMessageHelper::message_helper_mock()->MobileLanguageToString(lang); +} + smart_objects::SmartObjectSPtr MessageHelper::GetBCActivateAppRequestToHMI( ApplicationConstSharedPtr app, - const protocol_handler::SessionObserver& session_observer, const policy::PolicyHandlerInterface& policy_handler, hmi_apis::Common_HMILevel::eType level, bool send_policy_priority, ApplicationManager& app_mngr) { return MockMessageHelper::message_helper_mock()->GetBCActivateAppRequestToHMI( - app, - session_observer, - policy_handler, - level, - send_policy_priority, - app_mngr); + app, policy_handler, level, send_policy_priority, app_mngr); +} + +smart_objects::SmartObjectSPtr MessageHelper::GetBCCloseApplicationRequestToHMI( + ApplicationConstSharedPtr app, ApplicationManager& app_mngr) { + return MockMessageHelper::message_helper_mock() + ->GetBCCloseApplicationRequestToHMI(app, app_mngr); } ns_smart_device_link::ns_smart_objects::SmartObjectSPtr @@ -400,6 +407,16 @@ mobile_apis::Result::eType MessageHelper::ProcessSoftButtons( message_params, app, policy_handler, app_mngr); } +void MessageHelper::SubscribeApplicationToSoftButton( + smart_objects::SmartObject& message_params, + ApplicationSharedPtr app, + int32_t function_id, + const WindowID window_id) { + return MockMessageHelper::message_helper_mock() + ->SubscribeApplicationToSoftButton( + message_params, app, function_id, window_id); +} + void MessageHelper::SubscribeApplicationToSoftButton( smart_objects::SmartObject& message_params, ApplicationSharedPtr app, @@ -523,6 +540,12 @@ bool MessageHelper::PrintSmartObject(const smart_objects::SmartObject& object) { return MockMessageHelper::message_helper_mock()->PrintSmartObject(object); } +WindowID MessageHelper::ExtractWindowIdFromSmartObject( + const smart_objects::SmartObject& s_map) { + return MockMessageHelper::message_helper_mock() + ->ExtractWindowIdFromSmartObject(s_map); +} + void MessageHelper::SendSetAppIcon(const uint32_t app_id, const std::string& icon_path, ApplicationManager& application_manager) { @@ -589,4 +612,30 @@ void MessageHelper::BroadcastCapabilityUpdate( MockMessageHelper::message_helper_mock()->BroadcastCapabilityUpdate( msg_params, app_mngr); } + +smart_objects::SmartObjectList MessageHelper::CreateUICreateWindowRequestsToHMI( + application_manager::ApplicationSharedPtr application, + ApplicationManager& app_mngr, + const smart_objects::SmartObject& windows_info) { + return MockMessageHelper::message_helper_mock() + ->CreateUICreateWindowRequestsToHMI(application, app_mngr, windows_info); +} + +smart_objects::SmartObjectSPtr +MessageHelper::CreateDisplayCapabilityUpdateToMobile( + const smart_objects::SmartObject& system_capabilities, Application& app) { + return MockMessageHelper::message_helper_mock() + ->CreateDisplayCapabilityUpdateToMobile(system_capabilities, app); +} + +smart_objects::SmartObjectSPtr MessageHelper::CreateOnServiceUpdateNotification( + const hmi_apis::Common_ServiceType::eType service_type, + const hmi_apis::Common_ServiceEvent::eType service_event, + const hmi_apis::Common_ServiceStatusUpdateReason::eType + service_update_reason, + const uint32_t app_id) { + return MockMessageHelper::message_helper_mock() + ->CreateOnServiceUpdateNotification( + service_type, service_event, service_update_reason, app_id); +} } // namespace application_manager diff --git a/src/components/application_manager/test/policy_event_observer_test.cc b/src/components/application_manager/test/policy_event_observer_test.cc index 9b97f054b37..a74b12071cd 100644 --- a/src/components/application_manager/test/policy_event_observer_test.cc +++ b/src/components/application_manager/test/policy_event_observer_test.cc @@ -33,10 +33,10 @@ #include "application_manager/policies/policy_event_observer.h" #include "application_manager/policies/mock_policy_handler_interface.h" +#include "application_manager/mock_event_dispatcher.h" #include "gmock/gmock.h" #include "policy/policy_types.h" #include "smart_objects/smart_object.h" -#include "application_manager/mock_event_dispatcher.h" namespace test { namespace components { diff --git a/src/components/application_manager/test/policy_handler_test.cc b/src/components/application_manager/test/policy_handler_test.cc index af21a705bf7..f99b76b9ad7 100644 --- a/src/components/application_manager/test/policy_handler_test.cc +++ b/src/components/application_manager/test/policy_handler_test.cc @@ -30,48 +30,47 @@ * POSSIBILITY OF SUCH DAMAGE. */ +#include #include #include -#include #include "gmock/gmock.h" -#include "application_manager/policies/policy_handler.h" +#include "application_manager/application_impl.h" +#include "application_manager/application_manager_impl.h" #include "application_manager/policies/delegates/app_permission_delegate.h" +#include "application_manager/policies/policy_handler.h" #include "connection_handler/connection_handler_impl.h" -#include "application_manager/application_manager_impl.h" -#include "application_manager/application_impl.h" #ifdef ENABLE_SECURITY -#include "security_manager/mock_security_manager.h" #include "security_manager/mock_crypto_manager.h" +#include "security_manager/mock_security_manager.h" #endif // ENABLE_SECURITY #include "application_manager/mock_message_helper.h" #include "connection_handler/mock_connection_handler_settings.h" -#include "transport_manager/mock_transport_manager.h" -#include "policy/policy_types.h" #include "json/reader.h" -#include "json/writer.h" #include "json/value.h" +#include "json/writer.h" +#include "policy/policy_types.h" #include "smart_objects/smart_object.h" +#include "transport_manager/mock_transport_manager.h" #include "utils/file_system.h" -#include "utils/custom_string.h" -#include "policy/usage_statistics/counter.h" -#include "policy/usage_statistics/statistics_manager.h" #include "interfaces/MOBILE_API.h" #include "policy/mock_policy_settings.h" +#include "policy/usage_statistics/counter.h" +#include "policy/usage_statistics/statistics_manager.h" +#include "utils/custom_string.h" #include "application_manager/mock_application.h" -#include "policy/usage_statistics/mock_statistics_manager.h" -#include "protocol_handler/mock_session_observer.h" -#include "connection_handler/mock_connection_handler.h" #include "application_manager/mock_application_manager.h" -#include "application_manager/policies/mock_policy_handler_observer.h" #include "application_manager/mock_event_dispatcher.h" -#include "application_manager/mock_state_controller.h" #include "application_manager/mock_hmi_capabilities.h" #include "application_manager/mock_rpc_service.h" +#include "application_manager/mock_state_controller.h" +#include "application_manager/policies/mock_policy_handler_observer.h" +#include "connection_handler/mock_connection_handler.h" #include "policy/mock_policy_manager.h" #include "policy/usage_statistics/mock_statistics_manager.h" +#include "protocol_handler/mock_session_observer.h" namespace test { namespace components { @@ -92,6 +91,8 @@ using ::testing::SetArgReferee; typedef NiceMock MockRPCService; const std::string kDummyData = "some_data"; +const WindowID kDefaultWindowId = + mobile_apis::PredefinedWindows::DEFAULT_WINDOW; class PolicyHandlerTest : public ::testing::Test { public: @@ -174,8 +175,9 @@ class PolicyHandlerTest : public ::testing::Test { ON_CALL(policy_settings_, enable_policy()).WillByDefault(Return(true)); ON_CALL(app_manager_, event_dispatcher()) .WillByDefault(ReturnRef(mock_event_dispatcher_)); - std::string path = file_system::CreateDirectory("storage"); - file_system::CreateFile(path + "/" + "certificate"); + const std::string path("storage"); + if (file_system::CreateDirectory(path)) + file_system::CreateFile(path + "/" + "certificate"); mock_policy_manager_ = std::make_shared(); ASSERT_TRUE(mock_policy_manager_.use_count() != 0); @@ -234,21 +236,25 @@ class PolicyHandlerTest : public ::testing::Test { void TestOnPermissionsUpdated(const std::string& default_hmi_level, const mobile_apis::HMILevel::eType hmi_level) { - EXPECT_CALL(app_manager_, application_by_policy_id(kPolicyAppId_)) + EXPECT_CALL(app_manager_, application(kDeviceId, kPolicyAppId_)) .WillRepeatedly(Return(mock_app_)); EXPECT_CALL(*mock_app_, app_id()).WillRepeatedly(Return(kAppId1_)); - EXPECT_CALL(*mock_app_, hmi_level()) + EXPECT_CALL(*mock_app_, hmi_level(kDefaultWindowId)) .WillOnce(Return(mobile_apis::HMILevel::HMI_NONE)); EXPECT_CALL(mock_message_helper_, StringToHMILevel(default_hmi_level)) .WillOnce(Return(hmi_level)); + ChangePolicyManagerToMock(); + const policy::EncryptionRequired require_encryption; + EXPECT_CALL(*mock_policy_manager_, GetAppEncryptionRequired(kPolicyAppId_)) + .WillOnce(Return(require_encryption)); EXPECT_CALL(mock_message_helper_, - SendOnPermissionsChangeNotification(kAppId1_, _, _)); + SendOnPermissionsChangeNotification(kAppId1_, _, _, _)); EXPECT_CALL(app_manager_, state_controller()).Times(0); Permissions permissions; policy_handler_.OnPermissionsUpdated( - kPolicyAppId_, permissions, default_hmi_level); + kDeviceId, kPolicyAppId_, permissions, default_hmi_level); } void CreateFunctionalGroupPermission( @@ -396,7 +402,10 @@ TEST_F(PolicyHandlerTest, AppServiceUpdate_CheckAppService) { ifile.close(); BinaryMessage msg(json.begin(), json.end()); // Checks - EXPECT_CALL(*mock_policy_manager_, LoadPT("", msg)).WillOnce(Return(true)); + EXPECT_CALL(*mock_policy_manager_, LoadPT("", msg)) + .WillOnce(Return(PolicyManager::PtProcessingResult::kSuccess)); + EXPECT_CALL(*mock_policy_manager_, + OnPTUFinished(PolicyManager::PtProcessingResult::kSuccess)); policy_handler_.ReceiveMessageFromSDK("", msg); policy_table::AppServiceParameters app_service_params = @@ -463,7 +472,10 @@ TEST_F(PolicyHandlerTest, ReceiveMessageFromSDK) { EXPECT_CALL(app_manager_, GetNextHMICorrelationID()); EXPECT_CALL(mock_message_helper_, CreateGetVehicleDataRequest(_, _, _)); EXPECT_CALL(*mock_policy_manager_, PTUpdatedAt(_, _)); - EXPECT_CALL(*mock_policy_manager_, LoadPT("", msg)).WillOnce(Return(true)); + EXPECT_CALL(*mock_policy_manager_, LoadPT("", msg)) + .WillOnce(Return(PolicyManager::PtProcessingResult::kSuccess)); + EXPECT_CALL(*mock_policy_manager_, + OnPTUFinished(PolicyManager::PtProcessingResult::kSuccess)); EXPECT_CALL(*mock_policy_manager_, CleanupUnpairedDevices()); policy_handler_.ReceiveMessageFromSDK("", msg); } @@ -474,7 +486,11 @@ TEST_F(PolicyHandlerTest, ReceiveMessageFromSDK_PTNotLoaded) { BinaryMessage msg; // Checks - EXPECT_CALL(*mock_policy_manager_, LoadPT("", msg)).WillOnce(Return(false)); + EXPECT_CALL(*mock_policy_manager_, LoadPT("", msg)) + .WillOnce(Return(PolicyManager::PtProcessingResult::kWrongPtReceived)); + EXPECT_CALL( + *mock_policy_manager_, + OnPTUFinished(PolicyManager::PtProcessingResult::kWrongPtReceived)); EXPECT_CALL(app_manager_, GetNextHMICorrelationID()).Times(0); EXPECT_CALL(mock_message_helper_, CreateGetVehicleDataRequest(_, _, _)) .Times(0); @@ -495,38 +511,52 @@ TEST_F(PolicyHandlerTest, UnloadPolicyLibrary_method_ExpectLibraryUnloaded) { TEST_F(PolicyHandlerTest, OnPermissionsUpdated_method_With2Parameters) { // Check expectations - EXPECT_CALL(app_manager_, application_by_policy_id(kPolicyAppId_)) + ChangePolicyManagerToMock(); + const policy::EncryptionRequired require_encryption; + EXPECT_CALL(*mock_policy_manager_, GetAppEncryptionRequired(kPolicyAppId_)) + .WillOnce(Return(require_encryption)); + EXPECT_CALL(app_manager_, application(kDeviceId, kPolicyAppId_)) .WillOnce(Return(mock_app_)); EXPECT_CALL(*mock_app_, app_id()).WillOnce(Return(kAppId1_)); EXPECT_CALL(mock_message_helper_, - SendOnPermissionsChangeNotification(kAppId1_, _, _)); + SendOnPermissionsChangeNotification(kAppId1_, _, _, _)); // Act Permissions perms; - policy_handler_.OnPermissionsUpdated(kPolicyAppId_, perms); + policy_handler_.OnPermissionsUpdated(kDeviceId, kPolicyAppId_, perms); } TEST_F(PolicyHandlerTest, OnPermissionsUpdated_TwoParams_InvalidApp_UNSUCCESS) { std::shared_ptr invalid_app; - EXPECT_CALL(app_manager_, application_by_policy_id(kPolicyAppId_)) + EXPECT_CALL(app_manager_, application(kDeviceId, kPolicyAppId_)) .WillOnce(Return(invalid_app)); + ChangePolicyManagerToMock(); + const policy::EncryptionRequired require_encryption; + EXPECT_CALL(*mock_policy_manager_, GetAppEncryptionRequired(kPolicyAppId_)) + .Times(0); EXPECT_CALL(mock_message_helper_, - SendOnPermissionsChangeNotification(_, _, _)).Times(0); + SendOnPermissionsChangeNotification(_, _, _, _)) + .Times(0); Permissions permissions; - policy_handler_.OnPermissionsUpdated(kPolicyAppId_, permissions); + policy_handler_.OnPermissionsUpdated(kDeviceId, kPolicyAppId_, permissions); } TEST_F(PolicyHandlerTest, OnPermissionsUpdated_InvalidApp_UNSUCCESS) { std::shared_ptr invalid_app; - EXPECT_CALL(app_manager_, application_by_policy_id(kPolicyAppId_)) + EXPECT_CALL(app_manager_, application(kDeviceId, kPolicyAppId_)) .WillOnce(Return(mock_app_)) .WillOnce(Return(invalid_app)); EXPECT_CALL(*mock_app_, app_id()).WillOnce(Return(kAppId1_)); + ChangePolicyManagerToMock(); + const policy::EncryptionRequired require_encryption; + EXPECT_CALL(*mock_policy_manager_, GetAppEncryptionRequired(kPolicyAppId_)) + .WillOnce(Return(require_encryption)); EXPECT_CALL(mock_message_helper_, - SendOnPermissionsChangeNotification(kAppId1_, _, _)); + SendOnPermissionsChangeNotification(kAppId1_, _, _, _)); Permissions permissions; - policy_handler_.OnPermissionsUpdated(kPolicyAppId_, permissions, "HMI_FULL"); + policy_handler_.OnPermissionsUpdated( + kDeviceId, kPolicyAppId_, permissions, "HMI_FULL"); } TEST_F(PolicyHandlerTest, OnPermissionsUpdated_HmiLevelInvalidEnum_UNSUCCESS) { @@ -544,25 +574,30 @@ TEST_F(PolicyHandlerTest, const std::string new_kHmiLevel_string = "HMI_FULL"; mobile_apis::HMILevel::eType new_hmi_level = mobile_apis::HMILevel::HMI_FULL; // Check expectations - EXPECT_CALL(app_manager_, application_by_policy_id(kPolicyAppId_)) + EXPECT_CALL(app_manager_, application(kDeviceId, kPolicyAppId_)) .Times(2) .WillRepeatedly(Return(mock_app_)); EXPECT_CALL(*mock_app_, app_id()).WillOnce(Return(kAppId1_)); EXPECT_CALL(mock_message_helper_, StringToHMILevel(new_kHmiLevel_string)) .WillOnce(Return(new_hmi_level)); - EXPECT_CALL(*mock_app_, hmi_level()) + EXPECT_CALL(*mock_app_, hmi_level(kDefaultWindowId)) .WillOnce(Return(mobile_apis::HMILevel::HMI_NONE)); + ChangePolicyManagerToMock(); + const policy::EncryptionRequired require_encryption; + EXPECT_CALL(*mock_policy_manager_, GetAppEncryptionRequired(kPolicyAppId_)) + .WillOnce(Return(require_encryption)); EXPECT_CALL(mock_message_helper_, - SendOnPermissionsChangeNotification(kAppId1_, _, _)); + SendOnPermissionsChangeNotification(kAppId1_, _, _, _)); EXPECT_CALL(app_manager_, state_controller()) .WillRepeatedly(ReturnRef(mock_state_controller)); - EXPECT_CALL(mock_state_controller, SetRegularState(_, new_hmi_level, true)); + EXPECT_CALL(mock_state_controller, + SetRegularState(_, kDefaultWindowId, new_hmi_level, true)); // Act Permissions perms; policy_handler_.OnPermissionsUpdated( - kPolicyAppId_, perms, new_kHmiLevel_string); + kDeviceId, kPolicyAppId_, perms, new_kHmiLevel_string); } TEST_F(PolicyHandlerTest, @@ -572,25 +607,30 @@ TEST_F(PolicyHandlerTest, mobile_apis::HMILevel::eType new_hmi_level = mobile_apis::HMILevel::HMI_LIMITED; // Check expectations - EXPECT_CALL(app_manager_, application_by_policy_id(kPolicyAppId_)) + EXPECT_CALL(app_manager_, application(kDeviceId, kPolicyAppId_)) .Times(2) .WillRepeatedly(Return(mock_app_)); EXPECT_CALL(*mock_app_, app_id()).WillOnce(Return(kAppId1_)); EXPECT_CALL(mock_message_helper_, StringToHMILevel(new_kHmiLevel_string)) .WillOnce(Return(new_hmi_level)); - EXPECT_CALL(*mock_app_, hmi_level()) + EXPECT_CALL(*mock_app_, hmi_level(kDefaultWindowId)) .WillOnce(Return(mobile_apis::HMILevel::HMI_NONE)); + ChangePolicyManagerToMock(); + const policy::EncryptionRequired require_encryption; + EXPECT_CALL(*mock_policy_manager_, GetAppEncryptionRequired(kPolicyAppId_)) + .WillOnce(Return(require_encryption)); EXPECT_CALL(mock_message_helper_, - SendOnPermissionsChangeNotification(kAppId1_, _, _)); + SendOnPermissionsChangeNotification(kAppId1_, _, _, _)); EXPECT_CALL(app_manager_, state_controller()) .WillRepeatedly(ReturnRef(mock_state_controller)); - EXPECT_CALL(mock_state_controller, SetRegularState(_, new_hmi_level, false)); + EXPECT_CALL(mock_state_controller, + SetRegularState(_, kDefaultWindowId, new_hmi_level, false)); // Act Permissions perms; policy_handler_.OnPermissionsUpdated( - kPolicyAppId_, perms, new_kHmiLevel_string); + kDeviceId, kPolicyAppId_, perms, new_kHmiLevel_string); } TEST_F(PolicyHandlerTest, @@ -599,23 +639,27 @@ TEST_F(PolicyHandlerTest, std::string new_kHmiLevel_string = "HMI_FULL"; mobile_apis::HMILevel::eType new_hmi_level = mobile_apis::HMILevel::HMI_FULL; // Check expectations - EXPECT_CALL(app_manager_, application_by_policy_id(kPolicyAppId_)) + EXPECT_CALL(app_manager_, application(kDeviceId, kPolicyAppId_)) .Times(2) .WillRepeatedly(Return(mock_app_)); EXPECT_CALL(*mock_app_, app_id()).WillOnce(Return(kAppId1_)); EXPECT_CALL(mock_message_helper_, StringToHMILevel(new_kHmiLevel_string)) .WillOnce(Return(new_hmi_level)); - EXPECT_CALL(*mock_app_, hmi_level()) + EXPECT_CALL(*mock_app_, hmi_level(kDefaultWindowId)) .WillOnce(Return(mobile_apis::HMILevel::HMI_LIMITED)); + ChangePolicyManagerToMock(); + const policy::EncryptionRequired require_encryption; + EXPECT_CALL(*mock_policy_manager_, GetAppEncryptionRequired(kPolicyAppId_)) + .WillOnce(Return(require_encryption)); EXPECT_CALL(mock_message_helper_, - SendOnPermissionsChangeNotification(kAppId1_, _, _)); + SendOnPermissionsChangeNotification(kAppId1_, _, _, _)); EXPECT_CALL(app_manager_, state_controller()).Times(0); // Act Permissions perms; policy_handler_.OnPermissionsUpdated( - kPolicyAppId_, perms, new_kHmiLevel_string); + kDeviceId, kPolicyAppId_, perms, new_kHmiLevel_string); } TEST_F(PolicyHandlerTest, GetPriority) { @@ -636,13 +680,14 @@ TEST_F(PolicyHandlerTest, CheckPermissions) { const uint32_t device = 3; const mobile_apis::HMILevel::eType hmi_level = mobile_apis::HMILevel::HMI_NONE; - EXPECT_CALL(*mock_app_, hmi_level()).WillOnce(Return(hmi_level)); + EXPECT_CALL(*mock_app_, hmi_level(kDefaultWindowId)) + .WillOnce(Return(hmi_level)); EXPECT_CALL(*mock_app_, device()).WillOnce(Return(device)); EXPECT_CALL(*mock_app_, policy_app_id()).WillOnce(Return(kPolicyAppId_)); #ifdef EXTERNAL_PROPRIETARY_MODE - EXPECT_CALL( - *mock_policy_manager_, - CheckPermissions(kPolicyAppId_, kHmiLevel_, kRpc_, kRpc_params, _)); + EXPECT_CALL(*mock_policy_manager_, + CheckPermissions( + kDeviceId, kPolicyAppId_, kHmiLevel_, kRpc_, kRpc_params, _)); #else // EXTERNAL_PROPRIETARY_MODE EXPECT_CALL(*mock_policy_manager_, @@ -654,7 +699,8 @@ TEST_F(PolicyHandlerTest, CheckPermissions) { EXPECT_CALL(mock_message_helper_, GetDeviceMacAddressForHandle(device, _)) .WillOnce(Return(kDeviceId)); // Act - policy_handler_.CheckPermissions(mock_app_, kRpc_, kRpc_params, result); + policy_handler_.CheckPermissions( + mock_app_, kDefaultWindowId, kRpc_, kRpc_params, result); } TEST_F(PolicyHandlerTest, GetNotificationsNumber) { @@ -681,9 +727,9 @@ TEST_F(PolicyHandlerTest, GetDefaultHmi) { EnablePolicyAndPolicyManagerMock(); // Check expectations EXPECT_CALL(*mock_policy_manager_, - GetDefaultHmi(kPolicyAppId_, &default_hmi_)); + GetDefaultHmi(kDeviceId_, kPolicyAppId_, &default_hmi_)); // Act - policy_handler_.GetDefaultHmi(kPolicyAppId_, &default_hmi_); + policy_handler_.GetDefaultHmi(kDeviceId_, kPolicyAppId_, &default_hmi_); } TEST_F(PolicyHandlerTest, GetInitialAppData) { @@ -882,12 +928,14 @@ void PolicyHandlerTest::TestActivateApp(const uint32_t connection_key, #endif // EXTERNAL_PROPRIETARY_MODE EXPECT_CALL(*application1, policy_app_id()).WillOnce(Return(kPolicyAppId_)); - EXPECT_CALL(*mock_policy_manager_, GetAppPermissionsChanges(_)) + EXPECT_CALL(*mock_policy_manager_, + GetAppPermissionsChanges(kMacAddr_, kPolicyAppId_)) .WillOnce(Return(permissions)); ON_CALL(*mock_policy_manager_, Increment(_, _)).WillByDefault(Return()); EXPECT_CALL(*mock_policy_manager_, RemovePendingPermissionChanges(_)); EXPECT_CALL(mock_message_helper_, SendSDLActivateAppResponse(_, _, _)); ON_CALL(*application1, app_id()).WillByDefault(Return(kAppId1_)); + ON_CALL(*application1, mac_address()).WillByDefault(ReturnRef(kMacAddr_)); // Act policy_handler_.OnActivateApp(connection_key, correlation_id); } @@ -936,12 +984,14 @@ TEST_F(PolicyHandlerTest, OnActivateApp_AppIsRevoked_AppNotActivated) { // Check expectations EXPECT_CALL(*mock_app_, policy_app_id()).WillOnce(Return(kPolicyAppId_)); - EXPECT_CALL(*mock_policy_manager_, GetAppPermissionsChanges(_)) + EXPECT_CALL(*mock_policy_manager_, + GetAppPermissionsChanges(kDefaultId, kPolicyAppId_)) .WillOnce(Return(permissions)); ON_CALL(*mock_policy_manager_, Increment(_, _)).WillByDefault(Return()); EXPECT_CALL(*mock_policy_manager_, RemovePendingPermissionChanges(_)); EXPECT_CALL(mock_message_helper_, SendSDLActivateAppResponse(_, _, _)); ON_CALL(*mock_app_, app_id()).WillByDefault(Return(kAppId1_)); + ON_CALL(*mock_app_, mac_address()).WillByDefault(ReturnRef(kDefaultId)); // Act policy_handler_.OnActivateApp(kConnectionKey_, kCorrelationKey_); } @@ -963,10 +1013,10 @@ void PolicyHandlerTest::OnPendingPermissionChangePrecondition( std::shared_ptr application = std::make_shared(); - EXPECT_CALL(app_manager_, application_by_policy_id(kPolicyAppId_)) - .WillOnce(Return(application)); + EXPECT_CALL(app_manager_, application(_, _)).WillOnce(Return(application)); EXPECT_CALL(*application, app_id()).WillRepeatedly(Return(kAppId1_)); - EXPECT_CALL(*application, hmi_level()).WillRepeatedly(Return(hmi_level)); + EXPECT_CALL(*application, hmi_level(kDefaultWindowId)) + .WillRepeatedly(Return(hmi_level)); } TEST_F(PolicyHandlerTest, @@ -978,14 +1028,15 @@ TEST_F(PolicyHandlerTest, AppPermissions permissions(kPolicyAppId_); permissions.appPermissionsConsentNeeded = false; EXPECT_CALL(mock_message_helper_, - SendOnAppPermissionsChangedNotification(kAppId1_, _, _)).Times(0); - - EXPECT_CALL(*mock_policy_manager_, GetAppPermissionsChanges(_)) + SendOnAppPermissionsChangedNotification(kAppId1_, _, _)) + .Times(0); + EXPECT_CALL(*mock_policy_manager_, + GetAppPermissionsChanges(kDeviceId_, kPolicyAppId_)) .WillOnce(Return(permissions)); EXPECT_CALL(*mock_policy_manager_, RemovePendingPermissionChanges(kPolicyAppId_)); // Act - policy_handler_.OnPendingPermissionChange(kPolicyAppId_); + policy_handler_.OnPendingPermissionChange(kDeviceId_, kPolicyAppId_); } TEST_F(PolicyHandlerTest, OnPendingPermissionChange_AppInLimitedConsentNeeded) { @@ -997,12 +1048,13 @@ TEST_F(PolicyHandlerTest, OnPendingPermissionChange_AppInLimitedConsentNeeded) { // Check expectations EXPECT_CALL(mock_message_helper_, SendOnAppPermissionsChangedNotification(kAppId1_, _, _)); - EXPECT_CALL(*mock_policy_manager_, GetAppPermissionsChanges(_)) + EXPECT_CALL(*mock_policy_manager_, + GetAppPermissionsChanges(kDeviceId_, kPolicyAppId_)) .WillOnce(Return(permissions)); EXPECT_CALL(*mock_policy_manager_, RemovePendingPermissionChanges(kPolicyAppId_)); // Act - policy_handler_.OnPendingPermissionChange(kPolicyAppId_); + policy_handler_.OnPendingPermissionChange(kDeviceId_, kPolicyAppId_); } TEST_F(PolicyHandlerTest, OnPendingPermissionChange_AppLimitedAndRevoked) { @@ -1019,17 +1071,19 @@ TEST_F(PolicyHandlerTest, OnPendingPermissionChange_AppLimitedAndRevoked) { SendOnAppPermissionsChangedNotification(kAppId1_, _, _)); EXPECT_CALL(mock_state_controller, SetRegularState(_, + kDefaultWindowId, mobile_apis::HMILevel::HMI_NONE, mobile_apis::AudioStreamingState::NOT_AUDIBLE, mobile_apis::VideoStreamingState::NOT_STREAMABLE, true)); - EXPECT_CALL(*mock_policy_manager_, GetAppPermissionsChanges(_)) + EXPECT_CALL(*mock_policy_manager_, + GetAppPermissionsChanges(kDeviceId_, kPolicyAppId_)) .WillOnce(Return(permissions)); EXPECT_CALL(*mock_policy_manager_, RemovePendingPermissionChanges(kPolicyAppId_)); // Act - policy_handler_.OnPendingPermissionChange(kPolicyAppId_); + policy_handler_.OnPendingPermissionChange(kDeviceId_, kPolicyAppId_); } TEST_F(PolicyHandlerTest, OnPendingPermissionChange_AppInBackgroundAndRevoked) { @@ -1043,12 +1097,13 @@ TEST_F(PolicyHandlerTest, OnPendingPermissionChange_AppInBackgroundAndRevoked) { EXPECT_CALL(mock_message_helper_, SendOnAppPermissionsChangedNotification(kAppId1_, _, _)); - EXPECT_CALL(*mock_policy_manager_, GetAppPermissionsChanges(_)) + EXPECT_CALL(*mock_policy_manager_, + GetAppPermissionsChanges(kDeviceId_, kPolicyAppId_)) .WillOnce(Return(permissions)); EXPECT_CALL(*mock_policy_manager_, RemovePendingPermissionChanges(kPolicyAppId_)); // Act - policy_handler_.OnPendingPermissionChange(kPolicyAppId_); + policy_handler_.OnPendingPermissionChange(kDeviceId_, kPolicyAppId_); } TEST_F(PolicyHandlerTest, @@ -1065,7 +1120,8 @@ TEST_F(PolicyHandlerTest, EXPECT_CALL(mock_message_helper_, SendOnAppPermissionsChangedNotification(kAppId1_, _, _)); - EXPECT_CALL(*mock_policy_manager_, GetAppPermissionsChanges(_)) + EXPECT_CALL(*mock_policy_manager_, + GetAppPermissionsChanges(kDeviceId_, kPolicyAppId_)) .WillOnce(Return(permissions)); EXPECT_CALL(mock_message_helper_, @@ -1082,7 +1138,7 @@ TEST_F(PolicyHandlerTest, RemovePendingPermissionChanges(kPolicyAppId_)); // Act - policy_handler_.OnPendingPermissionChange(kPolicyAppId_); + policy_handler_.OnPendingPermissionChange(kDeviceId_, kPolicyAppId_); } TEST_F(PolicyHandlerTest, @@ -1095,13 +1151,14 @@ TEST_F(PolicyHandlerTest, EXPECT_CALL(mock_message_helper_, SendOnAppPermissionsChangedNotification(kAppId1_, _, _)); - EXPECT_CALL(*mock_policy_manager_, GetAppPermissionsChanges(_)) + EXPECT_CALL(*mock_policy_manager_, + GetAppPermissionsChanges(kDeviceId_, kPolicyAppId_)) .WillOnce(Return(permissions)); EXPECT_CALL(*mock_policy_manager_, RemovePendingPermissionChanges(kPolicyAppId_)); - policy_handler_.OnPendingPermissionChange(kPolicyAppId_); + policy_handler_.OnPendingPermissionChange(kDeviceId_, kPolicyAppId_); } TEST_F(PolicyHandlerTest, @@ -1117,9 +1174,11 @@ TEST_F(PolicyHandlerTest, // Check expectations // Notification won't be sent EXPECT_CALL(mock_message_helper_, - SendOnAppPermissionsChangedNotification(kAppId1_, _, _)).Times(0); + SendOnAppPermissionsChangedNotification(kAppId1_, _, _)) + .Times(0); - EXPECT_CALL(*mock_policy_manager_, GetAppPermissionsChanges(_)) + EXPECT_CALL(*mock_policy_manager_, + GetAppPermissionsChanges(kDeviceId_, kPolicyAppId_)) .WillOnce(Return(permissions)); EXPECT_CALL(mock_message_helper_, @@ -1136,7 +1195,7 @@ TEST_F(PolicyHandlerTest, RemovePendingPermissionChanges(kPolicyAppId_)); // Act - policy_handler_.OnPendingPermissionChange(kPolicyAppId_); + policy_handler_.OnPendingPermissionChange(kDeviceId_, kPolicyAppId_); } TEST_F(PolicyHandlerTest, PTExchangeAtUserRequest) { @@ -1232,7 +1291,7 @@ TEST_F(PolicyHandlerTest, OnCurrentDeviceIdUpdateRequired) { // Check expectations std::shared_ptr application = std::make_shared(); - EXPECT_CALL(app_manager_, application_by_policy_id(kPolicyAppId_)) + EXPECT_CALL(app_manager_, application(kDeviceId_, kPolicyAppId_)) .WillOnce(Return(application)); EXPECT_CALL(app_manager_, connection_handler()) .WillOnce(ReturnRef(conn_handler)); @@ -1249,10 +1308,11 @@ TEST_F(PolicyHandlerTest, OnCurrentDeviceIdUpdateRequired) { _, _, _, - _)); + _)) + .WillOnce(DoAll(SetArgPointee<3>(kDeviceId_), Return(0))); // Act - policy_handler_.OnCurrentDeviceIdUpdateRequired(kPolicyAppId_); + policy_handler_.OnCurrentDeviceIdUpdateRequired(handle, kPolicyAppId_); } TEST_F(PolicyHandlerTest, OnSystemInfoChanged) { @@ -1301,11 +1361,17 @@ TEST_F(PolicyHandlerTest, GetAppRequestTypes) { // Arrange EnablePolicy(); ChangePolicyManagerToMock(); - // Check expectations + const transport_manager::DeviceHandle handle = 0u; +// Check expectations +#ifdef EXTERNAL_PROPRIETARY_MODE + EXPECT_CALL(*mock_policy_manager_, GetAppRequestTypes(handle, kPolicyAppId_)) + .WillOnce(Return(std::vector())); +#else EXPECT_CALL(*mock_policy_manager_, GetAppRequestTypes(kPolicyAppId_)) .WillOnce(Return(std::vector())); +#endif // Act - policy_handler_.GetAppRequestTypes(kPolicyAppId_); + policy_handler_.GetAppRequestTypes(handle, kPolicyAppId_); } TEST_F(PolicyHandlerTest, OnVIIsReady) { @@ -1374,13 +1440,14 @@ TEST_F(PolicyHandlerTest, SendOnAppPermissionsChanged) { std::shared_ptr application = std::make_shared(); // Check expectations - EXPECT_CALL(app_manager_, application_by_policy_id(kPolicyAppId_)) + EXPECT_CALL(app_manager_, application(kDeviceId_, kPolicyAppId_)) .WillOnce(Return(application)); EXPECT_CALL(mock_message_helper_, SendOnAppPermissionsChangedNotification(_, _, _)); AppPermissions permissions(kPolicyAppId_); // Act - policy_handler_.SendOnAppPermissionsChanged(permissions, kPolicyAppId_); + policy_handler_.SendOnAppPermissionsChanged( + permissions, kDeviceId_, kPolicyAppId_); } TEST_F(PolicyHandlerTest, OnPTExchangeNeeded) { @@ -1398,11 +1465,12 @@ TEST_F(PolicyHandlerTest, AddApplication) { // Check expectations EXPECT_CALL( *mock_policy_manager_, - AddApplication(kPolicyAppId_, HmiTypes(policy_table::AHT_DEFAULT))) + AddApplication( + kMacAddr_, kPolicyAppId_, HmiTypes(policy_table::AHT_DEFAULT))) .WillOnce(Return(std::make_shared())); // Act - policy_handler_.AddApplication(kPolicyAppId_, - HmiTypes(policy_table::AHT_DEFAULT)); + policy_handler_.AddApplication( + kMacAddr_, kPolicyAppId_, HmiTypes(policy_table::AHT_DEFAULT)); } TEST_F(PolicyHandlerTest, HeartBeatTimeout) { @@ -1437,9 +1505,10 @@ TEST_F(PolicyHandlerTest, OnAppRegisteredOnMobile) { EnablePolicyAndPolicyManagerMock(); // Check expectations - EXPECT_CALL(*mock_policy_manager_, OnAppRegisteredOnMobile(kPolicyAppId_)); + EXPECT_CALL(*mock_policy_manager_, + OnAppRegisteredOnMobile(kDeviceId, kPolicyAppId_)); // Act - policy_handler_.OnAppRegisteredOnMobile(kPolicyAppId_); + policy_handler_.OnAppRegisteredOnMobile(kDeviceId, kPolicyAppId_); } TEST_F(PolicyHandlerTest, IsRequestTypeAllowed) { @@ -1450,13 +1519,20 @@ TEST_F(PolicyHandlerTest, IsRequestTypeAllowed) { mobile_apis::RequestType::eType type = mobile_apis::RequestType::eType::EMERGENCY; + const transport_manager::DeviceHandle handle = 0u; + EXPECT_CALL(*mock_policy_manager_, GetAppRequestTypesState(kPolicyAppId_)) .WillOnce(Return(policy::RequestType::State::AVAILABLE)); - +#ifdef EXTERNAL_PROPRIETARY_MODE + EXPECT_CALL(*mock_policy_manager_, GetAppRequestTypes(handle, kPolicyAppId_)) + .WillOnce(Return(std::vector({"HTTP"}))); +#else EXPECT_CALL(*mock_policy_manager_, GetAppRequestTypes(kPolicyAppId_)) .WillOnce(Return(std::vector({"HTTP"}))); +#endif // Act - EXPECT_FALSE(policy_handler_.IsRequestTypeAllowed(kPolicyAppId_, type)); + EXPECT_FALSE( + policy_handler_.IsRequestTypeAllowed(handle, kPolicyAppId_, type)); } TEST_F(PolicyHandlerTest, IsRequestSubTypeAllowed) { @@ -1475,16 +1551,6 @@ TEST_F(PolicyHandlerTest, IsRequestSubTypeAllowed) { EXPECT_TRUE(policy_handler_.IsRequestSubTypeAllowed(kPolicyAppId_, subtype)); } -TEST_F(PolicyHandlerTest, GetVehicleInfo) { - // Arrange - EnablePolicyAndPolicyManagerMock(); - // Check expectations - EXPECT_CALL(*mock_policy_manager_, GetVehicleInfo()) - .WillOnce(Return(VehicleInfo())); - // Act - policy_handler_.GetVehicleInfo(); -} - TEST_F(PolicyHandlerTest, Increment_method_WithOneParameter) { // Arrange EnablePolicyAndPolicyManagerMock(); @@ -1720,7 +1786,8 @@ TEST_F(PolicyHandlerTest, OnSnapshotCreated_UrlNotAdded) { .WillRepeatedly(SetArgReferee<1>(test_data)); policy_handler_.OnSnapshotCreated(msg, retry_delay_seconds, timeout_exchange); #else // EXTERNAL_PROPRIETARY_MODE - policy_handler_.OnSnapshotCreated(msg); + policy_handler_.OnSnapshotCreated(msg, + policy::PTUIterationType::DefaultIteration); #endif // EXTERNAL_PROPRIETARY_MODE } @@ -1798,7 +1865,8 @@ TEST_F(PolicyHandlerTest, DISABLED_OnSnapshotCreated_UrlAdded) { #endif // PROPRIETARY_MODE EXPECT_CALL(*mock_policy_manager_, OnUpdateStarted()); - policy_handler_.OnSnapshotCreated(msg); + policy_handler_.OnSnapshotCreated(msg, + policy::PTUIterationType::DefaultIteration); } #endif // EXTERNAL_PROPRIETARY_MODE @@ -1846,8 +1914,9 @@ TEST_F(PolicyHandlerTest, OnDeviceConsentChanged_ConsentAllowed) { connection_handler::DeviceHandle test_device_id = 100u; EXPECT_CALL(app_manager_, connection_handler()) .WillOnce(ReturnRef(conn_handler)); + EXPECT_CALL(app_manager_, applications()).WillRepeatedly(Return(app_set)); - EXPECT_CALL(conn_handler, GetDeviceID(kPolicyAppId_, _)) + EXPECT_CALL(conn_handler, GetDeviceID(kDeviceId, _)) .WillOnce(DoAll(SetArgPointee<1>(test_device_id), Return(true))); test_app.insert(mock_app_); @@ -1857,12 +1926,13 @@ TEST_F(PolicyHandlerTest, OnDeviceConsentChanged_ConsentAllowed) { EXPECT_CALL(*mock_policy_manager_, IsPredataPolicy(kPolicyAppId_)) .WillOnce(Return(true)); + EXPECT_CALL( + *mock_policy_manager_, + ReactOnUserDevConsentForApp(test_device_id, kPolicyAppId_, is_allowed)); EXPECT_CALL(*mock_policy_manager_, - ReactOnUserDevConsentForApp(kPolicyAppId_, is_allowed)); - EXPECT_CALL(*mock_policy_manager_, - SendNotificationOnPermissionsUpdated(kPolicyAppId_)); + SendNotificationOnPermissionsUpdated(kDeviceId, kPolicyAppId_)); - policy_handler_.OnDeviceConsentChanged(kPolicyAppId_, is_allowed); + policy_handler_.OnDeviceConsentChanged(kDeviceId, is_allowed); } TEST_F(PolicyHandlerTest, OnDeviceConsentChanged_ConsentNotAllowed) { @@ -1870,27 +1940,29 @@ TEST_F(PolicyHandlerTest, OnDeviceConsentChanged_ConsentNotAllowed) { // Arrange EnablePolicyAndPolicyManagerMock(); - connection_handler::DeviceHandle test_device_id = 100u; + connection_handler::DeviceHandle handle = 100u; EXPECT_CALL(app_manager_, connection_handler()) .WillOnce(ReturnRef(conn_handler)); // Check expectations - EXPECT_CALL(conn_handler, GetDeviceID(kPolicyAppId_, _)) - .WillOnce(DoAll(SetArgPointee<1>(test_device_id), Return(true))); + EXPECT_CALL(conn_handler, GetDeviceID(kMacAddr_, _)) + .WillOnce(DoAll(SetArgPointee<1>(handle), Return(true))); test_app.insert(mock_app_); - EXPECT_CALL(*mock_app_, device()).WillOnce(Return(test_device_id)); + EXPECT_CALL(*mock_app_, device()).WillOnce(Return(handle)); EXPECT_CALL(*mock_app_, policy_app_id()).WillOnce(Return(kPolicyAppId_)); EXPECT_CALL(*mock_policy_manager_, IsPredataPolicy(kPolicyAppId_)) .WillOnce(Return(true)); - EXPECT_CALL(*mock_policy_manager_, ReactOnUserDevConsentForApp(_, _)) + EXPECT_CALL(*mock_policy_manager_, + ReactOnUserDevConsentForApp(handle, kPolicyAppId_, is_allowed)) .Times(0); - EXPECT_CALL(*mock_policy_manager_, SendNotificationOnPermissionsUpdated(_)) + EXPECT_CALL(*mock_policy_manager_, + SendNotificationOnPermissionsUpdated(kMacAddr_, kPolicyAppId_)) .Times(0); - policy_handler_.OnDeviceConsentChanged(kPolicyAppId_, is_allowed); + policy_handler_.OnDeviceConsentChanged(kMacAddr_, is_allowed); } TEST_F(PolicyHandlerTest, OnDeviceConsentChanged_PredatePolicyNotAllowed) { @@ -1901,8 +1973,9 @@ TEST_F(PolicyHandlerTest, OnDeviceConsentChanged_PredatePolicyNotAllowed) { connection_handler::DeviceHandle test_device_id = 100u; EXPECT_CALL(app_manager_, connection_handler()) .WillOnce(ReturnRef(conn_handler)); + EXPECT_CALL(app_manager_, applications()).WillRepeatedly(Return(app_set)); - EXPECT_CALL(conn_handler, GetDeviceID(kPolicyAppId_, _)) + EXPECT_CALL(conn_handler, GetDeviceID(kMacAddr_, _)) .WillOnce(DoAll(SetArgPointee<1>(test_device_id), Return(true))); test_app.insert(mock_app_); @@ -1914,12 +1987,13 @@ TEST_F(PolicyHandlerTest, OnDeviceConsentChanged_PredatePolicyNotAllowed) { EXPECT_CALL(*mock_policy_manager_, IsPredataPolicy(kPolicyAppId_)) .WillOnce(Return(false)); + EXPECT_CALL( + *mock_policy_manager_, + ReactOnUserDevConsentForApp(test_device_id, kPolicyAppId_, is_allowed)); EXPECT_CALL(*mock_policy_manager_, - ReactOnUserDevConsentForApp(kPolicyAppId_, is_allowed)); - EXPECT_CALL(*mock_policy_manager_, - SendNotificationOnPermissionsUpdated(kPolicyAppId_)); + SendNotificationOnPermissionsUpdated(kMacAddr_, kPolicyAppId_)); - policy_handler_.OnDeviceConsentChanged(kPolicyAppId_, is_allowed); + policy_handler_.OnDeviceConsentChanged(kMacAddr_, is_allowed); } #ifdef ENABLE_SECURITY #ifdef EXTERNAL_PROPRIETARY_MODE @@ -1970,7 +2044,7 @@ TEST_F(PolicyHandlerTest, GetAppIdForSending_GetDefaultMacAddress) { test_app.insert(mock_app_); EXPECT_CALL(*mock_app_, IsRegistered()).WillOnce(Return(true)); EXPECT_CALL(*mock_app_, app_id()).WillRepeatedly(Return(kAppId1_)); - EXPECT_CALL(*mock_app_, hmi_level()) + EXPECT_CALL(*mock_app_, hmi_level(kDefaultWindowId)) .WillRepeatedly(Return(mobile_api::HMILevel::HMI_FULL)); EXPECT_CALL(app_manager_, connection_handler()) .WillOnce(ReturnRef(conn_handler)); @@ -1993,7 +2067,7 @@ void PolicyHandlerTest::GetAppIDForSending() { // Check expectations EXPECT_CALL(*mock_app_, app_id()).WillRepeatedly(Return(kAppId1_)); EXPECT_CALL(*mock_app_, IsRegistered()).WillOnce(Return(true)); - EXPECT_CALL(*mock_app_, hmi_level()) + EXPECT_CALL(*mock_app_, hmi_level(kDefaultWindowId)) .WillRepeatedly(Return(mobile_api::HMILevel::HMI_FULL)); EXPECT_CALL(mock_session_observer, GetDataOnDeviceID( @@ -2020,7 +2094,7 @@ TEST_F(PolicyHandlerTest, GetAppIdForSending_ExpectReturnAnyIdButNone) { const uint32_t app_in_full_id = 1; EXPECT_CALL(*mock_app_in_full, app_id()) .WillRepeatedly(Return(app_in_full_id)); - EXPECT_CALL(*mock_app_in_full, hmi_level()) + EXPECT_CALL(*mock_app_in_full, hmi_level(kDefaultWindowId)) .WillRepeatedly(Return(mobile_api::HMILevel::HMI_FULL)); ON_CALL(*mock_app_in_full, IsRegistered()).WillByDefault(Return(true)); @@ -2032,7 +2106,7 @@ TEST_F(PolicyHandlerTest, GetAppIdForSending_ExpectReturnAnyIdButNone) { const uint32_t app_in_limited_id = 2; EXPECT_CALL(*mock_app_in_limited, app_id()) .WillRepeatedly(Return(app_in_limited_id)); - EXPECT_CALL(*mock_app_in_limited, hmi_level()) + EXPECT_CALL(*mock_app_in_limited, hmi_level(kDefaultWindowId)) .WillRepeatedly(Return(mobile_api::HMILevel::HMI_LIMITED)); ON_CALL(*mock_app_in_limited, IsRegistered()).WillByDefault(Return(true)); @@ -2044,7 +2118,7 @@ TEST_F(PolicyHandlerTest, GetAppIdForSending_ExpectReturnAnyIdButNone) { const uint32_t app_in_background_id = 3; EXPECT_CALL(*mock_app_in_background, app_id()) .WillRepeatedly(Return(app_in_background_id)); - EXPECT_CALL(*mock_app_in_background, hmi_level()) + EXPECT_CALL(*mock_app_in_background, hmi_level(kDefaultWindowId)) .WillRepeatedly(Return(mobile_api::HMILevel::HMI_BACKGROUND)); ON_CALL(*mock_app_in_background, IsRegistered()).WillByDefault(Return(true)); @@ -2055,7 +2129,7 @@ TEST_F(PolicyHandlerTest, GetAppIdForSending_ExpectReturnAnyIdButNone) { const uint32_t app_in_none_id = 4; EXPECT_CALL(*mock_app_in_none, app_id()) .WillRepeatedly(Return(app_in_none_id)); - EXPECT_CALL(*mock_app_in_none, hmi_level()) + EXPECT_CALL(*mock_app_in_none, hmi_level(kDefaultWindowId)) .WillRepeatedly(Return(mobile_api::HMILevel::HMI_NONE)); EXPECT_CALL(*mock_app_in_none, IsRegistered()).Times(0); @@ -2085,7 +2159,7 @@ TEST_F(PolicyHandlerTest, GetAppIdForSending_ExpectReturnAnyAppInNone) { const uint32_t app_in_none_id_1 = 1; EXPECT_CALL(*mock_app_in_none_1, app_id()) .WillRepeatedly(Return(app_in_none_id_1)); - EXPECT_CALL(*mock_app_in_none_1, hmi_level()) + EXPECT_CALL(*mock_app_in_none_1, hmi_level(kDefaultWindowId)) .WillRepeatedly(Return(mobile_api::HMILevel::HMI_FULL)); ON_CALL(*mock_app_in_none_1, IsRegistered()).WillByDefault(Return(true)); @@ -2097,7 +2171,7 @@ TEST_F(PolicyHandlerTest, GetAppIdForSending_ExpectReturnAnyAppInNone) { const uint32_t app_in_none_id_2 = 2; EXPECT_CALL(*mock_app_in_none_2, app_id()) .WillRepeatedly(Return(app_in_none_id_2)); - EXPECT_CALL(*mock_app_in_none_2, hmi_level()) + EXPECT_CALL(*mock_app_in_none_2, hmi_level(kDefaultWindowId)) .WillRepeatedly(Return(mobile_api::HMILevel::HMI_NONE)); ON_CALL(*mock_app_in_none_2, IsRegistered()).WillByDefault(Return(true)); @@ -2132,7 +2206,7 @@ TEST_F(PolicyHandlerTest, EXPECT_CALL(*mock_app_, app_id()).WillRepeatedly(Return(kAppId1_)); EXPECT_CALL(*mock_app_, policy_app_id()) .WillRepeatedly(Return(kPolicyAppId_)); - EXPECT_CALL(*mock_app_, hmi_level()) + EXPECT_CALL(*mock_app_, hmi_level(kDefaultWindowId)) .WillRepeatedly(Return(mobile_apis::HMILevel::HMI_FULL)); EXPECT_CALL(*mock_app_, IsRegistered()).WillRepeatedly(Return(true)); @@ -2159,7 +2233,7 @@ TEST_F(PolicyHandlerTest, EXPECT_CALL(*mock_app_, app_id()).WillRepeatedly(Return(kAppId1_)); EXPECT_CALL(*mock_app_, policy_app_id()) .WillRepeatedly(Return(kPolicyAppId_)); - EXPECT_CALL(*mock_app_, hmi_level()) + EXPECT_CALL(*mock_app_, hmi_level(kDefaultWindowId)) .WillRepeatedly(Return(mobile_apis::HMILevel::HMI_NONE)); EXPECT_CALL(*mock_app_, IsRegistered()).WillRepeatedly(Return(true)); @@ -2187,9 +2261,9 @@ TEST_F(PolicyHandlerTest, CanUpdate_TwoApplicationForSending_SUCCESS) { std::shared_ptr second_mock_app = std::make_shared(); - EXPECT_CALL(*mock_app_, hmi_level()) + EXPECT_CALL(*mock_app_, hmi_level(kDefaultWindowId)) .WillOnce(Return(mobile_apis::HMILevel::HMI_FULL)); - EXPECT_CALL(*second_mock_app, hmi_level()) + EXPECT_CALL(*second_mock_app, hmi_level(kDefaultWindowId)) .WillRepeatedly(Return(mobile_apis::HMILevel::HMI_LIMITED)); EXPECT_CALL(*second_mock_app, app_id()).WillRepeatedly(Return(kAppId2_)); @@ -2242,7 +2316,8 @@ TEST_F(PolicyHandlerTest, _, NULL, _, - _)).WillOnce(Return(1u)); + _)) + .WillOnce(Return(1u)); EXPECT_CALL(app_manager_, application(kConnectionKey_)) .WillOnce(Return(mock_app_)); diff --git a/src/components/application_manager/test/rc_policy_handler_test.cc b/src/components/application_manager/test/rc_policy_handler_test.cc index b7caf635c92..818a014a3f8 100644 --- a/src/components/application_manager/test/rc_policy_handler_test.cc +++ b/src/components/application_manager/test/rc_policy_handler_test.cc @@ -30,34 +30,34 @@ * POSSIBILITY OF SUCH DAMAGE. */ +#include #include #include -#include #include "gmock/gmock.h" -#include "application_manager/policies/policy_handler.h" -#include "application_manager/policies/delegates/app_permission_delegate.h" -#include "policy/mock_cache_manager.h" #include "application_manager/mock_message_helper.h" +#include "application_manager/policies/delegates/app_permission_delegate.h" +#include "application_manager/policies/policy_handler.h" #include "connection_handler/mock_connection_handler_settings.h" -#include "policy/policy_types.h" -#include "policy/access_remote.h" #include "json/reader.h" -#include "json/writer.h" #include "json/value.h" +#include "json/writer.h" +#include "policy/access_remote.h" +#include "policy/mock_cache_manager.h" +#include "policy/policy_types.h" #include "smart_objects/smart_object.h" -#include "utils/custom_string.h" -#include "interfaces/MOBILE_API.h" -#include "policy/mock_policy_settings.h" #include "application_manager/mock_application.h" -#include "policy/usage_statistics/mock_statistics_manager.h" -#include "protocol_handler/mock_session_observer.h" -#include "connection_handler/mock_connection_handler.h" #include "application_manager/mock_application_manager.h" -#include "application_manager/policies/mock_policy_handler_observer.h" #include "application_manager/mock_event_dispatcher.h" +#include "application_manager/policies/mock_policy_handler_observer.h" +#include "connection_handler/mock_connection_handler.h" +#include "interfaces/MOBILE_API.h" #include "policy/mock_policy_manager.h" +#include "policy/mock_policy_settings.h" +#include "policy/usage_statistics/mock_statistics_manager.h" +#include "protocol_handler/mock_session_observer.h" +#include "utils/custom_string.h" namespace test { namespace components { diff --git a/src/components/application_manager/test/request_controller/request_controller_test.cc b/src/components/application_manager/test/request_controller/request_controller_test.cc index 112e3c1c397..71e12b2825b 100644 --- a/src/components/application_manager/test/request_controller/request_controller_test.cc +++ b/src/components/application_manager/test/request_controller/request_controller_test.cc @@ -32,24 +32,23 @@ #include -#include "gtest/gtest.h" +#include "application_manager/mock_request.h" #include "application_manager/request_controller.h" #include "application_manager/request_info.h" -#include "application_manager/mock_request.h" +#include "gtest/gtest.h" -#include "smart_objects/smart_object.h" +#include "application_manager/application_impl.h" #include "application_manager/commands/command_request_impl.h" #include "application_manager/message_helper.h" -#include "application_manager/application_impl.h" +#include "smart_objects/smart_object.h" -#include "application_manager/mock_application_manager.h" #include "application_manager/event_engine/event_dispatcher.h" -#include "resumption/last_state.h" +#include "application_manager/mock_application_manager.h" +#include "application_manager/mock_request_controller_settings.h" #include "application_manager/policies/policy_handler.h" -#include "application_manager/state_controller.h" #include "application_manager/resumption/resume_ctrl.h" -#include "application_manager/mock_request_controller_settings.h" -#include "application_manager/mock_application_manager.h" +#include "application_manager/state_controller.h" +#include "resumption/last_state.h" #include "utils/test_async_waiter.h" namespace test { @@ -59,10 +58,10 @@ namespace request_controller_test { using ::application_manager::request_controller::RequestController; using ::application_manager::request_controller::RequestInfo; +using ::testing::_; +using ::testing::NiceMock; using ::testing::Return; using ::testing::ReturnRef; -using ::testing::NiceMock; -using ::testing::_; typedef NiceMock MRequest; typedef std::shared_ptr RequestPtr; diff --git a/src/components/application_manager/test/request_info_test.cc b/src/components/application_manager/test/request_info_test.cc index 0abef44e9a6..a0b1793cf5c 100644 --- a/src/components/application_manager/test/request_info_test.cc +++ b/src/components/application_manager/test/request_info_test.cc @@ -31,10 +31,10 @@ */ #include "application_manager/request_info.h" -#include "application_manager/mock_request.h" #include -#include #include +#include +#include "application_manager/mock_request.h" #include "gmock/gmock.h" namespace request_info = application_manager::request_controller; diff --git a/src/components/application_manager/test/request_tracker_test.cc b/src/components/application_manager/test/request_tracker_test.cc index ee09e0a3e04..9175652da60 100644 --- a/src/components/application_manager/test/request_tracker_test.cc +++ b/src/components/application_manager/test/request_tracker_test.cc @@ -30,13 +30,13 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include "gtest/gtest.h" -#include "utils/macro.h" #include "application_manager/request_tracker.h" #include "application_manager/mock_request_controller_settings.h" +#include "gtest/gtest.h" #include "interfaces/MOBILE_API.h" -#include "utils/lock.h" #include "utils/conditional_variable.h" +#include "utils/lock.h" +#include "utils/macro.h" namespace test { namespace components { @@ -246,6 +246,6 @@ TEST_F(RequestTrackerTestClass, tracker_.Track(app_id, none_level)); } -} // namespace request_controller +} // namespace request_controller_test } // namespace components } // namespace test 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 2413421c7fc..9f0430a937e 100644 --- a/src/components/application_manager/test/resumption/resume_ctrl_test.cc +++ b/src/components/application_manager/test/resumption/resume_ctrl_test.cc @@ -30,26 +30,28 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include #include +#include -#include "gtest/gtest.h" -#include "application_manager/resumption/resume_ctrl_impl.h" -#include "application_manager/usage_statistics.h" -#include "application_manager/mock_application.h" +#include "application_manager/application.h" +#include "application_manager/application_manager_impl.h" +#include "application_manager/display_capabilities_builder.h" #include "application_manager/mock_app_extension.h" +#include "application_manager/mock_application.h" #include "application_manager/mock_help_prompt_manager.h" #include "application_manager/mock_resumption_data.h" +#include "application_manager/mock_rpc_service.h" +#include "application_manager/resumption/resume_ctrl_impl.h" +#include "application_manager/usage_statistics.h" +#include "config_profile/profile.h" +#include "gtest/gtest.h" #include "interfaces/MOBILE_API.h" -#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" #include "application_manager/mock_application_manager_settings.h" #include "application_manager/mock_event_dispatcher.h" +#include "application_manager/mock_message_helper.h" #include "application_manager/mock_state_controller.h" namespace test { @@ -64,15 +66,21 @@ using ::testing::Eq; using ::testing::Mock; using ::testing::NiceMock; using ::testing::Return; -using ::testing::ReturnRef; -using ::testing::SetArgReferee; using ::testing::ReturnPointee; +using ::testing::ReturnRef; using ::testing::SaveArg; +using ::testing::SetArgReferee; using namespace application_manager_test; using namespace resumption; using namespace mobile_apis::HMILevel; +namespace { +const WindowID kDefaultWindowId = + mobile_apis::PredefinedWindows::DEFAULT_WINDOW; +const int32_t kDefaultHmiAppId = 111; +} // namespace + class ResumeCtrlTest : public ::testing::Test { protected: ResumeCtrlTest() @@ -156,6 +164,43 @@ class ResumeCtrlTest : public ::testing::Test { ON_CALL(*mock_app_, is_cloud_app()).WillByDefault(Return(false)); } + smart_objects::SmartObjectSPtr CreateStubCreateWindowRequest( + const std::string window_name, + const WindowID window_id, + const mobile_apis::WindowType::eType window_type) const { + auto request = std::make_shared( + smart_objects::SmartType_Map); + smart_objects::SmartObject msg_params(smart_objects::SmartType_Map); + smart_objects::SmartObject params(smart_objects::SmartType_Map); + + params[strings::correlation_id] = window_id; + + msg_params[strings::window_name] = window_name; + msg_params[strings::window_id] = window_id; + msg_params[strings::window_type] = window_type; + msg_params[strings::app_id] = kDefaultHmiAppId; + + (*request)[strings::msg_params] = msg_params; + (*request)[strings::params] = params; + + return request; + } + + smart_objects::SmartObjectSPtr CreateStubCreateWindowResponse( + const int32_t correlation_id, + const hmi_apis::Common_Result::eType result_code) const { + auto response = std::make_shared( + smart_objects::SmartType_Map); + smart_objects::SmartObject params(smart_objects::SmartType_Map); + + params[strings::correlation_id] = correlation_id; + params[hmi_response::code] = result_code; + + (*response)[strings::params] = params; + + return response; + } + NiceMock mock_event_dispatcher_; application_manager_test::MockApplicationManagerSettings mock_application_manager_settings_; @@ -185,6 +230,7 @@ class ResumeCtrlTest : public ::testing::Test { const std::string kNaviLowbandwidthLevel_; const std::string kProjectionLowbandwidthLevel_; const std::string kMediaLowbandwidthLevel_; + NiceMock mock_rpc_service_; }; /** @@ -501,7 +547,8 @@ TEST_F(ResumeCtrlTest, StartResumption_AppWithSubscribeOnButtons) { EXPECT_CALL(*mock_app_extension_, ProcessResumption(test_subscriptions)); EXPECT_CALL(*application_manager::MockMessageHelper::message_helper_mock(), - SendAllOnButtonSubscriptionNotificationsForApp(_, _)).Times(2); + SendAllOnButtonSubscriptionNotificationsForApp(_, _)) + .Times(2); const bool res = res_ctrl_->StartResumption(mock_app_, kHash_); EXPECT_TRUE(res); @@ -571,12 +618,231 @@ TEST_F(ResumeCtrlTest, StartResumption_AppWithSubscriptionToWayPoints) { mobile_apis::HMILevel::HMI_FULL; ON_CALL(mock_app_mngr_, GetDefaultHmiLevel(const_app_)) .WillByDefault(Return(hmi_test_level)); - EXPECT_CALL(mock_state_controller_, SetRegularState(_, hmi_test_level)); + EXPECT_CALL(mock_state_controller_, + SetRegularState(_, kDefaultWindowId, hmi_test_level)); const bool result = res_ctrl_->StartResumption(mock_app_, kHash_); EXPECT_TRUE(result); } +TEST_F(ResumeCtrlTest, + RestoreAppWidgets_AppWithWidgets_SendCreateWindowRequests) { + using namespace smart_objects; + using namespace application_manager; + GetInfoFromApp(); + const uint32_t count_of_widgets = 10u; + + auto create_window_info_so = []() -> SmartObject { + SmartObject widgets_info(SmartType_Array); + for (uint32_t i = 0; i < count_of_widgets; ++i) { + SmartObject widget_info(SmartType_Map); + widget_info[strings::associated_service_type] = "ServiceType"; + widget_info[strings::duplicate_updates_from_window_id] = 0; + widget_info[strings::window_name] = + std::string("Widget ") + std::to_string(i + 1); + widget_info[strings::window_type] = + static_cast(mobile_apis::WindowType::WIDGET); + widget_info[strings::window_id] = i + 1; + widgets_info[widgets_info.length()] = widget_info; + } + return widgets_info; + }; + + auto create_saved_app_so = [&create_window_info_so, this]() -> SmartObject { + smart_objects::SmartObject saved_app; + const auto test_app_widgets = create_window_info_so(); + saved_app[strings::hash_id] = kHash_; + saved_app[strings::windows_info] = test_app_widgets; + saved_app[application_manager::strings::grammar_id] = kTestGrammarId_; + saved_app[application_manager::strings::hmi_level] = eType::HMI_FULL; + return saved_app; + }; + + const auto saved_app = create_saved_app_so(); + + const auto hmi_request = std::make_shared( + smart_objects::SmartType_Map); + const auto hmi_requests = + smart_objects::SmartObjectList(count_of_widgets, hmi_request); + + DisplayCapabilitiesBuilder builder(*mock_app_); + ON_CALL(*mock_app_, display_capabilities_builder()) + .WillByDefault(ReturnRef(builder)); + EXPECT_CALL( + *application_manager::MockMessageHelper::message_helper_mock(), + CreateUICreateWindowRequestsToHMI(_, _, saved_app[strings::windows_info])) + .WillOnce(Return(hmi_requests)); + + ON_CALL(mock_app_mngr_, GetRPCService()) + .WillByDefault(ReturnRef(mock_rpc_service_)); + + EXPECT_CALL(mock_rpc_service_, + ManageHMICommand(_, commands::Command::SOURCE_SDL_TO_HMI)) + .Times(count_of_widgets) + .WillRepeatedly(Return(true)); + + res_ctrl_->RestoreAppWidgets(mock_app_, saved_app); +} + +TEST_F(ResumeCtrlTest, + RestoreWidgetsHMIState_AppWithWidgets_AddWidgetsInternally) { + const uint32_t count_of_widgets = 10u; + + smart_objects::SmartObject saved_app; + saved_app[strings::hash_id] = kHash_; + saved_app[strings::windows_info] = smart_objects::SmartObject(); + saved_app[application_manager::strings::grammar_id] = kTestGrammarId_; + saved_app[application_manager::strings::hmi_level] = eType::HMI_FULL; + + ON_CALL(mock_app_mngr_, application_by_hmi_app(kDefaultHmiAppId)) + .WillByDefault(Return(mock_app_)); + DisplayCapabilitiesBuilder builder(*mock_app_); + ON_CALL(*mock_app_, display_capabilities_builder()) + .WillByDefault(ReturnRef(builder)); + + smart_objects::SmartObjectList requests; + smart_objects::SmartObjectList responses; + for (uint32_t i = 0; i < count_of_widgets; ++i) { + const auto window_type = mobile_apis::WindowType::WIDGET; + const WindowID window_id = i + 1; + const auto window_name = std::string("Widget ") + std::to_string(window_id); + requests.push_back( + CreateStubCreateWindowRequest(window_name, window_id, window_type)); + responses.push_back(CreateStubCreateWindowResponse( + window_id, hmi_apis::Common_Result::SUCCESS)); + EXPECT_CALL(mock_app_mngr_, CreateRegularState(_, window_type, _, _, _, _)) + .WillRepeatedly(Return(nullptr)); + EXPECT_CALL(*mock_app_, SetInitialState(window_id, window_name, _)); + EXPECT_CALL(mock_state_controller_, + OnAppWindowAdded(_, window_id, window_type, _)); + } + + EXPECT_CALL(*application_manager::MockMessageHelper::message_helper_mock(), + CreateUICreateWindowRequestsToHMI(_, _, _)) + .WillOnce(Return(requests)); + + ON_CALL(mock_app_mngr_, GetRPCService()) + .WillByDefault(ReturnRef(mock_rpc_service_)); + EXPECT_CALL(mock_rpc_service_, + ManageHMICommand(_, commands::Command::SOURCE_SDL_TO_HMI)) + .Times(count_of_widgets) + .WillRepeatedly(Return(true)); + res_ctrl_->RestoreAppWidgets(mock_app_, saved_app); + for (const auto& response : responses) { + res_ctrl_->RestoreWidgetsHMIState(*response); + } +} + +TEST_F(ResumeCtrlTest, + RestoreAppWidgets_AppWithoutWidgets_NoCreateWindowRqSent) { + smart_objects::SmartObject saved_app; + saved_app[strings::hash_id] = kHash_; + saved_app[application_manager::strings::grammar_id] = kTestGrammarId_; + saved_app[application_manager::strings::hmi_level] = eType::HMI_FULL; + + EXPECT_CALL(*application_manager::MockMessageHelper::message_helper_mock(), + CreateUICreateWindowRequestsToHMI(_, _, _)) + .Times(0); + + res_ctrl_->RestoreAppWidgets(mock_app_, saved_app); +} + +TEST_F(ResumeCtrlTest, RestoreWidgetsHMIState_HMIResponseWith_InvalidCorrId) { + smart_objects::SmartObject saved_app; + saved_app[strings::hash_id] = kHash_; + saved_app[strings::windows_info] = smart_objects::SmartObject(); + saved_app[application_manager::strings::grammar_id] = kTestGrammarId_; + saved_app[application_manager::strings::hmi_level] = eType::HMI_FULL; + + const int32_t invalid_corr_id = -1; + auto response = CreateStubCreateWindowResponse( + invalid_corr_id, hmi_apis::Common_Result::SUCCESS); + + ON_CALL(mock_app_mngr_, application_by_hmi_app(kDefaultHmiAppId)) + .WillByDefault(Return(mock_app_)); + + DisplayCapabilitiesBuilder builder(*mock_app_); + ON_CALL(*mock_app_, display_capabilities_builder()) + .WillByDefault(ReturnRef(builder)); + + smart_objects::SmartObjectList requests; + + const auto window_type = mobile_apis::WindowType::WIDGET; + const WindowID window_id = 1; + const auto window_name = std::string("Widget ") + std::to_string(window_id); + requests.push_back( + CreateStubCreateWindowRequest(window_name, window_id, window_type)); + + EXPECT_CALL(mock_app_mngr_, CreateRegularState(_, window_type, _, _, _, _)) + .Times(0); + EXPECT_CALL(*mock_app_, SetInitialState(window_id, window_name, _)).Times(0); + EXPECT_CALL(mock_state_controller_, + OnAppWindowAdded(_, window_id, window_type, _)) + .Times(0); + + EXPECT_CALL(*application_manager::MockMessageHelper::message_helper_mock(), + CreateUICreateWindowRequestsToHMI(_, _, _)) + .WillOnce(Return(requests)); + + ON_CALL(mock_app_mngr_, GetRPCService()) + .WillByDefault(ReturnRef(mock_rpc_service_)); + EXPECT_CALL(mock_rpc_service_, + ManageHMICommand(_, commands::Command::SOURCE_SDL_TO_HMI)) + .WillRepeatedly(Return(true)); + res_ctrl_->RestoreAppWidgets(mock_app_, saved_app); + res_ctrl_->RestoreWidgetsHMIState(*response); +} + +TEST_F(ResumeCtrlTest, RestoreWidgetsHMIState_HMIResponseWith_Unsuccess) { + smart_objects::SmartObject saved_app; + saved_app[strings::hash_id] = kHash_; + saved_app[strings::windows_info] = smart_objects::SmartObject(); + saved_app[application_manager::strings::grammar_id] = kTestGrammarId_; + saved_app[application_manager::strings::hmi_level] = eType::HMI_FULL; + + const int32_t correlation_id = 1; + auto response = CreateStubCreateWindowResponse( + correlation_id, hmi_apis::Common_Result::GENERIC_ERROR); + + ON_CALL(mock_app_mngr_, application_by_hmi_app(kDefaultHmiAppId)) + .WillByDefault(Return(mock_app_)); + + DisplayCapabilitiesBuilder builder(*mock_app_); + smart_objects::SmartObject stub_window_info(smart_objects::SmartType_Null); + auto stub_resume_cb = [](Application&, const smart_objects::SmartObject&) {}; + builder.InitBuilder(stub_resume_cb, stub_window_info); + ON_CALL(*mock_app_, display_capabilities_builder()) + .WillByDefault(ReturnRef(builder)); + + smart_objects::SmartObjectList requests; + smart_objects::SmartObjectList responses; + + const auto window_type = mobile_apis::WindowType::WIDGET; + const WindowID window_id = 1; + const auto window_name = std::string("Widget ") + std::to_string(window_id); + requests.push_back( + CreateStubCreateWindowRequest(window_name, window_id, window_type)); + + EXPECT_CALL(mock_app_mngr_, CreateRegularState(_, window_type, _, _, _, _)) + .Times(0); + EXPECT_CALL(*mock_app_, SetInitialState(window_id, window_name, _)).Times(0); + EXPECT_CALL(mock_state_controller_, + OnAppWindowAdded(_, window_id, window_type, _)) + .Times(0); + + EXPECT_CALL(*application_manager::MockMessageHelper::message_helper_mock(), + CreateUICreateWindowRequestsToHMI(_, _, _)) + .WillOnce(Return(requests)); + + ON_CALL(mock_app_mngr_, GetRPCService()) + .WillByDefault(ReturnRef(mock_rpc_service_)); + EXPECT_CALL(mock_rpc_service_, + ManageHMICommand(_, commands::Command::SOURCE_SDL_TO_HMI)) + .WillRepeatedly(Return(true)); + res_ctrl_->RestoreAppWidgets(mock_app_, saved_app); + res_ctrl_->RestoreWidgetsHMIState(*response); +} + TEST_F(ResumeCtrlTest, StartResumptionOnlyHMILevel) { smart_objects::SmartObject saved_app; @@ -631,7 +897,8 @@ TEST_F(ResumeCtrlTest, StartAppHmiStateResumption_AppInFull) { DataAccessor data_accessor( command, app_set_lock_ptr_); - EXPECT_CALL(mock_state_controller_, SetRegularState(_, restored_test_type)) + EXPECT_CALL(mock_state_controller_, + SetRegularState(_, kDefaultWindowId, restored_test_type)) .Times(AtLeast(1)); GetInfoFromApp(); EXPECT_CALL(mock_app_mngr_, GetDefaultHmiLevel(const_app_)) @@ -680,7 +947,8 @@ TEST_F(ResumeCtrlTest, StartAppHmiStateResumption_AppHasDeferredResumption) { 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)) + EXPECT_CALL(mock_state_controller_, + SetRegularState(_, kDefaultWindowId, deferred_level)) .Times(AtLeast(1)); GetInfoFromApp(); ON_CALL(*mock_storage_, @@ -715,7 +983,8 @@ TEST_F(ResumeCtrlTest, 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)) + EXPECT_CALL(mock_state_controller_, + SetRegularState(_, kDefaultWindowId, eType::HMI_LIMITED)) .Times(AtLeast(1)); GetInfoFromApp(); ON_CALL(*mock_storage_, @@ -759,7 +1028,8 @@ TEST_F( // in this test, it is expected that the app will resume into LIMITED, which // is the higher level among NONE and LIMITED - EXPECT_CALL(mock_state_controller_, SetRegularState(_, eType::HMI_LIMITED)) + EXPECT_CALL(mock_state_controller_, + SetRegularState(_, kDefaultWindowId, eType::HMI_LIMITED)) .Times(AtLeast(1)); GetInfoFromApp(); ON_CALL(*mock_storage_, @@ -815,7 +1085,8 @@ TEST_F(ResumeCtrlTest, RestoreAppHMIState_RestoreHMILevelFull) { saved_app[application_manager::strings::grammar_id] = kTestGrammarId_; saved_app[application_manager::strings::hmi_level] = restored_test_type; - EXPECT_CALL(mock_state_controller_, SetRegularState(_, restored_test_type)) + EXPECT_CALL(mock_state_controller_, + SetRegularState(_, kDefaultWindowId, restored_test_type)) .Times(AtLeast(1)); GetInfoFromApp(); EXPECT_CALL(mock_app_mngr_, GetDefaultHmiLevel(const_app_)) @@ -827,7 +1098,6 @@ TEST_F(ResumeCtrlTest, RestoreAppHMIState_RestoreHMILevelFull) { ON_CALL(mock_app_mngr_, GetUserConsentForDevice("12345")) .WillByDefault(Return(policy::kDeviceAllowed)); - EXPECT_CALL(*mock_app_, set_is_resuming(true)); const bool res = res_ctrl_->RestoreAppHMIState(mock_app_); EXPECT_TRUE(res); @@ -846,7 +1116,8 @@ TEST_F(ResumeCtrlTest, SetupDefaultHMILevel) { ON_CALL(mock_app_mngr_, GetDefaultHmiLevel(const_app_)) .WillByDefault(Return(kDefaultTestLevel_)); - EXPECT_CALL(mock_state_controller_, SetRegularState(_, kDefaultTestLevel_)) + EXPECT_CALL(mock_state_controller_, + SetRegularState(_, kDefaultWindowId, kDefaultTestLevel_)) .Times(AtLeast(1)); res_ctrl_->SetupDefaultHMILevel(mock_app_); @@ -875,7 +1146,8 @@ TEST_F(ResumeCtrlTest, EXPECT_CALL(*mock_app_, is_media_application()).WillRepeatedly(Return(false)); // SetRegularState() should be called with kProjectionLowbandwidthLevel_ - EXPECT_CALL(mock_state_controller_, SetRegularState(_, eType::HMI_NONE)) + EXPECT_CALL(mock_state_controller_, + SetRegularState(_, kDefaultWindowId, eType::HMI_NONE)) .Times(AtLeast(1)); res_ctrl_->SetupDefaultHMILevel(mock_app_); @@ -902,7 +1174,8 @@ TEST_F(ResumeCtrlTest, ApplicationResumptiOnTimer_AppInFull) { MockStateController state_controller; EXPECT_CALL(mock_app_mngr_, state_controller()) .WillOnce(ReturnRef(state_controller)); - EXPECT_CALL(state_controller, SetRegularState(_, restored_test_type)) + EXPECT_CALL(state_controller, + SetRegularState(_, kDefaultWindowId, restored_test_type)) .Times(AtLeast(1)); GetInfoFromApp(); EXPECT_CALL(mock_app_mngr_, GetDefaultHmiLevel(const_app_)) @@ -930,8 +1203,8 @@ TEST_F(ResumeCtrlTest, SetAppHMIState_HMINone_WithoutCheckPolicy) { EXPECT_CALL(mock_app_mngr_, GetUserConsentForDevice("12345")).Times(0); - EXPECT_CALL(*mock_app_, set_is_resuming(true)); - EXPECT_CALL(mock_state_controller_, SetRegularState(_, kDefaultTestLevel_)) + EXPECT_CALL(mock_state_controller_, + SetRegularState(_, kDefaultWindowId, kDefaultTestLevel_)) .Times(AtLeast(1)); const bool res = res_ctrl_->SetAppHMIState(mock_app_, kDefaultTestLevel_, false); @@ -943,8 +1216,8 @@ TEST_F(ResumeCtrlTest, SetAppHMIState_HMILimited_WithoutCheckPolicy) { GetInfoFromApp(); EXPECT_CALL(mock_app_mngr_, GetUserConsentForDevice("12345")).Times(0); - EXPECT_CALL(*mock_app_, set_is_resuming(true)); - EXPECT_CALL(mock_state_controller_, SetRegularState(_, test_type)) + EXPECT_CALL(mock_state_controller_, + SetRegularState(_, kDefaultWindowId, test_type)) .Times(AtLeast(1)); const bool res = res_ctrl_->SetAppHMIState(mock_app_, test_type, false); EXPECT_TRUE(res); @@ -957,8 +1230,8 @@ TEST_F(ResumeCtrlTest, SetAppHMIState_HMIFull_WithoutCheckPolicy) { EXPECT_CALL(mock_app_mngr_, GetDefaultHmiLevel(const_app_)).Times(0); EXPECT_CALL(mock_app_mngr_, GetUserConsentForDevice("12345")).Times(0); - EXPECT_CALL(*mock_app_, set_is_resuming(true)); - EXPECT_CALL(mock_state_controller_, SetRegularState(_, test_type)) + EXPECT_CALL(mock_state_controller_, + SetRegularState(_, kDefaultWindowId, test_type)) .Times(AtLeast(1)); const bool res = res_ctrl_->SetAppHMIState(mock_app_, test_type, false); @@ -972,8 +1245,8 @@ TEST_F(ResumeCtrlTest, SetAppHMIState_HMIFull_WithPolicy_DevAllowed) { ON_CALL(mock_app_mngr_, GetUserConsentForDevice("12345")) .WillByDefault(Return(policy::kDeviceAllowed)); - EXPECT_CALL(*mock_app_, set_is_resuming(true)); - EXPECT_CALL(mock_state_controller_, SetRegularState(_, test_type)) + EXPECT_CALL(mock_state_controller_, + SetRegularState(_, kDefaultWindowId, test_type)) .Times(AtLeast(1)); const bool res = res_ctrl_->SetAppHMIState(mock_app_, test_type, true); @@ -987,10 +1260,10 @@ TEST_F(ResumeCtrlTest, SetAppHMIState_HMIFull_WithPolicy_DevDisallowed) { ON_CALL(mock_app_mngr_, GetUserConsentForDevice("12345")) .WillByDefault(Return(policy::kDeviceDisallowed)); - EXPECT_CALL(*mock_app_, set_is_resuming(true)); ON_CALL(mock_app_mngr_, GetDefaultHmiLevel(const_app_)) .WillByDefault(Return(kDefaultTestLevel_)); - EXPECT_CALL(mock_state_controller_, SetRegularState(_, kDefaultTestLevel_)) + EXPECT_CALL(mock_state_controller_, + SetRegularState(_, kDefaultWindowId, kDefaultTestLevel_)) .Times(AtLeast(1)); const bool res = res_ctrl_->SetAppHMIState(mock_app_, test_type, true); EXPECT_FALSE(res); @@ -1245,7 +1518,8 @@ TEST_F( DataAccessor data_accessor( command, app_set_lock_ptr_); - EXPECT_CALL(mock_state_controller_, SetRegularState(_, restored_test_type)) + EXPECT_CALL(mock_state_controller_, + SetRegularState(_, kDefaultWindowId, restored_test_type)) .Times(AtLeast(1)); GetInfoFromApp(); EXPECT_CALL(mock_app_mngr_, GetDefaultHmiLevel(const_app_)) @@ -1352,7 +1626,8 @@ TEST_F( DataAccessor data_accessor( command, app_set_lock_ptr_); - EXPECT_CALL(mock_state_controller_, SetRegularState(_, restored_test_type)) + EXPECT_CALL(mock_state_controller_, + SetRegularState(_, kDefaultWindowId, restored_test_type)) .Times(AtLeast(1)); GetInfoFromApp(); EXPECT_CALL(mock_app_mngr_, GetDefaultHmiLevel(const_app_)) 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 8423520b9f1..d67c229cc3a 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 @@ -30,30 +30,30 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include #include -#include "gtest/gtest.h" +#include #include "application_manager/mock_application.h" #include "application_manager/mock_application_manager_settings.h" +#include "gtest/gtest.h" #include "interfaces/MOBILE_API.h" #include "utils/sqlite_wrapper/sql_database.h" #include "utils/sqlite_wrapper/sql_query.h" -#include "utils/file_system.h" #include "application_manager/resumption_data_test.h" #include "application_manager/test_resumption_data_db.h" +#include "utils/file_system.h" -#include "application_manager/resumption/resumption_sql_queries.h" #include "application_manager/resumption/resumption_data_db.h" +#include "application_manager/resumption/resumption_sql_queries.h" namespace test { namespace components { namespace resumption_test { +using application_manager_test::MockApplication; +using ::testing::_; using ::testing::NiceMock; using ::testing::ReturnRef; -using ::testing::_; -using application_manager_test::MockApplication; namespace am = application_manager; using namespace file_system; @@ -344,7 +344,8 @@ void ResumptionDataDBTest::CheckCharacters(int64_t global_properties_key) { while (select_characters.Next()) { std::string character = (*keyboard_props_)[am::strings::limited_character_list] - [characters_idx++].asString(); + [characters_idx++] + .asString(); EXPECT_EQ(character, select_characters.GetString(0)); } } @@ -392,16 +393,17 @@ void ResumptionDataDBTest::CheckCommandsData() { ++i; uint cmd = (*test_commands_map[i])[am::strings::cmd_id].asUInt(); EXPECT_EQ(cmd, select_commands.GetUInteger(1)); - std::string name = - (*test_commands_map[i])[am::strings::menu_params] - [am::strings::menu_name].asString(); + std::string name = (*test_commands_map[i])[am::strings::menu_params] + [am::strings::menu_name] + .asString(); EXPECT_EQ(name, select_commands.GetString(2)); int position = (*test_commands_map[i])[am::strings::menu_params] - [am::strings::position].asInt(); + [am::strings::position] + .asInt(); EXPECT_EQ(position, select_commands.GetInteger(4)); - int parent_id = - (*test_commands_map[i])[am::strings::menu_params] - [am::hmi_request::parent_id].asInt(); + int parent_id = (*test_commands_map[i])[am::strings::menu_params] + [am::hmi_request::parent_id] + .asInt(); EXPECT_EQ(parent_id, select_commands.GetInteger(3)); std::string icon_name = (*test_commands_map[i])[am::strings::cmd_icon][am::strings::value] @@ -409,7 +411,8 @@ void ResumptionDataDBTest::CheckCommandsData() { EXPECT_EQ(icon_name, select_commands.GetString(5)); int icon_type = (*test_commands_map[i])[am::strings::cmd_icon] - [am::strings::image_type].asInt(); + [am::strings::image_type] + .asInt(); EXPECT_EQ(icon_type, select_commands.GetInteger(6)); j = 0; @@ -461,12 +464,12 @@ void ResumptionDataDBTest::CheckChoiceSetData() { std::string menu_name = command[am::strings::choice_set][choice_idx][am::strings::menu_name] .asString(); - std::string secondary_text = - command[am::strings::choice_set][choice_idx] - [am::strings::secondary_text].asString(); - std::string tertiary_text = - command[am::strings::choice_set][choice_idx] - [am::strings::tertiary_text].asString(); + std::string secondary_text = command[am::strings::choice_set][choice_idx] + [am::strings::secondary_text] + .asString(); + std::string tertiary_text = command[am::strings::choice_set][choice_idx] + [am::strings::tertiary_text] + .asString(); EXPECT_EQ(choice_id, select_choice_set.GetInteger(4)); EXPECT_EQ(menu_name, select_choice_set.GetString(5)); @@ -478,12 +481,12 @@ void ResumptionDataDBTest::CheckChoiceSetData() { EXPECT_TRUE(select_image.Prepare(kSelectImage)); select_image.Bind(0, select_choice_set.GetLongInt(8)); EXPECT_TRUE(select_image.Exec()); - std::string image_value = - command[am::strings::choice_set][choice_idx][am::strings::image] - [am::strings::value].asString(); - int image_type = - command[am::strings::choice_set][choice_idx][am::strings::image] - [am::strings::image_type].asInt(); + std::string image_value = command[am::strings::choice_set][choice_idx] + [am::strings::image][am::strings::value] + .asString(); + int image_type = command[am::strings::choice_set][choice_idx] + [am::strings::image][am::strings::image_type] + .asInt(); EXPECT_EQ(image_value, select_image.GetString(1)); EXPECT_EQ(image_type, select_image.GetInteger(0)); @@ -491,9 +494,9 @@ void ResumptionDataDBTest::CheckChoiceSetData() { EXPECT_TRUE(select_image.Prepare(kSelectImage)); select_image.Bind(0, select_choice_set.GetLongInt(9)); EXPECT_TRUE(select_image.Exec()); - image_value = - command[am::strings::choice_set][choice_idx] - [am::strings::secondary_image][am::strings::value].asString(); + image_value = command[am::strings::choice_set][choice_idx] + [am::strings::secondary_image][am::strings::value] + .asString(); image_type = command[am::strings::choice_set][choice_idx] [am::strings::secondary_image][am::strings::image_type] @@ -503,9 +506,9 @@ void ResumptionDataDBTest::CheckChoiceSetData() { vr_cmd_idx = 0; } - std::string vr_comm = - command[am::strings::choice_set][choice_idx][am::strings::vr_commands] - [vr_cmd_idx++].asString(); + std::string vr_comm = command[am::strings::choice_set][choice_idx] + [am::strings::vr_commands][vr_cmd_idx++] + .asString(); EXPECT_EQ(vr_comm, select_choice_set.GetString(10)); } } diff --git a/src/components/application_manager/test/resumption/resumption_data_json_test.cc b/src/components/application_manager/test/resumption/resumption_data_json_test.cc index 40e61a3c53c..955309e091b 100644 --- a/src/components/application_manager/test/resumption/resumption_data_json_test.cc +++ b/src/components/application_manager/test/resumption/resumption_data_json_test.cc @@ -30,13 +30,13 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include #include +#include #include "gtest/gtest.h" -#include "application_manager/usage_statistics.h" #include "application_manager/mock_application.h" #include "application_manager/mock_resumption_data.h" +#include "application_manager/usage_statistics.h" #include "interfaces/MOBILE_API.h" #include "resumption/last_state_impl.h" @@ -51,9 +51,9 @@ namespace components { namespace resumption_test { using ::testing::_; +using ::testing::NiceMock; using ::testing::Return; using ::testing::ReturnRef; -using ::testing::NiceMock; namespace am = application_manager; using namespace Json; diff --git a/src/components/application_manager/test/resumption/resumption_data_test.cc b/src/components/application_manager/test/resumption/resumption_data_test.cc index fe24ea39b62..e362064a781 100644 --- a/src/components/application_manager/test/resumption/resumption_data_test.cc +++ b/src/components/application_manager/test/resumption/resumption_data_test.cc @@ -30,16 +30,16 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include #include +#include #include "gtest/gtest.h" -#include "application_manager/usage_statistics.h" +#include "application_manager/application.h" +#include "application_manager/message_helper.h" #include "application_manager/mock_resumption_data.h" +#include "application_manager/usage_statistics.h" #include "utils/custom_string.h" -#include "application_manager/application.h" #include "utils/data_accessor.h" -#include "application_manager/message_helper.h" #include "application_manager/resumption_data_test.h" @@ -47,10 +47,10 @@ namespace test { namespace components { namespace resumption_test { namespace custom_str = utils::custom_string; +using ::testing::_; using ::testing::Return; -using ::testing::ReturnRef; using ::testing::ReturnPointee; -using ::testing::_; +using ::testing::ReturnRef; void ResumptionDataTest::CheckSavedApp(sm::SmartObject& resume_app_list) { EXPECT_EQ(policy_app_id_, resume_app_list[am::strings::app_id].asString()); @@ -74,14 +74,15 @@ void ResumptionDataTest::CheckSavedApp(sm::SmartObject& resume_app_list) { CheckGlobalProporties( resume_app_list[am::strings::application_global_properties]); CheckSubscriptions(resume_app_list[am::strings::application_subscriptions]); + CheckWindowsInfo(resume_app_list[am::strings::windows_info]); } void ResumptionDataTest::CheckCommands(sm::SmartObject& res_list) { for (uint32_t i = 0; i < kCountOfCommands_; ++i) { EXPECT_EQ(i, res_list[i][am::strings::cmd_id].asUInt()); - std::string name = - (*test_commands_map[i])[am::strings::menu_params] - [am::strings::menu_name].asString(); + std::string name = (*test_commands_map[i])[am::strings::menu_params] + [am::strings::menu_name] + .asString(); EXPECT_EQ(name, res_list[i][am::strings::menu_params][am::strings::menu_name] .asString()); @@ -93,7 +94,8 @@ void ResumptionDataTest::CheckCommands(sm::SmartObject& res_list) { res_list[i][am::strings::menu_params][am::strings::position].asInt()); int parent_id = (*test_commands_map[i])[am::strings::menu_params] - [am::hmi_request::parent_id].asInt(); + [am::hmi_request::parent_id] + .asInt(); EXPECT_EQ(parent_id, res_list[i][am::strings::menu_params][am::hmi_request::parent_id] .asInt()); @@ -150,20 +152,24 @@ void ResumptionDataTest::CheckChoiceSet(sm::SmartObject& res_list) { std::snprintf(numb, 12, "%d", i + j); std::string test_choice = (*test_choiceset_map[i])[am::strings::choice_set][j] - [am::strings::vr_commands][0].asString(); + [am::strings::vr_commands][0] + .asString(); EXPECT_EQ(test_choice, command[am::strings::vr_commands][0].asString()); std::string menu_name = (*test_choiceset_map[i])[am::strings::choice_set][j] - [am::strings::menu_name].asString(); + [am::strings::menu_name] + .asString(); EXPECT_EQ(menu_name, command[am::strings::menu_name].asString()); std::string secondary_text = (*test_choiceset_map[i])[am::strings::choice_set][j] - [am::strings::secondary_text].asString(); + [am::strings::secondary_text] + .asString(); EXPECT_EQ(secondary_text, command[am::strings::secondary_text].asString()); std::string tertiary_text = (*test_choiceset_map[i])[am::strings::choice_set][j] - [am::strings::tertiary_text].asString(); + [am::strings::tertiary_text] + .asString(); EXPECT_EQ(tertiary_text, command[am::strings::tertiary_text].asString()); std::string image_value = @@ -181,13 +187,15 @@ void ResumptionDataTest::CheckChoiceSet(sm::SmartObject& res_list) { image_value = (*test_choiceset_map[i])[am::strings::choice_set][j] [am::strings::secondary_image] - [am::strings::value].asString(); + [am::strings::value] + .asString(); EXPECT_EQ( image_value, command[am::strings::secondary_image][am::strings::value].asString()); image_type = (*test_choiceset_map[i])[am::strings::choice_set][j] [am::strings::secondary_image] - [am::strings::image_type].asInt(); + [am::strings::image_type] + .asInt(); EXPECT_EQ(image_type, command[am::strings::secondary_image][am::strings::image_type] .asInt()); @@ -320,6 +328,33 @@ void ResumptionDataTest::CheckVRTitle( EXPECT_EQ(vtitle, res_list[am::strings::vr_help_title].asString()); } +void ResumptionDataTest::CheckWindowsInfo(sm::SmartObject& res_list) { + using namespace application_manager; + auto check_window_info = [this]( + const smart_objects::SmartObject& window_info) { + using namespace application_manager; + const WindowID saved_window_id = window_info[strings::window_id].asInt(); + const auto test_window_info = test_window_params_map_[saved_window_id]; + const auto& saved_window_name = + window_info[strings::window_name].asString(); + ASSERT_TRUE(0 != test_window_info.use_count()); + const auto& window_name = + (*test_window_info)[strings::window_name].asString(); + const auto& saved_duplicate_window_id = + window_info[strings::duplicate_updates_from_window_id].asInt(); + const auto& saved_associated_service_type = + window_info[strings::associated_service_type].asString(); + EXPECT_EQ(saved_window_name, window_name); + EXPECT_EQ("ServiceType", saved_associated_service_type); + EXPECT_EQ(0, saved_duplicate_window_id); + }; + + for (size_t i = 0; i < res_list.length(); ++i) { + const auto& saved_window_info = res_list[i]; + check_window_info(saved_window_info); + } +} + void ResumptionDataTest::PrepareData() { mock_app_extension_ = std::make_shared >(); @@ -334,9 +369,14 @@ void ResumptionDataTest::PrepareData() { DataAccessor sub_menu_m(test_submenu_map, sublock_ptr_); DataAccessor commands_m(test_commands_map, comlock_ptr_); DataAccessor choice_set_m(test_choiceset_map, setlock_ptr_); + DataAccessor window_params_map( + test_window_params_map_, window_params_map_lock_ptr_); SetSubscriptions(); DataAccessor btn_sub(btn_subscr, btnlock_ptr_); + SetWindowsInfo(); + SetDefaultCurrentHmiState(); + SetDefaultWindowIds(); ON_CALL(*app_mock, is_application_data_changed()).WillByDefault(Return(true)); @@ -345,7 +385,8 @@ void ResumptionDataTest::PrepareData() { ON_CALL(*app_mock, curHash()).WillByDefault(ReturnRef(hash_)); ON_CALL(*app_mock, get_grammar_id()).WillByDefault(Return(grammar_id_)); ON_CALL(*app_mock, device()).WillByDefault(Return(device_handle_)); - ON_CALL(*app_mock, hmi_level()).WillByDefault(Return(hmi_level_)); + ON_CALL(*app_mock, hmi_level(mobile_apis::PredefinedWindows::DEFAULT_WINDOW)) + .WillByDefault(Return(hmi_level_)); ON_CALL(*app_mock, app_id()).WillByDefault(Return(app_id_)); ON_CALL(*app_mock, hmi_app_id()).WillByDefault(Return(hmi_app_id_)); ON_CALL(*app_mock, IsAudioApplication()).WillByDefault(Return(is_audio_)); @@ -368,6 +409,21 @@ void ResumptionDataTest::PrepareData() { ON_CALL(*app_mock, SubscribedButtons()).WillByDefault(Return(btn_sub)); ON_CALL(*app_mock, getAppFiles()).WillByDefault(ReturnRef(app_files_map_)); + ON_CALL(*app_mock, window_optional_params_map()) + .WillByDefault(Return(window_params_map)); +} + +void ResumptionDataTest::SetDefaultCurrentHmiState() { + am::HmiStatePtr hmi_state = + std::make_shared(app_mock, mock_application_manager_); + hmi_state->set_window_type(mobile_apis::WindowType::WIDGET); + + ON_CALL(*app_mock, CurrentHmiState(_)).WillByDefault(Return(hmi_state)); +} + +void ResumptionDataTest::SetDefaultWindowIds() { + const am::WindowIds window_ids{1, 2, 3, 4, 5}; + ON_CALL(*app_mock, GetWindowIds()).WillByDefault(Return(window_ids)); } void ResumptionDataTest::SetGlobalProporties() { @@ -543,6 +599,21 @@ void ResumptionDataTest::SetSubscriptions() { btn_subscr.insert(ButtonName::eType::OK); } +void ResumptionDataTest::SetWindowsInfo() { + using namespace application_manager; + const uint32_t number_of_widgets = 5; + for (uint32_t i = 0; i < number_of_widgets; ++i) { + auto window_info = std::make_shared( + smart_objects::SmartType_Map); + const WindowID window_id = i + 1; + (*window_info)[strings::window_name] = + std::string("Widget ") + std::to_string(window_id); + (*window_info)[strings::associated_service_type] = "ServiceType"; + (*window_info)[strings::duplicate_updates_from_window_id] = 0; + test_window_params_map_[window_id] = window_info; + } +} + } // namespace resumption_test } // namespace components } // namespace test diff --git a/src/components/application_manager/test/resumption_sql_queries_test.cc b/src/components/application_manager/test/resumption_sql_queries_test.cc index 0ec902085f2..61490ae4aff 100644 --- a/src/components/application_manager/test/resumption_sql_queries_test.cc +++ b/src/components/application_manager/test/resumption_sql_queries_test.cc @@ -31,17 +31,17 @@ */ #include -#include -#include #include +#include #include +#include #include "gtest/gtest.h" -#include "utils/sqlite_wrapper/sql_database.h" -#include "utils/sqlite_wrapper/sql_query.h" -#include "utils/file_system.h" #include "application_manager/resumption/resumption_sql_queries.h" #include "policy/sql_pt_queries.h" +#include "utils/file_system.h" +#include "utils/sqlite_wrapper/sql_database.h" +#include "utils/sqlite_wrapper/sql_query.h" namespace test { namespace components { @@ -49,8 +49,8 @@ namespace resumption_test { using namespace ::resumption; -using std::string; using std::pair; +using std::string; using utils::dbms::SQLDatabase; using utils::dbms::SQLQuery; @@ -808,7 +808,8 @@ TEST_F(ResumptionSqlQueriesTest, kSelectCountHMILevel_ExpectDataCorrect) { int64_t key = FillImageTable(temp_query, /*image_type=*/1, test_image, - /*is_template=*/true).LastInsertId(); + /*is_template=*/true) + .LastInsertId(); key = FillGlobalPropertiesTable( temp_query, "vrHelp", "menuTitle", 1, 1, 2, "auto", key) .LastInsertId(); @@ -838,7 +839,8 @@ TEST_F(ResumptionSqlQueriesTest, kSelectHMILevel_ExpectDataCorrect) { int64_t key = FillImageTable(temp_query, /*image_type=*/1, test_image, - /*is_template=*/true).LastInsertId(); + /*is_template=*/true) + .LastInsertId(); key = FillGlobalPropertiesTable( temp_query, "vrHelp", "menuTitle", 1, 1, 2, "auto", key) .LastInsertId(); @@ -866,7 +868,8 @@ TEST_F(ResumptionSqlQueriesTest, kCheckHMIId_ExpectDataCorrect) { int64_t key = FillImageTable(temp_query, /*image_type=*/1, test_image, - /*is_template=*/true).LastInsertId(); + /*is_template=*/true) + .LastInsertId(); key = FillGlobalPropertiesTable( temp_query, "vrHelp", "menuTitle", 1, 1, 2, "auto", key) .LastInsertId(); @@ -894,7 +897,8 @@ TEST_F(ResumptionSqlQueriesTest, kSelectHMIId_ExpectDataCorrect) { int64_t key = FillImageTable(temp_query, /*image_type=*/1, test_image, - /*is_template=*/true).LastInsertId(); + /*is_template=*/true) + .LastInsertId(); key = FillGlobalPropertiesTable( temp_query, "vrHelp", "menuTitle", 1, 1, 2, "auto", key) .LastInsertId(); @@ -922,7 +926,8 @@ TEST_F(ResumptionSqlQueriesTest, kSelectCountHMIId_ExpectDataCorrect) { int64_t key = FillImageTable(temp_query, /*image_type=*/1, test_image, - /*is_template=*/true).LastInsertId(); + /*is_template=*/true) + .LastInsertId(); key = FillGlobalPropertiesTable( temp_query, "vrHelp", "menuTitle", 1, 1, 2, "auto", key) .LastInsertId(); @@ -951,7 +956,8 @@ TEST_F(ResumptionSqlQueriesTest, kCountHashId_ExpectDataCorrect) { int64_t key = FillImageTable(temp_query, /*image_type=*/1, test_image, - /*is_template=*/true).LastInsertId(); + /*is_template=*/true) + .LastInsertId(); key = FillGlobalPropertiesTable( temp_query, "vrHelp", "menuTitle", 1, 1, 2, "auto", key) .LastInsertId(); @@ -980,7 +986,8 @@ TEST_F(ResumptionSqlQueriesTest, kSelectHashId_ExpectDataCorrect) { int64_t key = FillImageTable(temp_query, /*image_type=*/1, test_image, - /*is_template=*/true).LastInsertId(); + /*is_template=*/true) + .LastInsertId(); key = FillGlobalPropertiesTable( temp_query, "vrHelp", "menuTitle", 1, 1, 2, "auto", key) .LastInsertId(); @@ -1017,7 +1024,8 @@ TEST_F(ResumptionSqlQueriesTest, kCheckApplication_ExpectDataCorrect) { int64_t key = FillImageTable(temp_query, /*image_type=*/1, test_image, - /*is_template=*/true).LastInsertId(); + /*is_template=*/true) + .LastInsertId(); key = FillGlobalPropertiesTable( temp_query, "vrHelp", "menuTitle", 1, 1, 2, "auto", key) .LastInsertId(); @@ -1045,7 +1053,8 @@ TEST_F(ResumptionSqlQueriesTest, kCountApplications_ExpectDataCorrect) { int64_t key = FillImageTable(temp_query, /*image_type=*/1, test_image, - /*is_template=*/true).LastInsertId(); + /*is_template=*/true) + .LastInsertId(); key = FillGlobalPropertiesTable( temp_query, "vrHelp", "menuTitle", 1, 1, 2, "auto", key) .LastInsertId(); @@ -1091,7 +1100,8 @@ TEST_F(ResumptionSqlQueriesTest, int64_t key = FillImageTable(temp_query, /*image_type=*/1, test_image, - /*is_template=*/true).LastInsertId(); + /*is_template=*/true) + .LastInsertId(); key = FillGlobalPropertiesTable( temp_query, "vrHelp", "menuTitle", 1, 1, 2, "auto", key) .LastInsertId(); @@ -1122,7 +1132,8 @@ TEST_F(ResumptionSqlQueriesTest, kUpdateHMILevel_ExpectDataUpdated) { int64_t key = FillImageTable(temp_query, /*image_type=*/1, test_image, - /*is_template=*/true).LastInsertId(); + /*is_template=*/true) + .LastInsertId(); key = FillGlobalPropertiesTable( temp_query, "vrHelp", "menuTitle", 1, 1, 2, "auto", key) .LastInsertId(); @@ -1158,7 +1169,8 @@ TEST_F(ResumptionSqlQueriesTest, kUpdateIgnOffCount_ExpectDataUpdated) { int64_t key = FillImageTable(temp_query, /*image_type=*/1, test_image, - /*is_template=*/true).LastInsertId(); + /*is_template=*/true) + .LastInsertId(); key = FillGlobalPropertiesTable( temp_query, "vrHelp", "menuTitle", 1, 1, 2, "auto", key) .LastInsertId(); @@ -1192,7 +1204,8 @@ TEST_F(ResumptionSqlQueriesTest, kCountApplicationsIgnOff_ExpectDataCorrect) { int64_t key = FillImageTable(temp_query, /*image_type=*/1, test_image, - /*is_template=*/true).LastInsertId(); + /*is_template=*/true) + .LastInsertId(); key = FillGlobalPropertiesTable( temp_query, "vrHelp", "menuTitle", 1, 1, 2, "auto", key) .LastInsertId(); @@ -1236,7 +1249,8 @@ TEST_F(ResumptionSqlQueriesTest, int64_t key = FillImageTable(temp_query, /*image_type=*/1, test_image, - /*is_template=*/true).LastInsertId(); + /*is_template=*/true) + .LastInsertId(); key = FillGlobalPropertiesTable( temp_query, "vrHelp", "menuTitle", 1, 1, 2, "auto", key) .LastInsertId(); @@ -1279,7 +1293,8 @@ TEST_F(ResumptionSqlQueriesTest, kUpdateSuspendData_ExpectDataUpdated) { int64_t key = FillImageTable(temp_query, /*image_type=*/1, test_image, - /*is_template=*/true).LastInsertId(); + /*is_template=*/true) + .LastInsertId(); key = FillGlobalPropertiesTable( temp_query, "vrHelp", "menuTitle", 1, 1, 2, "auto", key) .LastInsertId(); @@ -1311,7 +1326,8 @@ TEST_F(ResumptionSqlQueriesTest, kDeleteFile_ExpectDataDeleted) { int64_t key1 = FillImageTable(temp_query, /*image_type=*/1, test_image, - /*is_template=*/true).LastInsertId(); + /*is_template=*/true) + .LastInsertId(); key1 = FillGlobalPropertiesTable( temp_query, "vrHelp", "menuTitle", 1, 1, 2, "auto", key1) .LastInsertId(); @@ -1326,7 +1342,8 @@ TEST_F(ResumptionSqlQueriesTest, kDeleteFile_ExpectDataDeleted) { false, app_id2, device_id, - key1).LastInsertId(); + key1) + .LastInsertId(); int64_t key2 = FillFileTable(temp_query, 1, true, true, "tst_name").LastInsertId(); FillApplicationFilesArrayTable(temp_query, key1, key2); @@ -1344,7 +1361,8 @@ TEST_F(ResumptionSqlQueriesTest, int64_t key1 = FillImageTable(temp_query, /*image_type=*/1, test_image, - /*is_template=*/true).LastInsertId(); + /*is_template=*/true) + .LastInsertId(); key1 = FillGlobalPropertiesTable( temp_query, "vrHelp", "menuTitle", 1, 1, 2, "auto", key1) .LastInsertId(); @@ -1359,7 +1377,8 @@ TEST_F(ResumptionSqlQueriesTest, false, app_id2, device_id, - key1).LastInsertId(); + key1) + .LastInsertId(); int64_t key2 = FillFileTable(temp_query, 1, true, true, "tst_name").LastInsertId(); FillApplicationFilesArrayTable(temp_query, key1, key2); @@ -1383,7 +1402,8 @@ TEST_F(ResumptionSqlQueriesTest, kDeleteSubMenu_ExpectDataDeleted) { int64_t key = FillImageTable(temp_query, /*image_type=*/1, test_image, - /*is_template=*/true).LastInsertId(); + /*is_template=*/true) + .LastInsertId(); key = FillGlobalPropertiesTable( temp_query, "vrHelp", "menuTitle", 1, 1, 2, "auto", key) .LastInsertId(); @@ -1398,7 +1418,8 @@ TEST_F(ResumptionSqlQueriesTest, kDeleteSubMenu_ExpectDataDeleted) { false, app_id2, device_id, - key).LastInsertId(); + key) + .LastInsertId(); int64_t submenu_key = FillSubMenuTable(temp_query, 1, "tst_menuName", 2).LastInsertId(); @@ -1417,7 +1438,8 @@ TEST_F(ResumptionSqlQueriesTest, int64_t key = FillImageTable(temp_query, /*image_type=*/1, test_image, - /*is_template=*/true).LastInsertId(); + /*is_template=*/true) + .LastInsertId(); key = FillGlobalPropertiesTable( temp_query, "vrHelp", "menuTitle", 1, 1, 2, "auto", key) .LastInsertId(); @@ -1432,7 +1454,8 @@ TEST_F(ResumptionSqlQueriesTest, false, app_id2, device_id, - key).LastInsertId(); + key) + .LastInsertId(); int64_t submenu_key = FillSubMenuTable(temp_query, 1, "tst_menuName", 2).LastInsertId(); @@ -1454,7 +1477,8 @@ TEST_F(ResumptionSqlQueriesTest, int64_t key1 = FillImageTable(temp_query, /*image_type=*/1, test_image, - /*is_template=*/true).LastInsertId(); + /*is_template=*/true) + .LastInsertId(); key1 = FillGlobalPropertiesTable( temp_query, "vrHelp", "menuTitle", 1, 1, 2, "auto", key1) .LastInsertId(); @@ -1469,7 +1493,8 @@ TEST_F(ResumptionSqlQueriesTest, false, app_id2, device_id, - key1).LastInsertId(); + key1) + .LastInsertId(); int64_t key2 = FillFileTable(temp_query, 1, true, true, "tst_name").LastInsertId(); key1 = FillApplicationFilesArrayTable(temp_query, key1, key2).LastInsertId(); @@ -1494,7 +1519,8 @@ TEST_F(ResumptionSqlQueriesTest, kDeleteImageFromCommands_ExpectDataDeleted) { int64_t key1 = FillImageTable(temp_query, /*image_type=*/1, test_image, - /*is_template=*/true).LastInsertId(); + /*is_template=*/true) + .LastInsertId(); int64_t key2 = FillCommandTable(temp_query, 1, "tst_menu_name", 1, 2, key1) .LastInsertId(); key1 = FillGlobalPropertiesTable( @@ -1511,7 +1537,8 @@ TEST_F(ResumptionSqlQueriesTest, kDeleteImageFromCommands_ExpectDataDeleted) { false, app_id2, device_id, - key1).LastInsertId(); + key1) + .LastInsertId(); FillApplicationCommandsArrayTable(temp_query, key1, key2); // Check before action const std::string select_count_image = "SELECT COUNT(*) FROM image;"; @@ -1527,7 +1554,8 @@ TEST_F(ResumptionSqlQueriesTest, kDeleteVrCommands_ExpectDataDeleted) { int64_t key1 = FillImageTable(temp_query, /*image_type=*/1, test_image, - /*is_template=*/true).LastInsertId(); + /*is_template=*/true) + .LastInsertId(); int64_t key2 = FillCommandTable(temp_query, 1, "tst_menu_name", 1, 2, key1) .LastInsertId(); key1 = FillGlobalPropertiesTable( @@ -1544,7 +1572,8 @@ TEST_F(ResumptionSqlQueriesTest, kDeleteVrCommands_ExpectDataDeleted) { false, app_id2, device_id, - key1).LastInsertId(); + key1) + .LastInsertId(); FillVRCommandsArrayTable( temp_query, "tst_vr_command", kVRCommandFromCommand, key2); @@ -1564,7 +1593,8 @@ TEST_F(ResumptionSqlQueriesTest, kDeleteCommands_ExpectDataDeleted) { int64_t key1 = FillImageTable(temp_query, /*image_type=*/1, test_image, - /*is_template=*/true).LastInsertId(); + /*is_template=*/true) + .LastInsertId(); int64_t key2 = FillCommandTable(temp_query, 1, "tst_menu_name", 1, 2, key1) .LastInsertId(); @@ -1582,7 +1612,8 @@ TEST_F(ResumptionSqlQueriesTest, kDeleteCommands_ExpectDataDeleted) { false, app_id2, device_id, - key1).LastInsertId(); + key1) + .LastInsertId(); FillApplicationCommandsArrayTable(temp_query, key1, key2); // Check @@ -1599,7 +1630,8 @@ TEST_F(ResumptionSqlQueriesTest, int64_t key1 = FillImageTable(temp_query, /*image_type=*/1, test_image, - /*is_template=*/true).LastInsertId(); + /*is_template=*/true) + .LastInsertId(); int64_t key2 = FillCommandTable(temp_query, 1, "tst_menu_name", 1, 2, key1) .LastInsertId(); @@ -1617,7 +1649,8 @@ TEST_F(ResumptionSqlQueriesTest, false, app_id2, device_id, - key1).LastInsertId(); + key1) + .LastInsertId(); FillApplicationCommandsArrayTable(temp_query, key1, key2); // Check @@ -1640,13 +1673,15 @@ TEST_F(ResumptionSqlQueriesTest, kDeleteImageFromChoiceSet_ExpectDataDeleted) { int64_t key1 = FillImageTable(temp_query, /*image_type=*/1, test_image, - /*is_template=*/true).LastInsertId(); + /*is_template=*/true) + .LastInsertId(); int64_t key2 = FillChoiceTable(temp_query, 2, "tst_menu_name", "secondary_txt", "tst_tert_text", - key1).LastInsertId(); + key1) + .LastInsertId(); int64_t key3 = FillApplicationTable(temp_query, connection_key, grammarID, @@ -1658,7 +1693,8 @@ TEST_F(ResumptionSqlQueriesTest, kDeleteImageFromChoiceSet_ExpectDataDeleted) { false, app_id2, device_id, - key1).LastInsertId(); + key1) + .LastInsertId(); int64_t key4 = FillApplicationChoiceSetTable(temp_query, 1, 2).LastInsertId(); FillChoiceArrayTable(temp_query, key4, key2); FillApplicationChoiceSetArrayTable(temp_query, key4, key3); @@ -1678,7 +1714,8 @@ TEST_F(ResumptionSqlQueriesTest, int64_t key1 = FillImageTable(temp_query, /*image_type=*/1, test_image, - /*is_template=*/true).LastInsertId(); + /*is_template=*/true) + .LastInsertId(); int64_t key2 = FillChoiceTable( temp_query, 1, "tst_menu_name", "second_text", "tert_txt", key1) @@ -1694,7 +1731,8 @@ TEST_F(ResumptionSqlQueriesTest, false, app_id2, device_id, - key1).LastInsertId(); + key1) + .LastInsertId(); FillVRCommandsArrayTable( temp_query, "tst_vr_command", kVRCommandFromChoice, key2); @@ -1724,7 +1762,8 @@ TEST_F(ResumptionSqlQueriesTest, kDeleteChoice_ExpectDataDeleted) { int64_t key1 = FillImageTable(temp_query, /*image_type=*/1, test_image, - /*is_template=*/true).LastInsertId(); + /*is_template=*/true) + .LastInsertId(); int64_t key2 = FillChoiceTable( temp_query, 1, "tst_menu_name", "second_text", "tert_txt", key1) @@ -1740,7 +1779,8 @@ TEST_F(ResumptionSqlQueriesTest, kDeleteChoice_ExpectDataDeleted) { false, app_id2, device_id, - key1).LastInsertId(); + key1) + .LastInsertId(); int64_t key3 = FillApplicationChoiceSetTable(temp_query, 1, 2).LastInsertId(); FillChoiceArrayTable(temp_query, key3, key2); FillApplicationChoiceSetArrayTable(temp_query, key3, key1); @@ -1773,7 +1813,8 @@ TEST_F(ResumptionSqlQueriesTest, kDeleteChoiceArray_ExpectDataDeleted) { false, app_id2, device_id, - 1).LastInsertId(); + 1) + .LastInsertId(); FillApplicationChoiceSetArrayTable( temp_query, application_choiceset_table_key, application_table_key); FillChoiceArrayTable( @@ -1803,7 +1844,8 @@ TEST_F(ResumptionSqlQueriesTest, false, app_id2, device_id, - 1).LastInsertId(); + 1) + .LastInsertId(); int64_t key2 = FillApplicationChoiceSetTable(temp_query, 1, 2).LastInsertId(); FillApplicationChoiceSetArrayTable(temp_query, key2, key1); @@ -1838,7 +1880,8 @@ TEST_F(ResumptionSqlQueriesTest, false, app_id2, device_id, - 1).LastInsertId(); + 1) + .LastInsertId(); int64_t key2 = FillApplicationChoiceSetTable(temp_query, 1, 2).LastInsertId(); FillApplicationChoiceSetArrayTable(temp_query, key2, key1); @@ -1864,7 +1907,8 @@ TEST_F(ResumptionSqlQueriesTest, int64_t key1 = FillImageTable(temp_query, /*image_type=*/1, test_image, - /*is_template=*/true).LastInsertId(); + /*is_template=*/true) + .LastInsertId(); int64_t key2 = FillGlobalPropertiesTable( temp_query, "vrHelp", "menuTitle", 1, 1, 2, "auto", key1) .LastInsertId(); @@ -1896,7 +1940,8 @@ TEST_F(ResumptionSqlQueriesTest, kDeletevrHelpItem_ExpectDataDeleted) { int64_t key1 = FillImageTable(temp_query, /*image_type=*/1, test_image, - /*is_template=*/true).LastInsertId(); + /*is_template=*/true) + .LastInsertId(); int64_t key2 = FillGlobalPropertiesTable( temp_query, "vrHelp", "menuTitle", 1, 1, 2, "auto", key1) .LastInsertId(); @@ -1929,7 +1974,8 @@ TEST_F(ResumptionSqlQueriesTest, kDeletevrHelpItemArray_ExpectDataDeleted) { int64_t key1 = FillImageTable(temp_query, /*image_type=*/1, test_image, - /*is_template=*/true).LastInsertId(); + /*is_template=*/true) + .LastInsertId(); int64_t key2 = FillGlobalPropertiesTable( temp_query, "vrHelp", "menuTitle", 1, 1, 2, "auto", key1) .LastInsertId(); @@ -1963,9 +2009,9 @@ TEST_F(ResumptionSqlQueriesTest, string character_list = "abcdefghij"; int64_t key1 = FillTableLimitedCharacterListTable(temp_query, character_list) .LastInsertId(); - int64_t key2 = - FillGlobalPropertiesTable( - temp_query, "vrHelp", "menuTitle", 1, 1, 2, "auto", 0).LastInsertId(); + int64_t key2 = FillGlobalPropertiesTable( + temp_query, "vrHelp", "menuTitle", 1, 1, 2, "auto", 0) + .LastInsertId(); FillApplicationTable(temp_query, connection_key, grammarID, @@ -1999,9 +2045,9 @@ TEST_F(ResumptionSqlQueriesTest, kDeleteCharacterArray_ExpectDataDeleted) { string character_list = "abcdefghij"; int64_t key1 = FillTableLimitedCharacterListTable(temp_query, character_list) .LastInsertId(); - int64_t key2 = - FillGlobalPropertiesTable( - temp_query, "vrHelp", "menuTitle", 1, 1, 2, "auto", 0).LastInsertId(); + int64_t key2 = FillGlobalPropertiesTable( + temp_query, "vrHelp", "menuTitle", 1, 1, 2, "auto", 0) + .LastInsertId(); FillApplicationTable(temp_query, connection_key, grammarID, @@ -2031,7 +2077,8 @@ TEST_F(ResumptionSqlQueriesTest, kDeleteTTSChunk_ExpectDataDeleted) { FillTTSChunkTable(temp_query, 1, "tst_text").LastInsertId(); int64_t glob_prop_key = FillGlobalPropertiesTable( - temp_query, "vrHelp", "menuTitle", 1, 1, 2, "auto", 0).LastInsertId(); + temp_query, "vrHelp", "menuTitle", 1, 1, 2, "auto", 0) + .LastInsertId(); FillApplicationTable(temp_query, connection_key, @@ -2087,7 +2134,8 @@ TEST_F(ResumptionSqlQueriesTest, FillTTSChunkTable(temp_query, 1, "tst_text").LastInsertId(); int64_t glob_prop_key = FillGlobalPropertiesTable( - temp_query, "vrHelp", "menuTitle", 1, 1, 2, "auto", 0).LastInsertId(); + temp_query, "vrHelp", "menuTitle", 1, 1, 2, "auto", 0) + .LastInsertId(); FillApplicationTable(temp_query, connection_key, grammarID, @@ -2121,7 +2169,8 @@ TEST_F(ResumptionSqlQueriesTest, kDeleteGlobalProperties_ExpectDataDeleted) { SQLQuery temp_query(db()); int64_t glob_prop_key = FillGlobalPropertiesTable( - temp_query, "vrHelp", "menuTitle", 1, 1, 2, "auto", 0).LastInsertId(); + temp_query, "vrHelp", "menuTitle", 1, 1, 2, "auto", 0) + .LastInsertId(); FillApplicationTable(temp_query, connection_key, grammarID, @@ -2160,7 +2209,8 @@ TEST_F(ResumptionSqlQueriesTest, kSelectPrimaryKeyImage_ExpectDataCorrect) { int64_t image_key = FillImageTable(temp_query, /*image_type=*/2, "tst_image", - /*is_template=*/true).LastInsertId(); + /*is_template=*/true) + .LastInsertId(); ValToPosPair p1(0, "tst_image"); ValToPosPair p2(1, ""); // Check @@ -2588,7 +2638,8 @@ TEST_F(ResumptionSqlQueriesTest, kSelectCountFiles_ExpectDataCorrect) { false, app_id1, device_id, - 9).LastInsertId(); + 9) + .LastInsertId(); int64_t file_key = FillFileTable(temp_query, 1, true, true, "tst_name").LastInsertId(); FillApplicationFilesArrayTable(temp_query, app_key, file_key); @@ -2613,7 +2664,8 @@ TEST_F(ResumptionSqlQueriesTest, kSelectFiles_ExpectDataCorrect) { false, app_id1, device_id, - 9).LastInsertId(); + 9) + .LastInsertId(); int64_t file_key = FillFileTable(temp_query, 1, true, true, "tst_name").LastInsertId(); FillApplicationFilesArrayTable(temp_query, app_key, file_key); @@ -2640,7 +2692,8 @@ TEST_F(ResumptionSqlQueriesTest, kSelectCountSubMenu_ExpectDataCorrect) { false, app_id1, device_id, - 9).LastInsertId(); + 9) + .LastInsertId(); int64_t submenu_key = FillSubMenuTable(temp_query, 1, "menu_name", 1).LastInsertId(); FillApplicationSubMenuArrayTable(temp_query, app_key, submenu_key); @@ -2664,7 +2717,8 @@ TEST_F(ResumptionSqlQueriesTest, kSelectSubMenu_ExpectDataCorrect) { false, app_id1, device_id, - 9).LastInsertId(); + 9) + .LastInsertId(); int64_t submenu_key = FillSubMenuTable(temp_query, 1, "menu_name", 1).LastInsertId(); @@ -2691,7 +2745,8 @@ TEST_F(ResumptionSqlQueriesTest, kSelectCountCommands_ExpectDataCorrect) { false, app_id1, device_id, - 9).LastInsertId(); + 9) + .LastInsertId(); int64_t command_key = FillCommandTable(temp_query, 1, "menu_name", 1, 2, 5).LastInsertId(); FillApplicationCommandsArrayTable(temp_query, app_key, command_key); @@ -2715,11 +2770,13 @@ TEST_F(ResumptionSqlQueriesTest, kSelectCommandsFromCommand_ExpectDataCorrect) { false, app_id1, device_id, - 9).LastInsertId(); + 9) + .LastInsertId(); int64_t image_key = FillImageTable(temp_query, /*image_type=*/2, "tst_image", - /*is_template=*/true).LastInsertId(); + /*is_template=*/true) + .LastInsertId(); FillChoiceTable( temp_query, 1, "menu_name", "sec_text", "tert_text", image_key) @@ -2758,11 +2815,13 @@ TEST_F(ResumptionSqlQueriesTest, kSelectCommandsFromChoice_ExpectDataCorrect) { false, app_id1, device_id, - 9).LastInsertId(); + 9) + .LastInsertId(); int64_t image_key = FillImageTable(temp_query, /*image_type=*/2, "tst_image", - /*is_template=*/true).LastInsertId(); + /*is_template=*/true) + .LastInsertId(); int64_t choice_key = FillChoiceTable( @@ -2814,7 +2873,8 @@ TEST_F(ResumptionSqlQueriesTest, kSelectCountSubscriptions_ExpectDataCorrect) { false, app_id1, device_id, - 9).LastInsertId(); + 9) + .LastInsertId(); FillAppSubscriptionsArrayTable(temp_query, 2, 3, app_key); ValToPosPair p1(0, app_id1); ValToPosPair p2(1, device_id); @@ -2836,7 +2896,8 @@ TEST_F(ResumptionSqlQueriesTest, kSelectSubscriptions_ExpectDataCorrect) { false, app_id1, device_id, - 9).LastInsertId(); + 9) + .LastInsertId(); FillAppSubscriptionsArrayTable(temp_query, 2, 3, app_key); ValToPosPair p1(0, app_id1); ValToPosPair p2(1, device_id); @@ -2859,7 +2920,8 @@ TEST_F(ResumptionSqlQueriesTest, kSelectCountChoiceSet_ExpectDataCorrect) { false, app_id1, device_id, - 9).LastInsertId(); + 9) + .LastInsertId(); FillApplicationChoiceSetArrayTable(temp_query, 2, app_key); ValToPosPair p1(0, app_id1); ValToPosPair p2(1, device_id); @@ -2881,11 +2943,13 @@ TEST_F(ResumptionSqlQueriesTest, kSelectChoiceSets_ExpectDataCorrect) { false, app_id1, device_id, - 9).LastInsertId(); + 9) + .LastInsertId(); int64_t image_key = FillImageTable(temp_query, /*image_type=*/2, "tst_image", - /*is_template=*/true).LastInsertId(); + /*is_template=*/true) + .LastInsertId(); int64_t choice_key = FillChoiceTable( temp_query, 1, "menu_name", "sec_text", "tert_text", image_key) @@ -2920,7 +2984,8 @@ TEST_F(ResumptionSqlQueriesTest, kSelectImage_ExpectDataCorrect) { int64_t image_key = FillImageTable(temp_query, /*image_type=*/2, "tst_image", - /*is_template=*/true).LastInsertId(); + /*is_template=*/true) + .LastInsertId(); // Check ValToPosPair p1(0, IntToString(image_key)); ValToPosPair p2(1, ""); @@ -2947,7 +3012,8 @@ TEST_F(ResumptionSqlQueriesTest, false, app_id1, device_id, - glob_prop_key).LastInsertId(); + glob_prop_key) + .LastInsertId(); // Check ValToPosPair p1(0, app_id1); @@ -2961,7 +3027,8 @@ TEST_F(ResumptionSqlQueriesTest, kSelectGlobalProperties_ExpectDataCorrect) { int64_t image_key = FillImageTable(temp_query, /*image_type=*/2, test_image, - /*is_template=*/true).LastInsertId(); + /*is_template=*/true) + .LastInsertId(); int64_t glob_prop_key = FillGlobalPropertiesTable( temp_query, "tst_vr_title", "tst_menu", 2, 3, 3, "auto", image_key) @@ -2977,7 +3044,8 @@ TEST_F(ResumptionSqlQueriesTest, kSelectGlobalProperties_ExpectDataCorrect) { false, app_id1, device_id, - glob_prop_key).LastInsertId(); + glob_prop_key) + .LastInsertId(); FillHelpTimeoutPromptArrayTable(temp_query, glob_prop_key, 3, 7); // Check @@ -3001,7 +3069,8 @@ TEST_F(ResumptionSqlQueriesTest, kChecksVrHelpItem_ExpectDataCorrect) { int64_t image_key = FillImageTable(temp_query, /*image_type=*/2, "tst_image", - /*is_template=*/true).LastInsertId(); + /*is_template=*/true) + .LastInsertId(); int64_t glob_prop_key = FillGlobalPropertiesTable( temp_query, "tst_vr_title", "tst_menu", 2, 3, 3, "auto", image_key) @@ -3021,7 +3090,8 @@ TEST_F(ResumptionSqlQueriesTest, kSelectVrHelpItem_ExpectDataCorrect) { int64_t image_key = FillImageTable(temp_query, /*image_type=*/2, "tst_image", - /*is_template=*/true).LastInsertId(); + /*is_template=*/true) + .LastInsertId(); int64_t glob_prop_key = FillGlobalPropertiesTable( temp_query, "tst_vr_title", "tst_menu", 2, 3, 3, "auto", image_key) @@ -3046,8 +3116,9 @@ TEST_F(ResumptionSqlQueriesTest, kChecksCharacter_ExpectDataCorrect) { temp_query, "tst_vr_title", "tst_menu", 2, 3, 3, "auto", 2) .LastInsertId(); string character_list = "abcdefghijkl"; - int64_t lim_char_list_key = FillTableLimitedCharacterListTable( - temp_query, character_list).LastInsertId(); + int64_t lim_char_list_key = + FillTableLimitedCharacterListTable(temp_query, character_list) + .LastInsertId(); FillCharacterArrayTable(temp_query, glob_prop_key, lim_char_list_key); // Check ValToPosPair p1(0, IntToString(glob_prop_key)); @@ -3063,8 +3134,9 @@ TEST_F(ResumptionSqlQueriesTest, kSelectCharacter_ExpectDataCorrect) { temp_query, "tst_vr_title", "tst_menu", 2, 3, 3, "auto", 2) .LastInsertId(); string character_list = "abcdefghijkl"; - int64_t lim_char_list_key = FillTableLimitedCharacterListTable( - temp_query, character_list).LastInsertId(); + int64_t lim_char_list_key = + FillTableLimitedCharacterListTable(temp_query, character_list) + .LastInsertId(); FillCharacterArrayTable(temp_query, glob_prop_key, lim_char_list_key); // Check ValToPosPair p1(0, IntToString(glob_prop_key)); diff --git a/src/components/application_manager/test/rpc_passing_handler_test.cc b/src/components/application_manager/test/rpc_passing_handler_test.cc new file mode 100644 index 00000000000..fb74a0a7e3f --- /dev/null +++ b/src/components/application_manager/test/rpc_passing_handler_test.cc @@ -0,0 +1,440 @@ +/* + * Copyright (c) 2019, 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 "gtest/gtest.h" + +#include "application_manager/rpc_passing_handler.h" + +#include "application_manager/mock_app_service_manager.h" +#include "application_manager/mock_application.h" +#include "application_manager/mock_application_manager.h" +#include "application_manager/mock_application_manager_settings.h" +#include "application_manager/mock_rpc_handler.h" +#include "application_manager/mock_rpc_service.h" +#include "resumption/mock_last_state.h" + +#include +#include "application_manager/smart_object_keys.h" +#include "smart_objects/smart_object.h" +#include "utils/semantic_version.h" +#include "utils/test_async_waiter.h" + +namespace test { +namespace components { +namespace application_manager_test { + +namespace am = application_manager; +using ::testing::_; +using ::testing::DoAll; +using ::testing::InSequence; +using ::testing::Mock; +using ::testing::NiceMock; +using ::testing::Pointee; +using ::testing::Return; +using ::testing::ReturnRef; + +struct PassthroughParams { + const uint32_t connection_key; + const int32_t correlation_id; + smart_objects::SmartObject message; + smart_objects::SmartObject forwarded_message; +}; + +class RPCPassingHandlerTest : public ::testing::Test { + public: + RPCPassingHandlerTest() + : mock_app_service_manager_(mock_app_manager_, mock_last_state_) + , mock_app_ptr_(std::make_shared >()) + , version_(utils::SemanticVersion(5, 1, 0)) {} + + ~RPCPassingHandlerTest() {} + + void SetUp() OVERRIDE { + rpc_passing_handler_ = + new am::RPCPassingHandler(mock_app_service_manager_, mock_app_manager_); + app_services_.clear(); + + ON_CALL(mock_app_manager_, IncreaseForwardedRequestTimeout(_, _)) + .WillByDefault(Return()); + ON_CALL(mock_app_manager_, get_settings()) + .WillByDefault(ReturnRef(mock_app_manager_settings_)); + + ON_CALL(mock_app_manager_settings_, rpc_pass_through_timeout()) + .WillByDefault(Return(kRPCPassthroughTimeout)); + + ON_CALL(mock_app_manager_, GetRPCService()) + .WillByDefault(ReturnRef(mock_rpc_service_)); + ON_CALL(mock_rpc_service_, ManageMobileCommand(_, _)) + .WillByDefault(Return(true)); + ON_CALL(mock_rpc_service_, SendMessageToMobile(_, _)) + .WillByDefault(Return()); + + ON_CALL(mock_app_manager_, GetAppServiceManager()) + .WillByDefault(ReturnRef(mock_app_service_manager_)); + ON_CALL(mock_app_service_manager_, GetActiveServices()) + .WillByDefault(Return(app_services_)); + + ON_CALL(mock_app_manager_, GetRPCHandler()) + .WillByDefault(ReturnRef(mock_rpc_handler_)); + ON_CALL(mock_rpc_handler_, ValidateRpcSO(_, _, _, _)) + .WillByDefault(Return(true)); + + ON_CALL(mock_app_manager_, application(_)) + .WillByDefault(Return(mock_app_ptr_)); + ON_CALL(*mock_app_ptr_, msg_version()).WillByDefault(ReturnRef(version_)); + } + + void TearDown() OVERRIDE { + delete rpc_passing_handler_; + rpc_passing_handler_ = NULL; + } + + protected: + am::AppService CreateAppService(uint32_t connection_key, + const std::string& service_id, + const std::string& service_type) { + am::AppService app_service; + + app_service.connection_key = connection_key; + app_service.mobile_service = true; + app_service.default_service = false; + + smart_objects::SmartObject record(smart_objects::SmartType::SmartType_Map); + record[am::strings::service_id] = service_id; + record[am::strings::service_manifest][am::strings::service_type] = + service_type; + record[am::strings::service_manifest][am::strings::allow_app_consumers] = + true; + record[am::strings::service_manifest][am::strings::handled_rpcs] = + smart_objects::SmartObject(smart_objects::SmartType::SmartType_Array); + record[am::strings::service_manifest][am::strings::handled_rpcs][0] = + mobile_apis::FunctionID::SendLocationID; + record[am::strings::service_published] = true; + record[am::strings::service_active] = true; + app_service.record = record; + + return app_service; + } + + smart_objects::SmartObject CreatePassThroughRequest(uint32_t connection_key, + int32_t correlation_id) { + smart_objects::SmartObject record(smart_objects::SmartType::SmartType_Map); + record[am::strings::params][am::strings::connection_key] = connection_key; + record[am::strings::params][am::strings::correlation_id] = correlation_id; + record[am::strings::params][am::strings::function_id] = + mobile_apis::FunctionID::SendLocationID; + record[am::strings::params][am::strings::message_type] = + am::MessageType::kRequest; + record[am::strings::msg_params][am::strings::latitude_degrees] = 50; + record[am::strings::msg_params][am::strings::longitude_degrees] = 50; + record[am::strings::msg_params][am::strings::location_name] = + "TestLocation"; + + return record; + } + + smart_objects::SmartObject CreatePassThroughResponse( + uint32_t connection_key, + int32_t correlation_id, + const std::string& result_code, + bool success, + std::string info = std::string()) { + smart_objects::SmartObject record(smart_objects::SmartType::SmartType_Map); + record[am::strings::params][am::strings::connection_key] = connection_key; + record[am::strings::params][am::strings::correlation_id] = correlation_id; + record[am::strings::params][am::strings::function_id] = + mobile_apis::FunctionID::SendLocationID; + record[am::strings::params][am::strings::message_type] = + am::MessageType::kResponse; + record[am::strings::msg_params][am::strings::result_code] = result_code; + record[am::strings::msg_params][am::strings::success] = success; + record[am::strings::msg_params][am::strings::info] = info; + + return record; + } + + void SendRequestToASP(const PassthroughParams& params, uint32_t timeout = 0) { + if (timeout == 0) { + // If timeout argument is not sepcified + timeout = kRPCPassthroughTimeout; + } + + // Call RPCPassThrough with request smart object + + // Will call PopulateRPCRequestQueue + EXPECT_CALL(mock_app_service_manager_, GetActiveServices()) + .WillOnce(Return(app_services_)); + + // Will call ForwardRequesttoMobile + EXPECT_CALL(mock_app_manager_settings_, rpc_pass_through_timeout()) + .WillOnce(Return(timeout)); + EXPECT_CALL(mock_app_manager_, GetRPCService()); + EXPECT_CALL(mock_rpc_service_, + SendMessageToMobile(Pointee(params.forwarded_message), false)); + + bool mobile_result = rpc_passing_handler_->RPCPassThrough(params.message); + EXPECT_EQ(mobile_result, true); + } + + NiceMock mock_app_manager_; + NiceMock mock_app_manager_settings_; + MockRPCService mock_rpc_service_; + MockRPCHandler mock_rpc_handler_; + resumption_test::MockLastState mock_last_state_; + MockAppServiceManager mock_app_service_manager_; + std::shared_ptr > mock_app_ptr_; + const utils::SemanticVersion version_; + am::RPCPassingHandler* rpc_passing_handler_; + std::vector app_services_; + + uint32_t kRPCPassthroughTimeout = 10000; + uint32_t kConnectionKey_ASC = 1; + uint32_t kConnectionKey_NAV_ASP = 2; + uint32_t kConnectionKey_MEDIA_ASP = 3; + int32_t kCorrelationId = 1; + const uint32_t MAX_TEST_DURATION = 1000; // 1 second +}; + +TEST_F(RPCPassingHandlerTest, RPCPassingTest_REQUEST_ForwardToMobile) { + app_services_.push_back(CreateAppService( + kConnectionKey_NAV_ASP, "Navigation service", "NAVIGATION")); + + PassthroughParams request_params{ + .connection_key = kConnectionKey_ASC, + .correlation_id = kCorrelationId, + .message = CreatePassThroughRequest(kConnectionKey_ASC, kCorrelationId), + .forwarded_message = + CreatePassThroughRequest(kConnectionKey_NAV_ASP, kCorrelationId), + }; + + SendRequestToASP(request_params); +} + +TEST_F(RPCPassingHandlerTest, RPCPassingTest_REQUEST_NoPassthrough) { + smart_objects::SmartObject request = + CreatePassThroughRequest(kConnectionKey_ASC, kCorrelationId); + + // Call RPCPassThrough with request smart object + + // Will call PopulateRPCRequestQueue + EXPECT_CALL(mock_app_service_manager_, GetActiveServices()) + .WillOnce(Return(app_services_)); + EXPECT_CALL( + mock_app_manager_, + IncreaseForwardedRequestTimeout(kConnectionKey_ASC, kCorrelationId)) + .Times(0); + // Will return false since there are no active services to handle the rpc + EXPECT_CALL(mock_rpc_service_, ManageMobileCommand(_, _)).Times(0); + EXPECT_CALL(mock_rpc_service_, SendMessageToMobile(_, _)).Times(0); + + bool result = rpc_passing_handler_->RPCPassThrough(request); + EXPECT_EQ(result, false); +} + +TEST_F(RPCPassingHandlerTest, RPCPassingTest_RESPONSE_UnknownCorrelationID) { + smart_objects::SmartObject invalid_response = CreatePassThroughResponse( + kConnectionKey_NAV_ASP, kCorrelationId + 1, "SUCCESS", true); + + app_services_.push_back(CreateAppService( + kConnectionKey_NAV_ASP, "Navigation service", "NAVIGATION")); + + PassthroughParams request_params{ + .connection_key = kConnectionKey_ASC, + .correlation_id = kCorrelationId, + .message = CreatePassThroughRequest(kConnectionKey_ASC, kCorrelationId), + .forwarded_message = + CreatePassThroughRequest(kConnectionKey_NAV_ASP, kCorrelationId), + }; + + SendRequestToASP(request_params); + + // Call RPCPassThrough with response smart object + // Will return false since the correlation id does not exist in the map + EXPECT_CALL(mock_rpc_service_, ManageMobileCommand(_, _)).Times(0); + EXPECT_CALL(mock_rpc_service_, SendMessageToMobile(_, _)).Times(0); + + bool result = rpc_passing_handler_->RPCPassThrough(invalid_response); + EXPECT_EQ(result, false); +} + +TEST_F(RPCPassingHandlerTest, RPCPassingTest_SUCCESS) { + smart_objects::SmartObject response = CreatePassThroughResponse( + kConnectionKey_NAV_ASP, kCorrelationId, "SUCCESS", true); + smart_objects::SmartObject forwarded_response = CreatePassThroughResponse( + kConnectionKey_ASC, kCorrelationId, "SUCCESS", true); + + app_services_.push_back(CreateAppService( + kConnectionKey_NAV_ASP, "Navigation service", "NAVIGATION")); + + PassthroughParams request_params{ + .connection_key = kConnectionKey_ASC, + .correlation_id = kCorrelationId, + .message = CreatePassThroughRequest(kConnectionKey_ASC, kCorrelationId), + .forwarded_message = + CreatePassThroughRequest(kConnectionKey_NAV_ASP, kCorrelationId), + }; + + SendRequestToASP(request_params); + + // Call RPCPassThrough with response smart object + // Will ForwardResponseToMobile + EXPECT_CALL(mock_app_manager_, GetRPCService()); + EXPECT_CALL(mock_rpc_service_, + SendMessageToMobile(Pointee(forwarded_response), false)); + + bool result = rpc_passing_handler_->RPCPassThrough(response); + EXPECT_EQ(result, true); +} + +TEST_F(RPCPassingHandlerTest, + RPCPassingTest_UNSUPPORTED_REQUEST_ForwardToCore) { + smart_objects::SmartObject unsupported_response = CreatePassThroughResponse( + kConnectionKey_NAV_ASP, kCorrelationId, "UNSUPPORTED_REQUEST", false); + smart_objects::SmartObject forwarded_request = + CreatePassThroughRequest(kConnectionKey_ASC, kCorrelationId); + + app_services_.push_back(CreateAppService( + kConnectionKey_NAV_ASP, "Navigation service", "NAVIGATION")); + + PassthroughParams request_params{ + .connection_key = kConnectionKey_ASC, + .correlation_id = kCorrelationId, + .message = CreatePassThroughRequest(kConnectionKey_ASC, kCorrelationId), + .forwarded_message = + CreatePassThroughRequest(kConnectionKey_NAV_ASP, kCorrelationId), + }; + + SendRequestToASP(request_params); + + // Call RPCPassThrough with response smart object + // Will cycle to core (no other app services in list) + EXPECT_CALL(mock_app_manager_, GetRPCHandler()); + EXPECT_CALL(mock_rpc_handler_, ValidateRpcSO(forwarded_request, _, _, false)) + .WillOnce(Return(true)); + EXPECT_CALL(mock_app_manager_, GetRPCService()); + EXPECT_CALL(mock_rpc_service_, + ManageMobileCommand(Pointee(forwarded_request), + am::commands::Command::SOURCE_MOBILE)); + + bool result = rpc_passing_handler_->RPCPassThrough(unsupported_response); + EXPECT_EQ(result, true); +} + +TEST_F(RPCPassingHandlerTest, + RPCPassingTest_UNSUPPORTED_REQUEST_ForwardToMobile) { + smart_objects::SmartObject unsupported_response = CreatePassThroughResponse( + kConnectionKey_NAV_ASP, kCorrelationId, "UNSUPPORTED_REQUEST", false); + smart_objects::SmartObject forwarded_request = + CreatePassThroughRequest(kConnectionKey_MEDIA_ASP, kCorrelationId); + + app_services_.push_back(CreateAppService( + kConnectionKey_NAV_ASP, "Navigation service", "NAVIGATION")); + app_services_.push_back( + CreateAppService(kConnectionKey_MEDIA_ASP, "Media service", "MEDIA")); + + PassthroughParams request_params{ + .connection_key = kConnectionKey_ASC, + .correlation_id = kCorrelationId, + .message = CreatePassThroughRequest(kConnectionKey_ASC, kCorrelationId), + .forwarded_message = + CreatePassThroughRequest(kConnectionKey_NAV_ASP, kCorrelationId), + }; + + SendRequestToASP(request_params); + + // Call RPCPassThrough with response smart object + // Will cycle to next compatible active app service + EXPECT_CALL(mock_app_manager_settings_, rpc_pass_through_timeout()); + EXPECT_CALL(mock_app_manager_, GetRPCService()); + EXPECT_CALL(mock_rpc_service_, + SendMessageToMobile(Pointee(forwarded_request), false)); + + bool result = rpc_passing_handler_->RPCPassThrough(unsupported_response); + EXPECT_EQ(result, true); +} + +TEST_F(RPCPassingHandlerTest, RPCPassingTest_REQUEST_Timeout) { + uint32_t timeout_in_ms = 4; + std::shared_ptr waiter = std::make_shared(); + + app_services_.push_back(CreateAppService( + kConnectionKey_NAV_ASP, "Navigation service", "NAVIGATION")); + + PassthroughParams request_params{ + .connection_key = kConnectionKey_ASC, + .correlation_id = kCorrelationId, + .message = CreatePassThroughRequest(kConnectionKey_ASC, kCorrelationId), + .forwarded_message = + CreatePassThroughRequest(kConnectionKey_NAV_ASP, kCorrelationId), + }; + + // Call RPCPassThrough with request smart object + + // Will call PopulateRPCRequestQueue + EXPECT_CALL(mock_app_service_manager_, GetActiveServices()) + .WillOnce(Return(app_services_)); + + // Will call ForwardRequesttoMobile + EXPECT_CALL(mock_app_manager_settings_, rpc_pass_through_timeout()) + .WillOnce(Return(timeout_in_ms)); + EXPECT_CALL( + mock_rpc_service_, + SendMessageToMobile(Pointee(request_params.forwarded_message), false)); + + // Request timeout will trigger perform next request + // Will cycle to core (no other app services in list) + EXPECT_CALL(mock_app_manager_, GetRPCHandler()); + EXPECT_CALL(mock_rpc_handler_, + ValidateRpcSO(request_params.message, _, _, false)) + .WillOnce(Return(true)); + EXPECT_CALL(mock_app_manager_, GetRPCService()).Times(2); + EXPECT_CALL(mock_rpc_service_, + ManageMobileCommand(Pointee(request_params.message), + am::commands::Command::SOURCE_MOBILE)) + .WillOnce(DoAll(NotifyTestAsyncWaiter(waiter), Return(true))); + + bool mobile_result = + rpc_passing_handler_->RPCPassThrough(request_params.message); + EXPECT_EQ(mobile_result, true); + + const uint32_t wait_time = MAX_TEST_DURATION + timeout_in_ms; + EXPECT_TRUE(waiter->WaitFor(1, wait_time)); + + // This sleep prevents a SEGFAULT which occurs after the + // RPCPassingHandlerTests are completed and the next test set runs + usleep(6000); // sleep 6 ms +} + +} // namespace application_manager_test +} // namespace components +} // namespace test 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 9574f8d00f4..9799dbcac20 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 @@ -30,55 +30,60 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include "gtest/gtest.h" +#include "application_manager/application_manager_impl.h" #include "application_manager/hmi_state.h" +#include "application_manager/mock_application.h" #include "application_manager/state_controller_impl.h" #include "application_manager/usage_statistics.h" -#include "application_manager/application_manager_impl.h" -#include "application_manager/mock_application.h" -#include "connection_handler/mock_connection_handler_settings.h" #include "connection_handler/connection_handler_impl.h" +#include "connection_handler/mock_connection_handler_settings.h" +#include "gtest/gtest.h" #include "transport_manager/mock_transport_manager.h" -#include "utils/lock.h" #include "utils/data_accessor.h" +#include "utils/lock.h" -#include "application_manager/message_helper.h" #include "application_manager/event_engine/event.h" -#include "application_manager/smart_object_keys.h" +#include "application_manager/message_helper.h" +#include "application_manager/mock_application_manager.h" +#include "application_manager/mock_event_dispatcher.h" #include "application_manager/mock_message_helper.h" +#include "application_manager/mock_rpc_service.h" +#include "application_manager/policies/mock_policy_handler_interface.h" +#include "application_manager/resumption/resume_ctrl.h" +#include "application_manager/smart_object_keys.h" +#include "connection_handler/mock_connection_handler.h" #include "policy/mock_policy_settings.h" #include "policy/usage_statistics/mock_statistics_manager.h" #include "protocol_handler/mock_session_observer.h" -#include "connection_handler/mock_connection_handler.h" -#include "application_manager/policies/mock_policy_handler_interface.h" -#include "application_manager/mock_event_dispatcher.h" -#include "application_manager/resumption/resume_ctrl.h" -#include "application_manager/mock_application_manager.h" -#include "application_manager/mock_rpc_service.h" namespace am = application_manager; using am::HmiState; using am::HmiStatePtr; using am::UsageStatistics; using ::testing::_; +using ::testing::AtLeast; +using ::testing::InSequence; +using ::testing::Mock; +using ::testing::NiceMock; using ::testing::Return; -using ::testing::ReturnRef; using ::testing::ReturnPointee; +using ::testing::ReturnRef; using ::testing::SaveArg; -using ::testing::Mock; -using ::testing::NiceMock; -using ::testing::InSequence; using ::testing::Truly; -using ::testing::AtLeast; + +using application_manager::MockMessageHelper; namespace test { namespace components { namespace state_controller_test { -namespace constants { +namespace { const uint32_t kCorrID = 314u; const uint32_t kHMIAppID = 2718u; -} // namespace constants +const am::WindowID kDefaultWindowId = + mobile_apis::PredefinedWindows::DEFAULT_WINDOW; +const am::WindowID kCustomWindowId = 2; +} // namespace struct HmiStatesComparator { mobile_apis::HMILevel::eType hmi_level_; @@ -151,7 +156,6 @@ class StateControllerImplTest : public ::testing::Test { ~StateControllerImplTest() { Mock::VerifyAndClearExpectations(&message_helper_mock_); } - NiceMock app_manager_mock_; NiceMock mock_rpc_service_; NiceMock policy_interface_; @@ -213,7 +217,11 @@ class StateControllerImplTest : public ::testing::Test { std::vector invalid_states_for_not_audio_app; std::vector invalid_states_for_audio_app; std::vector valid_state_ids_; - std::vector applications_list_; + + typedef std::map*> + AppPtrMockMapping; + AppPtrMockMapping applications_list_; connection_handler_test::MockConnectionHandlerSettings mock_connection_handler__settings; @@ -554,21 +562,26 @@ class StateControllerImplTest : public ::testing::Test { // application properties, i.e. is_media_application flag from RAI and // AppHmiTypes (NAVIGATION, etc.). Most likely logic should be changed // after conclusion on APPLINK-20231 - std::vector::iterator app = std::find_if( - applications_list_.begin(), - applications_list_.end(), - [app_id](am::ApplicationSharedPtr a) { return app_id == a->app_id(); }); - - if (app == applications_list_.end()) { + AppPtrMockMapping::iterator it = + std::find_if(applications_list_.begin(), + applications_list_.end(), + [app_id](AppPtrMockMapping::value_type& item) { + return app_id == item.first->app_id(); + }); + + if (applications_list_.end() == it) { return APP_TYPE_NON_MEDIA; } - if ((*app)->is_navi()) { + auto app = it->first; + if (app->is_navi()) { return APP_TYPE_NAVI; } - if ((*app)->is_media_application()) { + + if (app->is_media_application()) { return APP_TYPE_MEDIA; } + return APP_TYPE_NON_MEDIA; } @@ -644,17 +657,16 @@ class StateControllerImplTest : public ::testing::Test { template void TestMixState(void (StateControllerImplTest::*call_back_result)( std::vector&, ApplicationType)) { - std::vector::iterator it_begin = - applications_list_.begin(); - std::vector::iterator it_end = - applications_list_.end(); + AppPtrMockMapping::iterator it_begin = applications_list_.begin(); + AppPtrMockMapping::iterator it_end = applications_list_.end(); ApplicationType app_type; uint32_t app_id; am::ApplicationSharedPtr app; + for (; it_begin != it_end; ++it_begin) { - app_id = (*it_begin)->app_id(); + app_id = it_begin->first->app_id(); app_type = AppType(app_id); - app = (*it_begin); + app = it_begin->first; am::HmiStatePtr state_first = std::make_shared(app, app_manager_mock_); am::HmiStatePtr state_second = std::make_shared(app, app_manager_mock_); @@ -925,14 +937,14 @@ class StateControllerImplTest : public ::testing::Test { MEDIA, NAVI, VC); - applications_list_.push_back(simple_app_); - applications_list_.push_back(media_app_); - applications_list_.push_back(navi_app_); - applications_list_.push_back(vc_app_); - applications_list_.push_back(media_navi_app_); - applications_list_.push_back(media_vc_app_); - applications_list_.push_back(navi_vc_app_); - applications_list_.push_back(media_navi_vc_app_); + applications_list_[simple_app_] = simple_app_ptr_; + applications_list_[media_app_] = media_app_ptr_; + applications_list_[navi_app_] = navi_app_ptr_; + applications_list_[vc_app_] = vc_app_ptr_; + applications_list_[media_navi_app_] = media_navi_app_ptr_; + applications_list_[media_vc_app_] = media_vc_app_ptr_; + applications_list_[navi_vc_app_] = navi_vc_app_ptr_; + applications_list_[media_navi_vc_app_] = media_navi_vc_app_ptr_; } void CheckAppConfiguration() { ASSERT_EQ(simple_app_.get(), simple_app_ptr_); @@ -1003,7 +1015,6 @@ class StateControllerImplTest : public ::testing::Test { ON_CALL(app_manager_mock_, event_dispatcher()) .WillByDefault(ReturnRef(mock_event_dispatcher_)); state_ctrl_ = std::make_shared(app_manager_mock_); - ON_CALL(app_manager_mock_, applications()) .WillByDefault(Return(applications_)); ConfigureApps(); @@ -1016,6 +1027,22 @@ class StateControllerImplTest : public ::testing::Test { delete conn_handler; } + application_manager::commands::MessageSharedPtr CreateCloseAppMessage() { + using namespace application_manager; + + smart_objects::SmartObjectSPtr message = + std::make_shared( + smart_objects::SmartType_Map); + (*message)[application_manager::strings::params] + [application_manager::strings::function_id] = + hmi_apis::FunctionID::BasicCommunication_CloseApplication; + (*message)[strings::params][strings::message_type] = MessageType::kRequest; + (*message)[strings::params][strings::correlation_id] = kCorrID; + (*message)[strings::msg_params][strings::app_id] = kHMIAppID; + + return message; + } + void SetConnection() { conn_handler = new connection_handler::ConnectionHandlerImpl( mock_connection_handler__settings, mock_transport_manager); @@ -1036,7 +1063,7 @@ class StateControllerImplTest : public ::testing::Test { (*bc_activate_app_request)[am::strings::params] [am::strings::correlation_id] = corr_id; ON_CALL(message_helper_mock_, - GetBCActivateAppRequestToHMI(_, _, _, hmi_lvl, _, _)) + GetBCActivateAppRequestToHMI(_, _, hmi_lvl, _, _)) .WillByDefault(Return(bc_activate_app_request)); ON_CALL(app_manager_mock_, GetRPCService()) .WillByDefault(ReturnRef(mock_rpc_service_)); @@ -1044,22 +1071,36 @@ class StateControllerImplTest : public ::testing::Test { .WillByDefault(Return(true)); } - void ExpectSuccesfullSetHmiState( + void ExpectSuccessfulSetHmiState( am::ApplicationSharedPtr app, NiceMock* app_mock, am::HmiStatePtr old_state, am::HmiStatePtr new_state) { - EXPECT_CALL(*app_mock, CurrentHmiState()) + ExpectSuccessfulSetHmiState( + app, app_mock, kDefaultWindowId, old_state, new_state); + } + + void ExpectSuccessfulSetHmiState( + am::ApplicationSharedPtr app, + NiceMock* app_mock, + am::WindowID window_id, + am::HmiStatePtr old_state, + am::HmiStatePtr new_state) { + EXPECT_CALL(*app_mock, CurrentHmiState(window_id)) .WillOnce(Return(old_state)) .WillOnce(Return(new_state)); - EXPECT_CALL(*app_mock, - SetRegularState(Truly(HmiStatesComparator(new_state)))); + EXPECT_CALL( + *app_mock, + SetRegularState(window_id, Truly(HmiStatesComparator(new_state)))); if (!HmiStatesComparator(old_state)(new_state)) { - EXPECT_CALL(app_manager_mock_, SendHMIStatusNotification(app)); - EXPECT_CALL( - app_manager_mock_, - OnHMILevelChanged( - app->app_id(), old_state->hmi_level(), new_state->hmi_level())); + EXPECT_CALL(message_helper_mock_, + SendHMIStatusNotification(app, window_id, _)); + if (kDefaultWindowId == window_id) { + EXPECT_CALL( + app_manager_mock_, + OnHMILevelChanged( + app->app_id(), old_state->hmi_level(), new_state->hmi_level())); + } } } @@ -1068,22 +1109,33 @@ class StateControllerImplTest : public ::testing::Test { NiceMock* app_mock, am::HmiStatePtr old_state, am::HmiStatePtr new_state) { - EXPECT_CALL(*app_mock, RegularHmiState()) + EXPECT_CALL(*app_mock, RegularHmiState(kDefaultWindowId)) .WillOnce(Return(old_state)) .WillOnce(Return(old_state)); - ExpectSuccesfullSetHmiState(app, app_mock, old_state, new_state); + ExpectSuccessfulSetHmiState(app, app_mock, old_state, new_state); } void ExpectAppWontChangeHmiStateDueToConflictResolving( am::ApplicationSharedPtr app, NiceMock* app_mock, + const am::WindowID window_id, am::HmiStatePtr state) { - ON_CALL(*app_mock, RegularHmiState()).WillByDefault(Return(state)); - EXPECT_CALL(app_manager_mock_, SendHMIStatusNotification(app)).Times(0); + ON_CALL(*app_mock, RegularHmiState(window_id)).WillByDefault(Return(state)); + EXPECT_CALL(message_helper_mock_, + SendHMIStatusNotification(app, window_id, _)) + .Times(0); EXPECT_CALL(app_manager_mock_, OnHMILevelChanged(app->app_id(), _, _)) .Times(0); } + void ExpectAppWontChangeHmiStateDueToConflictResolving( + am::ApplicationSharedPtr app, + NiceMock* app_mock, + am::HmiStatePtr state) { + ExpectAppWontChangeHmiStateDueToConflictResolving( + app, app_mock, kDefaultWindowId, state); + } + void InsertApplication(am::ApplicationSharedPtr app) { application_set_.insert(app); ON_CALL(app_manager_mock_, application(app->app_id())) @@ -1135,13 +1187,14 @@ class StateControllerImplTest : public ::testing::Test { using smart_objects::SmartObject; namespace FunctionID = hmi_apis::FunctionID; - EXPECT_CALL(app_mock, CurrentHmiState()) + EXPECT_CALL(app_mock, CurrentHmiState(kDefaultWindowId)) .WillRepeatedly(Return(NoneNotAudibleState())); for (size_t i = 0; i < state_ids.size(); ++i) { am::HmiState::StateID state_id = state_ids[i]; EXPECT_CALL(app_mock, - AddHMIState(Truly(HmiStatesIDComparator(state_id)))); + AddHMIState(kDefaultWindowId, + Truly(HmiStatesIDComparator(state_id)))); switch (state_id) { case am::HmiState::StateID::STATE_ID_VR_SESSION: { Event vr_start_event(FunctionID::VR_Started); @@ -1182,7 +1235,7 @@ class StateControllerImplTest : public ::testing::Test { default: break; } - EXPECT_CALL(app_mock, AddHMIState(_)).Times(0); + EXPECT_CALL(app_mock, AddHMIState(kDefaultWindowId, _)).Times(0); } } @@ -1194,12 +1247,23 @@ class StateControllerImplTest : public ::testing::Test { using smart_objects::SmartObject; namespace FunctionID = hmi_apis::FunctionID; - EXPECT_CALL(app_mock, CurrentHmiState()) + ON_CALL(message_helper_mock_, GetBCCloseApplicationRequestToHMI(_, _)) + .WillByDefault(Return(CreateCloseAppMessage())); + ON_CALL(app_manager_mock_, GetRPCService()) + .WillByDefault(ReturnRef(mock_rpc_service_)); + ON_CALL(mock_rpc_service_, ManageHMICommand(_, _)) + .WillByDefault(Return(true)); + EXPECT_CALL(app_mock, CurrentHmiState(kDefaultWindowId)) .WillRepeatedly(Return(NoneNotAudibleState())); + am::WindowIds window_ids = {kDefaultWindowId}; + EXPECT_CALL(app_mock, GetWindowIds()).WillRepeatedly(Return(window_ids)); + for (uint32_t i = 0; i < state_ids.size(); ++i) { am::HmiState::StateID state_id = state_ids[i]; - EXPECT_CALL(app_mock, AddHMIState(Truly(HmiStatesIDComparator(state_id)))) + EXPECT_CALL( + app_mock, + AddHMIState(kDefaultWindowId, Truly(HmiStatesIDComparator(state_id)))) .Times(1); switch (state_id) { @@ -1243,16 +1307,17 @@ class StateControllerImplTest : public ::testing::Test { break; } - EXPECT_CALL(app_mock, AddHMIState(_)).Times(0); + EXPECT_CALL(app_mock, AddHMIState(kDefaultWindowId, _)).Times(0); } for (uint32_t i = 0; i < state_ids.size(); ++i) { am::HmiState::StateID state_id = state_ids[i]; - EXPECT_CALL(app_mock, RemoveHMIState(state_id)).Times(1); + EXPECT_CALL(app_mock, RemoveHMIState(kDefaultWindowId, state_id)) + .Times(1); - EXPECT_CALL(app_mock, PostponedHmiState()) + EXPECT_CALL(app_mock, PostponedHmiState(kDefaultWindowId)) .WillOnce(Return(NoneNotAudibleState())); - EXPECT_CALL(app_mock, RemovePostponedState()); + EXPECT_CALL(app_mock, RemovePostponedState(kDefaultWindowId)); switch (state_id) { case am::HmiState::StateID::STATE_ID_VR_SESSION: { @@ -1295,7 +1360,7 @@ class StateControllerImplTest : public ::testing::Test { break; } - EXPECT_CALL(app_mock, RemoveHMIState(_)).Times(0); + EXPECT_CALL(app_mock, RemoveHMIState(kDefaultWindowId, _)).Times(0); } } }; @@ -1307,6 +1372,7 @@ TEST_F(StateControllerImplTest, OnStateChangedWithEqualStates) { for (uint32_t i = 0; i < valid_states_for_not_audio_app_.size(); ++i) { state_ctrl_->OnStateChanged(simple_app_, + kDefaultWindowId, valid_states_for_not_audio_app_[i], valid_states_for_not_audio_app_[i]); } @@ -1317,8 +1383,9 @@ TEST_F(StateControllerImplTest, OnStateChangedWithDifferentStates) { for (uint32_t j = 0; j < valid_states_for_not_audio_app_.size(); ++j) { HmiStatesComparator comp(valid_states_for_not_audio_app_[i]); if (!comp(valid_states_for_not_audio_app_[j])) { - EXPECT_CALL(app_manager_mock_, SendHMIStatusNotification(simple_app_)) - .Times(1); + EXPECT_CALL( + message_helper_mock_, + SendHMIStatusNotification(simple_app_, kDefaultWindowId, _)); EXPECT_CALL( app_manager_mock_, OnHMILevelChanged(simple_app_id_, @@ -1330,10 +1397,12 @@ TEST_F(StateControllerImplTest, OnStateChangedWithDifferentStates) { EXPECT_CALL(*simple_app_ptr_, ResetDataInNone()).Times(1); } state_ctrl_->OnStateChanged(simple_app_, + kDefaultWindowId, valid_states_for_not_audio_app_[i], valid_states_for_not_audio_app_[j]); - EXPECT_CALL(app_manager_mock_, SendHMIStatusNotification(_)).Times(0); + EXPECT_CALL(message_helper_mock_, SendHMIStatusNotification(_, _, _)) + .Times(0); EXPECT_CALL(app_manager_mock_, OnHMILevelChanged(_, _, _)).Times(0); EXPECT_CALL(*simple_app_ptr_, ResetDataInNone()).Times(0); } @@ -1356,10 +1425,12 @@ TEST_F(StateControllerImplTest, OnStateChangedToNone) { SystemContext::SYSCTXT_MAIN); EXPECT_CALL(*simple_app_ptr_, ResetDataInNone()).Times(0); - state_ctrl_->OnStateChanged(simple_app_, none_state, not_none_state); + state_ctrl_->OnStateChanged( + simple_app_, kDefaultWindowId, none_state, not_none_state); EXPECT_CALL(*simple_app_ptr_, ResetDataInNone()).Times(1); - state_ctrl_->OnStateChanged(simple_app_, not_none_state, none_state); + state_ctrl_->OnStateChanged( + simple_app_, kDefaultWindowId, not_none_state, none_state); } TEST_F(StateControllerImplTest, MoveSimpleAppToValidStates) { @@ -1377,18 +1448,21 @@ TEST_F(StateControllerImplTest, MoveSimpleAppToValidStates) { it != valid_states_for_not_audio_app_.end(); ++it) { HmiStatePtr state_to_setup = *it; - EXPECT_CALL(*simple_app_ptr_, CurrentHmiState()) + EXPECT_CALL(*simple_app_ptr_, CurrentHmiState(kDefaultWindowId)) .WillOnce(Return(initial_state)) .WillOnce(Return(state_to_setup)); - EXPECT_CALL(app_manager_mock_, SendHMIStatusNotification(simple_app_)); + EXPECT_CALL(message_helper_mock_, + SendHMIStatusNotification(simple_app_, kDefaultWindowId, _)); EXPECT_CALL(app_manager_mock_, OnHMILevelChanged(simple_app_id_, initial_state->hmi_level(), state_to_setup->hmi_level())); EXPECT_CALL(*simple_app_ptr_, - SetRegularState(Truly(HmiStatesComparator(state_to_setup)))); - state_ctrl_->SetRegularState(simple_app_, state_to_setup, false); + SetRegularState(kDefaultWindowId, + Truly(HmiStatesComparator(state_to_setup)))); + state_ctrl_->SetRegularState( + simple_app_, kDefaultWindowId, state_to_setup, false); initial_state = state_to_setup; } } @@ -1413,18 +1487,21 @@ TEST_F(StateControllerImplTest, MoveAudioNotResumeAppToValidStates) { it != valid_states_for_audio_app_.end(); ++it) { HmiStatePtr state_to_setup = *it; - EXPECT_CALL(*audio_app_mock, CurrentHmiState()) + EXPECT_CALL(*audio_app_mock, CurrentHmiState(kDefaultWindowId)) .WillOnce(Return(initial_state)) .WillOnce(Return(state_to_setup)); - EXPECT_CALL(app_manager_mock_, SendHMIStatusNotification(audio_app)); + EXPECT_CALL(message_helper_mock_, + SendHMIStatusNotification(audio_app, kDefaultWindowId, _)); EXPECT_CALL(app_manager_mock_, OnHMILevelChanged(audio_app->app_id(), initial_state->hmi_level(), state_to_setup->hmi_level())); EXPECT_CALL(*audio_app_mock, - SetRegularState(Truly(HmiStatesComparator(state_to_setup)))); - state_ctrl_->SetRegularState(media_navi_vc_app_, state_to_setup, false); + SetRegularState(kDefaultWindowId, + Truly(HmiStatesComparator(state_to_setup)))); + state_ctrl_->SetRegularState( + media_navi_vc_app_, kDefaultWindowId, state_to_setup, false); initial_state = state_to_setup; } } @@ -1452,7 +1529,7 @@ TEST_F(StateControllerImplTest, MoveAudioResumeAppToValidStates) { HmiStatePtr state_to_setup = *it; HmiStatePtr state_to_check = state_to_setup; // First time current state is initial, then it changes to setup state - EXPECT_CALL(*audio_app_mock, CurrentHmiState()) + EXPECT_CALL(*audio_app_mock, CurrentHmiState(kDefaultWindowId)) .WillOnce(Return(initial_state)) .WillOnce(Return(state_to_setup)); // Audio resume app when HMI level is LIMITED or FULL gets audible state @@ -1480,8 +1557,10 @@ TEST_F(StateControllerImplTest, MoveAudioResumeAppToValidStates) { // Check that we set correct state EXPECT_CALL(*audio_app_mock, - SetRegularState(Truly(HmiStatesComparator(state_to_check)))); - state_ctrl_->SetRegularState(media_navi_vc_app_, state_to_setup, false); + SetRegularState(kDefaultWindowId, + Truly(HmiStatesComparator(state_to_check)))); + state_ctrl_->SetRegularState( + media_navi_vc_app_, kDefaultWindowId, state_to_setup, false); initial_state = state_to_setup; } } @@ -1494,11 +1573,13 @@ TEST_F(StateControllerImplTest, MoveAppFromValidStateToInvalid) { invalid_state_it != common_invalid_states_.end(); ++invalid_state_it) { HmiStatePtr invalid_state = *invalid_state_it; - EXPECT_CALL(*simple_app_ptr_, CurrentHmiState()).Times(0); + EXPECT_CALL(*simple_app_ptr_, CurrentHmiState(kDefaultWindowId)).Times(0); EXPECT_CALL(*simple_app_ptr_, is_resuming()).Times(0); EXPECT_CALL(app_manager_mock_, OnHMILevelChanged(_, _, _)).Times(0); - EXPECT_CALL(*simple_app_ptr_, SetRegularState(_)).Times(0); - state_ctrl_->SetRegularState(simple_app_, invalid_state, false); + EXPECT_CALL(*simple_app_ptr_, SetRegularState(kDefaultWindowId, _)) + .Times(0); + state_ctrl_->SetRegularState( + simple_app_, kDefaultWindowId, invalid_state, false); } for (std::vector::iterator invalid_state_it = @@ -1506,11 +1587,14 @@ TEST_F(StateControllerImplTest, MoveAppFromValidStateToInvalid) { invalid_state_it != common_invalid_states_.end(); ++invalid_state_it) { HmiStatePtr invalid_state = *invalid_state_it; - EXPECT_CALL(*media_navi_vc_app_ptr_, CurrentHmiState()).Times(0); + EXPECT_CALL(*media_navi_vc_app_ptr_, CurrentHmiState(kDefaultWindowId)) + .Times(0); EXPECT_CALL(*media_navi_vc_app_ptr_, is_resuming()).Times(0); EXPECT_CALL(app_manager_mock_, OnHMILevelChanged(_, _, _)).Times(0); - EXPECT_CALL(*media_navi_vc_app_ptr_, SetRegularState(_)).Times(0); - state_ctrl_->SetRegularState(media_navi_vc_app_, invalid_state, false); + EXPECT_CALL(*media_navi_vc_app_ptr_, SetRegularState(kDefaultWindowId, _)) + .Times(0); + state_ctrl_->SetRegularState( + media_navi_vc_app_, kDefaultWindowId, invalid_state, false); } } @@ -1532,7 +1616,7 @@ TEST_F(StateControllerImplTest, InsertApplication(app_in_full); InsertApplication(app_moved_to_full); - ExpectSuccesfullSetHmiState(app_moved_to_full, + ExpectSuccessfulSetHmiState(app_moved_to_full, app_moved_to_full_mock, BackgroundState(), FullNotAudibleState()); @@ -1540,7 +1624,8 @@ TEST_F(StateControllerImplTest, ExpectAppChangeHmiStateDueToConflictResolving( app_in_full, app_in_full_mock, FullNotAudibleState(), BackgroundState()); - state_ctrl_->SetRegularState(app_moved_to_full, FullNotAudibleState(), false); + state_ctrl_->SetRegularState( + app_moved_to_full, kDefaultWindowId, FullNotAudibleState(), false); } TEST_F(StateControllerImplTest, SetFullToSimpleAppWhileAudioAppAppIsInFull) { @@ -1557,14 +1642,15 @@ TEST_F(StateControllerImplTest, SetFullToSimpleAppWhileAudioAppAppIsInFull) { InsertApplication(app_in_full); InsertApplication(app_moved_to_full); - ExpectSuccesfullSetHmiState(app_moved_to_full, + ExpectSuccessfulSetHmiState(app_moved_to_full, app_moved_to_full_mock, BackgroundState(), FullNotAudibleState()); ExpectAppChangeHmiStateDueToConflictResolving( app_in_full, app_in_full_mock, FullAudibleState(), LimitedState()); - state_ctrl_->SetRegularState(app_moved_to_full, FullNotAudibleState(), false); + state_ctrl_->SetRegularState( + app_moved_to_full, kDefaultWindowId, FullNotAudibleState(), false); } TEST_F(StateControllerImplTest, @@ -1583,14 +1669,15 @@ TEST_F(StateControllerImplTest, InsertApplication(app_in_full); InsertApplication(app_moved_to_full); - ExpectSuccesfullSetHmiState(app_moved_to_full, + ExpectSuccessfulSetHmiState(app_moved_to_full, app_moved_to_full_mock, BackgroundState(), FullAudibleState()); ExpectAppChangeHmiStateDueToConflictResolving( app_in_full, app_in_full_mock, FullAudibleState(), LimitedState()); - state_ctrl_->SetRegularState(app_moved_to_full, FullAudibleState(), false); + state_ctrl_->SetRegularState( + app_moved_to_full, kDefaultWindowId, FullAudibleState(), false); } TEST_F(StateControllerImplTest, @@ -1607,7 +1694,7 @@ TEST_F(StateControllerImplTest, InsertApplication(app_in_full); InsertApplication(app_moved_to_full); - ExpectSuccesfullSetHmiState(app_moved_to_full, + ExpectSuccessfulSetHmiState(app_moved_to_full, app_moved_to_full_mock, BackgroundState(), FullAudibleState()); @@ -1615,7 +1702,8 @@ TEST_F(StateControllerImplTest, ExpectAppChangeHmiStateDueToConflictResolving( app_in_full, app_in_full_mock, FullAudibleState(), BackgroundState()); - state_ctrl_->SetRegularState(app_moved_to_full, FullAudibleState(), false); + state_ctrl_->SetRegularState( + app_moved_to_full, kDefaultWindowId, FullAudibleState(), false); } TEST_F(StateControllerImplTest, @@ -1633,7 +1721,7 @@ TEST_F(StateControllerImplTest, InsertApplication(app_in_limited); InsertApplication(app_moved_to_full); - ExpectSuccesfullSetHmiState(app_moved_to_full, + ExpectSuccessfulSetHmiState(app_moved_to_full, app_moved_to_full_mock, BackgroundState(), FullAudibleState()); @@ -1641,7 +1729,8 @@ TEST_F(StateControllerImplTest, ExpectAppChangeHmiStateDueToConflictResolving( app_in_limited, app_in_limited_mock, LimitedState(), BackgroundState()); - state_ctrl_->SetRegularState(app_moved_to_full, FullAudibleState(), false); + state_ctrl_->SetRegularState( + app_moved_to_full, kDefaultWindowId, FullAudibleState(), false); } TEST_F(StateControllerImplTest, @@ -1660,7 +1749,7 @@ TEST_F(StateControllerImplTest, InsertApplication(app_in_limited); InsertApplication(app_moved_to_limited); - ExpectSuccesfullSetHmiState(app_moved_to_limited, + ExpectSuccessfulSetHmiState(app_moved_to_limited, app_moved_to_limited_mock, BackgroundState(), LimitedState()); @@ -1668,7 +1757,8 @@ TEST_F(StateControllerImplTest, ExpectAppChangeHmiStateDueToConflictResolving( app_in_limited, app_in_limited_mock, LimitedState(), BackgroundState()); - state_ctrl_->SetRegularState(app_moved_to_limited, LimitedState(), false); + state_ctrl_->SetRegularState( + app_moved_to_limited, kDefaultWindowId, LimitedState(), false); } TEST_F(StateControllerImplTest, @@ -1686,14 +1776,15 @@ TEST_F(StateControllerImplTest, InsertApplication(app_in_limited); InsertApplication(app_moved_to_limited); - ExpectSuccesfullSetHmiState(app_moved_to_limited, + ExpectSuccessfulSetHmiState(app_moved_to_limited, app_moved_to_limited_mock, BackgroundState(), LimitedState()); ExpectAppWontChangeHmiStateDueToConflictResolving( app_in_limited, app_in_limited_mock, LimitedState()); - state_ctrl_->SetRegularState(app_moved_to_limited, LimitedState(), false); + state_ctrl_->SetRegularState( + app_moved_to_limited, kDefaultWindowId, LimitedState(), false); } TEST_F(StateControllerImplTest, @@ -1712,14 +1803,15 @@ TEST_F(StateControllerImplTest, InsertApplication(app_in_full); InsertApplication(app_moved_to_limited); - ExpectSuccesfullSetHmiState(app_moved_to_limited, + ExpectSuccessfulSetHmiState(app_moved_to_limited, app_moved_to_limited_mock, BackgroundState(), LimitedState()); ExpectAppWontChangeHmiStateDueToConflictResolving( app_in_full, app_in_full_mock, FullAudibleState()); - state_ctrl_->SetRegularState(app_moved_to_limited, LimitedState(), false); + state_ctrl_->SetRegularState( + app_moved_to_limited, kDefaultWindowId, LimitedState(), false); } TEST_F(StateControllerImplTest, SetFullToSimpleAppWhile2AudioAppsInLimited) { @@ -1743,7 +1835,7 @@ TEST_F(StateControllerImplTest, SetFullToSimpleAppWhile2AudioAppsInLimited) { InsertApplication(limited_app1); InsertApplication(limited_app2); - ExpectSuccesfullSetHmiState(app_moved_to_full, + ExpectSuccessfulSetHmiState(app_moved_to_full, app_moved_to_full_mock, BackgroundState(), FullNotAudibleState()); @@ -1753,7 +1845,8 @@ TEST_F(StateControllerImplTest, SetFullToSimpleAppWhile2AudioAppsInLimited) { ExpectAppWontChangeHmiStateDueToConflictResolving( limited_app2, limited_app2_mock, LimitedState()); - state_ctrl_->SetRegularState(app_moved_to_full, FullNotAudibleState(), false); + state_ctrl_->SetRegularState( + app_moved_to_full, kDefaultWindowId, FullNotAudibleState(), false); } TEST_F(StateControllerImplTest, @@ -1778,7 +1871,7 @@ TEST_F(StateControllerImplTest, InsertApplication(limited_app); InsertApplication(full_app); - ExpectSuccesfullSetHmiState(app_moved_to_full, + ExpectSuccessfulSetHmiState(app_moved_to_full, app_moved_to_full_mock, BackgroundState(), FullNotAudibleState()); @@ -1789,7 +1882,8 @@ TEST_F(StateControllerImplTest, ExpectAppChangeHmiStateDueToConflictResolving( full_app, full_app_mock, FullAudibleState(), LimitedState()); - state_ctrl_->SetRegularState(app_moved_to_full, FullNotAudibleState(), false); + state_ctrl_->SetRegularState( + app_moved_to_full, kDefaultWindowId, FullNotAudibleState(), false); } TEST_F(StateControllerImplTest, @@ -1814,7 +1908,7 @@ TEST_F(StateControllerImplTest, InsertApplication(limited_app); InsertApplication(full_app); - ExpectSuccesfullSetHmiState(app_moved_to_full, + ExpectSuccessfulSetHmiState(app_moved_to_full, app_moved_to_full_mock, BackgroundState(), FullNotAudibleState()); @@ -1825,7 +1919,8 @@ TEST_F(StateControllerImplTest, ExpectAppChangeHmiStateDueToConflictResolving( full_app, full_app_mock, FullNotAudibleState(), BackgroundState()); - state_ctrl_->SetRegularState(app_moved_to_full, FullNotAudibleState(), false); + state_ctrl_->SetRegularState( + app_moved_to_full, kDefaultWindowId, FullNotAudibleState(), false); } TEST_F( @@ -1851,7 +1946,7 @@ TEST_F( InsertApplication(limited_app); InsertApplication(full_app); - ExpectSuccesfullSetHmiState(app_moved_to_full, + ExpectSuccessfulSetHmiState(app_moved_to_full, app_moved_to_full_mock, BackgroundState(), FullAudibleState()); @@ -1862,7 +1957,8 @@ TEST_F( ExpectAppChangeHmiStateDueToConflictResolving( full_app, full_app_mock, FullNotAudibleState(), BackgroundState()); - state_ctrl_->SetRegularState(app_moved_to_full, FullAudibleState(), false); + state_ctrl_->SetRegularState( + app_moved_to_full, kDefaultWindowId, FullAudibleState(), false); } TEST_F( @@ -1888,7 +1984,7 @@ TEST_F( InsertApplication(limited_app); InsertApplication(full_app); - ExpectSuccesfullSetHmiState(app_moved_to_full, + ExpectSuccessfulSetHmiState(app_moved_to_full, app_moved_to_full_mock, BackgroundState(), FullAudibleState()); @@ -1899,7 +1995,8 @@ TEST_F( ExpectAppChangeHmiStateDueToConflictResolving( full_app, full_app_mock, FullAudibleState(), LimitedState()); - state_ctrl_->SetRegularState(app_moved_to_full, FullAudibleState(), false); + state_ctrl_->SetRegularState( + app_moved_to_full, kDefaultWindowId, FullAudibleState(), false); } TEST_F(StateControllerImplTest, @@ -1912,19 +2009,20 @@ TEST_F(StateControllerImplTest, InsertApplication(media_app_); InsertApplication(navi_app_); InsertApplication(vc_app_); - ExpectSuccesfullSetHmiState(media_navi_vc_app_, + ExpectSuccessfulSetHmiState(media_navi_vc_app_, media_navi_vc_app_ptr_, BackgroundState(), FullAudibleState()); - EXPECT_CALL(*media_app_ptr_, RegularHmiState()) + EXPECT_CALL(*media_app_ptr_, RegularHmiState(kDefaultWindowId)) .WillOnce(Return(LimitedState())); ExpectAppChangeHmiStateDueToConflictResolving( navi_app_, navi_app_ptr_, LimitedState(), BackgroundState()); ExpectAppChangeHmiStateDueToConflictResolving( vc_app_, vc_app_ptr_, LimitedState(), BackgroundState()); - state_ctrl_->SetRegularState(media_navi_vc_app_, FullAudibleState(), false); + state_ctrl_->SetRegularState( + media_navi_vc_app_, kDefaultWindowId, FullAudibleState(), false); } TEST_F(StateControllerImplTest, @@ -1937,19 +2035,20 @@ TEST_F(StateControllerImplTest, InsertApplication(media_app_); InsertApplication(navi_app_); InsertApplication(vc_app_); - ExpectSuccesfullSetHmiState(media_navi_vc_app_, + ExpectSuccessfulSetHmiState(media_navi_vc_app_, media_navi_vc_app_ptr_, BackgroundState(), FullAudibleState()); - EXPECT_CALL(*media_app_ptr_, RegularHmiState()) + EXPECT_CALL(*media_app_ptr_, RegularHmiState(kDefaultWindowId)) .WillOnce(Return(LimitedState())); ExpectAppChangeHmiStateDueToConflictResolving( navi_app_, navi_app_ptr_, LimitedState(), BackgroundState()); ExpectAppChangeHmiStateDueToConflictResolving( vc_app_, vc_app_ptr_, FullAudibleState(), BackgroundState()); - state_ctrl_->SetRegularState(media_navi_vc_app_, FullAudibleState(), false); + state_ctrl_->SetRegularState( + media_navi_vc_app_, kDefaultWindowId, FullAudibleState(), false); } // TODO {AKozoriz} Changed logic in state_controller @@ -1969,12 +2068,6 @@ TEST_F(StateControllerImplTest, DISABLED_ActivateAppSuccessReceivedFromHMI) { StateLevelPair(LimitedState(), Common_HMILevel::LIMITED)); hmi_states.push_back( StateLevelPair(BackgroundState(), Common_HMILevel::BACKGROUND)); - hmi_states.push_back( - StateLevelPair(createHmiState(HMILevel::HMI_NONE, - AudioStreamingState::NOT_AUDIBLE, - VideoStreamingState::NOT_STREAMABLE, - SystemContext::SYSCTXT_MAIN), - Common_HMILevel::NONE)); std::vector initial_hmi_states = hmi_states; std::vector::iterator it = hmi_states.begin(); std::vector::iterator it2 = initial_hmi_states.begin(); @@ -1998,9 +2091,9 @@ TEST_F(StateControllerImplTest, DISABLED_ActivateAppSuccessReceivedFromHMI) { .WillOnce(Return(hmi_app_id)); EXPECT_CALL(app_manager_mock_, application_by_hmi_app(hmi_app_id)) .WillOnce(Return(media_app_)); - ExpectSuccesfullSetHmiState( + ExpectSuccessfulSetHmiState( media_app_, media_app_ptr_, initial_hmi_state, hmi_state); - state_ctrl_->SetRegularState(media_app_, hmi_state, true); + state_ctrl_->SetRegularState(media_app_, kDefaultWindowId, hmi_state, true); smart_objects::SmartObject message; message[am::strings::params][am::hmi_response::code] = Common_Result::SUCCESS; @@ -2056,14 +2149,16 @@ TEST_F(StateControllerImplTest, SendEventBCActivateApp_HMIReceivesError) { EXPECT_CALL(app_manager_mock_, application_by_hmi_app(hmi_app_id)) .WillOnce(Return(simple_app_)); - EXPECT_CALL(*simple_app_ptr_, RegularHmiState()).Times(0); - EXPECT_CALL(*simple_app_ptr_, CurrentHmiState()).Times(0); - EXPECT_CALL(*simple_app_ptr_, SetRegularState(_)).Times(0); + EXPECT_CALL(*simple_app_ptr_, RegularHmiState(kDefaultWindowId)).Times(0); + EXPECT_CALL(*simple_app_ptr_, CurrentHmiState(kDefaultWindowId)).Times(0); + EXPECT_CALL(*simple_app_ptr_, SetRegularState(kDefaultWindowId, _)) + .Times(0); EXPECT_CALL(app_manager_mock_, SendHMIStatusNotification(simple_app_)) .Times(0); EXPECT_CALL(app_manager_mock_, - OnHMILevelChanged(simple_app_->app_id(), _, _)).Times(0); + OnHMILevelChanged(simple_app_->app_id(), _, _)) + .Times(0); smart_objects::SmartObject message; message[am::strings::params][am::hmi_response::code] = *it; @@ -2083,13 +2178,14 @@ TEST_F(StateControllerImplTest, ActivateAppInvalidCorrelationId) { .WillOnce(Return(hmi_app_id)); EXPECT_CALL(app_manager_mock_, application_by_hmi_app(hmi_app_id)) .WillOnce(Return(am::ApplicationSharedPtr())); - EXPECT_CALL(*simple_app_ptr_, SetRegularState(_)).Times(0); + EXPECT_CALL(*simple_app_ptr_, SetRegularState(kDefaultWindowId, _)).Times(0); EXPECT_CALL(app_manager_mock_, SendHMIStatusNotification(simple_app_)) .Times(0); EXPECT_CALL(app_manager_mock_, OnHMILevelChanged(simple_app_->app_id(), _, _)) .Times(0); SetBCActivateAppRequestToHMI(Common_HMILevel::FULL, corr_id); - state_ctrl_->SetRegularState(simple_app_, FullNotAudibleState(), true); + state_ctrl_->SetRegularState( + simple_app_, kDefaultWindowId, FullNotAudibleState(), true); smart_objects::SmartObject message; message[am::strings::params][am::hmi_response::code] = Common_Result::SUCCESS; message[am::strings::params][am::strings::correlation_id] = corr_id; @@ -2513,45 +2609,52 @@ TEST_F(StateControllerImplTest, TEST_F(StateControllerImplTest, SetRegularStateWithNewHmiLvl) { using namespace mobile_apis; + auto message = CreateCloseAppMessage(); + ON_CALL(message_helper_mock_, GetBCCloseApplicationRequestToHMI(_, _)) + .WillByDefault(Return(message)); + ON_CALL(app_manager_mock_, GetRPCService()) + .WillByDefault(ReturnRef(mock_rpc_service_)); + ON_CALL(mock_rpc_service_, ManageHMICommand(_, _)) + .WillByDefault(Return(true)); + + ON_CALL(*simple_app_ptr_, RegularHmiState(kDefaultWindowId)) + .WillByDefault(Return(NoneNotAudibleState())); + ON_CALL(*simple_app_ptr_, CurrentHmiState(kDefaultWindowId)) + .WillByDefault(Return(NoneNotAudibleState())); HMILevel::eType set_lvl = HMILevel::HMI_NONE; - EXPECT_CALL(*simple_app_ptr_, RegularHmiState()) - .WillOnce(Return(BackgroundState())); - EXPECT_CALL(*simple_app_ptr_, CurrentHmiState()) - .WillOnce(Return(BackgroundState())) - .WillOnce(Return(BackgroundState())); - - state_ctrl_->SetRegularState(simple_app_, set_lvl); + state_ctrl_->SetRegularState(simple_app_, kDefaultWindowId, set_lvl); set_lvl = HMILevel::HMI_LIMITED; - EXPECT_CALL(*simple_app_ptr_, RegularHmiState()) + EXPECT_CALL(*simple_app_ptr_, RegularHmiState(kDefaultWindowId)) .WillOnce(Return(BackgroundState())); - EXPECT_CALL(*simple_app_ptr_, CurrentHmiState()) + EXPECT_CALL(*simple_app_ptr_, CurrentHmiState(kDefaultWindowId)) .WillOnce(Return(BackgroundState())) .WillOnce(Return(BackgroundState())); - state_ctrl_->SetRegularState(simple_app_, set_lvl); + + state_ctrl_->SetRegularState(simple_app_, kDefaultWindowId, set_lvl); set_lvl = HMILevel::HMI_FULL; - EXPECT_CALL(*simple_app_ptr_, RegularHmiState()) + EXPECT_CALL(*simple_app_ptr_, RegularHmiState(kDefaultWindowId)) .WillOnce(Return(BackgroundState())); const uint32_t corr_id = 314; SetBCActivateAppRequestToHMI( static_cast(set_lvl), corr_id); - state_ctrl_->SetRegularState(simple_app_, set_lvl); + state_ctrl_->SetRegularState(simple_app_, kDefaultWindowId, set_lvl); set_lvl = HMILevel::HMI_BACKGROUND; - EXPECT_CALL(*simple_app_ptr_, RegularHmiState()) + EXPECT_CALL(*simple_app_ptr_, RegularHmiState(kDefaultWindowId)) .WillOnce(Return(BackgroundState())); - EXPECT_CALL(*simple_app_ptr_, CurrentHmiState()) + EXPECT_CALL(*simple_app_ptr_, CurrentHmiState(kDefaultWindowId)) .WillOnce(Return(BackgroundState())) .WillOnce(Return(BackgroundState())); - state_ctrl_->SetRegularState(simple_app_, set_lvl); + state_ctrl_->SetRegularState(simple_app_, kDefaultWindowId, set_lvl); } TEST_F(StateControllerImplTest, SetRegularStateWithAudioStateAudible) { @@ -2561,16 +2664,18 @@ TEST_F(StateControllerImplTest, SetRegularStateWithAudioStateAudible) { AudioStreamingState::AUDIBLE, VideoStreamingState::STREAMABLE, SystemContext::SYSCTXT_MAIN); - EXPECT_CALL(*simple_app_ptr_, RegularHmiState()) + EXPECT_CALL(*simple_app_ptr_, RegularHmiState(kDefaultWindowId)) .WillRepeatedly(Return(BackgroundState())); - EXPECT_CALL(*simple_app_ptr_, CurrentHmiState()) + EXPECT_CALL(*simple_app_ptr_, CurrentHmiState(kDefaultWindowId)) .WillOnce(Return(check_state)) .WillOnce(Return(check_state)); EXPECT_CALL(*simple_app_ptr_, - SetRegularState(Truly(HmiStatesComparator(check_state)))); + SetRegularState(kDefaultWindowId, + Truly(HmiStatesComparator(check_state)))); state_ctrl_->SetRegularState(simple_app_, + kDefaultWindowId, AudioStreamingState::AUDIBLE, VideoStreamingState::STREAMABLE); } @@ -2587,23 +2692,27 @@ TEST_F(StateControllerImplTest, // Non-media app can't have LIMITED-AUDIO state EXPECT_CALL(*simple_app_ptr_, is_resuming()).WillRepeatedly(Return(true)); - EXPECT_CALL(*simple_app_ptr_, CurrentHmiState()).Times(0); - EXPECT_CALL(*simple_app_ptr_, SetRegularState(_)).Times(0); + EXPECT_CALL(*simple_app_ptr_, CurrentHmiState(kDefaultWindowId)).Times(0); + EXPECT_CALL(*simple_app_ptr_, SetRegularState(kDefaultWindowId, _)).Times(0); EXPECT_CALL(app_manager_mock_, GetDefaultHmiLevel(_)) .WillRepeatedly(Return(mobile_apis::HMILevel::HMI_NONE)); EXPECT_CALL(app_manager_mock_, active_application()) .WillRepeatedly(Return(am::ApplicationSharedPtr())); EXPECT_CALL(*simple_app_ptr_, - SetPostponedState(Truly(HmiStatesComparator(check_state)))); - state_ctrl_->SetRegularState(simple_app_, check_state, false); + SetPostponedState(kDefaultWindowId, + Truly(HmiStatesComparator(check_state)))); + state_ctrl_->SetRegularState( + simple_app_, kDefaultWindowId, check_state, false); check_state = LimitedState(); EXPECT_CALL(*media_app_ptr_, is_resuming()).WillRepeatedly(Return(true)); - EXPECT_CALL(*media_app_ptr_, CurrentHmiState()).Times(0); - EXPECT_CALL(*media_app_ptr_, SetRegularState(_)).Times(0); + EXPECT_CALL(*media_app_ptr_, CurrentHmiState(kDefaultWindowId)).Times(0); + EXPECT_CALL(*media_app_ptr_, SetRegularState(kDefaultWindowId, _)).Times(0); EXPECT_CALL(*media_app_ptr_, - SetPostponedState(Truly(HmiStatesComparator(check_state)))); - state_ctrl_->SetRegularState(media_app_, check_state, false); + SetPostponedState(kDefaultWindowId, + Truly(HmiStatesComparator(check_state)))); + state_ctrl_->SetRegularState( + media_app_, kDefaultWindowId, check_state, false); } TEST_F(StateControllerImplTest, SetRegularStateMediaToNonMediaApp_VR_Stopped) { @@ -2620,25 +2729,29 @@ TEST_F(StateControllerImplTest, SetRegularStateMediaToNonMediaApp_VR_Stopped) { HmiStatePtr check_state = FullNotAudibleState(); // Non-media app can't have LIMITED-AUDIO state - EXPECT_CALL(*simple_app_ptr_, CurrentHmiState()) + EXPECT_CALL(*simple_app_ptr_, CurrentHmiState(kDefaultWindowId)) .WillOnce(Return(check_state)) .WillOnce(Return(check_state)); EXPECT_CALL(*simple_app_ptr_, is_resuming()).WillRepeatedly(Return(false)); EXPECT_CALL(message_helper_mock_, - SendOnResumeAudioSourceToHMI(simple_app_id_, _)).Times(0); + SendOnResumeAudioSourceToHMI(simple_app_id_, _)) + .Times(0); EXPECT_CALL(*simple_app_ptr_, - SetPostponedState(Truly(HmiStatesComparator(check_state)))) + SetPostponedState(kDefaultWindowId, + Truly(HmiStatesComparator(check_state)))) .Times(0); EXPECT_CALL(*simple_app_ptr_, - SetRegularState(Truly(HmiStatesComparator(check_state)))); - state_ctrl_->SetRegularState(simple_app_, check_state, false); + SetRegularState(kDefaultWindowId, + Truly(HmiStatesComparator(check_state)))); + state_ctrl_->SetRegularState( + simple_app_, kDefaultWindowId, check_state, false); // Set state of media app after vr has stopped check_state = LimitedState(); - EXPECT_CALL(*media_app_ptr_, CurrentHmiState()) + EXPECT_CALL(*media_app_ptr_, CurrentHmiState(kDefaultWindowId)) .WillOnce(Return(check_state)) .WillOnce(Return(check_state)); @@ -2647,11 +2760,14 @@ TEST_F(StateControllerImplTest, SetRegularStateMediaToNonMediaApp_VR_Stopped) { EXPECT_CALL(message_helper_mock_, SendOnResumeAudioSourceToHMI(media_app_id_, _)); EXPECT_CALL(*media_app_ptr_, - SetPostponedState(Truly(HmiStatesComparator(check_state)))) + SetPostponedState(kDefaultWindowId, + Truly(HmiStatesComparator(check_state)))) .Times(0); EXPECT_CALL(*media_app_ptr_, - SetRegularState(Truly(HmiStatesComparator(check_state)))); - state_ctrl_->SetRegularState(media_app_, check_state, false); + SetRegularState(kDefaultWindowId, + Truly(HmiStatesComparator(check_state)))); + state_ctrl_->SetRegularState( + media_app_, kDefaultWindowId, check_state, false); } TEST_F(StateControllerImplTest, @@ -2674,28 +2790,32 @@ TEST_F(StateControllerImplTest, HmiStatePtr check_state = FullNotAudibleState(); EXPECT_CALL(*simple_app_ptr_, is_resuming()).WillRepeatedly(Return(true)); - EXPECT_CALL(*simple_app_ptr_, RegularHmiState()).Times(0); - EXPECT_CALL(*simple_app_ptr_, CurrentHmiState()).Times(0); - EXPECT_CALL(*simple_app_ptr_, SetRegularState(_)).Times(0); + EXPECT_CALL(*simple_app_ptr_, RegularHmiState(kDefaultWindowId)).Times(0); + EXPECT_CALL(*simple_app_ptr_, CurrentHmiState(kDefaultWindowId)).Times(0); + EXPECT_CALL(*simple_app_ptr_, SetRegularState(kDefaultWindowId, _)).Times(0); EXPECT_CALL(app_manager_mock_, GetDefaultHmiLevel(_)) .WillRepeatedly(Return(mobile_apis::HMILevel::HMI_NONE)); EXPECT_CALL(app_manager_mock_, active_application()) .WillRepeatedly(Return(am::ApplicationSharedPtr())); EXPECT_CALL(*simple_app_ptr_, - SetPostponedState(Truly(HmiStatesComparator(check_state)))); - state_ctrl_->SetRegularState(simple_app_, check_state, false); + SetPostponedState(kDefaultWindowId, + Truly(HmiStatesComparator(check_state)))); + state_ctrl_->SetRegularState( + simple_app_, kDefaultWindowId, check_state, false); // Set media app check_state = LimitedState(); EXPECT_CALL(*media_app_ptr_, is_resuming()).WillRepeatedly(Return(true)); - EXPECT_CALL(*media_app_ptr_, RegularHmiState()).Times(0); - EXPECT_CALL(*media_app_ptr_, CurrentHmiState()).Times(0); - EXPECT_CALL(*media_app_ptr_, SetRegularState(_)).Times(0); + EXPECT_CALL(*media_app_ptr_, RegularHmiState(kDefaultWindowId)).Times(0); + EXPECT_CALL(*media_app_ptr_, CurrentHmiState(kDefaultWindowId)).Times(0); + EXPECT_CALL(*media_app_ptr_, SetRegularState(kDefaultWindowId, _)).Times(0); EXPECT_CALL(*media_app_ptr_, - SetPostponedState(Truly(HmiStatesComparator(check_state)))); - state_ctrl_->SetRegularState(media_app_, check_state, false); + SetPostponedState(kDefaultWindowId, + Truly(HmiStatesComparator(check_state)))); + state_ctrl_->SetRegularState( + media_app_, kDefaultWindowId, check_state, false); } TEST_F(StateControllerImplTest, @@ -2728,8 +2848,10 @@ TEST_F(StateControllerImplTest, .WillRepeatedly(Return(am::ApplicationSharedPtr())); EXPECT_CALL(*media_app_ptr_, - SetPostponedState(Truly(HmiStatesComparator(check_state)))); - state_ctrl_->SetRegularState(media_app_, check_state, false); + SetPostponedState(kDefaultWindowId, + Truly(HmiStatesComparator(check_state)))); + state_ctrl_->SetRegularState( + media_app_, kDefaultWindowId, check_state, false); } TEST_F(StateControllerImplTest, @@ -2757,13 +2879,13 @@ TEST_F(StateControllerImplTest, EXPECT_CALL(app_manager_mock_, IsAppTypeExistsInFullOrLimited(_)) .WillRepeatedly(Return(false)); - EXPECT_CALL(*navi_app_ptr_, CurrentHmiState()) + EXPECT_CALL(*navi_app_ptr_, CurrentHmiState(kDefaultWindowId)) .WillRepeatedly(Return(hmi_state)); EXPECT_CALL(app_manager_mock_, active_application()) .WillRepeatedly(Return(am::ApplicationSharedPtr())); - state_ctrl_->SetRegularState(navi_app_, hmi_state, false); + state_ctrl_->SetRegularState(navi_app_, kDefaultWindowId, hmi_state, false); } TEST_F(StateControllerImplTest, @@ -2791,15 +2913,15 @@ TEST_F(StateControllerImplTest, EXPECT_CALL(app_manager_mock_, IsAppTypeExistsInFullOrLimited(_)) .WillRepeatedly(Return(false)); - EXPECT_CALL(*navi_app_ptr_, CurrentHmiState()) + EXPECT_CALL(*navi_app_ptr_, CurrentHmiState(kDefaultWindowId)) .WillRepeatedly(Return(hmi_state)); EXPECT_CALL(app_manager_mock_, active_application()) .WillRepeatedly(Return(am::ApplicationSharedPtr())); - EXPECT_CALL(*navi_app_ptr_, SetPostponedState(_)).Times(0); + EXPECT_CALL(*navi_app_ptr_, SetPostponedState(kDefaultWindowId, _)).Times(0); - state_ctrl_->SetRegularState(navi_app_, hmi_state, false); + state_ctrl_->SetRegularState(navi_app_, kDefaultWindowId, hmi_state, false); } TEST_F(StateControllerImplTest, @@ -2807,7 +2929,6 @@ TEST_F(StateControllerImplTest, using namespace hmi_apis; using namespace smart_objects; using namespace am::event_engine; - using namespace constants; const uint32_t app_id = navi_app_->app_id(); // Precondition @@ -2831,13 +2952,13 @@ TEST_F(StateControllerImplTest, EXPECT_CALL(app_manager_mock_, IsAppTypeExistsInFullOrLimited(_)) .WillRepeatedly(Return(false)); - EXPECT_CALL(*navi_app_ptr_, CurrentHmiState()) + EXPECT_CALL(*navi_app_ptr_, CurrentHmiState(kDefaultWindowId)) .WillRepeatedly(Return(hmi_state)); EXPECT_CALL(app_manager_mock_, active_application()) .WillRepeatedly(Return(am::ApplicationSharedPtr())); - state_ctrl_->SetRegularState(navi_app_, hmi_state, true); + state_ctrl_->SetRegularState(navi_app_, kDefaultWindowId, hmi_state, true); } TEST_F(StateControllerImplTest, @@ -2845,7 +2966,6 @@ TEST_F(StateControllerImplTest, using namespace hmi_apis; using namespace smart_objects; using namespace am::event_engine; - using namespace constants; const uint32_t app_id = navi_app_->app_id(); // Precondition @@ -2869,15 +2989,15 @@ TEST_F(StateControllerImplTest, EXPECT_CALL(app_manager_mock_, IsAppTypeExistsInFullOrLimited(_)) .WillRepeatedly(Return(false)); - EXPECT_CALL(*navi_app_ptr_, CurrentHmiState()) + EXPECT_CALL(*navi_app_ptr_, CurrentHmiState(kDefaultWindowId)) .WillRepeatedly(Return(hmi_state)); EXPECT_CALL(app_manager_mock_, active_application()) .WillRepeatedly(Return(am::ApplicationSharedPtr())); - EXPECT_CALL(*navi_app_ptr_, SetPostponedState(_)).Times(0); + EXPECT_CALL(*navi_app_ptr_, SetPostponedState(kDefaultWindowId, _)).Times(0); - state_ctrl_->SetRegularState(navi_app_, hmi_state, true); + state_ctrl_->SetRegularState(navi_app_, kDefaultWindowId, hmi_state, true); } TEST_F(StateControllerImplTest, @@ -2898,13 +3018,16 @@ TEST_F(StateControllerImplTest, EXPECT_CALL(*simple_app_ptr_, keep_context()).WillOnce(Return(true)); EXPECT_CALL(*simple_app_ptr_, IsAudioApplication()) .WillRepeatedly(Return(true)); - EXPECT_CALL(*simple_app_ptr_, CurrentHmiState()) + EXPECT_CALL(*simple_app_ptr_, CurrentHmiState(kDefaultWindowId)) .WillOnce(Return(FullAudibleState())); EXPECT_CALL(*simple_app_ptr_, set_keep_context(false)); HmiStatePtr new_state; - EXPECT_CALL(*simple_app_ptr_, AddHMIState(_)) - .WillOnce(SaveArg<0>(&new_state)); + EXPECT_CALL(*simple_app_ptr_, AddHMIState(kDefaultWindowId, _)) + .WillOnce(SaveArg<1>(&new_state)); + + am::WindowIds window_ids = {kDefaultWindowId}; + EXPECT_CALL(*simple_app_ptr_, GetWindowIds()).WillOnce(Return(window_ids)); state_ctrl_->on_event(event); @@ -2929,12 +3052,15 @@ TEST_F(StateControllerImplTest, OnEventChangedAudioSourceAppToBackground) { EXPECT_CALL(*simple_app_ptr_, IsAudioApplication()) .WillRepeatedly(Return(true)); - EXPECT_CALL(*simple_app_ptr_, CurrentHmiState()) + EXPECT_CALL(*simple_app_ptr_, CurrentHmiState(kDefaultWindowId)) .WillOnce(Return(LimitedState())); HmiStatePtr new_state; - EXPECT_CALL(*simple_app_ptr_, AddHMIState(_)) - .WillOnce(SaveArg<0>(&new_state)); + EXPECT_CALL(*simple_app_ptr_, AddHMIState(kDefaultWindowId, _)) + .WillOnce(SaveArg<1>(&new_state)); + + am::WindowIds window_ids = {kDefaultWindowId}; + EXPECT_CALL(*simple_app_ptr_, GetWindowIds()).WillOnce(Return(window_ids)); state_ctrl_->on_event(event); @@ -2953,9 +3079,13 @@ TEST_F(StateControllerImplTest, OnEventOnAppDeactivatedIncorrectHmiLevel) { event.set_smart_object(msg); EXPECT_CALL(app_manager_mock_, application(app_id)) .WillOnce(Return(simple_app_)); - EXPECT_CALL(*simple_app_ptr_, hmi_level()) + EXPECT_CALL(*simple_app_ptr_, hmi_level(kDefaultWindowId)) .WillOnce(Return(mobile_apis::HMILevel::HMI_BACKGROUND)); - EXPECT_CALL(*simple_app_ptr_, RegularHmiState()).Times(0); + EXPECT_CALL(*simple_app_ptr_, RegularHmiState(kDefaultWindowId)).Times(0); + + am::WindowIds window_ids = {kDefaultWindowId}; + EXPECT_CALL(*simple_app_ptr_, GetWindowIds()).WillOnce(Return(window_ids)); + state_ctrl_->on_event(event); } @@ -2969,7 +3099,7 @@ TEST_F(StateControllerImplTest, OnEventOnAppDeactivatedIncorrectApp) { const am::ApplicationSharedPtr incorrect_app; EXPECT_CALL(app_manager_mock_, application(_)) .WillOnce(Return(incorrect_app)); - EXPECT_CALL(*simple_app_ptr_, hmi_level()).Times(0); + EXPECT_CALL(*simple_app_ptr_, hmi_level(kDefaultWindowId)).Times(0); state_ctrl_->on_event(event); } @@ -2990,15 +3120,20 @@ TEST_F(StateControllerImplTest, OnEventOnAppDeactivatedAudioApplication) { EXPECT_CALL(app_manager_mock_, application(app_id)) .WillOnce(Return(simple_app_)); EXPECT_CALL(*simple_app_ptr_, app_id()).WillRepeatedly(Return(app_id)); - EXPECT_CALL(*simple_app_ptr_, hmi_level()) + EXPECT_CALL(*simple_app_ptr_, hmi_level(kDefaultWindowId)) .WillRepeatedly(Return(mobile_apis::HMILevel::HMI_FULL)); // DeactivateApp - EXPECT_CALL(*simple_app_ptr_, RegularHmiState()).WillOnce(Return(state)); + EXPECT_CALL(*simple_app_ptr_, RegularHmiState(kDefaultWindowId)) + .WillOnce(Return(state)); EXPECT_CALL(*simple_app_ptr_, IsAudioApplication()) .WillRepeatedly(Return(true)); - EXPECT_CALL(*simple_app_ptr_, CurrentHmiState()) + EXPECT_CALL(*simple_app_ptr_, CurrentHmiState(kDefaultWindowId)) .WillOnce(Return(BackgroundState())) .WillOnce(Return(BackgroundState())); + + am::WindowIds window_ids = {kDefaultWindowId}; + EXPECT_CALL(*simple_app_ptr_, GetWindowIds()).WillOnce(Return(window_ids)); + state_ctrl_->on_event(event); } @@ -3019,16 +3154,21 @@ TEST_F(StateControllerImplTest, OnEventOnAppDeactivatedNotAudioApplication) { EXPECT_CALL(app_manager_mock_, application(app_id)) .WillOnce(Return(simple_app_)); EXPECT_CALL(*simple_app_ptr_, app_id()).WillRepeatedly(Return(app_id)); - EXPECT_CALL(*simple_app_ptr_, hmi_level()) + EXPECT_CALL(*simple_app_ptr_, hmi_level(kDefaultWindowId)) .WillRepeatedly(Return(mobile_apis::HMILevel::HMI_FULL)); // DeactivateApp - EXPECT_CALL(*simple_app_ptr_, RegularHmiState()).WillOnce(Return(state)); + EXPECT_CALL(*simple_app_ptr_, RegularHmiState(kDefaultWindowId)) + .WillOnce(Return(state)); EXPECT_CALL(*simple_app_ptr_, IsAudioApplication()) .WillRepeatedly(Return(false)); - EXPECT_CALL(*simple_app_ptr_, CurrentHmiState()) + EXPECT_CALL(*simple_app_ptr_, CurrentHmiState(kDefaultWindowId)) .WillOnce(Return(BackgroundState())) .WillOnce(Return(BackgroundState())); + + am::WindowIds window_ids = {kDefaultWindowId}; + EXPECT_CALL(*simple_app_ptr_, GetWindowIds()).WillOnce(Return(window_ids)); + state_ctrl_->on_event(event); } @@ -3048,25 +3188,35 @@ TEST_F(StateControllerImplTest, OnEventOnAppActivatedIncorrectApp) { } TEST_F(StateControllerImplTest, OnEventOnAppActivated) { - using namespace constants; - smart_objects::SmartObject msg; - for (std::vector::const_iterator it = - applications_list_.begin(); + am::WindowIds window_ids = {kDefaultWindowId}; + + for (AppPtrMockMapping::const_iterator it = applications_list_.begin(); it != applications_list_.end(); ++it) { - uint32_t app_id = (*it)->app_id(); + uint32_t app_id = it->first->app_id(); msg[am::strings::msg_params][am::strings::app_id] = app_id; const hmi_apis::FunctionID::eType event_id = hmi_apis::FunctionID::BasicCommunication_OnAppActivated; am::event_engine::Event event(event_id); event.set_smart_object(msg); - EXPECT_CALL(app_manager_mock_, application(app_id)).WillOnce(Return(*it)); + EXPECT_CALL(app_manager_mock_, application(app_id)) + .WillOnce(Return(it->first)); // SetRegularState - EXPECT_CALL(*simple_app_ptr_, app_id()).WillRepeatedly(Return(app_id)); - EXPECT_CALL(*simple_app_ptr_, IsAudioApplication()) - .WillRepeatedly(Return(true)); + EXPECT_CALL(*it->second, app_id()).WillRepeatedly(Return(app_id)); + EXPECT_CALL(*it->second, IsAudioApplication()).WillRepeatedly(Return(true)); + EXPECT_CALL(*it->second, GetWindowIds()).WillOnce(Return(window_ids)); + + const am::HmiStatePtr old_state = + CreateHmiStateByHmiStateType( + mobile_apis::HMILevel::HMI_NONE, + mobile_apis::AudioStreamingState::NOT_AUDIBLE, + mobile_apis::VideoStreamingState::NOT_STREAMABLE, + mobile_apis::SystemContext::SYSCTXT_MAIN, + simple_app_); + EXPECT_CALL(*it->second, RegularHmiState(kDefaultWindowId)) + .WillOnce(Return(old_state)); smart_objects::SmartObjectSPtr activate_app = std::make_shared(); @@ -3147,9 +3297,9 @@ TEST_F(StateControllerImplTest, OnApplicationRegisteredDifferentStates) { simple_app_); EXPECT_CALL(*simple_app_ptr_, app_id()).WillRepeatedly(Return(app_id)); - EXPECT_CALL(*simple_app_ptr_, CurrentHmiState()) + EXPECT_CALL(*simple_app_ptr_, CurrentHmiState(kDefaultWindowId)) .WillRepeatedly(Return(old_state)); - EXPECT_CALL(*simple_app_ptr_, AddHMIState(_)).Times(4); + EXPECT_CALL(*simple_app_ptr_, AddHMIState(kDefaultWindowId, _)).Times(4); const am::HmiStatePtr default_state = CreateHmiStateByHmiStateType( @@ -3159,12 +3309,14 @@ TEST_F(StateControllerImplTest, OnApplicationRegisteredDifferentStates) { mobile_apis::SystemContext::SYSCTXT_MAIN, simple_app_); - EXPECT_CALL(*simple_app_ptr_, RegularHmiState()).WillOnce(Return(old_state)); - EXPECT_CALL(*simple_app_ptr_, CurrentHmiState()) + EXPECT_CALL(*simple_app_ptr_, RegularHmiState(kDefaultWindowId)) + .WillOnce(Return(old_state)); + EXPECT_CALL(*simple_app_ptr_, CurrentHmiState(kDefaultWindowId)) .WillRepeatedly(Return(default_state)); EXPECT_CALL(*simple_app_ptr_, ResetDataInNone()).Times(0); - EXPECT_CALL(app_manager_mock_, SendHMIStatusNotification(_)); + EXPECT_CALL(message_helper_mock_, + SendHMIStatusNotification(simple_app_, kDefaultWindowId, _)); EXPECT_CALL(app_manager_mock_, OnHMILevelChanged(_, _, _)); state_ctrl_->OnApplicationRegistered(simple_app_, @@ -3198,9 +3350,9 @@ TEST_F(StateControllerImplTest, OnApplicationRegisteredEqualStates) { simple_app_); EXPECT_CALL(*simple_app_ptr_, app_id()).WillRepeatedly(Return(app_id)); - EXPECT_CALL(*simple_app_ptr_, CurrentHmiState()) + EXPECT_CALL(*simple_app_ptr_, CurrentHmiState(kDefaultWindowId)) .WillRepeatedly(Return(old_state)); - EXPECT_CALL(*simple_app_ptr_, AddHMIState(_)).Times(2); + EXPECT_CALL(*simple_app_ptr_, AddHMIState(kDefaultWindowId, _)).Times(2); const am::HmiStatePtr default_state = CreateHmiStateByHmiStateType( @@ -3209,9 +3361,9 @@ TEST_F(StateControllerImplTest, OnApplicationRegisteredEqualStates) { mobile_apis::VideoStreamingState::NOT_STREAMABLE, mobile_apis::SystemContext::SYSCTXT_MAIN, simple_app_); - EXPECT_CALL(*simple_app_ptr_, RegularHmiState()) + EXPECT_CALL(*simple_app_ptr_, RegularHmiState(kDefaultWindowId)) .WillOnce(Return(default_state)); - EXPECT_CALL(*simple_app_ptr_, CurrentHmiState()) + EXPECT_CALL(*simple_app_ptr_, CurrentHmiState(kDefaultWindowId)) .WillRepeatedly(Return(default_state)); EXPECT_CALL(*simple_app_ptr_, ResetDataInNone()).Times(0); @@ -3222,6 +3374,328 @@ TEST_F(StateControllerImplTest, OnApplicationRegisteredEqualStates) { mobile_apis::HMILevel::HMI_BACKGROUND); } +TEST_F( + StateControllerImplTest, + SetRegularState_AppIsResumingAndAudioSourceIsActive_HmiStateIsNotChanged) { + am::event_engine::Event audio_source_event( + hmi_apis::FunctionID::BasicCommunication_OnEventChanged); + smart_objects::SmartObject message; + message[am::strings::msg_params][am::hmi_notification::is_active] = true; + message[am::strings::msg_params][am::hmi_notification::event_name] = + hmi_apis::Common_EventTypes::AUDIO_SOURCE; + audio_source_event.set_smart_object(message); + state_ctrl_->on_event(audio_source_event); + + EXPECT_CALL(*media_app_ptr_, is_resuming()).WillRepeatedly(Return(true)); + EXPECT_CALL(*media_app_ptr_, SetRegularState(_, _)).Times(0); + + const am::HmiStatePtr new_state = FullAudibleState(); + const bool send_activate_app = true; + state_ctrl_->SetRegularState( + media_app_, kDefaultWindowId, new_state, send_activate_app); +} + +TEST_F(StateControllerImplTest, + SetRegularState_BcActivateAppSendFailed_HmiLevelIsNotChanged) { + const am::HmiStatePtr new_state = FullAudibleState(); + SetBCActivateAppRequestToHMI( + static_cast(new_state->hmi_level()), + kCorrID); + + smart_objects::SmartObjectSPtr bc_activate_app_request; + EXPECT_CALL(message_helper_mock_, GetBCActivateAppRequestToHMI(_, _, _, _, _)) + .WillOnce(Return(bc_activate_app_request)); + EXPECT_CALL(*simple_app_ptr_, SetRegularState(_, _)).Times(0); + + const bool send_activate_app = true; + state_ctrl_->SetRegularState( + simple_app_, kDefaultWindowId, new_state, send_activate_app); +} + +TEST_F(StateControllerImplTest, + SetRegularState_SetLevelAudioAndVideoState_HmiStateIsChanged) { + HmiStatePtr old_state = NoneNotAudibleState(); + HmiStatePtr new_state = BackgroundState(); + + EXPECT_CALL(*simple_app_ptr_, RegularHmiState(kDefaultWindowId)) + .WillOnce(Return(old_state)); + ExpectSuccessfulSetHmiState( + simple_app_, simple_app_ptr_, old_state, new_state); + + const bool send_activate_app = false; + state_ctrl_->SetRegularState(simple_app_, + kDefaultWindowId, + new_state->hmi_level(), + new_state->audio_streaming_state(), + new_state->video_streaming_state(), + send_activate_app); +} + +TEST_F(StateControllerImplTest, + SetRegularState_SetLevelAudioVideoStatesAndContext_HmiStateIsChanged) { + HmiStatePtr old_state = NoneNotAudibleState(); + HmiStatePtr new_state = BackgroundState(); + + EXPECT_CALL(*simple_app_ptr_, RegularHmiState(kDefaultWindowId)) + .WillOnce(Return(old_state)); + ExpectSuccessfulSetHmiState( + simple_app_, simple_app_ptr_, old_state, new_state); + + const bool send_activate_app = false; + state_ctrl_->SetRegularState(simple_app_, + kDefaultWindowId, + new_state->hmi_level(), + new_state->audio_streaming_state(), + new_state->video_streaming_state(), + new_state->system_context(), + send_activate_app); +} + +TEST_F(StateControllerImplTest, + SetRegularState_SetSystemContextOnly_HmiStateIsChanged) { + HmiStatePtr old_state = FullAudibleState(); + HmiStatePtr new_state = FullNotAudibleState(); + + EXPECT_CALL(*simple_app_ptr_, RegularHmiState(kDefaultWindowId)) + .WillOnce(Return(old_state)); + ExpectSuccessfulSetHmiState( + simple_app_, simple_app_ptr_, old_state, new_state); + + state_ctrl_->SetRegularState( + simple_app_, kDefaultWindowId, new_state->system_context()); +} + +TEST_F(StateControllerImplTest, + OnAppActivated_ActivateNotExistingWindow_HmiLevelIsNotChanged) { + InsertApplication(simple_app_); + + am::event_engine::Event activate_widget_event( + hmi_apis::FunctionID::BasicCommunication_OnAppActivated); + smart_objects::SmartObject message; + message[am::strings::msg_params][am::strings::app_id] = simple_app_id_; + message[am::strings::msg_params][am::strings::window_id] = kCustomWindowId; + activate_widget_event.set_smart_object(message); + + const am::WindowIds window_ids = {kDefaultWindowId}; + ON_CALL(*simple_app_ptr_, GetWindowIds()).WillByDefault(Return(window_ids)); + + ExpectAppWontChangeHmiStateDueToConflictResolving( + simple_app_, simple_app_ptr_, kCustomWindowId, NoneNotAudibleState()); + + state_ctrl_->on_event(activate_widget_event); +} + +TEST_F(StateControllerImplTest, + OnAppActivated_ActivateCustomWindow_HmiStateIsChanged) { + InsertApplication(simple_app_); + + am::event_engine::Event activate_widget_event( + hmi_apis::FunctionID::BasicCommunication_OnAppActivated); + smart_objects::SmartObject message; + message[am::strings::msg_params][am::strings::app_id] = simple_app_id_; + message[am::strings::msg_params][am::strings::window_id] = kCustomWindowId; + activate_widget_event.set_smart_object(message); + + const am::WindowIds window_ids = {kDefaultWindowId, kCustomWindowId}; + ON_CALL(*simple_app_ptr_, GetWindowIds()).WillByDefault(Return(window_ids)); + + std::vector > states_transition = { + std::make_pair(NoneNotAudibleState(), BackgroundState()), + std::make_pair(BackgroundState(), FullNotAudibleState())}; + + for (auto& states_pair : states_transition) { + HmiStatePtr old_state = states_pair.first; + HmiStatePtr new_state = states_pair.second; + + EXPECT_CALL(*simple_app_ptr_, hmi_level(kCustomWindowId)) + .WillOnce(Return(old_state->hmi_level())); + EXPECT_CALL(*simple_app_ptr_, audio_streaming_state()) + .WillOnce(Return(old_state->audio_streaming_state())); + EXPECT_CALL(*simple_app_ptr_, video_streaming_state()) + .WillOnce(Return(old_state->video_streaming_state())); + + EXPECT_CALL(*simple_app_ptr_, RegularHmiState(kCustomWindowId)) + .WillOnce(Return(old_state)); + ExpectSuccessfulSetHmiState( + simple_app_, simple_app_ptr_, kCustomWindowId, old_state, new_state); + + EXPECT_CALL(message_helper_mock_, + GetBCActivateAppRequestToHMI(_, _, _, _, _)) + .Times(0); + + state_ctrl_->on_event(activate_widget_event); + } +} + +TEST_F(StateControllerImplTest, + OnAppDeactivated_DeactivateNotExistingWindow_HmiStateIsNotChanged) { + InsertApplication(simple_app_); + + am::event_engine::Event activate_widget_event( + hmi_apis::FunctionID::BasicCommunication_OnAppDeactivated); + smart_objects::SmartObject message; + message[am::strings::msg_params][am::strings::app_id] = simple_app_id_; + message[am::strings::msg_params][am::strings::window_id] = kCustomWindowId; + activate_widget_event.set_smart_object(message); + + const am::WindowIds window_ids = {kDefaultWindowId}; + ON_CALL(*simple_app_ptr_, GetWindowIds()).WillByDefault(Return(window_ids)); + + ExpectAppWontChangeHmiStateDueToConflictResolving( + simple_app_, simple_app_ptr_, kCustomWindowId, FullNotAudibleState()); + + state_ctrl_->on_event(activate_widget_event); +} + +TEST_F(StateControllerImplTest, + OnAppDeactivated_DeactivateCustomWindow_HmiStateIsChanged) { + InsertApplication(simple_app_); + + am::event_engine::Event activate_widget_event( + hmi_apis::FunctionID::BasicCommunication_OnAppDeactivated); + smart_objects::SmartObject message; + message[am::strings::msg_params][am::strings::app_id] = simple_app_id_; + message[am::strings::msg_params][am::strings::window_id] = kCustomWindowId; + activate_widget_event.set_smart_object(message); + + const am::WindowIds window_ids = {kDefaultWindowId, kCustomWindowId}; + ON_CALL(*simple_app_ptr_, GetWindowIds()).WillByDefault(Return(window_ids)); + + std::vector > states_transition = { + std::make_pair(FullNotAudibleState(), BackgroundState()), + std::make_pair(BackgroundState(), NoneNotAudibleState())}; + + for (auto& states_pair : states_transition) { + HmiStatePtr old_state = states_pair.first; + HmiStatePtr new_state = states_pair.second; + + EXPECT_CALL(*simple_app_ptr_, hmi_level(kCustomWindowId)) + .WillOnce(Return(old_state->hmi_level())); + EXPECT_CALL(*simple_app_ptr_, audio_streaming_state()) + .WillOnce(Return(old_state->audio_streaming_state())); + EXPECT_CALL(*simple_app_ptr_, video_streaming_state()) + .WillOnce(Return(old_state->video_streaming_state())); + + EXPECT_CALL(*simple_app_ptr_, RegularHmiState(kCustomWindowId)) + .WillOnce(Return(old_state)); + ExpectSuccessfulSetHmiState( + simple_app_, simple_app_ptr_, kCustomWindowId, old_state, new_state); + + EXPECT_CALL(message_helper_mock_, + GetBCActivateAppRequestToHMI(_, _, _, _, _)) + .Times(0); + + state_ctrl_->on_event(activate_widget_event); + } +} + +TEST_F( + StateControllerImplTest, + ActivateDefaultWindow_AppWithWindowWasActivated_WindowStreamingStateIsUpdated) { + HmiStatePtr old_state = NoneNotAudibleState(); + HmiStatePtr new_state = FullAudibleState(); + + EXPECT_CALL(*media_app_ptr_, RegularHmiState(kDefaultWindowId)) + .WillOnce(Return(old_state)) + .WillRepeatedly(Return(new_state)); + ExpectSuccessfulSetHmiState( + media_app_, media_app_ptr_, kDefaultWindowId, old_state, new_state); + + const am::WindowIds window_ids = {kDefaultWindowId, kCustomWindowId}; + ON_CALL(*media_app_ptr_, GetWindowIds()).WillByDefault(Return(window_ids)); + + EXPECT_CALL(*media_app_ptr_, RegularHmiState(kCustomWindowId)) + .WillOnce(Return(old_state)); + + HmiStatePtr expected_window_state = NoneNotAudibleState(); + expected_window_state->set_audio_streaming_state( + new_state->audio_streaming_state()); + expected_window_state->set_video_streaming_state( + new_state->video_streaming_state()); + + EXPECT_CALL( + *media_app_ptr_, + SetRegularState(kCustomWindowId, + Truly(HmiStatesComparator(expected_window_state)))); + EXPECT_CALL(message_helper_mock_, + SendHMIStatusNotification(media_app_, kCustomWindowId, _)); + + state_ctrl_->ActivateDefaultWindow(media_app_); +} + +TEST_F(StateControllerImplTest, + ExitDefaultWindow_AppWithWindowWasExited_WindowStreamingStateIsUpdated) { + HmiStatePtr old_state = FullAudibleState(); + HmiStatePtr new_state = NoneNotAudibleState(); + + EXPECT_CALL(*media_app_ptr_, RegularHmiState(kDefaultWindowId)) + .WillOnce(Return(old_state)) + .WillRepeatedly(Return(new_state)); + ExpectSuccessfulSetHmiState( + media_app_, media_app_ptr_, kDefaultWindowId, old_state, new_state); + + const am::WindowIds window_ids = {kDefaultWindowId, kCustomWindowId}; + ON_CALL(*media_app_ptr_, GetWindowIds()).WillByDefault(Return(window_ids)); + + EXPECT_CALL(*media_app_ptr_, RegularHmiState(kCustomWindowId)) + .WillOnce(Return(old_state)); + + HmiStatePtr expected_window_state = FullAudibleState(); + expected_window_state->set_audio_streaming_state( + new_state->audio_streaming_state()); + expected_window_state->set_video_streaming_state( + new_state->video_streaming_state()); + + EXPECT_CALL( + *media_app_ptr_, + SetRegularState(kCustomWindowId, + Truly(HmiStatesComparator(expected_window_state)))); + EXPECT_CALL(message_helper_mock_, + SendHMIStatusNotification(media_app_, kCustomWindowId, _)); + + state_ctrl_->ExitDefaultWindow(media_app_); +} + +TEST_F(StateControllerImplTest, + OnAppWindowAdded_NewAppWindowWasAdded_HmiNotificationIsSent) { + am::event_engine::Event audio_source_event( + hmi_apis::FunctionID::BasicCommunication_OnEventChanged); + smart_objects::SmartObject message; + message[am::strings::msg_params][am::hmi_notification::is_active] = true; + message[am::strings::msg_params][am::hmi_notification::event_name] = + hmi_apis::Common_EventTypes::AUDIO_SOURCE; + audio_source_event.set_smart_object(message); + state_ctrl_->on_event(audio_source_event); + + HmiStatePtr initial_state = + createHmiState(mobile_apis::HMILevel::INVALID_ENUM, + mobile_apis::AudioStreamingState::INVALID_ENUM, + mobile_apis::VideoStreamingState::INVALID_ENUM, + mobile_apis::SystemContext::INVALID_ENUM); + HmiStatePtr expected_state = NoneNotAudibleState(); + + EXPECT_CALL(*simple_app_ptr_, + AddHMIState(kCustomWindowId, + Truly(HmiStatesIDComparator( + HmiState::StateID::STATE_ID_AUDIO_SOURCE)))); + EXPECT_CALL(*simple_app_ptr_, RegularHmiState(kCustomWindowId)) + .WillOnce(Return(initial_state)); + EXPECT_CALL(*simple_app_ptr_, + SetRegularState(kCustomWindowId, + Truly(HmiStatesComparator(expected_state)))); + EXPECT_CALL(*simple_app_ptr_, CurrentHmiState(kCustomWindowId)) + .WillOnce(Return(initial_state)) + .WillOnce(Return(expected_state)); + EXPECT_CALL(message_helper_mock_, + SendHMIStatusNotification(simple_app_, kCustomWindowId, _)); + EXPECT_CALL(app_manager_mock_, OnHMILevelChanged(_, _, _)).Times(0); + + state_ctrl_->OnAppWindowAdded(simple_app_, + kCustomWindowId, + mobile_apis::WindowType::WIDGET, + mobile_apis::HMILevel::HMI_NONE); +} + } // namespace state_controller_test } // namespace components } // namespace test diff --git a/src/components/application_manager/test/usage_statistics_test.cc b/src/components/application_manager/test/usage_statistics_test.cc index dfc694f3c50..b494afb68ee 100644 --- a/src/components/application_manager/test/usage_statistics_test.cc +++ b/src/components/application_manager/test/usage_statistics_test.cc @@ -33,9 +33,9 @@ #include "application_manager/usage_statistics.h" #include #include "gmock/gmock.h" -#include "smart_objects/enum_schema_item.h" -#include "policy/usage_statistics/mock_statistics_manager.h" #include "policy/usage_statistics/mock_app_stopwatch.h" +#include "policy/usage_statistics/mock_statistics_manager.h" +#include "smart_objects/enum_schema_item.h" namespace test { namespace components { diff --git a/src/components/application_manager/test/zero_request_amount_test.cc b/src/components/application_manager/test/zero_request_amount_test.cc index 640a186e2bd..0166c036c15 100644 --- a/src/components/application_manager/test/zero_request_amount_test.cc +++ b/src/components/application_manager/test/zero_request_amount_test.cc @@ -30,19 +30,19 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include #include +#include #include "gtest/gtest.h" -#include "application_manager/request_controller.h" -#include "application_manager/commands/command_request_impl.h" #include "application_manager/application_manager_impl.h" -#include "application_manager/message_helper.h" +#include "application_manager/commands/command_request_impl.h" #include "application_manager/commands/mobile/put_file_request.h" #include "application_manager/commands/mobile/register_app_interface_request.h" #include "application_manager/commands/mobile/unregister_app_interface_request.h" -#include "smart_objects/smart_object.h" +#include "application_manager/message_helper.h" +#include "application_manager/request_controller.h" #include "interfaces/MOBILE_API.h" +#include "smart_objects/smart_object.h" namespace test { namespace components { diff --git a/src/components/config_profile/include/config_profile/profile.h b/src/components/config_profile/include/config_profile/profile.h index ba43ec9695a..5489a962e88 100644 --- a/src/components/config_profile/include/config_profile/profile.h +++ b/src/components/config_profile/include/config_profile/profile.h @@ -34,18 +34,18 @@ #define SRC_COMPONENTS_CONFIG_PROFILE_INCLUDE_CONFIG_PROFILE_PROFILE_H_ #include -#include -#include #include #include -#include "utils/macro.h" -#include "protocol_handler/protocol_handler_settings.h" +#include +#include +#include "application_manager/application_manager_settings.h" #include "connection_handler/connection_handler_settings.h" #include "hmi_message_handler/hmi_message_handler_settings.h" #include "media_manager/media_manager_settings.h" -#include "transport_manager/transport_manager_settings.h" -#include "application_manager/application_manager_settings.h" #include "policy/policy_settings.h" +#include "protocol_handler/protocol_handler_settings.h" +#include "transport_manager/transport_manager_settings.h" +#include "utils/macro.h" namespace profile { @@ -85,23 +85,23 @@ class Profile : public protocol_handler::ProtocolHandlerSettings, const std::string& sdl_version() const OVERRIDE; /** - * @brief Returns true if HMI should be started, otherwise false - */ + * @brief Returns true if HMI should be started, otherwise false + */ bool launch_hmi() const OVERRIDE; #ifdef WEB_HMI /** - * @brief Returns link to web hmi - */ + * @brief Returns link to web hmi + */ std::string link_to_web_hmi() const; #endif // WEB_HMI /** - * @brief Returns application configuration path - */ + * @brief Returns application configuration path + */ const std::string& app_config_folder() const; /** - * @brief Returns application storage path - */ + * @brief Returns application storage path + */ const std::string& app_storage_folder() const; /** @@ -110,24 +110,24 @@ 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 - */ + * @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 - */ + * @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 - */ + * @brief Returns offset from SIGRTMIN for user defined signal + * SIGIGNITIONOFF + * which is used for handling LOW Voltage functionality + */ int ignition_off_signal_offset() const; /** @@ -202,8 +202,8 @@ class Profile : public protocol_handler::ProtocolHandlerSettings, uint32_t stop_streaming_timeout() const; /** - * @brief Returns port for time reports - */ + * @brief Returns port for time reports + */ const uint16_t& time_testing_port() const; /** @@ -228,8 +228,8 @@ class Profile : public protocol_handler::ProtocolHandlerSettings, const std::vector& vr_commands() const; /** - * @brief Returns folder containing all plugins - */ + * @brief Returns folder containing all plugins + */ const std::string& plugins_folder() const OVERRIDE; /** @@ -254,38 +254,38 @@ class Profile : public protocol_handler::ProtocolHandlerSettings, const uint64_t thread_min_stack_size() const; /** - * @brief Returns true if audio mixing is supported - */ + * @brief Returns true if audio mixing is supported + */ bool is_mixing_audio_supported() const; /** - * @brief Returns true if video re-decoding enabled - */ + * @brief Returns true if video re-decoding enabled + */ bool is_redecoding_enabled() const; /** - * @brief Returns title for Vr Help - */ + * @brief Returns title for Vr Help + */ const std::string& vr_help_title() const; /** - * @brief Returns application directory quota size - */ + * @brief Returns application directory quota size + */ const uint32_t& app_dir_quota() const; /** - * @brief Returns the video server type - */ + * @brief Returns the video server type + */ const std::string& video_server_type() const; /** - * @brief Returns the audio server type - */ + * @brief Returns the audio server type + */ const std::string& audio_server_type() const; /** - * @brief Returns the video pipe path - */ + * @brief Returns the video pipe path + */ const std::string& named_video_pipe_path() const; /** @@ -300,13 +300,13 @@ class Profile : public protocol_handler::ProtocolHandlerSettings, const uint32_t& app_hmi_level_none_time_scale() const; /** - * @brief Returns path to testing file to which redirects video stream - */ + * @brief Returns path to testing file to which redirects video stream + */ const std::string& video_stream_file() const; /** - * @brief Returns path to testing file to which redirects audio stream - */ + * @brief Returns path to testing file to which redirects audio stream + */ const std::string& audio_stream_file() const; /** @@ -423,6 +423,15 @@ class Profile : public protocol_handler::ProtocolHandlerSettings, */ uint16_t cloud_app_max_retry_attempts() const OVERRIDE; + const uint8_t* bluetooth_uuid() const OVERRIDE; + + const std::string& aoa_filter_manufacturer() const OVERRIDE; + const std::string& aoa_filter_model_name() const OVERRIDE; + const std::string& aoa_filter_description() const OVERRIDE; + const std::string& aoa_filter_version() const OVERRIDE; + const std::string& aoa_filter_uri() const OVERRIDE; + const std::string& aoa_filter_serial_number() const OVERRIDE; + // TransportManageMMESettings interface const std::string& event_mq_name() const OVERRIDE; @@ -452,8 +461,8 @@ class Profile : public protocol_handler::ProtocolHandlerSettings, const std::vector& supported_diag_modes() const OVERRIDE; /** - * @brief Returns system files folder path - */ + * @brief Returns system files folder path + */ const std::string& system_files_path() const OVERRIDE; /** @@ -527,6 +536,11 @@ class Profile : public protocol_handler::ProtocolHandlerSettings, const std::vector& video_service_transports() const OVERRIDE; uint32_t rpc_pass_through_timeout() const OVERRIDE; + + // RcConsentManager + uint16_t period_for_consent_expiration() const OVERRIDE; + // RcConsentManager end + const std::vector& embedded_services() const OVERRIDE; const std::string hmi_origin_id() const OVERRIDE; /** @@ -610,6 +624,10 @@ class Profile : public protocol_handler::ProtocolHandlerSettings, const char* const pKey, bool* out_result) const; + std::vector ReadUint8Container(const char* const pSection, + const char* const pKey, + bool* out_result) const; + /** * @brief Returns delimiter for SDL-generated TTS chunks * @return TTS delimiter @@ -750,9 +768,9 @@ class Profile : public protocol_handler::ProtocolHandlerSettings, const bool enable_app_launch_ios() const OVERRIDE; /** - * @brief Returns the millisecond count before timeout - * for transport change feature occures. - */ + * @brief Returns the millisecond count before timeout + * for transport change feature occures. + */ uint32_t app_transport_change_timer() const OVERRIDE; /** @@ -975,6 +993,13 @@ class Profile : public protocol_handler::ProtocolHandlerSettings, std::string transport_manager_tcp_adapter_network_interface_; uint32_t cloud_app_retry_timeout_; uint16_t cloud_app_max_retry_attempts_; + std::vector bluetooth_uuid_; + std::string aoa_filter_manufacturer_; + std::string aoa_filter_model_name_; + std::string aoa_filter_description_; + std::string aoa_filter_version_; + std::string aoa_filter_uri_; + std::string aoa_filter_serial_number_; std::string tts_delimiter_; uint32_t audio_data_stopped_timeout_; uint32_t video_data_stopped_timeout_; @@ -1067,6 +1092,7 @@ class Profile : public protocol_handler::ProtocolHandlerSettings, int wake_up_signal_offset_; int ignition_off_signal_offset_; uint32_t rpc_pass_through_timeout_; + uint16_t period_for_consent_expiration_; std::vector embedded_services_; diff --git a/src/components/config_profile/src/ini_file.cc b/src/components/config_profile/src/ini_file.cc index 3245b096cbc..024c75de3e0 100644 --- a/src/components/config_profile/src/ini_file.cc +++ b/src/components/config_profile/src/ini_file.cc @@ -31,13 +31,13 @@ */ #include "config_profile/ini_file.h" -#include -#include -#include -#include #include +#include #include #include +#include +#include +#include #include "utils/logger.h" @@ -157,7 +157,7 @@ char ini_write_value(const char* fname, const char* item, const char* value, uint8_t flag) { - FILE* rd_fp, * wr_fp = 0; + FILE *rd_fp, *wr_fp = 0; uint16_t i, cr_count; int32_t wr_result; bool chapter_found = false; diff --git a/src/components/config_profile/src/profile.cc b/src/components/config_profile/src/profile.cc index e5a32f45605..dd0dc50f447 100644 --- a/src/components/config_profile/src/profile.cc +++ b/src/components/config_profile/src/profile.cc @@ -33,18 +33,18 @@ #include "config_profile/profile.h" #include -#include -#include #include -#include +#include #include +#include +#include #include #include "config_profile/ini_file.h" +#include "utils/file_system.h" #include "utils/logger.h" #include "utils/threads/thread.h" -#include "utils/file_system.h" #ifdef ENABLE_SECURITY #include @@ -97,6 +97,7 @@ const char* kTransportRequiredForResumptionSection = const char* kLowBandwidthTransportResumptionLevelSection = "LowBandwidthTransportResumptionLevel"; const char* kAppServicesSection = "AppServices"; +const char* kRCModuleConsentSection = "RCModuleConsent"; const char* kSDLVersionKey = "SDLVersion"; const char* kHmiCapabilitiesKey = "HMICapabilities"; @@ -184,6 +185,13 @@ const char* kAppHmiLevelNoneRequestsTimeScaleKey = const char* kPendingRequestsAmoundKey = "PendingRequestsAmount"; const char* kSupportedDiagModesKey = "SupportedDiagModes"; const char* kTransportManagerDisconnectTimeoutKey = "DisconnectTimeout"; +const char* kBluetoothUUIDKey = "BluetoothUUID"; +const char* kAOAFilterManufacturerKey = "AOAFilterManufacturer"; +const char* kAOAFilterModelNameKey = "AOAFilterModelName"; +const char* kAOAFilterDescriptionKey = "AOAFilterDescription"; +const char* kAOAFilterVersionKey = "AOAFilterVersion"; +const char* kAOAFilterURIKey = "AOAFilterURI"; +const char* kAOAFilterSerialNumber = "AOAFilterSerialNumber"; const char* kTTSDelimiterKey = "TTSDelimiter"; const char* kRecordingFileNameKey = "RecordingFileName"; const char* kRecordingFileSourceKey = "RecordingFileSource"; @@ -240,6 +248,7 @@ const char* kSecondaryTransportForWiFiKey = "SecondaryTransportForWiFi"; const char* kAudioServiceTransportsKey = "AudioServiceTransports"; const char* kVideoServiceTransportsKey = "VideoServiceTransports"; const char* kRpcPassThroughTimeoutKey = "RpcPassThroughTimeout"; +const char* kPeriodForConsentExpirationKey = "PeriodForConsentExpiration"; const char* kDefaultTransportRequiredForResumptionKey = "DefaultTransportRequiredForResumption"; @@ -396,7 +405,30 @@ const std::string kAllowedSymbols = const bool kDefaultMultipleTransportsEnabled = false; const char* kDefaultLowBandwidthResumptionLevel = "NONE"; const uint32_t kDefaultRpcPassThroughTimeout = 10000; +const uint16_t kDefaultPeriodForConsentExpiration = 30; const char* kDefaultHMIOriginId = "HMI_ID"; +const std::vector kDefaultBluetoothUUID = {0x93, + 0x6D, + 0xA0, + 0x1F, + 0x9A, + 0xBD, + 0x4D, + 0x9D, + 0x80, + 0xC7, + 0x02, + 0xAF, + 0x85, + 0xC8, + 0x22, + 0xA8}; +const char* kDefaultAOAFilterManufacturer = "SDL"; +const char* kDefaultAOAFilterModelName = "Core"; +const char* kDefaultAOAFilterDescription = "SmartDeviceLink Core Component USB"; +const char* kDefaultAOAFilterVersion = "1.0"; +const char* kDefaultAOAFilterURI = "http://www.smartdevicelink.org"; +const char* kDefaultAOAFilterSerialNumber = "N000000"; } // namespace namespace profile { @@ -513,7 +545,8 @@ Profile::Profile() , low_voltage_signal_offset_(kDefaultLowVoltageSignalOffset) , wake_up_signal_offset_(kDefaultWakeUpSignalOffset) , ignition_off_signal_offset_(kDefaultIgnitionOffSignalOffset) - , rpc_pass_through_timeout_(kDefaultRpcPassThroughTimeout) { + , rpc_pass_through_timeout_(kDefaultRpcPassThroughTimeout) + , period_for_consent_expiration_(kDefaultPeriodForConsentExpiration) { // SDL version ReadStringValue( &sdl_version_, kDefaultSDLVersion, kMainSection, kSDLVersionKey); @@ -806,6 +839,34 @@ uint16_t Profile::cloud_app_max_retry_attempts() const { return cloud_app_max_retry_attempts_; } +const uint8_t* Profile::bluetooth_uuid() const { + return bluetooth_uuid_.data(); +} + +const std::string& Profile::aoa_filter_manufacturer() const { + return aoa_filter_manufacturer_; +} + +const std::string& Profile::aoa_filter_model_name() const { + return aoa_filter_model_name_; +} + +const std::string& Profile::aoa_filter_description() const { + return aoa_filter_description_; +} + +const std::string& Profile::aoa_filter_version() const { + return aoa_filter_version_; +} + +const std::string& Profile::aoa_filter_uri() const { + return aoa_filter_uri_; +} + +const std::string& Profile::aoa_filter_serial_number() const { + return aoa_filter_serial_number_; +} + const std::string& Profile::tts_delimiter() const { return tts_delimiter_; } @@ -1089,6 +1150,10 @@ uint32_t Profile::rpc_pass_through_timeout() const { return rpc_pass_through_timeout_; } +uint16_t Profile::period_for_consent_expiration() const { + return period_for_consent_expiration_; +} + const std::vector& Profile::secondary_transports_for_bluetooth() const { return secondary_transports_for_bluetooth_; @@ -1821,6 +1886,64 @@ void Profile::UpdateValues() { kCloudAppMaxRetryAttemptsKey, kCloudAppTransportSection); + bool read_result = true; + bluetooth_uuid_ = ReadUint8Container( + kTransportManagerSection, kBluetoothUUIDKey, &read_result); + if (!read_result || bluetooth_uuid_.size() != 16) { + bluetooth_uuid_ = kDefaultBluetoothUUID; + } + + ReadStringValue(&aoa_filter_manufacturer_, + kDefaultAOAFilterManufacturer, + kTransportManagerSection, + kAOAFilterManufacturerKey); + + LOG_UPDATED_VALUE(aoa_filter_manufacturer_, + kAOAFilterManufacturerKey, + kTransportManagerSection); + + ReadStringValue(&aoa_filter_model_name_, + kDefaultAOAFilterModelName, + kTransportManagerSection, + kAOAFilterModelNameKey); + + LOG_UPDATED_VALUE( + aoa_filter_model_name_, kAOAFilterModelNameKey, kTransportManagerSection); + + ReadStringValue(&aoa_filter_description_, + kDefaultAOAFilterDescription, + kTransportManagerSection, + kAOAFilterDescriptionKey); + + LOG_UPDATED_VALUE(aoa_filter_description_, + kAOAFilterDescriptionKey, + kTransportManagerSection); + + ReadStringValue(&aoa_filter_version_, + kDefaultAOAFilterVersion, + kTransportManagerSection, + kAOAFilterVersionKey); + + LOG_UPDATED_VALUE( + aoa_filter_version_, kAOAFilterVersionKey, kTransportManagerSection); + + ReadStringValue(&aoa_filter_uri_, + kDefaultAOAFilterURI, + kTransportManagerSection, + kAOAFilterURIKey); + + LOG_UPDATED_VALUE( + aoa_filter_uri_, kAOAFilterURIKey, kTransportManagerSection); + + ReadStringValue(&aoa_filter_serial_number_, + kDefaultAOAFilterSerialNumber, + kTransportManagerSection, + kAOAFilterSerialNumber); + + LOG_UPDATED_VALUE(aoa_filter_serial_number_, + kAOAFilterSerialNumber, + kTransportManagerSection); + // Event MQ ReadStringValue( &event_mq_name_, kDefaultEventMQ, kTransportManagerSection, kEventMQKey); @@ -2263,6 +2386,15 @@ void Profile::UpdateValues() { kRpcPassThroughTimeoutKey, kAppServicesSection); + ReadUIntValue(&period_for_consent_expiration_, + kDefaultPeriodForConsentExpiration, + kRCModuleConsentSection, + kPeriodForConsentExpirationKey); + + LOG_UPDATED_VALUE(period_for_consent_expiration_, + kPeriodForConsentExpirationKey, + kRCModuleConsentSection); + { // Secondary Transports and ServicesMap struct KeyPair { std::vector* ini_vector; @@ -2449,6 +2581,10 @@ int32_t hex_to_int(const std::string& value) { return static_cast(strtol(value.c_str(), NULL, 16)); } +uint8_t hex_to_uint8(const std::string& value) { + return static_cast(strtol(value.c_str(), NULL, 16)); +} + std::string trim_string(const std::string& str) { const char* delims = " \t"; @@ -2460,7 +2596,7 @@ std::string trim_string(const std::string& str) { return str.substr(start, end - start + 1); } -} +} // namespace std::vector Profile::ReadIntContainer(const char* const pSection, const char* const pKey, @@ -2474,6 +2610,18 @@ std::vector Profile::ReadIntContainer(const char* const pSection, return value_list; } +std::vector Profile::ReadUint8Container(const char* const pSection, + const char* const pKey, + bool* out_result) const { + const std::vector string_list = + ReadStringContainer(pSection, pKey, out_result); + std::vector value_list; + value_list.resize(string_list.size()); + std::transform( + string_list.begin(), string_list.end(), value_list.begin(), hex_to_uint8); + return value_list; +} + std::vector Profile::ReadStringContainer( const char* const pSection, const char* const pKey, diff --git a/src/components/config_profile/test/ini_file_test.cc b/src/components/config_profile/test/ini_file_test.cc index 0443f061a25..ca4f2fc8494 100644 --- a/src/components/config_profile/test/ini_file_test.cc +++ b/src/components/config_profile/test/ini_file_test.cc @@ -30,8 +30,8 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include "gtest/gtest.h" #include "config_profile/ini_file.h" +#include "gtest/gtest.h" #include "utils/file_system.h" namespace test { diff --git a/src/components/config_profile/test/profile_test.cc b/src/components/config_profile/test/profile_test.cc index 64bafdd6bf5..6dc04344406 100644 --- a/src/components/config_profile/test/profile_test.cc +++ b/src/components/config_profile/test/profile_test.cc @@ -33,8 +33,8 @@ #include #include -#include "gtest/gtest.h" #include "config_profile/profile.h" +#include "gtest/gtest.h" #include "utils/file_system.h" #include "utils/threads/thread.h" diff --git a/src/components/connection_handler/include/connection_handler/connection.h b/src/components/connection_handler/include/connection_handler/connection.h index 4f900bb65ec..7e4ab6a24e2 100644 --- a/src/components/connection_handler/include/connection_handler/connection.h +++ b/src/components/connection_handler/include/connection_handler/connection.h @@ -36,12 +36,12 @@ #include #include -#include "utils/lock.h" -#include "utils/threads/thread.h" #include "connection_handler/device.h" #include "connection_handler/heartbeat_monitor.h" #include "protocol/service_type.h" #include "protocol_handler/protocol_packet.h" +#include "utils/lock.h" +#include "utils/threads/thread.h" #ifdef ENABLE_SECURITY namespace security_manager { 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 06eb4f232d8..b7b791a5c10 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 @@ -33,26 +33,26 @@ #ifndef SRC_COMPONENTS_CONNECTION_HANDLER_INCLUDE_CONNECTION_HANDLER_CONNECTION_HANDLER_IMPL_H_ #define SRC_COMPONENTS_CONNECTION_HANDLER_INCLUDE_CONNECTION_HANDLER_CONNECTION_HANDLER_IMPL_H_ -#include #include +#include #include #include -#include "transport_manager/transport_manager_listener_empty.h" -#include "protocol_handler/session_observer.h" -#include "protocol_handler/protocol_handler.h" +#include "connection_handler/connection.h" +#include "connection_handler/connection_handler.h" #include "connection_handler/connection_handler_observer.h" #include "connection_handler/device.h" -#include "connection_handler/connection.h" #include "connection_handler/devices_discovery_starter.h" -#include "connection_handler/connection_handler.h" +#include "protocol_handler/protocol_handler.h" +#include "protocol_handler/session_observer.h" +#include "transport_manager/transport_manager_listener_empty.h" +#include "utils/lock.h" #include "utils/logger.h" #include "utils/macro.h" #include "utils/message_queue.h" -#include "utils/lock.h" -#include "utils/stl_utils.h" #include "utils/rwlock.h" +#include "utils/stl_utils.h" const transport_manager::ConnectionUID kDisabledSecondary = 0xFFFFFFFF; @@ -620,6 +620,15 @@ class ConnectionHandlerImpl const uint8_t GetSessionIdFromSecondaryTransport( transport_manager::ConnectionUID secondary_transport_id) const; + /** + * @brief Get pointer to the primary connection by connection handle + * @param connection_handle handle of the current connection + * @return pointer to the primary connection if current one is secondary + * otherwise returns pointer to the same connection + */ + Connection* GetPrimaryConnection( + const ConnectionHandle connection_handle) const; + const ConnectionHandlerSettings& settings_; /** * \brief Pointer to observer diff --git a/src/components/connection_handler/include/connection_handler/device.h b/src/components/connection_handler/include/connection_handler/device.h index 26376c1d8d6..1cad7a72c5c 100644 --- a/src/components/connection_handler/include/connection_handler/device.h +++ b/src/components/connection_handler/include/connection_handler/device.h @@ -33,8 +33,8 @@ #ifndef SRC_COMPONENTS_CONNECTION_HANDLER_INCLUDE_CONNECTION_HANDLER_DEVICE_H_ #define SRC_COMPONENTS_CONNECTION_HANDLER_INCLUDE_CONNECTION_HANDLER_DEVICE_H_ -#include #include +#include #include #include "transport_manager/common.h" @@ -77,9 +77,9 @@ class Device { std::string user_friendly_name() const; /** - *\brief Also should be used for iOS USB connections - *(better not know why this same method) - */ + *\brief Also should be used for iOS USB connections + *(better not know why this same method) + */ std::string mac_address() const; /** 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 cf956353dd8..9e04929f796 100644 --- a/src/components/connection_handler/include/connection_handler/heartbeat_monitor.h +++ b/src/components/connection_handler/include/connection_handler/heartbeat_monitor.h @@ -35,11 +35,11 @@ #include #include -#include "utils/threads/thread.h" -#include "utils/threads/thread_delegate.h" #include "utils/date_time.h" -#include "utils/macro.h" #include "utils/lock.h" +#include "utils/macro.h" +#include "utils/threads/thread.h" +#include "utils/threads/thread_delegate.h" namespace connection_handler { @@ -64,7 +64,7 @@ class HeartBeatMonitor : public threads::ThreadDelegate { void RemoveSession(uint8_t session_id); /** - * \brief Resets timer preventing session from being killed + * \brief Resets timer preventing session from being killed */ void KeepAlive(uint8_t session_id); diff --git a/src/components/connection_handler/src/connection.cc b/src/components/connection_handler/src/connection.cc index 3f5b0e19019..304be9ddb08 100644 --- a/src/components/connection_handler/src/connection.cc +++ b/src/components/connection_handler/src/connection.cc @@ -37,13 +37,13 @@ #include "connection_handler/connection.h" #include "connection_handler/connection_handler.h" #include "protocol_handler/protocol_packet.h" +#include "utils/helpers.h" #include "utils/logger.h" #include "utils/macro.h" -#include "utils/helpers.h" #ifdef ENABLE_SECURITY -#include "security_manager/ssl_context.h" #include "security_manager/security_manager.h" +#include "security_manager/ssl_context.h" #endif // ENABLE_SECURITY /** @@ -190,12 +190,11 @@ bool Connection::AddNewService(uint8_t session_id, Session& session = session_it->second; if (session.protocol_version <= protocol_handler::PROTOCOL_VERSION_2 && - helpers::Compare( - service_type, - protocol_handler::ServiceType::kAudio, - protocol_handler::ServiceType::kMobileNav)) { + helpers:: + Compare( + service_type, + protocol_handler::ServiceType::kAudio, + protocol_handler::ServiceType::kMobileNav)) { LOG4CXX_WARN(logger_, "Audio and video services are disallowed for protocol version " "2 or lower"); @@ -265,8 +264,10 @@ bool Connection::RemoveService(uint8_t session_id, find(service_list.begin(), service_list.end(), service_type); if (service_list.end() == service_it) { LOG4CXX_WARN(logger_, - "Session " << session_id << " didn't established" - " service " << service_type); + "Session " << session_id + << " didn't established" + " service " + << service_type); return false; } service_list.erase(service_it); diff --git a/src/components/connection_handler/src/connection_handler_impl.cc b/src/components/connection_handler/src/connection_handler_impl.cc index c412c9c6375..db1ee2dce5a 100644 --- a/src/components/connection_handler/src/connection_handler_impl.cc +++ b/src/components/connection_handler/src/connection_handler_impl.cc @@ -31,14 +31,14 @@ */ #include -#include -#include #include +#include #include +#include #include "connection_handler/connection_handler_impl.h" -#include "transport_manager/info.h" #include "encryption/hashing.h" +#include "transport_manager/info.h" #ifdef ENABLE_SECURITY #include "security_manager/security_manager.h" @@ -95,9 +95,9 @@ void ConnectionHandlerImpl::Stop() { void ConnectionHandlerImpl::set_connection_handler_observer( ConnectionHandlerObserver* observer) { - LOG4CXX_DEBUG(logger_, - "ConnectionHandlerImpl::set_connection_handler_observer() " - << observer); + LOG4CXX_DEBUG( + logger_, + "ConnectionHandlerImpl::set_connection_handler_observer() " << observer); sync_primitives::AutoWriteLock write_lock(connection_handler_observer_lock_); if (!observer) { LOG4CXX_WARN(logger_, "Set Null pointer to observer."); @@ -107,9 +107,9 @@ void ConnectionHandlerImpl::set_connection_handler_observer( void ConnectionHandlerImpl::set_protocol_handler( protocol_handler::ProtocolHandler* protocol_handler) { - LOG4CXX_DEBUG(logger_, - "ConnectionHandlerImpl::set_protocol_handler()" - << protocol_handler); + LOG4CXX_DEBUG( + logger_, + "ConnectionHandlerImpl::set_protocol_handler()" << protocol_handler); if (!protocol_handler) { LOG4CXX_WARN(logger_, "Set Null pointer to protocol handler."); } @@ -392,9 +392,9 @@ bool AllowProtection(const ConnectionHandlerSettings& settings, if (std::find(force_unprotected_list.begin(), force_unprotected_list.end(), service_type) != force_unprotected_list.end()) { - LOG4CXX_ERROR(logger_, - "Service " << static_cast(service_type) - << " shall be protected"); + LOG4CXX_ERROR( + logger_, + "Service " << static_cast(service_type) << " shall be protected"); return false; } LOG4CXX_DEBUG(logger_, @@ -686,34 +686,34 @@ uint32_t ConnectionHandlerImpl::OnSessionEndedCallback( KeyFromPair(primary_connection_handle, session_id); if (protocol_handler::kRpc == service_type) { - LOG4CXX_INFO(logger_, - "Session " << static_cast(session_id) - << " to be removed"); + LOG4CXX_INFO( + logger_, + "Session " << static_cast(session_id) << " to be removed"); // old version of protocol doesn't support hash if (protocol_handler::HASH_ID_NOT_SUPPORTED != *hashCode) { if (protocol_handler::HASH_ID_WRONG == *hashCode || session_key != *hashCode) { - LOG4CXX_WARN(logger_, - "Wrong hash_id for session " - << static_cast(session_id)); + LOG4CXX_WARN( + logger_, + "Wrong hash_id for session " << static_cast(session_id)); *hashCode = protocol_handler::HASH_ID_WRONG; return 0; } } if (!connection->RemoveSession(session_id)) { - LOG4CXX_WARN(logger_, - "Couldn't remove session " - << static_cast(session_id)); + LOG4CXX_WARN( + logger_, + "Couldn't remove session " << static_cast(session_id)); return 0; } } else { - LOG4CXX_INFO(logger_, - "Service " << static_cast(service_type) - << " to be removed"); + LOG4CXX_INFO( + logger_, + "Service " << static_cast(service_type) << " to be removed"); if (!connection->RemoveService(session_id, service_type)) { - LOG4CXX_WARN(logger_, - "Couldn't remove service " - << static_cast(service_type)); + LOG4CXX_WARN( + logger_, + "Couldn't remove service " << static_cast(service_type)); return 0; } } @@ -1124,6 +1124,26 @@ const uint8_t ConnectionHandlerImpl::GetSessionIdFromSecondaryTransport( return 0; } +Connection* ConnectionHandlerImpl::GetPrimaryConnection( + const ConnectionHandle connection_handle) const { + LOG4CXX_DEBUG(logger_, + "Getting primary connection for ID " << connection_handle); + ConnectionList::const_iterator it = connection_list_.find(connection_handle); + if (connection_list_.end() == it) { + LOG4CXX_ERROR( + logger_, + "Connection with ID " << connection_handle << " was not found"); + return nullptr; + } + + auto connection_ptr = it->second; + if (connection_ptr->primary_connection_handle() != 0) { + return GetPrimaryConnection(connection_ptr->primary_connection_handle()); + } + + return connection_ptr; +} + std::string ConnectionHandlerImpl::GetCloudAppID( const transport_manager::ConnectionUID connection_id) const { sync_primitives::AutoLock auto_lock(cloud_app_id_map_lock_); @@ -1229,13 +1249,12 @@ int ConnectionHandlerImpl::SetSSLContext( PairFromKey(key, &connection_handle, &session_id); 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!"); + auto connection = GetPrimaryConnection(connection_handle); + if (!connection) { return security_manager::SecurityManager::ERROR_INTERNAL; } - Connection& connection = *it->second; - return connection.SetSSLContext(session_id, context); + + return connection->SetSSLContext(session_id, context); } security_manager::SSLContext* ConnectionHandlerImpl::GetSSLContext( @@ -1246,13 +1265,12 @@ security_manager::SSLContext* ConnectionHandlerImpl::GetSSLContext( PairFromKey(key, &connection_handle, &session_id); 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 NULL; + auto connection = GetPrimaryConnection(connection_handle); + if (!connection) { + return nullptr; } - Connection& connection = *it->second; - return connection.GetSSLContext(session_id, service_type); + + return connection->GetSSLContext(session_id, service_type); } void ConnectionHandlerImpl::SetProtectionFlag( @@ -1263,18 +1281,28 @@ void ConnectionHandlerImpl::SetProtectionFlag( PairFromKey(key, &connection_handle, &session_id); 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!"); + auto connection = GetPrimaryConnection(connection_handle); + if (!connection) { return; } - Connection& connection = *it->second; - connection.SetProtectionFlag(session_id, service_type); + + connection->SetProtectionFlag(session_id, service_type); } security_manager::SSLContext::HandshakeContext ConnectionHandlerImpl::GetHandshakeContext(uint32_t key) const { - return connection_handler_observer_->GetHandshakeContext(key); + transport_manager::ConnectionUID connection_handle = 0; + uint8_t session_id = 0; + PairFromKey(key, &connection_handle, &session_id); + + sync_primitives::AutoReadLock lock(connection_list_lock_); + auto connection = GetPrimaryConnection(connection_handle); + if (!connection) { + return security_manager::SSLContext::HandshakeContext(); + } + + auto primary_key = KeyFromPair(connection->connection_handle(), session_id); + return connection_handler_observer_->GetHandshakeContext(primary_key); } #endif // ENABLE_SECURITY @@ -1368,7 +1396,8 @@ void ConnectionHandlerImpl::RemoveCloudAppDevice(const DeviceHandle device_id) { void ConnectionHandlerImpl::StartTransportManager() { LOG4CXX_AUTO_TRACE(logger_); - transport_manager_.Visibility(true); + transport_manager_.PerformActionOnClients( + transport_manager::TransportAction::kVisibilityOn); } void ConnectionHandlerImpl::CloseRevokedConnection(uint32_t connection_key) { @@ -1480,9 +1509,9 @@ void ConnectionHandlerImpl::CloseSession(ConnectionHandle connection_handle, return; } - LOG4CXX_DEBUG(logger_, - "Session with id: " << session_id - << " has been closed successfully"); + LOG4CXX_DEBUG( + logger_, + "Session with id: " << session_id << " has been closed successfully"); } void ConnectionHandlerImpl::CloseConnectionSessions( @@ -1663,9 +1692,9 @@ void ConnectionHandlerImpl::BindProtocolVersionWithSession( PairFromKey(connection_key, &connection_handle, &session_id); sync_primitives::AutoReadLock lock(connection_list_lock_); - ConnectionList::iterator it = connection_list_.find(connection_handle); - if (connection_list_.end() != it) { - it->second->UpdateProtocolVersionSession(session_id, protocol_version); + auto connection = GetPrimaryConnection(connection_handle); + if (connection) { + connection->UpdateProtocolVersionSession(session_id, protocol_version); } } @@ -1674,13 +1703,14 @@ bool ConnectionHandlerImpl::IsHeartBeatSupported( uint8_t session_id) const { LOG4CXX_AUTO_TRACE(logger_); sync_primitives::AutoReadLock lock(connection_list_lock_); - uint32_t connection = static_cast(connection_handle); - ConnectionList::const_iterator it = connection_list_.find(connection); - if (connection_list_.end() == it) { - LOG4CXX_WARN(logger_, "Connection not found !"); + const uint32_t connection_id = static_cast(connection_handle); + auto connection = GetPrimaryConnection(connection_id); + + if (!connection) { return false; } - return it->second->SupportHeartBeat(session_id); + + return connection->SupportHeartBeat(session_id); } bool ConnectionHandlerImpl::ProtocolVersionUsed( @@ -1689,15 +1719,15 @@ bool ConnectionHandlerImpl::ProtocolVersionUsed( uint8_t& protocol_version) const { LOG4CXX_AUTO_TRACE(logger_); sync_primitives::AutoReadLock lock(connection_list_lock_); - ConnectionList::const_iterator it = connection_list_.find(connection_id); - if (connection_list_.end() != it) { - return it->second->ProtocolVersion(session_id, protocol_version); + auto connection = GetPrimaryConnection(connection_id); + + if (connection) { + return connection->ProtocolVersion(session_id, protocol_version); } else if (ending_connection_ && static_cast(ending_connection_->connection_handle()) == connection_id) { return ending_connection_->ProtocolVersion(session_id, protocol_version); } - LOG4CXX_WARN(logger_, "Connection not found !"); return false; } diff --git a/src/components/connection_handler/src/device.cc b/src/components/connection_handler/src/device.cc index 0ecb439172a..515304778b5 100644 --- a/src/components/connection_handler/src/device.cc +++ b/src/components/connection_handler/src/device.cc @@ -54,9 +54,9 @@ Device::Device(DeviceHandle device_handle, , mac_address_(mac_address) , connection_type_(connection_type) { mac_address_ = encryption::MakeHash(mac_address); - LOG4CXX_DEBUG(logger_, - "Device: MAC address - " << mac_address << ", hash - " - << mac_address_); + LOG4CXX_DEBUG( + logger_, + "Device: MAC address - " << mac_address << ", hash - " << mac_address_); } DeviceHandle Device::device_handle() const { diff --git a/src/components/connection_handler/src/heartbeat_monitor.cc b/src/components/connection_handler/src/heartbeat_monitor.cc index 4c2d5899af4..2b50f1ce1b8 100644 --- a/src/components/connection_handler/src/heartbeat_monitor.cc +++ b/src/components/connection_handler/src/heartbeat_monitor.cc @@ -34,8 +34,8 @@ #include #include -#include "utils/logger.h" #include "connection_handler/connection.h" +#include "utils/logger.h" namespace connection_handler { @@ -79,9 +79,9 @@ void HeartBeatMonitor::Process() { void HeartBeatMonitor::threadMain() { AutoLock main_lock(main_thread_lock_); - LOG4CXX_DEBUG(logger_, - "Start heart beat monitor. Timeout is " - << default_heartbeat_timeout_); + LOG4CXX_DEBUG( + logger_, + "Start heart beat monitor. Timeout is " << default_heartbeat_timeout_); while (run_) { heartbeat_monitor_.WaitFor(main_lock, kDefaultCycleTimeout); Process(); @@ -94,9 +94,9 @@ void HeartBeatMonitor::AddSession(uint8_t session_id) { LOG4CXX_DEBUG(logger_, "Add session with id " << converted_session_id); AutoLock auto_lock(sessions_list_lock_); if (sessions_.end() != sessions_.find(session_id)) { - LOG4CXX_WARN(logger_, - "Session with id: " << converted_session_id - << " already exists"); + LOG4CXX_WARN( + logger_, + "Session with id: " << converted_session_id << " already exists"); return; } sessions_.insert( diff --git a/src/components/connection_handler/test/connection_handler_impl_test.cc b/src/components/connection_handler/test/connection_handler_impl_test.cc index 64de24b1033..855225c460a 100644 --- a/src/components/connection_handler/test/connection_handler_impl_test.cc +++ b/src/components/connection_handler/test/connection_handler_impl_test.cc @@ -30,22 +30,22 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include "gtest/gtest.h" -#include +#include "connection_handler/connection_handler_impl.h" #include +#include #include -#include "connection_handler/connection_handler_impl.h" +#include "gtest/gtest.h" #include "protocol/common.h" // TODO(EZamakhov): move security test #ifdef ENABLE_SECURITY #include "security_manager/mock_security_manager.h" #include "security_manager/mock_ssl_context.h" #endif // ENABLE_SECURITY -#include "protocol_handler/mock_protocol_handler.h" #include "connection_handler/mock_connection_handler_observer.h" #include "connection_handler/mock_connection_handler_settings.h" -#include "transport_manager/mock_transport_manager.h" #include "encryption/hashing.h" +#include "protocol_handler/mock_protocol_handler.h" +#include "transport_manager/mock_transport_manager.h" #include "utils/test_async_waiter.h" namespace test { @@ -333,7 +333,8 @@ class ConnectionHandlerTest : public ::testing::Test { connection_handler_->set_connection_handler_observer( &temp_connection_handler_observer); EXPECT_CALL(temp_connection_handler_observer, - OnServiceStartedCallback(_, _, service_type, _)).Times(1); + OnServiceStartedCallback(_, _, service_type, _)) + .Times(1); connection_handler_->OnSessionStartedCallback(2u, out_context_.new_session_id_, @@ -635,7 +636,8 @@ TEST_F(ConnectionHandlerTest, OnApplicationFloodCallBack) { connection_handler_->set_protocol_handler(&mock_protocol_handler_); EXPECT_CALL(mock_protocol_handler_, - SendEndSession(uid_, out_context_.new_session_id_)).Times(1); + SendEndSession(uid_, out_context_.new_session_id_)) + .Times(1); InSequence seq; EXPECT_CALL(mock_connection_handler_observer, OnServiceEndedCallback(connection_key_, kMobileNav, kCommon)); @@ -753,7 +755,8 @@ TEST_F(ConnectionHandlerTest, UpdateDeviceList) { // New value that sets in OnDeviceListUpdated does not add EXPECT_CALL(mock_connection_handler_observer, - OnDeviceListUpdated(CheckDevList(map_with_unused_var))).Times(0); + OnDeviceListUpdated(CheckDevList(map_with_unused_var))) + .Times(0); connection_handler_->OnDeviceListUpdated(unused_info); } @@ -784,7 +787,9 @@ TEST_F(ConnectionHandlerTest, StartTransportManager) { AddTestDeviceConnection(); AddTestSession(); - EXPECT_CALL(mock_transport_manager_, Visibility(true)); + EXPECT_CALL(mock_transport_manager_, + PerformActionOnClients( + transport_manager::TransportAction::kVisibilityOn)); connection_handler_->StartTransportManager(); } @@ -1021,7 +1026,8 @@ TEST_F(ConnectionHandlerTest, CloseSessionWithMalformedMessage) { TestAsyncWaiter waiter; uint32_t times = 0; EXPECT_CALL(mock_protocol_handler_, - SendEndSession(uid_, out_context_.new_session_id_)).Times(0); + SendEndSession(uid_, out_context_.new_session_id_)) + .Times(0); InSequence seq; EXPECT_CALL(mock_connection_handler_observer, @@ -1061,7 +1067,8 @@ TEST_F(ConnectionHandlerTest, CloseConnectionSessionsWithMalformedMessage) { TestAsyncWaiter waiter; uint32_t times = 0; EXPECT_CALL(mock_protocol_handler_, - SendEndSession(uid_, out_context_.new_session_id_)).Times(0); + SendEndSession(uid_, out_context_.new_session_id_)) + .Times(0); InSequence seq; EXPECT_CALL(mock_connection_handler_observer, @@ -2063,7 +2070,8 @@ TEST_F(ConnectionHandlerTest, StartStopSecondarySession) { secondary_uid); EXPECT_CALL(mock_connection_handler_observer, - OnSecondaryTransportStartedCallback(device_handle_, _)).Times(1); + OnSecondaryTransportStartedCallback(device_handle_, _)) + .Times(1); connection_handler_->OnSecondaryTransportStarted( uid_, secondary_uid, out_context_.new_session_id_); @@ -2084,11 +2092,14 @@ TEST_F(ConnectionHandlerTest, StartStopSecondarySession) { connection_handler_->set_connection_handler_observer( &mock_connection_handler_observer); EXPECT_CALL(mock_connection_handler_observer, - OnSecondaryTransportEndedCallback(_)).Times(1); + OnSecondaryTransportEndedCallback(_)) + .Times(1); EXPECT_CALL(mock_connection_handler_observer, - OnServiceEndedCallback(_, kAudio, _)).Times(1); + OnServiceEndedCallback(_, kAudio, _)) + .Times(1); EXPECT_CALL(mock_connection_handler_observer, - OnServiceEndedCallback(_, kMobileNav, _)).Times(1); + OnServiceEndedCallback(_, kMobileNav, _)) + .Times(1); connection_handler_->OnSecondaryTransportEnded(uid_, secondary_uid); @@ -2120,7 +2131,8 @@ TEST_F(ConnectionHandlerTest, StopSecondarySession_NoService) { secondary_uid); EXPECT_CALL(mock_connection_handler_observer, - OnSecondaryTransportStartedCallback(device_handle_, _)).Times(1); + OnSecondaryTransportStartedCallback(device_handle_, _)) + .Times(1); connection_handler_->OnSecondaryTransportStarted( uid_, secondary_uid, out_context_.new_session_id_); diff --git a/src/components/connection_handler/test/connection_test.cc b/src/components/connection_handler/test/connection_test.cc index 98b83f5fc4c..dd86831225c 100644 --- a/src/components/connection_handler/test/connection_test.cc +++ b/src/components/connection_handler/test/connection_test.cc @@ -34,12 +34,12 @@ #include "gtest/gtest.h" -#include "protocol/common.h" #include "connection_handler/connection.h" -#include "connection_handler/mock_connection_handler.h" #include "connection_handler/connection_handler_impl.h" -#include "protocol/service_type.h" +#include "connection_handler/mock_connection_handler.h" #include "connection_handler/mock_connection_handler_settings.h" +#include "protocol/common.h" +#include "protocol/service_type.h" #include "transport_manager/mock_transport_manager.h" #ifdef ENABLE_SECURITY #include "security_manager/mock_security_manager.h" diff --git a/src/components/connection_handler/test/device_test.cc b/src/components/connection_handler/test/device_test.cc index 8c6d0af57a8..555bd8ed2a2 100644 --- a/src/components/connection_handler/test/device_test.cc +++ b/src/components/connection_handler/test/device_test.cc @@ -30,9 +30,9 @@ * POSSIBILITY OF SUCH DAMAGE. */ +#include "connection_handler/device.h" #include #include "encryption/hashing.h" -#include "connection_handler/device.h" namespace test { namespace components { @@ -75,6 +75,6 @@ TEST(ConnectionDevice, MacAddressHash) { EXPECT_EQ(hashed_mac_address, test_device.mac_address()); } -} // namespace connection_handlet_test +} // namespace connection_handler_test } // namespace components } // namespace test diff --git a/src/components/connection_handler/test/heart_beat_monitor_test.cc b/src/components/connection_handler/test/heart_beat_monitor_test.cc index ccfff341164..d7362551348 100644 --- a/src/components/connection_handler/test/heart_beat_monitor_test.cc +++ b/src/components/connection_handler/test/heart_beat_monitor_test.cc @@ -30,13 +30,13 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include #include -#include "gtest/gtest.h" -#include "connection_handler/heartbeat_monitor.h" +#include #include "connection_handler/connection.h" #include "connection_handler/connection_handler.h" +#include "connection_handler/heartbeat_monitor.h" #include "connection_handler/mock_connection_handler.h" +#include "gtest/gtest.h" #include "utils/test_async_waiter.h" namespace { @@ -44,14 +44,14 @@ const int32_t MILLISECONDS_IN_SECOND = 1000; const int32_t MICROSECONDS_IN_MILLISECONDS = 1000; const int32_t MICROSECONDS_IN_SECOND = 1000 * 1000; const uint32_t kTime_offset = 20u; -} +} // namespace namespace test { namespace components { namespace connection_handler_test { -using ::testing::DoAll; using ::testing::_; +using ::testing::DoAll; using ::testing::Return; class HeartBeatMonitorTest : public testing::Test { diff --git a/src/components/formatters/include/formatters/CFormatterJsonBase.h b/src/components/formatters/include/formatters/CFormatterJsonBase.h index 66ffa0c1c59..01c84bfba3d 100644 --- a/src/components/formatters/include/formatters/CFormatterJsonBase.h +++ b/src/components/formatters/include/formatters/CFormatterJsonBase.h @@ -35,8 +35,8 @@ #ifndef SRC_COMPONENTS_FORMATTERS_INCLUDE_FORMATTERS_CFORMATTERJSONBASE_H_ #define SRC_COMPONENTS_FORMATTERS_INCLUDE_FORMATTERS_CFORMATTERJSONBASE_H_ -#include "smart_objects/smart_object.h" #include "json/json.h" +#include "smart_objects/smart_object.h" namespace ns_smart_device_link { namespace ns_json_handler { @@ -44,33 +44,33 @@ namespace formatters { namespace meta_formatter_error_code { /** - * @brief Error codes of MetaFormatter represented as bitmask - **/ + * @brief Error codes of MetaFormatter represented as bitmask + **/ typedef long tMetaFormatterErrorCode; /** - * @brief OK, no error - */ + * @brief OK, no error + */ static const tMetaFormatterErrorCode kErrorOk = 0x0; /** - * @brief origin smart object is not function - */ + * @brief origin smart object is not function + */ static const tMetaFormatterErrorCode kErrorObjectIsNotFunction = 0x01; /** - * @brief smart shema describes object which is not function - */ + * @brief smart schema describes object which is not function + */ static const tMetaFormatterErrorCode kErrorSchemaIsNotFunction = 0x02; /** - * @brief result smart object has invalid type (SmartType_Invalid) - * before passing to MetaFormatter, i.e. result object can not - * be changed, i.e. result object can not be built - * - */ + * @brief result smart object has invalid type (SmartType_Invalid) + * before passing to MetaFormatter, i.e. result object can not + * be changed, i.e. result object can not be built + * + */ static const tMetaFormatterErrorCode kErrorFailedCreateObjectBySchema = 0x04; -} +} // namespace meta_formatter_error_code /** * @brief The base class for all JSON based formatters. @@ -102,18 +102,18 @@ class CFormatterJsonBase { ns_smart_device_link::ns_smart_objects::SmartObject& obj); /** - * @brief The method constructs a JSON object from the input SmartObject - * - * @param obj Input SmartObject. Can contain a complex structure of objects. - * @param value The resulting JSON object. It has the same structure as the - *input SmartObject. - */ + * @brief The method constructs a JSON object from the input SmartObject + * + * @param obj Input SmartObject. Can contain a complex structure of objects. + * @param value The resulting JSON object. It has the same structure as the + *input SmartObject. + */ static void objToJsonValue( const ns_smart_device_link::ns_smart_objects::SmartObject& obj, Json::Value& value); }; -} -} -} // namespace ns_smart_device_link::ns_json_handler::formatters +} // namespace formatters +} // namespace ns_json_handler +} // namespace ns_smart_device_link #endif // SRC_COMPONENTS_FORMATTERS_INCLUDE_FORMATTERS_CFORMATTERJSONBASE_H_ diff --git a/src/components/formatters/include/formatters/CFormatterJsonSDLRPCv1.h b/src/components/formatters/include/formatters/CFormatterJsonSDLRPCv1.h index cd3e50212af..b1054100df0 100644 --- a/src/components/formatters/include/formatters/CFormatterJsonSDLRPCv1.h +++ b/src/components/formatters/include/formatters/CFormatterJsonSDLRPCv1.h @@ -32,8 +32,8 @@ #include "json/json.h" -#include "smart_objects/smart_object.h" #include "smart_objects/enum_schema_item.h" +#include "smart_objects/smart_object.h" #include "CFormatterJsonBase.h" @@ -238,8 +238,8 @@ int32_t formatters::CFormatterJsonSDLRPCv1::fromString( return result; } -} -} -} // namespace ns_smart_device_link::ns_json_handler::formatters +} // namespace formatters +} // namespace ns_json_handler +} // namespace ns_smart_device_link #endif // SRC_COMPONENTS_FORMATTERS_INCLUDE_FORMATTERS_CFORMATTERJSONSDLRPCV1_H_ diff --git a/src/components/formatters/include/formatters/CFormatterJsonSDLRPCv2.h b/src/components/formatters/include/formatters/CFormatterJsonSDLRPCv2.h index f86e4e51cb4..ab0289b2939 100644 --- a/src/components/formatters/include/formatters/CFormatterJsonSDLRPCv2.h +++ b/src/components/formatters/include/formatters/CFormatterJsonSDLRPCv2.h @@ -188,8 +188,8 @@ inline bool CFormatterJsonSDLRPCv2::fromString( return result; } -} -} -} // namespace ns_smart_device_link::ns_json_handler::formatters +} // namespace formatters +} // namespace ns_json_handler +} // namespace ns_smart_device_link #endif // SRC_COMPONENTS_FORMATTERS_INCLUDE_FORMATTERS_CFORMATTERJSONSDLRPCV2_H_ diff --git a/src/components/formatters/include/formatters/CSmartFactory.h b/src/components/formatters/include/formatters/CSmartFactory.h index f3c3fbe207e..c384dbf01de 100644 --- a/src/components/formatters/include/formatters/CSmartFactory.h +++ b/src/components/formatters/include/formatters/CSmartFactory.h @@ -35,10 +35,10 @@ #ifndef SRC_COMPONENTS_FORMATTERS_INCLUDE_FORMATTERS_CSMARTFACTORY_H_ #define SRC_COMPONENTS_FORMATTERS_INCLUDE_FORMATTERS_CSMARTFACTORY_H_ -#include "smart_objects/smart_object.h" -#include "smart_objects/smart_schema.h" #include #include +#include "smart_objects/smart_object.h" +#include "smart_objects/smart_schema.h" namespace ns_smart_device_link { namespace ns_json_handler { @@ -94,7 +94,7 @@ extern const std::string kCode; * @brief String constant for "message" param name. */ extern const std::string kMessage; -} +} // namespace strings /** * @brief Smart Schema key. @@ -286,11 +286,11 @@ bool CSmartFactory::attachSchema( return false; MessageTypeEnum msgtype( - (MessageTypeEnum) - object[strings::S_PARAMS][strings::S_MESSAGE_TYPE].asInt()); + (MessageTypeEnum)object[strings::S_PARAMS][strings::S_MESSAGE_TYPE] + .asInt()); FunctionIdEnum fid( - (FunctionIdEnum) - object[strings::S_PARAMS][strings::S_FUNCTION_ID].asInt()); + (FunctionIdEnum)object[strings::S_PARAMS][strings::S_FUNCTION_ID] + .asInt()); SmartSchemaKey key(fid, msgtype); @@ -415,6 +415,6 @@ bool operator<(const SmartSchemaKey& l, return false; } -} -} +} // namespace ns_json_handler +} // namespace ns_smart_device_link #endif // SRC_COMPONENTS_FORMATTERS_INCLUDE_FORMATTERS_CSMARTFACTORY_H_ diff --git a/src/components/formatters/include/formatters/formatter_json_rpc.h b/src/components/formatters/include/formatters/formatter_json_rpc.h index 35037679889..593c8378776 100644 --- a/src/components/formatters/include/formatters/formatter_json_rpc.h +++ b/src/components/formatters/include/formatters/formatter_json_rpc.h @@ -35,12 +35,12 @@ #ifndef SRC_COMPONENTS_FORMATTERS_INCLUDE_FORMATTERS_FORMATTER_JSON_RPC_H_ #define SRC_COMPONENTS_FORMATTERS_INCLUDE_FORMATTERS_FORMATTER_JSON_RPC_H_ -#include #include +#include -#include "smart_objects/smart_object.h" -#include "smart_objects/enum_schema_item.h" #include "json/json.h" +#include "smart_objects/enum_schema_item.h" +#include "smart_objects/smart_object.h" #include "CFormatterJsonBase.h" #include "formatters/CSmartFactory.h" diff --git a/src/components/formatters/include/formatters/meta_formatter.h b/src/components/formatters/include/formatters/meta_formatter.h index 36e39301f67..b2ff546bfc7 100644 --- a/src/components/formatters/include/formatters/meta_formatter.h +++ b/src/components/formatters/include/formatters/meta_formatter.h @@ -44,35 +44,35 @@ namespace ns_json_handler { namespace formatters { /** - * @brief Formats to string the smart object against given schema for given - *formatter - * - * Sample usage: - * CSmartFactory factory; - * SmartObject object; - * CSmartSchmema schema; - * - */ + * @brief Formats to string the smart object against given schema for given + *formatter + * + * Sample usage: + * CSmartFactory factory; + * SmartObject object; + * CSmartSchmema schema; + * + */ class CMetaFormatter { public: /** - * @brief Creates smart object by the given schema having copied - * matched tree elements from original object. - * - * @param object Original smart object which macthed tree elements - * will be copied from - * @param schema Smart schema which describes result smart object - * @param result_object createdsmart object - * @return true if successful, false - otherwise - */ + * @brief Creates smart object by the given schema having copied + * matched tree elements from original object. + * + * @param object Original smart object which macthed tree elements + * will be copied from + * @param schema Smart schema which describes result smart object + * @param result_object createdsmart object + * @return true if successful, false - otherwise + */ static bool CreateObjectByPattern( const ns_smart_device_link::ns_smart_objects::SmartObject& object, const ns_smart_device_link::ns_smart_objects::CSmartSchema& schema, ns_smart_device_link::ns_smart_objects::SmartObject& result_object); }; +} // namespace formatters +} // namespace ns_json_handler } // namespace ns_smart_device_link -} // namespace ns_smart_device_link::ns_json_handler -} // namespace ns_smart_device_link::ns_json_handler::formatters #endif // SRC_COMPONENTS_FORMATTERS_INCLUDE_FORMATTERS_META_FORMATTER_H_ diff --git a/src/components/formatters/src/CFormatterJsonBase.cc b/src/components/formatters/src/CFormatterJsonBase.cc index af8668543af..6dc3d28f16d 100644 --- a/src/components/formatters/src/CFormatterJsonBase.cc +++ b/src/components/formatters/src/CFormatterJsonBase.cc @@ -31,8 +31,8 @@ // 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 "json/json.h" #include "formatters/CFormatterJsonBase.h" +#include "json/json.h" #include "utils/convert_utils.h" void ns_smart_device_link::ns_json_handler::formatters::CFormatterJsonBase:: diff --git a/src/components/formatters/src/CFormatterJsonSDLRPCv1.cc b/src/components/formatters/src/CFormatterJsonSDLRPCv1.cc index a5c3d1a1035..2f47c83a6bf 100644 --- a/src/components/formatters/src/CFormatterJsonSDLRPCv1.cc +++ b/src/components/formatters/src/CFormatterJsonSDLRPCv1.cc @@ -164,6 +164,6 @@ CFormatterJsonSDLRPCv1::MetaFormatToString( return result_code; } -} -} -} +} // namespace formatters +} // namespace ns_json_handler +} // namespace ns_smart_device_link diff --git a/src/components/formatters/src/CFormatterJsonSDLRPCv2.cc b/src/components/formatters/src/CFormatterJsonSDLRPCv2.cc index a582b52462c..bee92fbbee0 100644 --- a/src/components/formatters/src/CFormatterJsonSDLRPCv2.cc +++ b/src/components/formatters/src/CFormatterJsonSDLRPCv2.cc @@ -107,6 +107,6 @@ CFormatterJsonSDLRPCv2::MetaFormatToString( return result_code; } -} -} -} +} // namespace formatters +} // namespace ns_json_handler +} // namespace ns_smart_device_link diff --git a/src/components/formatters/test/CFormatterJsonBase_test.cc b/src/components/formatters/test/CFormatterJsonBase_test.cc index 1cd9c55bbc8..91700b3f997 100644 --- a/src/components/formatters/test/CFormatterJsonBase_test.cc +++ b/src/components/formatters/test/CFormatterJsonBase_test.cc @@ -30,13 +30,13 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include +#include "formatters/CFormatterJsonBase.h" #include -#include "json/value.h" +#include +#include "formatters/generic_json_formatter.h" #include "gtest/gtest.h" #include "json/reader.h" -#include "formatters/CFormatterJsonBase.h" -#include "formatters/generic_json_formatter.h" +#include "json/value.h" namespace test { namespace components { diff --git a/src/components/formatters/test/CSmartFactory_test.cc b/src/components/formatters/test/CSmartFactory_test.cc index 3aba109e588..5bd212f4314 100644 --- a/src/components/formatters/test/CSmartFactory_test.cc +++ b/src/components/formatters/test/CSmartFactory_test.cc @@ -30,8 +30,8 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include "formatters/SmartFactoryTestHelper.h" #include "formatters/CSmartFactory.h" +#include "formatters/SmartFactoryTestHelper.h" #include "gtest/gtest.h" namespace test { diff --git a/src/components/formatters/test/cFormatterJsonSDLRPCv2_test.cc b/src/components/formatters/test/cFormatterJsonSDLRPCv2_test.cc index 628e9956bb4..34cde397aaa 100644 --- a/src/components/formatters/test/cFormatterJsonSDLRPCv2_test.cc +++ b/src/components/formatters/test/cFormatterJsonSDLRPCv2_test.cc @@ -30,9 +30,9 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include "gtest/gtest.h" -#include "formatters/create_smartSchema.h" #include "formatters/CFormatterJsonSDLRPCv2.h" +#include "formatters/create_smartSchema.h" +#include "gtest/gtest.h" namespace test { namespace components { diff --git a/src/components/formatters/test/formatter_json_rpc_test.cc b/src/components/formatters/test/formatter_json_rpc_test.cc index f397accbd4a..6e2e8753ca2 100644 --- a/src/components/formatters/test/formatter_json_rpc_test.cc +++ b/src/components/formatters/test/formatter_json_rpc_test.cc @@ -30,18 +30,14 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include #include "formatters/formatter_json_rpc.h" -#include -#include -#include #include -#include "gtest/gtest.h" -#include "formatters/formatter_json_rpc.h" -#include +#include #include -#include "gtest/gtest.h" +#include #include "formatters/CSmartFactory.h" +#include "formatters/formatter_json_rpc.h" +#include "gtest/gtest.h" #include "interfaces/HMI_API_schema.h" #include "interfaces/MOBILE_API_schema.h" diff --git a/src/components/formatters/test/generic_json_formatter_test.cc b/src/components/formatters/test/generic_json_formatter_test.cc index 97840eb1106..39f0fd6e7e8 100644 --- a/src/components/formatters/test/generic_json_formatter_test.cc +++ b/src/components/formatters/test/generic_json_formatter_test.cc @@ -30,8 +30,8 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include "gtest/gtest.h" #include "formatters/generic_json_formatter.h" +#include "gtest/gtest.h" namespace test { namespace components { @@ -169,6 +169,6 @@ TEST(GenericJsonFormatter, FromString) { result.getElement("subobject").getElement("strField").asString().c_str()); } -} // formatters -} // components -} // test +} // namespace formatters +} // namespace components +} // namespace test diff --git a/src/components/formatters/test/include/formatters/SmartFactoryTestHelper.h b/src/components/formatters/test/include/formatters/SmartFactoryTestHelper.h index 4b1ca94b982..08962db1201 100644 --- a/src/components/formatters/test/include/formatters/SmartFactoryTestHelper.h +++ b/src/components/formatters/test/include/formatters/SmartFactoryTestHelper.h @@ -38,15 +38,15 @@ #include "formatters/CSmartFactory.h" #include "interfaces/HMI_API_schema.h" -#include "smart_objects/always_true_schema_item.h" #include "smart_objects/always_false_schema_item.h" +#include "smart_objects/always_true_schema_item.h" #include "smart_objects/array_schema_item.h" #include "smart_objects/bool_schema_item.h" -#include "smart_objects/object_schema_item.h" -#include "smart_objects/string_schema_item.h" #include "smart_objects/enum_schema_item.h" #include "smart_objects/number_schema_item.h" +#include "smart_objects/object_schema_item.h" #include "smart_objects/schema_item_parameter.h" +#include "smart_objects/string_schema_item.h" namespace test { namespace components { @@ -107,7 +107,8 @@ class CSmartFactoryTest : public CSmartFactory > TStructsSchemaItems; + std::shared_ptr > + TStructsSchemaItems; static std::shared_ptr ProvideObjectSchemaItemForStruct( TStructsSchemaItems& struct_schema_items, diff --git a/src/components/formatters/test/include/formatters/create_smartSchema.h b/src/components/formatters/test/include/formatters/create_smartSchema.h index 73ff9ba77b7..4fd0f200d31 100644 --- a/src/components/formatters/test/include/formatters/create_smartSchema.h +++ b/src/components/formatters/test/include/formatters/create_smartSchema.h @@ -33,8 +33,8 @@ #ifndef SRC_COMPONENTS_FORMATTERS_TEST_INCLUDE_FORMATTERS_CREATE_SMARTSCHEMA_H_ #define SRC_COMPONENTS_FORMATTERS_TEST_INCLUDE_FORMATTERS_CREATE_SMARTSCHEMA_H_ -#include "formatters/CFormatterJsonSDLRPCv1.h" #include "SmartFactoryTestHelper.h" +#include "formatters/CFormatterJsonSDLRPCv1.h" namespace test { namespace components { diff --git a/src/components/formatters/test/include/formatters/meta_formatter_test_helper.h b/src/components/formatters/test/include/formatters/meta_formatter_test_helper.h index 0ee21d092c6..8a2b5abf0de 100644 --- a/src/components/formatters/test/include/formatters/meta_formatter_test_helper.h +++ b/src/components/formatters/test/include/formatters/meta_formatter_test_helper.h @@ -35,10 +35,10 @@ #include "gtest/gtest.h" -#include "smart_objects/smart_object.h" +#include "create_smartSchema.h" #include "formatters/CFormatterJsonSDLRPCv1.h" #include "formatters/CSmartFactory.h" -#include "create_smartSchema.h" +#include "smart_objects/smart_object.h" namespace test { namespace components { diff --git a/src/components/formatters/test/meta_formatter_test.cc b/src/components/formatters/test/meta_formatter_test.cc index 87f05ab50e2..5de0b619bf6 100644 --- a/src/components/formatters/test/meta_formatter_test.cc +++ b/src/components/formatters/test/meta_formatter_test.cc @@ -30,9 +30,9 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include "gtest/gtest.h" #include "formatters/meta_formatter.h" #include "formatters/meta_formatter_test_helper.h" +#include "gtest/gtest.h" namespace test { namespace components { @@ -44,7 +44,8 @@ TEST_F(CMetaFormatterTestHelper, Json::Reader reader; CSmartFactory factory_; + StructIdentifiers::eType> + factory_; SmartObject object1 = factory_.CreateSmartObject( FunctionIDTest::RegisterAppInterface, MessageTypeTest::request); @@ -122,7 +123,7 @@ TEST_F(CMetaFormatterTestHelper, } TEST_F(CMetaFormatterTestHelper, ObjectWithEmptyMap) { - std::map schemaMembersMap; + std::map schemaMembersMap; CSmartSchema map_schema = CSmartSchema(CObjectSchemaItem::create(schemaMembersMap)); @@ -210,67 +211,63 @@ TEST_F(CMetaFormatterTestHelper, SmartObject result_object; SmartObject object; - std::map paramsMembersMap; + std::map paramsMembersMap; - paramsMembersMap[S_FUNCTION_ID] = CObjectSchemaItem::SMember( + paramsMembersMap[S_FUNCTION_ID] = SMember( TEnumSchemaItem::create(function_id_items_), true); - paramsMembersMap[S_MESSAGE_TYPE] = CObjectSchemaItem::SMember( + paramsMembersMap[S_MESSAGE_TYPE] = SMember( TEnumSchemaItem::create(message_type_items_), true); - paramsMembersMap[S_CORRELATION_ID] = CObjectSchemaItem::SMember( - TNumberSchemaItem::create(TSchemaItemParameter(0), - TSchemaItemParameter(100), - TSchemaItemParameter(55)), - true); + paramsMembersMap[S_CORRELATION_ID] = + SMember(TNumberSchemaItem::create(TSchemaItemParameter(0), + TSchemaItemParameter(100), + TSchemaItemParameter(55)), + true); - paramsMembersMap[S_PROTOCOL_VERSION] = CObjectSchemaItem::SMember( - TNumberSchemaItem::create(TSchemaItemParameter(1), - TSchemaItemParameter(2)), - false); + paramsMembersMap[S_PROTOCOL_VERSION] = + SMember(TNumberSchemaItem::create(TSchemaItemParameter(1), + TSchemaItemParameter(2)), + false); paramsMembersMap[S_PROTOCOL_TYPE] = - CObjectSchemaItem::SMember(TNumberSchemaItem::create(), false); + SMember(TNumberSchemaItem::create(), false); - std::map schemaMembersMap; + std::map schemaMembersMap; - schemaMembersMap["mandatory_emptyMap1"] = CObjectSchemaItem::SMember( - CObjectSchemaItem::create( - std::map()), - true); + schemaMembersMap["mandatory_emptyMap1"] = SMember( + CObjectSchemaItem::create(std::map()), true); - schemaMembersMap["mandatory_emptyMap2"] = CObjectSchemaItem::SMember( - CObjectSchemaItem::create( - std::map()), - true); + schemaMembersMap["mandatory_emptyMap2"] = SMember( + CObjectSchemaItem::create(std::map()), true); - schemaMembersMap["mandatory_emptyAray"] = CObjectSchemaItem::SMember( - CArraySchemaItem::create(TNumberSchemaItem::create()), true); + schemaMembersMap["mandatory_emptyAray"] = + SMember(CArraySchemaItem::create(TNumberSchemaItem::create()), true); - schemaMembersMap["non_mandatory_Array"] = CObjectSchemaItem::SMember( - CArraySchemaItem::create(TNumberSchemaItem::create(), - TSchemaItemParameter(1), - TSchemaItemParameter(2)), - false); + schemaMembersMap["non_mandatory_Array"] = + SMember(CArraySchemaItem::create(TNumberSchemaItem::create(), + TSchemaItemParameter(1), + TSchemaItemParameter(2)), + false); - schemaMembersMap["mandatory_string"] = CObjectSchemaItem::SMember( + schemaMembersMap["mandatory_string"] = SMember( CStringSchemaItem::create(TSchemaItemParameter(0), TSchemaItemParameter(500), TSchemaItemParameter("defValue")), true); - schemaMembersMap["non_mandatory_string"] = CObjectSchemaItem::SMember( - CStringSchemaItem::create( - TSchemaItemParameter(0), - TSchemaItemParameter(500), - TSchemaItemParameter("ignoredDefValue")), - false); - - std::map rootMembersMap; - rootMembersMap[S_MSG_PARAMS] = CObjectSchemaItem::SMember( - CObjectSchemaItem::create(schemaMembersMap), true); - rootMembersMap[S_PARAMS] = CObjectSchemaItem::SMember( - CObjectSchemaItem::create(paramsMembersMap), true); + schemaMembersMap["non_mandatory_string"] = + SMember(CStringSchemaItem::create( + TSchemaItemParameter(0), + TSchemaItemParameter(500), + TSchemaItemParameter("ignoredDefValue")), + false); + + std::map rootMembersMap; + rootMembersMap[S_MSG_PARAMS] = + SMember(CObjectSchemaItem::create(schemaMembersMap), true); + rootMembersMap[S_PARAMS] = + SMember(CObjectSchemaItem::create(paramsMembersMap), true); CSmartSchema schema = CSmartSchema(CObjectSchemaItem::create(rootMembersMap)); diff --git a/src/components/formatters/test/src/SmartFactoryTestHelper.cc b/src/components/formatters/test/src/SmartFactoryTestHelper.cc index d48f9f58a0b..4d089ff9b14 100644 --- a/src/components/formatters/test/src/SmartFactoryTestHelper.cc +++ b/src/components/formatters/test/src/SmartFactoryTestHelper.cc @@ -169,27 +169,24 @@ void CSmartFactoryTest::InitFunctionSchemes( const TStructsSchemaItems& struct_schema_items, const std::set& function_id_items, const std::set& message_type_items) { - CObjectSchemaItem::Members params_members; - params_members[S_FUNCTION_ID] = CObjectSchemaItem::SMember( + Members params_members; + params_members[S_FUNCTION_ID] = SMember( TEnumSchemaItem::create(function_id_items), true); - params_members[S_MESSAGE_TYPE] = CObjectSchemaItem::SMember( + params_members[S_MESSAGE_TYPE] = SMember( TEnumSchemaItem::create(message_type_items), true); params_members[S_PROTOCOL_VERSION] = - CObjectSchemaItem::SMember(TNumberSchemaItem::create(), true); + SMember(TNumberSchemaItem::create(), true); params_members[S_PROTOCOL_TYPE] = - CObjectSchemaItem::SMember(TNumberSchemaItem::create(), true); + SMember(TNumberSchemaItem::create(), true); params_members[S_CORRELATION_ID] = - CObjectSchemaItem::SMember(TNumberSchemaItem::create(), true); - params_members[kCode] = - CObjectSchemaItem::SMember(TNumberSchemaItem::create(), true); - params_members[kMessage] = - CObjectSchemaItem::SMember(CStringSchemaItem::create(), true); + SMember(TNumberSchemaItem::create(), true); + params_members[kCode] = SMember(TNumberSchemaItem::create(), true); + params_members[kMessage] = SMember(CStringSchemaItem::create(), true); - CObjectSchemaItem::Members root_members_map; + Members root_members_map; root_members_map[ns_smart_device_link::ns_json_handler::strings::S_PARAMS] = - CObjectSchemaItem::SMember(CObjectSchemaItem::create(params_members), - true); + SMember(CObjectSchemaItem::create(params_members), true); CSmartSchema error_response_schema( CObjectSchemaItem::create(root_members_map)); @@ -240,26 +237,26 @@ void CSmartFactoryTest::InitFunctionSchemes( CSmartSchema CSmartFactoryTest::InitFunction_Function1_request( const std::set& function_id_items, const std::set& message_type_items) { - CObjectSchemaItem::Members schema_members; - CObjectSchemaItem::Members params_members; + Members schema_members; + Members params_members; - params_members[S_FUNCTION_ID] = CObjectSchemaItem::SMember( + params_members[S_FUNCTION_ID] = SMember( TEnumSchemaItem::create(function_id_items), true); - params_members[S_MESSAGE_TYPE] = CObjectSchemaItem::SMember( + params_members[S_MESSAGE_TYPE] = SMember( TEnumSchemaItem::create(message_type_items), true); params_members[S_PROTOCOL_VERSION] = - CObjectSchemaItem::SMember(TNumberSchemaItem::create(), true); + SMember(TNumberSchemaItem::create(), true); params_members[S_PROTOCOL_TYPE] = - CObjectSchemaItem::SMember(TNumberSchemaItem::create(), true); + SMember(TNumberSchemaItem::create(), true); params_members[S_CORRELATION_ID] = - CObjectSchemaItem::SMember(TNumberSchemaItem::create(), true); + SMember(TNumberSchemaItem::create(), true); - CObjectSchemaItem::Members root_members_map; - root_members_map[S_MSG_PARAMS] = CObjectSchemaItem::SMember( - CObjectSchemaItem::create(schema_members), true); - root_members_map[S_PARAMS] = CObjectSchemaItem::SMember( - CObjectSchemaItem::create(params_members), true); + Members root_members_map; + root_members_map[S_MSG_PARAMS] = + SMember(CObjectSchemaItem::create(schema_members), true); + root_members_map[S_PARAMS] = + SMember(CObjectSchemaItem::create(params_members), true); return CSmartSchema(CObjectSchemaItem::create(root_members_map)); } @@ -272,31 +269,29 @@ CSmartSchema CSmartFactoryTest::InitFunction_Function1_response( std::shared_ptr available_SchemaItem = CBoolSchemaItem::create(TSchemaItemParameter()); - CObjectSchemaItem::Members schema_members; + Members schema_members; - schema_members["available"] = - CObjectSchemaItem::SMember(available_SchemaItem, true); + schema_members["available"] = SMember(available_SchemaItem, true); - CObjectSchemaItem::Members params_members; - params_members[S_FUNCTION_ID] = CObjectSchemaItem::SMember( + Members params_members; + params_members[S_FUNCTION_ID] = SMember( TEnumSchemaItem::create(function_id_items), true); - params_members[S_MESSAGE_TYPE] = CObjectSchemaItem::SMember( + params_members[S_MESSAGE_TYPE] = SMember( TEnumSchemaItem::create(message_type_items), true); params_members[S_PROTOCOL_VERSION] = - CObjectSchemaItem::SMember(TNumberSchemaItem::create(), true); + SMember(TNumberSchemaItem::create(), true); params_members[S_PROTOCOL_TYPE] = - CObjectSchemaItem::SMember(TNumberSchemaItem::create(), true); + SMember(TNumberSchemaItem::create(), true); params_members[S_CORRELATION_ID] = - CObjectSchemaItem::SMember(TNumberSchemaItem::create(), true); - params_members[kCode] = - CObjectSchemaItem::SMember(TNumberSchemaItem::create(), true); + SMember(TNumberSchemaItem::create(), true); + params_members[kCode] = SMember(TNumberSchemaItem::create(), true); - CObjectSchemaItem::Members root_members_map; - root_members_map[S_MSG_PARAMS] = CObjectSchemaItem::SMember( - CObjectSchemaItem::create(schema_members), true); - root_members_map[S_PARAMS] = CObjectSchemaItem::SMember( - CObjectSchemaItem::create(params_members), true); + Members root_members_map; + root_members_map[S_MSG_PARAMS] = + SMember(CObjectSchemaItem::create(schema_members), true); + root_members_map[S_PARAMS] = + SMember(CObjectSchemaItem::create(params_members), true); return CSmartSchema(CObjectSchemaItem::create(root_members_map)); } @@ -304,26 +299,26 @@ CSmartSchema CSmartFactoryTest::InitFunction_Function1_response( CSmartSchema CSmartFactoryTest::InitFunction_Function2_request( const std::set& function_id_items, const std::set& message_type_items) { - CObjectSchemaItem::Members schema_members; + Members schema_members; - CObjectSchemaItem::Members params_members; - params_members[S_FUNCTION_ID] = CObjectSchemaItem::SMember( + Members params_members; + params_members[S_FUNCTION_ID] = SMember( TEnumSchemaItem::create(function_id_items), true); - params_members[S_MESSAGE_TYPE] = CObjectSchemaItem::SMember( + params_members[S_MESSAGE_TYPE] = SMember( TEnumSchemaItem::create(message_type_items), true); params_members[S_PROTOCOL_VERSION] = - CObjectSchemaItem::SMember(TNumberSchemaItem::create(), true); + SMember(TNumberSchemaItem::create(), true); params_members[S_PROTOCOL_TYPE] = - CObjectSchemaItem::SMember(TNumberSchemaItem::create(), true); + SMember(TNumberSchemaItem::create(), true); params_members[S_CORRELATION_ID] = - CObjectSchemaItem::SMember(TNumberSchemaItem::create(), true); + SMember(TNumberSchemaItem::create(), true); - CObjectSchemaItem::Members root_members_map; - root_members_map[S_MSG_PARAMS] = CObjectSchemaItem::SMember( - CObjectSchemaItem::create(schema_members), true); - root_members_map[S_PARAMS] = CObjectSchemaItem::SMember( - CObjectSchemaItem::create(params_members), true); + Members root_members_map; + root_members_map[S_MSG_PARAMS] = + SMember(CObjectSchemaItem::create(schema_members), true); + root_members_map[S_PARAMS] = + SMember(CObjectSchemaItem::create(params_members), true); return CSmartSchema(CObjectSchemaItem::create(root_members_map)); } @@ -336,31 +331,29 @@ CSmartSchema CSmartFactoryTest::InitFunction_Function2_response( std::shared_ptr available_SchemaItem = CBoolSchemaItem::create(TSchemaItemParameter()); - CObjectSchemaItem::Members schema_members; + Members schema_members; - schema_members["available"] = - CObjectSchemaItem::SMember(available_SchemaItem, true); + schema_members["available"] = SMember(available_SchemaItem, true); - CObjectSchemaItem::Members params_members; - params_members[S_FUNCTION_ID] = CObjectSchemaItem::SMember( + Members params_members; + params_members[S_FUNCTION_ID] = SMember( TEnumSchemaItem::create(function_id_items), true); - params_members[S_MESSAGE_TYPE] = CObjectSchemaItem::SMember( + params_members[S_MESSAGE_TYPE] = SMember( TEnumSchemaItem::create(message_type_items), true); params_members[S_PROTOCOL_VERSION] = - CObjectSchemaItem::SMember(TNumberSchemaItem::create(), true); + SMember(TNumberSchemaItem::create(), true); params_members[S_PROTOCOL_TYPE] = - CObjectSchemaItem::SMember(TNumberSchemaItem::create(), true); + SMember(TNumberSchemaItem::create(), true); params_members[S_CORRELATION_ID] = - CObjectSchemaItem::SMember(TNumberSchemaItem::create(), true); - params_members[kCode] = - CObjectSchemaItem::SMember(TNumberSchemaItem::create(), true); + SMember(TNumberSchemaItem::create(), true); + params_members[kCode] = SMember(TNumberSchemaItem::create(), true); - CObjectSchemaItem::Members root_members_map; - root_members_map[S_MSG_PARAMS] = CObjectSchemaItem::SMember( - CObjectSchemaItem::create(schema_members), true); - root_members_map[S_PARAMS] = CObjectSchemaItem::SMember( - CObjectSchemaItem::create(params_members), true); + Members root_members_map; + root_members_map[S_MSG_PARAMS] = + SMember(CObjectSchemaItem::create(schema_members), true); + root_members_map[S_PARAMS] = + SMember(CObjectSchemaItem::create(params_members), true); return CSmartSchema(CObjectSchemaItem::create(root_members_map)); } @@ -368,26 +361,26 @@ CSmartSchema CSmartFactoryTest::InitFunction_Function2_response( CSmartSchema CSmartFactoryTest::InitFunction_Function3_request( const std::set& function_id_items, const std::set& message_type_items) { - CObjectSchemaItem::Members schema_members; + Members schema_members; - CObjectSchemaItem::Members params_members; - params_members[S_FUNCTION_ID] = CObjectSchemaItem::SMember( + Members params_members; + params_members[S_FUNCTION_ID] = SMember( TEnumSchemaItem::create(function_id_items), true); - params_members[S_MESSAGE_TYPE] = CObjectSchemaItem::SMember( + params_members[S_MESSAGE_TYPE] = SMember( TEnumSchemaItem::create(message_type_items), true); params_members[S_PROTOCOL_VERSION] = - CObjectSchemaItem::SMember(TNumberSchemaItem::create(), true); + SMember(TNumberSchemaItem::create(), true); params_members[S_PROTOCOL_TYPE] = - CObjectSchemaItem::SMember(TNumberSchemaItem::create(), true); + SMember(TNumberSchemaItem::create(), true); params_members[S_CORRELATION_ID] = - CObjectSchemaItem::SMember(TNumberSchemaItem::create(), true); + SMember(TNumberSchemaItem::create(), true); - CObjectSchemaItem::Members root_members_map; - root_members_map[S_MSG_PARAMS] = CObjectSchemaItem::SMember( - CObjectSchemaItem::create(schema_members), true); - root_members_map[S_PARAMS] = CObjectSchemaItem::SMember( - CObjectSchemaItem::create(params_members), true); + Members root_members_map; + root_members_map[S_MSG_PARAMS] = + SMember(CObjectSchemaItem::create(schema_members), true); + root_members_map[S_PARAMS] = + SMember(CObjectSchemaItem::create(params_members), true); return CSmartSchema(CObjectSchemaItem::create(root_members_map)); } @@ -402,31 +395,29 @@ CSmartSchema CSmartFactoryTest::InitFunction_Function3_response( std::shared_ptr available_SchemaItem = CBoolSchemaItem::create(TSchemaItemParameter()); - CObjectSchemaItem::Members schema_members; + Members schema_members; - schema_members["available"] = - CObjectSchemaItem::SMember(available_SchemaItem, true); + schema_members["available"] = SMember(available_SchemaItem, true); - CObjectSchemaItem::Members params_members; - params_members[S_FUNCTION_ID] = CObjectSchemaItem::SMember( + Members params_members; + params_members[S_FUNCTION_ID] = SMember( TEnumSchemaItem::create(function_id_items), true); - params_members[S_MESSAGE_TYPE] = CObjectSchemaItem::SMember( + params_members[S_MESSAGE_TYPE] = SMember( TEnumSchemaItem::create(message_type_items), true); params_members[S_PROTOCOL_VERSION] = - CObjectSchemaItem::SMember(TNumberSchemaItem::create(), true); + SMember(TNumberSchemaItem::create(), true); params_members[S_PROTOCOL_TYPE] = - CObjectSchemaItem::SMember(TNumberSchemaItem::create(), true); + SMember(TNumberSchemaItem::create(), true); params_members[S_CORRELATION_ID] = - CObjectSchemaItem::SMember(TNumberSchemaItem::create(), true); - params_members[kCode] = - CObjectSchemaItem::SMember(TNumberSchemaItem::create(), true); + SMember(TNumberSchemaItem::create(), true); + params_members[kCode] = SMember(TNumberSchemaItem::create(), true); - CObjectSchemaItem::Members root_members_map; - root_members_map[S_MSG_PARAMS] = CObjectSchemaItem::SMember( - CObjectSchemaItem::create(schema_members), true); - root_members_map[S_PARAMS] = CObjectSchemaItem::SMember( - CObjectSchemaItem::create(params_members), true); + Members root_members_map; + root_members_map[S_MSG_PARAMS] = + SMember(CObjectSchemaItem::create(schema_members), true); + root_members_map[S_PARAMS] = + SMember(CObjectSchemaItem::create(params_members), true); return CSmartSchema(CObjectSchemaItem::create(root_members_map)); } @@ -455,20 +446,19 @@ std::shared_ptr CSmartFactoryTest::InitStructSchemaItem_Common_1( TNumberSchemaItem::create(TSchemaItemParameter(1), TSchemaItemParameter(500), TSchemaItemParameter()); - CObjectSchemaItem::Members struct_members; - struct_members["image"] = CObjectSchemaItem::SMember(image_SchemaItem, false); + Members struct_members; + struct_members["image"] = SMember(image_SchemaItem, false); - CObjectSchemaItem::Members schema_members; + Members schema_members; - schema_members["text"] = CObjectSchemaItem::SMember(text_SchemaItem, true); - schema_members["position"] = - CObjectSchemaItem::SMember(position_SchemaItem, true); + schema_members["text"] = SMember(text_SchemaItem, true); + schema_members["position"] = SMember(position_SchemaItem, true); - CObjectSchemaItem::Members root_members_map; - root_members_map[""] = CObjectSchemaItem::SMember( - CObjectSchemaItem::create(struct_members), true); - root_members_map[""] = CObjectSchemaItem::SMember( - CObjectSchemaItem::create(schema_members), true); + Members root_members_map; + root_members_map[""] = + SMember(CObjectSchemaItem::create(struct_members), true); + root_members_map[""] = + SMember(CObjectSchemaItem::create(schema_members), true); return CObjectSchemaItem::create(schema_members); } @@ -489,10 +479,9 @@ CSmartFactoryTest::InitStructSchemaItem_Common_2() { TSchemaItemParameter(500), TSchemaItemParameter()); - CObjectSchemaItem::Members schema_members; - schema_members["text"] = CObjectSchemaItem::SMember(text_SchemaItem, true); - schema_members["position"] = - CObjectSchemaItem::SMember(position_SchemaItem, true); + Members schema_members; + schema_members["text"] = SMember(text_SchemaItem, true); + schema_members["position"] = SMember(position_SchemaItem, true); return CObjectSchemaItem::create(schema_members); } diff --git a/src/components/formatters/test/src/create_smartSchema.cc b/src/components/formatters/test/src/create_smartSchema.cc index 3602fc3de7b..c852c65ea12 100644 --- a/src/components/formatters/test/src/create_smartSchema.cc +++ b/src/components/formatters/test/src/create_smartSchema.cc @@ -189,39 +189,36 @@ CSmartSchema initObjectSchema() { TSchemaItemParameter()); // Map of parameters - std::map schemaMembersMap; + std::map schemaMembersMap; - schemaMembersMap["success"] = - CObjectSchemaItem::SMember(success_SchemaItem, false); - schemaMembersMap["resultCode"] = - CObjectSchemaItem::SMember(resultCode_SchemaItem, false); - schemaMembersMap["info"] = CObjectSchemaItem::SMember(info_SchemaItem, false); - schemaMembersMap["tryAgainTime"] = - CObjectSchemaItem::SMember(tryAgainTime_SchemaItem, false); + schemaMembersMap["success"] = SMember(success_SchemaItem, false); + schemaMembersMap["resultCode"] = SMember(resultCode_SchemaItem, false); + schemaMembersMap["info"] = SMember(info_SchemaItem, false); + schemaMembersMap["tryAgainTime"] = SMember(tryAgainTime_SchemaItem, false); - std::map paramsMembersMap; + std::map paramsMembersMap; paramsMembersMap[S_FUNCTION_ID] = - CObjectSchemaItem::SMember(TEnumSchemaItem::create( - functionId_allowedEnumSubsetValues), - true); - paramsMembersMap[S_MESSAGE_TYPE] = CObjectSchemaItem::SMember( - TEnumSchemaItem::create( - messageType_allowedEnumSubsetValues), - true); + SMember(TEnumSchemaItem::create( + functionId_allowedEnumSubsetValues), + true); + paramsMembersMap[S_MESSAGE_TYPE] = + SMember(TEnumSchemaItem::create( + messageType_allowedEnumSubsetValues), + true); paramsMembersMap[S_CORRELATION_ID] = - CObjectSchemaItem::SMember(TNumberSchemaItem::create(), true); - paramsMembersMap[S_PROTOCOL_VERSION] = CObjectSchemaItem::SMember( - TNumberSchemaItem::create(TSchemaItemParameter(1), - TSchemaItemParameter(2)), - true); + SMember(TNumberSchemaItem::create(), true); + paramsMembersMap[S_PROTOCOL_VERSION] = + SMember(TNumberSchemaItem::create(TSchemaItemParameter(1), + TSchemaItemParameter(2)), + true); paramsMembersMap[S_PROTOCOL_TYPE] = - CObjectSchemaItem::SMember(TNumberSchemaItem::create(), true); + SMember(TNumberSchemaItem::create(), true); - std::map rootMembersMap; - rootMembersMap[S_MSG_PARAMS] = CObjectSchemaItem::SMember( - CObjectSchemaItem::create(schemaMembersMap), true); - rootMembersMap[S_PARAMS] = CObjectSchemaItem::SMember( - CObjectSchemaItem::create(paramsMembersMap), true); + std::map rootMembersMap; + rootMembersMap[S_MSG_PARAMS] = + SMember(CObjectSchemaItem::create(schemaMembersMap), true); + rootMembersMap[S_PARAMS] = + SMember(CObjectSchemaItem::create(paramsMembersMap), true); return CSmartSchema(CObjectSchemaItem::create(rootMembersMap)); }; @@ -294,9 +291,9 @@ CSmartSchema initSchemaForMetaFormatter() { speechCapabilities_allowedEnumSubsetValues, TSchemaItemParameter()); - std::map ttsMap; - ttsMap["text"] = CObjectSchemaItem::SMember(ttsNameItem_SchemaItem, false); - ttsMap["type"] = CObjectSchemaItem::SMember(ttstype_SchemaItem, false); + std::map ttsMap; + ttsMap["text"] = SMember(ttsNameItem_SchemaItem, false); + ttsMap["type"] = SMember(ttstype_SchemaItem, false); ; ISchemaItemPtr hmiDisplayLanguageDesired_SchemaItem = @@ -350,62 +347,57 @@ CSmartSchema initSchemaForMetaFormatter() { TSchemaItemParameter(1000)); // Creation map for syncMsgVersion - std::map schemaSyncMsgVersionMap; + std::map schemaSyncMsgVersionMap; schemaSyncMsgVersionMap["majorVersion"] = - CObjectSchemaItem::SMember(majorVersion_SchemaItem, false); + SMember(majorVersion_SchemaItem, false); schemaSyncMsgVersionMap["minorVersion"] = - CObjectSchemaItem::SMember(minorVersion_SchemaItem, false); + SMember(minorVersion_SchemaItem, false); schemaSyncMsgVersionMap["patchVersion"] = - CObjectSchemaItem::SMember(patchVersion_SchemaItem, false); + SMember(patchVersion_SchemaItem, false); ; // Map of parameters - std::map schemaMembersMap; - - schemaMembersMap["appID"] = - CObjectSchemaItem::SMember(appID_SchemaItem, false); - schemaMembersMap["appName"] = - CObjectSchemaItem::SMember(appName_SchemaItem, false); - schemaMembersMap["appType"] = - CObjectSchemaItem::SMember(appType_SchemaItem, false); + std::map schemaMembersMap; + + schemaMembersMap["appID"] = SMember(appID_SchemaItem, false); + schemaMembersMap["appName"] = SMember(appName_SchemaItem, false); + schemaMembersMap["appType"] = SMember(appType_SchemaItem, false); schemaMembersMap["hmiDisplayLanguageDesired"] = - CObjectSchemaItem::SMember(hmiDisplayLanguageDesired_SchemaItem, false); + SMember(hmiDisplayLanguageDesired_SchemaItem, false); schemaMembersMap["isMediaApplication"] = - CObjectSchemaItem::SMember(isMediaApplication_SchemaItem, false); + SMember(isMediaApplication_SchemaItem, false); schemaMembersMap["languageDesired"] = - CObjectSchemaItem::SMember(languageDesired_SchemaItem, false); + SMember(languageDesired_SchemaItem, false); schemaMembersMap["ngnMediaScreenAppName"] = - CObjectSchemaItem::SMember(ngnMediaScreenAppName_SchemaItem, false); - schemaMembersMap["syncMsgVersion"] = CObjectSchemaItem::SMember( - CObjectSchemaItem::create(schemaSyncMsgVersionMap), false); - schemaMembersMap["ttsName"] = - CObjectSchemaItem::SMember(ttsName_SchemaItem, false); - schemaMembersMap["vrSynonyms"] = - CObjectSchemaItem::SMember(vrSynonyms_SchemaItem, false); - - std::map paramsMembersMap; + SMember(ngnMediaScreenAppName_SchemaItem, false); + schemaMembersMap["syncMsgVersion"] = + SMember(CObjectSchemaItem::create(schemaSyncMsgVersionMap), false); + schemaMembersMap["ttsName"] = SMember(ttsName_SchemaItem, false); + schemaMembersMap["vrSynonyms"] = SMember(vrSynonyms_SchemaItem, false); + + std::map paramsMembersMap; paramsMembersMap[S_FUNCTION_ID] = - CObjectSchemaItem::SMember(TEnumSchemaItem::create( - functionId_allowedEnumSubsetValues), - true); - paramsMembersMap[S_MESSAGE_TYPE] = CObjectSchemaItem::SMember( - TEnumSchemaItem::create( - messageType_allowedEnumSubsetValues), - true); + SMember(TEnumSchemaItem::create( + functionId_allowedEnumSubsetValues), + true); + paramsMembersMap[S_MESSAGE_TYPE] = + SMember(TEnumSchemaItem::create( + messageType_allowedEnumSubsetValues), + true); paramsMembersMap[S_CORRELATION_ID] = - CObjectSchemaItem::SMember(TNumberSchemaItem::create(), true); - paramsMembersMap[S_PROTOCOL_VERSION] = CObjectSchemaItem::SMember( - TNumberSchemaItem::create(TSchemaItemParameter(1), - TSchemaItemParameter(2)), - true); + SMember(TNumberSchemaItem::create(), true); + paramsMembersMap[S_PROTOCOL_VERSION] = + SMember(TNumberSchemaItem::create(TSchemaItemParameter(1), + TSchemaItemParameter(2)), + true); paramsMembersMap[S_PROTOCOL_TYPE] = - CObjectSchemaItem::SMember(TNumberSchemaItem::create(), true); + SMember(TNumberSchemaItem::create(), true); - std::map rootMembersMap; - rootMembersMap[S_MSG_PARAMS] = CObjectSchemaItem::SMember( - CObjectSchemaItem::create(schemaMembersMap), true); - rootMembersMap[S_PARAMS] = CObjectSchemaItem::SMember( - CObjectSchemaItem::create(paramsMembersMap), true); + std::map rootMembersMap; + rootMembersMap[S_MSG_PARAMS] = + SMember(CObjectSchemaItem::create(schemaMembersMap), true); + rootMembersMap[S_PARAMS] = + SMember(CObjectSchemaItem::create(paramsMembersMap), true); return CSmartSchema(CObjectSchemaItem::create(rootMembersMap)); }; diff --git a/src/components/formatters/test/src/meta_formatter_test_helper.cc b/src/components/formatters/test/src/meta_formatter_test_helper.cc index b322510f6c2..4f8975fe53d 100644 --- a/src/components/formatters/test/src/meta_formatter_test_helper.cc +++ b/src/components/formatters/test/src/meta_formatter_test_helper.cc @@ -29,8 +29,8 @@ * 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 "formatters/meta_formatter_test_helper.h" +#include "gtest/gtest.h" namespace test { namespace components { diff --git a/src/components/hmi_message_handler/include/hmi_message_handler/hmi_message_handler_impl.h b/src/components/hmi_message_handler/include/hmi_message_handler/hmi_message_handler_impl.h index 0d85c30fc20..167e2f84e62 100644 --- a/src/components/hmi_message_handler/include/hmi_message_handler/hmi_message_handler_impl.h +++ b/src/components/hmi_message_handler/include/hmi_message_handler/hmi_message_handler_impl.h @@ -47,12 +47,12 @@ namespace hmi_message_handler { namespace impl { /* -* These dummy classes are here to locally impose strong typing on different -* kinds of messages -* Currently there is no type difference between incoming and outgoing messages -* TODO(ik): replace these with globally defined message types -* when we have them. -*/ + * These dummy classes are here to locally impose strong typing on different + * kinds of messages + * Currently there is no type difference between incoming and outgoing messages + * TODO(ik): replace these with globally defined message types + * when we have them. + */ struct MessageFromHmi : public MessageSharedPointer { MessageFromHmi() {} explicit MessageFromHmi(const MessageSharedPointer& message) @@ -77,7 +77,7 @@ typedef threads::MessageLoopThread > FromHmiQueue; typedef threads::MessageLoopThread > ToHmiQueue; -} +} // namespace impl class ToHMIThreadImpl; class FromHMIThreadImpl; diff --git a/src/components/hmi_message_handler/include/hmi_message_handler/mb_controller.h b/src/components/hmi_message_handler/include/hmi_message_handler/mb_controller.h index 0a2e3e0f993..544a3ca2754 100644 --- a/src/components/hmi_message_handler/include/hmi_message_handler/mb_controller.h +++ b/src/components/hmi_message_handler/include/hmi_message_handler/mb_controller.h @@ -31,28 +31,27 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #ifndef MB_CONTROLLER_H #define MB_CONTROLLER_H -#include -#include -#include +#include +#include #include -#include -#include #include +#include +#include +#include +#include #include #include -#include #include #include #include +#include #include #include #include #include -#include #include "json/json.h" -#include "utils/macro.h" #include "utils/lock.h" -#include +#include "utils/macro.h" #include "websocket_session.h" using namespace boost::beast::websocket; @@ -181,6 +180,6 @@ class CMessageBrokerController std::atomic_bool shutdown_; }; -} // hmi_message_handler +} // namespace hmi_message_handler #endif /* MB_CONTROLLER_H */ \ No newline at end of file diff --git a/src/components/hmi_message_handler/include/hmi_message_handler/messagebroker_adapter.h b/src/components/hmi_message_handler/include/hmi_message_handler/messagebroker_adapter.h index 423f3312971..41bb7efa5d6 100644 --- a/src/components/hmi_message_handler/include/hmi_message_handler/messagebroker_adapter.h +++ b/src/components/hmi_message_handler/include/hmi_message_handler/messagebroker_adapter.h @@ -35,8 +35,8 @@ #include -#include "hmi_message_handler/mb_controller.h" #include "hmi_message_handler/hmi_message_adapter_impl.h" +#include "hmi_message_handler/mb_controller.h" #include "utils/threads/thread_validator.h" namespace hmi_message_handler { diff --git a/src/components/hmi_message_handler/include/hmi_message_handler/websocket_session.h b/src/components/hmi_message_handler/include/hmi_message_handler/websocket_session.h index 4d177d250f9..8edcfc1a361 100644 --- a/src/components/hmi_message_handler/include/hmi_message_handler/websocket_session.h +++ b/src/components/hmi_message_handler/include/hmi_message_handler/websocket_session.h @@ -31,43 +31,42 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #ifndef WEBSOCKET_SESSION_H #define WEBSOCKET_SESSION_H -#include -#include -#include +#include +#include #include -#include -#include #include +#include +#include +#include +#include #include #include -#include #include #include #include #include +#include +#include #include #include #include -#include -#include #include "json/json.h" -#include "utils/macro.h" #include "utils/lock.h" -#include -#include "utils/threads/thread.h" -#include "utils/threads/message_loop_thread.h" +#include "utils/macro.h" #include "utils/message_queue.h" +#include "utils/threads/message_loop_thread.h" +#include "utils/threads/thread.h" using namespace boost::beast::websocket; using ::utils::MessageQueue; #ifdef DEBUG_ON /** -* \def DBG_MSG -* \brief Debug message output with file name and line number. -* \param x formatted debug message. -* \return printf construction. -*/ + * \def DBG_MSG + * \brief Debug message output with file name and line number. + * \param x formatted debug message. + * \return printf construction. + */ #define DBG_MSG(x) \ printf("%s:%d ", __FILE__, __LINE__); \ printf x @@ -203,6 +202,6 @@ class WebsocketSession : public std::enable_shared_from_this { threads::Thread* thread_; }; -} // hmi_message_handler +} // namespace hmi_message_handler #endif /* WEBSOCKET_SESSION_H */ \ No newline at end of file diff --git a/src/components/hmi_message_handler/src/mb_controller.cc b/src/components/hmi_message_handler/src/mb_controller.cc index 4f46026039f..ffc6ef23a31 100644 --- a/src/components/hmi_message_handler/src/mb_controller.cc +++ b/src/components/hmi_message_handler/src/mb_controller.cc @@ -337,8 +337,8 @@ bool CMessageBrokerController::addSubscriber(WebsocketSession* ws_session, bool result = true; sync_primitives::AutoLock lock(mSubscribersListLock); std::pair::iterator, - std::multimap::iterator> p = - mSubscribersList.equal_range(name); + std::multimap::iterator> + p = mSubscribersList.equal_range(name); if (p.first != p.second) { std::multimap::iterator itr; for (itr = p.first; itr != p.second; itr++) { @@ -359,8 +359,8 @@ void CMessageBrokerController::deleteSubscriber(WebsocketSession* ws, std::string name) { sync_primitives::AutoLock lock(mSubscribersListLock); std::pair::iterator, - std::multimap::iterator> p = - mSubscribersList.equal_range(name); + std::multimap::iterator> + p = mSubscribersList.equal_range(name); if (p.first != p.second) { std::multimap::iterator itr; for (itr = p.first; itr != p.second;) { @@ -380,8 +380,8 @@ int CMessageBrokerController::getSubscribersFd( sync_primitives::AutoLock lock(mSubscribersListLock); std::pair::iterator, - std::multimap::iterator> p = - mSubscribersList.equal_range(name); + std::multimap::iterator> + p = mSubscribersList.equal_range(name); if (p.first != p.second) { std::multimap::iterator itr; for (itr = p.first; itr != p.second; itr++) { @@ -501,4 +501,4 @@ void CMessageBrokerController::processInternalRequest( int CMessageBrokerController::getNextControllerId() { return 1000 * mControllersIdCounter++; } -} +} // namespace hmi_message_handler diff --git a/src/components/hmi_message_handler/src/messagebroker_adapter.cc b/src/components/hmi_message_handler/src/messagebroker_adapter.cc index 8e45d4ecd90..52fb3d35df7 100644 --- a/src/components/hmi_message_handler/src/messagebroker_adapter.cc +++ b/src/components/hmi_message_handler/src/messagebroker_adapter.cc @@ -139,7 +139,7 @@ void MessageBrokerAdapter::SubscribeTo() { MessageBrokerController::subscribeTo("RC.OnInteriorVehicleData"); MessageBrokerController::subscribeTo("RC.OnRemoteControlSettings"); MessageBrokerController::subscribeTo( - "SystemCapability.OnSystemCapabilityUpdated"); + "BasicCommunication.OnSystemCapabilityUpdated"); LOG4CXX_INFO(logger_, "Subscribed to notifications."); } diff --git a/src/components/hmi_message_handler/src/websocket_session.cc b/src/components/hmi_message_handler/src/websocket_session.cc index a148f486615..3d18da19d2b 100644 --- a/src/components/hmi_message_handler/src/websocket_session.cc +++ b/src/components/hmi_message_handler/src/websocket_session.cc @@ -29,8 +29,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "hmi_message_handler/websocket_session.h" -#include "hmi_message_handler/mb_controller.h" #include +#include "hmi_message_handler/mb_controller.h" using namespace boost::beast::websocket; namespace hmi_message_handler { @@ -319,4 +319,4 @@ void WebsocketSession::LoopThreadDelegate::SetShutdown() { message_queue_.Shutdown(); } } -} +} // namespace hmi_message_handler diff --git a/src/components/hmi_message_handler/test/hmi_message_adapter_test.cc b/src/components/hmi_message_handler/test/hmi_message_adapter_test.cc index 73fe76640d0..5762566b96f 100644 --- a/src/components/hmi_message_handler/test/hmi_message_adapter_test.cc +++ b/src/components/hmi_message_handler/test/hmi_message_adapter_test.cc @@ -40,8 +40,8 @@ namespace test { namespace components { namespace hmi_message_handler_test { -using ::testing::Return; using hmi_message_handler::HMIMessageHandlerImpl; +using ::testing::Return; typedef std::shared_ptr MockHMIMessageAdapterImplSPtr; @@ -74,6 +74,6 @@ TEST(HMIMessageAdapterImplTest, Handler_NULLPointer_CorrectReturnedPointer) { EXPECT_EQ(NULL, message_adapter_impl->get_handler()); } -} // namespace hmi_message_helper_test +} // namespace hmi_message_handler_test } // namespace components } // namespace test diff --git a/src/components/hmi_message_handler/test/hmi_message_handler_impl_test.cc b/src/components/hmi_message_handler/test/hmi_message_handler_impl_test.cc index e66f900299e..eaa274d0f46 100644 --- a/src/components/hmi_message_handler/test/hmi_message_handler_impl_test.cc +++ b/src/components/hmi_message_handler/test/hmi_message_handler_impl_test.cc @@ -30,21 +30,21 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include "gtest/gtest.h" -#include "application_manager/message.h" #include "hmi_message_handler/hmi_message_handler_impl.h" +#include "application_manager/message.h" +#include "gtest/gtest.h" #include "hmi_message_handler/messagebroker_adapter.h" -#include "hmi_message_handler/mock_hmi_message_observer.h" -#include "hmi_message_handler/mock_hmi_message_handler_settings.h" #include "hmi_message_handler/mock_hmi_message_adapter_impl.h" +#include "hmi_message_handler/mock_hmi_message_handler_settings.h" +#include "hmi_message_handler/mock_hmi_message_observer.h" #include "utils/test_async_waiter.h" namespace test { namespace components { namespace hmi_message_handler_test { -using ::testing::Return; using ::testing::_; +using ::testing::Return; class HMIMessageHandlerImplTest : public ::testing::Test { public: diff --git a/src/components/hmi_message_handler/test/include/hmi_message_handler/mock_hmi_message_adapter_impl.h b/src/components/hmi_message_handler/test/include/hmi_message_handler/mock_hmi_message_adapter_impl.h index 0ec82b78624..4984fce23d5 100644 --- a/src/components/hmi_message_handler/test/include/hmi_message_handler/mock_hmi_message_adapter_impl.h +++ b/src/components/hmi_message_handler/test/include/hmi_message_handler/mock_hmi_message_adapter_impl.h @@ -1,34 +1,34 @@ /* -* Copyright (c) 2015, 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) 2015, 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 "gmock/gmock.h" #include "hmi_message_handler/hmi_message_adapter_impl.h" diff --git a/src/components/include/application_manager/app_launch_settings.h b/src/components/include/application_manager/app_launch_settings.h index 47daf2f87c8..fb65997c699 100644 --- a/src/components/include/application_manager/app_launch_settings.h +++ b/src/components/include/application_manager/app_launch_settings.h @@ -17,6 +17,6 @@ class AppLaunchSettings { virtual const std::string& app_storage_folder() const = 0; }; -} // namespace application_manager +} // namespace app_launch #endif // SRC_COMPONENTS_INCLUDE_APPLICATION_MANAGER_APP_LAUNCH_SETTINGS_H_ diff --git a/src/components/include/application_manager/application_manager.h b/src/components/include/application_manager/application_manager.h index e8f646c1e57..fa2e8941b8f 100644 --- a/src/components/include/application_manager/application_manager.h +++ b/src/components/include/application_manager/application_manager.h @@ -34,23 +34,20 @@ #define SRC_COMPONENTS_INCLUDE_APPLICATION_MANAGER_APPLICATION_MANAGER_H_ #include +#include #include #include -#include #include "application_manager/application.h" -#include "application_manager/hmi_capabilities.h" #include "application_manager/commands/command.h" -#include "application_manager/command_factory.h" #include "connection_handler/connection_handler.h" #include "utils/data_accessor.h" -#include "telemetry_monitor/telemetry_observable.h" -#include "application_manager/policies/policy_handler_interface.h" #include "application_manager/application_manager_settings.h" -#include "application_manager/state_controller.h" #include "application_manager/hmi_interfaces.h" -#include "policy/policy_types.h" #include "application_manager/plugin_manager/rpc_plugin_manager.h" +#include "application_manager/state_controller.h" +#include "policy/policy_types.h" +#include "telemetry_monitor/telemetry_observable.h" namespace resumption { class LastState; @@ -77,6 +74,10 @@ namespace resumption { class ResumeCtrl; } +namespace policy { +class PolicyHandlerInterface; +} + namespace application_manager { namespace event_engine { @@ -95,9 +96,12 @@ class StateControllerImpl; struct CommandParametersPermissions; using policy::RPCParams; typedef std::vector AppSharedPtrs; -struct ApplicationsAppIdSorter { +struct ApplicationsSorter { bool operator()(const ApplicationSharedPtr lhs, const ApplicationSharedPtr rhs) const { + if (lhs->app_id() == rhs->app_id()) { + return lhs->device() < rhs->device(); + } return lhs->app_id() < rhs->app_id(); } }; @@ -111,11 +115,17 @@ struct ApplicationsPolicyAppIdSorter { } }; -typedef std::set ApplicationSet; +typedef std::set ApplicationSet; typedef std::set AppsWaitRegistrationSet; +/** + * @brief ReregisterWaitList is list of applications expected to be + * re-registered after transport switching is complete + */ +typedef std::vector ReregisterWaitList; + // typedef for Applications list iterator typedef ApplicationSet::iterator ApplicationSetIt; @@ -156,6 +166,7 @@ class ApplicationManager { virtual DataAccessor applications() const = 0; virtual DataAccessor pending_applications() const = 0; + virtual DataAccessor reregister_applications() const = 0; virtual ApplicationSharedPtr application(uint32_t app_id) const = 0; virtual ApplicationSharedPtr active_application() const = 0; @@ -177,16 +188,19 @@ class ApplicationManager { virtual ApplicationSharedPtr pending_application_by_policy_id( const std::string& policy_app_id) const = 0; + virtual ApplicationSharedPtr reregister_application_by_policy_id( + const std::string& policy_app_id) const = 0; + virtual AppSharedPtrs applications_by_button(uint32_t button) = 0; virtual AppSharedPtrs applications_with_navi() = 0; /** - * @brief application find application by device and policy identifier - * @param device_id device id - * @param policy_app_id poilcy identifier - * @return pointer to application in case if application exist, in other case - * return empty shared pointer - */ + * @brief application find application by device and policy identifier + * @param device_id device id + * @param policy_app_id poilcy identifier + * @return pointer to application in case if application exist, in other case + * return empty shared pointer + */ virtual ApplicationSharedPtr application( const std::string& device_id, const std::string& policy_app_id) const = 0; @@ -278,15 +292,6 @@ class ApplicationManager { mobile_apis::HMILevel::eType from, mobile_apis::HMILevel::eType to) = 0; - /** - * @brief Sends HMI status notification to mobile - * - * @param application_impl application with changed HMI status - * - **/ - virtual void SendHMIStatusNotification( - const std::shared_ptr app) = 0; - /** * @brief Checks if driver distraction state is valid, creates message * which is sent to the application if allowed, otherwise it is added @@ -467,11 +472,11 @@ class ApplicationManager { * @param vehicle_info Enum value of type of vehicle data * @param new value (for integer values currently) of vehicle data */ - virtual void IviInfoUpdated(mobile_apis::VehicleDataType::eType vehicle_info, - int value) = 0; + virtual void IviInfoUpdated(const std::string& vehicle_info, int value) = 0; - virtual ApplicationSharedPtr RegisterApplication(const std::shared_ptr< - smart_objects::SmartObject>& request_for_registration) = 0; + virtual ApplicationSharedPtr RegisterApplication( + const std::shared_ptr& + request_for_registration) = 0; virtual void SendUpdateAppList() = 0; @@ -606,8 +611,8 @@ class ApplicationManager { /** * @brief Checks, if given RPC is allowed at current HMI level for specific * application in policy table - * @param policy_app_id Application id - * @param hmi_level Current HMI level of application + * @param app Application + * @param window_id id of application's window * @param function_id FunctionID of RPC * @param params_permissions Permissions for RPC parameters (e.g. * SubscribeVehicleData) defined in policy table @@ -615,6 +620,7 @@ class ApplicationManager { */ virtual mobile_apis::Result::eType CheckPolicyPermissions( const ApplicationSharedPtr app, + const WindowID window_id, const std::string& function_id, const RPCParams& rpc_params, CommandParametersPermissions* params_permissions = NULL) = 0; @@ -635,19 +641,22 @@ class ApplicationManager { /** * @brief IsAppInReconnectMode check if application belongs to session * affected by transport switching at the moment + * @param device_id device indentifier * @param policy_app_id Application id * @return True if application is registered within session being switched, * otherwise - false */ - virtual bool IsAppInReconnectMode(const std::string& policy_app_id) const = 0; + virtual bool IsAppInReconnectMode( + const connection_handler::DeviceHandle& device_id, + const std::string& policy_app_id) const = 0; virtual resumption::ResumeCtrl& resume_controller() = 0; /** - * @brief hmi_interfaces getter for hmi_interfaces component, that handle - * hmi_instrfaces state - * @return reference to hmi_interfaces component - */ + * @brief hmi_interfaces getter for hmi_interfaces component, that handle + * hmi_instrfaces state + * @return reference to hmi_interfaces component + */ virtual HmiInterfaces& hmi_interfaces() = 0; virtual app_launch::AppLaunchCtrl& app_launch_ctrl() = 0; @@ -675,19 +684,19 @@ class ApplicationManager { virtual void AddAppToTTSGlobalPropertiesList(const uint32_t app_id) = 0; /** - * Generate grammar ID - * - * @return New grammar ID - */ + * Generate grammar ID + * + * @return New grammar ID + */ virtual uint32_t GenerateGrammarID() = 0; virtual policy::DeviceConsent GetUserConsentForDevice( const std::string& device_id) const = 0; /** - * @brief Handle sequence for unauthorized application - * @param app_id Application id - */ + * @brief Handle sequence for unauthorized application + * @param app_id Application id + */ virtual void OnAppUnauthorized(const uint32_t& app_id) = 0; virtual bool ActivateApplication(ApplicationSharedPtr app) = 0; @@ -705,6 +714,7 @@ class ApplicationManager { /** * @brief CreateRegularState create regular HMI state for application * @param app Application + * @param window_type type of window * @param hmi_level of returned state * @param audio_state of returned state * @param system_context of returned state @@ -712,10 +722,11 @@ class ApplicationManager { */ virtual HmiStatePtr CreateRegularState( std::shared_ptr app, - mobile_apis::HMILevel::eType hmi_level, - mobile_apis::AudioStreamingState::eType audio_state, - mobile_apis::VideoStreamingState::eType video_state, - mobile_apis::SystemContext::eType system_context) const = 0; + const mobile_apis::WindowType::eType window_type, + const mobile_apis::HMILevel::eType hmi_level, + const mobile_apis::AudioStreamingState::eType audio_state, + const mobile_apis::VideoStreamingState::eType video_state, + const mobile_apis::SystemContext::eType system_context) const = 0; /** * @brief Checks if application can stream (streaming service is started and diff --git a/src/components/include/application_manager/application_manager_settings.h b/src/components/include/application_manager/application_manager_settings.h index b206e56125a..524feed6e5d 100644 --- a/src/components/include/application_manager/application_manager_settings.h +++ b/src/components/include/application_manager/application_manager_settings.h @@ -33,12 +33,12 @@ #ifndef SRC_COMPONENTS_INCLUDE_APPLICATION_MANAGER_APPLICATION_MANAGER_SETTINGS_H_ #define SRC_COMPONENTS_INCLUDE_APPLICATION_MANAGER_APPLICATION_MANAGER_SETTINGS_H_ -#include "application_manager/request_controller_settings.h" #include "application_manager/app_launch_settings.h" +#include "application_manager/request_controller_settings.h" #include -#include #include +#include #include namespace application_manager { @@ -83,6 +83,7 @@ class ApplicationManagerSettings : public RequestControlerSettings, virtual const std::string& named_audio_pipe_path() const = 0; virtual const std::string& video_stream_file() const = 0; virtual const std::string& audio_stream_file() const = 0; + virtual uint16_t period_for_consent_expiration() const = 0; virtual bool use_full_app_id() const = 0; virtual uint32_t rpc_pass_through_timeout() const = 0; diff --git a/src/components/include/application_manager/hmi_capabilities.h b/src/components/include/application_manager/hmi_capabilities.h index 1283584ef86..8e59bcc74d1 100644 --- a/src/components/include/application_manager/hmi_capabilities.h +++ b/src/components/include/application_manager/hmi_capabilities.h @@ -28,17 +28,17 @@ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. -*/ + */ #ifndef SRC_COMPONENTS_INCLUDE_APPLICATION_MANAGER_HMI_CAPABILITIES_H_ #define SRC_COMPONENTS_INCLUDE_APPLICATION_MANAGER_HMI_CAPABILITIES_H_ +#include "application_manager/hmi_language_handler.h" #include "interfaces/HMI_API.h" #include "interfaces/MOBILE_API.h" #include "json/json.h" -#include "utils/macro.h" -#include "application_manager/hmi_language_handler.h" #include "smart_objects/smart_object.h" +#include "utils/macro.h" namespace resumption { class LastState; @@ -56,16 +56,16 @@ class HMICapabilities { virtual ~HMICapabilities() {} /** - * @brief return component which follows for correctness of - * languages - * @return HMI language handler - */ + * @brief return component which follows for correctness of + * languages + * @return HMI language handler + */ virtual HMILanguageHandler& get_hmi_language_handler() = 0; /* - * @brief Checks is image type(Static/Dynamic) requested by + * @brief Checks if image type(Static/Dynamic) requested by * Mobile Device is supported on current HMI. - * @param image_type recieved type of image from Enum. + * @param image_type received type of image from Enum. * @return Bool true if supported */ virtual bool VerifyImageType(const int32_t image_type) const = 0; @@ -229,6 +229,20 @@ class HMICapabilities { virtual void set_display_capabilities( const smart_objects::SmartObject& display_capabilities) = 0; + /* + * @brief Retrieves information about the display capability + * @return Currently supported display capability + */ + virtual const smart_objects::SmartObjectSPtr system_display_capabilities() + const = 0; + + /* + * @brief Sets supported display capability + * @param display_capabilities supported display capability + */ + virtual void set_system_display_capabilities( + const smart_objects::SmartObject& display_capabilities) = 0; + /* * @brief Retrieves information about the HMI zone capabilities * @@ -499,6 +513,22 @@ class HMICapabilities { virtual const smart_objects::SmartObject* rc_capability() const = 0; + /** + * @brief Sets available SeatLocation capabilities for further usage by + * RC functionality + * @param seat_location_capability capabilities to set + */ + virtual void set_seat_location_capability( + const smart_objects::SmartObject& seat_location_capability) = 0; + + /** + * @brief seat_location_capability Retrieves information regarding the + * seat location capability + * @return smart object of seat location capability + */ + virtual const smart_objects::SmartObject* seat_location_capability() + const = 0; + virtual void Init(resumption::LastState* last_state) = 0; /** @@ -525,6 +555,18 @@ class HMICapabilities { virtual void convert_json_languages_to_obj( const Json::Value& json_languages, smart_objects::SmartObject& languages) const = 0; + + /* + * @brief function that converts a single entry of audio pass thru capability + * to smart object + * + * @param capability json object that represents a single entry of audio pass + * thru capability + * @param output_so the converted object + */ + virtual void convert_audio_capability_to_obj( + const Json::Value& capability, + smart_objects::SmartObject& output_so) const = 0; }; } // namespace application_manager diff --git a/src/components/include/application_manager/policies/policy_encryption_flag_getter.h b/src/components/include/application_manager/policies/policy_encryption_flag_getter.h new file mode 100644 index 00000000000..1a004fb9261 --- /dev/null +++ b/src/components/include/application_manager/policies/policy_encryption_flag_getter.h @@ -0,0 +1,106 @@ +/* + * Copyright (c) 2019, Ford Motor Company + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following + * disclaimer in the documentation and/or other materials provided with the + * distribution. + * + * Neither the name of the Ford Motor Company nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef SRC_COMPONENTS_INCLUDE_APPLICATION_MANAGER_POLICIES_POLICY_ENCRYPTION_FLAG_GETTER +#define SRC_COMPONENTS_INCLUDE_APPLICATION_MANAGER_POLICIES_POLICY_ENCRYPTION_FLAG_GETTER + +#include +#include "policy/policy_table/types.h" + +using rpc::policy_table_interface_base::Strings; + +namespace policy { +/* + * @brief PolicyEncryptionFlagGetterInterface interface + */ +class PolicyEncryptionFlagGetterInterface { + public: + /*! + * @brief virtual destructor PolicyEncryptionFlagGetterInterface + */ + virtual ~PolicyEncryptionFlagGetterInterface() {} + + /* + * @brief retreives flag whether given application needs encryption + * @param policy_app_id policy app id + * @return true if the app need encryption + */ + virtual bool AppNeedEncryption(const std::string& policy_app_id) const = 0; + + /* + * @brief Retrieves encryption required flag on the application level + * @param policy_app_id policy app id + * @return true if the app need encryption + */ + virtual const rpc::Optional GetAppEncryptionRequired( + const std::string& policy_app_id) const = 0; + + /* + * @brief retreives function group for app + * @param policy_app_id policy app id + * @return groups that exist for app + */ + virtual const std::vector GetFunctionalGroupsForApp( + const std::string& policy_app_id) const = 0; + + /* + * @brief retreives flag indicating whether function group needs encryption + * @param policy_group group + * @return true if the group need encryption + */ + virtual bool FunctionGroupNeedEncryption( + const std::string& policy_group) const = 0; + + /* + * @brief retreives rpcs for given function group + * @param policy_group group + * @return RPCs that exists in group + */ + virtual const std::vector GetRPCsForFunctionGroup( + const std::string& group) const = 0; + + /* + * @brief retreives policy function name + * @param function_id function id + * @return policy function name + */ + virtual const std::string GetPolicyFunctionName( + const uint32_t function_id) const = 0; + /* + * @brief retrieves application names from policy table + * @return container with policy application names + */ + virtual const std::vector GetApplicationPolicyIDs() const = 0; +}; + +} // namespace policy +#endif // SRC_COMPONENTS_INCLUDE_APPLICATION_MANAGER_POLICIES_POLICY_ENCRYPTION_FLAG_GETTER diff --git a/src/components/include/application_manager/policies/policy_handler_interface.h b/src/components/include/application_manager/policies/policy_handler_interface.h index c7caae1d28c..190a1f786b5 100644 --- a/src/components/include/application_manager/policies/policy_handler_interface.h +++ b/src/components/include/application_manager/policies/policy_handler_interface.h @@ -33,32 +33,46 @@ #ifndef SRC_COMPONENTS_INCLUDE_APPLICATION_MANAGER_POLICIES_POLICY_HANDLER_INTERFACE_H_ #define SRC_COMPONENTS_INCLUDE_APPLICATION_MANAGER_POLICIES_POLICY_HANDLER_INTERFACE_H_ -#include #include +#include #include +#include #include -#include -#include "interfaces/MOBILE_API.h" -#include "application_manager/policies/policy_handler_observer.h" +#include "boost/optional.hpp" + #include "application_manager/application.h" -#include "policy/usage_statistics/statistics_manager.h" -#include "utils/custom_string.h" -#include "utils/callable.h" +#include "application_manager/policies/custom_vehicle_data_provider.h" +#include "application_manager/policies/policy_encryption_flag_getter.h" +#include "application_manager/policies/policy_handler_observer.h" +#include "interfaces/MOBILE_API.h" +#include "policy/cache_manager_interface.h" #include "policy/policy_settings.h" -#include "smart_objects/smart_object.h" -#include "policy/policy_types.h" #include "policy/policy_table/types.h" -#include "policy/cache_manager_interface.h" +#include "policy/policy_types.h" +#include "policy/usage_statistics/statistics_manager.h" +#include "smart_objects/smart_object.h" +#include "utils/callable.h" +#include "utils/custom_string.h" +#include "utils/optional.h" +#ifdef EXTERNAL_PROPRIETARY_MODE +#include "policy/ptu_retry_handler.h" +#endif // EXTERNAL_PROPRIETARY_MODE using namespace ::rpc::policy_table_interface_base; namespace policy { typedef std::shared_ptr StatusNotifier; +typedef std::shared_ptr + PolicyEncryptionFlagGetterInterfaceSPtr; -class PolicyHandlerInterface { +class PTURetryHandler; + +class PolicyHandlerInterface : public VehicleDataItemProvider { public: virtual ~PolicyHandlerInterface() {} virtual bool LoadPolicyLibrary() = 0; + virtual PolicyEncryptionFlagGetterInterfaceSPtr PolicyEncryptionFlagGetter() + const = 0; virtual bool PolicyEnabled() const = 0; virtual bool InitPolicyTable() = 0; virtual bool ResetPolicyTable() = 0; @@ -68,25 +82,30 @@ class PolicyHandlerInterface { virtual bool ReceiveMessageFromSDK(const std::string& file, const BinaryMessage& pt_string) = 0; virtual bool UnloadPolicyLibrary() = 0; - virtual void OnPermissionsUpdated(const std::string& policy_app_id, + virtual void OnPermissionsUpdated(const std::string& device_id, + const std::string& policy_app_id, const Permissions& permissions, const HMILevel& default_hmi) = 0; - - virtual void OnPermissionsUpdated(const std::string& policy_app_id, + virtual void OnPermissionsUpdated(const std::string& device_id, + const std::string& policy_app_id, const Permissions& permissions) = 0; #ifdef EXTERNAL_PROPRIETARY_MODE virtual void OnSnapshotCreated(const BinaryMessage& pt_string, const std::vector& retry_delay_seconds, uint32_t timeout_exchange) = 0; + + virtual PTURetryHandler& ptu_retry_handler() const = 0; #else // EXTERNAL_PROPRIETARY_MODE - virtual void OnSnapshotCreated(const BinaryMessage& pt_string) = 0; + virtual void OnSnapshotCreated(const BinaryMessage& pt_string, + const PTUIterationType iteration_type) = 0; #endif // EXTERNAL_PROPRIETARY_MODE virtual bool GetPriority(const std::string& policy_app_id, std::string* priority) const = 0; virtual void CheckPermissions( const application_manager::ApplicationSharedPtr app, + const application_manager::WindowID window_id, const PTString& rpc, const RPCParams& rpc_params, CheckPermissionResult& result) = 0; @@ -95,7 +114,8 @@ class PolicyHandlerInterface { const std::string& priority) const = 0; virtual DeviceConsent GetUserConsentForDevice( const std::string& device_id) const = 0; - virtual bool GetDefaultHmi(const std::string& policy_app_id, + virtual bool GetDefaultHmi(const std::string& device_id, + const std::string& policy_app_id, std::string* default_hmi) const = 0; virtual bool GetInitialAppData(const std::string& application_id, StringArray* nicknames = NULL, @@ -104,6 +124,7 @@ class PolicyHandlerInterface { EndpointUrls& out_end_points) = 0; virtual void GetUpdateUrls(const uint32_t service_type, EndpointUrls& out_end_points) = 0; + virtual Json::Value GetPolicyTableData() const = 0; virtual std::string GetLockScreenIconUrl() const = 0; virtual std::string GetIconUrl(const std::string& policy_app_id) const = 0; virtual uint32_t NextRetryTimeout() = 0; @@ -121,6 +142,10 @@ class PolicyHandlerInterface { virtual uint32_t TimeoutExchangeMSec() const = 0; virtual void OnExceededTimeout() = 0; virtual void OnSystemReady() = 0; + virtual const boost::optional LockScreenDismissalEnabledState() + const = 0; + virtual const boost::optional LockScreenDismissalWarningMessage( + const std::string& language) const = 0; virtual void PTUpdatedAt(Counters counter, int value) = 0; virtual void add_listener(PolicyHandlerObserver* listener) = 0; virtual void remove_listener(PolicyHandlerObserver* listener) = 0; @@ -130,6 +155,7 @@ class PolicyHandlerInterface { virtual void SendOnAppPermissionsChanged( const AppPermissions& permissions, + const std::string& device_id, const std::string& policy_app_id) const = 0; /** @@ -169,7 +195,8 @@ class PolicyHandlerInterface { */ virtual void OnIgnitionCycleOver() = 0; - virtual void OnPendingPermissionChange(const std::string& policy_app_id) = 0; + virtual void OnPendingPermissionChange(const std::string& device_id, + const std::string& policy_app_id) = 0; /** * Initializes PT exchange at user request @@ -194,13 +221,13 @@ class PolicyHandlerInterface { const DeviceInfo& device_info) = 0; /** -*@brief Processes data from OnAppPermissionConsent notification with -*permissions changes and ExternalConsent status changes done by user -*@param connection_key Connection key of application, 0 if no key has been -*provided -*@param permissions Groups permissions changes -*@param external_consent_status Customer connectivity settings status changes -*/ + *@brief Processes data from OnAppPermissionConsent notification with + *permissions changes and ExternalConsent status changes done by user + *@param connection_key Connection key of application, 0 if no key has been + *provided + *@param permissions Groups permissions changes + *@param external_consent_status Customer connectivity settings status changes + */ #ifdef EXTERNAL_PROPRIETARY_MODE virtual void OnAppPermissionConsent( const uint32_t connection_key, @@ -248,9 +275,11 @@ class PolicyHandlerInterface { /** * @brief Update currently used device id in policies manager for given * application + * @param device_handle device identifier * @param policy_app_id Application id */ virtual std::string OnCurrentDeviceIdUpdateRequired( + const transport_manager::DeviceHandle& device_handle, const std::string& policy_app_id) = 0; /** @@ -320,6 +349,13 @@ class PolicyHandlerInterface { virtual void OnPTUFinished(const bool ptu_result) = 0; + virtual void OnPTInited() = 0; + + /** + * @brief Force stops retry sequence timer and resets retry sequence + */ + virtual void StopRetrySequence() = 0; + #ifdef EXTERNAL_PROPRIETARY_MODE virtual void OnCertificateDecrypted(bool is_succeeded) = 0; #endif // EXTERNAL_PROPRIETARY_MODE @@ -335,10 +371,12 @@ class PolicyHandlerInterface { /** * @brief Allows to add new or update existed application during * registration process + * @param device_id device identifier * @param application_id The policy aplication id. * @return function that will notify update manager about new application */ virtual StatusNotifier AddApplication( + const std::string& device_id, const std::string& application_id, const rpc::policy_table_interface_base::AppHmiTypes& hmi_types) = 0; @@ -377,17 +415,21 @@ class PolicyHandlerInterface { * succesfully registered on mobile device. * It will send OnAppPermissionSend notification and will try to start PTU. * + * @param device_id device identifier * @param application_id registered application. */ - virtual void OnAppRegisteredOnMobile(const std::string& application_id) = 0; + virtual void OnAppRegisteredOnMobile(const std::string& device_id, + const std::string& application_id) = 0; /** * @brief Checks if certain request type is allowed for application + * @param device_handle device identifier * @param policy_app_id Unique applicaion id * @param type Request type * @return true, if allowed, otherwise - false */ virtual bool IsRequestTypeAllowed( + const transport_manager::DeviceHandle& device_handle, const std::string& policy_app_id, mobile_apis::RequestType::eType type) const = 0; @@ -419,10 +461,12 @@ class PolicyHandlerInterface { /** * @brief Gets application request types + * @param device_handle device identifier * @param policy_app_id Unique application id * @return request types */ virtual const std::vector GetAppRequestTypes( + const transport_manager::DeviceHandle& device_handle, const std::string& policy_app_id) const = 0; /** @@ -433,12 +477,6 @@ class PolicyHandlerInterface { virtual const std::vector GetAppRequestSubTypes( const std::string& policy_app_id) const = 0; - /** - * @brief Gets vehicle information - * @return Structure with vehicle information - */ - virtual const VehicleInfo GetVehicleInfo() const = 0; - /** * @brief Get a list of enabled cloud applications * @param enabled_apps List filled with the policy app id of each enabled @@ -519,7 +557,7 @@ class PolicyHandlerInterface { * @brief Check if an app can send unknown rpc requests to an app service * provider * @param policy_app_id Unique application id - */ + */ virtual bool UnknownRPCPassthroughAllowed( const std::string& policy_app_id) const = 0; @@ -558,10 +596,12 @@ class PolicyHandlerInterface { /** * @brief Sets HMI default type for specified application + * @param device_handle device identifier * @param application_id ID application * @param app_types list of HMI types */ virtual void SetDefaultHmiTypes( + const transport_manager::DeviceHandle& device_handle, const std::string& application_id, const smart_objects::SmartObject* app_types) = 0; @@ -626,14 +666,14 @@ class PolicyHandlerInterface { * @brief Processes data received via OnAppPermissionChanged notification * from. Being started asyncronously from AppPermissionDelegate class. * Sets updated permissions and ExternalConsent for registered applications -*and + *and * applications which already have appropriate group assigned which related to * devices already known by policy * @param connection_key Connection key of application, 0 if no key has been * provided within notification * @param external_consent_status Customer connectivity settings changes to -*process -*@param permissions Permissions changes to process + *process + *@param permissions Permissions changes to process */ #ifdef EXTERNAL_PROPRIETARY_MODE virtual void OnAppPermissionConsentInternal( diff --git a/src/components/include/application_manager/policies/policy_handler_observer.h b/src/components/include/application_manager/policies/policy_handler_observer.h index c13846dff22..fc22d196df5 100644 --- a/src/components/include/application_manager/policies/policy_handler_observer.h +++ b/src/components/include/application_manager/policies/policy_handler_observer.h @@ -34,8 +34,8 @@ #define SRC_COMPONENTS_INCLUDE_APPLICATION_MANAGER_POLICIES_POLICY_HANDLER_OBSERVER_H_ #include -#include #include +#include namespace policy { @@ -53,6 +53,20 @@ class PolicyHandlerObserver { virtual void OnPTUFinished(const bool ptu_result) {} + virtual void OnPTInited() {} + + virtual void OnPTUTimeoutExceeded() {} + +#ifdef EXTERNAL_PROPRIETARY_MODE + /** + * @brief OnCertDecryptFinished is called when certificate decryption is + * finished in the external flow + * @param decrypt_result bool value indicating whether decryption was + * successful + */ + virtual void OnCertDecryptFinished(const bool decrypt_result) {} +#endif + virtual ~PolicyHandlerObserver() {} }; } // namespace policy diff --git a/src/components/include/application_manager/rpc_handler.h b/src/components/include/application_manager/rpc_handler.h index 2ada9e7901a..aafb81b853f 100644 --- a/src/components/include/application_manager/rpc_handler.h +++ b/src/components/include/application_manager/rpc_handler.h @@ -33,24 +33,27 @@ #ifndef SRC_COMPONENTS_INCLUDE_APPLICATION_MANAGER_RPC_HANDLER_H #define SRC_COMPONENTS_INCLUDE_APPLICATION_MANAGER_RPC_HANDLER_H -#include "protocol_handler/protocol_observer.h" #include "hmi_message_handler/hmi_message_handler.h" +#include "protocol_handler/protocol_observer.h" #ifdef TELEMETRY_MONITOR #include "application_manager/telemetry_observer.h" +#include "telemetry_monitor/telemetry_observable.h" #endif // TELEMETRY_MONITOR namespace application_manager { namespace rpc_handler { +using ns_smart_device_link::ns_smart_objects::SMember; + class RPCHandler : public hmi_message_handler::HMIMessageObserver, public protocol_handler::ProtocolObserver #ifdef TELEMETRY_MONITOR - , + , public telemetry_monitor::TelemetryObservable #endif // TELEMETRY_MONITOR - { +{ public: virtual bool ValidateRpcSO(smart_objects::SmartObject& message, utils::SemanticVersion& msg_version, diff --git a/src/components/include/application_manager/rpc_service.h b/src/components/include/application_manager/rpc_service.h index e0127eac807..4a80733ee75 100644 --- a/src/components/include/application_manager/rpc_service.h +++ b/src/components/include/application_manager/rpc_service.h @@ -35,12 +35,17 @@ #include "application_manager/commands/command.h" #include "application_manager/message.h" -#include "protocol_handler/protocol_handler.h" #include "hmi_message_handler/hmi_message_handler.h" +#include "interfaces/HMI_API_schema.h" +#include "interfaces/MOBILE_API_schema.h" +#include "protocol_handler/protocol_handler.h" +#include "smart_objects/object_schema_item.h" namespace application_manager { namespace rpc_service { +using ns_smart_device_link::ns_smart_objects::SMember; + class RPCService { public: virtual ~RPCService() {} @@ -59,8 +64,8 @@ class RPCService { * @return true if command is executed, otherwise return false */ virtual bool ManageHMICommand(const commands::MessageSharedPtr message, - commands::Command::CommandSource - source = commands::Command::SOURCE_HMI) = 0; + commands::Command::CommandSource source = + commands::Command::SOURCE_HMI) = 0; /** * @brief SendMessageToMobile Put message to the queue to be sent to mobile. @@ -81,12 +86,26 @@ class RPCService { * to app services or handled by app services plugin) * @param function_id RPC function id * @param source RPC command source - * @param rpc_passing Reference to bool. Set to true to enable rpc pasing * @return true if App Services can handle RPC */ virtual bool IsAppServiceRPC(int32_t function_id, commands::Command::CommandSource source) = 0; + virtual void UpdateMobileRPCParams( + const mobile_apis::FunctionID::eType& function_id, + const mobile_apis::messageType::eType& message_type, + const std::map& members) = 0; + + virtual void UpdateHMIRPCParams( + const hmi_apis::FunctionID::eType& function_id, + const hmi_apis::messageType::eType& message_type, + const std::map& members) = 0; + + /** + * @brief Stop RPC service by shutting down hmi and mobile message queues + */ + virtual void Stop() = 0; + /** * @brief set_protocol_handler * @param handler diff --git a/src/components/include/application_manager/state_controller.h b/src/components/include/application_manager/state_controller.h index 8f608488e9a..2fa4b0c2187 100644 --- a/src/components/include/application_manager/state_controller.h +++ b/src/components/include/application_manager/state_controller.h @@ -33,58 +33,152 @@ #ifndef SRC_COMPONENTS_INCLUDE_APPLICATION_MANAGER_STATE_CONTROLLER_H_ #define SRC_COMPONENTS_INCLUDE_APPLICATION_MANAGER_STATE_CONTROLLER_H_ -#include "stdint.h" -#include "application_manager/request_controller_settings.h" -#include "application_manager/application_manager.h" #include "application_manager/application.h" +#include "application_manager/application_manager.h" +#include "application_manager/request_controller_settings.h" +#include "stdint.h" namespace application_manager { class StateController { public: + /** + * @brief SetRegularState setup regular hmi state, that will appear if + * no specific events are active + * @param app appication to setup regular State + * @param window_id id of applicaion's window to apply HMI state + * @param state state of new regular state + * @param request_hmi_state_change: if true, ActivateAppRequest or + * CloseApplication will be sent to HMI dependent on hmi level of resolved hmi + * state + */ virtual void SetRegularState(ApplicationSharedPtr app, + const WindowID window_id, HmiStatePtr state, - const bool SendActivateApp) = 0; + const bool request_hmi_state_change) = 0; + /** + * @brief SetRegularState Change regular hmi level and audio state + * @param app appication to setup regular State + * @param window_id id of applicaion's window to apply HMI state + * @param hmi_level of new regular state + * @param audio_state of new regular state + * @paran video_state of new regular state + * @param request_hmi_state_change: if true, ActivateAppRequest or + * CloseApplication will be sent to HMI dependent on hmi level of resolved hmi + * state + */ virtual void SetRegularState( ApplicationSharedPtr app, + const WindowID window_id, const mobile_apis::HMILevel::eType hmi_level, const mobile_apis::AudioStreamingState::eType audio_state, const mobile_apis::VideoStreamingState::eType video_state, - const bool SendActivateApp) = 0; + const bool request_hmi_state_change) = 0; + /** + * @brief SetRegularState Change regular hmi level + * @param app appication to setup regular State + * @param window_id id of applicaion's window to apply HMI state + * @param hmi_level of new regular state + * @param request_hmi_state_change: if true, ActivateAppRequest or + * CloseApplication will be sent to HMI dependent on hmi level of resolved hmi + * state + */ virtual void SetRegularState(ApplicationSharedPtr app, + const WindowID window_id, const mobile_apis::HMILevel::eType hmi_level, - const bool SendActivateApp) = 0; + const bool request_hmi_state_change) = 0; + /** + * @brief SetRegularState Change regular hmi level, audio state and system + * context + * @param app appication to setup regular State + * @param window_id id of applicaion's window to apply HMI state + * @param hmi_level of new regular state + * @param audio_state of new regular state + * @param video_state of new regular state + * @param system_context of new regular state + * @param request_hmi_state_change: if true, ActivateAppRequest or + * CloseApplication will be sent to HMI dependent on hmi level of resolved hmi + * state + */ virtual void SetRegularState( ApplicationSharedPtr app, + const WindowID window_id, const mobile_apis::HMILevel::eType hmi_level, const mobile_apis::AudioStreamingState::eType audio_state, const mobile_apis::VideoStreamingState::eType video_state, const mobile_apis::SystemContext::eType system_context, - const bool SendActivateApp) = 0; + const bool request_hmi_state_change) = 0; + /** + * @brief SetRegularState Sets regular state with new hmi level + * to application + * @param app appication to setup regular state + * @param window_id id of applicaion's window to apply HMI state + * @param hmi_level new hmi level for application + */ virtual void SetRegularState( ApplicationSharedPtr app, + const WindowID window_id, const mobile_apis::HMILevel::eType hmi_level) = 0; + /** + * @brief SetRegularState Change regular audio state + * @param app appication to setup regular State + * @param window_id id of applicaion's window to apply HMI state + * @param audio_state of new regular state + * @param video_state of new regular state + */ virtual void SetRegularState( ApplicationSharedPtr app, + const WindowID window_id, const mobile_apis::AudioStreamingState::eType audio_state, const mobile_apis::VideoStreamingState::eType video_state) = 0; + /** + * @brief SetRegularState Change regular system context + * @param app appication to setup regular State + * @param window_id id of applicaion's window to apply HMI state + * @param system_context of new regular state + */ virtual void SetRegularState( ApplicationSharedPtr app, + const WindowID window_id, const mobile_apis::SystemContext::eType system_context) = 0; - virtual void SetRegularState(ApplicationSharedPtr app, HmiStatePtr state) = 0; + /** + * @brief SetRegularState Sets new regular state to application + * @param app appication to setup regular state + * @param window_id id of applicaion's window to apply HMI state + * @param state new hmi state for application + */ + virtual void SetRegularState(ApplicationSharedPtr app, + const WindowID window_id, + HmiStatePtr state) = 0; + /** + * @brief Sets default application state and apply currently active HMI states + * on application registration + * @param app application to apply states + * @param default_level default HMI level + */ virtual void OnApplicationRegistered( ApplicationSharedPtr app, const mobile_apis::HMILevel::eType default_level) = 0; - virtual int64_t SendBCActivateApp(ApplicationConstSharedPtr app, - hmi_apis::Common_HMILevel::eType level, - bool send_policy_priority) = 0; + /** + * @brief OnAppWidgetAdded Sets default state for widget and apply currently + * active HMI states + * @param app application to apply states + * @param window_id id of window to add + * @param default_level default HMI level + */ + virtual void OnAppWindowAdded( + ApplicationSharedPtr app, + const WindowID window_id, + const mobile_apis::WindowType::eType window_type, + const mobile_apis::HMILevel::eType default_level) = 0; + /** * @brief OnVideoStreamingStarted process video streaming started * @param app projection or navigation application starting streaming @@ -96,12 +190,41 @@ class StateController { * @param app projection or navigation application stopping streaming */ virtual void OnVideoStreamingStopped(ApplicationConstSharedPtr app) = 0; + + /** + * @brief OnStateChanged send HMIStatusNotification if needed + * @param app application + * @param window_id id of applicaion's window to apply HMI state + * @param old_state state before change + * @param new_state state after change + */ virtual void OnStateChanged(ApplicationSharedPtr app, + const WindowID window_id, HmiStatePtr old_state, HmiStatePtr new_state) = 0; + /** + * @brief Checks activity of Deactivate HMI state. + * @return Returns TRUE if deactivate HMI state is active, otherwise returns + * FALSE. + */ virtual bool IsStateActive(HmiState::StateID state_id) const = 0; + + /** + * @brief ActivateDefaultWindow performs set of actions required for a proper + * application activation (i.e. main window activation) + * @param app pointer to application to be activated + */ + virtual void ActivateDefaultWindow(ApplicationSharedPtr app) = 0; + + /** + * @brief ExitDefaultWindow performs set of action required for a proper + * application exiting (i.e. main window exit) + * @param app pointer to application to be exited + */ + virtual void ExitDefaultWindow(ApplicationSharedPtr app) = 0; }; + } // namespace application_manager #endif // SRC_COMPONENTS_INCLUDE_APPLICATION_MANAGER_STATE_CONTROLLER_H_ diff --git a/src/components/include/connection_handler/connection_handler.h b/src/components/include/connection_handler/connection_handler.h index ea9cc6c0391..eb92336b4f9 100644 --- a/src/components/include/connection_handler/connection_handler.h +++ b/src/components/include/connection_handler/connection_handler.h @@ -33,14 +33,14 @@ #ifndef SRC_COMPONENTS_INCLUDE_CONNECTION_HANDLER_CONNECTION_HANDLER_H_ #define SRC_COMPONENTS_INCLUDE_CONNECTION_HANDLER_CONNECTION_HANDLER_H_ +#include "connection_handler/connection.h" #include "connection_handler/connection_handler_settings.h" -#include "transport_manager/transport_manager_listener.h" -#include "protocol_handler/session_observer.h" #include "connection_handler/device.h" -#include "connection_handler/connection.h" #include "connection_handler/devices_discovery_starter.h" -#include "utils/macro.h" +#include "protocol_handler/session_observer.h" +#include "transport_manager/transport_manager_listener.h" #include "utils/data_accessor.h" +#include "utils/macro.h" /** * \namespace connection_handler @@ -158,12 +158,12 @@ class ConnectionHandler { CloseSessionReason close_reason) = 0; /** - * @brief SendEndService allows to end up specific service. - * - * @param key application identifier whose service should be closed. - * - * @param service_type the service that should be closed. - */ + * @brief SendEndService allows to end up specific service. + * + * @param key application identifier whose service should be closed. + * + * @param service_type the service that should be closed. + */ virtual void SendEndService(uint32_t key, uint8_t service_type) = 0; /** @@ -188,9 +188,9 @@ class ConnectionHandler { uint32_t timeout) = 0; /** - * \brief Keep connection associated with the key from being closed by - * heartbeat monitor - */ + * \brief Keep connection associated with the key from being closed by + * heartbeat monitor + */ virtual void KeepConnectionAlive(uint32_t connection_key, uint8_t session_id) = 0; diff --git a/src/components/include/connection_handler/connection_handler_observer.h b/src/components/include/connection_handler/connection_handler_observer.h index b9d6a18926c..48e42639590 100644 --- a/src/components/include/connection_handler/connection_handler_observer.h +++ b/src/components/include/connection_handler/connection_handler_observer.h @@ -34,9 +34,9 @@ #define SRC_COMPONENTS_INCLUDE_CONNECTION_HANDLER_CONNECTION_HANDLER_OBSERVER_H_ #include -#include "connection_handler/device.h" #include "connection_handler/connection.h" #include "connection_handler/connection_handler.h" +#include "connection_handler/device.h" #include "protocol/service_type.h" #ifdef ENABLE_SECURITY diff --git a/src/components/include/hmi_message_handler/hmi_message_adapter.h b/src/components/include/hmi_message_handler/hmi_message_adapter.h index 704cc619bef..af8cddcf32f 100644 --- a/src/components/include/hmi_message_handler/hmi_message_adapter.h +++ b/src/components/include/hmi_message_handler/hmi_message_adapter.h @@ -53,7 +53,7 @@ class HMIMessageAdapter : public HMIMessageSender { /** * \brief Interface for subscriptions. * Each class implementing interface should use it according to - * standarts of transport for which it is to be an adapter. + * standards of transport for which it is to be an adapter. * For example, Adapter for MessageBroker will use it to subscribe to * notifications * from HMI. diff --git a/src/components/include/hmi_message_handler/hmi_message_handler.h b/src/components/include/hmi_message_handler/hmi_message_handler.h index 411d19fb753..0bcc38d3801 100644 --- a/src/components/include/hmi_message_handler/hmi_message_handler.h +++ b/src/components/include/hmi_message_handler/hmi_message_handler.h @@ -33,9 +33,9 @@ #ifndef SRC_COMPONENTS_INCLUDE_HMI_MESSAGE_HANDLER_HMI_MESSAGE_HANDLER_H_ #define SRC_COMPONENTS_INCLUDE_HMI_MESSAGE_HANDLER_HMI_MESSAGE_HANDLER_H_ -#include "hmi_message_handler/hmi_message_sender.h" -#include "hmi_message_handler/hmi_message_observer.h" #include "hmi_message_handler/hmi_message_handler_settings.h" +#include "hmi_message_handler/hmi_message_observer.h" +#include "hmi_message_handler/hmi_message_sender.h" namespace hmi_message_handler { diff --git a/src/components/include/hmi_message_handler/hmi_message_observer.h b/src/components/include/hmi_message_handler/hmi_message_observer.h index e7ba2619ee4..5c104312f72 100644 --- a/src/components/include/hmi_message_handler/hmi_message_observer.h +++ b/src/components/include/hmi_message_handler/hmi_message_observer.h @@ -47,6 +47,6 @@ class HMIMessageObserver { virtual void OnErrorSending( std::shared_ptr message) = 0; }; -} +} // namespace hmi_message_handler #endif // SRC_COMPONENTS_INCLUDE_HMI_MESSAGE_HANDLER_HMI_MESSAGE_OBSERVER_H_ diff --git a/src/components/include/hmi_message_handler/hmi_message_sender.h b/src/components/include/hmi_message_handler/hmi_message_sender.h index 3f70f78a97f..c4183f0838c 100644 --- a/src/components/include/hmi_message_handler/hmi_message_sender.h +++ b/src/components/include/hmi_message_handler/hmi_message_sender.h @@ -43,6 +43,6 @@ class HMIMessageSender { virtual ~HMIMessageSender() {} virtual void SendMessageToHMI(MessageSharedPointer message) = 0; }; -} +} // namespace hmi_message_handler #endif // SRC_COMPONENTS_INCLUDE_HMI_MESSAGE_HANDLER_HMI_MESSAGE_SENDER_H_ diff --git a/src/components/include/media_manager/media_manager.h b/src/components/include/media_manager/media_manager.h index 64acbcbc0b3..123e11f2f08 100644 --- a/src/components/include/media_manager/media_manager.h +++ b/src/components/include/media_manager/media_manager.h @@ -34,8 +34,8 @@ #define SRC_COMPONENTS_INCLUDE_MEDIA_MANAGER_MEDIA_MANAGER_H_ #include -#include "protocol/service_type.h" #include "media_manager/media_manager_settings.h" +#include "protocol/service_type.h" namespace media_manager { class MediaManager { @@ -60,6 +60,14 @@ class MediaManager { */ virtual const MediaManagerSettings& settings() const = 0; + /** + * \brief Convert an amount of audio bytes to an estimated time in ms + * \param data_size number of bytes to be played + * \return milliseconds required to play many bytes with + * the current pcm stream capabilities + */ + virtual uint32_t DataSizeToMilliseconds(uint64_t data_size) const = 0; + virtual ~MediaManager() {} }; diff --git a/src/components/include/media_manager/media_manager_settings.h b/src/components/include/media_manager/media_manager_settings.h index e48a74b08d3..183a7e6f5b9 100644 --- a/src/components/include/media_manager/media_manager_settings.h +++ b/src/components/include/media_manager/media_manager_settings.h @@ -32,8 +32,8 @@ #ifndef SRC_COMPONENTS_INCLUDE_MEDIA_MANAGER_MEDIA_MANAGER_SETTINGS_H_ #define SRC_COMPONENTS_INCLUDE_MEDIA_MANAGER_MEDIA_MANAGER_SETTINGS_H_ -#include #include +#include namespace media_manager { 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 8299d019f52..8220d05584a 100644 --- a/src/components/include/policy/policy_external/policy/policy_listener.h +++ b/src/components/include/policy/policy_external/policy/policy_listener.h @@ -42,17 +42,23 @@ namespace policy { namespace custom_str = utils::custom_string; +class PTURetryHandler; + class PolicyListener { public: virtual ~PolicyListener() {} - virtual void OnPermissionsUpdated(const std::string& policy_app_id, + virtual void OnPermissionsUpdated(const std::string& device_id, + const std::string& policy_app_id, const Permissions& permissions, const policy::HMILevel& default_hmi) = 0; - virtual void OnPermissionsUpdated(const std::string& policy_app_id, + virtual void OnPermissionsUpdated(const std::string& device_id, + const std::string& policy_app_id, const Permissions& permissions) = 0; - virtual void OnPendingPermissionChange(const std::string& policy_app_id) = 0; + virtual void OnPendingPermissionChange(const std::string& device_id, + const std::string& policy_app_id) = 0; virtual void OnUpdateStatusChanged(const std::string&) = 0; virtual std::string OnCurrentDeviceIdUpdateRequired( + const transport_manager::DeviceHandle& device_handle, const std::string& policy_app_id) = 0; virtual void OnSystemInfoUpdateRequired() = 0; virtual custom_str::CustomString GetAppName( @@ -95,10 +101,12 @@ class PolicyListener { /** * @brief Sends OnAppPermissionsChanged notification to HMI * @param permissions contains parameter for OnAppPermisionChanged + * @param device_id device identifier * @param policy_app_id contains policy application id */ virtual void SendOnAppPermissionsChanged( const AppPermissions& permissions, + const std::string& device_id, const std::string& policy_app_id) const = 0; /** @@ -146,7 +154,7 @@ class PolicyListener { * @return list devices ids */ virtual std::vector GetDevicesIds( - const std::string& policy_app_id) = 0; + const std::string& policy_app_id) const = 0; /** * Notifies about changing HMI level @@ -175,6 +183,14 @@ class PolicyListener { virtual void OnUpdateHMIStatus(const std::string& device_id, const std::string& policy_app_id, const std::string& hmi_level) = 0; + + /** + * @brief Notify Connected mobile apps about changing state of + * LockScreenDismissal + */ + virtual void OnLockScreenDismissalStateChanged() = 0; + + virtual PTURetryHandler& ptu_retry_handler() const = 0; }; } // namespace policy #endif // SRC_COMPONENTS_INCLUDE_POLICY_POLICY_EXTERNAL_POLICY_POLICY_LISTENER_H_ diff --git a/src/components/include/policy/policy_external/policy/policy_manager.h b/src/components/include/policy/policy_external/policy/policy_manager.h index a2eb2db0c91..248bbfe16c8 100644 --- a/src/components/include/policy/policy_external/policy/policy_manager.h +++ b/src/components/include/policy/policy_external/policy/policy_manager.h @@ -36,25 +36,33 @@ #include #include "utils/callable.h" +#include "utils/optional.h" -#include "policy/policy_types.h" -#include "policy/policy_table/types.h" +#include "application_manager/policies/policy_encryption_flag_getter.h" +#include "policy/access_remote.h" +#include "policy/cache_manager_interface.h" #include "policy/policy_listener.h" +#include "policy/policy_table/types.h" +#include "policy/policy_types.h" +#include "policy/ptu_retry_handler.h" #include "policy/usage_statistics/statistics_manager.h" -#include "policy/cache_manager_interface.h" -#include "policy/access_remote.h" namespace policy { class PolicySettings; typedef std::shared_ptr StatusNotifier; -class PolicyManager : public usage_statistics::StatisticsManager { +class PolicyManager : public usage_statistics::StatisticsManager, + public PolicyEncryptionFlagGetterInterface, + public PTURetryHandler { public: /** * @brief The NotificationMode enum defines whether application will be * notified about changes done (e.g. after consents were changed) or not */ enum NotificationMode { kSilentMode, kNotifyApplicationMode }; + + enum PtProcessingResult { kSuccess, kWrongPtReceived, kNewPtRequired }; + virtual ~PolicyManager() {} /** @@ -78,10 +86,16 @@ class PolicyManager : public usage_statistics::StatisticsManager { * sent in snapshot and received Policy Table. * @param file name of file with update policy table * @param pt_content PTU as binary string - * @return true if successfully + * @return result of PT processing + */ + virtual PtProcessingResult LoadPT(const std::string& file, + const BinaryMessage& pt_content) = 0; + + /** + * @brief Performs finalizing actions after PT update was processed + * @param ptu_result result of last PT processing */ - virtual bool LoadPT(const std::string& file, - const BinaryMessage& pt_content) = 0; + virtual void OnPTUFinished(const PtProcessingResult ptu_result) = 0; /** * @brief Resets Policy Table @@ -132,6 +146,7 @@ class PolicyManager : public usage_statistics::StatisticsManager { * @brief Check if specified RPC for specified application * has permission to be executed in specified HMI Level * and also its permitted params. + * @param device_id device identifier * @param app_id Id of application provided during registration * @param hmi_level Current HMI Level of application * @param rpc Name of RPC @@ -139,7 +154,8 @@ class PolicyManager : public usage_statistics::StatisticsManager { * @param CheckPermissionResult containing flag if HMI Level is allowed * and list of allowed params. */ - virtual void CheckPermissions(const PTString& app_id, + virtual void CheckPermissions(const PTString& device_id, + const PTString& app_id, const PTString& hmi_level, const PTString& rpc, const RPCParams& rpc_params, @@ -164,6 +180,24 @@ class PolicyManager : public usage_statistics::StatisticsManager { */ virtual void KmsChanged(int kilometers) = 0; + /** + * @brief Returns state of the lock screen that could be able to be dismissed + * while connected to SDL, allowing users the ability to interact with the + * app. + * @return bool True if lock screen can be dismissed. + */ + virtual const boost::optional LockScreenDismissalEnabledState() + const = 0; + + /** + * @brief Returns lock screen warning message. In case when specified language + * is absent in policy table will be returned message on default language + * ("en-us"). Otherwise returns uninitialized boost::optional + * @return std::string Lock screen warning message + */ + virtual const boost::optional LockScreenDismissalWarningMessage( + const std::string& language) const = 0; + /** * @brief Increments counter of ignition cycles */ @@ -175,6 +209,11 @@ class PolicyManager : public usage_statistics::StatisticsManager { */ virtual std::string ForcePTExchange() = 0; + /** + * @brief Stops retry sequence timer and resets retry sequence + */ + virtual void StopRetrySequence() = 0; + /** * @brief Exchange by user request * @return Current status of policy table @@ -183,8 +222,9 @@ class PolicyManager : public usage_statistics::StatisticsManager { /** * @brief Resets retry sequence + * @param reset_type - reset retry count with sending OnStatusUpdate or not */ - virtual void ResetRetrySequence() = 0; + virtual void ResetRetrySequence(const ResetRetryCountType reset_type) = 0; /** * @brief Gets timeout to wait before next retry updating PT @@ -246,12 +286,15 @@ class PolicyManager : public usage_statistics::StatisticsManager { /** * @brief Update Application Policies as reaction * on User allowing/disallowing device this app is running on. + * @param device_handle device identifier * @param app_id Unique application id * @param is_device_allowed true if user allowing device otherwise false * @return true if operation was successful */ - virtual bool ReactOnUserDevConsentForApp(const std::string& app_id, - const bool is_device_allowed) = 0; + virtual bool ReactOnUserDevConsentForApp( + const transport_manager::DeviceHandle& device_handle, + const std::string& app_id, + const bool is_device_allowed) = 0; /** * @brief Sets counter value that passed for receiving PT UPdate. @@ -299,12 +342,14 @@ class PolicyManager : public usage_statistics::StatisticsManager { /** * @brief Get default HMI level for application + * @param device_id device identifier * @param policy_app_id Unique application id * @param default_hmi Default HMI level for application or empty, if value * was not set * @return true, if succedeed, otherwise - false */ - virtual bool GetDefaultHmi(const std::string& policy_app_id, + virtual bool GetDefaultHmi(const std::string& device_id, + const std::string& policy_app_id, std::string* default_hmi) const = 0; /** @@ -350,11 +395,12 @@ class PolicyManager : public usage_statistics::StatisticsManager { /** * @brief Gets specific application permissions changes since last policy * table update + * @param device_id device identifier * @param policy_app_id Unique application id * @return Permissions changes */ virtual AppPermissions GetAppPermissionsChanges( - const std::string& policy_app_id) = 0; + const std::string& device_id, const std::string& policy_app_id) = 0; /** * @brief Removes specific application permissions changes @@ -364,9 +410,11 @@ class PolicyManager : public usage_statistics::StatisticsManager { /** * @brief Return device id, which hosts specific application + * @param device_handle device identifier * @param policy_app_id Application id, which is required to update device id */ virtual std::string& GetCurrentDeviceId( + const transport_manager::DeviceHandle& device_handle, const std::string& policy_app_id) const = 0; /** @@ -387,10 +435,11 @@ class PolicyManager : public usage_statistics::StatisticsManager { /** * @brief Send OnPermissionsUpdated for choosen application + * @param device_id device identifier * @param application_id Unique application id */ virtual void SendNotificationOnPermissionsUpdated( - const std::string& application_id) = 0; + const std::string& device_id, const std::string& application_id) = 0; /** * @brief Marks device as upaired @@ -401,11 +450,13 @@ class PolicyManager : public usage_statistics::StatisticsManager { /** * @brief Adds, application to the db or update existed one * run PTU if policy update is necessary for application. + * @param device_id device identifier * @param application_id Unique application id * @param hmi_types application HMI types * @return function that will notify update manager about new application */ virtual StatusNotifier AddApplication( + const std::string& device_id, const std::string& application_id, const rpc::policy_table_interface_base::AppHmiTypes& hmi_types) = 0; @@ -485,10 +536,13 @@ class PolicyManager : public usage_statistics::StatisticsManager { /** * @brief OnAppRegisteredOnMobile allows to handle event when application were * succesfully registered on mobile device. - * It will send OnAppPermissionSend notification and will try to start PTU. * + * It will send OnAppPermissionSend notification and will try to start PTU. + * + * @param device_id device identifier * @param application_id registered application. */ - virtual void OnAppRegisteredOnMobile(const std::string& application_id) = 0; + virtual void OnAppRegisteredOnMobile(const std::string& device_id, + const std::string& application_id) = 0; virtual void OnDeviceSwitching(const std::string& device_id_from, const std::string& device_id_to) = 0; @@ -511,25 +565,41 @@ class PolicyManager : public usage_statistics::StatisticsManager { /** * @brief Gets request types for application + * @param device_handle device identifier * @param policy_app_id Unique application id * @return request types of application */ virtual const std::vector GetAppRequestTypes( + const transport_manager::DeviceHandle& device_handle, const std::string policy_app_id) const = 0; /** - * @brief Gets request subtypes for application - * @param policy_app_id Unique application id - * @return request subtypes of application - */ + * @brief Gets request subtypes for application + * @param policy_app_id Unique application id + * @return request subtypes of application + */ virtual const std::vector GetAppRequestSubTypes( const std::string& policy_app_id) const = 0; /** - * @brief Get information about vehicle - * @return vehicle information + * @brief Gets vehicle data items + * @return Structure with vehicle data items */ - virtual const VehicleInfo GetVehicleInfo() const = 0; + virtual const std::vector GetVehicleDataItems() + const = 0; + + /** + * @brief Gets vehicle data items removed by policies + * @return Structure with vehicle data items + */ + virtual std::vector + GetRemovedVehicleDataItems() const = 0; + + /** + * @brief Gets copy of current policy table data + * @return policy_table as json object + */ + virtual Json::Value GetPolicyTableData() const = 0; /** * @brief Get a list of enabled cloud applications @@ -629,7 +699,7 @@ class PolicyManager : public usage_statistics::StatisticsManager { * @brief Check if an app can send unknown rpc requests to an app service * provider * @param policy_app_id Unique application id - */ + */ virtual bool UnknownRPCPassthroughAllowed( const std::string& policy_app_id) const = 0; @@ -675,11 +745,14 @@ class PolicyManager : public usage_statistics::StatisticsManager { /** * @brief Assigns new HMI types for specified application + * @param device_handle device identifier * @param application_id Unique application id * @param hmi_types new HMI types list */ - virtual void SetDefaultHmiTypes(const std::string& application_id, - const std::vector& hmi_types) = 0; + virtual void SetDefaultHmiTypes( + const transport_manager::DeviceHandle& device_handle, + const std::string& application_id, + const std::vector& hmi_types) = 0; /** * @brief Gets HMI types * @param application_id ID application @@ -707,11 +780,11 @@ class PolicyManager : public usage_statistics::StatisticsManager { const std::string& application_id) = 0; /** - * @brief Gets all allowed module types - * @param policy_app_id unique identifier of application - * @param modules list of allowed module types - * @return true if application has allowed modules - */ + * @brief Gets all allowed module types + * @param policy_app_id unique identifier of application + * @param modules list of allowed module types + * @return true if application has allowed modules + */ virtual bool GetModuleTypes(const std::string& policy_app_id, std::vector* modules) const = 0; diff --git a/src/components/include/policy/policy_external/policy/policy_settings.h b/src/components/include/policy/policy_external/policy/policy_settings.h index 7eca5129ad0..d9d2493d101 100644 --- a/src/components/include/policy/policy_external/policy/policy_settings.h +++ b/src/components/include/policy/policy_external/policy/policy_settings.h @@ -1,7 +1,7 @@ #ifndef SRC_COMPONENTS_INCLUDE_POLICY_POLICY_SETTINGS_H_ #define SRC_COMPONENTS_INCLUDE_POLICY_POLICY_SETTINGS_H_ -#include #include +#include namespace policy { class PolicySettings { @@ -17,8 +17,8 @@ class PolicySettings { virtual const std::string& preloaded_pt_file() const = 0; /** - * @brief Returns application storage path - */ + * @brief Returns application storage path + */ virtual const std::string& app_storage_folder() const = 0; virtual uint16_t attempts_to_open_policy_db() const = 0; @@ -34,8 +34,8 @@ class PolicySettings { virtual bool use_full_app_id() const = 0; /** - * @brief Returns system files folder path - */ + * @brief Returns system files folder path + */ virtual const std::string& system_files_path() const = 0; virtual ~PolicySettings() {} diff --git a/src/components/include/policy/policy_regular/policy/policy_listener.h b/src/components/include/policy/policy_regular/policy/policy_listener.h index 56e674e81bc..bbe220060e4 100644 --- a/src/components/include/policy/policy_regular/policy/policy_listener.h +++ b/src/components/include/policy/policy_regular/policy/policy_listener.h @@ -45,14 +45,18 @@ namespace custom_str = utils::custom_string; class PolicyListener { public: virtual ~PolicyListener() {} - virtual void OnPermissionsUpdated(const std::string& policy_app_id, + virtual void OnPermissionsUpdated(const std::string& device_id, + const std::string& policy_app_id, const Permissions& permissions, const policy::HMILevel& default_hmi) = 0; - virtual void OnPermissionsUpdated(const std::string& policy_app_id, + virtual void OnPermissionsUpdated(const std::string& device_id, + const std::string& policy_app_id, const Permissions& permissions) = 0; - virtual void OnPendingPermissionChange(const std::string& policy_app_id) = 0; + virtual void OnPendingPermissionChange(const std::string& device_id, + const std::string& policy_app_id) = 0; virtual void OnUpdateStatusChanged(const std::string&) = 0; virtual std::string OnCurrentDeviceIdUpdateRequired( + const transport_manager::DeviceHandle& device_handle, const std::string& policy_app_id) = 0; virtual void OnSystemInfoUpdateRequired() = 0; virtual custom_str::CustomString GetAppName( @@ -61,12 +65,12 @@ class PolicyListener { std::map app_hmi_types) = 0; /** - * @brief CanUpdate allows to find active application - * and check whether related device consented. - * - * @return true if there are at least one application has been registered - * with consented device. - */ + * @brief CanUpdate allows to find active application + * and check whether related device consented. + * + * @return true if there are at least one application has been registered + * with consented device. + */ virtual bool CanUpdate() = 0; /** @@ -75,11 +79,13 @@ class PolicyListener { * * @param pt_string the snapshot * - * @param retry_seconds retry sequence timeouts. + * @param iteration_type flag indicating whether PTU was caused by retry + * sequence. * * @param timeout_exceed timeout. */ - virtual void OnSnapshotCreated(const BinaryMessage& pt_string) = 0; + virtual void OnSnapshotCreated(const BinaryMessage& pt_string, + const PTUIterationType iteration_type) = 0; /** * @brief Make appropriate changes for related applications permissions and @@ -93,10 +99,12 @@ class PolicyListener { /** * @brief Sends OnAppPermissionsChanged notification to HMI * @param permissions contains parameter for OnAppPermisionChanged + * @param device_id device identifier * @param policy_app_id contains policy application id */ virtual void SendOnAppPermissionsChanged( const AppPermissions& permissions, + const std::string& device_id, const std::string& policy_app_id) const = 0; /** @@ -112,6 +120,11 @@ class PolicyListener { */ virtual void OnCertificateUpdated(const std::string& certificate_data) = 0; + /** + * @brief OnPTUTimeOut the callback which signals if PTU timeout occured + */ + virtual void OnPTUTimeOut() = 0; + /** * @brief OnAuthTokenUpdated the callback which signals if an app's auth token * field has been updated during a PTU @@ -128,7 +141,7 @@ class PolicyListener { * @return list devices ids */ virtual std::vector GetDevicesIds( - const std::string& policy_app_id) = 0; + const std::string& policy_app_id) const = 0; /** * Notifies about changing HMI level @@ -157,6 +170,12 @@ class PolicyListener { virtual void OnUpdateHMIStatus(const std::string& device_id, const std::string& policy_app_id, const std::string& hmi_level) = 0; + + /** + * @brief Notify Connected mobile apps about changing state + * LockScreenDismissal + */ + virtual void OnLockScreenDismissalStateChanged() = 0; }; } // namespace policy #endif // SRC_COMPONENTS_INCLUDE_POLICY_POLICY_REGULAR_POLICY_POLICY_LISTENER_H_ diff --git a/src/components/include/policy/policy_regular/policy/policy_manager.h b/src/components/include/policy/policy_regular/policy/policy_manager.h index 18fb3e1c2ba..ee1f5fa98ff 100644 --- a/src/components/include/policy/policy_regular/policy/policy_manager.h +++ b/src/components/include/policy/policy_regular/policy/policy_manager.h @@ -33,23 +33,28 @@ #ifndef SRC_COMPONENTS_INCLUDE_POLICY_POLICY_REGULAR_POLICY_POLICY_MANAGER_H_ #define SRC_COMPONENTS_INCLUDE_POLICY_POLICY_REGULAR_POLICY_POLICY_MANAGER_H_ -#include #include +#include +#include "boost/optional.hpp" -#include "utils/callable.h" -#include "policy/policy_types.h" -#include "policy/policy_table/types.h" +#include "policy/access_remote.h" +#include "policy/cache_manager_interface.h" #include "policy/policy_listener.h" +#include "policy/policy_table/types.h" +#include "policy/policy_types.h" #include "policy/usage_statistics/statistics_manager.h" -#include "policy/cache_manager_interface.h" -#include "policy/access_remote.h" +#include "utils/callable.h" +#include "utils/optional.h" namespace policy { class PolicySettings; typedef std::shared_ptr StatusNotifier; -class PolicyManager : public usage_statistics::StatisticsManager { +class PolicyManager : public usage_statistics::StatisticsManager, + public PolicyEncryptionFlagGetterInterface { public: + enum PtProcessingResult { kSuccess, kWrongPtReceived, kNewPtRequired }; + virtual ~PolicyManager() {} /** @@ -73,10 +78,16 @@ class PolicyManager : public usage_statistics::StatisticsManager { * sent in snapshot and received Policy Table. * @param file name of file with update policy table * @param pt_content PTU as binary string - * @return true if successfully + * @return result of PT processing + */ + virtual PtProcessingResult LoadPT(const std::string& file, + const BinaryMessage& pt_content) = 0; + + /** + * @brief Performs finalizing actions after PT update was processed + * @param ptu_result result of last PT processing */ - virtual bool LoadPT(const std::string& file, - const BinaryMessage& pt_content) = 0; + virtual void OnPTUFinished(const PtProcessingResult ptu_result) = 0; /** * @brief Resets Policy Table @@ -114,7 +125,7 @@ class PolicyManager : public usage_statistics::StatisticsManager { /** * @brief PTU is needed, for this PTS has to be formed and sent. */ - virtual bool RequestPTUpdate() = 0; + virtual bool RequestPTUpdate(const PTUIterationType iteration_type) = 0; /** * @brief Check if specified RPC for specified application @@ -164,6 +175,23 @@ class PolicyManager : public usage_statistics::StatisticsManager { */ virtual void KmsChanged(int kilometers) = 0; + /** + * @brief Returns state of the lock screen that could be able to be dismissed + * while connected to SDL, allowing users the ability to interact with the + * app. + * @return bool True if lock screen can be dismissed. + */ + virtual const boost::optional LockScreenDismissalEnabledState() + const = 0; + + /** + * @brief Returns lock screen warning message + * @param language_code Specific language for which need message + * @return std::string Lock screen warning message + */ + virtual const boost::optional LockScreenDismissalWarningMessage( + const std::string& language) const = 0; + /** * @brief Increments counter of ignition cycles */ @@ -181,6 +209,18 @@ class PolicyManager : public usage_statistics::StatisticsManager { */ virtual std::string ForcePTExchangeAtUserRequest() = 0; + /** + * @brief Stops retry sequence timer and resets retry sequence + */ + virtual void StopRetrySequence() = 0; + + /** + * @brief Resets retry sequence + * @param send_event - if true corresponding event is sent to + * UpdateStatusManager + */ + virtual void ResetRetrySequence(const ResetRetryCountType reset_type) = 0; + /** * @brief Gets timeout to wait before next retry updating PT * If timeout is less or equal to zero then the retry sequence is not need. @@ -241,12 +281,15 @@ class PolicyManager : public usage_statistics::StatisticsManager { /** * @brief Update Application Policies as reaction * on User allowing/disallowing device this app is running on. + * @param device_handle device identifier * @param app_id Unique application id * @param is_device_allowed true if user allowing device otherwise false * @return true if operation was successful */ - virtual bool ReactOnUserDevConsentForApp(const std::string app_id, - bool is_device_allowed) = 0; + virtual bool ReactOnUserDevConsentForApp( + const transport_manager::DeviceHandle& device_handle, + const std::string app_id, + bool is_device_allowed) = 0; /** * @brief Sets counter value that passed for receiving PT UPdate. @@ -292,12 +335,14 @@ class PolicyManager : public usage_statistics::StatisticsManager { /** * @brief Get default HMI level for application + * @param device_id device identifier * @param policy_app_id Unique application id * @param default_hmi Default HMI level for application or empty, if value * was not set * @return true, if succedeed, otherwise - false */ - virtual bool GetDefaultHmi(const std::string& policy_app_id, + virtual bool GetDefaultHmi(const std::string& device_id, + const std::string& policy_app_id, std::string* default_hmi) const = 0; /** @@ -341,11 +386,12 @@ class PolicyManager : public usage_statistics::StatisticsManager { /** * @brief Gets specific application permissions changes since last policy * table update + * @param device_id device identifier * @param policy_app_id Unique application id * @return Permissions changes */ virtual AppPermissions GetAppPermissionsChanges( - const std::string& policy_app_id) = 0; + const std::string& device_id, const std::string& policy_app_id) = 0; /** * @brief Removes specific application permissions changes @@ -355,9 +401,11 @@ class PolicyManager : public usage_statistics::StatisticsManager { /** * @brief Return device id, which hosts specific application + * @param device_handle device identifier * @param policy_app_id Application id, which is required to update device id */ virtual std::string& GetCurrentDeviceId( + const transport_manager::DeviceHandle& device_handle, const std::string& policy_app_id) const = 0; /** @@ -378,10 +426,11 @@ class PolicyManager : public usage_statistics::StatisticsManager { /** * @brief Send OnPermissionsUpdated for choosen application + * @param device_id device identifier * @param application_id Unique application id */ virtual void SendNotificationOnPermissionsUpdated( - const std::string& application_id) = 0; + const std::string& device_id, const std::string& application_id) = 0; /** * @brief Marks device as upaired @@ -392,11 +441,13 @@ class PolicyManager : public usage_statistics::StatisticsManager { /** * @brief Adds, application to the db or update existed one * run PTU if policy update is necessary for application. + * @param device_id device identifier * @param application_id Unique application id * @param hmi_types application HMI types * @return function that will notify update manager about new application */ virtual StatusNotifier AddApplication( + const std::string& device_id, const std::string& application_id, const rpc::policy_table_interface_base::AppHmiTypes& hmi_types) = 0; @@ -506,11 +557,24 @@ class PolicyManager : public usage_statistics::StatisticsManager { const std::string& policy_app_id) const = 0; /** - * @brief Get information about vehicle - * @return vehicle information + * @brief Gets vehicle data items + * @return Structure with vehicle data items */ - virtual const VehicleInfo GetVehicleInfo() const = 0; + virtual const std::vector GetVehicleDataItems() + const = 0; + /** + * @brief Gets removed vehicle data items + * @return Structure with vehicle data items + */ + virtual std::vector + GetRemovedVehicleDataItems() const = 0; + + /** + * @brief Gets copy of current policy table data + * @return policy_table as json object + */ + virtual Json::Value GetPolicyTableData() const = 0; /** * @brief Get a list of enabled cloud applications * @param enabled_apps List filled with the policy app id of each enabled @@ -610,17 +674,20 @@ class PolicyManager : public usage_statistics::StatisticsManager { * @brief Check if an app can send unknown rpc requests to an app service * provider * @param policy_app_id Unique application id - */ + */ virtual bool UnknownRPCPassthroughAllowed( const std::string& policy_app_id) const = 0; /** * @brief OnAppRegisteredOnMobile allows to handle event when application were * succesfully registered on mobile device. - * It will send OnAppPermissionSend notification and will try to start PTU. * + * It will send OnAppPermissionSend notification and will try to start PTU. + * + * @param device_id device identifier * @param application_id registered application. */ - virtual void OnAppRegisteredOnMobile(const std::string& application_id) = 0; + virtual void OnAppRegisteredOnMobile(const std::string& device_id, + const std::string& application_id) = 0; virtual void OnDeviceSwitching(const std::string& device_id_from, const std::string& device_id_to) = 0; @@ -655,11 +722,14 @@ class PolicyManager : public usage_statistics::StatisticsManager { /** * @brief Assigns new HMI types for specified application + * @param device_handle device identifier * @param application_id Unique application id * @param hmi_types new HMI types list */ - virtual void SetDefaultHmiTypes(const std::string& application_id, - const std::vector& hmi_types) = 0; + virtual void SetDefaultHmiTypes( + const transport_manager::DeviceHandle& device_handle, + const std::string& application_id, + const std::vector& hmi_types) = 0; /** * @brief Gets HMI types @@ -688,11 +758,11 @@ class PolicyManager : public usage_statistics::StatisticsManager { const std::string& application_id) = 0; /** - * @brief Gets all allowed module types - * @param policy_app_id unique identifier of application - * @param modules list of allowed module types - * @return true if application has allowed modules - */ + * @brief Gets all allowed module types + * @param policy_app_id unique identifier of application + * @param modules list of allowed module types + * @return true if application has allowed modules + */ virtual bool GetModuleTypes(const std::string& policy_app_id, std::vector* modules) const = 0; diff --git a/src/components/include/policy/policy_regular/policy/policy_settings.h b/src/components/include/policy/policy_regular/policy/policy_settings.h index 35a2d54c3a8..3529a32717d 100644 --- a/src/components/include/policy/policy_regular/policy/policy_settings.h +++ b/src/components/include/policy/policy_regular/policy/policy_settings.h @@ -1,7 +1,7 @@ #ifndef SRC_COMPONENTS_INCLUDE_POLICY_POLICY_SETTINGS_H_ #define SRC_COMPONENTS_INCLUDE_POLICY_POLICY_SETTINGS_H_ -#include #include +#include namespace policy { class PolicySettings { @@ -17,8 +17,8 @@ class PolicySettings { virtual const std::string& preloaded_pt_file() const = 0; /** - * @brief Returns application storage path - */ + * @brief Returns application storage path + */ virtual const std::string& app_storage_folder() const = 0; virtual uint16_t attempts_to_open_policy_db() const = 0; @@ -32,8 +32,8 @@ class PolicySettings { virtual const std::string& policies_snapshot_file_name() const = 0; /** - * @brief Returns system files folder path - */ + * @brief Returns system files folder path + */ virtual const std::string& system_files_path() const = 0; virtual bool use_full_app_id() const = 0; diff --git a/src/components/include/protocol/common.h b/src/components/include/protocol/common.h index 1c95020a962..4b227eeff16 100644 --- a/src/components/include/protocol/common.h +++ b/src/components/include/protocol/common.h @@ -33,8 +33,8 @@ #ifndef SRC_COMPONENTS_INCLUDE_PROTOCOL_COMMON_H_ #define SRC_COMPONENTS_INCLUDE_PROTOCOL_COMMON_H_ -#include "utils/macro.h" #include "protocol/raw_message.h" +#include "utils/macro.h" /** *\namespace protocol_handlerHandler @@ -111,20 +111,20 @@ const bool PROTECTION_OFF = false; */ enum { /** - *\brief Constant: Control type of frame - */ + *\brief Constant: Control type of frame + */ FRAME_TYPE_CONTROL = 0x00, /** - *\brief Constant: Single type of frame. - */ + *\brief Constant: Single type of frame. + */ FRAME_TYPE_SINGLE = 0x01, /** - *\brief Constant: First frame for multiple frames - */ + *\brief Constant: First frame for multiple frames + */ FRAME_TYPE_FIRST = 0x02, /** - *\brief Constant: Consecutive type of frame for multiple frames - */ + *\brief Constant: Consecutive type of frame for multiple frames + */ FRAME_TYPE_CONSECUTIVE = 0x03, /** *\brief Maximum value of frame type field (size 3-bit) diff --git a/src/components/include/protocol/raw_message.h b/src/components/include/protocol/raw_message.h index 5171d42593f..3de0d783cb0 100644 --- a/src/components/include/protocol/raw_message.h +++ b/src/components/include/protocol/raw_message.h @@ -32,10 +32,10 @@ #ifndef SRC_COMPONENTS_INCLUDE_PROTOCOL_RAW_MESSAGE_H_ #define SRC_COMPONENTS_INCLUDE_PROTOCOL_RAW_MESSAGE_H_ -#include "utils/macro.h" #include -#include "protocol/service_type.h" #include "protocol/message_priority.h" +#include "protocol/service_type.h" +#include "utils/macro.h" namespace protocol_handler { /** @@ -58,6 +58,7 @@ class RawMessage { uint32_t protocol_version, const uint8_t* const data_param, uint32_t data_size, + bool protection, uint8_t type = ServiceType::kRpc, uint32_t payload_size = 0); /** @@ -96,6 +97,8 @@ class RawMessage { ServiceType service_type() const { return service_type_; } + + bool protection_flag() const; /** * \brief Specifies current state of message in queue. * if false message is "ready to be processed" @@ -109,6 +112,7 @@ class RawMessage { uint8_t* data_; size_t data_size_; uint32_t protocol_version_; + bool protection_; ServiceType service_type_; size_t payload_size_; bool waiting_; diff --git a/src/components/include/protocol_handler/protocol_handler.h b/src/components/include/protocol_handler/protocol_handler.h index d65902030be..aacb31c2608 100644 --- a/src/components/include/protocol_handler/protocol_handler.h +++ b/src/components/include/protocol_handler/protocol_handler.h @@ -39,6 +39,7 @@ *\namespace protocol_handlerHandler *\brief Namespace for SmartDeviceLink ProtocolHandler related functionality. */ + namespace protocol_handler { class ProtocolObserver; @@ -69,10 +70,12 @@ class ProtocolHandler { /** * \brief Method for sending message to Mobile Application. * \param message RawMessage with params to be sent to Mobile App. + * \param needs_encryption whether message needs to be encrypted by policy * \param final_message tells whether message's * connection must be closed when message is processed */ virtual void SendMessageToMobileApp(const RawMessagePtr message, + bool needs_encryption, bool final_message) = 0; /** @@ -86,27 +89,27 @@ class ProtocolHandler { /** * \brief Prepare and send heartbeat message to mobile app - * \param connection_id Identifier of connection within which - * session exists - * \param session_id ID of session to be ended + * \param connection_id Identifier of connection within which + * session exists + * \param session_id ID of session to be ended */ virtual void SendHeartBeat(int32_t connection_id, uint8_t session_id) = 0; /** - * \brief Sends ending session to mobile application - * \param connection_id Identifier of connection within which - * session exists - * \param session_id ID of session to be ended - */ + * \brief Sends ending session to mobile application + * \param connection_id Identifier of connection within which + * session exists + * \param session_id ID of session to be ended + */ virtual void SendEndSession(int32_t connection_id, uint8_t session_id) = 0; /** - * \brief Sends ending session to mobile application - * \param primary_connection_id Identifier of connection within which - * service exists - * \param connection_id Identifier of the actual transport for the service - * \param session_id ID of session to be ended - */ + * \brief Sends ending session to mobile application + * \param primary_connection_id Identifier of connection within which + * service exists + * \param connection_id Identifier of the actual transport for the service + * \param session_id ID of session to be ended + */ virtual void SendEndService(int32_t primary_connection_id, int32_t connection_id, uint8_t session_id, @@ -115,7 +118,7 @@ class ProtocolHandler { /** * \brief Called to notify all handsheke handlers about handshake failure. */ - virtual void NotifyOnFailedHandshake() = 0; + virtual void NotifyOnGetSystemTimeFailed() = 0; /** * \brief Protocol handler settings getter @@ -136,6 +139,18 @@ class ProtocolHandler { const SessionContext& context, std::vector& rejected_params) = 0; + virtual bool IsRPCServiceSecure(const uint32_t connection_key) const = 0; + + virtual void ProcessFailedPTU() = 0; + +#ifdef EXTERNAL_PROPRIETARY_MODE + /** + * @brief ProcessFailedCertDecrypt is called to notify security manager that + * certificate decryption failed in the external flow + */ + virtual void ProcessFailedCertDecrypt() = 0; +#endif + protected: /** * \brief Destructor diff --git a/src/components/include/protocol_handler/telemetry_observer.h b/src/components/include/protocol_handler/telemetry_observer.h index b2bf94de35a..0fdbd07affb 100644 --- a/src/components/include/protocol_handler/telemetry_observer.h +++ b/src/components/include/protocol_handler/telemetry_observer.h @@ -53,5 +53,5 @@ class PHTelemetryObserver { virtual void EndMessageProcess(std::shared_ptr m) = 0; virtual ~PHTelemetryObserver() {} }; -} // protocol_handler +} // namespace protocol_handler #endif // SRC_COMPONENTS_INCLUDE_PROTOCOL_HANDLER_TELEMETRY_OBSERVER_H_ diff --git a/src/components/include/rpc_base/validation_report.h b/src/components/include/rpc_base/validation_report.h index 82f265e594b..c138ac143f3 100644 --- a/src/components/include/rpc_base/validation_report.h +++ b/src/components/include/rpc_base/validation_report.h @@ -33,8 +33,8 @@ #ifndef SRC_COMPONENTS_RPC_BASE_INCLUDE_RPC_BASE_VALIDATION_REPORT_H_ #define SRC_COMPONENTS_RPC_BASE_INCLUDE_RPC_BASE_VALIDATION_REPORT_H_ -#include #include +#include namespace rpc { diff --git a/src/components/include/security_manager/crypto_manager.h b/src/components/include/security_manager/crypto_manager.h index 486b6da64f9..ba50820a818 100644 --- a/src/components/include/security_manager/crypto_manager.h +++ b/src/components/include/security_manager/crypto_manager.h @@ -45,7 +45,7 @@ **security_manager::CryptoManager::CreateSSLContext() * \brief Creates an instance of \ref SSLContext class * - * \fn void + * \fn void *security_manager::CryptoManager::ReleaseSSLContext(security_manager::SSLContext **context) * \brief Frees \ref SSLContext instance @@ -67,19 +67,19 @@ class CryptoManager : public policy::PolicyHandlerObserver { virtual void ReleaseSSLContext(SSLContext* context) = 0; virtual std::string LastError() const = 0; /** - * @brief IsCertificateUpdateRequired checks if certificate update is needed - * @param system_time - time with which certificate expiration time - * should be compared - * @param certificates_time - certificate expiration time - * @return True if certificate expired and need to be updated - * otherwise False - */ + * @brief IsCertificateUpdateRequired checks if certificate update is needed + * @param system_time - time with which certificate expiration time + * should be compared + * @param certificates_time - certificate expiration time + * @return True if certificate expired and need to be updated + * otherwise False + */ virtual bool IsCertificateUpdateRequired( const time_t system_time, const time_t certificates_time) const = 0; /** - * \brief Crypto manager settings getter - * \return pointer to crypto manager settings class - */ + * \brief Crypto manager settings getter + * \return pointer to crypto manager settings class + */ virtual const CryptoManagerSettings& get_settings() const = 0; virtual ~CryptoManager() {} }; diff --git a/src/components/include/security_manager/security_manager.h b/src/components/include/security_manager/security_manager.h index 61ba43c74f1..358c4e52684 100644 --- a/src/components/include/security_manager/security_manager.h +++ b/src/components/include/security_manager/security_manager.h @@ -40,8 +40,8 @@ #include "protocol_handler/protocol_observer.h" #include "protocol_handler/session_observer.h" -#include "security_manager/security_manager_listener.h" #include "application_manager/policies/policy_handler_observer.h" +#include "security_manager/security_manager_listener.h" namespace security_manager { @@ -166,7 +166,17 @@ class SecurityManager : public protocol_handler::ProtocolObserver, /** * @brief Notify all listeners that handshake was failed */ - virtual void NotifyListenersOnHandshakeFailed() = 0; + virtual void NotifyListenersOnGetSystemTimeFailed() = 0; + + virtual void ProcessFailedPTU() = 0; + +#ifdef EXTERNAL_PROPRIETARY_MODE + /** + * @brief ProcessFailedCertDecrypt is called to notify listeners that + * certificate decryption failed in the external flow + */ + virtual void ProcessFailedCertDecrypt() = 0; +#endif /** * @brief Check if policy certificate data is empty @@ -174,6 +184,12 @@ class SecurityManager : public protocol_handler::ProtocolObserver, */ virtual bool IsPolicyCertificateDataEmpty() = 0; + /** + * @brief ResetPendingSystemTimeRequests resets waiting for system time + * requests flag + */ + virtual void ResetPendingSystemTimeRequests() = 0; + /** * \brief Add/Remove for SecurityManagerListener */ diff --git a/src/components/include/security_manager/security_manager_listener.h b/src/components/include/security_manager/security_manager_listener.h index 00a4c681349..0648ed0a11f 100644 --- a/src/components/include/security_manager/security_manager_listener.h +++ b/src/components/include/security_manager/security_manager_listener.h @@ -52,13 +52,28 @@ class SecurityManagerListener { * @brief Notification about handshake failure * @return true on success notification handling or false otherwise */ - virtual bool OnHandshakeFailed() = 0; + virtual bool OnGetSystemTimeFailed() = 0; /** * @brief Notify listeners that certificate update is required. */ virtual void OnCertificateUpdateRequired() = 0; + virtual bool OnPTUFailed() = 0; + +#ifdef EXTERNAL_PROPRIETARY_MODE + /** + * @brief OnCertDecryptFailed is called when certificate decryption fails in + * external flow + * @return since this callback is a part of SecurityManagerListener, bool + * return value is used to indicate whether listener instance can be deleted + * by calling entity. if true - listener can be deleted and removed from + * listeners by SecurityManager, false - listener retains its place within + * SecurityManager. + */ + virtual bool OnCertDecryptFailed() = 0; +#endif + /** * @brief Get certificate data from policy * @param reference to string where to save certificate data diff --git a/src/components/include/security_manager/security_query.h b/src/components/include/security_manager/security_query.h index 8aa5b60853f..5e664666637 100644 --- a/src/components/include/security_manager/security_query.h +++ b/src/components/include/security_manager/security_query.h @@ -35,9 +35,9 @@ #include #include -#include -#include #include +#include +#include namespace security_manager { /** @@ -187,8 +187,8 @@ class SecurityQuery { std::string json_message_; }; /** -*\brief SmartPointer wrapper -*/ + *\brief SmartPointer wrapper + */ typedef std::shared_ptr SecurityQueryPtr; } // namespace security_manager #endif // SRC_COMPONENTS_INCLUDE_SECURITY_MANAGER_SECURITY_QUERY_H_ diff --git a/src/components/include/security_manager/ssl_context.h b/src/components/include/security_manager/ssl_context.h index 7d52c72abe7..397cf893475 100644 --- a/src/components/include/security_manager/ssl_context.h +++ b/src/components/include/security_manager/ssl_context.h @@ -33,10 +33,10 @@ #ifndef SRC_COMPONENTS_INCLUDE_SECURITY_MANAGER_SSL_CONTEXT_H_ #define SRC_COMPONENTS_INCLUDE_SECURITY_MANAGER_SSL_CONTEXT_H_ -#include // for size_t typedef -#include #include #include +#include // for size_t typedef +#include #include "utils/custom_string.h" // TODO(EZamakhov): update brief info @@ -106,11 +106,11 @@ class SSLContext { virtual bool IsInitCompleted() const = 0; virtual bool IsHandshakePending() const = 0; /** - * @brief GetCertificateDueDate gets certificate expiration date - * @param due_date - certificate expiration time to be received - * @return True if certificate expiration date received - * otherwise False - */ + * @brief GetCertificateDueDate gets certificate expiration date + * @param due_date - certificate expiration time to be received + * @return True if certificate expiration date received + * otherwise False + */ virtual bool GetCertificateDueDate(time_t& due_date) const = 0; virtual bool HasCertificate() const = 0; virtual size_t get_max_block_size(size_t mtu) const = 0; diff --git a/src/components/include/test/application_manager/mock_app_extension.h b/src/components/include/test/application_manager/mock_app_extension.h index 5898bc9b721..10a911e799f 100644 --- a/src/components/include/test/application_manager/mock_app_extension.h +++ b/src/components/include/test/application_manager/mock_app_extension.h @@ -33,8 +33,8 @@ #ifndef SRC_COMPONENTS_INCLUDE_TEST_APPLICATION_MANAGER_MOCK_APP_EXTENSION_H_ #define SRC_COMPONENTS_INCLUDE_TEST_APPLICATION_MANAGER_MOCK_APP_EXTENSION_H_ -#include "gmock/gmock.h" #include "application_manager/app_extension.h" +#include "gmock/gmock.h" namespace test { namespace components { diff --git a/src/components/include/test/application_manager/mock_app_launch_settings.h b/src/components/include/test/application_manager/mock_app_launch_settings.h index c59eb276cea..57bd708d621 100644 --- a/src/components/include/test/application_manager/mock_app_launch_settings.h +++ b/src/components/include/test/application_manager/mock_app_launch_settings.h @@ -33,8 +33,8 @@ #ifndef SRC_COMPONENTS_INCLUDE_TEST_APPLICATION_MANAGER_MOCK_APP_LAUNCH_SETTINGS_H_ #define SRC_COMPONENTS_INCLUDE_TEST_APPLICATION_MANAGER_MOCK_APP_LAUNCH_SETTINGS_H_ -#include "gmock/gmock.h" #include "application_manager/app_launch_settings.h" +#include "gmock/gmock.h" namespace test { namespace components { 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 679e6ccfb3c..e5332286565 100644 --- a/src/components/include/test/application_manager/mock_application_manager.h +++ b/src/components/include/test/application_manager/mock_application_manager.h @@ -33,9 +33,9 @@ #ifndef SRC_COMPONENTS_INCLUDE_TEST_APPLICATION_MANAGER_MOCK_APPLICATION_MANAGER_H_ #define SRC_COMPONENTS_INCLUDE_TEST_APPLICATION_MANAGER_MOCK_APPLICATION_MANAGER_H_ +#include #include #include -#include #include "gmock/gmock.h" @@ -80,6 +80,8 @@ class MockApplicationManager : public application_manager::ApplicationManager { MOCK_CONST_METHOD0( pending_applications, DataAccessor()); + MOCK_CONST_METHOD0(reregister_applications, + DataAccessor()); MOCK_CONST_METHOD1( application, application_manager::ApplicationSharedPtr(uint32_t app_id)); MOCK_CONST_METHOD0(active_application, @@ -111,6 +113,9 @@ class MockApplicationManager : public application_manager::ApplicationManager { MOCK_CONST_METHOD1(pending_application_by_policy_id, application_manager::ApplicationSharedPtr( const std::string& policy_app_id)); + MOCK_CONST_METHOD1(reregister_application_by_policy_id, + application_manager::ApplicationSharedPtr( + const std::string& policy_app_id)); MOCK_METHOD1( applications_by_button, std::vector(uint32_t button)); @@ -194,11 +199,11 @@ class MockApplicationManager : public application_manager::ApplicationManager { MOCK_METHOD1(SetIconFileFromSystemRequest, void(const std::string policy_id)); MOCK_CONST_METHOD0(IsHMICooperating, bool()); MOCK_METHOD2(IviInfoUpdated, - void(mobile_apis::VehicleDataType::eType vehicle_info, - int value)); + void(const std::string& vehicle_info, int value)); MOCK_METHOD1(RegisterApplication, - application_manager::ApplicationSharedPtr(const std::shared_ptr< - smart_objects::SmartObject>& request_for_registration)); + application_manager::ApplicationSharedPtr( + const std::shared_ptr& + request_for_registration)); MOCK_METHOD0(SendUpdateAppList, void()); MOCK_METHOD2(MarkAppsGreyOut, void(const connection_handler::DeviceHandle handle, @@ -247,9 +252,10 @@ class MockApplicationManager : public application_manager::ApplicationManager { MOCK_CONST_METHOD2(HMILevelAllowsStreaming, bool(uint32_t app_id, protocol_handler::ServiceType service_type)); - MOCK_METHOD4(CheckPolicyPermissions, + MOCK_METHOD5(CheckPolicyPermissions, mobile_apis::Result::eType( const application_manager::ApplicationSharedPtr app, + const application_manager::WindowID window_id, const std::string& function_id, const application_manager::RPCParams& rpc_params, application_manager::CommandParametersPermissions* @@ -276,9 +282,10 @@ class MockApplicationManager : public application_manager::ApplicationManager { void(uint32_t app_id, protocol_handler::ServiceType service_type, bool state)); - MOCK_CONST_METHOD5(CreateRegularState, + MOCK_CONST_METHOD6(CreateRegularState, application_manager::HmiStatePtr( application_manager::ApplicationSharedPtr app, + const mobile_apis::WindowType::eType window_type, mobile_apis::HMILevel::eType hmi_level, mobile_apis::AudioStreamingState::eType audio_state, mobile_apis::VideoStreamingState::eType video_state, @@ -334,8 +341,9 @@ class MockApplicationManager : public application_manager::ApplicationManager { MOCK_METHOD2(ProcessReconnection, void(application_manager::ApplicationSharedPtr application, const uint32_t connection_key)); - MOCK_CONST_METHOD1(IsAppInReconnectMode, - bool(const std::string& policy_app_id)); + MOCK_CONST_METHOD2(IsAppInReconnectMode, + bool(const connection_handler::DeviceHandle& device_id, + 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)); 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 a4ec7c0317d..998ff252fee 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 @@ -34,8 +34,8 @@ #define SRC_COMPONENTS_INCLUDE_TEST_APPLICATION_MANAGER_MOCK_APPLICATION_MANAGER_SETTINGS_H_ #include -#include "gmock/gmock.h" #include "application_manager/application_manager_settings.h" +#include "gmock/gmock.h" namespace test { namespace components { @@ -89,6 +89,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(period_for_consent_expiration, uint16_t()); MOCK_CONST_METHOD0(use_full_app_id, bool()); MOCK_CONST_METHOD0(cloud_app_retry_timeout, uint32_t()); MOCK_CONST_METHOD0(cloud_app_max_retry_attempts, uint16_t()); diff --git a/src/components/include/test/application_manager/mock_request_controller_settings.h b/src/components/include/test/application_manager/mock_request_controller_settings.h index fe848f4a75f..d4d4e29a614 100644 --- a/src/components/include/test/application_manager/mock_request_controller_settings.h +++ b/src/components/include/test/application_manager/mock_request_controller_settings.h @@ -37,8 +37,8 @@ #include #include -#include "gmock/gmock.h" #include "application_manager/request_controller_settings.h" +#include "gmock/gmock.h" namespace test { namespace components { diff --git a/src/components/include/test/application_manager/mock_rpc_handler.h b/src/components/include/test/application_manager/mock_rpc_handler.h new file mode 100644 index 00000000000..fb577622ceb --- /dev/null +++ b/src/components/include/test/application_manager/mock_rpc_handler.h @@ -0,0 +1,41 @@ +#ifndef MOCK_RPC_HANDLER_H +#define MOCK_RPC_HANDLER_H + +#include "application_manager/rpc_handler.h" +#include "telemetry_monitor/telemetry_observable.h" + +#include "gmock/gmock.h" + +namespace test { +namespace components { +namespace application_manager_test { + +class MockRPCHandler : public application_manager::rpc_handler::RPCHandler { + public: + MOCK_METHOD4(ValidateRpcSO, + bool(smart_objects::SmartObject& message, + utils::SemanticVersion& msg_version, + rpc::ValidationReport& report_out, + bool allow_unknown_parameters)); + + MOCK_METHOD1(OnMessageReceived, + void(protocol_handler::RawMessagePtr message)); + + MOCK_METHOD1(OnMobileMessageSent, + void(protocol_handler::RawMessagePtr message)); + + MOCK_METHOD1(OnMessageReceived, + void(std::shared_ptr message)); + + MOCK_METHOD1(OnErrorSending, + void(std::shared_ptr message)); + + MOCK_METHOD1(SetTelemetryObserver, + void(application_manager::AMTelemetryObserver* observer)); +}; + +} // namespace application_manager_test +} // namespace components +} // namespace test + +#endif // MOCK_RPC_HANDLER_H diff --git a/src/components/include/test/application_manager/mock_rpc_plugin.h b/src/components/include/test/application_manager/mock_rpc_plugin.h index 1f7dd8951ba..7e4ff11bc78 100644 --- a/src/components/include/test/application_manager/mock_rpc_plugin.h +++ b/src/components/include/test/application_manager/mock_rpc_plugin.h @@ -1,8 +1,8 @@ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_PLUGIN_MANAGER_MOCK_RPC_PLUGIN_H #define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_PLUGIN_MANAGER_MOCK_RPC_PLUGIN_H -#include "gmock/gmock.h" #include "application_manager/plugin_manager/rpc_plugin.h" +#include "gmock/gmock.h" namespace application_manager { class CommandFactory; @@ -10,11 +10,12 @@ namespace plugin_manager { class MockRPCPlugin : public RPCPlugin { public: - MOCK_METHOD4(Init, + MOCK_METHOD5(Init, bool(ApplicationManager& app_manager, rpc_service::RPCService& rpc_service, HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handler)); + policy::PolicyHandlerInterface& policy_handler, + resumption::LastState& last_state)); MOCK_METHOD2(IsAbleToProcess, bool(const int32_t function_id, const commands::Command::CommandSource message_source)); diff --git a/src/components/include/test/application_manager/mock_rpc_plugin_manager.h b/src/components/include/test/application_manager/mock_rpc_plugin_manager.h index 74763f00d6b..db0c04624b6 100644 --- a/src/components/include/test/application_manager/mock_rpc_plugin_manager.h +++ b/src/components/include/test/application_manager/mock_rpc_plugin_manager.h @@ -2,8 +2,8 @@ #define SRC_COMPONENTS_INCLUDE_TEST_APPLICATION_MANAGER_MOCK_RPC_PLUGIN_MANAGER_H_ #include -#include "gmock/gmock.h" #include "application_manager/plugin_manager/rpc_plugin_manager.h" +#include "gmock/gmock.h" namespace application_manager { namespace plugin_manager { diff --git a/src/components/include/test/application_manager/mock_rpc_service.h b/src/components/include/test/application_manager/mock_rpc_service.h index aacb48a5abf..ed06b930d84 100644 --- a/src/components/include/test/application_manager/mock_rpc_service.h +++ b/src/components/include/test/application_manager/mock_rpc_service.h @@ -1,13 +1,16 @@ #ifndef MOCK_RPC_SERVICE_H #define MOCK_RPC_SERVICE_H -#include "gmock/gmock.h" #include "application_manager/rpc_service.h" +#include "gmock/gmock.h" +#include "smart_objects/object_schema_item.h" namespace test { namespace components { namespace application_manager_test { +using ns_smart_device_link::ns_smart_objects::SMember; + class MockRPCService : public application_manager::rpc_service::RPCService { public: MOCK_METHOD2( @@ -31,9 +34,20 @@ class MockRPCService : public application_manager::rpc_service::RPCService { IsAppServiceRPC, bool(int32_t function_id, application_manager::commands::Command::CommandSource source)); + MOCK_METHOD3(UpdateMobileRPCParams, + void(const mobile_apis::FunctionID::eType& function_id, + const mobile_apis::messageType::eType& message_type, + const std::map& members)); + + MOCK_METHOD3(UpdateHMIRPCParams, + void(const hmi_apis::FunctionID::eType& function_id, + const hmi_apis::messageType::eType& message_type, + const std::map& members)); + + MOCK_METHOD0(Stop, void()); }; -} -} -} +} // namespace application_manager_test +} // namespace components +} // namespace test #endif // MOCK_RPC_SERVICE_H diff --git a/src/components/include/test/application_manager/mock_state_controller.h b/src/components/include/test/application_manager/mock_state_controller.h index 0165180a0ad..545090bf30e 100644 --- a/src/components/include/test/application_manager/mock_state_controller.h +++ b/src/components/include/test/application_manager/mock_state_controller.h @@ -33,12 +33,11 @@ #ifndef SRC_COMPONENTS_INCLUDE_TEST_APPLICATION_MANAGER_MOCK_STATE_CONTROLLER_H_ #define SRC_COMPONENTS_INCLUDE_TEST_APPLICATION_MANAGER_MOCK_STATE_CONTROLLER_H_ -#include "gmock/gmock.h" #include "application_manager/application.h" #include "application_manager/hmi_state.h" #include "application_manager/state_controller.h" +#include "gmock/gmock.h" #include "interfaces/MOBILE_API.h" -#include "application_manager/application.h" namespace test { namespace components { @@ -47,55 +46,68 @@ namespace am = application_manager; class MockStateController : public am::StateController { public: - MOCK_METHOD3(SetRegularState, + MOCK_METHOD4(SetRegularState, void(am::ApplicationSharedPtr app, + const am::WindowID window_id, am::HmiStatePtr state, - const bool SendActivateApp)); - MOCK_METHOD5(SetRegularState, + const bool request_hmi_state_change)); + MOCK_METHOD6(SetRegularState, void(am::ApplicationSharedPtr app, + const am::WindowID window_id, const mobile_apis::HMILevel::eType hmi_level, const mobile_apis::AudioStreamingState::eType audio_state, const mobile_apis::VideoStreamingState::eType video_state, - const bool SendActivateApp)); - MOCK_METHOD3(SetRegularState, + const bool request_hmi_state_change)); + MOCK_METHOD4(SetRegularState, void(am::ApplicationSharedPtr app, + const am::WindowID window_id, const mobile_apis::HMILevel::eType hmi_level, - const bool SendActivateApp)); - MOCK_METHOD6(SetRegularState, + const bool request_hmi_state_change)); + MOCK_METHOD7(SetRegularState, void(am::ApplicationSharedPtr app, + const am::WindowID window_id, const mobile_apis::HMILevel::eType hmi_level, const mobile_apis::AudioStreamingState::eType audio_state, const mobile_apis::VideoStreamingState::eType video_state, const mobile_apis::SystemContext::eType system_context, - const bool SendActivateApp)); - MOCK_METHOD2(SetRegularState, + const bool request_hmi_state_change)); + MOCK_METHOD3(SetRegularState, void(am::ApplicationSharedPtr app, + const am::WindowID window_id, const mobile_apis::HMILevel::eType hmi_level)); - MOCK_METHOD3(SetRegularState, + MOCK_METHOD4(SetRegularState, void(am::ApplicationSharedPtr app, + const am::WindowID window_id, const mobile_apis::AudioStreamingState::eType audio_state, const mobile_apis::VideoStreamingState::eType video_state)); - MOCK_METHOD2(SetRegularState, + MOCK_METHOD3(SetRegularState, void(am::ApplicationSharedPtr app, + const am::WindowID window_id, const mobile_apis::SystemContext::eType system_context)); - MOCK_METHOD2(SetRegularState, - void(am::ApplicationSharedPtr app, am::HmiStatePtr state)); + MOCK_METHOD3(SetRegularState, + void(am::ApplicationSharedPtr app, + const am::WindowID window_id, + am::HmiStatePtr state)); MOCK_METHOD2(OnApplicationRegistered, void(am::ApplicationSharedPtr app, const mobile_apis::HMILevel::eType default_level)); - MOCK_METHOD3(SendBCActivateApp, - int64_t(am::ApplicationConstSharedPtr app, - hmi_apis::Common_HMILevel::eType level, - bool send_policy_priority)); + MOCK_METHOD4(OnAppWindowAdded, + void(am::ApplicationSharedPtr app, + const am::WindowID window_id, + const mobile_apis::WindowType::eType window_type, + const mobile_apis::HMILevel::eType default_level)); MOCK_METHOD1(OnVideoStreamingStarted, void(am::ApplicationConstSharedPtr app)); MOCK_METHOD1(OnVideoStreamingStopped, void(am::ApplicationConstSharedPtr app)); - MOCK_METHOD3(OnStateChanged, + MOCK_METHOD4(OnStateChanged, void(am::ApplicationSharedPtr app, + const am::WindowID window_id, am::HmiStatePtr old_state, am::HmiStatePtr new_state)); MOCK_CONST_METHOD1(IsStateActive, bool(am::HmiState::StateID state_id)); + MOCK_METHOD1(ActivateDefaultWindow, void(am::ApplicationSharedPtr app)); + MOCK_METHOD1(ExitDefaultWindow, void(am::ApplicationSharedPtr app)); }; } // namespace application_manager_test diff --git a/src/components/include/test/application_manager/policies/mock_custom_vehicle_data_provider.h b/src/components/include/test/application_manager/policies/mock_custom_vehicle_data_provider.h new file mode 100644 index 00000000000..ba077122ce6 --- /dev/null +++ b/src/components/include/test/application_manager/policies/mock_custom_vehicle_data_provider.h @@ -0,0 +1,24 @@ +#ifndef MOCK_CUSTOM_VEHICLE_DATA_MANAGER_H +#define MOCK_CUSTOM_VEHICLE_DATA_MANAGER_H + +#include "application_manager/policies/custom_vehicle_data_provider.h" +#include "gmock/gmock.h" + +namespace test { +namespace components { +namespace policy_test { + +class MockCustomVehicleDataProvider : public policy::VehicleDataItemProvider { + public: + MOCK_CONST_METHOD0( + GetVehicleDataItems, + const std::vector()); + MOCK_CONST_METHOD0( + GetRemovedVehicleDataItems, + std::vector()); +}; + +} // namespace policy_test +} // namespace components +} // namespace test +#endif // MOCK_CUSTOM_VEHICLE_DATA_MANAGER_H diff --git a/src/components/include/test/application_manager/policies/mock_policy_handler_interface.h b/src/components/include/test/application_manager/policies/mock_policy_handler_interface.h index 3521d84a848..f74526148a5 100644 --- a/src/components/include/test/application_manager/policies/mock_policy_handler_interface.h +++ b/src/components/include/test/application_manager/policies/mock_policy_handler_interface.h @@ -33,8 +33,9 @@ #ifndef SRC_COMPONENTS_INCLUDE_TEST_APPLICATION_MANAGER_POLICIES_MOCK_POLICY_HANDLER_INTERFACE_H_ #define SRC_COMPONENTS_INCLUDE_TEST_APPLICATION_MANAGER_POLICIES_MOCK_POLICY_HANDLER_INTERFACE_H_ -#include "application_manager/policies/policy_handler_interface.h" #include "application_manager/application_manager.h" +#include "application_manager/policies/policy_encryption_flag_getter.h" +#include "application_manager/policies/policy_handler_interface.h" #include "gmock/gmock.h" #include "policy/policy_types.h" #include "smart_objects/smart_object.h" @@ -46,6 +47,8 @@ namespace policy_test { class MockPolicyHandlerInterface : public policy::PolicyHandlerInterface { public: MOCK_METHOD0(LoadPolicyLibrary, bool()); + MOCK_CONST_METHOD0(PolicyEncryptionFlagGetter, + policy::PolicyEncryptionFlagGetterInterfaceSPtr()); MOCK_CONST_METHOD0(PolicyEnabled, bool()); MOCK_METHOD0(InitPolicyTable, bool()); MOCK_METHOD0(ResetPolicyTable, bool()); @@ -57,13 +60,22 @@ class MockPolicyHandlerInterface : public policy::PolicyHandlerInterface { bool(const std::string& file, const policy::BinaryMessage& pt_string)); MOCK_METHOD0(UnloadPolicyLibrary, bool()); - MOCK_METHOD3(OnPermissionsUpdated, - void(const std::string& policy_app_id, + MOCK_METHOD4(OnPermissionsUpdated, + void(const std::string& device_id, + const std::string& policy_app_id, const policy::Permissions& permissions, const policy::HMILevel& default_hmi)); - MOCK_METHOD2(OnPermissionsUpdated, - void(const std::string& policy_app_id, + MOCK_METHOD3(OnPermissionsUpdated, + void(const std::string& device_id, + const std::string& policy_app_id, const policy::Permissions& permissions)); + MOCK_CONST_METHOD0(GetPolicyTableData, Json::Value()); + MOCK_CONST_METHOD0( + GetVehicleDataItems, + const std::vector()); + MOCK_CONST_METHOD0( + GetRemovedVehicleDataItems, + std::vector()); #ifdef EXTERNAL_PROPRIETARY_MODE MOCK_METHOD3(OnSnapshotCreated, @@ -71,14 +83,17 @@ class MockPolicyHandlerInterface : public policy::PolicyHandlerInterface { const std::vector& retry_delay_seconds, uint32_t timeout_exchange)); #else // EXTERNAL_PROPRIETARY_MODE - MOCK_METHOD1(OnSnapshotCreated, void(const policy::BinaryMessage& pt_string)); + MOCK_METHOD2(OnSnapshotCreated, + void(const policy::BinaryMessage& pt_string, + const policy::PTUIterationType iteration_type)); #endif // EXTERNAL_PROPRIETARY_MODE MOCK_CONST_METHOD2(GetPriority, bool(const std::string& policy_app_id, std::string* priority)); - MOCK_METHOD4(CheckPermissions, + MOCK_METHOD5(CheckPermissions, void(const application_manager::ApplicationSharedPtr app, + const application_manager::WindowID window_id, const policy::PTString& rpc, const application_manager::RPCParams& rpc_params, policy::CheckPermissionResult& result)); @@ -86,8 +101,9 @@ class MockPolicyHandlerInterface : public policy::PolicyHandlerInterface { uint32_t(const std::string& priority)); MOCK_CONST_METHOD1(GetUserConsentForDevice, policy::DeviceConsent(const std::string& device_id)); - MOCK_CONST_METHOD2(GetDefaultHmi, - bool(const std::string& policy_app_id, + MOCK_CONST_METHOD3(GetDefaultHmi, + bool(const std::string& device_id, + const std::string& policy_app_id, std::string* default_hmi)); MOCK_METHOD3(GetInitialAppData, @@ -109,6 +125,10 @@ class MockPolicyHandlerInterface : public policy::PolicyHandlerInterface { MOCK_CONST_METHOD0(TimeoutExchangeMSec, uint32_t()); MOCK_METHOD0(OnExceededTimeout, void()); MOCK_METHOD0(OnSystemReady, void()); + MOCK_CONST_METHOD0(LockScreenDismissalEnabledState, + const boost::optional()); + MOCK_CONST_METHOD1(LockScreenDismissalWarningMessage, + const boost::optional(const std::string&)); MOCK_METHOD2(PTUpdatedAt, void(policy::Counters counter, int value)); MOCK_METHOD1(add_listener, void(policy::PolicyHandlerObserver* listener)); MOCK_METHOD1(remove_listener, void(policy::PolicyHandlerObserver* listener)); @@ -123,8 +143,9 @@ class MockPolicyHandlerInterface : public policy::PolicyHandlerInterface { MOCK_METHOD2(OnAllowSDLFunctionalityNotification, void(bool is_allowed, const std::string& device_id)); MOCK_METHOD0(OnIgnitionCycleOver, void()); - MOCK_METHOD1(OnPendingPermissionChange, - void(const std::string& policy_app_id)); + MOCK_METHOD2(OnPendingPermissionChange, + void(const std::string& device_id, + const std::string& policy_app_id)); MOCK_METHOD1(PTExchangeAtUserRequest, void(uint32_t correlation_id)); MOCK_METHOD2(AddDevice, void(const std::string& device_id, @@ -152,8 +173,9 @@ class MockPolicyHandlerInterface : public policy::PolicyHandlerInterface { const uint32_t correlation_id)); MOCK_METHOD1(OnGetStatusUpdate, void(const uint32_t correlation_id)); MOCK_METHOD1(OnUpdateStatusChanged, void(const std::string& status)); - MOCK_METHOD1(OnCurrentDeviceIdUpdateRequired, - std::string(const std::string& policy_app_id)); + MOCK_METHOD2(OnCurrentDeviceIdUpdateRequired, + std::string(const transport_manager::DeviceHandle& device_handle, + const std::string& policy_app_id)); MOCK_METHOD1(OnSystemInfoChanged, void(const std::string& language)); MOCK_METHOD3(OnGetSystemInfo, void(const std::string& ccpu_version, @@ -174,18 +196,22 @@ class MockPolicyHandlerInterface : public policy::PolicyHandlerInterface { void(std::map app_hmi_types)); MOCK_METHOD1(OnCertificateUpdated, void(const std::string& certificate_data)); MOCK_METHOD1(OnPTUFinished, void(const bool ptu_result)); + MOCK_METHOD0(OnPTInited, void()); + MOCK_METHOD0(StopRetrySequence, void()); MOCK_METHOD1(OnCertificateDecrypted, void(bool is_succeeded)); MOCK_METHOD0(CanUpdate, bool()); MOCK_METHOD2(OnDeviceConsentChanged, void(const std::string& device_id, bool is_allowed)); - MOCK_CONST_METHOD2(SendOnAppPermissionsChanged, + MOCK_CONST_METHOD3(SendOnAppPermissionsChanged, void(const policy::AppPermissions& permissions, + const std::string& device_id, const std::string& policy_app_id)); MOCK_METHOD0(OnPTExchangeNeeded, void()); MOCK_METHOD1(GetAvailableApps, void(std::queue& apps)); - MOCK_METHOD2( + MOCK_METHOD3( AddApplication, policy::StatusNotifier( + const std::string& device_id, const std::string& application_id, const rpc::policy_table_interface_base::AppHmiTypes& hmi_types)); MOCK_METHOD1(IsApplicationRevoked, bool(const std::string& app_id)); @@ -193,10 +219,12 @@ class MockPolicyHandlerInterface : public policy::PolicyHandlerInterface { MOCK_CONST_METHOD1(HeartBeatTimeout, uint32_t(const std::string& app_id)); MOCK_METHOD0(OnAppsSearchStarted, void()); MOCK_METHOD1(OnAppsSearchCompleted, void(const bool trigger_ptu)); - MOCK_METHOD1(OnAppRegisteredOnMobile, - void(const std::string& application_id)); - MOCK_CONST_METHOD2(IsRequestTypeAllowed, - bool(const std::string& policy_app_id, + MOCK_METHOD2(OnAppRegisteredOnMobile, + void(const std::string& device_id, + const std::string& application_id)); + MOCK_CONST_METHOD3(IsRequestTypeAllowed, + bool(const transport_manager::DeviceHandle& device_handle, + const std::string& policy_app_id, mobile_apis::RequestType::eType type)); MOCK_CONST_METHOD2(IsRequestSubTypeAllowed, bool(const std::string& policy_app_id, @@ -210,10 +238,10 @@ class MockPolicyHandlerInterface : public policy::PolicyHandlerInterface { MOCK_CONST_METHOD1( GetAppRequestSubTypes, const std::vector(const std::string& policy_app_id)); - MOCK_CONST_METHOD1( - GetAppRequestTypes, - const std::vector(const std::string& policy_app_id)); - MOCK_CONST_METHOD0(GetVehicleInfo, const policy::VehicleInfo()); + MOCK_CONST_METHOD2(GetAppRequestTypes, + const std::vector( + const transport_manager::DeviceHandle& device_handle, + const std::string& policy_app_id)); MOCK_CONST_METHOD1(GetEnabledCloudApps, void(std::vector& enabled_apps)); MOCK_CONST_METHOD1(CheckCloudAppEnabled, @@ -242,6 +270,8 @@ class MockPolicyHandlerInterface : public policy::PolicyHandlerInterface { #ifdef EXTERNAL_PROPRIETARY_MODE MOCK_CONST_METHOD0(GetMetaInfo, const policy::MetaInfo()); + MOCK_METHOD0(IncrementRetryIndex, void()); + MOCK_CONST_METHOD0(ptu_retry_handler, policy::PTURetryHandler&()); #endif // EXTERNAL_PROPRIETARY_MODE MOCK_METHOD1(Increment, void(usage_statistics::GlobalCounterId type)); @@ -289,8 +319,9 @@ class MockPolicyHandlerInterface : public policy::PolicyHandlerInterface { MOCK_CONST_METHOD2(GetModuleTypes, bool(const std::string& policy_app_id, std::vector* modules)); - MOCK_METHOD2(SetDefaultHmiTypes, - void(const std::string& application_id, + MOCK_METHOD3(SetDefaultHmiTypes, + void(const transport_manager::DeviceHandle& device_handle, + const std::string& application_id, const smart_objects::SmartObject* app_types)); MOCK_METHOD2(OnDeviceSwitching, void(const std::string& device_id_from, diff --git a/src/components/include/test/application_manager/policies/mock_policy_handler_observer.h b/src/components/include/test/application_manager/policies/mock_policy_handler_observer.h index bd8c83d8976..43e49833686 100644 --- a/src/components/include/test/application_manager/policies/mock_policy_handler_observer.h +++ b/src/components/include/test/application_manager/policies/mock_policy_handler_observer.h @@ -37,8 +37,8 @@ #include #include -#include "gmock/gmock.h" #include "application_manager/policies/policy_handler_observer.h" +#include "gmock/gmock.h" namespace test { namespace components { diff --git a/src/components/include/test/connection_handler/mock_connection_handler.h b/src/components/include/test/connection_handler/mock_connection_handler.h index 8cc439c78a0..41c2f04ebbd 100644 --- a/src/components/include/test/connection_handler/mock_connection_handler.h +++ b/src/components/include/test/connection_handler/mock_connection_handler.h @@ -33,23 +33,23 @@ #ifndef SRC_COMPONENTS_INCLUDE_TEST_CONNECTION_HANDLER_MOCK_CONNECTION_HANDLER_H_ #define SRC_COMPONENTS_INCLUDE_TEST_CONNECTION_HANDLER_MOCK_CONNECTION_HANDLER_H_ -#include #include +#include #include -#include "gmock/gmock.h" #include "connection_handler/connection_handler.h" #include "connection_handler/connection_handler_observer.h" -#include "connection_handler/devices_discovery_starter.h" #include "connection_handler/connection_handler_settings.h" +#include "connection_handler/devices_discovery_starter.h" +#include "gmock/gmock.h" namespace test { namespace components { namespace connection_handler_test { +using connection_handler::CloseSessionReason; using connection_handler::ConnectionHandle; using connection_handler::DeviceHandle; -using connection_handler::CloseSessionReason; using connection_handler::DevicesDiscoveryStarter; using connection_handler::SessionTransports; 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 552be4bee0c..8f7ec905506 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 @@ -33,8 +33,8 @@ #ifndef SRC_COMPONENTS_INCLUDE_TEST_CONNECTION_HANDLER_MOCK_CONNECTION_HANDLER_OBSERVER_H_ #define SRC_COMPONENTS_INCLUDE_TEST_CONNECTION_HANDLER_MOCK_CONNECTION_HANDLER_OBSERVER_H_ -#include "gmock/gmock.h" #include "connection_handler/connection_handler_observer.h" +#include "gmock/gmock.h" namespace test { namespace components { diff --git a/src/components/include/test/connection_handler/mock_connection_handler_settings.h b/src/components/include/test/connection_handler/mock_connection_handler_settings.h index c813455698d..38bd41e431d 100644 --- a/src/components/include/test/connection_handler/mock_connection_handler_settings.h +++ b/src/components/include/test/connection_handler/mock_connection_handler_settings.h @@ -34,8 +34,8 @@ #define SRC_COMPONENTS_INCLUDE_TEST_CONNECTION_HANDLER_MOCK_CONNECTION_HANDLER_SETTINGS_H_ #include -#include "gmock/gmock.h" #include "connection_handler/connection_handler_settings.h" +#include "gmock/gmock.h" namespace test { namespace components { diff --git a/src/components/include/test/hmi_message_handler/mock_hmi_message_observer.h b/src/components/include/test/hmi_message_handler/mock_hmi_message_observer.h index 17ec69ccf85..221b353a512 100644 --- a/src/components/include/test/hmi_message_handler/mock_hmi_message_observer.h +++ b/src/components/include/test/hmi_message_handler/mock_hmi_message_observer.h @@ -34,8 +34,8 @@ #define SRC_COMPONENTS_INCLUDE_TEST_HMI_MESSAGE_HANDLER_MOCK_HMI_MESSAGE_OBSERVER_H_ #include "gmock/gmock.h" -#include "utils/singleton.h" #include "hmi_message_handler/hmi_message_observer.h" +#include "utils/singleton.h" namespace test { namespace components { diff --git a/src/components/include/test/media_manager/mock_media_manager.h b/src/components/include/test/media_manager/mock_media_manager.h index b58cfab5d77..aa0baa5682b 100644 --- a/src/components/include/test/media_manager/mock_media_manager.h +++ b/src/components/include/test/media_manager/mock_media_manager.h @@ -57,6 +57,7 @@ class MockMediaManager : public media_manager::MediaManager { MOCK_METHOD2(FramesProcessed, void(int32_t application_key, int32_t frame_number)); MOCK_CONST_METHOD0(settings, const media_manager::MediaManagerSettings&()); + MOCK_CONST_METHOD1(DataSizeToMilliseconds, uint32_t(uint64_t data_size)); }; } // namespace media_manager_test diff --git a/src/components/include/test/policy/policy_external/policy/mock_cache_manager.h b/src/components/include/test/policy/policy_external/policy/mock_cache_manager.h index 6f754ad2c99..b74ddbd13cd 100644 --- a/src/components/include/test/policy/policy_external/policy/mock_cache_manager.h +++ b/src/components/include/test/policy/policy_external/policy/mock_cache_manager.h @@ -57,6 +57,7 @@ class MockCacheManagerInterface : public ::policy::CacheManagerInterface { const PTString& hmi_level, const PTString& rpc, CheckPermissionResult& result)); + MOCK_CONST_METHOD0(pt, std::shared_ptr()); MOCK_METHOD0(IsPTPreloaded, bool()); MOCK_METHOD0(IgnitionCyclesBeforeExchange, int()); MOCK_METHOD1(KilometersBeforeExchange, int(int current)); @@ -75,7 +76,11 @@ class MockCacheManagerInterface : public ::policy::CacheManagerInterface { MOCK_METHOD0(TimeoutResponse, int()); MOCK_METHOD1(SecondsBetweenRetries, bool(std::vector& seconds)); MOCK_CONST_METHOD1(IsDeviceConsentCached, bool(const std::string& device_id)); - MOCK_CONST_METHOD0(GetVehicleInfo, const VehicleInfo()); + MOCK_CONST_METHOD0(GetPolicyTableData, Json::Value()); + MOCK_CONST_METHOD0(GetVehicleDataItems, + const std::vector()); + MOCK_CONST_METHOD0(GetRemovedVehicleDataItems, + std::vector()); MOCK_CONST_METHOD1(GetEnabledCloudApps, void(std::vector& enabled_apps)); MOCK_CONST_METHOD7(GetCloudAppParameters, @@ -110,6 +115,10 @@ class MockCacheManagerInterface : public ::policy::CacheManagerInterface { policy_table::AppServiceParameters* app_service_parameters)); MOCK_CONST_METHOD1(UnknownRPCPassthroughAllowed, bool(const std::string& policy_app_id)); + MOCK_CONST_METHOD0(LockScreenDismissalEnabledState, + const boost::optional()); + MOCK_CONST_METHOD1(LockScreenDismissalWarningMessage, + const boost::optional(const std::string&)); MOCK_CONST_METHOD1(GetDeviceConsent, DeviceConsent(const std::string& device_id)); MOCK_METHOD2(SetDeviceConsent, @@ -120,11 +129,11 @@ class MockCacheManagerInterface : public ::policy::CacheManagerInterface { MOCK_CONST_METHOD1(GetCachedDeviceConsent, DeviceConsent(const std::string& device_id)); MOCK_METHOD1(SetVINValue, bool(const std::string& value)); - MOCK_METHOD3(GetUserFriendlyMsg, - std::vector( - const std::vector& msg_codes, - const std::string& language, - const std::string& active_hmi_language)); + MOCK_CONST_METHOD3(GetUserFriendlyMsg, + std::vector( + const std::vector& msg_codes, + const std::string& language, + const std::string& active_hmi_language)); MOCK_METHOD2(GetUpdateUrls, void(const std::string& service_type, EndpointUrls& out_end_points)); @@ -292,6 +301,19 @@ class MockCacheManagerInterface : public ::policy::CacheManagerInterface { RequestType::State(const std::string& policy_app_id)); MOCK_CONST_METHOD1(GetAppRequestSubTypesState, RequestSubType::State(const std::string& policy_app_id)); + + MOCK_CONST_METHOD1( + GetAppEncryptionRequiredFlag, + rpc::Optional(const std::string& application_policy_name)); + + MOCK_CONST_METHOD1( + GetFunctionalGroupingEncryptionRequiredFlag, + rpc::Optional(const std::string& functional_group)); + + MOCK_CONST_METHOD2(GetApplicationParams, + void(const std::string& application_name, + policy_table::ApplicationParams& application_params)); + MOCK_CONST_METHOD0(GetPolicyAppIDs, const policy_table::Strings()); }; } // namespace policy_test diff --git a/src/components/include/test/policy/policy_external/policy/mock_policy_listener.h b/src/components/include/test/policy/policy_external/policy/mock_policy_listener.h index 720a81862a8..2eb5b3300b9 100644 --- a/src/components/include/test/policy/policy_external/policy/mock_policy_listener.h +++ b/src/components/include/test/policy/policy_external/policy/mock_policy_listener.h @@ -32,16 +32,17 @@ #ifndef SRC_COMPONENTS_INCLUDE_TEST_POLICY_POLICY_EXTERNAL_POLICY_MOCK_POLICY_LISTENER_H_ #define SRC_COMPONENTS_INCLUDE_TEST_POLICY_POLICY_EXTERNAL_POLICY_MOCK_POLICY_LISTENER_H_ -#include #include #include +#include #include #include "gmock/gmock.h" +#include "utils/macro.h" #include "policy/policy_listener.h" -#include "rpc_base/rpc_base.h" #include "policy/policy_table/types.h" +#include "rpc_base/rpc_base.h" #include "utils/custom_string.h" namespace policy_table = ::rpc::policy_table_interface_base; @@ -54,18 +55,22 @@ namespace custom_str = utils::custom_string; class MockPolicyListener : public ::policy::PolicyListener { public: - MOCK_METHOD3(OnPermissionsUpdated, - void(const std::string& policy_app_id, + MOCK_METHOD4(OnPermissionsUpdated, + void(const std::string& device_id, + const std::string& policy_app_id, const policy::Permissions& permissions, const policy::HMILevel& default_hmi)); - MOCK_METHOD2(OnPermissionsUpdated, - void(const std::string& policy_app_id, + MOCK_METHOD3(OnPermissionsUpdated, + void(const std::string& device_id, + const std::string& policy_app_id, const policy::Permissions& permissions)); - MOCK_METHOD1(OnPendingPermissionChange, - void(const std::string& policy_app_id)); + MOCK_METHOD2(OnPendingPermissionChange, + void(const std::string& device_id, + const std::string& policy_app_id)); MOCK_METHOD1(OnUpdateStatusChanged, void(const std::string& status)); - MOCK_METHOD1(OnCurrentDeviceIdUpdateRequired, - std::string(const std::string& policy_app_id)); + MOCK_METHOD2(OnCurrentDeviceIdUpdateRequired, + std::string(const transport_manager::DeviceHandle& device_handle, + const std::string& policy_app_id)); MOCK_METHOD0(OnSystemInfoUpdateRequired, void()); MOCK_METHOD1(GetAppName, custom_str::CustomString(const std::string& policy_app_id)); @@ -85,10 +90,13 @@ class MockPolicyListener : public ::policy::PolicyListener { void(const std::string& policy_app_id, const std::string& auth_token)); MOCK_METHOD1(OnPTUFinished, void(const bool ptu_result)); - MOCK_CONST_METHOD2(SendOnAppPermissionsChanged, - void(const policy::AppPermissions&, const std::string&)); - MOCK_METHOD1(GetDevicesIds, - std::vector(const std::string& policy_app_id)); + MOCK_CONST_METHOD3(SendOnAppPermissionsChanged, + void(const policy::AppPermissions& permissions, + const std::string& device_id, + const std::string& policy_app_id)); + MOCK_CONST_METHOD1( + GetDevicesIds, + std::vector(const std::string& policy_app_id)); MOCK_METHOD3(OnUpdateHMILevel, void(const std::string& device_id, const std::string& policy_app_id, @@ -103,6 +111,10 @@ class MockPolicyListener : public ::policy::PolicyListener { void(const std::string& device_id, const std::string& policy_app_id, const std::string& hmi_level)); + MOCK_METHOD0(OnLockScreenDismissalStateChanged, void()); + MOCK_METHOD1(OnCertDecryptFinished, void(bool)); + MOCK_METHOD0(IncrementRetryIndex, void()); + MOCK_CONST_METHOD0(ptu_retry_handler, policy::PTURetryHandler&()); }; } // namespace policy_test diff --git a/src/components/include/test/policy/policy_external/policy/mock_policy_manager.h b/src/components/include/test/policy/policy_external/policy/mock_policy_manager.h index 8fc8a9c358a..8e6cc2666d2 100644 --- a/src/components/include/test/policy/policy_external/policy/mock_policy_manager.h +++ b/src/components/include/test/policy/policy_external/policy/mock_policy_manager.h @@ -40,9 +40,9 @@ #include "policy/policy_types.h" #include "policy/usage_statistics/statistics_manager.h" -#include "rpc_base/rpc_base.h" -#include "policy/policy_table/types.h" #include "policy/policy_manager.h" +#include "policy/policy_table/types.h" +#include "rpc_base/rpc_base.h" namespace policy_table = ::rpc::policy_table_interface_base; @@ -54,12 +54,31 @@ namespace policy_manager_test { class MockPolicyManager : public PolicyManager { public: + MOCK_CONST_METHOD1(AppNeedEncryption, bool(const std::string& policy_app_id)); + MOCK_CONST_METHOD1( + GetFunctionalGroupsForApp, + const std::vector(const std::string& policy_app_id)); + MOCK_CONST_METHOD0(GetApplicationPolicyIDs, const std::vector()); + MOCK_CONST_METHOD2(FunctionNeedEncryption, + bool(const std::string& policy_group, + const std::string& policy_function_id)); + MOCK_CONST_METHOD1(FunctionGroupNeedEncryption, + bool(const std::string& policy_group)); + MOCK_CONST_METHOD1( + GetAppEncryptionRequired, + const rpc::Optional(const std::string& policy_app_id)); + MOCK_CONST_METHOD1(GetRPCsForFunctionGroup, + const std::vector(const std::string& group)); + MOCK_CONST_METHOD1(GetPolicyFunctionName, + const std::string(const uint32_t function_id)); MOCK_METHOD1(set_listener, void(PolicyListener* listener)); MOCK_METHOD2(InitPT, bool(const std::string& file_name, const PolicySettings* settings)); MOCK_METHOD2(LoadPT, - bool(const std::string& file, const BinaryMessage& pt_content)); + PtProcessingResult(const std::string& file, + const BinaryMessage& pt_content)); + MOCK_METHOD1(OnPTUFinished, void(const PtProcessingResult ptu_result)); MOCK_METHOD1(ResetPT, bool(const std::string& file_name)); MOCK_METHOD1(GetUpdateUrl, std::string(int service_type)); MOCK_METHOD2(GetUpdateUrls, @@ -68,8 +87,9 @@ class MockPolicyManager : public PolicyManager { void(const std::string& service_type, EndpointUrls& out_end_points)); MOCK_METHOD0(RequestPTUpdate, void()); - MOCK_METHOD5(CheckPermissions, - void(const PTString& app_id, + MOCK_METHOD6(CheckPermissions, + void(const PTString& device_id, + const PTString& app_id, const PTString& hmi_level, const PTString& rpc, const RPCParams& rpc_params, @@ -77,10 +97,16 @@ class MockPolicyManager : public PolicyManager { MOCK_METHOD0(ResetUserConsent, bool()); MOCK_CONST_METHOD0(GetPolicyTableStatus, std::string()); MOCK_METHOD1(KmsChanged, void(int kilometers)); + MOCK_CONST_METHOD0(LockScreenDismissalEnabledState, + const boost::optional()); + MOCK_CONST_METHOD1(LockScreenDismissalWarningMessage, + const boost::optional(const std::string&)); MOCK_METHOD0(IncrementIgnitionCycles, void()); MOCK_METHOD0(ForcePTExchange, std::string()); MOCK_METHOD0(ForcePTExchangeAtUserRequest, std::string()); - MOCK_METHOD0(ResetRetrySequence, void()); + MOCK_METHOD0(StopRetrySequence, void()); + MOCK_METHOD1(ResetRetrySequence, + void(const policy::ResetRetryCountType send_event)); MOCK_METHOD0(NextRetryTimeout, int()); MOCK_METHOD0(TimeoutExchangeMSec, uint32_t()); MOCK_METHOD0(RetrySequenceDelaysSeconds, const std::vector()); @@ -95,8 +121,10 @@ class MockPolicyManager : public PolicyManager { std::vector& permissions)); MOCK_METHOD2(SetUserConsentForDevice, void(const std::string& device_id, const bool is_allowed)); - MOCK_METHOD2(ReactOnUserDevConsentForApp, - bool(const std::string& app_id, bool is_device_allowed)); + MOCK_METHOD3(ReactOnUserDevConsentForApp, + bool(const transport_manager::DeviceHandle& device_handle, + const std::string& app_id, + bool is_device_allowed)); MOCK_METHOD2(PTUpdatedAt, void(policy::Counters counter, int value)); MOCK_METHOD3(GetInitialAppData, @@ -113,8 +141,9 @@ class MockPolicyManager : public PolicyManager { MOCK_METHOD2(SetUserConsentForApp, void(const policy::PermissionConsent& permissions, const policy::PolicyManager::NotificationMode mode)); - MOCK_CONST_METHOD2(GetDefaultHmi, - bool(const std::string& policy_app_id, + MOCK_CONST_METHOD3(GetDefaultHmi, + bool(const std::string& device_id, + const std::string& policy_app_id, std::string* default_hmi)); MOCK_CONST_METHOD2(GetPriority, bool(const std::string& policy_app_id, @@ -130,26 +159,32 @@ class MockPolicyManager : public PolicyManager { void(const std::string& device_id, const std::string& policy_app_id, std::vector& permissions)); - MOCK_METHOD1(GetAppPermissionsChanges, - policy::AppPermissions(const std::string& policy_app_id)); + MOCK_METHOD2(GetAppPermissionsChanges, + policy::AppPermissions(const std::string& device_id, + const std::string& policy_app_id)); MOCK_METHOD1(RemovePendingPermissionChanges, void(const std::string& app_id)); - MOCK_CONST_METHOD1(GetCurrentDeviceId, - std::string&(const std::string& policy_app_id)); + MOCK_CONST_METHOD2( + GetCurrentDeviceId, + std::string&(const transport_manager::DeviceHandle& device_handle, + const std::string& policy_app_id)); MOCK_METHOD1(SetSystemLanguage, void(const std::string& language)); MOCK_METHOD3(SetSystemInfo, void(const std::string& ccpu_version, const std::string& wers_country_code, const std::string& language)); - MOCK_METHOD1(SendNotificationOnPermissionsUpdated, - void(const std::string& application_id)); + MOCK_METHOD2(SendNotificationOnPermissionsUpdated, + void(const std::string& device_id, + const std::string& application_id)); MOCK_METHOD1(MarkUnpairedDevice, void(const std::string& device_id)); - MOCK_METHOD2( + MOCK_METHOD3( AddApplication, StatusNotifier( + const std::string& device_id, const std::string& application_id, const rpc::policy_table_interface_base::AppHmiTypes& hmi_types)); - MOCK_METHOD2(SetDefaultHmiTypes, - void(const std::string& application_id, + MOCK_METHOD3(SetDefaultHmiTypes, + void(const transport_manager::DeviceHandle& device_handle, + const std::string& application_id, const std::vector& hmi_types)); MOCK_METHOD2(GetHMITypes, bool(const std::string& application_id, @@ -177,14 +212,20 @@ class MockPolicyManager : public PolicyManager { MOCK_METHOD1(SaveUpdateStatusRequired, void(bool is_update_needed)); MOCK_METHOD0(OnAppsSearchStarted, void()); MOCK_METHOD1(OnAppsSearchCompleted, void(const bool trigger_ptu)); - MOCK_METHOD1(OnAppRegisteredOnMobile, - void(const std::string& application_id)); + MOCK_METHOD2(OnAppRegisteredOnMobile, + void(const std::string& device_id, + const std::string& application_id)); MOCK_CONST_METHOD0(GetLockScreenIconUrl, std::string()); MOCK_CONST_METHOD1(GetIconUrl, std::string(const std::string& policy_app_id)); - MOCK_CONST_METHOD1( - GetAppRequestTypes, - const std::vector(const std::string policy_app_id)); - MOCK_CONST_METHOD0(GetVehicleInfo, const policy::VehicleInfo()); + MOCK_CONST_METHOD2(GetAppRequestTypes, + const std::vector( + const transport_manager::DeviceHandle& device_handle, + const std::string policy_app_id)); + MOCK_CONST_METHOD0(GetPolicyTableData, Json::Value()); + MOCK_CONST_METHOD0(GetVehicleDataItems, + const std::vector()); + MOCK_CONST_METHOD0(GetRemovedVehicleDataItems, + std::vector()); MOCK_CONST_METHOD1(GetEnabledCloudApps, void(std::vector& enabled_apps)); MOCK_CONST_METHOD7(GetCloudAppParameters, @@ -258,6 +299,11 @@ class MockPolicyManager : public PolicyManager { RequestType::State(const std::string& policy_app_id)); MOCK_CONST_METHOD1(GetAppRequestSubTypesState, RequestSubType::State(const std::string& policy_app_id)); + MOCK_METHOD0(IncrementPTURetryIndex, void()); + MOCK_CONST_METHOD0(IsAllowedPTURetryCountExceeded, bool()); + MOCK_CONST_METHOD0(IsAllowedRetryCountExceeded, bool()); + MOCK_METHOD0(OnSystemRequestReceived, void()); + MOCK_METHOD0(RetrySequenceFailed, void()); }; } // namespace policy_manager_test } // namespace components diff --git a/src/components/include/test/policy/policy_external/policy/mock_policy_settings.h b/src/components/include/test/policy/policy_external/policy/mock_policy_settings.h index fe051aaae0e..16239bfb76a 100644 --- a/src/components/include/test/policy/policy_external/policy/mock_policy_settings.h +++ b/src/components/include/test/policy/policy_external/policy/mock_policy_settings.h @@ -32,8 +32,8 @@ #ifndef SRC_COMPONENTS_INCLUDE_TEST_POLICY_MOCK_POLICY_SETTINGS_H_ #define SRC_COMPONENTS_INCLUDE_TEST_POLICY_MOCK_POLICY_SETTINGS_H_ -#include "gmock/gmock.h" #include +#include "gmock/gmock.h" #include "policy/policy_settings.h" namespace test { @@ -52,7 +52,7 @@ class MockPolicySettings : public ::policy::PolicySettings { MOCK_CONST_METHOD0(use_full_app_id, bool()); }; -} // namespace policy_test +} // namespace policy_handler_test } // namespace components } // namespace test diff --git a/src/components/include/test/policy/policy_external/policy/mock_ptu_retry_handler.h b/src/components/include/test/policy/policy_external/policy/mock_ptu_retry_handler.h new file mode 100644 index 00000000000..d76c791b853 --- /dev/null +++ b/src/components/include/test/policy/policy_external/policy/mock_ptu_retry_handler.h @@ -0,0 +1,48 @@ +/* + Copyright (c) 2019, 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_POLICY_POLICY_EXTERNAL_INCLUDE_POLICY_MOCK_PTU_RETRY_HANDLER_H_ +#define SRC_COMPONENTS_POLICY_POLICY_EXTERNAL_INCLUDE_POLICY_MOCK_PTU_RETRY_HANDLER_H_ + +#include "policy/ptu_retry_handler.h" + +namespace policy { + +class MockPTURetryHandler : public PTURetryHandler { + public: + MOCK_CONST_METHOD0(IsAllowedRetryCountExceeded, bool()); + MOCK_METHOD0(OnSystemRequestReceived, void()); + MOCK_METHOD0(RetrySequenceFailed, void()); +}; +} // namespace policy + +#endif // SRC_COMPONENTS_POLICY_POLICY_EXTERNAL_INCLUDE_POLICY_MOCK_PTU_RETRY_HANDLER_H_ \ No newline at end of file diff --git a/src/components/include/test/policy/policy_regular/policy/mock_cache_manager.h b/src/components/include/test/policy/policy_regular/policy/mock_cache_manager.h index dacdaf202f8..e592caf3bc3 100644 --- a/src/components/include/test/policy/policy_regular/policy/mock_cache_manager.h +++ b/src/components/include/test/policy/policy_regular/policy/mock_cache_manager.h @@ -62,7 +62,11 @@ class MockCacheManagerInterface : public CacheManagerInterface { MOCK_METHOD0(ResetIgnitionCycles, void()); MOCK_METHOD0(TimeoutResponse, int()); MOCK_METHOD1(SecondsBetweenRetries, bool(std::vector& seconds)); - MOCK_CONST_METHOD0(GetVehicleInfo, const VehicleInfo()); + MOCK_CONST_METHOD0(GetPolicyTableData, Json::Value()); + MOCK_CONST_METHOD0(GetVehicleDataItems, + const std::vector()); + MOCK_CONST_METHOD0(GetRemovedVehicleDataItems, + std::vector()); MOCK_CONST_METHOD1(GetEnabledCloudApps, void(std::vector& enabled_apps)); MOCK_CONST_METHOD7(GetCloudAppParameters, @@ -91,11 +95,15 @@ class MockCacheManagerInterface : public CacheManagerInterface { MOCK_METHOD2(SetHybridAppPreference, void(const std::string& policy_app_id, const std::string& hybrid_app_preference)); + MOCK_CONST_METHOD0(LockScreenDismissalEnabledState, + const boost::optional()); + MOCK_CONST_METHOD1(LockScreenDismissalWarningMessage, + const boost::optional(const std::string&)); MOCK_METHOD1(SetVINValue, bool(const std::string& value)); - MOCK_METHOD2(GetUserFriendlyMsg, - std::vector( - const std::vector& msg_codes, - const std::string& language)); + MOCK_CONST_METHOD2(GetUserFriendlyMsg, + std::vector( + const std::vector& msg_codes, + const std::string& language)); MOCK_CONST_METHOD2( GetAppServiceParameters, void(const std::string& policy_app_id, @@ -254,6 +262,19 @@ class MockCacheManagerInterface : public CacheManagerInterface { RequestType::State(const std::string& policy_app_id)); MOCK_CONST_METHOD1(GetAppRequestSubTypesState, RequestSubType::State(const std::string& policy_app_id)); + + MOCK_CONST_METHOD1( + GetAppEncryptionRequiredFlag, + rpc::Optional(const std::string& application_policy_name)); + + MOCK_CONST_METHOD1( + GetFunctionalGroupingEncryptionRequiredFlag, + rpc::Optional(const std::string& functional_group)); + + MOCK_CONST_METHOD2(GetApplicationParams, + void(const std::string& application_name, + policy_table::ApplicationParams& application_params)); + MOCK_CONST_METHOD0(GetPolicyAppIDs, const policy_table::Strings()); }; } // namespace policy_test diff --git a/src/components/include/test/policy/policy_regular/policy/mock_policy_listener.h b/src/components/include/test/policy/policy_regular/policy/mock_policy_listener.h index 045d4f4e4f9..48c549e91bb 100644 --- a/src/components/include/test/policy/policy_regular/policy/mock_policy_listener.h +++ b/src/components/include/test/policy/policy_regular/policy/mock_policy_listener.h @@ -35,10 +35,11 @@ #include #include "gmock/gmock.h" +#include "utils/macro.h" #include "policy/policy_listener.h" -#include "rpc_base/rpc_base.h" #include "policy/policy_table/types.h" +#include "rpc_base/rpc_base.h" #include "utils/custom_string.h" namespace policy_table = ::rpc::policy_table_interface_base; @@ -52,17 +53,21 @@ namespace custom_str = utils::custom_string; class MockPolicyListener : public ::policy::PolicyListener { public: MOCK_METHOD3(OnPermissionsUpdated, - void(const std::string& policy_app_id, + void(const std::string& device_id, + const std::string& policy_app_id, + const policy::Permissions& permissions)); + MOCK_METHOD4(OnPermissionsUpdated, + void(const std::string& device_id, + const std::string& policy_app_id, const policy::Permissions& permissions, const policy::HMILevel& default_hmi)); - MOCK_METHOD2(OnPermissionsUpdated, - void(const std::string& policy_app_id, - const policy::Permissions& permissions)); - MOCK_METHOD1(OnPendingPermissionChange, - void(const std::string& policy_app_id)); + MOCK_METHOD2(OnPendingPermissionChange, + void(const std::string& device_id, + const std::string& policy_app_id)); MOCK_METHOD1(OnUpdateStatusChanged, void(const std::string& status)); - MOCK_METHOD1(OnCurrentDeviceIdUpdateRequired, - std::string(const std::string& policy_app_id)); + MOCK_METHOD2(OnCurrentDeviceIdUpdateRequired, + std::string(const transport_manager::DeviceHandle& device_handle, + const std::string& policy_app_id)); MOCK_METHOD0(OnSystemInfoUpdateRequired, void()); MOCK_METHOD1(GetAppName, custom_str::CustomString(const std::string& policy_app_id)); @@ -72,20 +77,25 @@ class MockPolicyListener : public ::policy::PolicyListener { MOCK_METHOD1(OnUpdateHMIAppType, void(std::map)); MOCK_METHOD1(GetAvailableApps, void(std::queue&)); - MOCK_METHOD1(OnSnapshotCreated, void(const policy::BinaryMessage& pt_string)); + MOCK_METHOD2(OnSnapshotCreated, + void(const policy::BinaryMessage& pt_string, + const policy::PTUIterationType iteration_type)); MOCK_METHOD0(CanUpdate, bool()); MOCK_METHOD1(OnCertificateUpdated, void(const std::string&)); MOCK_METHOD2(OnAuthTokenUpdated, void(const std::string& policy_app_id, const std::string& auth_token)); - MOCK_CONST_METHOD2(SendOnAppPermissionsChanged, - void(const policy::AppPermissions&, const std::string&)); + MOCK_CONST_METHOD3(SendOnAppPermissionsChanged, + void(const policy::AppPermissions& permissions, + const std::string& device_id, + const std::string& policy_app_id)); MOCK_METHOD3(OnUpdateHMILevel, void(const std::string& device_id, const std::string& policy_app_id, const std::string& hmi_level)); - MOCK_METHOD1(GetDevicesIds, - std::vector(const std::string& policy_app_id)); + MOCK_CONST_METHOD1( + GetDevicesIds, + std::vector(const std::string& policy_app_id)); MOCK_CONST_METHOD1(GetRegisteredLinks, void(std::map&)); MOCK_METHOD1(OnRemoteAllowedChanged, void(bool new_consent)); @@ -96,6 +106,8 @@ class MockPolicyListener : public ::policy::PolicyListener { void(const std::string& device_id, const std::string& policy_app_id, const std::string& hmi_level)); + MOCK_METHOD0(OnLockScreenDismissalStateChanged, void()); + MOCK_METHOD0(OnPTUTimeOut, void()); }; } // namespace policy_test diff --git a/src/components/include/test/policy/policy_regular/policy/mock_policy_manager.h b/src/components/include/test/policy/policy_regular/policy/mock_policy_manager.h index b6fdc2c2c99..927f5ba5cca 100644 --- a/src/components/include/test/policy/policy_regular/policy/mock_policy_manager.h +++ b/src/components/include/test/policy/policy_regular/policy/mock_policy_manager.h @@ -40,8 +40,8 @@ #include "policy/policy_types.h" #include "policy/usage_statistics/statistics_manager.h" -#include "rpc_base/rpc_base.h" #include "policy/policy_manager.h" +#include "rpc_base/rpc_base.h" namespace policy_table = ::rpc::policy_table_interface_base; @@ -55,12 +55,31 @@ using namespace policy; class MockPolicyManager : public PolicyManager { public: + MOCK_CONST_METHOD1(AppNeedEncryption, bool(const std::string& policy_app_id)); + MOCK_CONST_METHOD1( + GetFunctionalGroupsForApp, + const std::vector(const std::string& policy_app_id)); + MOCK_CONST_METHOD0(GetApplicationPolicyIDs, const std::vector()); + MOCK_CONST_METHOD2(FunctionNeedEncryption, + bool(const std::string& policy_group, + const std::string& policy_function_id)); + MOCK_CONST_METHOD1(FunctionGroupNeedEncryption, + bool(const std::string& policy_group)); + MOCK_CONST_METHOD1( + GetAppEncryptionRequired, + const rpc::Optional(const std::string& policy_app_id)); + MOCK_CONST_METHOD1(GetRPCsForFunctionGroup, + const std::vector(const std::string& group)); + MOCK_CONST_METHOD1(GetPolicyFunctionName, + const std::string(const uint32_t function_id)); MOCK_METHOD1(set_listener, void(PolicyListener* listener)); MOCK_METHOD2(InitPT, bool(const std::string& file_name, const PolicySettings* settings)); MOCK_METHOD2(LoadPT, - bool(const std::string& file, const BinaryMessage& pt_content)); + PtProcessingResult(const std::string& file, + const BinaryMessage& pt_content)); + MOCK_METHOD1(OnPTUFinished, void(const PtProcessingResult ptu_result)); MOCK_METHOD1(ResetPT, bool(const std::string& file_name)); MOCK_METHOD2(GetUpdateUrls, @@ -68,7 +87,8 @@ class MockPolicyManager : public PolicyManager { MOCK_METHOD2(GetUpdateUrls, void(const std::string& service_type, EndpointUrls& out_end_points)); - MOCK_METHOD0(RequestPTUpdate, bool()); + MOCK_METHOD1(RequestPTUpdate, + bool(const policy::PTUIterationType iteration_type)); MOCK_METHOD5(CheckPermissions, void(const PTString& app_id, const PTString& hmi_level, @@ -78,10 +98,16 @@ class MockPolicyManager : public PolicyManager { MOCK_METHOD0(ResetUserConsent, bool()); MOCK_CONST_METHOD0(GetPolicyTableStatus, std::string()); MOCK_METHOD1(KmsChanged, void(int kilometers)); + MOCK_CONST_METHOD0(LockScreenDismissalEnabledState, + const boost::optional()); + MOCK_CONST_METHOD1(LockScreenDismissalWarningMessage, + const boost::optional(const std::string&)); MOCK_METHOD0(IncrementIgnitionCycles, void()); MOCK_METHOD0(ForcePTExchange, std::string()); MOCK_METHOD0(ForcePTExchangeAtUserRequest, std::string()); - MOCK_METHOD0(ResetRetrySequence, void()); + MOCK_METHOD0(StopRetrySequence, void()); + MOCK_METHOD1(ResetRetrySequence, + void(const policy::ResetRetryCountType send_event)); MOCK_METHOD0(NextRetryTimeout, uint32_t()); MOCK_METHOD0(TimeoutExchangeMSec, uint32_t()); MOCK_METHOD0(RetrySequenceDelaysSeconds, const std::vector()); @@ -96,8 +122,10 @@ class MockPolicyManager : public PolicyManager { std::vector& permissions)); MOCK_METHOD2(SetUserConsentForDevice, void(const std::string& device_id, const bool is_allowed)); - MOCK_METHOD2(ReactOnUserDevConsentForApp, - bool(const std::string app_id, bool is_device_allowed)); + MOCK_METHOD3(ReactOnUserDevConsentForApp, + bool(const transport_manager::DeviceHandle& device_handle, + const std::string app_id, + bool is_device_allowed)); MOCK_METHOD2(PTUpdatedAt, void(policy::Counters counter, int value)); MOCK_METHOD3(GetInitialAppData, @@ -113,8 +141,9 @@ class MockPolicyManager : public PolicyManager { const policy::DeviceInfo& device_info)); MOCK_METHOD1(SetUserConsentForApp, void(const policy::PermissionConsent& permissions)); - MOCK_CONST_METHOD2(GetDefaultHmi, - bool(const std::string& policy_app_id, + MOCK_CONST_METHOD3(GetDefaultHmi, + bool(const std::string& device_id, + const std::string& policy_app_id, std::string* default_hmi)); MOCK_CONST_METHOD2(GetPriority, bool(const std::string& policy_app_id, @@ -129,26 +158,32 @@ class MockPolicyManager : public PolicyManager { void(const std::string& device_id, const std::string& policy_app_id, std::vector& permissions)); - MOCK_METHOD1(GetAppPermissionsChanges, - policy::AppPermissions(const std::string& policy_app_id)); + MOCK_METHOD2(GetAppPermissionsChanges, + policy::AppPermissions(const std::string& device_id, + const std::string& policy_app_id)); MOCK_METHOD1(RemovePendingPermissionChanges, void(const std::string& app_id)); - MOCK_CONST_METHOD1(GetCurrentDeviceId, - std::string&(const std::string& policy_app_id)); + MOCK_CONST_METHOD2( + GetCurrentDeviceId, + std::string&(const transport_manager::DeviceHandle& device_handle, + const std::string& policy_app_id)); MOCK_METHOD1(SetSystemLanguage, void(const std::string& language)); MOCK_METHOD3(SetSystemInfo, void(const std::string& ccpu_version, const std::string& wers_country_code, const std::string& language)); - MOCK_METHOD1(SendNotificationOnPermissionsUpdated, - void(const std::string& application_id)); + MOCK_METHOD2(SendNotificationOnPermissionsUpdated, + void(const std::string& device_id, + const std::string& application_id)); MOCK_METHOD1(MarkUnpairedDevice, void(const std::string& device_id)); - MOCK_METHOD2( + MOCK_METHOD3( AddApplication, StatusNotifier( + const std::string& device_id, const std::string& application_id, const rpc::policy_table_interface_base::AppHmiTypes& hmi_types)); - MOCK_METHOD2(SetDefaultHmiTypes, - void(const std::string& application_id, + MOCK_METHOD3(SetDefaultHmiTypes, + void(const transport_manager::DeviceHandle& device_handle, + const std::string& application_id, const std::vector& hmi_types)); MOCK_METHOD2(GetHMITypes, bool(const std::string& application_id, @@ -175,12 +210,17 @@ class MockPolicyManager : public PolicyManager { MOCK_METHOD1(SaveUpdateStatusRequired, void(bool is_update_needed)); MOCK_METHOD0(OnAppsSearchStarted, void()); MOCK_METHOD1(OnAppsSearchCompleted, void(const bool trigger_ptu)); - MOCK_METHOD1(OnAppRegisteredOnMobile, - void(const std::string& application_id)); + MOCK_METHOD2(OnAppRegisteredOnMobile, + void(const std::string& device_id, + const std::string& application_id)); MOCK_CONST_METHOD1( GetAppRequestTypes, const std::vector(const std::string policy_app_id)); - MOCK_CONST_METHOD0(GetVehicleInfo, const policy::VehicleInfo()); + MOCK_CONST_METHOD0(GetPolicyTableData, Json::Value()); + MOCK_CONST_METHOD0(GetVehicleDataItems, + const std::vector()); + MOCK_CONST_METHOD0(GetRemovedVehicleDataItems, + std::vector()); MOCK_CONST_METHOD1(GetEnabledCloudApps, void(std::vector& enabled_apps)); MOCK_CONST_METHOD7(GetCloudAppParameters, diff --git a/src/components/include/test/policy/policy_regular/policy/mock_policy_settings.h b/src/components/include/test/policy/policy_regular/policy/mock_policy_settings.h index 6e0acae33c5..26c5572d990 100644 --- a/src/components/include/test/policy/policy_regular/policy/mock_policy_settings.h +++ b/src/components/include/test/policy/policy_regular/policy/mock_policy_settings.h @@ -32,8 +32,8 @@ #ifndef SRC_COMPONENTS_INCLUDE_TEST_POLICY_MOCK_POLICY_SETTINGS_H_ #define SRC_COMPONENTS_INCLUDE_TEST_POLICY_MOCK_POLICY_SETTINGS_H_ -#include "gmock/gmock.h" #include +#include "gmock/gmock.h" #include "policy/policy_settings.h" namespace test { @@ -52,7 +52,7 @@ class MockPolicySettings : public ::policy::PolicySettings { MOCK_CONST_METHOD0(use_full_app_id, bool()); }; -} // namespace policy_test +} // namespace policy_handler_test } // namespace components } // namespace test 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 f6db0c70978..354c797c247 100644 --- a/src/components/include/test/protocol_handler/mock_protocol_handler.h +++ b/src/components/include/test/protocol_handler/mock_protocol_handler.h @@ -33,9 +33,9 @@ #define SRC_COMPONENTS_INCLUDE_TEST_PROTOCOL_HANDLER_MOCK_PROTOCOL_HANDLER_H_ #include "gmock/gmock.h" -#include "protocol_handler/protocol_packet.h" #include "protocol_handler/protocol_handler.h" #include "protocol_handler/protocol_handler_settings.h" +#include "protocol_handler/protocol_packet.h" #include "protocol_handler/session_observer.h" namespace test { @@ -44,8 +44,9 @@ namespace protocol_handler_test { class MockProtocolHandler : public ::protocol_handler::ProtocolHandler { public: - MOCK_METHOD2(SendMessageToMobileApp, + MOCK_METHOD3(SendMessageToMobileApp, void(const ::protocol_handler::RawMessagePtr message, + bool needs_encryption, bool final_message)); MOCK_METHOD1(AddProtocolObserver, void(::protocol_handler::ProtocolObserver* observer)); @@ -66,7 +67,12 @@ class MockProtocolHandler : public ::protocol_handler::ProtocolHandler { MOCK_METHOD2(NotifySessionStarted, void(const ::protocol_handler::SessionContext& context, std::vector& rejected_params)); - MOCK_METHOD0(NotifyOnFailedHandshake, void()); + MOCK_METHOD0(NotifyOnGetSystemTimeFailed, void()); + MOCK_CONST_METHOD1(IsRPCServiceSecure, bool(const uint32_t connection_key)); + MOCK_METHOD0(ProcessFailedPTU, void()); +#ifdef EXTERNAL_PROPRIETARY_MODE + MOCK_METHOD0(ProcessFailedCertDecrypt, void()); +#endif }; } // namespace protocol_handler_test } // namespace components diff --git a/src/components/include/test/protocol_handler/mock_protocol_observer.h b/src/components/include/test/protocol_handler/mock_protocol_observer.h index 257ea5ad9f3..ef28d80d0b0 100644 --- a/src/components/include/test/protocol_handler/mock_protocol_observer.h +++ b/src/components/include/test/protocol_handler/mock_protocol_observer.h @@ -33,8 +33,8 @@ #ifndef SRC_COMPONENTS_INCLUDE_TEST_PROTOCOL_HANDLER_MOCK_PROTOCOL_OBSERVER_H_ #define SRC_COMPONENTS_INCLUDE_TEST_PROTOCOL_HANDLER_MOCK_PROTOCOL_OBSERVER_H_ -#include "gmock/gmock.h" #include +#include "gmock/gmock.h" #include "protocol_handler/protocol_observer.h" namespace test { 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 0d74b15f64d..01bb41a96e3 100644 --- a/src/components/include/test/protocol_handler/mock_session_observer.h +++ b/src/components/include/test/protocol_handler/mock_session_observer.h @@ -34,8 +34,8 @@ #define SRC_COMPONENTS_INCLUDE_TEST_PROTOCOL_HANDLER_MOCK_SESSION_OBSERVER_H_ #include -#include #include +#include #include "protocol_handler/session_observer.h" #include "transport_manager/common.h" diff --git a/src/components/include/test/security_manager/mock_security_manager.h b/src/components/include/test/security_manager/mock_security_manager.h index b2c2e3bf176..e44d6207c1a 100644 --- a/src/components/include/test/security_manager/mock_security_manager.h +++ b/src/components/include/test/security_manager/mock_security_manager.h @@ -33,12 +33,12 @@ #ifndef SRC_COMPONENTS_INCLUDE_TEST_SECURITY_MANAGER_MOCK_SECURITY_MANAGER_H_ #define SRC_COMPONENTS_INCLUDE_TEST_SECURITY_MANAGER_MOCK_SECURITY_MANAGER_H_ -#include #include +#include #include "gmock/gmock.h" -#include "utils/byte_order.h" #include "security_manager/security_manager.h" #include "security_manager/security_query.h" +#include "utils/byte_order.h" namespace test { namespace components { @@ -68,11 +68,16 @@ class MockSecurityManager : public ::security_manager::SecurityManager { void(const ::protocol_handler::RawMessagePtr)); MOCK_METHOD1(IsCertificateUpdateRequired, bool(const uint32_t)); MOCK_METHOD0(NotifyOnCertificateUpdateRequired, void()); - MOCK_METHOD0(NotifyListenersOnHandshakeFailed, void()); + MOCK_METHOD0(NotifyListenersOnGetSystemTimeFailed, void()); MOCK_METHOD0(IsPolicyCertificateDataEmpty, bool()); + MOCK_METHOD0(ProcessFailedPTU, void()); MOCK_METHOD1(OnCertificateUpdated, bool(const std::string&)); MOCK_METHOD1(PostponeHandshake, void(const uint32_t)); MOCK_CONST_METHOD0(IsSystemTimeProviderReady, bool()); + MOCK_METHOD0(ResetPendingSystemTimeRequests, void()); +#ifdef EXTERNAL_PROPRIETARY_MODE + MOCK_METHOD0(ProcessFailedCertDecrypt, void()); +#endif }; /* diff --git a/src/components/include/test/security_manager/mock_security_manager_listener.h b/src/components/include/test/security_manager/mock_security_manager_listener.h index 7a7714d299b..81790d18301 100644 --- a/src/components/include/test/security_manager/mock_security_manager_listener.h +++ b/src/components/include/test/security_manager/mock_security_manager_listener.h @@ -49,7 +49,11 @@ class MockSecurityManagerListener ::security_manager::SSLContext::HandshakeResult result)); MOCK_METHOD0(OnCertificateUpdateRequired, void()); MOCK_CONST_METHOD1(GetPolicyCertificateData, bool(std::string& data)); - MOCK_METHOD0(OnHandshakeFailed, bool()); + MOCK_METHOD0(OnGetSystemTimeFailed, bool()); + MOCK_METHOD0(OnPTUFailed, bool()); +#ifdef EXTERNAL_PROPRIETARY_MODE + MOCK_METHOD0(OnCertDecryptFailed, bool()); +#endif }; } // namespace security_manager_test } // namespace components diff --git a/src/components/include/test/telemetry_monitor/mock_telemetry_observable.h b/src/components/include/test/telemetry_monitor/mock_telemetry_observable.h index dd07f1d3c8b..eb106db9a2b 100644 --- a/src/components/include/test/telemetry_monitor/mock_telemetry_observable.h +++ b/src/components/include/test/telemetry_monitor/mock_telemetry_observable.h @@ -33,9 +33,9 @@ #ifndef SRC_COMPONENTS_INCLUDE_TEST_TELEMETRY_MONITOR_MOCK_TELEMETRY_OBSERVABLE_H_ #define SRC_COMPONENTS_INCLUDE_TEST_TELEMETRY_MONITOR_MOCK_TELEMETRY_OBSERVABLE_H_ +#include "application_manager/telemetry_observer.h" #include "gmock/gmock.h" #include "telemetry_monitor/telemetry_observable.h" -#include "application_manager/telemetry_observer.h" namespace test { namespace components { diff --git a/src/components/include/test/transport_manager/mock_transport_manager.h b/src/components/include/test/transport_manager/mock_transport_manager.h index 2ef79f930c0..884bde50bf0 100644 --- a/src/components/include/test/transport_manager/mock_transport_manager.h +++ b/src/components/include/test/transport_manager/mock_transport_manager.h @@ -33,22 +33,22 @@ #ifndef SRC_COMPONENTS_INCLUDE_TEST_TRANSPORT_MANAGER_MOCK_TRANSPORT_MANAGER_H_ #define SRC_COMPONENTS_INCLUDE_TEST_TRANSPORT_MANAGER_MOCK_TRANSPORT_MANAGER_H_ -#include "gmock/gmock.h" #include -#include "transport_manager/transport_manager.h" -#include "transport_manager/transport_adapter/transport_adapter_event.h" -#include "telemetry_monitor/telemetry_observable.h" +#include "gmock/gmock.h" #include "resumption/last_state.h" +#include "telemetry_monitor/telemetry_observable.h" +#include "transport_manager/transport_adapter/transport_adapter_event.h" +#include "transport_manager/transport_manager.h" namespace test { namespace components { namespace transport_manager_test { -using ::transport_manager::DeviceHandle; using ::transport_manager::ConnectionUID; -using ::transport_manager::transport_adapter::TransportAdapter; +using ::transport_manager::DeviceHandle; using ::transport_manager::TransportAdapterEvent; using ::transport_manager::TransportManagerListener; +using ::transport_manager::transport_adapter::TransportAdapter; /* * MOCK implementation of ::transport_manager::TransportManager interface */ @@ -58,6 +58,9 @@ class MockTransportManager : public ::transport_manager::TransportManager, public: MOCK_METHOD1(Init, int(resumption::LastState& last_state)); MOCK_METHOD0(Reinit, int()); + MOCK_METHOD0(Deinit, void()); + MOCK_METHOD0(StopEventsProcessing, void()); + MOCK_METHOD0(StartEventsProcessing, void()); MOCK_METHOD0(SearchDevices, int()); MOCK_METHOD1( AddCloudDevice, @@ -78,7 +81,9 @@ class MockTransportManager : public ::transport_manager::TransportManager, MOCK_METHOD1(AddEventListener, int(TransportManagerListener* listener)); MOCK_METHOD0(Stop, int()); MOCK_METHOD1(RemoveDevice, int(const DeviceHandle)); - MOCK_CONST_METHOD1(Visibility, int(const bool&)); + MOCK_CONST_METHOD1(PerformActionOnClients, + int(transport_manager::TransportAction required_action)); + MOCK_METHOD1(SetTelemetryObserver, void(transport_manager::TMTelemetryObserver* observer)); }; diff --git a/src/components/include/test/transport_manager/mock_transport_manager_settings.h b/src/components/include/test/transport_manager/mock_transport_manager_settings.h index bed0d5e6e62..6ed4ac5d51e 100644 --- a/src/components/include/test/transport_manager/mock_transport_manager_settings.h +++ b/src/components/include/test/transport_manager/mock_transport_manager_settings.h @@ -33,9 +33,9 @@ #define SRC_COMPONENTS_INCLUDE_TEST_TRANSPORT_MANAGER_MOCK_TRANSPORT_MANAGER_SETTINGS_H_ #include "gmock/gmock.h" +#include "mock_transport_manager_mme_settings.h" #include "protocol_handler/protocol_handler.h" #include "transport_manager/transport_manager_settings.h" -#include "mock_transport_manager_mme_settings.h" namespace test { namespace components { @@ -65,6 +65,13 @@ class MockTransportManagerSettings std::string&()); MOCK_CONST_METHOD0(cloud_app_retry_timeout, uint32_t()); MOCK_CONST_METHOD0(cloud_app_max_retry_attempts, uint16_t()); + MOCK_CONST_METHOD0(bluetooth_uuid, const uint8_t*()); + MOCK_CONST_METHOD0(aoa_filter_manufacturer, const std::string&()); + MOCK_CONST_METHOD0(aoa_filter_model_name, const std::string&()); + MOCK_CONST_METHOD0(aoa_filter_description, const std::string&()); + MOCK_CONST_METHOD0(aoa_filter_version, const std::string&()); + MOCK_CONST_METHOD0(aoa_filter_uri, const std::string&()); + MOCK_CONST_METHOD0(aoa_filter_serial_number, const std::string&()); }; } // namespace transport_manager_test diff --git a/src/components/include/test/transport_manager/transport_adapter/mock_device.h b/src/components/include/test/transport_manager/transport_adapter/mock_device.h index 6829e98d1d1..c1e0153a761 100644 --- a/src/components/include/test/transport_manager/transport_adapter/mock_device.h +++ b/src/components/include/test/transport_manager/transport_adapter/mock_device.h @@ -34,9 +34,9 @@ #define SRC_COMPONENTS_TRANSPORT_MANAGER_TEST_INCLUDE_TRANSPORT_MANAGER_MOCK_DEVICE_H_ #include "gmock/gmock.h" -#include "transport_manager/transport_adapter/device.h" #include "transport_manager/common.h" #include "transport_manager/tcp/tcp_device.h" +#include "transport_manager/transport_adapter/device.h" namespace test { namespace components { diff --git a/src/components/include/test/transport_manager/transport_adapter/mock_transport_adapter.h b/src/components/include/test/transport_manager/transport_adapter/mock_transport_adapter.h index 3864c3f6f9f..0c0e2dd5ec6 100644 --- a/src/components/include/test/transport_manager/transport_adapter/mock_transport_adapter.h +++ b/src/components/include/test/transport_manager/transport_adapter/mock_transport_adapter.h @@ -34,8 +34,8 @@ #define SRC_COMPONENTS_INCLUDE_TEST_TRANSPORT_MANAGER_TRANSPORT_ADAPTER_MOCK_TRANSPORT_ADAPTER_H_ #include "gmock/gmock.h" -#include "transport_manager/transport_adapter/transport_adapter.h" #include "transport_manager/transport_adapter/device.h" +#include "transport_manager/transport_adapter/transport_adapter.h" namespace test { namespace components { @@ -72,12 +72,9 @@ class MockTransportAdapter const ::transport_manager::DeviceUID& device_handle)); MOCK_METHOD2(RunAppOnDevice, void(const std::string&, const std::string&)); MOCK_CONST_METHOD0(IsClientOriginatedConnectSupported, bool()); - MOCK_METHOD0( - StartClientListening, - ::transport_manager::transport_adapter::TransportAdapter::Error()); - MOCK_METHOD0( - StopClientListening, - ::transport_manager::transport_adapter::TransportAdapter::Error()); + MOCK_METHOD1(ChangeClientListening, + ::transport_manager::transport_adapter::TransportAdapter::Error( + ::transport_manager::TransportAction required_change)); MOCK_METHOD2(RemoveFinalizedConnection, void(const ::transport_manager::DeviceUID& device_handle, const ::transport_manager::ApplicationHandle& app_handle)); diff --git a/src/components/include/test/utils/mock_system_time_handler.h b/src/components/include/test/utils/mock_system_time_handler.h index 7bb2a7f0a50..5d82c0a8c74 100644 --- a/src/components/include/test/utils/mock_system_time_handler.h +++ b/src/components/include/test/utils/mock_system_time_handler.h @@ -50,6 +50,7 @@ class MockSystemTimeHandler : public ::utils::SystemTimeHandler { void(utils::SystemTimeListener* listener)); MOCK_METHOD0(GetUTCTime, time_t()); MOCK_CONST_METHOD0(system_time_can_be_received, bool()); + MOCK_METHOD0(ResetPendingSystemTimeRequests, void()); ~MockSystemTimeHandler() {} private: diff --git a/src/components/include/test/utils/test_async_waiter.h b/src/components/include/test/utils/test_async_waiter.h index fee7672e936..12d6cd04b76 100644 --- a/src/components/include/test/utils/test_async_waiter.h +++ b/src/components/include/test/utils/test_async_waiter.h @@ -35,8 +35,8 @@ #include -#include "utils/lock.h" #include "utils/conditional_variable.h" +#include "utils/lock.h" namespace test { diff --git a/src/components/include/transport_manager/common.h b/src/components/include/transport_manager/common.h index b36dcde67e5..08f52ae1d01 100644 --- a/src/components/include/transport_manager/common.h +++ b/src/components/include/transport_manager/common.h @@ -33,15 +33,26 @@ #ifndef SRC_COMPONENTS_INCLUDE_TRANSPORT_MANAGER_COMMON_H_ #define SRC_COMPONENTS_INCLUDE_TRANSPORT_MANAGER_COMMON_H_ -#include -#include #include +#include +#include /** * @brief - transport_manager namespace */ namespace transport_manager { +/** + * @enum Actions that could + * be performed on connected clients. + */ +enum class TransportAction { + kVisibilityOn, + kVisibilityOff, + kListeningOn, + kListeningOff +}; + /** * @enum Transport manager states. */ diff --git a/src/components/include/transport_manager/error.h b/src/components/include/transport_manager/error.h index ba357dd54be..eb0f7027174 100644 --- a/src/components/include/transport_manager/error.h +++ b/src/components/include/transport_manager/error.h @@ -33,8 +33,8 @@ #ifndef SRC_COMPONENTS_INCLUDE_TRANSPORT_MANAGER_ERROR_H_ #define SRC_COMPONENTS_INCLUDE_TRANSPORT_MANAGER_ERROR_H_ -#include #include +#include namespace transport_manager { diff --git a/src/components/include/transport_manager/transport_adapter/device.h b/src/components/include/transport_manager/transport_adapter/device.h index ad035245d8b..184616d714a 100644 --- a/src/components/include/transport_manager/transport_adapter/device.h +++ b/src/components/include/transport_manager/transport_adapter/device.h @@ -33,9 +33,9 @@ #ifndef SRC_COMPONENTS_INCLUDE_TRANSPORT_MANAGER_TRANSPORT_ADAPTER_DEVICE_H_ #define SRC_COMPONENTS_INCLUDE_TRANSPORT_MANAGER_TRANSPORT_ADAPTER_DEVICE_H_ +#include #include #include -#include #include "transport_manager/common.h" 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 eaa1fa9955e..b92e010ece0 100644 --- a/src/components/include/transport_manager/transport_adapter/transport_adapter.h +++ b/src/components/include/transport_manager/transport_adapter/transport_adapter.h @@ -36,15 +36,15 @@ #ifndef SRC_COMPONENTS_INCLUDE_TRANSPORT_MANAGER_TRANSPORT_ADAPTER_TRANSPORT_ADAPTER_H_ #define SRC_COMPONENTS_INCLUDE_TRANSPORT_MANAGER_TRANSPORT_ADAPTER_TRANSPORT_ADAPTER_H_ -#include -#include #include #include +#include +#include -#include "transport_manager/transport_adapter/device.h" +#include "protocol/common.h" #include "transport_manager/common.h" #include "transport_manager/error.h" -#include "protocol/common.h" +#include "transport_manager/transport_adapter/device.h" namespace transport_manager { @@ -111,7 +111,15 @@ class TransportAdapter { /** * @enum Available types of errors. */ - enum Error { OK, FAIL, NOT_SUPPORTED, ALREADY_EXISTS, BAD_STATE, BAD_PARAM }; + enum Error { + UNKNOWN = -1, + OK, + FAIL, + NOT_SUPPORTED, + ALREADY_EXISTS, + BAD_STATE, + BAD_PARAM + }; public: /** @@ -236,18 +244,10 @@ class TransportAdapter { virtual bool IsClientOriginatedConnectSupported() const = 0; /** - * @brief Start client listener. - * - * @return Error information about possible reason of failure. - */ - virtual Error StartClientListening() = 0; - - /** - * @brief Stop client listener. - * + * @brief Changes client listening state of current adapter * @return Error information about possible reason of failure. */ - virtual Error StopClientListening() = 0; + virtual Error ChangeClientListening(TransportAction required_change) = 0; /** * @brief Remove marked as FINALISING connection from accounting. 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 63d1678ed02..79daa51c36e 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 @@ -33,9 +33,9 @@ #ifndef SRC_COMPONENTS_INCLUDE_TRANSPORT_MANAGER_TRANSPORT_ADAPTER_TRANSPORT_ADAPTER_EVENT_H_ #define SRC_COMPONENTS_INCLUDE_TRANSPORT_MANAGER_TRANSPORT_ADAPTER_TRANSPORT_ADAPTER_EVENT_H_ +#include "protocol/common.h" #include "transport_manager/common.h" #include "transport_manager/transport_adapter/transport_adapter.h" -#include "protocol/common.h" namespace transport_manager { diff --git a/src/components/include/transport_manager/transport_manager.h b/src/components/include/transport_manager/transport_manager.h index eabb4f7028b..ce92bfd9cb2 100644 --- a/src/components/include/transport_manager/transport_manager.h +++ b/src/components/include/transport_manager/transport_manager.h @@ -33,10 +33,10 @@ #ifndef SRC_COMPONENTS_INCLUDE_TRANSPORT_MANAGER_TRANSPORT_MANAGER_H_ #define SRC_COMPONENTS_INCLUDE_TRANSPORT_MANAGER_TRANSPORT_MANAGER_H_ +#include "protocol/common.h" #include "transport_manager/common.h" -#include "transport_manager/transport_manager_listener.h" #include "transport_manager/transport_adapter/transport_adapter_event.h" -#include "protocol/common.h" +#include "transport_manager/transport_manager_listener.h" namespace resumption { class LastState; @@ -69,10 +69,25 @@ class TransportManager { virtual int Reinit() = 0; /** - * @brief Start scanning for new devices. - * - * @return Code error. - **/ + * @brief Deinitializes all transport adapters and device instances + */ + virtual void Deinit() = 0; + + /** + * @brief Stops transport events processing handler threads + */ + virtual void StopEventsProcessing() = 0; + + /** + * @brief Resumes transport events processing handler threads + */ + virtual void StartEventsProcessing() = 0; + + /** + * @brief Start scanning for new devices. + * + * @return Code error. + **/ virtual int SearchDevices() = 0; virtual void AddCloudDevice( @@ -193,13 +208,13 @@ class TransportManager { virtual int RemoveDevice(const DeviceHandle device_handle) = 0; /** - * @brief Turns on or off visibility of SDL to mobile devices - * when visibility is ON (on_off = true) mobile devices are able to connect - * otherwise ((on_off = false)) SDL is not visible from outside - * - * @return Code error. + * @brief Performs specified action on connected clients + * @param required_action is the action which should be performed for the + * connected clients + * @return error code */ - virtual int Visibility(const bool& on_off) const = 0; + virtual int PerformActionOnClients( + const TransportAction required_action) const = 0; }; } // namespace transport_manager #endif // SRC_COMPONENTS_INCLUDE_TRANSPORT_MANAGER_TRANSPORT_MANAGER_H_ diff --git a/src/components/include/transport_manager/transport_manager_listener.h b/src/components/include/transport_manager/transport_manager_listener.h index 22ee519a67d..a733dc7d1c2 100644 --- a/src/components/include/transport_manager/transport_manager_listener.h +++ b/src/components/include/transport_manager/transport_manager_listener.h @@ -35,10 +35,10 @@ #include #include +#include "protocol/common.h" #include "transport_manager/common.h" -#include "transport_manager/info.h" #include "transport_manager/error.h" -#include "protocol/common.h" +#include "transport_manager/info.h" namespace transport_manager { @@ -57,8 +57,8 @@ class TransportManagerListener { virtual void OnDeviceListUpdated(const std::vector&) = 0; /** - * @brief Reaction to "Find new applications" request - */ + * @brief Reaction to "Find new applications" request + */ virtual void OnFindNewApplicationsRequest() = 0; /** 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 193a86819c7..6754540b4c1 100644 --- a/src/components/include/transport_manager/transport_manager_listener_empty.h +++ b/src/components/include/transport_manager/transport_manager_listener_empty.h @@ -35,8 +35,8 @@ #include -#include "transport_manager/transport_manager_listener.h" #include "protocol/common.h" +#include "transport_manager/transport_manager_listener.h" namespace transport_manager { diff --git a/src/components/include/transport_manager/transport_manager_mme_settings.h b/src/components/include/transport_manager/transport_manager_mme_settings.h index efe26468ab8..721df03d34c 100644 --- a/src/components/include/transport_manager/transport_manager_mme_settings.h +++ b/src/components/include/transport_manager/transport_manager_mme_settings.h @@ -60,6 +60,6 @@ class TransportManagerMMESettings { virtual uint32_t iap_hub_connection_wait_timeout() const = 0; }; -} +} // namespace transport_manager #endif // SRC_COMPONENTS_INCLUDE_TRANSPORT_MANAGER_TRANSPORT_MANAGER_MME_SETTINGS_H_ diff --git a/src/components/include/transport_manager/transport_manager_settings.h b/src/components/include/transport_manager/transport_manager_settings.h index cbc1516c29d..83d0b3e8333 100644 --- a/src/components/include/transport_manager/transport_manager_settings.h +++ b/src/components/include/transport_manager/transport_manager_settings.h @@ -79,6 +79,15 @@ class TransportManagerSettings : public TransportManagerMMESettings { * @brief Returns maximum retry attempts for cloud app connections */ virtual uint16_t cloud_app_max_retry_attempts() const = 0; + + virtual const uint8_t* bluetooth_uuid() const = 0; + + virtual const std::string& aoa_filter_manufacturer() const = 0; + virtual const std::string& aoa_filter_model_name() const = 0; + virtual const std::string& aoa_filter_description() const = 0; + virtual const std::string& aoa_filter_version() const = 0; + virtual const std::string& aoa_filter_uri() const = 0; + virtual const std::string& aoa_filter_serial_number() const = 0; }; } // namespace transport_manager #endif // SRC_COMPONENTS_INCLUDE_TRANSPORT_MANAGER_TRANSPORT_MANAGER_SETTINGS_H_ diff --git a/src/components/include/utils/custom_string.h b/src/components/include/utils/custom_string.h index 7b21e7a64dd..0e5ef244f07 100644 --- a/src/components/include/utils/custom_string.h +++ b/src/components/include/utils/custom_string.h @@ -81,8 +81,8 @@ class CustomString { CustomString(size_t n, char c); /** - * @brief Returns the length of the string, in terms of characters. - */ + * @brief Returns the length of the string, in terms of characters. + */ size_t size() const; /** diff --git a/src/components/include/utils/date_time.h b/src/components/include/utils/date_time.h index 17b4fafe385..747cb0ea696 100644 --- a/src/components/include/utils/date_time.h +++ b/src/components/include/utils/date_time.h @@ -53,6 +53,7 @@ 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 SECONDS_IN_DAY = 86400; const int32_t MICROSECONDS_IN_SECOND = MILLISECONDS_IN_SECOND * MICROSECONDS_IN_MILLISECOND; const int32_t NANOSECONDS_IN_MILLISECOND = @@ -83,6 +84,9 @@ int64_t calculateTimeSpan(const TimeDuration& sinceTime); // return MILLISECONDS count between time1 and time2 int64_t calculateTimeDiff(const TimeDuration& time1, const TimeDuration& time2); +// returns difference between specific date and current date +int64_t calculateAmountDaysFromDate(const std::time_t& start_date); + /** * @brief Adds milliseconds to time struct * @param time contains time struct diff --git a/src/components/include/utils/logger.h b/src/components/include/utils/logger.h index 75daa552a2f..d492cfcb1be 100644 --- a/src/components/include/utils/logger.h +++ b/src/components/include/utils/logger.h @@ -35,13 +35,13 @@ #ifdef ENABLE_LOG #include -#include -#include #include #include -#include "utils/push_log.h" -#include "utils/logger_status.h" +#include +#include #include "utils/auto_trace.h" +#include "utils/logger_status.h" +#include "utils/push_log.h" #endif // ENABLE_LOG #ifdef ENABLE_LOG @@ -65,6 +65,11 @@ void deinit_logger(); #define DEINIT_LOGGER() deinit_logger() +// Logger thread deinitilization macro that need to stop the thread of handling +// messages for the log4cxx +#define DELETE_THREAD_LOGGER(logger_var) \ + logger::delete_log_message_loop_thread(logger_var) + // special macros to dump logs from queue // it's need, for example, when crash happend #define FLUSH_LOGGER() logger::flush_logger() @@ -121,15 +126,15 @@ log4cxx_time_t time_now(); #define LOG4CXX_FATAL(loggerPtr, logEvent) \ LOG_WITH_LEVEL(loggerPtr, ::log4cxx::Level::getFatal(), logEvent) -#define LOG4CXX_ERROR_WITH_ERRNO(loggerPtr, message) \ - LOG4CXX_ERROR(loggerPtr, \ - message << ", error code " << errno << " (" << strerror(errno) \ - << ")") +#define LOG4CXX_ERROR_WITH_ERRNO(loggerPtr, message) \ + LOG4CXX_ERROR( \ + loggerPtr, \ + message << ", error code " << errno << " (" << strerror(errno) << ")") -#define LOG4CXX_WARN_WITH_ERRNO(loggerPtr, message) \ - LOG4CXX_WARN(loggerPtr, \ - message << ", error code " << errno << " (" << strerror(errno) \ - << ")") +#define LOG4CXX_WARN_WITH_ERRNO(loggerPtr, message) \ + LOG4CXX_WARN( \ + loggerPtr, \ + message << ", error code " << errno << " (" << strerror(errno) << ")") #else // ENABLE_LOG is OFF @@ -141,6 +146,8 @@ log4cxx_time_t time_now(); #define DEINIT_LOGGER() +#define DELETE_THREAD_LOGGER(logger_var) + #define FLUSH_LOGGER() #define LOG4CXX_IS_TRACE_ENABLED(logger) false diff --git a/src/components/include/utils/macro.h b/src/components/include/utils/macro.h index e6f3b6b3ca9..00298f690ec 100644 --- a/src/components/include/utils/macro.h +++ b/src/components/include/utils/macro.h @@ -40,7 +40,7 @@ #include "logger.h" // A macro to set some action for variable to avoid "unused variable" warning -#define UNUSED(x) (void) x; +#define UNUSED(x) (void)x; // A macro to disallow the copy constructor and operator= functions // This should be used in the private: declarations for a class #define DISALLOW_COPY_AND_ASSIGN(TypeName) \ @@ -133,9 +133,9 @@ #endif /* -* @brief Calculate size of na array -* @param arr array, which size need to calculate -*/ + * @brief Calculate size of na array + * @param arr array, which size need to calculate + */ #define ARRAYSIZE(arr) sizeof(arr) / sizeof(*arr) #ifdef BUILD_TESTS @@ -146,9 +146,9 @@ #endif // BUILD_TESTS /* -* @brief deprecate a method declaration, a warning will be thrown by your -* compiler if a method with this macro is used -*/ + * @brief deprecate a method declaration, a warning will be thrown by your + * compiler if a method with this macro is used + */ #if __cplusplus > 201103L #define DEPRECATED [[deprecated]] #else diff --git a/src/components/include/utils/message_queue.h b/src/components/include/utils/message_queue.h index 093aa4cac26..8dfe7afa523 100644 --- a/src/components/include/utils/message_queue.h +++ b/src/components/include/utils/message_queue.h @@ -33,8 +33,8 @@ #ifndef SRC_COMPONENTS_INCLUDE_UTILS_MESSAGE_QUEUE_H_ #define SRC_COMPONENTS_INCLUDE_UTILS_MESSAGE_QUEUE_H_ -#include #include +#include #include "utils/conditional_variable.h" #include "utils/lock.h" @@ -97,9 +97,9 @@ class MessageQueue { void wait(); /** - * \brief waitUntilEmpty message queue - * Wait until message queue is empty - */ + * \brief waitUntilEmpty message queue + * Wait until message queue is empty + */ void WaitUntilEmpty(); /** @@ -112,8 +112,8 @@ class MessageQueue { void Shutdown(); /** - * \brief Clears queue. - */ + * \brief Clears queue. + */ void Reset(); private: @@ -131,8 +131,7 @@ class MessageQueue { }; template -MessageQueue::MessageQueue() - : shutting_down_(false) {} +MessageQueue::MessageQueue() : shutting_down_(false) {} template MessageQueue::~MessageQueue() {} diff --git a/src/components/include/utils/prioritized_queue.h b/src/components/include/utils/prioritized_queue.h index eb4ba6a6c3c..a2eb200012e 100644 --- a/src/components/include/utils/prioritized_queue.h +++ b/src/components/include/utils/prioritized_queue.h @@ -33,9 +33,9 @@ #ifndef SRC_COMPONENTS_INCLUDE_UTILS_PRIORITIZED_QUEUE_H_ #define SRC_COMPONENTS_INCLUDE_UTILS_PRIORITIZED_QUEUE_H_ -#include -#include #include +#include +#include #include "utils/macro.h" diff --git a/src/components/include/utils/push_log.h b/src/components/include/utils/push_log.h index aaeaa83bae2..f6c396ae71b 100644 --- a/src/components/include/utils/push_log.h +++ b/src/components/include/utils/push_log.h @@ -51,7 +51,7 @@ bool logs_enabled(); void set_logs_enabled(bool state); void create_log_message_loop_thread(); -void delete_log_message_loop_thread(); +void delete_log_message_loop_thread(log4cxx::LoggerPtr& logger); } // namespace logger #endif // SRC_COMPONENTS_INCLUDE_UTILS_PUSH_LOG_H_ diff --git a/src/components/include/utils/rwlock.h b/src/components/include/utils/rwlock.h index b7e7484b484..5c7735713e5 100644 --- a/src/components/include/utils/rwlock.h +++ b/src/components/include/utils/rwlock.h @@ -98,15 +98,15 @@ class RWLock { bool TryAcquireForReading(); /** - * @brief Try to Acqure read-write lock for writing. - * Applies a write lock like AcquireForWriting(), with the exception that + * @brief Try to Acqure read-write lock for writing. + * Applies a write lock like AcquireForWriting(), with the exception that * the - * function fails if any thread currently holds rwlock (for reading or + * function fails if any thread currently holds rwlock (for reading or * writing) - * Invoke of TryAcquireForWriting will not block calling thread and returns + * Invoke of TryAcquireForWriting will not block calling thread and returns * "false" - * @returns true if lock was acquired and false if was not - */ + * @returns true if lock was acquired and false if was not + */ bool TryAcquireForWriting(); /** @@ -126,12 +126,12 @@ class RWLock { bool AcquireForWriting(); /** - * @brief Release read-write lock. - * Releases a lock held on the read-write lock object. - * Results are undefined if the read-write lock rwlock - * is not held by the calling thread. - * @returns true if lock was released and false if was not - */ + * @brief Release read-write lock. + * Releases a lock held on the read-write lock object. + * Results are undefined if the read-write lock rwlock + * is not held by the calling thread. + * @returns true if lock was released and false if was not + */ bool Release(); private: diff --git a/src/components/include/utils/scope_guard.h b/src/components/include/utils/scope_guard.h index a425356c0e1..a05be6dc11a 100644 --- a/src/components/include/utils/scope_guard.h +++ b/src/components/include/utils/scope_guard.h @@ -322,5 +322,5 @@ ObjScopeGuardImpl1 MakeObjGuard(Obj& obj, const P1& p1) { return ObjScopeGuardImpl1::MakeObjGuard(obj, memFun, p1); } -} +} // namespace utils #endif // SRC_COMPONENTS_INCLUDE_UTILS_SCOPE_GUARD_H_ diff --git a/src/components/include/utils/semantic_version.h b/src/components/include/utils/semantic_version.h index 5fe7ce1debb..5b2f2a1cdfd 100644 --- a/src/components/include/utils/semantic_version.h +++ b/src/components/include/utils/semantic_version.h @@ -120,6 +120,6 @@ struct SemanticVersion { extern const SemanticVersion base_rpc_version; extern const SemanticVersion rpc_version_5; -} +} // namespace utils #endif // SRC_COMPONENTS_INCLUDE_UTILS_CALLABLE_H \ No newline at end of file diff --git a/src/components/include/utils/threads/async_runner.h b/src/components/include/utils/threads/async_runner.h index 64c9d099398..5c88112267f 100644 --- a/src/components/include/utils/threads/async_runner.h +++ b/src/components/include/utils/threads/async_runner.h @@ -33,14 +33,14 @@ #ifndef SRC_COMPONENTS_INCLUDE_UTILS_THREADS_ASYNC_RUNNER_H_ #define SRC_COMPONENTS_INCLUDE_UTILS_THREADS_ASYNC_RUNNER_H_ -#include #include +#include -#include "thread_delegate.h" #include "thread.h" +#include "thread_delegate.h" -#include "utils/lock.h" #include "utils/conditional_variable.h" +#include "utils/lock.h" namespace threads { diff --git a/src/components/include/utils/threads/message_loop_thread.h b/src/components/include/utils/threads/message_loop_thread.h index add7fc38b81..26ae127b69c 100644 --- a/src/components/include/utils/threads/message_loop_thread.h +++ b/src/components/include/utils/threads/message_loop_thread.h @@ -33,8 +33,8 @@ #ifndef SRC_COMPONENTS_INCLUDE_UTILS_THREADS_MESSAGE_LOOP_THREAD_H_ #define SRC_COMPONENTS_INCLUDE_UTILS_THREADS_MESSAGE_LOOP_THREAD_H_ -#include #include +#include #include "utils/logger.h" #include "utils/macro.h" diff --git a/src/components/include/utils/threads/thread.h b/src/components/include/utils/threads/thread.h index cba79b20bdf..6f72679d635 100644 --- a/src/components/include/utils/threads/thread.h +++ b/src/components/include/utils/threads/thread.h @@ -40,11 +40,11 @@ #include #include +#include "utils/conditional_variable.h" +#include "utils/lock.h" #include "utils/macro.h" #include "utils/threads/thread_delegate.h" #include "utils/threads/thread_options.h" -#include "utils/conditional_variable.h" -#include "utils/lock.h" namespace threads { diff --git a/src/components/include/utils/typed_enum_print.h b/src/components/include/utils/typed_enum_print.h index e2b903c948f..0f3cc41bf8c 100644 --- a/src/components/include/utils/typed_enum_print.h +++ b/src/components/include/utils/typed_enum_print.h @@ -33,8 +33,8 @@ #ifndef SRC_COMPONENTS_INCLUDE_UTILS_TYPED_ENUM_PRINT_H_ #define SRC_COMPONENTS_INCLUDE_UTILS_TYPED_ENUM_PRINT_H_ -#include #include +#include namespace utils { diff --git a/src/components/interfaces/HMI_API.xml b/src/components/interfaces/HMI_API.xml index 55a3a99e9df..d105d2e3e84 100644 --- a/src/components/interfaces/HMI_API.xml +++ b/src/components/interfaces/HMI_API.xml @@ -66,6 +66,28 @@ + + + + This window type describes the main screen on a display. + + + + + A widget is a small window that the app can create to provide information and softbuttons for a quick app control. + + + + + + + The default window is a main window pre-created on behalf of the app. + + + The primary widget of the app. + + + Lists of the transport types used for device connection to HU. @@ -116,6 +138,27 @@ + + + + + + + + + + + + + + + If supported, this toggles between a top-down view and an angled/3D view. If your app supports different, but substantially similar options, then you may implement those. If you don't implement these or similar options, do not subscribe to this button. + + + + + If supported, this toggles between locking the orientation to north or to the vehicle's heading. If your app supports different, but substantially similar options, then you may implement those. If you don't implement these or similar options, do not subscribe to this button. + @@ -359,7 +402,7 @@ Indicates that a button press of the Play/Pause button would stop the current playback. - + Enumeration that describes possible contexts the application might be in on HU. @@ -514,6 +557,9 @@ The track field of NGN and GEN1.1 MFD displays. This field is only available for media applications; applies to "Show" + + The title of the new template that will be displayed; applies to "Show" + The first line of the alert text field; applies to "Alert" @@ -565,12 +611,6 @@ Optional text to label an app menu button (for certain touchscreen platforms). - - Navigation text for UpdateTurnList. - - - Text of notification to be displayed on screen. - Optional name / title of intended location for SendLocation. @@ -585,7 +625,13 @@ - + + + Navigation text for UpdateTurnList. + + + Text of notification to be displayed on screen. + @@ -667,6 +713,9 @@ The optional image of a destination / location + + The image field for Alert + @@ -1111,6 +1160,7 @@ + @@ -1605,6 +1655,56 @@ + + + Describes a location (origin coordinates and span) of a vehicle component. + + + + + + + + + + + + + + + + Information about a RC module + + uuid of a module. "moduleId + moduleType" uniquely identify a module. + + + Location of a module. + + + Service area of a module. + + + allow multiple users/apps to access the module or not + + + + + Describes the location of a seat. + + + + + + Contains information about the locations of each seat + + + + + + Contains a list of SeatLocation in the vehicle + + + @@ -1678,8 +1778,7 @@ Seat control data corresponds to "SEAT" ModuleType. - - + @@ -1707,6 +1806,9 @@ It should not be used to identify a module by mobile application. + + Information about a RC module, including its id. + @@ -1845,6 +1947,13 @@ The speed in KPH + + + True, if GPS lat/long, time, and altitude have been purposefully shifted (requires a proprietary algorithm to unshift). + False, if the GPS data is raw and un-shifted. + If not provided, then value is assumed False. + + @@ -1880,9 +1989,15 @@ True if the hd radio is on, false is the radio is off - number of HD sub-channels if available + + Number of HD sub-channels if available. + Note that this parameter is deprecated in MOBILE API. + + + + The list of available hd sub-channel indexes. Empty list means no Hd channel is available. Read-only. - + Current HD sub-channel if available @@ -1905,6 +2020,9 @@ The short name or a short description of the radio control module. + + Information about a RC module, including its id. + Availability of the control of enable/disable radio. @@ -1936,9 +2054,17 @@ - + Availability of the getting the number of available HD channels. True: Available, False: Not Available, Not present: Not Available. + Note that this parameter is deprecated in MOBILE API + + + + + + Availability of the list of available HD sub-channel indexes. + True: Available, False: Not Available, Not present: Not Available. @@ -2040,6 +2166,8 @@ value false means disabled, value true means enabled. + + @@ -2047,6 +2175,9 @@ The short name or a short description of the climate control module. + + Information about a RC module, including its id. + Availability of the reading of current temperature. @@ -2141,6 +2272,12 @@ True: Available, False: Not Available, Not present: Not Available. + + + Availability of the control of enable/disable climate control. + True: Available, False: Not Available, Not present: Not Available. + + @@ -2184,6 +2321,9 @@ It should not be used to identify a module by mobile application. + + Information about a RC module, including its id. + Availability of the control of audio source. @@ -2343,6 +2483,9 @@ It should not be used to identify a module by mobile application. + + Information about a RC module, including its id. + An array of available light names that are controllable. @@ -2387,6 +2530,9 @@ It should not be used to identify a module by mobile application. + + Information about a RC module, including its id. + Availability of the control of distance unit. @@ -2402,6 +2548,9 @@ 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 + + Id of a module, published by System Capability. + @@ -2444,6 +2593,9 @@ The name of the Button from the ButtonName enum + + Information about a RC module, including its id. + The button supports a short press. Whenever the button is pressed short, onButtonPressed(SHORT) should be invoked. @@ -2576,6 +2728,17 @@ + + + + Predefined or dynamically created window template. + Currently only predefined window template layouts are defined. + + + + + + Data type containing information about application needed by HMI. @@ -2609,7 +2772,7 @@ Defines an additional voice recognition command. - Must not interfere with any name of previously registered applications(SDL makes check). + Must not interfere with any name of previously registered applications from the same device. @@ -2667,6 +2830,12 @@ + + How the main menu or submenu is laid out on screen + + + + A choice is an option given to the user which can be selected either by menu, or through voice recognition system. @@ -2827,6 +2996,12 @@ Must be true if the button supports referencing a static or dynamic image. + + + The button supports the use of text. + If not included, the default value should be considered true that the button will support text. + + @@ -2883,8 +3058,11 @@ All omitted characters will be greyed out (disabled) on the keyboard. If omitted, the entire keyboard will be enabled. - - Allows an app to prepopulate the text field with a suggested or completed entry as the user types + + + Allows an app to prepopulate the text field with a list of suggested or completed entries as the user types. + If empty, the auto-complete list will be removed from the screen. + @@ -3151,8 +3329,13 @@ References signal "VedsEvntRoll_D_Ltchd". See VehicleDataEventStatus. - - References signal "VedsMaxDeltaV_D_Ltchd". See VehicleDataEventStatus. + + + References signal "VedsMaxDeltaV_D_Ltchd". Change in velocity in KPH. Additional reserved values: + 0x00 No event + 0xFE Not supported + 0xFF Fault + References signal "VedsMultiEvnt_D_Ltchd". See VehicleDataEventStatus. @@ -3300,6 +3483,77 @@ True if the system can utilize the haptic spatial data from the source being streamed. + + The diagonal screen size in inches. + + + PPI is the diagonal resolution in pixels divided by the diagonal screen size in inches. + + + The scaling factor the app should use to change the size of the projecting view. + + + + + + + + + + + + + The specified ID of the window. Can be set to a predefined window, + or omitted for the main window on the main display. + + + + A set of all fields that support text data. See TextField + + + A set of all fields that support images. See ImageField + + + Provides information about image types supported by the system. + + + A set of all window templates available on the head unit. + + + The number of on-window custom presets available (if any); otherwise omitted. + + + The number of buttons and the capabilities of each on-window button. + + + The number of soft buttons available on-window and the capabilities for each button. + + + An array of available menu layouts. If this parameter is not provided, only the `LIST` layout is assumed to be available + + + + + Contains information about the display capabilities. + + + + Informs the application how many windows the app is allowed to create per type. + + + + + Contains a list of capabilities of all windows related to the app. + Once the app has registered the capabilities of all windows are provided. + GetSystemCapability still allows requesting window capabilities of all windows. + After registration, only windows with capabilities changed will be included. + Following cases will cause only affected windows to be included: + 1. App creates a new window. After the window is created, a system capability notification will be sent + related only to the created window. + 2. App sets a new layout to the window. The new layout changes window capabilties. + The notification will reflect those changes to the single window. + + @@ -3361,10 +3615,10 @@ The position of the haptic rectangle to be highlighted. The center of this rectangle will be "touched" when a press occurs. - - + + Specifies the version number of the SmartDeviceLink protocol that is supported by the mobile application or app service - + The major version indicates versions that is not-compatible to previous versions. @@ -3376,6 +3630,48 @@ + + + Refers to the Video service. + + + Refers to the Audio service. + + + Refers to the RPC service. + + + + + + When a request for a Service is received. + + + When a request for a Service is Accepted. + + + When a request for a Service is Rejected. + + + + + + When a Service is rejected because the system was unable to get a required Policy Table Update. + + + When a Service is rejected because the security certificate is invalid/expired. + + + When a Service is rejected because the system was unable to get a valid SystemTime from HMI, which is required for certificate authentication. + + + When a Service is rejected because the system configuration ini file requires the service must be protected, but the app asks for an unprotected service. + + + When a mobile app requests a protected service, but the system starts an unprotected service instead. + + + @@ -3484,6 +3780,14 @@ Audiobook: The total number of sections in the playback queue (e.g. the number of chapters in the book) + + + + Music: The album art of the current track + Podcast: The podcast or chapter artwork of the current podcast episode + Audiobook: The book or chapter artwork of the current audiobook + + @@ -3510,7 +3814,7 @@ - + @@ -3581,7 +3885,7 @@ Using this action plus a supplied direction can give the type of turn. - + @@ -3782,10 +4086,15 @@ + + - The systemCapabilityType identifies which data object exists in this struct. For example, if the SystemCapability Type is NAVIGATION then a "navigationCapability" should exist + + The systemCapabilityType 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 param included. @@ -3802,8 +4111,16 @@ Describes extended capabilities of the module's phone feature - An array of currently available services. If this is an update to the capability the affected services will include an update reason in that item - + + An array of currently available services. + If this is an update to the capability the affected services will include + an update reason in that item + + + + + Contains information about the locations of each seat + @@ -3826,6 +4143,9 @@ The module where the button should be pressed + + Id of a module, published by System Capability. + Indicates whether this is a LONG or SHORT button press event. @@ -3893,6 +4213,26 @@ + + + Must be sent by SDL to HMI when there is an update on status of certain services. + Services supported with current version: Video + + + Specifies the service which has been updated. + + + Specifies service update event. + + + + The reason for a service event. Certain events may not have a reason, such as when a service is ACCEPTED (which is the normal expected behavior). + + + + ID of the application which triggered the update. + + Request from SDL to HMI to obtain current UTC time. @@ -3973,17 +4313,35 @@ + + Request from the application to exit the foreground. + + ID of selected application. + + + + Must be sent by HU system when the user clicks on app in the list of registered apps or on soft button with 'STEAL_FOCUS' action. ID of selected application. + + + This is the unique ID assigned to the window that this RPC is intended. If this param is not included, it will be assumed that this request is specifically for the main window on the main display. See PredefinedWindows enum. + + Must be sent by HU system when the user switches to any functionality which is not other mobile application. ID of deactivated application. + + + This is the unique ID assigned to the window that this RPC is intended. If this param is not included, it will be assumed that this request is specifically for the main window on the main display. See PredefinedWindows enum. + + Issued by SDL to notify HMI about new application registered. @@ -4002,7 +4360,7 @@ Defines an additional voice recognition command. - Must not interfere with any name of previously registered applications(SDL makes check). + Must not interfere with any name of previously registered applications from the same device. @@ -4059,7 +4417,10 @@ Request from SDL to call a specific number. - The number to dial. Only the character + and numbers are allowed. + + Phone number is a string, which can be up to 40 chars. + All characters shall be stripped from string except digits 0-9 and * # , ; + + ID of application that concerns this RPC. @@ -4154,45 +4515,54 @@ - - Notification, that comes to HMI when mobile sents file with systemFile flag - + + Notification that is sent to HMI when a mobile application uploads a file + - - Optional offset in bytes for resuming partial data chunks - - - Optional length in bytes for resuming partial data chunks - + + Optional offset in bytes for resuming partial data chunks + + + Optional length in bytes for resuming partial data chunks + - - Full Size of file. sends in first OnPutFile notification if file is splited - into many PutFiles - - + + Full Size of file. sends in first OnPutFile notification if file is splited + into many PutFiles + + - - File reference name. - + + File reference name. + - - File reference name. - + + File reference name. + - - Selected file type. - + + Selected file type. + - - - Indicates if the file is meant to persist between sessions / ignition cycles. - If set to TRUE, then the system will aim to persist this file through session / cycles. - While files with this designation will have priority over others, they are subject to deletion by the system at any time. - In the event of automatic deletion by the system, the app will receive a rejection and have to resend the file. - If omitted, the value will be set to false. - - - + + + Indicates if the file is meant to persist between sessions / ignition cycles. + If set to TRUE, then the system will aim to persist this file through session / cycles. + While files with this designation will have priority over others, they are subject to deletion by the system at any time. + In the event of automatic deletion by the system, the app will receive a rejection and have to resend the file. + If omitted, the value will be set to false. + + + + + Indicates if the file is meant to be passed thru core to elsewhere on the system. + If true the system will pass the data thru as it arrives to a predetermined area outside of core. + + + + ID of application that uploaded this file. + + This request is sent to retrieve a file path from the HMI. @@ -4216,7 +4586,7 @@ Selected file type. - + Request from SDL to HMI to obtain information about head unit system. @@ -4259,10 +4629,17 @@ - A notification to inform the HMI that a specific system capability has changed. + + A notification between HMI and SDL that a specific system capability has been changed. + It can be sent in both directions SDL to HMI and HMI to SDL. Direction is dependent on + the point where capabilities have been changed + The system capability that has been updated + + ID of application that is related to this RPC. + @@ -4350,6 +4727,11 @@ ID of application related to this RPC. + + + An ID for this specific alert to allow cancellation through the `CancelInteraction` RPC. + + @@ -4373,7 +4755,7 @@ Request new VR synonyms registration Defines an additional voice recognition command. - Must not interfere with any name of previously registered applications(SDL makes check). + Must not interfere with any name of previously registered applications from the same device. @@ -4541,7 +4923,7 @@ - + Request from SDL to show an alert message on the display. @@ -4562,19 +4944,64 @@ ID of application requested this RPC. + + + An ID for this specific alert to allow cancellation through the `CancelInteraction` RPC. + + + + + Image to be displayed for the corresponding alert. See Image. + If omitted, no (or the default if applicable) icon should be displayed. + + + Amount of time (in milliseconds) that SDL must wait before resending an alert. Must be provided if another system event or overlay currently has a higher priority than this alert. + + + This RPC is deprecated. Use Show RPC to change layout. + + + Predefined or dynamically created screen layout. + Currently only predefined screen layouts are defined. + + + + ID of application related to this RPC. + + + + + + + This RPC is deprecated. Use Show RPC to change layout. + + See DisplayCapabilities + + + See ButtonCapabilities + + + If returned, the platform supports on-screen SoftButtons; see SoftButtonCapabilities. + + + If returned, the platform supports custom on-screen Presets; see PresetBankCapabilities. + + + - - Array of lines of show text fields. See TextFieldStruct. Uses mainField1, mainField2, mainField3, mainField4. If some field is not set, the corresponding text should stay unchanged. If field's text is empty "", the field must be cleared. + + Array of lines of show text fields. See TextFieldStruct. If some field is not set, the corresponding text should stay unchanged. If field's text is empty "", the field must be cleared. mainField1: The text that should be displayed in a single or upper display line. mainField2: The text that should be displayed on the second display line. mainField3: The text that should be displayed on the second "page" first display line. mainField4: The text that should be displayed on the second "page" second display line. + templateTitle: The title of the new template that will be displayed. statusBar: statusBar. mediaClock: Text value for MediaClock field. mediaTrack: The text that should be displayed in the track field. This field is only valid for media applications on NGN type ACMs. @@ -4604,16 +5031,105 @@ Id of application related to this RPC. + + + This is the unique ID assigned to the window that this RPC is intended. + If this param is not included, + it will be assumed that this request is specifically for the main window + on the main display. + See PredefinedWindows enum. + + + + + + Used to set an alternate template layout to a window. + + + + + + + Create a new window on the display with the specified window type. + + + + A unique ID to identify the window. The value of '0' will always be the default main window on the main display and should not be used in this context as it will already be created for the app. See PredefinedWindows enum. Creating a window with an ID that is already in use will be rejected with `INVALID_ID`. + + + + + + The window name to be used by the HMI. The name of the pre-created default window will match the app name. + Multiple apps can share the same window name except for the default main window. + Creating a window with a name which is already in use by the app will result in `DUPLICATE_NAME`. + + + + + The type of the window to be created. Main window or widget. + + + + + Allows an app to create a widget related to a specific service type. + As an example if a `MEDIA` app becomes active, this app becomes audible and is allowed to play audio. + Actions such as skip or play/pause will be directed to this active media app. + In case of widgets, the system can provide a single "media" widget which will act as a placeholder for the active media app. + It is only allowed to have one window per service type. This means that a media app can only have a single MEDIA widget. + Still the app can create widgets omitting this parameter. + Those widgets would be available as app specific widgets that are permanently included in the HMI. + This parameter is related to widgets only. The default main window, which is pre-created during app registration, + will be created based on the HMI types specified in the app registration request. + + + + + + Optional parameter. Specify whether the content sent to an existing window + should be duplicated to the created window. + If there isn't a window with the ID, the request will be rejected with `INVALID_DATA`. + + + + ID of application that concerns this RPC. + + + + + + + + + Deletes previously created window of the SDL application. + + + + A unique ID to identify the window. The value of '0' will always be the default main window + on the main display and cannot be deleted. + See PredefinedWindows enum. + + + + ID of application that concerns this RPC. + + + + + + Request from SDL to add a command to the application menu. ID of the command to be added. - Optional sub value containing parameters of the command (position, name, etc.). See MenuParams. If omitted the command should be added to the end of the list of commands. + + Optional sub value containing parameters of the command (position, name, etc.). See MenuParams. + If omitted the command should be added to the end of the list of commands. Image to be displayed for representing the command. See Image. @@ -4623,8 +5139,10 @@ ID of application that concerns this RPC. + - + + Request from SDL to delete a command from the in-application menu with the specified command id. @@ -4634,8 +5152,10 @@ ID of application that concerns this RPC. + + Request from SDL to add a sub menu to the in-application menu. @@ -4650,6 +5170,9 @@ ID of application that requested this RPC. + + Sets the layout of the submenu screen. + @@ -4664,6 +5187,20 @@ + + Request from SDL to show an app's menu or a corresponding sub-menu. + + + If ommited the HMI opens the app's menu. + If set to a sub-menu ID the HMI opens the corresponding sub-menu previously added using `AddSubMenu`. + + + + ID of application that concerns this RPC. + + + + Request from SDL for triggering an interaction (e.g. "Permit GPS?" - Yes, no, Always Allow). @@ -4688,6 +5225,11 @@ ID of application that concerns this RPC. + + + An ID for this specific alert to allow cancellation through the `CancelInteraction` RPC. + + @@ -4700,6 +5242,23 @@ + + + + The ID of the specific interaction you want to dismiss. If not set, the most recent of the RPC type set in functionID will be dismissed. + + + + + The ID of the type of interaction the developer wants to dismiss. Only values 10, (PerformInteractionID), 12 (AlertID), 25 (ScrollableMessageID), and 26 (SliderID) are permitted. + + + + ID of application requested this RPC. + + + + Sets the initial media clock value and automatic update method. @@ -4747,6 +5306,9 @@ ID of application that concerns this RPC. + + Sets the layout of the main menu screen. If this is sent while a menu is already on-screen, the head unit will change the display to the new layout type. + @@ -4770,6 +5332,11 @@ ID of application that is related to this RPC. + + + This is the unique ID assigned to the window that this RPC is intended. If this param is not included, it will be assumed that this request is specifically for the main window on the main display. See PredefinedWindows enum. + + Method is invoked at system startup by SDL to request information about UI capabilities of HMI. @@ -4778,7 +5345,17 @@ Information about the capabilities of the display: its type, text field supported, etc. See DisplayCapabilities. - + + + Describes an audio configuration that the system supports for PerformAudioPassThru. + Note: please fill out both audioPassThruCapabilities and audioPassThruCapabilitiesList parameters, as: + - Newer SDL Core uses audioPassThruCapabilitiesList instead of audioPassThruCapabilities, and + - audioPassThruCapabilities is a mandatory field and cannot be omitted. + + + + Describes the audio configurations that the system supports for PerformAudioPassThru. + Must be returned if the platform supports on-screen SoftButtons. @@ -4795,10 +5372,10 @@ Request new app name registration - Needs to be unique over all applications. + Needs to be unique over all applications from the same device. May not be empty. May not start with a new line character. - May not interfere with any name or synonym of any registered applications. - Applications with the same name will be rejected. (SDL makes all the checks) + May not interfere with any name or synonym of any registered applications from the same device. + Additional applications with the same name from the same device will be rejected. @@ -4855,66 +5432,6 @@ - - - - Predefined or dynamically created screen layout. - Currently only predefined screen layouts are defined. - - - - ID of application related to this RPC. - - - - - - - See DisplayCapabilities - - - See ButtonCapabilities - - - If returned, the platform supports on-screen SoftButtons; see SoftButtonCapabilities. - - - If returned, the platform supports custom on-screen Presets; see PresetBankCapabilities. - - - - Used to show a custom form; it can be a parent or child screen. If no parent screen is designated, it is set as a parent screen. - - - Predefined or dynamically created screen layout. - Currently only predefined forms are defined. - Predefined layouts include: - "DEFAULT" - Default media / non-media screen - "ONSCREEN_PRESETS" - Custom root media screen containing app-defined onscreen presets. - "KEYBOARD_SEARCH" - Custom template containing app-configured on-screen keyboard with active search updating; user also can trigger voice search. - "NAV_FULLSCREEN_MAP" - Custom root template screen containing full screen map with navigation controls. - "NAV_POI_MENU" - Custom template containing app-defined POI options. - "NAV_SEARCH_RESULTS" - Custom template containing a list of app-defined search results - "NAV_POI_INFO" - Custom template containing app-defined POI information (and potentially map data). - - - - - Parent screen of predefined form to display. - Currently only predefined forms are defined. - If not provided, then set to "DEFAULT". - Predefined layouts include: - "DEFAULT" - Default media / non-media screen - "ONSCREEN_PRESETS" - Custom root media screen containing app-defined onscreen presets. - "NAV_FULLSCREEN_MAP" - Custom template containing full screen map with navigation controls. - - - - - - Provides additional human readable info regarding the result. - - On-screen keyboard event. Can be full string or individual keypresses depending on keyboard mode. @@ -4961,6 +5478,11 @@ ID of application that concerns this RPC. + + + An ID for this specific alert to allow cancellation through the `CancelInteraction` RPC. + + @@ -4982,6 +5504,11 @@ ID of application related to this RPC. + + + An ID for this specific alert to allow cancellation through the `CancelInteraction` RPC. + + @@ -6018,6 +6545,9 @@ Parameter used by cloud apps to identify a head unit + + The estimated percentage of remaining oil life of the engine. + @@ -6200,18 +6730,26 @@ - - Sent by system to SDL to get list of URL for specified service type and optionally policy's application id. - - - - - + + + Request from HMI to SDL core to get policy configuration data (i.e. OEM Network Mapping table file version etc.) from Policy Table. + + Name of the Struct where configuration data is located in Policy Table, i.e. module_config etc. + + + Name of the property located within the policyType Struct, i.e. vehicle_year etc. + + + + + Value of requested property from policyType in PT. If no value is found in PT for specified policyType and property, this parameter will be omitted. + + @@ -6231,7 +6769,23 @@ See RemoteControlCapabilities, all available RC modules and buttons shall be returned. + + See SeatLocationCapability, all available seat locations shall be returned. + + + + Sets some properties for the application initiated request. + + Location of the user's seat. Default is driver's seat location if it is not set yet. + + + ID of application related to this RPC. + + + + + @@ -6252,8 +6806,11 @@ The module data to retrieve from the vehicle for that type + + Id of a module, published by System Capability. + - If subscribe is true, the head unit will send OnInteriorVehicleData notifications for the module type + If subscribe is true, the head unit will send OnInteriorVehicleData notifications for the requested module (moduleId and moduleType) @@ -6268,20 +6825,23 @@ - Sender: SDL->HMI. HMI is expected to display a permission prompt to the driver showing the RC module and app details (for example, app's name). The driver is expected to have an ability to grant or deny the permission. The module type that the app requests to control. + + Ids of a module, published by System Capability. + ID of the application that triggers the permission prompt. - - "true" - if the driver grants the permission for controlling to the named app; - "false" - in case the driver denies the permission for controlling to the named app. + + This array has the same size as "moduleIds" in the request; each element corresponding to one moduleId + "true" - if the driver grants the permission for controlling the named app; + "false" - in case the driver denies the permission for controlling the named app. @@ -6318,7 +6878,10 @@ Interface used for interacting with app services as a producer or consumer - Registers a service offered by this app on the module + + Registers a service offered by this app on the module. + Subsequent calls with the same service type will update the manifest for that service. + The manifest of the service that wishes to be published. @@ -6333,6 +6896,18 @@ + + Unpublish an existing service published by the HMI. + + + The ID of the service to be unpublished. + + + + + The response to UnpublishAppService + + This notification includes the data that is updated from the specific service. HMI->SDL if the HMI is a producer, SDL->HMI if the HMI is a consumer @@ -6341,18 +6916,18 @@ This request asks the module for current data related to the specific service. It also includes an option to subscribe to that service for future updates - + The type of service that is to be offered by this app. See AppServiceType for known enum equivalent types. Parameter is a string to allow for new service types to be used by apps on older versions of SDL Core. - + If true, the consumer is requesting to subscribe to all future updates from the service publisher. If false, the consumer doesn't wish to subscribe and should be unsubscribed if it was previously subscribed. - + - This response includes the data that was requested from the specific service + This response includes the data that was requested from the specific service @@ -6360,15 +6935,15 @@ Fully qualified URI based on a predetermined scheme provided by the app service. SDL makes no guarantee that this URI is correct. - + The service ID that the app consumer wishes to send this URI. - + This string is the appID of the app requesting the app service provider take the specific action. This will automatically be set by SDL Core in requests originating from the HMI - + This flag signals the requesting consumer would like this service to become the active primary service of the destination's type. @@ -6413,7 +6988,7 @@ True if the service was set to the default service of this type. False if the app was not to be the default - + @@ -6424,7 +6999,7 @@ The ID of the service to be activated - + diff --git a/src/components/interfaces/MOBILE_API.xml b/src/components/interfaces/MOBILE_API.xml index 9bc321fde82..2a09cc6b57e 100644 --- a/src/components/interfaces/MOBILE_API.xml +++ b/src/components/interfaces/MOBILE_API.xml @@ -1,7 +1,7 @@ - + The request succeeded @@ -138,6 +138,9 @@ The data sent failed to pass CRC check in receiver end + + SDL receives an un-encrypted RPC request that needs protection. + @@ -346,7 +349,29 @@ This mode causes the interaction to immediately display a keyboard entry through the HMI. - + + + + + This window type describes the main window on a display. + + + + + A widget is a small window that the app can create to provide information and soft buttons for quick app control. + + + + + + + The default window is a main window pre-created on behalf of the app. + + + The primary widget of the app. + + + Enumeration that describes current levels of HMI. @@ -543,6 +568,7 @@ + @@ -623,6 +649,26 @@ + + + + + + + + + + + + + + If supported, this toggles between a top-down view and an angled/3D view. If your app supports different, but substantially similar options, then you may implement those. If you don't implement these or similar options, do not subscribe to this button. + + + + + If supported, this toggles between locking the orientation to north or to the vehicle's heading. If your app supports different, but substantially similar options, then you may implement those. If you don't implement these or similar options, do not subscribe to this button. + @@ -732,7 +778,11 @@ The track field of NGN and GEN1.1 MFD displays. This field is only available for media applications; applies to "Show" - + + + The title of the new template that will be displayed; applies to "Show" + + The first line of the alert text field; applies to "Alert" @@ -871,7 +921,11 @@ The optional image of a destination / location - + + + The image field for Alert + + @@ -1074,6 +1128,9 @@ The different global properties. + + Location of the user's seat of setGlobalProperties + The property helpPrompt of setGlobalProperties @@ -1642,9 +1699,6 @@ - - - Enumeration listing possible file types. @@ -1800,7 +1854,8 @@ - References signal "VedsMaxDeltaV_D_Ltchd". Change in velocity in KPH. Additional reserved values: + + References signal "VedsMaxDeltaV_D_Ltchd". Change in velocity in KPH. Additional reserved values: 0x00 No event 0xFE Not supported 0xFF Fault @@ -1832,10 +1887,6 @@ - - - - Enumeration that describes possible result codes of a vehicle data entry request. @@ -1845,7 +1896,7 @@ DTC / DID request successful, however, not all active DTCs or full contents of DID location available - This vehicle data item is not allowed for this app by Ford. + This vehicle data item is not allowed for this app by the OEM/Manufactorer of the connected module. The user has not granted access to this type of vehicle data item at this time. @@ -1909,6 +1960,12 @@ + + How the main menu or submenu is laid out on screen + + + + Struct with the GPS data. @@ -2014,6 +2071,13 @@ + + + True, if GPS lat/long, time, and altitude have been purposefully shifted (requires a proprietary algorithm to unshift). + False, if the GPS data is raw and un-shifted. + If not provided, then value is assumed False. + + @@ -2024,6 +2088,9 @@ Published data result code. + + Type of requested oem specific parameter + @@ -2172,10 +2239,14 @@ + - - Contains information about the display capabilities. + + + + + Contains information about the display capabilities. This struct is deprecated; please see the new SystemCapability DISPLAYS and corresponding struct DisplayCapability The type of the display. See DisplayType @@ -2206,15 +2277,49 @@ The number of on-screen custom presets available (if any); otherwise omitted. - + + Describes a location (origin coordinates and span) of a vehicle component. + + + + + + + + + + + + + + + + Information about a RC module + + uuid of a module. "moduleId + moduleType" uniquely identify a module. + + + Location of a module. + + + Service area of a module. + + + allow multiple users/apps to access the module or not + + + Contains information about a button's capabilities. The name of the button. See ButtonName. + + Information about a RC module, including its id. + The button supports a short press. @@ -2260,6 +2365,12 @@ The button supports referencing a static or dynamic image. + + + The button supports the use of text. + If not included, the default value should be considered true that the button will support text. + + @@ -2269,6 +2380,64 @@ + + + + The specified ID of the window. This ID is either one used when sending the CreateWindow request, + or one of the predefined window ID values from the enum PredefinedWindows. If ommited, value is + assumed to be the main window on the main display. + + + + A set of all fields that support text data. See TextField + + + A set of all fields that support images. See ImageField + + + Provides information about image types supported by the system. + + + A set of all window templates available on the head unit. + + + The number of on-window custom presets available (if any); otherwise omitted. + + + The number of buttons and the capabilities of each on-window button. + + + The number of soft buttons available on-window and the capabilities for each button. + + + An array of available menu layouts. If this parameter is not provided, only the `LIST` layout is assumed to be available + + + + + + + + + + + + + Informs the application how many windows the app is allowed to create per type. + + + + + Contains a list of capabilities of all windows related to the app. + Once the app has registered the capabilities of all windows are provided. + GetSystemCapability still allows requesting window capabilities of all windows. + After registration, only windows with capabilities changed will be included. Following cases will cause only affected windows to be included: + 1. App creates a new window. After the window is created, a system capability notification will be sent related only to the created window. + 2. App sets a new layout to the window. The new layout changes window capabilties. The notification will reflect those changes to the single window. + + + + Availability of build in Nav. True: Available, False: Not Available @@ -2282,6 +2451,15 @@ Availability of remote control feature. True: Available, False: Not Available + + Availability of App Services functionality. True: Available, False: Not Available + + + Availability of displays capability. True: Available, False: Not Available + + + Availability of seat location feature. True: Available, False: Not Available + @@ -2342,7 +2520,7 @@ Trim of the vehicle, e.g. SE - + Enumeration listing possible keyboard layouts. @@ -2376,25 +2554,34 @@ Configuration of on-screen keyboard (if available). The keyboard language. - + Desired keyboard layout. - + Desired keypress mode. If omitted, this value will be set to RESEND_CURRENT_ENTRY. - + Array of keyboard characters to enable. All omitted characters will be greyed out (disabled) on the keyboard. If omitted, the entire keyboard will be enabled. - - - Allows an app to prepopulate the text field with a suggested or completed entry as the user types - - + + + Deprecated, use autoCompleteList instead. + + + + + + + Allows an app to prepopulate the text field with a list of suggested or completed entries as the user types. + If empty, the auto-complete list will be removed from the screen. + + + Various information about connecting device. @@ -2645,6 +2832,14 @@ + + + + + + + + + + Describes the location of a seat. + + + + + + Contains information about the locations of each seat + + + + + + Contains a list of SeatLocation in the vehicle + + + List possible zones of a multi-contour massage seat. @@ -2953,15 +3187,22 @@ - + List possible seats that is a remote controllable seat. + + + Seat control data corresponds to "SEAT" ModuleType. - + + + + + @@ -2991,6 +3232,9 @@ It should not be used to identify a module by mobile application. + + Information about a RC module, including its id. + @@ -3100,16 +3344,21 @@ True if the hd radio is on, false if the radio is off - - number of HD sub-channels if available + + Number of HD sub-channels if available + - + + The list of available HD sub-channel indexes. Empty list means no Hd channel is available. Read-only. + + Current HD sub-channel if available + @@ -3160,17 +3409,22 @@ value false means disabled, value true means enabled. + + True if the climate module is on, false if the climate module is off + Contains information about a radio control module's capabilities. - The short friendly name of the climate control module. It should not be used to identify a module by mobile application. + + Information about a RC module, including its id. + Availability of the control of enable/disable radio. @@ -3201,11 +3455,20 @@ True: Available, False: Not Available, Not present: Not Available. - + Availability of the getting the number of available HD channels. True: Available, False: Not Available, Not present: Not Available. + + + + + + + Availability of the list of available HD sub-channel indexes. + True: Available, False: Not Available, Not present: Not Available. + @@ -3247,11 +3510,13 @@ Contains information about a climate control module's capabilities. - The short friendly name of the climate control module. It should not be used to identify a module by mobile application. + + Information about a RC module, including its id. + Availability of the reading of current temperature. @@ -3346,6 +3611,12 @@ True: Available, False: Not Available, Not present: Not Available. + + + Availability of the control of enable/disable climate control. + True: Available, False: Not Available, Not present: Not Available. + + @@ -3391,6 +3662,9 @@ It should not be used to identify a module by mobile application. + + Information about a RC module, including its id. + Availability of the control of audio source. @@ -3543,6 +3817,9 @@ It should not be used to identify a module by mobile application. + + Information about a RC module, including its id. + An array of available LightCapabilities that are controllable. @@ -3588,6 +3865,9 @@ It should not be used to identify a module by mobile application. + + Information about a RC module, including its id. + Availability of the control of distance unit. @@ -3603,6 +3883,9 @@ 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 + + Id of a module, published by System Capability. + @@ -3830,6 +4113,13 @@ Audiobook: The total number of sections in the playback queue (e.g. the number of chapters in the book) + + + Music: The album art of the current track + Podcast: The podcast or chapter artwork of the current podcast episode + Audiobook: The book or chapter artwork of the current audiobook + + @@ -4141,6 +4431,10 @@ An array of currently available services. If this is an update to the capability the affected services will include an update reason in that item + + Contains information about the locations of each seat + + @@ -4157,21 +4451,21 @@ - The mobile application name, e.g. "Ford Drive Green". - Needs to be unique over all applications. + The mobile application name, e.g. "My SDL App". + Needs to be unique over all applications from the same device. May not be empty. May not start with a new line character. - May not interfere with any name or synonym of previously registered applications and any predefined blacklist of words (global commands) - Needs to be unique over all applications. Applications with the same name will be rejected. + May not interfere with any name or synonym of previously registered applications from the same device and any predefined blacklist of words (global commands) + Additional applications with the same name from the same device will be rejected. Only characters from char set [@TODO: Create char set (character/hex value) for each ACM and refer to] are supported. - TTS string for VR recognition of the mobile application name, e.g. "Ford Drive Green". + TTS string for VR recognition of the mobile application name, e.g. "My S D L App". Meant to overcome any failing on speech engine in properly pronouncing / understanding app name. - Needs to be unique over all applications. + Needs to be unique over all applications from the same device. May not be empty. May not start with a new line character. Only characters from char set [@TODO: Create char set (character/hex value) for each ACM and refer to] are supported. @@ -4189,7 +4483,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) + May not interfere with any app name of previously registered applications from the same device and any predefined blacklist of words (global commands) Only characters from char set [@TODO: Create char set (character/hex value) for each ACM and refer to] are supported. @@ -4289,22 +4583,45 @@ The currently active display language on the module. See "Language" for options. - - - See DisplayCapabilities + + + + See DisplayCapabilities. This parameter is deprecated and replaced by SystemCapability using DISPLAYS. + + + + - - - See ButtonCapabilities + + + + See ButtonCapabilities. This parameter is deprecated and replaced by SystemCapability using DISPLAYS. + + + + - - - If returned, the platform supports on-screen SoftButtons; see SoftButtonCapabilities. + + + + If returned, the platform supports on-screen SoftButtons; see SoftButtonCapabilities. + This parameter is deprecated and replaced by SystemCapability using DISPLAYS. + + + + - - - If returned, the platform supports custom on-screen Presets; see PresetBankCapabilities. + + + + If returned, the platform supports custom on-screen Presets; see PresetBankCapabilities. + This parameter is deprecated and replaced by SystemCapability using DISPLAYS. + + + + + See HmiZoneCapabilities @@ -4340,7 +4657,7 @@ - Specifies the HMI’s capabilities. See HMICapabilities. + Specifies the HMI's capabilities. See HMICapabilities. @@ -4389,9 +4706,113 @@ + + + Create a new window on the display with the specified window type. + + + + A unique ID to identify the window. The value of '0' will always be the default main window on the main display and should not be used in this context as it will already be created for the app. See PredefinedWindows enum. Creating a window with an ID that is already in use will be rejected with `INVALID_ID`. + + + + + + The window name to be used by the HMI. The name of the pre-created default window will match the app name. + Multiple apps can share the same window name except for the default main window. + Creating a window with a name which is already in use by the app will result in `DUPLICATE_NAME`. + + + + + The type of the window to be created. Main window or widget. + + + + + Allows an app to create a widget related to a specific service type. + As an example if a `MEDIA` app becomes active, this app becomes audible and is allowed to play audio. Actions such as skip or play/pause will be + directed to this active media app. In case of widgets, the system can provide a single "media" widget which will act as a placeholder for the active media app. + + It is only allowed to have one window per service type. This means that a media app can only have a single MEDIA widget. Still the app can create widgets omitting this parameter. Those widgets would be available as app specific widgets that are permanently included in the HMI. + + This parameter is related to widgets only. The default main window, which is pre-created during app registration, will be created based on the HMI types specified in the app registration request. + + + + + Optional parameter. Specify whether the content sent to an existing window + should be duplicated to the created window. + If there isn't a window with the ID, the request will be rejected with `INVALID_DATA`. + + + + + + + true if successful; false, if failed. + + + + Provides additional human readable info regarding the result. + + + + See Result + + + + + + + + + + + + + + + + Deletes previously created window of the SDL application. + + + + A unique ID to identify the window. The value of '0' will always be the default main window on the main display and cannot be deleted. + See PredefinedWindows enum. + + + + + + + true if successful; false, if failed. + + + + Provides additional human readable info regarding the result. + + + + See Result + + + + + + + + + + + + + Allows setting global properties. - + + Location of the user's seat. Default is driver's seat location if it is not set yet. + The help prompt. @@ -4435,6 +4856,10 @@ On-screen keyboard configuration (if available). + + + Sets the layout of the main menu screen. If this is sent while a menu is already on-screen, the head unit will change the display to the new layout type. + @@ -4610,6 +5035,10 @@ The image field for AddSubMenu + + + Sets the layout of the submenu screen. + @@ -4669,6 +5098,43 @@ + + Shows the built in menu view + + + + If omitted the HMI opens the app's menu. + If set to a sub-menu ID the HMI opens the corresponding sub-menu previously added using `AddSubMenu`. + + + + + + + + + true if successful; false, if failed + + + + See Result + + + + + + + + + + + + + Provides additional human readable info regarding the result. + + + + creates interaction choice set to be used later by performInteraction @@ -4762,7 +5228,13 @@ See LayoutMode. - + + + + An ID for this specific PerformInteraction to allow cancellation through the `CancelInteraction` RPC. + + + @@ -4895,6 +5367,19 @@ If omitted on supported displays, the displayed alert shall not have any SoftButtons. + + + + Image struct determining whether static or dynamic icon. + If omitted on supported displays, no (or the default if applicable) icon should be displayed. + + + + + + An ID for this specific alert to allow cancellation through the `CancelInteraction` RPC. + + @@ -5024,9 +5509,31 @@ - App defined metadata information. See MetadataStruct. Uses mainField1, mainField2, mainField3, mainField4. + + 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. + If any text field contains no tags or the none tag, the metadata tag for that textfield should be removed. + + + + + + The title of the new template that will be displayed. + How this will be displayed is dependent on the OEM design and implementation of the template. + + + + + This is the unique ID assigned to the window that this RPC is intended. If this param is not included, + it will be assumed that this request is specifically for the main window on the main display. + See PredefinedWindows enum. + + + + + + Used to set an alternate template layout to a window. + @@ -5385,8 +5892,6 @@ Parameter used by cloud apps to identify a head unit - - Emergency Call notification and confirmation data @@ -5402,9 +5907,6 @@ Information related to the MyKey feature - - - @@ -5503,8 +6005,6 @@ Parameter used by cloud apps to identify a head unit - - Emergency Call notification and confirmation data @@ -5520,8 +6020,6 @@ Information related to the MyKey feature - - @@ -5599,8 +6097,6 @@ Parameter used by cloud apps to identify a head unit - - Emergency Call notification and confirmation data @@ -5616,8 +6112,6 @@ Information related to the MyKey feature - - @@ -5715,8 +6209,6 @@ Parameter used by cloud apps to identify a head unit - - Emergency Call notification and confirmation data @@ -5732,8 +6224,6 @@ Information related to the MyKey feature - - @@ -5814,8 +6304,6 @@ Parameter used by cloud apps to identify a head unit - - Emergency Call notification and confirmation data @@ -5831,8 +6319,6 @@ Information related to the MyKey feature - - @@ -5934,8 +6420,6 @@ Parameter used by cloud apps to identify a head unit - - Emergency Call notification and confirmation data @@ -5951,8 +6435,6 @@ Information related to the MyKey feature - - @@ -6033,7 +6515,7 @@ Provides additional human readable info regarding the result. - + 2 byte ECU Header for DTC response (as defined in VHR_Layout_Specification_DTCs.pdf) @@ -6088,7 +6570,7 @@ Provides additional human readable info regarding the result. - + Array of bytes comprising CAN message result. @@ -6110,6 +6592,11 @@ If omitted on supported displays, only the system defined "Close" SoftButton will be displayed. + + + An ID for this specific ScrollableMessage to allow cancellation through the `CancelInteraction` RPC. + + @@ -6164,6 +6651,11 @@ If omitted, the value is set to 10000. + + + An ID for this specific Slider to allow cancellation through the `CancelInteraction` RPC. + + @@ -6366,6 +6858,7 @@ + @@ -6668,12 +7161,11 @@ - - - Used to set an alternate display layout. - If not sent, default screen for given platform will be shown - - + + + + + This RPC is deprecated. Use Show RPC to change layout. Predefined or dynamically created screen layout. @@ -6686,12 +7178,15 @@ - - + + + + + This RPC is deprecated. Use Show RPC to change layout. true, if successful; false, if failed - + See Result @@ -6703,23 +7198,23 @@ - + See DisplayCapabilities - + See ButtonCapabilities - + If returned, the platform supports on-screen SoftButtons; see SoftButtonCapabilities. - + If returned, the platform supports custom on-screen Presets; see PresetBankCapabilities. - + Provides additional human readable info regarding the result. @@ -6772,6 +7267,10 @@ + + + Provides additional human readable info regarding the result. + @@ -6879,6 +7378,9 @@ The module where the button should be pressed + + Id of a module, published by System Capability. + The name of supported RC climate or radio button. @@ -6915,11 +7417,14 @@ In the future, this should be the Identification of a module. + + Id of a module, published by System Capability. + - If subscribe is true, the head unit will register OnInteriorVehicleData notifications for the requested moduleType. - If subscribe is false, the head unit will unregister OnInteriorVehicleData notifications for the requested moduleType. - If subscribe is not included, the subscription status of the app for the requested moduleType will remain unchanged. + If subscribe is true, the head unit will register OnInteriorVehicleData notifications for the requested module (moduleId and moduleType). + If subscribe is false, the head unit will unregister OnInteriorVehicleData notifications for the requested module (moduleId and moduleType). + If subscribe is not included, the subscription status of the app for the requested module (moduleId and moduleType) will remain unchanged. @@ -6928,7 +7433,7 @@ - + See Result @@ -6957,6 +7462,73 @@ + + + + The module type that the app requests to control. + + + Ids of a module of same type, published by System Capability. + + + + + + true if successful; false, if failed + + + See Result + + + + + + + + + + + + + + + + + This array has the same size as "moduleIds" in the request and each element corresponds to one moduleId + If true, SDL grants the permission for the requested module + If false, SDL denies the permission for the requested module. + + + + + + + + + Id of a module, published by System Capability. + + + + + + true if successful; false, if failed + + + See Result + + + + + + + + + + + + + + @@ -6966,7 +7538,7 @@ Used to set the values of one remote control module - + See Result @@ -7082,7 +7654,7 @@ - + See Result @@ -7194,10 +7766,16 @@ - Registers a service offered by this app on the module + + Registers a service offered by this app on the module. + Subsequent calls with the same service type will update the manifest for that service. + - The manifest of the service that wishes to be published. + + The manifest of the service that wishes to be published. + If already published, the updated manifest for this service. + @@ -7229,6 +7807,38 @@ + + Unpublish an existing service published by this application. + + + The ID of the service to be unpublished. + + + + + The response to UnpublishAppService + + true, if successful; false, if failed + + + + See Result + + + + + + + + + + + + + Provides additional human readable info regarding the result. + + + This request asks the module for current data related to the specific service. It also includes an option to subscribe to that service for future updates @@ -7304,6 +7914,77 @@ + + + Close an active interaction on the HMI. + + + + + The ID of the specific interaction you want to dismiss. If not set, the most recent of the RPC type set in functionID will be dismissed. + + + + + + The ID of the type of interaction the developer wants to dismiss. Only values 10, (PerformInteractionID), 12 (AlertID), 25 (ScrollableMessageID), and 26 (SliderID) are permitted. + + + + + + + If no applicable request can be dismissed, the result will be IGNORED. + + + + true if successful; false, if failed + + + + See Result + + + + + + + + + + + + + + + + Provides additional human readable info regarding the result. + + + + + Request from the application to exit the foreground and enter HMI_NONE. + + + + + true if successful; false, if failed + + + + See Result + + + + + + + + + Provides additional human readable info regarding the result. + + + @@ -7325,6 +8006,11 @@ If it is NOT_STREAMABLE, the app must stop streaming video to SDL Core(stop service). + + + This is the unique ID assigned to the window that this RPC is intended. If this param is not included, it will be assumed that this request is specifically for the main window on the main display. See PredefinedWindows enum. + + @@ -7432,8 +8118,6 @@ Parameter used by cloud apps to identify a head unit - - Emergency Call notification and confirmation data @@ -7449,8 +8133,6 @@ Information related to the MyKey feature - - @@ -7475,6 +8157,21 @@ Current State of Driver Distraction + + + If enabled, the lock screen will be able to be dismissed while connected to SDL, allowing users + the ability to interact with the app. Dismissals should include a warning to the user and ensure + that they are not the driver. + + + + + Warning message to be displayed on the lock screen when dismissal is enabled. + This warning should be used to ensure that the user is not the driver of the vehicle, + ex. `Swipe down to dismiss, acknowledging that you are not the driver.`. + This parameter must be present if "lockScreenDismissalEnabled" is set to true. + + @@ -7482,6 +8179,7 @@ Change in permissions for a given set of RPCs + diff --git a/src/components/media_manager/CMakeLists.txt b/src/components/media_manager/CMakeLists.txt index 6a582b4e3be..50c9fce20a2 100644 --- a/src/components/media_manager/CMakeLists.txt +++ b/src/components/media_manager/CMakeLists.txt @@ -65,6 +65,7 @@ set(EXCLUDE_PATHS set(LIBRARIES MOBILE_API ProtocolLibrary + PolicyStatic Utils ) diff --git a/src/components/media_manager/include/media_manager/audio/a2dp_source_player_adapter.h b/src/components/media_manager/include/media_manager/audio/a2dp_source_player_adapter.h index 54d898b7b28..cd594ee8b1e 100644 --- a/src/components/media_manager/include/media_manager/audio/a2dp_source_player_adapter.h +++ b/src/components/media_manager/include/media_manager/audio/a2dp_source_player_adapter.h @@ -34,10 +34,10 @@ #define SRC_COMPONENTS_MEDIA_MANAGER_INCLUDE_MEDIA_MANAGER_AUDIO_A2DP_SOURCE_PLAYER_ADAPTER_H_ #include -#include "protocol/common.h" +#include "connection_handler/connection_handler_impl.h" #include "media_manager/media_adapter_impl.h" +#include "protocol/common.h" #include "utils/threads/thread_delegate.h" -#include "connection_handler/connection_handler_impl.h" namespace protocol_handler { class SessionObserver; diff --git a/src/components/media_manager/include/media_manager/audio/audio_stream_sender_thread.h b/src/components/media_manager/include/media_manager/audio/audio_stream_sender_thread.h index a246e468b70..cb0ea8aa11d 100644 --- a/src/components/media_manager/include/media_manager/audio/audio_stream_sender_thread.h +++ b/src/components/media_manager/include/media_manager/audio/audio_stream_sender_thread.h @@ -34,11 +34,11 @@ #define SRC_COMPONENTS_MEDIA_MANAGER_INCLUDE_MEDIA_MANAGER_AUDIO_AUDIO_STREAM_SENDER_THREAD_H_ #include -#include "utils/macro.h" -#include "utils/threads/thread_delegate.h" +#include "smart_objects/smart_object.h" #include "utils/conditional_variable.h" #include "utils/lock.h" -#include "smart_objects/smart_object.h" +#include "utils/macro.h" +#include "utils/threads/thread_delegate.h" namespace application_manager { class ApplicationManager; diff --git a/src/components/media_manager/include/media_manager/audio/from_mic_recorder_listener.h b/src/components/media_manager/include/media_manager/audio/from_mic_recorder_listener.h index c615195f944..643657951b0 100644 --- a/src/components/media_manager/include/media_manager/audio/from_mic_recorder_listener.h +++ b/src/components/media_manager/include/media_manager/audio/from_mic_recorder_listener.h @@ -35,6 +35,7 @@ #include #include "media_manager/media_adapter_listener.h" +#include "utils/macro.h" namespace application_manager { class ApplicationManager; diff --git a/src/components/media_manager/include/media_manager/audio/from_mic_to_file_recorder_thread.h b/src/components/media_manager/include/media_manager/audio/from_mic_to_file_recorder_thread.h index ded709b1fad..e6b54cc4874 100644 --- a/src/components/media_manager/include/media_manager/audio/from_mic_to_file_recorder_thread.h +++ b/src/components/media_manager/include/media_manager/audio/from_mic_to_file_recorder_thread.h @@ -33,8 +33,8 @@ #ifndef SRC_COMPONENTS_MEDIA_MANAGER_INCLUDE_MEDIA_MANAGER_AUDIO_FROM_MIC_TO_FILE_RECORDER_THREAD_H_ #define SRC_COMPONENTS_MEDIA_MANAGER_INCLUDE_MEDIA_MANAGER_AUDIO_FROM_MIC_TO_FILE_RECORDER_THREAD_H_ -#include #include +#include #include #include "utils/lock.h" diff --git a/src/components/media_manager/include/media_manager/file_streamer_adapter.h b/src/components/media_manager/include/media_manager/file_streamer_adapter.h index c4c91a98d83..a11b05b2ee7 100644 --- a/src/components/media_manager/include/media_manager/file_streamer_adapter.h +++ b/src/components/media_manager/include/media_manager/file_streamer_adapter.h @@ -33,8 +33,8 @@ #ifndef SRC_COMPONENTS_MEDIA_MANAGER_INCLUDE_MEDIA_MANAGER_FILE_STREAMER_ADAPTER_H_ #define SRC_COMPONENTS_MEDIA_MANAGER_INCLUDE_MEDIA_MANAGER_FILE_STREAMER_ADAPTER_H_ -#include #include +#include #include "media_manager/streamer_adapter.h" #include "utils/threads/thread_delegate.h" diff --git a/src/components/media_manager/include/media_manager/media_manager_impl.h b/src/components/media_manager/include/media_manager/media_manager_impl.h index 749356e6566..408fa126552 100644 --- a/src/components/media_manager/include/media_manager/media_manager_impl.h +++ b/src/components/media_manager/include/media_manager/media_manager_impl.h @@ -33,13 +33,14 @@ #ifndef SRC_COMPONENTS_MEDIA_MANAGER_INCLUDE_MEDIA_MANAGER_MEDIA_MANAGER_IMPL_H_ #define SRC_COMPONENTS_MEDIA_MANAGER_INCLUDE_MEDIA_MANAGER_MEDIA_MANAGER_IMPL_H_ -#include +#include #include -#include "protocol_handler/protocol_observer.h" -#include "protocol_handler/protocol_handler.h" -#include "media_manager/media_manager.h" +#include #include "media_manager/media_adapter_impl.h" #include "media_manager/media_adapter_listener.h" +#include "media_manager/media_manager.h" +#include "protocol_handler/protocol_handler.h" +#include "protocol_handler/protocol_observer.h" namespace application_manager { class ApplicationManager; @@ -81,6 +82,8 @@ class MediaManagerImpl : public MediaManager, virtual const MediaManagerSettings& settings() const OVERRIDE; + virtual uint32_t DataSizeToMilliseconds(uint64_t data_size) const OVERRIDE; + #ifdef BUILD_TESTS void set_mock_a2dp_player(MediaAdapter* media_adapter); void set_mock_mic_listener(MediaListenerPtr media_listener); @@ -106,6 +109,12 @@ class MediaManagerImpl : public MediaManager, std::map streamer_; std::map streamer_listener_; + uint32_t bits_per_sample_; + uint32_t sampling_rate_; + uint64_t stream_data_size_; + std::chrono::time_point + socket_audio_stream_start_time_; + application_manager::ApplicationManager& application_manager_; private: diff --git a/src/components/media_manager/include/media_manager/streamer_adapter.h b/src/components/media_manager/include/media_manager/streamer_adapter.h index 56bf941f8ec..a35e680b6a6 100644 --- a/src/components/media_manager/include/media_manager/streamer_adapter.h +++ b/src/components/media_manager/include/media_manager/streamer_adapter.h @@ -33,12 +33,12 @@ #ifndef SRC_COMPONENTS_MEDIA_MANAGER_INCLUDE_MEDIA_MANAGER_STREAMER_ADAPTER_H_ #define SRC_COMPONENTS_MEDIA_MANAGER_INCLUDE_MEDIA_MANAGER_STREAMER_ADAPTER_H_ +#include #include "media_manager/media_adapter_impl.h" +#include "protocol/raw_message.h" #include "utils/message_queue.h" #include "utils/threads/thread.h" #include "utils/threads/thread_delegate.h" -#include -#include "protocol/raw_message.h" namespace media_manager { @@ -60,6 +60,7 @@ class StreamerAdapter : public MediaAdapterImpl { virtual void SendData(int32_t application_key, const ::protocol_handler::RawMessagePtr msg); virtual bool is_app_performing_activity(int32_t application_key) const; + virtual size_t GetMsgQueueSize(); protected: // TODO(AN): APPLINK-15203 Use MessageLoopThread diff --git a/src/components/media_manager/include/media_manager/video/socket_video_streamer_adapter.h b/src/components/media_manager/include/media_manager/video/socket_video_streamer_adapter.h index ad5739bd5f4..d3d5111a60f 100644 --- a/src/components/media_manager/include/media_manager/video/socket_video_streamer_adapter.h +++ b/src/components/media_manager/include/media_manager/video/socket_video_streamer_adapter.h @@ -33,8 +33,8 @@ #ifndef SRC_COMPONENTS_MEDIA_MANAGER_INCLUDE_MEDIA_MANAGER_VIDEO_SOCKET_VIDEO_STREAMER_ADAPTER_H_ #define SRC_COMPONENTS_MEDIA_MANAGER_INCLUDE_MEDIA_MANAGER_VIDEO_SOCKET_VIDEO_STREAMER_ADAPTER_H_ -#include #include +#include #include "media_manager/socket_streamer_adapter.h" diff --git a/src/components/media_manager/src/audio/a2dp_source_player_adapter.cc b/src/components/media_manager/src/audio/a2dp_source_player_adapter.cc index 91e3c5465dd..581997f6100 100644 --- a/src/components/media_manager/src/audio/a2dp_source_player_adapter.cc +++ b/src/components/media_manager/src/audio/a2dp_source_player_adapter.cc @@ -29,17 +29,17 @@ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ +#include "media_manager/audio/a2dp_source_player_adapter.h" #include -#include #include +#include #include #include -#include "utils/threads/thread.h" -#include "media_manager/audio/a2dp_source_player_adapter.h" -#include "utils/lock.h" -#include "utils/logger.h" #include "connection_handler/connection_handler_impl.h" #include "protocol_handler/session_observer.h" +#include "utils/lock.h" +#include "utils/logger.h" +#include "utils/threads/thread.h" namespace media_manager { @@ -60,7 +60,7 @@ class A2DPSourcePlayerAdapter::A2DPSourcePlayerThread // The Sample format to use static const pa_sample_spec sSampleFormat_; - pa_simple* s_in, *s_out; + pa_simple *s_in, *s_out; std::string device_; bool should_be_stopped_; sync_primitives::Lock should_be_stopped_lock_; @@ -85,9 +85,9 @@ A2DPSourcePlayerAdapter::~A2DPSourcePlayerAdapter() { } void A2DPSourcePlayerAdapter::StartActivity(int32_t application_key) { - LOG4CXX_INFO(logger_, - "Starting a2dp playing music for " << application_key - << " application."); + LOG4CXX_INFO( + logger_, + "Starting a2dp playing music for " << application_key << " application."); if (application_key != current_application_) { current_application_ = application_key; @@ -110,9 +110,9 @@ void A2DPSourcePlayerAdapter::StartActivity(int32_t application_key) { } void A2DPSourcePlayerAdapter::StopActivity(int32_t application_key) { - LOG4CXX_INFO(logger_, - "Stopping 2dp playing for " << application_key - << " application."); + LOG4CXX_INFO( + logger_, + "Stopping 2dp playing for " << application_key << " application."); if (application_key != current_application_) { return; } diff --git a/src/components/media_manager/src/audio/audio_stream_sender_thread.cc b/src/components/media_manager/src/audio/audio_stream_sender_thread.cc index 23181e7431a..078841f2a49 100644 --- a/src/components/media_manager/src/audio/audio_stream_sender_thread.cc +++ b/src/components/media_manager/src/audio/audio_stream_sender_thread.cc @@ -35,20 +35,20 @@ #include #endif -#include #include -#include "application_manager/application_manager.h" +#include #include "application_manager/application_impl.h" -#include "application_manager/rpc_service.h" +#include "application_manager/application_manager.h" #include "application_manager/commands/command.h" -#include "smart_objects/smart_object.h" +#include "application_manager/message.h" +#include "application_manager/rpc_service.h" +#include "application_manager/smart_object_keys.h" #include "interfaces/MOBILE_API.h" +#include "media_manager/audio/audio_stream_sender_thread.h" +#include "media_manager/media_manager_settings.h" +#include "smart_objects/smart_object.h" #include "utils/file_system.h" #include "utils/logger.h" -#include "media_manager/media_manager_settings.h" -#include "media_manager/audio/audio_stream_sender_thread.h" -#include "application_manager/smart_object_keys.h" -#include "application_manager/message.h" namespace media_manager { using sync_primitives::AutoLock; diff --git a/src/components/media_manager/src/audio/from_mic_recorder_adapter.cc b/src/components/media_manager/src/audio/from_mic_recorder_adapter.cc index d9735fcbbce..e55efed4ced 100644 --- a/src/components/media_manager/src/audio/from_mic_recorder_adapter.cc +++ b/src/components/media_manager/src/audio/from_mic_recorder_adapter.cc @@ -30,11 +30,11 @@ * POSSIBILITY OF SUCH DAMAGE. */ +#include "media_manager/audio/from_mic_recorder_adapter.h" #include -#include "utils/threads/thread.h" -#include "utils/logger.h" #include "media_manager/audio/from_mic_to_file_recorder_thread.h" -#include "media_manager/audio/from_mic_recorder_adapter.h" +#include "utils/logger.h" +#include "utils/threads/thread.h" namespace media_manager { diff --git a/src/components/media_manager/src/audio/from_mic_recorder_listener.cc b/src/components/media_manager/src/audio/from_mic_recorder_listener.cc index 647db1e1a30..721229b2505 100644 --- a/src/components/media_manager/src/audio/from_mic_recorder_listener.cc +++ b/src/components/media_manager/src/audio/from_mic_recorder_listener.cc @@ -30,10 +30,10 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include "utils/threads/thread.h" -#include "utils/logger.h" #include "media_manager/audio/from_mic_recorder_listener.h" #include "media_manager/audio/audio_stream_sender_thread.h" +#include "utils/logger.h" +#include "utils/threads/thread.h" namespace media_manager { @@ -63,9 +63,9 @@ void FromMicRecorderListener::OnErrorReceived(int32_t application_key, const DataForListener& data) {} void FromMicRecorderListener::OnActivityStarted(int32_t application_key) { - LOG4CXX_INFO(logger_, - "FromMicRecorderListener::OnActivityStarted " - << application_key); + LOG4CXX_INFO( + logger_, + "FromMicRecorderListener::OnActivityStarted " << application_key); if (application_key == current_application_) { return; } diff --git a/src/components/media_manager/src/audio/from_mic_to_file_recorder_thread.cc b/src/components/media_manager/src/audio/from_mic_to_file_recorder_thread.cc index 5c12614662b..a34bdd3f09c 100644 --- a/src/components/media_manager/src/audio/from_mic_to_file_recorder_thread.cc +++ b/src/components/media_manager/src/audio/from_mic_to_file_recorder_thread.cc @@ -84,7 +84,7 @@ void FromMicToFileRecorderThread::set_record_duration(int32_t duration) { void FromMicToFileRecorderThread::initArgs() { LOG4CXX_AUTO_TRACE(logger_); - argv_ = new gchar* [argc_]; + argv_ = new gchar*[argc_]; argv_[0] = new gchar[14]; argv_[1] = new gchar[3]; @@ -122,7 +122,7 @@ void FromMicToFileRecorderThread::threadMain() { initArgs(); GstElement* pipeline; - GstElement* alsasrc, *audioconvert, *capsfilter, *wavenc, *filesink; + GstElement *alsasrc, *audioconvert, *capsfilter, *wavenc, *filesink; GstCaps* audiocaps; GstBus* bus; @@ -155,7 +155,7 @@ void FromMicToFileRecorderThread::threadMain() { {NULL}}; // g_option_context_parse() modifies params, so keep argc_ and argv_ int32_t argc = argc_; - gchar** argv = new gchar* [argc]; + gchar** argv = new gchar*[argc]; for (int32_t i = 0; i < argc; i++) { argv[i] = argv_[i]; } diff --git a/src/components/media_manager/src/audio/socket_audio_streamer_adapter.cc b/src/components/media_manager/src/audio/socket_audio_streamer_adapter.cc index 429fab01b35..373d92cdde1 100644 --- a/src/components/media_manager/src/audio/socket_audio_streamer_adapter.cc +++ b/src/components/media_manager/src/audio/socket_audio_streamer_adapter.cc @@ -30,8 +30,8 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include #include "media_manager/audio/socket_audio_streamer_adapter.h" +#include namespace { const std::string kHeader = diff --git a/src/components/media_manager/src/file_streamer_adapter.cc b/src/components/media_manager/src/file_streamer_adapter.cc index 3418f7d9634..7761e136012 100644 --- a/src/components/media_manager/src/file_streamer_adapter.cc +++ b/src/components/media_manager/src/file_streamer_adapter.cc @@ -30,9 +30,9 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include "utils/logger.h" -#include "utils/file_system.h" #include "media_manager/file_streamer_adapter.h" +#include "utils/file_system.h" +#include "utils/logger.h" namespace media_manager { diff --git a/src/components/media_manager/src/media_manager_impl.cc b/src/components/media_manager/src/media_manager_impl.cc index ec88e910d3f..44f96012424 100644 --- a/src/components/media_manager/src/media_manager_impl.cc +++ b/src/components/media_manager/src/media_manager_impl.cc @@ -31,27 +31,28 @@ */ #include "media_manager/media_manager_impl.h" -#include "media_manager/audio/from_mic_recorder_listener.h" -#include "media_manager/streamer_listener.h" -#include "application_manager/message_helper.h" #include "application_manager/application.h" -#include "application_manager/application_manager.h" #include "application_manager/application_impl.h" +#include "application_manager/application_manager.h" +#include "application_manager/message_helper.h" +#include "application_manager/smart_object_keys.h" +#include "media_manager/audio/from_mic_recorder_listener.h" +#include "media_manager/streamer_listener.h" #include "protocol_handler/protocol_handler.h" #include "utils/file_system.h" -#include "utils/logger.h" #include "utils/helpers.h" +#include "utils/logger.h" #if defined(EXTENDED_MEDIA_MODE) #include "media_manager/audio/a2dp_source_player_adapter.h" #include "media_manager/audio/from_mic_recorder_adapter.h" #endif -#include "media_manager/video/socket_video_streamer_adapter.h" -#include "media_manager/audio/socket_audio_streamer_adapter.h" -#include "media_manager/video/pipe_video_streamer_adapter.h" -#include "media_manager/audio/pipe_audio_streamer_adapter.h" -#include "media_manager/video/file_video_streamer_adapter.h" #include "media_manager/audio/file_audio_streamer_adapter.h" +#include "media_manager/audio/pipe_audio_streamer_adapter.h" +#include "media_manager/audio/socket_audio_streamer_adapter.h" #include "media_manager/media_manager_settings.h" +#include "media_manager/video/file_video_streamer_adapter.h" +#include "media_manager/video/pipe_video_streamer_adapter.h" +#include "media_manager/video/socket_video_streamer_adapter.h" namespace media_manager { @@ -64,6 +65,9 @@ MediaManagerImpl::MediaManagerImpl( , protocol_handler_(NULL) , a2dp_player_(NULL) , from_mic_recorder_(NULL) + , bits_per_sample_(16) + , sampling_rate_(16000) + , stream_data_size_(0ull) , application_manager_(application_manager) { Init(); } @@ -160,6 +164,23 @@ void MediaManagerImpl::Init() { streamer_[ServiceType::kAudio]->AddListener( streamer_listener_[ServiceType::kAudio]); } + + if (application_manager_.hmi_capabilities().pcm_stream_capabilities()) { + const auto pcm_caps = + application_manager_.hmi_capabilities().pcm_stream_capabilities(); + + if (pcm_caps->keyExists(application_manager::strings::bits_per_sample)) { + bits_per_sample_ = + pcm_caps->getElement(application_manager::strings::bits_per_sample) + .asUInt(); + } + + if (pcm_caps->keyExists(application_manager::strings::sampling_rate)) { + sampling_rate_ = + pcm_caps->getElement(application_manager::strings::sampling_rate) + .asUInt(); + } + } } void MediaManagerImpl::PlayA2DPSource(int32_t application_key) { @@ -220,9 +241,9 @@ void MediaManagerImpl::StartMicrophoneRecording(int32_t application_key, std::vector buf; if (file_system::ReadBinaryFile(record_file_source, buf)) { if (file_system::Write(file_path, buf)) { - LOG4CXX_INFO(logger_, - "File " << record_file_source << " copied to " - << output_file); + LOG4CXX_INFO( + logger_, + "File " << record_file_source << " copied to " << output_file); } else { LOG4CXX_WARN(logger_, "Could not write to file " << output_file); } @@ -263,6 +284,8 @@ void MediaManagerImpl::StopStreaming( int32_t application_key, protocol_handler::ServiceType service_type) { LOG4CXX_AUTO_TRACE(logger_); + stream_data_size_ = 0ull; + if (streamer_[service_type]) { streamer_[service_type]->StopActivity(application_key); } @@ -298,7 +321,25 @@ void MediaManagerImpl::OnMessageReceived( ApplicationSharedPtr app = application_manager_.application(streaming_app_id); if (app) { - app->WakeUpStreaming(service_type); + if (ServiceType::kAudio == service_type && + "socket" == settings().audio_server_type()) { + if (stream_data_size_ == 0) { + socket_audio_stream_start_time_ = std::chrono::system_clock::now(); + } + + stream_data_size_ += message->data_size(); + uint32_t ms_for_all_data = DataSizeToMilliseconds(stream_data_size_); + uint32_t ms_since_stream_start = + std::chrono::duration_cast( + std::chrono::system_clock::now() - + socket_audio_stream_start_time_) + .count(); + uint32_t ms_stream_remaining = ms_for_all_data - ms_since_stream_start; + + app->WakeUpStreaming(service_type, ms_stream_remaining); + } else { + app->WakeUpStreaming(service_type); + } streamer_[service_type]->SendData(streaming_app_id, message); } } @@ -311,10 +352,46 @@ void MediaManagerImpl::FramesProcessed(int32_t application_key, if (protocol_handler_) { protocol_handler_->SendFramesNumber(application_key, frame_number); } + + application_manager::ApplicationSharedPtr app = + application_manager_.application(application_key); + + if (app) { + auto audio_stream = std::dynamic_pointer_cast( + streamer_[protocol_handler::ServiceType::kAudio]); + auto video_stream = std::dynamic_pointer_cast( + streamer_[protocol_handler::ServiceType::kMobileNav]); + + if (audio_stream.use_count() != 0 && + "pipe" == settings().audio_server_type()) { + size_t audio_queue_size = audio_stream->GetMsgQueueSize(); + LOG4CXX_DEBUG(logger_, + "# Messages in audio queue = " << audio_queue_size); + if (audio_queue_size > 0) { + app->WakeUpStreaming(protocol_handler::ServiceType::kAudio); + } + } + + if (video_stream.use_count() != 0 && + "pipe" == settings().video_server_type()) { + size_t video_queue_size = video_stream->GetMsgQueueSize(); + LOG4CXX_DEBUG(logger_, + "# Messages in video queue = " << video_queue_size); + if (video_queue_size > 0) { + app->WakeUpStreaming(protocol_handler::ServiceType::kMobileNav); + } + } + } } const MediaManagerSettings& MediaManagerImpl::settings() const { return settings_; } +uint32_t MediaManagerImpl::DataSizeToMilliseconds(uint64_t data_size) const { + constexpr uint16_t latency_compensation = 500; + return 1000 * data_size / (sampling_rate_ * bits_per_sample_ / 8) + + latency_compensation; +} + } // namespace media_manager diff --git a/src/components/media_manager/src/pipe_streamer_adapter.cc b/src/components/media_manager/src/pipe_streamer_adapter.cc index 8bf14a546e0..bda106721fa 100644 --- a/src/components/media_manager/src/pipe_streamer_adapter.cc +++ b/src/components/media_manager/src/pipe_streamer_adapter.cc @@ -30,13 +30,13 @@ * POSSIBILITY OF SUCH DAMAGE. */ +#include "media_manager/pipe_streamer_adapter.h" #include #include #include #include -#include "utils/logger.h" #include "utils/file_system.h" -#include "media_manager/pipe_streamer_adapter.h" +#include "utils/logger.h" namespace media_manager { @@ -82,15 +82,15 @@ PipeStreamerAdapter::PipeStreamer::~PipeStreamer() { bool PipeStreamerAdapter::PipeStreamer::Connect() { LOG4CXX_AUTO_TRACE(logger_); - pipe_fd_ = open(named_pipe_path_.c_str(), O_RDWR, 0); + pipe_fd_ = open(named_pipe_path_.c_str(), O_RDWR | O_NONBLOCK, 0); if (-1 == pipe_fd_) { LOG4CXX_ERROR(logger_, "Cannot open pipe for writing " << named_pipe_path_); return false; } - LOG4CXX_INFO(logger_, - "Pipe " << named_pipe_path_ - << " was successfuly opened for writing"); + LOG4CXX_INFO( + logger_, + "Pipe " << named_pipe_path_ << " was successfuly opened for writing"); return true; } @@ -106,16 +106,51 @@ void PipeStreamerAdapter::PipeStreamer::Disconnect() { bool PipeStreamerAdapter::PipeStreamer::Send( protocol_handler::RawMessagePtr msg) { LOG4CXX_AUTO_TRACE(logger_); - ssize_t ret = write(pipe_fd_, msg->data(), msg->data_size()); - if (-1 == ret) { - LOG4CXX_ERROR(logger_, "Failed writing data to pipe " << named_pipe_path_); - return false; - } - - if (static_cast(ret) != msg->data_size()) { - LOG4CXX_WARN(logger_, - "Couldn't write all the data to pipe " << named_pipe_path_); - } + fd_set wfds; + FD_ZERO(&wfds); + FD_SET(pipe_fd_, &wfds); + struct timeval tv; + tv.tv_sec = 10; + tv.tv_usec = 0; + ssize_t write_ret = 0; + bool data_remaining = false; + do { + int select_ret = select(pipe_fd_ + 1, NULL, &wfds, NULL, &tv); + // Most likely pipe closed, fail stream + if (select_ret == -1) { + LOG4CXX_ERROR(logger_, + "Failed writing data to pipe " + << named_pipe_path_ << ". Errno: " << strerror(errno)); + return false; + // Select success, attempt to write + } else if (select_ret) { + ssize_t temp_ret = write( + pipe_fd_, msg->data() + write_ret, msg->data_size() - write_ret); + if (-1 == temp_ret) { + LOG4CXX_ERROR(logger_, + "Failed writing data to pipe " + << named_pipe_path_ + << ". Errno: " << strerror(errno)); + return false; + } + write_ret += temp_ret; + // Select timed out, fail stream. + } else { + LOG4CXX_ERROR(logger_, + "Failed writing data to pipe " << named_pipe_path_ + << ". Error: TIMEOUT"); + return false; + } + // Check that all data was written to the pipe. + data_remaining = static_cast(write_ret) != msg->data_size(); + if (data_remaining) { + LOG4CXX_WARN(logger_, + "Couldn't write all the data to pipe " + << named_pipe_path_ << ". " + << msg->data_size() - write_ret << " bytes remaining"); + } + // Loop to send remaining data if there is any. + } while (data_remaining); LOG4CXX_INFO(logger_, "Streamer::sent " << msg->data_size()); return true; diff --git a/src/components/media_manager/src/socket_streamer_adapter.cc b/src/components/media_manager/src/socket_streamer_adapter.cc index 60b01c901be..624e388a0c9 100644 --- a/src/components/media_manager/src/socket_streamer_adapter.cc +++ b/src/components/media_manager/src/socket_streamer_adapter.cc @@ -30,15 +30,15 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include -#include -#include -#include +#include "media_manager/socket_streamer_adapter.h" #include #include +#include +#include +#include +#include #include #include "utils/logger.h" -#include "media_manager/socket_streamer_adapter.h" namespace media_manager { diff --git a/src/components/media_manager/src/streamer_adapter.cc b/src/components/media_manager/src/streamer_adapter.cc index 37cb1426dc8..3ef12e3ed54 100644 --- a/src/components/media_manager/src/streamer_adapter.cc +++ b/src/components/media_manager/src/streamer_adapter.cc @@ -74,6 +74,10 @@ void StreamerAdapter::StartActivity(int32_t application_key) { current_application_ = application_key; } +size_t StreamerAdapter::GetMsgQueueSize() { + return messages_.size(); +} + void StreamerAdapter::StopActivity(int32_t application_key) { LOG4CXX_AUTO_TRACE(logger); if (!is_app_performing_activity(application_key)) { diff --git a/src/components/media_manager/src/video/video_stream_to_file_adapter.cc b/src/components/media_manager/src/video/video_stream_to_file_adapter.cc index f41954b1178..d907211d164 100644 --- a/src/components/media_manager/src/video/video_stream_to_file_adapter.cc +++ b/src/components/media_manager/src/video/video_stream_to_file_adapter.cc @@ -30,10 +30,10 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include "utils/logger.h" -#include "utils/file_system.h" -#include "config_profile/profile.h" #include "media_manager/video/video_stream_to_file_adapter.h" +#include "config_profile/profile.h" +#include "utils/file_system.h" +#include "utils/logger.h" namespace media_manager { diff --git a/src/components/media_manager/test/CMakeLists.txt b/src/components/media_manager/test/CMakeLists.txt index f5d596f681c..265a62a0d87 100644 --- a/src/components/media_manager/test/CMakeLists.txt +++ b/src/components/media_manager/test/CMakeLists.txt @@ -58,7 +58,7 @@ set(LIBRARIES connectionHandler encryption Resumption - Policy + PolicyStatic ${SecurityManagerLibrary} ) diff --git a/src/components/media_manager/test/include/media_manager/mock_media_adapter.h b/src/components/media_manager/test/include/media_manager/mock_media_adapter.h index 908b371b26f..78d44695e53 100644 --- a/src/components/media_manager/test/include/media_manager/mock_media_adapter.h +++ b/src/components/media_manager/test/include/media_manager/mock_media_adapter.h @@ -34,8 +34,8 @@ #define SRC_COMPONENTS_MEDIA_MANAGER_TEST_INCLUDE_MEDIA_MANAGER_MOCK_MEDIA_ADAPTER_H_ #include "gmock/gmock.h" -#include "media_manager/media_manager.h" #include "media_manager/media_adapter.h" +#include "media_manager/media_manager.h" namespace test { namespace components { diff --git a/src/components/media_manager/test/media_manager_impl_test.cc b/src/components/media_manager/test/media_manager_impl_test.cc index c77c984a756..ff35ac7dbb7 100644 --- a/src/components/media_manager/test/media_manager_impl_test.cc +++ b/src/components/media_manager/test/media_manager_impl_test.cc @@ -30,20 +30,21 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include "gmock/gmock.h" #include "media_manager/media_manager_impl.h" -#include "media_manager/mock_media_adapter.h" -#include "media_manager/mock_media_adapter_impl.h" -#include "media_manager/mock_media_adapter_listener.h" -#include "media_manager/mock_media_manager_settings.h" #include "application_manager/event_engine/event_dispatcher.h" #include "application_manager/message.h" #include "application_manager/mock_application.h" #include "application_manager/mock_application_manager.h" +#include "application_manager/mock_hmi_capabilities.h" #include "application_manager/resumption/resume_ctrl.h" #include "application_manager/state_controller.h" -#include "protocol_handler/mock_protocol_handler.h" +#include "gmock/gmock.h" +#include "media_manager/mock_media_adapter.h" +#include "media_manager/mock_media_adapter_impl.h" +#include "media_manager/mock_media_adapter_listener.h" +#include "media_manager/mock_media_manager_settings.h" #include "protocol/common.h" +#include "protocol_handler/mock_protocol_handler.h" #include "utils/file_system.h" #include "utils/scope_guard.h" @@ -58,13 +59,13 @@ using ::testing::_; using ::testing::Return; using ::testing::ReturnRef; -using ::utils::ScopeGuard; -using ::utils::MakeGuard; -using ::testing::NiceMock; -using ::protocol_handler::ServiceType; -using ::protocol_handler::RawMessagePtr; using application_manager::ApplicationSharedPtr; using application_manager::BinaryData; +using ::protocol_handler::RawMessagePtr; +using ::protocol_handler::ServiceType; +using ::testing::NiceMock; +using ::utils::MakeGuard; +using ::utils::ScopeGuard; namespace { const uint16_t kVideoStreamingPort = 8901u; @@ -109,6 +110,10 @@ class MediaManagerImplTest : public ::testing::Test { .WillByDefault(ReturnRef(kDefaultValue)); ON_CALL(mock_media_manager_settings_, audio_server_type()) .WillByDefault(ReturnRef(kDefaultValue)); + ON_CALL(mock_hmi_capabilities_, pcm_stream_capabilities()) + .WillByDefault(Return(nullptr)); + ON_CALL(app_mngr_, hmi_capabilities()) + .WillByDefault(ReturnRef(mock_hmi_capabilities_)); mock_app_ = std::make_shared(); media_manager_impl_.reset( new MediaManagerImpl(app_mngr_, mock_media_manager_settings_)); @@ -176,7 +181,7 @@ class MediaManagerImplTest : public ::testing::Test { .WillOnce(Return(true)); EXPECT_CALL(app_mngr_, application(kConnectionKey)) .WillOnce(Return(mock_app_)); - EXPECT_CALL(*mock_app_, WakeUpStreaming(service_type)); + EXPECT_CALL(*mock_app_, WakeUpStreaming(service_type, 0ull)); MockMediaAdapterImplPtr mock_media_streamer = std::make_shared(); media_manager_impl_->set_mock_streamer(service_type, mock_media_streamer); @@ -194,6 +199,7 @@ class MediaManagerImplTest : public ::testing::Test { kProtocolVersion, data_sending, data_sending_size, + false, serviceType)); media_manager_impl_->OnMessageReceived(raw_message_ptr); media_manager_impl_->OnMobileMessageSent(raw_message_ptr); @@ -205,6 +211,7 @@ class MediaManagerImplTest : public ::testing::Test { const ::testing::NiceMock mock_media_manager_settings_; std::shared_ptr media_manager_impl_; + application_manager_test::MockHMICapabilities mock_hmi_capabilities_; }; TEST_F(MediaManagerImplTest, @@ -403,6 +410,8 @@ TEST_F(MediaManagerImplTest, const int32_t frame_number = 10; EXPECT_CALL(mock_protocol_handler, SendFramesNumber(kApplicationKey, frame_number)); + EXPECT_CALL(app_mngr_, application(kConnectionKey)) + .WillOnce(Return(mock_app_)); media_manager_impl_->FramesProcessed(kApplicationKey, frame_number); } diff --git a/src/components/policy/policy_external/CMakeLists.txt b/src/components/policy/policy_external/CMakeLists.txt index bd052912451..361c48a598b 100644 --- a/src/components/policy/policy_external/CMakeLists.txt +++ b/src/components/policy/policy_external/CMakeLists.txt @@ -28,22 +28,26 @@ # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # POSSIBILITY OF SUCH DAMAGE. +include(${CMAKE_SOURCE_DIR}/tools/cmake/helpers/generators.cmake) + # --- Policy -set(target Policy) set(install_destination bin) set(copy_destination ${CMAKE_BINARY_DIR}/src/appMain) -set(library_name ${CMAKE_SHARED_LIBRARY_PREFIX}${target}${CMAKE_SHARED_LIBRARY_SUFFIX}) +set(library_name ${CMAKE_SHARED_LIBRARY_PREFIX}Policy${CMAKE_SHARED_LIBRARY_SUFFIX}) set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/") include_directories ( - include - ${COMPONENTS_DIR}/rpc_base/include + ${POLICY_PATH}/include/ + ${COMPONENTS_DIR}/ ${COMPONENTS_DIR}/utils/include/ ${COMPONENTS_DIR}/config_profile/include + ${COMPONENTS_DIR}/smart_objects/include/ + ${COMPONENTS_DIR}/rpc_base/include + ${CMAKE_BINARY_DIR}/src/components/ ${POLICY_GLOBAL_INCLUDE_PATH}/ - ${LOG4CXX_INCLUDE_DIRECTORY} ${BOOST_INCLUDE_DIR} + ${LOG4CXX_INCLUDE_DIRECTORY} ${JSONCPP_INCLUDE_DIRECTORY} ) @@ -60,12 +64,54 @@ set(SOURCES ${COMPONENTS_DIR}/rpc_base/src/rpc_base/rpc_base.cc ) +set(GENERATED_MOBILE_POLICY_TYPES_CPP + "${CMAKE_CURRENT_BINARY_DIR}/generated_MOBILE_API_policy_types.cc" + "${CMAKE_CURRENT_BINARY_DIR}/generated_MOBILE_API_enum_schema_factory.cc") + +set(GENERATED_MOBILE_POLICY_TYPES_HPP + "${CMAKE_CURRENT_BINARY_DIR}/generated_MOBILE_API_policy_types.h") + +set(GENERATED_MOBILE_POLICY_TYPES + ${GENERATED_MOBILE_POLICY_TYPES_HPP} + ${GENERATED_MOBILE_POLICY_TYPES_CPP}) + +generate_policy_types("${GENERATED_MOBILE_POLICY_TYPES}" + "${COMPONENTS_DIR}/interfaces/MOBILE_API.xml" + "rpc::policy_table_interface_base" + "mobile-policy-types") + +set(GENERATED_HMI_POLICY_TYPES_CPP + "${CMAKE_CURRENT_BINARY_DIR}/generated_HMI_API_policy_types.cc") + +set(GENERATED_HMI_POLICY_TYPES_HPP + "${CMAKE_CURRENT_BINARY_DIR}/generated_HMI_API_policy_types.h") + +set(GENERATED_HMI_POLICY_TYPES + ${GENERATED_HMI_POLICY_TYPES_HPP} + ${GENERATED_HMI_POLICY_TYPES_CPP}) + + +generate_policy_types("${GENERATED_HMI_POLICY_TYPES}" + "${COMPONENTS_DIR}/interfaces/HMI_API.xml" + "rpc::policy_table_interface_base" + "hmi-policy-types") + +if (REMOTE_CONTROL) + list(APPEND SOURCES ${POLICY_PATH}/src/access_remote_impl.cc) +endif() + list(APPEND SOURCES ${POLICY_PATH}/src/sql_pt_ext_queries.cc ${POLICY_PATH}/src/sql_pt_ext_representation.cc ) -set(LIBRARIES ConfigProfile policy_struct dbms jsoncpp Utils) +set(LIBRARIES + ConfigProfile + policy_struct + dbms jsoncpp + Utils +) + if (CMAKE_SYSTEM_NAME STREQUAL "QNX") # --- QDB Wrapper include_directories (${COMPONENTS_DIR}/utils/include/utils) @@ -75,21 +121,25 @@ else () list(APPEND LIBRARIES sqlite3) endif () -add_library(${target} SHARED ${SOURCES}) -target_link_libraries(${target} ${LIBRARIES} ) +add_library(PolicyStatic ${SOURCES}) +target_link_libraries(PolicyStatic ${LIBRARIES}) + + +add_library(Policy SHARED "src/policy_manager_impl.cc") +target_link_libraries(Policy PolicyStatic) if (ENABLE_LOG) - target_link_libraries(${target} log4cxx -L${LOG4CXX_LIBS_DIRECTORY}) + target_link_libraries(Policy log4cxx -L${LOG4CXX_LIBS_DIRECTORY}) endif() -add_custom_target(copy_library_${target} ALL +add_custom_target(copy_library_Policy ALL COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_CURRENT_BINARY_DIR}/${library_name} ${copy_destination} - DEPENDS ${target} + DEPENDS Policy COMMENT "Copying library ${library_name}") -install(TARGETS ${target} +install(TARGETS Policy DESTINATION ${install_destination} PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE @@ -100,13 +150,22 @@ install(TARGETS ${target} set(struct_target policy_struct) set(TABLE_STRUCT_SOURCES + ${GENERATED_MOBILE_POLICY_TYPES_CPP} + ${GENERATED_HMI_POLICY_TYPES_CPP} ${POLICY_PATH}/src/policy_table/enums.cc ${POLICY_PATH}/src/policy_table/types.cc ${POLICY_PATH}/src/policy_table/validation.cc ) add_library(${struct_target} ${TABLE_STRUCT_SOURCES}) -target_link_libraries(${struct_target} Utils) +target_link_libraries(${struct_target} +MOBILE_API +HMI_API +Utils +SmartObjects +formatters +jsoncpp +) # --- Usage statistics set(USAGE_STATISTICS_SOURCES diff --git a/src/components/policy/policy_external/doc/doxygen/components/SmartObjects/Smart Objects Validation/Schema Structure.txt b/src/components/policy/policy_external/doc/doxygen/components/SmartObjects/Smart Objects Validation/Schema Structure.txt index a031e9fd862..d4be0ce4901 100644 --- a/src/components/policy/policy_external/doc/doxygen/components/SmartObjects/Smart Objects Validation/Schema Structure.txt +++ b/src/components/policy/policy_external/doc/doxygen/components/SmartObjects/Smart Objects Validation/Schema Structure.txt @@ -19,7 +19,7 @@ ns_smart_device_link::ns_smart_objects::CArraySchemaItem provides validation for ns_smart_device_link::ns_smart_objects::CObjectSchemaItem used in case when Schema Item includes another Schema Item. Actually this is only way to create tree node of new Schema. All other Schema Items will be used only to become leafs of validation tree. After creation of all required Schema Items (which is actually bind in the tree) it is possible to create Schema. -Schema can be initialized not only by raw root Schema Item, but also by special abstraction called Member (defined by ns_smart_device_link::ns_smart_objects::CObjectSchemaItem::SMember class). So every root item (ns_smart_device_link::ns_smart_objects::CObjectSchemaItem) firstly should be wrapped as Member. This wrapping process also allows to set "is mandatory" status for every Member. +Schema can be initialized not only by raw root Schema Item, but also by special abstraction called Member (defined by ns_smart_device_link::ns_smart_objects::SMember class). So every root item (ns_smart_device_link::ns_smart_objects::CObjectSchemaItem) firstly should be wrapped as Member. This wrapping process also allows to set "is mandatory" status for every Member. and pass root Schema Item as initial parameter to the new Schema. @@ -69,29 +69,29 @@ TSharedPtr resultCode_SchemaItem = TEnumSchemaItem:: // Provides additional human readable info regarding the result. TSharedPtr info_SchemaItem = CStringSchemaItem::create(TSchemaItemParameter(1000), TSchemaItemParameter()); -schemaMembersMap["success"] = CObjectSchemaItem::SMember(success_SchemaItem, true); +schemaMembersMap["success"] = SMember(success_SchemaItem, true); -schemaMembersMap["resultCode"] = CObjectSchemaItem::SMember(resultCode_SchemaItem, true); +schemaMembersMap["resultCode"] = SMember(resultCode_SchemaItem, true); -schemaMembersMap["info"] = CObjectSchemaItem::SMember(info_SchemaItem, false); +schemaMembersMap["info"] = SMember(info_SchemaItem, false); -std::map paramsMembersMap; +std::map paramsMembersMap; -paramsMembersMap[ns_smart_device_link::ns_json_handler::strings::S_FUNCTION_ID] = CObjectSchemaItem::SMember(TEnumSchemaItem::create(FunctionIDItems), true); +paramsMembersMap[ns_smart_device_link::ns_json_handler::strings::S_FUNCTION_ID] = SMember(TEnumSchemaItem::create(FunctionIDItems), true); -paramsMembersMap[ns_smart_device_link::ns_json_handler::strings::S_MESSAGE_TYPE] = CObjectSchemaItem::SMember(TEnumSchemaItem::create(MessageTypeItems), true); +paramsMembersMap[ns_smart_device_link::ns_json_handler::strings::S_MESSAGE_TYPE] = SMember(TEnumSchemaItem::create(MessageTypeItems), true); -paramsMembersMap[ns_smart_device_link::ns_json_handler::strings::S_CORRELATION_ID] = CObjectSchemaItem::SMember(TNumberSchemaItem::create(), true); +paramsMembersMap[ns_smart_device_link::ns_json_handler::strings::S_CORRELATION_ID] = SMember(TNumberSchemaItem::create(), true); -paramsMembersMap[ns_smart_device_link::ns_json_handler::strings::S_PROTOCOL_VERSION] = CObjectSchemaItem::SMember(TNumberSchemaItem::create(1, 2), true); +paramsMembersMap[ns_smart_device_link::ns_json_handler::strings::S_PROTOCOL_VERSION] = SMember(TNumberSchemaItem::create(1, 2), true); -paramsMembersMap[ns_smart_device_link::ns_json_handler::strings::S_PROTOCOL_TYPE] = CObjectSchemaItem::SMember(TNumberSchemaItem::create(), true); +paramsMembersMap[ns_smart_device_link::ns_json_handler::strings::S_PROTOCOL_TYPE] = SMember(TNumberSchemaItem::create(), true); -std::map rootMembersMap; +std::map rootMembersMap; -rootMembersMap[ns_smart_device_link::ns_json_handler::strings::S_MSG_PARAMS] = CObjectSchemaItem::SMember(CObjectSchemaItem::create(schemaMembersMap), true); +rootMembersMap[ns_smart_device_link::ns_json_handler::strings::S_MSG_PARAMS] = SMember(CObjectSchemaItem::create(schemaMembersMap), true); -rootMembersMap[ns_smart_device_link::ns_json_handler::strings::S_PARAMS] = CObjectSchemaItem::SMember(CObjectSchemaItem::create(paramsMembersMap), true); +rootMembersMap[ns_smart_device_link::ns_json_handler::strings::S_PARAMS] = SMember(CObjectSchemaItem::create(paramsMembersMap), true); CSmartSchema(CObjectSchemaItem::create(rootMembersMap)); diff --git a/src/components/policy/policy_external/include/policy/access_remote.h b/src/components/policy/policy_external/include/policy/access_remote.h index fd185af0757..eadef088adb 100644 --- a/src/components/policy/policy_external/include/policy/access_remote.h +++ b/src/components/policy/policy_external/include/policy/access_remote.h @@ -32,9 +32,9 @@ #ifndef SRC_COMPONENTS_POLICY_POLICY_EXTERNAL_INCLUDE_POLICY_ACCESS_REMOTE_H_ #define SRC_COMPONENTS_POLICY_POLICY_EXTERNAL_INCLUDE_POLICY_ACCESS_REMOTE_H_ -#include #include #include +#include #include "policy/policy_table/types.h" #include "policy/policy_types.h" 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 2c35b2a378f..5e3cf3dde71 100644 --- a/src/components/policy/policy_external/include/policy/cache_manager.h +++ b/src/components/policy/policy_external/include/policy/cache_manager.h @@ -33,17 +33,19 @@ #ifndef SRC_COMPONENTS_POLICY_POLICY_EXTERNAL_INCLUDE_POLICY_CACHE_MANAGER_H_ #define SRC_COMPONENTS_POLICY_POLICY_EXTERNAL_INCLUDE_POLICY_CACHE_MANAGER_H_ +#include #include +#include "boost/optional.hpp" -#include "policy/pt_representation.h" +#include "policy/cache_manager_interface.h" #include "policy/pt_ext_representation.h" +#include "policy/pt_representation.h" #include "policy/usage_statistics/statistics_manager.h" -#include "policy/cache_manager_interface.h" #include "utils/threads/thread.h" #include "utils/threads/thread_delegate.h" -#include "utils/lock.h" #include "utils/conditional_variable.h" +#include "utils/lock.h" namespace policy { class PolicySettings; @@ -153,10 +155,26 @@ class CacheManager : public CacheManagerInterface { */ virtual bool SecondsBetweenRetries(std::vector& seconds); + const boost::optional LockScreenDismissalEnabledState() const OVERRIDE; + + const boost::optional LockScreenDismissalWarningMessage( + const std::string& language) const OVERRIDE; + + /** + * @brief Gets vehicle data items + * @return Structure with vehicle data items + */ + virtual const std::vector GetVehicleDataItems() + const OVERRIDE; + + std::vector GetRemovedVehicleDataItems() + const OVERRIDE; + /** - * @brief Gets information about vehicle + * @brief Gets copy of current policy table data + * @return policy_table as json object */ - virtual const VehicleInfo GetVehicleInfo() const; + virtual Json::Value GetPolicyTableData() const OVERRIDE; /** * @brief Get a list of enabled cloud applications @@ -256,7 +274,7 @@ class CacheManager : public CacheManagerInterface { * @brief Check if an app can send unknown rpc requests to an app service * provider * @param policy_app_id Unique application id - */ + */ virtual bool UnknownRPCPassthroughAllowed( const std::string& policy_app_id) const; @@ -283,7 +301,7 @@ class CacheManager : public CacheManagerInterface { std::vector GetUserFriendlyMsg( const std::vector& msg_codes, const std::string& language, - const std::string& active_hmi_language); + const std::string& active_hmi_language) const; /** * @brief GetLockScreenIcon allows to obtain lock screen icon url; @@ -407,6 +425,12 @@ class CacheManager : public CacheManagerInterface { */ bool GetFunctionalGroupings(policy_table::FunctionalGroupings& groups); + /** + * @brief Get policy app names from PT + * @return container of strings representing policy application names + */ + const policy_table::Strings GetPolicyAppIDs() const OVERRIDE; + /** * Checks if the application is represented in policy table * @param app_id application id @@ -798,35 +822,36 @@ class CacheManager : public CacheManagerInterface { ExternalConsentStatus GetExternalConsentEntities() OVERRIDE; /** - * @brief Creates collection of ExternalConsent items known by current - * functional - * groupings and appropiate section - * (disallowed_by_external_consent_entities_on/off) where - * is item is being holded. If item is not found it's not included into - * collection - * @param status Current status containing collection of ExternalConsent items - * @return Collection of ExternalConsent items mapped to list of groups with - * section - * marker where the item is found - */ + * @brief Creates collection of ExternalConsent items known by current + * functional + * groupings and appropiate section + * (disallowed_by_external_consent_entities_on/off) where + * is item is being holded. If item is not found it's not included into + * collection + * @param status Current status containing collection of ExternalConsent items + * @return Collection of ExternalConsent items mapped to list of groups with + * section + * marker where the item is found + */ GroupsByExternalConsentStatus GetGroupsWithSameEntities( const ExternalConsentStatus& status) OVERRIDE; /** - * @brief Gets collection of links device-to-application from device_data - * section of policy table if there any application records present, i.e. if - * any specific user consent is present - * @return Collection of device-to-application links - */ + * @brief Gets collection of links device-to-application from device_data + * section of policy table if there any application records present, i.e. if + * any specific user consent is present + * @return Collection of device-to-application links + */ std::map GetKnownLinksFromPT() OVERRIDE; /** - * @brief Sets groups permissions affected by customer connectivity settings - * entities status, i.e. groups assigned to particular application on - * particular device which have same entities as current ExternalConsent status - * @param permissions Groups permissions which result current ExternalConsent - * status - */ + * @brief Sets groups permissions affected by customer connectivity settings + * entities status, i.e. groups assigned to particular application on + * particular device which have same entities as current ExternalConsent + * status + * @param permissions Groups permissions which result current ExternalConsent + * status + */ void SetExternalConsentForApp(const PermissionConsent& permissions) OVERRIDE; #ifdef BUILD_TESTS @@ -846,6 +871,14 @@ class CacheManager : public CacheManagerInterface { void OnDeviceSwitching(const std::string& device_id_from, const std::string& device_id_to) OVERRIDE; + /** + * @brief Method for separate standard vehicle data items from custom + * @param full vehicle data items during PTU + * @return array with only custom vehicle items + */ + static policy_table::VehicleDataItems CollectCustomVDItems( + const policy_table::VehicleDataItems& vd_items); + private: std::string currentDateTime(); struct AppHMITypeToString { @@ -864,6 +897,24 @@ class CacheManager : public CacheManagerInterface { */ void CheckSnapshotInitialization(); + /** + * @brief Calculates difference between two provided custom vehicle data items + * @param items_before list of vehicle data items before PTU was applied + * @param items_after list of vehicle data items after PTU was applied + * @return list with calculated difference or empty list if two input lists + * are equal + */ + policy_table::VehicleDataItems CalculateCustomVdItemsDiff( + const policy_table::VehicleDataItems& items_before, + const policy_table::VehicleDataItems& items_after) const; + + /** + * @brief Sets the custom vehicle data items + * @param removed_items list of vehicle data items to set + */ + void SetRemovedCustomVdItems( + const policy_table::VehicleDataItems& removed_items); + void PersistData(); /** @@ -891,6 +942,16 @@ class CacheManager : public CacheManagerInterface { const std::string& policy_app_id, policy::Permissions& permission); + EncryptionRequired GetAppEncryptionRequiredFlag( + const std::string& application_policy_name) const OVERRIDE; + + EncryptionRequired GetFunctionalGroupingEncryptionRequiredFlag( + const std::string& functional_group) const OVERRIDE; + + void GetApplicationParams( + const std::string& application_name, + policy_table::ApplicationParams& application_policies) const OVERRIDE; + private: std::shared_ptr pt_; std::shared_ptr snapshot_; @@ -899,6 +960,7 @@ class CacheManager : public CacheManagerInterface { bool update_required; typedef std::set UnpairedDevices; UnpairedDevices is_unpaired_; + policy_table::VehicleDataItems removed_custom_vd_items_; mutable sync_primitives::RecursiveLock cache_lock_; sync_primitives::Lock unpaired_lock_; @@ -1020,6 +1082,24 @@ class CacheManager : public CacheManagerInterface { void MergeCFM(const policy_table::PolicyTable& new_pt, policy_table::PolicyTable& pt); + /** + * @brief MergeVD allows to merge VehicleDataItems section by + *definite rules. + * + * The rules are: + * 1. If vehicle_data_items key is not presented in the updated PolicyTable, + * update for VehicleDataItems should be ignored. + * 2. If vehicle_data_items presented in updated PolicyTable, the + * VehicleDataItems in the database (LocalPT) should be overwritten with + * updated data. + * + * @param new_pt the policy table loaded from updated preload JSON file. + * + * @param pt the exists database + */ + void MergeVD(const policy_table::PolicyTable& new_pt, + policy_table::PolicyTable& pt); + void InitBackupThread(); /** @@ -1050,12 +1130,28 @@ class CacheManager : public CacheManagerInterface { ~BackgroundBackuper(); virtual void threadMain(); virtual void exitThreadMain(); + + /** + * @brief Notifies BackgroundBackuper thread that new data is available and + * new backup iteration should be scheduled + */ void DoBackup(); + /** + * @brief Waits for BackgroundBackuper thread finish its own backup + * iteration. If currently no backup iteration in progress - function just + * returns the control back + */ + void WaitForBackupIsDone(); + private: void InternalBackup(); CacheManager* cache_manager_; sync_primitives::ConditionalVariable backup_notifier_; + sync_primitives::ConditionalVariable backup_done_; + sync_primitives::Lock backup_done_lock_; + + std::atomic_bool backup_is_in_progress_; volatile bool stop_flag_; volatile bool new_data_available_; diff --git a/src/components/policy/policy_external/include/policy/cache_manager_interface.h b/src/components/policy/policy_external/include/policy/cache_manager_interface.h index 6465c79c05e..2cb5f8fe331 100644 --- a/src/components/policy/policy_external/include/policy/cache_manager_interface.h +++ b/src/components/policy/policy_external/include/policy/cache_manager_interface.h @@ -35,13 +35,14 @@ #include #include +#include "boost/optional.hpp" #include "policy/policy_table/types.h" #include "policy/pt_representation.h" -#include "policy/usage_statistics/counter.h" -#include "policy/policy_types.h" #include "policy/policy_settings.h" +#include "policy/policy_types.h" +#include "policy/usage_statistics/counter.h" namespace policy_table = rpc::policy_table_interface_base; @@ -161,9 +162,24 @@ class CacheManagerInterface { virtual bool SecondsBetweenRetries(std::vector& seconds) = 0; /** - * @brief Get information about vehicle + * @brief Gets copy of current policy table data + * @return policy_table as json object */ - virtual const VehicleInfo GetVehicleInfo() const = 0; + virtual Json::Value GetPolicyTableData() const = 0; + + /** + * @brief Gets vehicle data items + * @return Structure with vehicle data items + */ + virtual const std::vector GetVehicleDataItems() + const = 0; + + /** + * @brief Gets vehicle data items removed after the last PTU + * @return List of removed vehicle data items + */ + virtual std::vector + GetRemovedVehicleDataItems() const = 0; /** * @brief Get a list of enabled cloud applications @@ -199,11 +215,11 @@ class CacheManagerInterface { std::string& hybrid_app_preference) const = 0; /** - * Initializes a new cloud application with default policies - * Then adds cloud specific policies - * @param app_id application id - * @return true if success - */ + * Initializes a new cloud application with default policies + * Then adds cloud specific policies + * @param app_id application id + * @return true if success + */ virtual void InitCloudApp(const std::string& policy_app_id) = 0; /** @@ -265,10 +281,28 @@ class CacheManagerInterface { * @brief Check if an app can send unknown rpc requests to an app service * provider * @param policy_app_id Unique application id - */ + */ virtual bool UnknownRPCPassthroughAllowed( const std::string& policy_app_id) const = 0; + /** + * @brief Returns state of the lock screen that could be able to be dismissed + * while connected to SDL, allowing users the ability to interact with the + * app. + * @return bool True if lock screen can be dismissed. + */ + virtual const boost::optional LockScreenDismissalEnabledState() + const = 0; + + /** + * @brief Returns lock screen warning message. In case when specified language + * is absent in policy table will be returned message on default language + * ("en-us"). Otherwise returns uninitialized boost::optional + * @return std::string Lock screen warning message + */ + virtual const boost::optional LockScreenDismissalWarningMessage( + const std::string& language) const = 0; + /** * @brief Allows to update 'vin' field in module_meta table. * @@ -290,7 +324,7 @@ class CacheManagerInterface { virtual std::vector GetUserFriendlyMsg( const std::vector& msg_codes, const std::string& language, - const std::string& active_hmi_language) = 0; + const std::string& active_hmi_language) const = 0; /** * @brief Get list of URL to send PTS to @@ -416,6 +450,12 @@ class CacheManagerInterface { virtual bool GetFunctionalGroupings( policy_table::FunctionalGroupings& groups) = 0; + /** + * @brief Get policy app names from PT + * @return container of strings representing policy application names + */ + virtual const policy_table::Strings GetPolicyAppIDs() const = 0; + /** * Checks if the application is represented in policy table * @param app_id application id @@ -867,9 +907,9 @@ class CacheManagerInterface { virtual std::string GetCertificate() const = 0; /** - * @brief Sets decrypted certificate in policy table - * @param certificate content of certificate - */ + * @brief Sets decrypted certificate in policy table + * @param certificate content of certificate + */ virtual void SetDecryptedCertificate(const std::string& certificate) = 0; /** @@ -894,34 +934,35 @@ class CacheManagerInterface { virtual ExternalConsentStatus GetExternalConsentEntities() = 0; /** - * @brief Creates collection of ExternalConsent items known by current - * functional - * groupings and appropiate section - * (disallowed_by_external_consent_entities_on/off) where - * is item is being holded - * @param status Current status containing collection of ExternalConsent items - * @return Collection of ExternalConsent items mapped to list of groups with - * section - * marker where the item is found - */ + * @brief Creates collection of ExternalConsent items known by current + * functional + * groupings and appropiate section + * (disallowed_by_external_consent_entities_on/off) where + * is item is being holded + * @param status Current status containing collection of ExternalConsent items + * @return Collection of ExternalConsent items mapped to list of groups with + * section + * marker where the item is found + */ virtual GroupsByExternalConsentStatus GetGroupsWithSameEntities( const ExternalConsentStatus& status) = 0; /** - * @brief Gets collection of links device-to-application from device_data - * section of policy table if there any application records present, i.e. if - * any specific user consent is present - * @return Collection of device-to-application links - */ + * @brief Gets collection of links device-to-application from device_data + * section of policy table if there any application records present, i.e. if + * any specific user consent is present + * @return Collection of device-to-application links + */ virtual std::map GetKnownLinksFromPT() = 0; /** - * @brief Sets groups permissions affected by customer connectivity settings - * entities status, i.e. groups assigned to particular application on - * particular device which have same entities as current ExternalConsent status - * @param permissions Groups permissions which result current ExternalConsent - * status - */ + * @brief Sets groups permissions affected by customer connectivity settings + * entities status, i.e. groups assigned to particular application on + * particular device which have same entities as current ExternalConsent + * status + * @param permissions Groups permissions which result current ExternalConsent + * status + */ virtual void SetExternalConsentForApp( const PermissionConsent& permissions) = 0; @@ -934,6 +975,37 @@ class CacheManagerInterface { virtual void OnDeviceSwitching(const std::string& device_id_from, const std::string& device_id_to) = 0; + /** + * @brief GetAppEncryptionRequiredFlag retrieves encryption required flag + * for + * given application + * @param application policy application name + * @return optional object containing encryption required flag + */ + virtual rpc::Optional GetAppEncryptionRequiredFlag( + const std::string& application_policy_name) const = 0; + + /** + * @brief GetFunctionalGroupingEncryptionRequiredFlag retrieves encryption + * required flag + * for + * given functional grouping + * @param functional_group policy functional group name + * @return optional object containing encryption required flag + */ + virtual rpc::Optional + GetFunctionalGroupingEncryptionRequiredFlag( + const std::string& functional_group) const = 0; + + /** + * @brief retreives application params + * @param application_name policy applicatoin name + * @param application_params application params + */ + virtual void GetApplicationParams( + const std::string& application_name, + policy_table::ApplicationParams& application_params) const = 0; + #ifdef BUILD_TESTS /** * @brief GetPT allows to obtain std::shared_ptr to PT. 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 e3cb509c154..2054485ef5b 100644 --- a/src/components/policy/policy_external/include/policy/policy_helper.h +++ b/src/components/policy/policy_external/include/policy/policy_helper.h @@ -1,4 +1,4 @@ -/* +/* Copyright (c) 2013, Ford Motor Company All rights reserved. @@ -128,6 +128,15 @@ struct CheckAppPolicy { */ bool HasNewGroups(const AppPoliciesValueType& app_policy, policy_table::Strings* new_groups = NULL) const; + /** + * @brief Checks whether updated application policy contains group content + * update in compare to current one + * @param app_policy Reference to updated application policy + * @param updated_groups List of updated groups if any + * @return True if updated groups found, otherwise - false + */ + bool HasUpdatedGroups(const policy::AppPoliciesValueType& app_policy, + policy_table::Strings* updated_groups = NULL) const; /** * @brief Checks whether updated policy has groups which require user consent * @param app_policy Reference to updated application policy @@ -201,6 +210,15 @@ struct CheckAppPolicy { */ bool IsRequestSubTypeChanged(const AppPoliciesValueType& app_policy) const; + /** + * @brief IsEncryptionRequiredFlagChanged check if encryption_needed flag was + * changed for application or application groups + * @param app_policy application policies + * @return true if encryption_needed state was changed otherwise - false + */ + bool IsEncryptionRequiredFlagChanged( + const AppPoliciesValueType& app_policy) const; + /** * @brief Helper function that inserts permissions into app_permissions_diff_ * map. @@ -243,13 +261,13 @@ struct FillActionsForAppPolicies { */ struct FillNotificationData { /** - * @brief Constructor - * @param data Output structure with filled data - * @param group_state Consent of the group processed by instance - * @param undefined_group_consent Defines how to treat 'undefined' consent - * @param does_require_user_consent Specifies whether processed group requires - * user consent - */ + * @brief Constructor + * @param data Output structure with filled data + * @param group_state Consent of the group processed by instance + * @param undefined_group_consent Defines how to treat 'undefined' consent + * @param does_require_user_consent Specifies whether processed group requires + * user consent + */ FillNotificationData(Permissions& data, GroupConsent group_state, GroupConsent undefined_group_consent, @@ -307,6 +325,14 @@ struct ProcessFunctionalGroup { private: GroupConsent GetGroupState(const std::string& group_name); + /* + * @brief Fills encryption required flags for all rpcs in functional group + * @param encryption_required Optional object containing encryption required + * flag + */ + void FillEncryptionFlagForRpcs( + const policy_table::Rpc& rpcs, + const policy::EncryptionRequired encryption_required); const policy_table::FunctionalGroupings& fg_; const std::vector& group_permissions_; Permissions& data_; diff --git a/src/components/policy/policy_external/include/policy/policy_manager_impl.h b/src/components/policy/policy_external/include/policy/policy_manager_impl.h index 8a2e5b93f5f..b1c22ab9e62 100644 --- a/src/components/policy/policy_external/include/policy/policy_manager_impl.h +++ b/src/components/policy/policy_external/include/policy/policy_manager_impl.h @@ -35,15 +35,16 @@ #include -#include "utils/lock.h" +#include "policy/access_remote.h" +#include "policy/access_remote_impl.h" +#include "policy/cache_manager_interface.h" #include "policy/policy_manager.h" #include "policy/policy_table.h" -#include "policy/cache_manager_interface.h" -#include "policy/update_status_manager.h" #include "policy/policy_table/functions.h" +#include "policy/update_status_manager.h" #include "policy/usage_statistics/statistics_manager.h" -#include "policy/access_remote.h" -#include "policy/access_remote_impl.h" +#include "utils/lock.h" +#include "utils/timer.h" namespace policy_table = rpc::policy_table_interface_base; @@ -54,7 +55,47 @@ class PolicyManagerImpl : public PolicyManager { public: PolicyManagerImpl(); explicit PolicyManagerImpl(bool in_memory); + /* + * \param policy_app_id policy app id + * \return true if the app need encryption + */ + bool AppNeedEncryption(const std::string& policy_app_id) const OVERRIDE; + /* + * \param policy_app_id policy app id + * \return Optional app need encryption + */ + const rpc::Optional GetAppEncryptionRequired( + const std::string& policy_app_id) const OVERRIDE; + + /* + * \param policy_app_id policy app id + * \return groups that exist for app + */ + const std::vector GetFunctionalGroupsForApp( + const std::string& policy_app_id) const OVERRIDE; + + const std::vector GetApplicationPolicyIDs() const OVERRIDE; + + /* + * \param policy_group group + * \return true if the group need encryption + */ + bool FunctionGroupNeedEncryption( + const std::string& policy_group) const OVERRIDE; + + /* + * \param policy_group group\ + * \return RPCs that exists in group + */ + const std::vector GetRPCsForFunctionGroup( + const std::string& group) const OVERRIDE; + /* + * \param function_id function id + * \return policy function name + */ + const std::string GetPolicyFunctionName( + const uint32_t function_id) const OVERRIDE; /** * @brief set_listener set new policy listener instance * @param listener new policy listener @@ -86,8 +127,10 @@ class PolicyManagerImpl : public PolicyManager { * @param pt_content PTU as binary string * @return true if successfully */ - bool LoadPT(const std::string& file, - const BinaryMessage& pt_content) OVERRIDE; + PtProcessingResult LoadPT(const std::string& file, + const BinaryMessage& pt_content) OVERRIDE; + + void OnPTUFinished(const PtProcessingResult ptu_result) OVERRIDE; /** * @brief Resets Policy Table @@ -122,6 +165,7 @@ class PolicyManagerImpl : public PolicyManager { * @brief Check if specified RPC for specified application * has permission to be executed in specified HMI Level * and also its permitted params. + * @param device_id device identifier * @param app_id Id of application provided during registration * @param hmi_level Current HMI Level of application * @param rpc Name of RPC @@ -129,7 +173,8 @@ class PolicyManagerImpl : public PolicyManager { * @param result containing flag if HMI Level is allowed * and list of allowed params. */ - void CheckPermissions(const PTString& app_id, + void CheckPermissions(const PTString& device_id, + const PTString& app_id, const PTString& hmi_level, const PTString& rpc, const RPCParams& rpc_params, @@ -148,6 +193,11 @@ class PolicyManagerImpl : public PolicyManager { */ void KmsChanged(int kilometers) OVERRIDE; + const boost::optional LockScreenDismissalEnabledState() const OVERRIDE; + + const boost::optional LockScreenDismissalWarningMessage( + const std::string& language) const OVERRIDE; + /** * @brief Increments counter of ignition cycles */ @@ -159,6 +209,8 @@ class PolicyManagerImpl : public PolicyManager { */ std::string ForcePTExchange() OVERRIDE; + void StopRetrySequence() OVERRIDE; + /** * @brief Exchange by user request * @return Current status of policy table @@ -173,8 +225,10 @@ class PolicyManagerImpl : public PolicyManager { /** * @brief Resets retry sequence + * @param send_event - if true corresponding event is sent to + * UpdateStatusManager */ - void ResetRetrySequence() OVERRIDE; + void ResetRetrySequence(const ResetRetryCountType reset_type) OVERRIDE; /** * @brief Gets timeout to wait before next retry updating PT @@ -262,12 +316,15 @@ class PolicyManagerImpl : public PolicyManager { /** * @brief Update Application Policies as reaction * on User allowing/disallowing device this app is running on. + * @param device_handle device identifier * @param app_id Unique application id * @param is_device_allowed true if user allowing device otherwise false * @return true if operation was successful */ - bool ReactOnUserDevConsentForApp(const std::string& app_id, - const bool is_device_allowed) OVERRIDE; + bool ReactOnUserDevConsentForApp( + const transport_manager::DeviceHandle& device_handle, + const std::string& app_id, + const bool is_device_allowed) OVERRIDE; /** * @brief Retrieves data from app_policies about app on its registration: @@ -310,12 +367,14 @@ class PolicyManagerImpl : public PolicyManager { /** * @brief Get default HMI level for application + * @param device_id device identifier * @param policy_app_id Unique application id * @param default_hmi Default HMI level for application or empty, if value * was not set * @return true, if succedeed, otherwise - false */ - bool GetDefaultHmi(const std::string& policy_app_id, + bool GetDefaultHmi(const std::string& device_id, + const std::string& policy_app_id, std::string* default_hmi) const OVERRIDE; /** @@ -360,9 +419,11 @@ class PolicyManagerImpl : public PolicyManager { /** * @brief Return device id, which hosts specific application + * @param device_id device identifier * @param policy_app_id Application id, which is required to update device id */ std::string& GetCurrentDeviceId( + const transport_manager::DeviceHandle& device_id, const std::string& policy_app_id) const OVERRIDE; /** @@ -404,11 +465,12 @@ class PolicyManagerImpl : public PolicyManager { /** * @brief Gets specific application permissions changes since last policy * table update + * @param device_id device identifier * @param policy_app_id Unique application id * @return Permissions changes */ AppPermissions GetAppPermissionsChanges( - const std::string& policy_app_id) OVERRIDE; + const std::string& device_id, const std::string& policy_app_id) OVERRIDE; /** * @brief Removes specific application permissions changes @@ -418,10 +480,11 @@ class PolicyManagerImpl : public PolicyManager { /** * @brief Send OnPermissionsUpdated for choosen application + * @param device_id device identifier * @param application_id Unique application id */ void SendNotificationOnPermissionsUpdated( - const std::string& application_id) OVERRIDE; + const std::string& device_id, const std::string& application_id) OVERRIDE; /** * @brief Removes unpaired device records and related records from DB @@ -452,20 +515,24 @@ class PolicyManagerImpl : public PolicyManager { /** * @brief Adds, application to the db or update existed one * run PTU if policy update is necessary for application. + * @param device_id device identifier * @param application_id Unique application id * @param hmi_types application HMI types * @return function that will notify update manager about new application */ StatusNotifier AddApplication( + const std::string& device_id, const std::string& application_id, const rpc::policy_table_interface_base::AppHmiTypes& hmi_types) OVERRIDE; /** * @brief Assigns new HMI types for specified application + * @param device_handle device identifier * @param application_id Unique application id * @param hmi_types new HMI types list */ - void SetDefaultHmiTypes(const std::string& application_id, + void SetDefaultHmiTypes(const transport_manager::DeviceHandle& device_handle, + const std::string& application_id, const std::vector& hmi_types) OVERRIDE; /** @@ -542,10 +609,10 @@ class PolicyManagerImpl : public PolicyManager { void OnAppsSearchCompleted(const bool trigger_ptu) OVERRIDE; /** - * @brief Get state of request types for given application - * @param policy_app_id Unique application id - * @return request type state - */ + * @brief Get state of request types for given application + * @param policy_app_id Unique application id + * @return request type state + */ RequestType::State GetAppRequestTypesState( const std::string& policy_app_id) const OVERRIDE; @@ -559,25 +626,37 @@ class PolicyManagerImpl : public PolicyManager { /** * @brief Gets request types for application + * @param device_handle device identifier * @param policy_app_id Unique application id * @return request types of application */ const std::vector GetAppRequestTypes( + const transport_manager::DeviceHandle& device_handle, const std::string policy_app_id) const OVERRIDE; /** - * @brief Gets request subtypes for application - * @param policy_app_id Unique application id - * @return request subtypes of application - */ + * @brief Gets request subtypes for application + * @param policy_app_id Unique application id + * @return request subtypes of application + */ const std::vector GetAppRequestSubTypes( const std::string& policy_app_id) const OVERRIDE; /** - * @brief Get information about vehicle - * @return vehicle information + * @brief Gets copy of current policy table data + * @return policy_table as json object */ - const VehicleInfo GetVehicleInfo() const OVERRIDE; + Json::Value GetPolicyTableData() const OVERRIDE; + + /** + * @brief Gets vehicle data items + * @return Structure with vehicle data items + */ + const std::vector GetVehicleDataItems() + const OVERRIDE; + + std::vector GetRemovedVehicleDataItems() + const OVERRIDE; /** * @brief Get a list of enabled cloud applications @@ -677,17 +756,20 @@ class PolicyManagerImpl : public PolicyManager { * provider * @param policy_app_id Unique application id * @return bool true if allowed - */ + */ bool UnknownRPCPassthroughAllowed( const std::string& policy_app_id) const OVERRIDE; /** * @brief OnAppRegisteredOnMobile allows to handle event when application were * succesfully registered on mobile device. - * It will send OnAppPermissionSend notification and will try to start PTU. * + * It will send OnAppPermissionSend notification and will try to start PTU. + * + * @param device_id device identifier * @param application_id registered application. */ - void OnAppRegisteredOnMobile(const std::string& application_id) OVERRIDE; + void OnAppRegisteredOnMobile(const std::string& device_id, + const std::string& application_id) OVERRIDE; void OnDeviceSwitching(const std::string& device_id_from, const std::string& device_id_to) OVERRIDE; @@ -776,14 +858,11 @@ class PolicyManagerImpl : public PolicyManager { } /** - * @brief Setter for send_on_update_sent_out and wrong_ptu_update_received + * @brief Setter for send_on_update_sent_out * @param send_on_update_sent_out new value of this flag - * @param wrong_ptu_update_received new value of this flag */ - inline void SetSendOnUpdateFlags(const bool send_on_update_sent_out, - const bool wrong_ptu_update_received) { + inline void SetSendOnUpdateFlags(const bool send_on_update_sent_out) { send_on_update_sent_out_ = send_on_update_sent_out; - wrong_ptu_update_received_ = wrong_ptu_update_received; } #endif // BUILD_TESTS @@ -820,8 +899,28 @@ class PolicyManagerImpl : public PolicyManager { void Add(const std::string& app_id, usage_statistics::AppStopwatchId type, int32_t timespan_seconds) OVERRIDE; + // Interface StatisticsManager (end) + /** + * @brief Check whether allowed retry sequence count is exceeded + * @return bool value - true is allowed count is exceeded, otherwise - false + */ + bool IsAllowedRetryCountExceeded() const OVERRIDE; + + /** + * @brief Finish PTU retry requence + */ + void RetrySequenceFailed() OVERRIDE; + + /** + * @brief In EXTERNAL_PROPRIETARY_MODE PTU sequence is driven by HMI and + * begins with OnSystemRequest from HMI. Following function is called when + * this notification is received to track number of PTU retries and react + * accordingly once allowed retry count is exceeded + */ + void OnSystemRequestReceived() OVERRIDE; + protected: /** * @brief Parse policy table content and convert to PT object @@ -832,6 +931,11 @@ class PolicyManagerImpl : public PolicyManager { const BinaryMessage& pt_content); private: + /** + * @brief Increments PTU retry index for external flow + */ + void IncrementRetryIndex(); + /** * @brief Checks if PT update should be started and schedules it if needed */ @@ -850,6 +954,17 @@ class PolicyManagerImpl : public PolicyManager { const std::shared_ptr update, const std::shared_ptr snapshot); + /** + * @brief Compares current policies to the updated one. + * Trigger actions in case if certain fields after udate was changes. + * This function should be called after PT update. + * Actions require already updated policy table + * @param update Shared pointer to policy table udpate + * @param snapshot Shared pointer to old copy of policy table + */ + void CheckPermissionsChangesAfterUpdate(const policy_table::Table& update, + const policy_table::Table& snapshot); + /** * @brief Processes results from policy table update analysis done by * CheckPermissionsChanges() by filling ApplicationsPoliciesActions struct @@ -902,19 +1017,23 @@ class PolicyManagerImpl : public PolicyManager { /** * @brief Allows to process case when added application is not present in * policy db. + * @param device_id device identifier * @param policy application id. * @param cuuren consent for application's device. */ - void AddNewApplication(const std::string& application_id, + void AddNewApplication(const std::string& device_id, + const std::string& application_id, DeviceConsent device_consent); /** * @brief Allows to process case when added application is already * in policy db. + * @param device_id device identifier * @param policy application id. * @param cuuren consent for application's device. */ - void PromoteExistedApplication(const std::string& application_id, + void PromoteExistedApplication(const std::string& device_id, + const std::string& application_id, DeviceConsent device_consent); /** @@ -932,9 +1051,12 @@ class PolicyManagerImpl : public PolicyManager { /** * @brief Checks whether need ask the permission of users + * @param device_id device identifier + * @param appid policy application id * @return true if user consent is needed */ - virtual bool IsConsentNeeded(const std::string& app_id); + virtual bool IsConsentNeeded(const std::string& device_id, + const std::string& app_id); /** * @brief Changes isConsentNeeded for app pending permissions, in case @@ -1009,22 +1131,24 @@ class PolicyManagerImpl : public PolicyManager { void SendAuthTokenUpdated(const std::string policy_app_id); /** - * @brief Gets all allowed module types - * @param policy_app_id unique identifier of application - * @param modules list of allowed module types - * @return true if application has allowed modules - */ + * @brief Gets all allowed module types + * @param policy_app_id unique identifier of application + * @param modules list of allowed module types + * @return true if application has allowed modules + */ bool GetModuleTypes(const std::string& policy_app_id, std::vector* modules) const OVERRIDE; /** * @brief Notify application about its permissions changes by preparing and * sending OnPermissionsChanged notification + * @param device_id device identifier * @param policy_app_id Application id to send notification to * @param app_group_permissons Current permissions for groups assigned to * application */ void NotifyPermissionsChanges( + const std::string& device_id, const std::string& policy_app_id, const std::vector& app_group_permissions); @@ -1049,11 +1173,13 @@ class PolicyManagerImpl : public PolicyManager { * user consents (if any) and ExternalConsent consents (if any) will be * updated * appropiately to current ExternalConsent status stored by policy table + * @param device_id device identifier * @param application_id Application id * @param processing_policy Defines whether consents timestamps must be * considered or external consents take over */ void ProcessExternalConsentStatusForApp( + const std::string& device_id, const std::string& application_id, const ConsentProcessingPolicy processing_policy); /** @@ -1081,16 +1207,26 @@ class PolicyManagerImpl : public PolicyManager { /** * @brief Notifies system by sending OnAppPermissionChanged notification + * @param device_id device identifier * @param app_policy Reference to application policy */ - void NotifySystem(const AppPoliciesValueType& app_policy) const; + void NotifySystem(const std::string& device_id, + const AppPoliciesValueType& app_policy) const; /** * @brief Sends OnPermissionChange notification to application if its * currently registered + * @param device_id device identifier * @param app_policy Reference to application policy */ - void SendPermissionsToApp(const AppPoliciesValueType& app_policy); + void SendPermissionsToApp(const std::string& device_id, + const AppPoliciesValueType& app_policy); + + /** + * @brief Resumes all policy actions for all apps, suspended during + * PTU applying + */ + void ResumePendingAppPolicyActions(); /** * @brief Gets groups names from collection of groups permissions @@ -1172,7 +1308,7 @@ class PolicyManagerImpl : public PolicyManager { /** * @brief Lock for guarding retry sequence */ - sync_primitives::Lock retry_sequence_lock_; + mutable sync_primitives::Lock retry_sequence_lock_; /** * @brief Device id, which is used during PTU handling for specific @@ -1198,11 +1334,6 @@ class PolicyManagerImpl : public PolicyManager { RetrySequenceURL retry_sequence_url_; friend struct ProccessAppGroups; - /** - * @brief Flag for notifying that invalid PTU was received - */ - bool wrong_ptu_update_received_; - /** * @brief Flag for notifying that PTU was started */ @@ -1212,6 +1343,27 @@ class PolicyManagerImpl : public PolicyManager { * @brief Flag for notifying that invalid PTU should be triggered */ bool trigger_ptu_; + + /** + * @brief Flag that indicates whether a PTU sequence (including retries) is in + * progress + */ + bool is_ptu_in_progress_; + + typedef std::list > + PendingAppPolicyActionsList; + + /** + * @brief List containing device_id and pending permissions structure pairs + * which can be processed later on demand + */ + PendingAppPolicyActionsList notify_system_list_; + + /** + * @brief List containing device_id and pending permissions structure pairs + * which can be processed later on demand + */ + PendingAppPolicyActionsList send_permissions_list_; }; } // namespace policy diff --git a/src/components/policy/policy_external/include/policy/policy_table.h b/src/components/policy/policy_external/include/policy/policy_table.h index fe27f1cb578..8f0d5f7efb9 100644 --- a/src/components/policy/policy_external/include/policy/policy_table.h +++ b/src/components/policy/policy_external/include/policy/policy_table.h @@ -33,8 +33,8 @@ #ifndef SRC_COMPONENTS_POLICY_POLICY_EXTERNAL_INCLUDE_POLICY_POLICY_TABLE_H_ #define SRC_COMPONENTS_POLICY_POLICY_EXTERNAL_INCLUDE_POLICY_POLICY_TABLE_H_ -#include "policy/pt_representation.h" #include "policy/pt_ext_representation.h" +#include "policy/pt_representation.h" namespace policy { 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 28b0caf95be..a74eb1f8862 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 @@ -35,133 +35,12 @@ #include +#include "generated_HMI_API_policy_types.h" +#include "generated_MOBILE_API_policy_types.h" + namespace rpc { namespace policy_table_interface_base { -enum Priority { - P_EMERGENCY, - P_NAVIGATION, - P_VOICECOM, - P_COMMUNICATION, - P_NORMAL, - P_PROJECTION, - P_NONE, -}; - -bool IsValidEnum(Priority val); -const char* EnumToJsonString(Priority val); -bool EnumFromJsonString(const std::string& literal, Priority* result); - -enum HmiLevel { - HL_BACKGROUND, - HL_FULL, - HL_LIMITED, - HL_NONE, -}; -bool IsValidEnum(HmiLevel val); -const char* EnumToJsonString(HmiLevel val); -bool EnumFromJsonString(const std::string& literal, HmiLevel* result); - -enum Parameter { - P_GPS, - P_SPEED, - P_ENGINETORQUE, - P_EXTERNALTEMPERATURE, - P_TURNSIGNAL, - P_FUELLEVEL, - P_FUELLEVEL_STATE, - P_HEADLAMPSTATUS, - P_INSTANTFUELCONSUMPTION, - P_FUELRANGE, - P_ODOMETER, - P_TIREPRESSURE, - P_WIPERSTATUS, - P_VIN, - P_ACCPEDALPOSITION, - P_BELTSTATUS, - P_ELECTRONICPARKBRAKESTATUS, - P_DRIVERBRAKING, - P_PRNDL, - P_RPM, - P_STEERINGWHEELANGLE, - P_ENGINEOILLIFE, - P_MYKEY, - P_AIRBAGSTATUS, - P_BODYINFORMATION, - P_CLUSTERMODESTATUS, - P_DEVICESTATUS, - P_EMERGENCYEVENT, - P_ECALLINFO, - P_ABS_STATE, - P_FUEL_RANGE, - P_TIRE_PRESSURE_VALUE, - P_TPMS, - P_CLOUD_APP_VEHICLE_ID, - P_LONGTITUDE_DEGREES, - P_LATITUDE_DEGREES, - P_LOCATION_NAME, - P_LOCATION_DESCRIPTION, - P_ADDRESS_LINES, - P_PHONE_NUMBER, - P_LOCATION_IMAGE, - P_DELIVERY_MODE, - P_TIMESTAMP, - P_ADDRESS, - P_EMPTY // Added to allow empty parameters handling -}; - -bool IsValidEnum(Parameter val); -const char* EnumToJsonString(Parameter val); -bool EnumFromJsonString(const std::string& literal, Parameter* result); - -enum AppHMIType { - AHT_DEFAULT, - AHT_COMMUNICATION, - AHT_MEDIA, - AHT_MESSAGING, - AHT_NAVIGATION, - AHT_INFORMATION, - AHT_SOCIAL, - AHT_BACKGROUND_PROCESS, - AHT_TESTING, - AHT_SYSTEM, - AHT_PROJECTION, - AHT_REMOTE_CONTROL, -}; -bool IsValidEnum(AppHMIType val); -const char* EnumToJsonString(AppHMIType val); -bool EnumFromJsonString(const std::string& literal, AppHMIType* result); - -enum RequestType { - RT_HTTP, - RT_FILE_RESUME, - RT_AUTH_REQUEST, - RT_AUTH_CHALLENGE, - RT_AUTH_ACK, - RT_PROPRIETARY, - RT_QUERY_APPS, - RT_LAUNCH_APP, - RT_LOCK_SCREEN_ICON_URL, - RT_TRAFFIC_MESSAGE_CHANNEL, - RT_DRIVER_PROFILE, - RT_VOICE_SEARCH, - RT_NAVIGATION, - RT_PHONE, - RT_CLIMATE, - RT_SETTINGS, - RT_VEHICLE_DIAGNOSTICS, - RT_EMERGENCY, - RT_MEDIA, - RT_FOTA, - RT_OEM_SPECIFIC, - RT_ICON_URL, - RT_EMPTY // Added to allow empty Request Types handling -}; - -bool IsValidEnum(RequestType val); -const char* EnumToJsonString(RequestType val); -bool EnumFromJsonString(const std::string& literal, RequestType* result); - enum Input { I_GUI, I_VUI, @@ -170,431 +49,6 @@ 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, - MT_AUDIO, - MT_LIGHT, - MT_HMI_SETTINGS, - MT_EMPTY -}; -bool IsValidEnum(ModuleType val); -const char* EnumToJsonString(ModuleType val); -bool EnumFromJsonString(const std::string& literal, ModuleType* result); - -enum HybridAppPreference { HAP_MOBILE, HAP_CLOUD, HAP_BOTH }; -bool IsValidEnum(HybridAppPreference val); -const char* EnumToJsonString(HybridAppPreference val); -bool EnumFromJsonString(const std::string& literal, - HybridAppPreference* result); - -/** - * @brief Enumeration FunctionID. - * - * Enumeration linking function names with function IDs in AppLink protocol. - * Assumes enumeration starts at value 0. - */ -enum FunctionID { - /** - * @brief RESERVED. - */ - RESERVED = 0, - - /** - * @brief RegisterAppInterfaceID. - */ - RegisterAppInterfaceID = 1, - - /** - * @brief UnregisterAppInterfaceID. - */ - UnregisterAppInterfaceID = 2, - - /** - * @brief SetGlobalPropertiesID. - */ - SetGlobalPropertiesID = 3, - - /** - * @brief ResetGlobalPropertiesID. - */ - ResetGlobalPropertiesID = 4, - - /** - * @brief AddCommandID. - */ - AddCommandID = 5, - - /** - * @brief DeleteCommandID. - */ - DeleteCommandID = 6, - - /** - * @brief AddSubMenuID. - */ - AddSubMenuID = 7, - - /** - * @brief DeleteSubMenuID. - */ - DeleteSubMenuID = 8, - - /** - * @brief CreateInteractionChoiceSetID. - */ - CreateInteractionChoiceSetID = 9, - - /** - * @brief PerformInteractionID. - */ - PerformInteractionID = 10, - - /** - * @brief DeleteInteractionChoiceSetID. - */ - DeleteInteractionChoiceSetID = 11, - - /** - * @brief AlertID. - */ - AlertID = 12, - - /** - * @brief ShowID. - */ - ShowID = 13, - - /** - * @brief SpeakID. - */ - SpeakID = 14, - - /** - * @brief SetMediaClockTimerID. - */ - SetMediaClockTimerID = 15, - - /** - * @brief PerformAudioPassThruID. - */ - PerformAudioPassThruID = 16, - - /** - * @brief EndAudioPassThruID. - */ - EndAudioPassThruID = 17, - - /** - * @brief SubscribeButtonID. - */ - SubscribeButtonID = 18, - - /** - * @brief UnsubscribeButtonID. - */ - UnsubscribeButtonID = 19, - - /** - * @brief SubscribeVehicleDataID. - */ - SubscribeVehicleDataID = 20, - - /** - * @brief UnsubscribeVehicleDataID. - */ - UnsubscribeVehicleDataID = 21, - - /** - * @brief GetVehicleDataID. - */ - GetVehicleDataID = 22, - - /** - * @brief ReadDIDID. - */ - ReadDIDID = 23, - - /** - * @brief GetDTCsID. - */ - GetDTCsID = 24, - - /** - * @brief ScrollableMessageID. - */ - ScrollableMessageID = 25, - - /** - * @brief SliderID. - */ - SliderID = 26, - - /** - * @brief ShowConstantTBTID. - */ - ShowConstantTBTID = 27, - - /** - * @brief AlertManeuverID. - */ - AlertManeuverID = 28, - - /** - * @brief UpdateTurnListID. - */ - UpdateTurnListID = 29, - - /** - * @brief ChangeRegistrationID. - */ - ChangeRegistrationID = 30, - - /** - * @brief GenericResponseID. - */ - GenericResponseID = 31, - - /** - * @brief PutFileID. - */ - PutFileID = 32, - - /** - * @brief DeleteFileID. - */ - DeleteFileID = 33, - - /** - * @brief ListFilesID. - */ - ListFilesID = 34, - - /** - * @brief SetAppIconID. - */ - SetAppIconID = 35, - - /** - * @brief SetDisplayLayoutID. - */ - SetDisplayLayoutID = 36, - - /** - * @brief DiagnosticMessageID. - */ - DiagnosticMessageID = 37, - - /** - * @brief SystemRequestID. - */ - SystemRequestID = 38, - - /** - * @brief SendLocationID. - */ - SendLocationID = 39, - - /** - * @brief DialNumberID. - */ - DialNumberID = 40, - - /** - * @brief ButtonPressID. - */ - ButtonPressID = 41, - - /** - * @brief GetInteriorVehicleDataID. - */ - GetInteriorVehicleDataID = 43, - - /** - * @brief SetInteriorVehicleDataID. - */ - SetInteriorVehicleDataID = 44, - - /** - * @brief GetWayPointsID. - */ - GetWayPointsID = 45, - - /** - * @brief SubscribeWayPointsID. - */ - SubscribeWayPointsID = 46, - - /** - * @brief UnsubscribeWayPointsID. - */ - UnsubscribeWayPointsID = 47, - - /** - * @brief GetSystemCapabilityID. - */ - GetSystemCapabilityID = 48, - - /** - * @brief SendHapticDataID. - */ - SendHapticDataID = 49, - - /** - * @brief SetCloudAppPropertiesID. - */ - SetCloudAppPropertiesID = 50, - - /** - * @brief GetCloudAppPropertiesID. - */ - GetCloudAppPropertiesID = 51, - - /** - * @brief PublishAppServiceID. - */ - PublishAppServiceID = 52, - - /** - * @brief GetAppServiceDataID. - */ - GetAppServiceDataID = 53, - - /** - * @brief GetFileID - */ - GetFileID = 54, - - /** - * @brief PerformAppServiceInteractionID. - */ - PerformAppServiceInteractionID = 55, - - /** - * @brief OnHMIStatusID. - */ - OnHMIStatusID = 32768, - - /** - * @brief OnAppInterfaceUnregisteredID. - */ - OnAppInterfaceUnregisteredID = 32769, - - /** - * @brief OnButtonEventID. - */ - OnButtonEventID = 32770, - - /** - * @brief OnButtonPressID. - */ - OnButtonPressID = 32771, - - /** - * @brief OnVehicleDataID. - */ - OnVehicleDataID = 32772, - - /** - * @brief OnCommandID. - */ - OnCommandID = 32773, - - /** - * @brief OnTBTClientStateID. - */ - OnTBTClientStateID = 32774, - - /** - * @brief OnDriverDistractionID. - */ - OnDriverDistractionID = 32775, - - /** - * @brief OnPermissionsChangeID. - */ - OnPermissionsChangeID = 32776, - - /** - * @brief OnAudioPassThruID. - */ - OnAudioPassThruID = 32777, - - /** - * @brief OnLanguageChangeID. - */ - OnLanguageChangeID = 32778, - - /** - * @brief OnKeyboardInputID. - */ - OnKeyboardInputID = 32779, - - /** - * @brief OnTouchEventID. - */ - OnTouchEventID = 32780, - - /** - * @brief OnSystemRequestID. - */ - OnSystemRequestID = 32781, - - /** - * @brief OnHashChangeID. - */ - OnHashChangeID = 32782, - - /** - * @brief OnInteriorVehicleDataID. - */ - OnInteriorVehicleDataID = 32783, - - /** - * @brief OnWayPointChangeID. - */ - OnWayPointChangeID = 32784, - - /** - * @brief OnRCStatusID. - */ - OnRCStatusID = 32785, - - /** - * @brief OnAppServiceDataID. - */ - OnAppServiceDataID = 32786, - - /** - * @brief OnSystemCapabilityUpdatedID - */ - OnSystemCapabilityUpdatedID = 32787, - - /** - * @brief EncodedSyncPDataID. - */ - EncodedSyncPDataID = 65536, - - /** - * @brief SyncPDataID. - */ - SyncPDataID = 65537, - - /** - * @brief OnEncodedSyncPDataID. - */ - OnEncodedSyncPDataID = 98304, - - /** - * @brief OnSyncPDataID. - */ - OnSyncPDataID = 98305 -}; -bool IsValidEnum(FunctionID val); -const char* EnumToJsonString(FunctionID val); -bool EnumFromJsonString(const std::string& literal, FunctionID* result); - extern const std::string kDefaultApp; extern const std::string kPreDataConsentApp; extern const std::string kDeviceApp; diff --git a/src/components/policy/policy_external/include/policy/policy_table/policy_enum_schema_factory.h b/src/components/policy/policy_external/include/policy/policy_table/policy_enum_schema_factory.h new file mode 100644 index 00000000000..48711793426 --- /dev/null +++ b/src/components/policy/policy_external/include/policy/policy_table/policy_enum_schema_factory.h @@ -0,0 +1,62 @@ +/** + * 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. + */ + +#ifndef SRC_COMPONENTS_POLICY_POLICY_EXTERNAL_INCLUDE_POLICY_POLICY_TABLE_POLICY_ENUM_SCHEMA_FACTORY_H +#define SRC_COMPONENTS_POLICY_POLICY_EXTERNAL_INCLUDE_POLICY_POLICY_TABLE_POLICY_ENUM_SCHEMA_FACTORY_H + +#include +#include + +#include "smart_objects/smart_schema.h" + +namespace rpc { +namespace policy_table_interface_base { + +class EnumSchemaItemFactory { + public: + /** + * @brief Get enum schema from enum name + * Implementation of this function should be generated from MOBILE_API.xml + * @param enum_name enum name to get schema factory for + * @return shared pointer to schema factory or empty shared pointer if + * enum_name is wrong + */ + static std::shared_ptr + Get(const std::string& enum_name); + + static bool IsRPCSpecVehicleDataType(const std::string& vd_name); +}; + +} // namespace policy_table_interface_base +} // namespace rpc + +#endif // SRC_COMPONENTS_POLICY_POLICY_EXTERNAL_INCLUDE_POLICY_POLICY_TABLE_POLICY_ENUM_SCHEMA_FACTORY_H 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 994fd86579e..11c76bdd680 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 @@ -37,7 +37,9 @@ #include "utils/macro.h" #include "policy/policy_table/enums.h" +#include "policy/policy_table/policy_enum_schema_factory.h" #include "rpc_base/rpc_message.h" +#include "utils/helpers.h" namespace Json { class Value; @@ -48,6 +50,7 @@ struct AppLevel; struct ApplicationParams; struct ConsentRecords; struct DeviceParams; +struct EndpointProperty; struct MessageLanguages; struct MessageString; struct RpcParameters; @@ -69,16 +72,18 @@ typedef Array, 0, 255> AppHMITypes; typedef Array, 0, 4> HmiLevels; -typedef Array, 0, 100> Parameters; +typedef Array, 0, 100> Parameters; typedef Map Rpc; -typedef Array, 1, 3> URL; +typedef Array, 1, 3> URL; typedef Map URLList; typedef Map ServiceEndpoints; +typedef Map ServiceEndpointProperties; + typedef uint8_t NumberOfNotificationsType; typedef Map, 0, 7> NumberOfNotificationsPerMinute; @@ -116,7 +121,6 @@ typedef Integer FunctionIDInt; typedef Map RemoteRpcs; typedef Map AccessModules; typedef Array, 0, 255> ModuleTypes; - typedef AppHMIType AppHmiType; typedef std::vector AppHmiTypes; @@ -237,6 +241,7 @@ struct ApplicationParams : PolicyBase { // App Service Params Optional app_service_parameters; Optional allow_unknown_rpc_passthrough; + Optional encryption_required; public: ApplicationParams(); @@ -331,6 +336,7 @@ struct Rpcs : CompositeType { disallowed_by_external_consent_entities_on; Optional disallowed_by_external_consent_entities_off; + Optional encryption_required; public: Rpcs(); @@ -348,6 +354,24 @@ struct Rpcs : CompositeType { bool Validate() const; }; +struct EndpointProperty : CompositeType { + public: + Optional > version; + + EndpointProperty(); + ~EndpointProperty(); + explicit EndpointProperty(const Json::Value* value__); + Json::Value ToJsonValue() const; + bool is_valid() const; + bool is_initialized() const; + bool struct_empty() const; + void ReportErrors(rpc::ValidationReport* report__) const; + void SetPolicyTableType(PolicyTableType pt_type) OVERRIDE; + + private: + bool Validate() const; +}; + struct ModuleConfig : CompositeType { public: Integer exchange_after_x_ignition_cycles; @@ -356,6 +380,7 @@ struct ModuleConfig : CompositeType { Integer timeout_after_x_seconds; SecondsBetweenRetries seconds_between_retries; ServiceEndpoints endpoints; + Optional endpoint_properties; NumberOfNotificationsPerMinute notifications_per_minute_by_priority; Optional > vehicle_make; Optional > vehicle_model; @@ -364,6 +389,9 @@ struct ModuleConfig : CompositeType { Optional > certificate; Optional preloaded_pt; Optional full_app_id_supported; + Optional lock_screen_dismissal_enabled; + + static const std::string kDefaultOemMappingServiceName; public: ModuleConfig(); @@ -373,6 +401,7 @@ struct ModuleConfig : CompositeType { uint16_t timeout_after_x_seconds, const SecondsBetweenRetries& seconds_between_retries, const ServiceEndpoints& endpoints, + const ServiceEndpointProperties& endpoint_properties, const NumberOfNotificationsPerMinute& notifications_per_minute_by_priority); ~ModuleConfig(); @@ -599,6 +628,88 @@ struct DeviceParams : CompositeType { bool Validate() const; }; +struct VehicleDataItem : CompositeType { + public: + static const std::vector kPODTypes; + + static const std::string kInteger; + static const std::string kStruct; + static const std::string kString; + static const std::string kFloat; + static const std::string kDouble; + static const std::string kBoolean; + static const std::string kName; + static const std::string kParams; + + String<1, 255> name; + String<0, 255> type; + String<1, 255> key; + Boolean mandatory; + Optional > params; + + Optional array; + Optional > since; + Optional > until; + Optional removed; + Optional deprecated; + Optional > minvalue; + Optional > maxvalue; + Optional > minsize; + Optional > maxsize; + Optional > minlength; + Optional > maxlength; + + VehicleDataItem(); + VehicleDataItem(const VehicleDataItem& policy_table); + explicit VehicleDataItem(const Json::Value* value__); + + bool operator==(const VehicleDataItem& vd); + + ~VehicleDataItem(); + + Json::Value ToJsonValue() const; + bool is_valid() const; + bool is_initialized() const; + bool struct_not_empty() const; + void ReportErrors(rpc::ValidationReport* report__) const; + virtual void SetPolicyTableType(PolicyTableType pt_type); + + /** + * @brief Validates type of vehicle data item according to + * POD types and generated from API enums. + * @return true if type is valid. + */ + bool ValidateTypes() const; + bool IsPrimitiveType() const; + bool ValidateNaming(std::string str) const; + + private: + bool Validate() const; +}; + +typedef Array VehicleDataItems; + +struct VehicleData : CompositeType { + public: + Optional > schema_version; + Optional schema_items; + + VehicleData(); + VehicleData(const VehicleData& vehicle_data); + VehicleData(const Json::Value* value__); + ~VehicleData(); + + Json::Value ToJsonValue() const; + bool is_valid() const; + bool is_initialized() const; + bool struct_empty() const; + void ReportErrors(rpc::ValidationReport* report__) const; + virtual void SetPolicyTableType(PolicyTableType pt_type); + + private: + bool Validate() const; +}; + struct PolicyTable : CompositeType { public: ApplicationPoliciesSection app_policies_section; @@ -608,6 +719,7 @@ struct PolicyTable : CompositeType { Optional module_meta; Optional usage_and_error_counts; Optional device_data; + Optional vehicle_data; public: PolicyTable(); 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 46c8f40a010..af7effd97f6 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 @@ -114,6 +114,7 @@ + + diff --git a/src/components/policy/policy_external/include/policy/policy_types.h b/src/components/policy/policy_external/include/policy/policy_types.h index 84d9376a93a..ee2d806ba5e 100644 --- a/src/components/policy/policy_external/include/policy/policy_types.h +++ b/src/components/policy/policy_external/include/policy/policy_types.h @@ -34,15 +34,16 @@ #define SRC_COMPONENTS_POLICY_POLICY_EXTERNAL_INCLUDE_POLICY_POLICY_TYPES_H_ #include -#include -#include #include +#include #include +#include #include -#include +#include -#include "utils/helpers.h" +#include "policy/policy_table/types.h" #include "transport_manager/common.h" +#include "utils/helpers.h" namespace policy { @@ -87,6 +88,8 @@ typedef std::string Parameter; typedef std::string RpcName; typedef std::set RPCParams; +typedef rpc::Optional EncryptionRequired; + typedef std::map > HMIPermissions; struct ParameterPermissions : std::map > { @@ -102,6 +105,7 @@ struct ParameterPermissions struct RpcPermissions { HMIPermissions hmi_permissions; ParameterPermissions parameter_permissions; + EncryptionRequired require_encryption; }; typedef std::map Permissions; @@ -118,11 +122,13 @@ typedef std::vector StringArray; enum PermitResult { kRpcAllowed = 0, kRpcDisallowed, kRpcUserDisallowed }; +enum class ResetRetryCountType { kResetWithStatusUpdate = 0, kResetInternally }; + /** - * @struct Stores result of check: - * if HMI Level was allowed for RPC to work in - * and list of parameters allowed for RPC if specified in PT. - */ + * @struct Stores result of check: + * if HMI Level was allowed for RPC to work in + * and list of parameters allowed for RPC if specified in PT. + */ struct CheckPermissionResult { CheckPermissionResult() : hmi_level_permitted(kRpcDisallowed) {} @@ -505,10 +511,11 @@ enum PermissionsCheckResult { RESULT_NICKNAME_MISMATCH, RESULT_PERMISSIONS_REVOKED, RESULT_CONSENT_NEEDED, - RESULT_CONSENT_NOT_REQIURED, + RESULT_CONSENT_NOT_REQUIRED, RESULT_PERMISSIONS_REVOKED_AND_CONSENT_NEEDED, RESULT_REQUEST_TYPE_CHANGED, - RESULT_REQUEST_SUBTYPE_CHANGED + RESULT_REQUEST_SUBTYPE_CHANGED, + RESULT_ENCRYPTION_REQUIRED_FLAG_CHANGED, }; /** diff --git a/src/components/policy/policy_external/include/policy/pt_ext_representation.h b/src/components/policy/policy_external/include/policy/pt_ext_representation.h index 0aa284b7076..f03947268a9 100644 --- a/src/components/policy/policy_external/include/policy/pt_ext_representation.h +++ b/src/components/policy/policy_external/include/policy/pt_ext_representation.h @@ -280,10 +280,10 @@ class PTExtRepresentation : public virtual PTRepresentation { virtual bool GetFunctionalGroupNames(policy::FunctionalGroupNames& names) = 0; /** - * @brief Set app policy to pre_DataConsented policy - * @param app_id Policy ID of application to be changed - * @return true, if succeeded, otherwise - false - */ + * @brief Set app policy to pre_DataConsented policy + * @param app_id Policy ID of application to be changed + * @return true, if succeeded, otherwise - false + */ virtual bool SetPredataPolicy(const std::string& app_id) = 0; /** diff --git a/src/components/policy/policy_external/include/policy/pt_representation.h b/src/components/policy/policy_external/include/policy/pt_representation.h index f25fcc6cab5..d233bbf268c 100644 --- a/src/components/policy/policy_external/include/policy/pt_representation.h +++ b/src/components/policy/policy_external/include/policy/pt_representation.h @@ -33,11 +33,11 @@ #ifndef SRC_COMPONENTS_POLICY_POLICY_EXTERNAL_INCLUDE_POLICY_PT_REPRESENTATION_H_ #define SRC_COMPONENTS_POLICY_POLICY_EXTERNAL_INCLUDE_POLICY_PT_REPRESENTATION_H_ -#include #include -#include "policy/policy_types.h" -#include "policy/policy_table/types.h" +#include #include "policy/policy_settings.h" +#include "policy/policy_table/types.h" +#include "policy/policy_types.h" namespace policy_table = rpc::policy_table_interface_base; @@ -133,11 +133,6 @@ class PTRepresentation { */ virtual bool SecondsBetweenRetries(std::vector* seconds) = 0; - /** - * @brief Get information about vehicle - */ - virtual const VehicleInfo GetVehicleInfo() const = 0; - /** * @brief Allows to update 'vin' field in module_meta table. * @@ -268,10 +263,10 @@ class PTRepresentation { virtual bool IsDefaultPolicy(const std::string& app_id) const = 0; /** - * Checks if the application has pre_data policy - * @param app_id application id - * @return true if application has pre_data policy - */ + * Checks if the application has pre_data policy + * @param app_id application id + * @return true if application has pre_data policy + */ virtual bool IsPredataPolicy(const std::string& app_id) const = 0; /** diff --git a/src/components/policy/policy_external/include/policy/ptu_retry_handler.h b/src/components/policy/policy_external/include/policy/ptu_retry_handler.h new file mode 100644 index 00000000000..79623124e3d --- /dev/null +++ b/src/components/policy/policy_external/include/policy/ptu_retry_handler.h @@ -0,0 +1,57 @@ +/* + Copyright (c) 2019, 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_POLICIES_PTU_RETRY_HANDLER_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_POLICIES_PTU_RETRY_HANDLER_H_ + +namespace policy { + +class PTURetryHandler { + public: + /** + * @brief Check whether allowed retry sequence count is exceeded + * @return bool value - true is allowed count is exceeded, otherwise - false + */ + virtual bool IsAllowedRetryCountExceeded() const = 0; + + /** + * @brief Begins new retry sequence + */ + virtual void OnSystemRequestReceived() = 0; + + /** + * @brief Handle OnSystemRequest from HMI timeout + */ + virtual void RetrySequenceFailed() = 0; +}; +} // namespace policy + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_POLICIES_PTU_RETRY_HANDLER_H_ diff --git a/src/components/policy/policy_external/include/policy/sql_pt_ext_representation.h b/src/components/policy/policy_external/include/policy/sql_pt_ext_representation.h index bd2097cfe3c..889ede9d20f 100644 --- a/src/components/policy/policy_external/include/policy/sql_pt_ext_representation.h +++ b/src/components/policy/policy_external/include/policy/sql_pt_ext_representation.h @@ -34,8 +34,8 @@ #define SRC_COMPONENTS_POLICY_POLICY_EXTERNAL_INCLUDE_POLICY_SQL_PT_EXT_REPRESENTATION_H_ #include -#include "policy/sql_pt_representation.h" #include "policy/pt_ext_representation.h" +#include "policy/sql_pt_representation.h" namespace policy { diff --git a/src/components/policy/policy_external/include/policy/sql_pt_queries.h b/src/components/policy/policy_external/include/policy/sql_pt_queries.h index 5382ff2d6b0..c613cec0d62 100644 --- a/src/components/policy/policy_external/include/policy/sql_pt_queries.h +++ b/src/components/policy/policy_external/include/policy/sql_pt_queries.h @@ -142,6 +142,21 @@ extern const std::string kDeleteModuleTypes; extern const std::string kDeleteAllDevices; extern const std::string kSelectDBVersion; extern const std::string kUpdateDBVersion; +extern const std::string kSelectVehicleDataItem; +extern const std::string kInsertVehicleDataItem; +extern const std::string kDeleteVehicleDataItems; +extern const std::string kInsertVehicleDataItemParams; +extern const std::string kSelectVehicleDataItemParams; +extern const std::string kDeleteVehicleDataItemParams; +extern const std::string kSelectVehicleDataItemWithVersion; +extern const std::string kSelectPrimitiveVehicleDataItems; +extern const std::string kSelectCompositeVehicleDataItemsKey; +extern const std::string kSelectOEMMappingVersion; +extern const std::string kSelectVehicleDataSchemaVersion; +extern const std::string kInsertVehicleDataSchemaVersion; +extern const std::string kSelectEndpointProperties; +extern const std::string kInsertEndpointVersion; + } // namespace sql_pt } // namespace policy diff --git a/src/components/policy/policy_external/include/policy/sql_pt_representation.h b/src/components/policy/policy_external/include/policy/sql_pt_representation.h index 581340ba020..5d2d63a8bd8 100644 --- a/src/components/policy/policy_external/include/policy/sql_pt_representation.h +++ b/src/components/policy/policy_external/include/policy/sql_pt_representation.h @@ -35,15 +35,16 @@ #include #include +#include "policy/policy_table/types.h" #include "policy/pt_representation.h" #include "rpc_base/rpc_base.h" -#include "policy/policy_table/types.h" namespace policy_table = rpc::policy_table_interface_base; namespace utils { namespace dbms { class SQLDatabase; +class SQLQuery; } // namespace dbms } // namespace utils @@ -70,8 +71,6 @@ class SQLPTRepresentation : public virtual PTRepresentation { virtual int TimeoutResponse(); virtual bool SecondsBetweenRetries(std::vector* seconds); virtual bool RefreshDB(); - virtual const VehicleInfo GetVehicleInfo() const; - virtual std::vector GetUserFriendlyMsg( const std::vector& msg_codes, const std::string& language); @@ -124,6 +123,9 @@ class SQLPTRepresentation : public virtual PTRepresentation { policy_table::ConsumerFriendlyMessages* messages) const; virtual bool GatherApplicationPoliciesSection( policy_table::ApplicationPoliciesSection* policies) const; + virtual bool GatherVehicleDataItems( + policy_table::VehicleDataItems* vehicle_data_items) const; + virtual bool GatherVehicleData(policy_table::VehicleData* vehicle_data) const; bool GatherAppGroup(const std::string& app_id, policy_table::Strings* app_groups) const; @@ -159,6 +161,9 @@ class SQLPTRepresentation : public virtual PTRepresentation { virtual bool SaveSpecificAppPolicy( const policy_table::ApplicationPolicies::value_type& app); virtual bool SaveDevicePolicy(const policy_table::DevicePolicy& device); + virtual bool SaveVehicleDataItems( + const policy_table::VehicleDataItems& vehicle_data_items); + virtual bool SaveVehicleData(const policy_table::VehicleData& vehicle_data); virtual bool SaveMessageString(const std::string& type, const std::string& lang, @@ -203,6 +208,26 @@ class SQLPTRepresentation : public virtual PTRepresentation { virtual bool IsDBVersionActual() const OVERRIDE; virtual bool UpdateDBVersion() const OVERRIDE; + policy_table::VehicleDataItems GetVehicleDataItem( + const std::string& name, const std::string& key) const; + bool InsertVehicleDataItem( + const policy_table::VehicleDataItem& vehicle_data_item); + bool VehicleDataItemExists( + const policy_table::VehicleDataItem& vehicle_data_item) const; + + /** + * @brief Retrieves vehicle data items of type Struct (which contains params) + * from the database including these parameters. + * @return Array of parameterized VehicleDataItems (including params) + */ + policy_table::VehicleDataItems SelectCompositeVehicleDataItems() const; + + /** + * @brief Retrieves vehicle data items of non Struct type from the database. + * @return Array of primitive VehicleDataItems + */ + policy_table::VehicleDataItems SelectPrimitiveVehicleDataItems() const; + private: utils::dbms::SQLDatabase* db_; @@ -220,12 +245,17 @@ class SQLPTRepresentation : public virtual PTRepresentation { const int32_t GetDBVersion() const; bool SaveRpcs(int64_t group_id, const policy_table::Rpc& rpcs); bool SaveServiceEndpoints(const policy_table::ServiceEndpoints& endpoints); + bool SaveServiceEndpointProperties( + const policy_table::ServiceEndpointProperties& endpoint_properties); bool SaveSecondsBetweenRetries( const policy_table::SecondsBetweenRetries& seconds); bool SaveNumberOfNotificationsPerMinute( const policy_table::NumberOfNotificationsPerMinute& notifications); bool SaveMessageType(const std::string& type); bool SaveLanguage(const std::string& code); + policy_table::VehicleDataItem PopulateVDIFromQuery( + const utils::dbms::SQLQuery& query) const; + bool DeleteVehicleDataItems() const; bool is_in_memory; bool SaveExternalConsentEntities( diff --git a/src/components/policy/policy_external/include/policy/status.h b/src/components/policy/policy_external/include/policy/status.h index 18789ecf991..336d59e8695 100644 --- a/src/components/policy/policy_external/include/policy/status.h +++ b/src/components/policy/policy_external/include/policy/status.h @@ -75,41 +75,41 @@ class Status { const policy::PolicyTableStatus enum_status); /** - * @brief Destructor - */ + * @brief Destructor + */ virtual ~Status(); /** - * @brief Process event by setting next status in case event can affect - * current status or ignores the event - * @param manager Status manager pointer - * @param event Event which needs to be processed - */ + * @brief Process event by setting next status in case event can affect + * current status or ignores the event + * @param manager Status manager pointer + * @param event Event which needs to be processed + */ virtual void ProcessEvent(UpdateStatusManager* manager, UpdateEvent event) = 0; /** - * @brief Return current status as string value - * @return Status as string - */ + * @brief Return current status as string value + * @return Status as string + */ const std::string get_status_string() const; /** - * @brief Return status as enum value - * @return Status as enum value - */ + * @brief Return status as enum value + * @return Status as enum value + */ PolicyTableStatus get_status() const; /** - * @brief Check whether update is required in terms of status - * @return True if update is required, otherwise - false - */ + * @brief Check whether update is required in terms of status + * @return True if update is required, otherwise - false + */ virtual bool IsUpdateRequired() const; /** - * @brief Check whether update is pending in terms of status - * @return True if update is pending, otherwise - false - */ + * @brief Check whether update is pending in terms of status + * @return True if update is pending, otherwise - false + */ virtual bool IsUpdatePending() const; private: @@ -128,11 +128,11 @@ class UpToDateStatus : public Status { UpToDateStatus(); /** - * @brief Process event by setting next status in case event can affect - * current status or ignores the event - * @param manager Status manager pointer - * @param event Event which needs to be processed - */ + * @brief Process event by setting next status in case event can affect + * current status or ignores the event + * @param manager Status manager pointer + * @param event Event which needs to be processed + */ void ProcessEvent(UpdateStatusManager* manager, UpdateEvent event) OVERRIDE; }; @@ -147,17 +147,17 @@ class UpdateNeededStatus : public Status { UpdateNeededStatus(); /** - * @brief Process event by setting next status in case event can affect - * current status or ignores the event - * @param manager Status manager pointer - * @param event Event which needs to be processed - */ + * @brief Process event by setting next status in case event can affect + * current status or ignores the event + * @param manager Status manager pointer + * @param event Event which needs to be processed + */ void ProcessEvent(UpdateStatusManager* manager, UpdateEvent event) OVERRIDE; /** - * @brief Check whether update is required in terms of status - * @return True if update is required, otherwise - false - */ + * @brief Check whether update is required in terms of status + * @return True if update is required, otherwise - false + */ bool IsUpdateRequired() const OVERRIDE; }; @@ -172,25 +172,25 @@ class UpdatingStatus : public Status { UpdatingStatus(); /** - * @brief Process event by setting next status in case event can affect - * current status or ignores the event - * @param manager Status manager pointer - * @param event Event which needs to be processed - */ + * @brief Process event by setting next status in case event can affect + * current status or ignores the event + * @param manager Status manager pointer + * @param event Event which needs to be processed + */ void ProcessEvent(UpdateStatusManager* manager, UpdateEvent event) OVERRIDE; /** - * @brief Check whether update is required in terms of status - * @return True if update is required, otherwise - false - */ + * @brief Check whether update is required in terms of status + * @return True if update is required, otherwise - false + */ bool IsUpdateRequired() const OVERRIDE; /** - * @brief Check whether update is pending in terms of status - * @return True if update is pending, otherwise - false - */ + * @brief Check whether update is pending in terms of status + * @return True if update is pending, otherwise - false + */ bool IsUpdatePending() const OVERRIDE; }; -} +} // namespace policy #endif // SRC_COMPONENTS_POLICY_POLICY_EXTERNAL_INCLUDE_POLICY_STATUS_H_ 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 3a9e13b83fe..9c0e29407ea 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 @@ -34,14 +34,13 @@ #define SRC_COMPONENTS_POLICY_POLICY_EXTERNAL_INCLUDE_POLICY_UPDATE_STATUS_MANAGER_H_ #include "policy/policy_types.h" -#include "utils/lock.h" -#include "utils/threads/thread.h" -#include "utils/threads/thread_delegate.h" +#include "policy/status.h" #include "utils/conditional_variable.h" #include "utils/lock.h" #include "utils/logger.h" #include "utils/macro.h" -#include "policy/status.h" +#include "utils/threads/thread.h" +#include "utils/threads/thread_delegate.h" namespace policy { @@ -235,6 +234,6 @@ class UpdateStatusManager { UpdateThreadDelegate* update_status_thread_delegate_; threads::Thread* thread_; }; -} +} // namespace policy #endif // SRC_COMPONENTS_POLICY_POLICY_EXTERNAL_INCLUDE_POLICY_UPDATE_STATUS_MANAGER_H_ diff --git a/src/components/policy/policy_external/include/policy/usage_statistics/counter.h b/src/components/policy/policy_external/include/policy/usage_statistics/counter.h index c145bb432ba..047a545150e 100644 --- a/src/components/policy/policy_external/include/policy/usage_statistics/counter.h +++ b/src/components/policy/policy_external/include/policy/usage_statistics/counter.h @@ -34,11 +34,11 @@ #define SRC_COMPONENTS_POLICY_POLICY_EXTERNAL_INCLUDE_POLICY_USAGE_STATISTICS_COUNTER_H_ #include -#include "policy/usage_statistics/statistics_manager.h" #include "policy/usage_statistics/app_stopwatch.h" +#include "policy/usage_statistics/statistics_manager.h" -#include "utils/timer.h" #include "utils/macro.h" +#include "utils/timer.h" namespace usage_statistics { diff --git a/src/components/policy/policy_external/src/cache_manager.cc b/src/components/policy/policy_external/src/cache_manager.cc index 96bb45a6c11..c9ed7865096 100644 --- a/src/components/policy/policy_external/src/cache_manager.cc +++ b/src/components/policy/policy_external/src/cache_manager.cc @@ -33,27 +33,28 @@ #include "policy/cache_manager.h" #include -#include -#include +#include #include -#include +#include +#include #include +#include #include -#include "utils/file_system.h" -#include "utils/helpers.h" -#include "json/reader.h" #include "json/features.h" +#include "json/reader.h" #include "json/writer.h" -#include "utils/logger.h" +#include "policy/policy_helper.h" +#include "policy/policy_table/enums.h" +#include "policy/sql_pt_ext_representation.h" +#include "rpc_base/rpc_base.h" #include "utils/date_time.h" +#include "utils/file_system.h" #include "utils/gen_hash.h" +#include "utils/helpers.h" +#include "utils/logger.h" #include "utils/threads/thread.h" #include "utils/threads/thread_delegate.h" -#include "rpc_base/rpc_base.h" -#include "policy/policy_table/enums.h" -#include "policy/policy_helper.h" -#include "policy/sql_pt_ext_representation.h" namespace policy_table = rpc::policy_table_interface_base; @@ -268,7 +269,8 @@ CacheManager::CacheManager() : CacheManagerInterface() , pt_(new policy_table::Table) , backup_(new SQLPTExtRepresentation()) - , update_required(false) { + , update_required(false) + , removed_custom_vd_items_() { InitBackupThread(); } @@ -325,6 +327,20 @@ const policy_table::Strings& CacheManager::GetGroups(const PTString& app_id) { return pt_->policy_table.app_policies_section.apps[app_id].groups; } +const policy_table::Strings CacheManager::GetPolicyAppIDs() const { + LOG4CXX_AUTO_TRACE(logger_); + sync_primitives::AutoLock auto_lock(cache_lock_); + + const auto apps = pt_->policy_table.app_policies_section.apps; + + policy_table::Strings policy_app_ids; + for (const auto& app : apps) { + policy_app_ids.push_back(app.first); + } + + return policy_app_ids; +} + bool CacheManager::CanAppKeepContext(const std::string& app_id) const { CACHE_MANAGER_CHECK(false); sync_primitives::AutoLock auto_lock(cache_lock_); @@ -738,6 +754,38 @@ bool CacheManager::ApplyUpdate(const policy_table::Table& update_pt) { pt_->policy_table.consumer_friendly_messages.assign_if_valid( update_pt.policy_table.consumer_friendly_messages); + pt_->policy_table.module_config.endpoint_properties = + update_pt.policy_table.module_config.endpoint_properties; + + // Apply update for vehicle data + if (update_pt.policy_table.vehicle_data.is_initialized()) { + policy_table::VehicleDataItems custom_items_before_apply; + if (pt_->policy_table.vehicle_data->schema_items.is_initialized()) { + custom_items_before_apply = + CollectCustomVDItems(*pt_->policy_table.vehicle_data->schema_items); + } + + if (!update_pt.policy_table.vehicle_data->schema_items.is_initialized() || + update_pt.policy_table.vehicle_data->schema_items->empty()) { + pt_->policy_table.vehicle_data->schema_items = + rpc::Optional(); + } else { + policy_table::VehicleDataItems custom_items = CollectCustomVDItems( + *update_pt.policy_table.vehicle_data->schema_items); + + pt_->policy_table.vehicle_data->schema_version = + update_pt.policy_table.vehicle_data->schema_version; + pt_->policy_table.vehicle_data->schema_items = + rpc::Optional(custom_items); + } + + policy_table::VehicleDataItems custom_items_after_apply = + *pt_->policy_table.vehicle_data->schema_items; + const auto& items_diff = CalculateCustomVdItemsDiff( + custom_items_before_apply, custom_items_after_apply); + SetRemovedCustomVdItems(items_diff); + } + ResetCalculatedPermissions(); Backup(); @@ -748,6 +796,21 @@ bool CacheManager::ApplyUpdate(const policy_table::Table& update_pt) { return true; } +policy_table::VehicleDataItems CacheManager::CollectCustomVDItems( + const policy_table::VehicleDataItems& vd_items) { + policy_table::VehicleDataItems result_items; + for (auto& item : vd_items) { + const std::string i_name = "VEHICLEDATA_" + std::string(item.name); + const std::string vd_name = boost::to_upper_copy(i_name); + const bool is_standard = + policy_table::EnumSchemaItemFactory::IsRPCSpecVehicleDataType(vd_name); + if (!is_standard) { + result_items.push_back(item); + } + } + return result_items; +} + void CacheManager::GetHMIAppTypeAfterUpdate( std::map& app_hmi_types) { LOG4CXX_AUTO_TRACE(logger_); @@ -904,9 +967,9 @@ bool CacheManager::HasDeviceSpecifiedConsent(const std::string& device_id, return false; } const std::string consent = is_allowed ? "allowed" : "disallowed"; - LOG4CXX_INFO(logger_, - "DeviceGetDeviceGroupsFromPolicies is already " << consent - << "."); + LOG4CXX_INFO( + logger_, + "DeviceGetDeviceGroupsFromPolicies is already " << consent << "."); return true; } @@ -1217,14 +1280,8 @@ void CacheManager::CheckPermissions(const PTString& app_id, if (rpc_param.hmi_levels.end() != hmi_iter) { result.hmi_level_permitted = PermitResult::kRpcAllowed; - policy_table::Parameters::const_iterator params_iter = - rpc_param.parameters->begin(); - policy_table::Parameters::const_iterator params_iter_end = - rpc_param.parameters->end(); - - for (; params_iter != params_iter_end; ++params_iter) { - result.list_of_allowed_params.insert( - policy_table::EnumToJsonString(*params_iter)); + for (const auto& param : *rpc_param.parameters) { + result.list_of_allowed_params.insert(std::string(param)); } } } @@ -1373,20 +1430,27 @@ bool CacheManager::SecondsBetweenRetries(std::vector& seconds) { return true; } -const policy::VehicleInfo CacheManager::GetVehicleInfo() const { - CACHE_MANAGER_CHECK(VehicleInfo()); +const std::vector +CacheManager::GetVehicleDataItems() const { + CACHE_MANAGER_CHECK(std::vector()); sync_primitives::AutoLock auto_lock(cache_lock_); - policy_table::ModuleConfig& module_config = pt_->policy_table.module_config; - VehicleInfo vehicle_info; - vehicle_info.vehicle_make = *module_config.vehicle_make; - vehicle_info.vehicle_model = *module_config.vehicle_model; - vehicle_info.vehicle_year = *module_config.vehicle_year; - LOG4CXX_DEBUG( - logger_, - "Vehicle info (make, model, year):" << vehicle_info.vehicle_make << "," - << vehicle_info.vehicle_model << "," - << vehicle_info.vehicle_year); - return vehicle_info; + + if (pt_->policy_table.vehicle_data.is_initialized() && + pt_->policy_table.vehicle_data->schema_items.is_initialized()) { + return *(pt_->policy_table.vehicle_data->schema_items); + } + + return std::vector(); +} + +std::vector +CacheManager::GetRemovedVehicleDataItems() const { + CACHE_MANAGER_CHECK(std::vector()); + return removed_custom_vd_items_; +} + +Json::Value CacheManager::GetPolicyTableData() const { + return pt_->policy_table.ToJsonValue(); } void CacheManager::GetEnabledCloudApps( @@ -1561,10 +1625,44 @@ bool CacheManager::UnknownRPCPassthroughAllowed( return false; } +const boost::optional CacheManager::LockScreenDismissalEnabledState() + const { + boost::optional empty; + CACHE_MANAGER_CHECK(empty); + sync_primitives::AutoLock auto_lock(cache_lock_); + policy_table::ModuleConfig& module_config = pt_->policy_table.module_config; + if (module_config.lock_screen_dismissal_enabled.is_initialized()) { + return boost::optional(*module_config.lock_screen_dismissal_enabled); + } + return empty; +} + +const boost::optional +CacheManager::LockScreenDismissalWarningMessage( + const std::string& language) const { + LOG4CXX_AUTO_TRACE(logger_); + boost::optional empty; + CACHE_MANAGER_CHECK(empty); + + const std::string lock_screen_dismissal_warning_message = + "LockScreenDismissalWarning"; + sync_primitives::AutoLock auto_lock(cache_lock_); + + std::vector msg_codes{lock_screen_dismissal_warning_message}; + + const auto messages = GetUserFriendlyMsg(msg_codes, language, "en-us"); + + if (messages.empty() || messages[0].text_body.empty()) { + return empty; + } + + return boost::optional(messages[0].text_body); +} + std::vector CacheManager::GetUserFriendlyMsg( const std::vector& msg_codes, const std::string& language, - const std::string& active_hmi_language) { + const std::string& active_hmi_language) const { LOG4CXX_AUTO_TRACE(logger_); std::vector result; CACHE_MANAGER_CHECK(result); @@ -1621,11 +1719,19 @@ std::vector CacheManager::GetUserFriendlyMsg( void CacheManager::GetUpdateUrls(const uint32_t service_type, EndpointUrls& out_end_points) { - std::stringstream service_type_stream; - service_type_stream << (service_type <= 9 ? "0x0" : "0x") << service_type; - - const std::string service_type_str = service_type_stream.str(); - GetUpdateUrls(service_type_str, out_end_points); + auto find_hexademical = + [service_type](policy_table::ServiceEndpoints::value_type end_point) { + uint32_t decimal; + std::istringstream(end_point.first) >> std::hex >> decimal; + return end_point.first.compare(0, 2, "0x") == 0 && + decimal == service_type; + }; + auto& end_points = pt_->policy_table.module_config.endpoints; + const auto end_point = + std::find_if(end_points.begin(), end_points.end(), find_hexademical); + if (end_point != end_points.end()) { + GetUpdateUrls(end_point->first, out_end_points); + } } void CacheManager::GetUpdateUrls(const std::string& service_type, @@ -1835,6 +1941,46 @@ void CacheManager::CheckSnapshotInitialization() { } } +policy_table::VehicleDataItems CacheManager::CalculateCustomVdItemsDiff( + const policy_table::VehicleDataItems& items_before, + const policy_table::VehicleDataItems& items_after) const { + LOG4CXX_AUTO_TRACE(logger_); + if (items_before.empty()) { + LOG4CXX_DEBUG(logger_, "No custom VD items found in policy"); + return policy_table::VehicleDataItems(); + } + + if (items_after.empty()) { + LOG4CXX_DEBUG(logger_, + "All custom VD items were removed after policy update"); + return items_before; + } + + policy_table::VehicleDataItems removed_items; + for (auto& item_to_search : items_before) { + auto item_predicate = + [&item_to_search](const policy_table::VehicleDataItem& item_to_check) { + return item_to_search.name == item_to_check.name; + }; + + auto it = + std::find_if(items_after.begin(), items_after.end(), item_predicate); + if (items_after.end() == it) { + removed_items.push_back(item_to_search); + } + } + + LOG4CXX_DEBUG(logger_, + "Found " << removed_items.size() << " removed VD items"); + return removed_items; +} + +void CacheManager::SetRemovedCustomVdItems( + const policy_table::VehicleDataItems& removed_items) { + LOG4CXX_AUTO_TRACE(logger_); + removed_custom_vd_items_ = removed_items; +} + void CacheManager::PersistData() { LOG4CXX_AUTO_TRACE(logger_); if (backup_.use_count() != 0) { @@ -1966,6 +2112,14 @@ std::shared_ptr CacheManager::GenerateSnapshot() { sync_primitives::AutoLock auto_lock(cache_lock_); snapshot_->policy_table = pt_->policy_table; + if (pt_->policy_table.vehicle_data.is_initialized()) { + snapshot_->policy_table.vehicle_data = + rpc::Optional(); + snapshot_->policy_table.vehicle_data->mark_initialized(); + snapshot_->policy_table.vehicle_data->schema_version = + pt_->policy_table.vehicle_data->schema_version; + } + snapshot_->SetPolicyTableType(policy_table::PT_SNAPSHOT); CheckSnapshotInitialization(); @@ -2189,9 +2343,9 @@ bool CacheManager::CleanupUnpairedDevices() { LOG4CXX_DEBUG(logger_, "Device_data size is: " << device_data.size()); device_data.erase(it_device); - LOG4CXX_INFO(logger_, - "Device id " << *iter - << " had been deleted from device_data section."); + LOG4CXX_INFO( + logger_, + "Device id " << *iter << " had been deleted from device_data section."); LOG4CXX_DEBUG(logger_, "Device_data size is: " << device_data.size()); } is_unpaired_.clear(); @@ -2483,6 +2637,8 @@ bool CacheManager::Init(const std::string& file_name, } else { rpc::ValidationReport report("policy_table"); snapshot->ReportErrors(&report); + LOG4CXX_DEBUG(logger_, + "Validation report: " << rpc::PrettyFormat(report)); ex_backup_->RemoveDB(); } } break; @@ -2547,7 +2703,6 @@ bool CacheManager::LoadFromFile(const std::string& file_name, LOG4CXX_FATAL(logger_, "Failed to read policy table source file."); return false; } - Json::Value value; Json::Reader reader(Json::Features::strictMode()); std::string json(json_string.begin(), json_string.end()); @@ -2586,10 +2741,14 @@ bool CacheManager::LoadFromFile(const std::string& file_name, bool CacheManager::ResetPT(const std::string& file_name) { LOG4CXX_AUTO_TRACE(logger_); is_unpaired_.clear(); + + backuper_->WaitForBackupIsDone(); + if (!backup_->RefreshDB()) { LOG4CXX_ERROR(logger_, "Can't re-create policy database. Reset failed."); return false; } + sync_primitives::AutoLock lock(cache_lock_); pt_.reset(new policy_table::Table()); const bool result = LoadFromFile(file_name, *pt_); @@ -2768,7 +2927,7 @@ ExternalConsentStatus CacheManager::GetExternalConsentEntities() { policy_table::DisallowedByExternalConsentEntities::const_iterator it_2 = (*it->second.disallowed_by_external_consent_entities_off).begin(); for (; it_2 != - (*it->second.disallowed_by_external_consent_entities_off).end(); + (*it->second.disallowed_by_external_consent_entities_off).end(); ++it_2) { items.insert(ExternalConsentStatusItem( it_2->entity_type, it_2->entity_id, EntityStatus::kStatusOff)); @@ -2886,6 +3045,7 @@ bool CacheManager::MergePreloadPT(const std::string& file_name) { MergeFG(new_table, current); MergeAP(new_table, current); MergeCFM(new_table, current); + MergeVD(new_table, current); Backup(); } return true; @@ -2917,8 +3077,9 @@ void CacheManager::MergeFG(const policy_table::PolicyTable& new_pt, void CacheManager::MergeAP(const policy_table::PolicyTable& new_pt, policy_table::PolicyTable& pt) { LOG4CXX_AUTO_TRACE(logger_); - pt.app_policies_section.device = const_cast( - new_pt).app_policies_section.device; + pt.app_policies_section.device = + const_cast(new_pt) + .app_policies_section.device; pt.app_policies_section.apps[kDefaultId] = const_cast(new_pt) @@ -2952,6 +3113,12 @@ void CacheManager::MergeCFM(const policy_table::PolicyTable& new_pt, } } +void CacheManager::MergeVD(const policy_table::PolicyTable& new_pt, + policy_table::PolicyTable& pt) { + LOG4CXX_AUTO_TRACE(logger_); + pt.vehicle_data.assign_if_valid(new_pt.vehicle_data); +} + void CacheManager::InitBackupThread() { LOG4CXX_AUTO_TRACE(logger_); backuper_ = new BackgroundBackuper(this); @@ -2993,6 +3160,7 @@ void CacheManager::OnDeviceSwitching(const std::string& device_id_from, CacheManager::BackgroundBackuper::BackgroundBackuper( CacheManager* cache_manager) : cache_manager_(cache_manager) + , backup_is_in_progress_(false) , stop_flag_(false) , new_data_available_(false) { LOG4CXX_AUTO_TRACE(logger_); @@ -3017,13 +3185,23 @@ void CacheManager::BackgroundBackuper::threadMain() { LOG4CXX_AUTO_TRACE(logger_); sync_primitives::AutoLock lock(need_backup_lock_); while (!stop_flag_) { + backup_is_in_progress_.exchange(true); { sync_primitives::AutoUnlock need_backup_lock(need_backup_lock_); InternalBackup(); } + + { + LOG4CXX_DEBUG(logger_, "Backup is done"); + sync_primitives::AutoLock auto_lock(backup_done_lock_); + backup_is_in_progress_.exchange(false); + backup_done_.Broadcast(); + } + if (new_data_available_ || stop_flag_) { continue; } + LOG4CXX_DEBUG(logger_, "Wait for a next backup"); backup_notifier_.Wait(need_backup_lock_); } @@ -3043,4 +3221,54 @@ void CacheManager::BackgroundBackuper::DoBackup() { backup_notifier_.NotifyOne(); } +void CacheManager::BackgroundBackuper::WaitForBackupIsDone() { + LOG4CXX_AUTO_TRACE(logger_); + sync_primitives::AutoLock auto_lock(backup_done_lock_); + if (backup_is_in_progress_) { + backup_done_.Wait(auto_lock); + } +} + +EncryptionRequired CacheManager::GetAppEncryptionRequiredFlag( + const std::string& application) const { + LOG4CXX_AUTO_TRACE(logger_); + sync_primitives::AutoLock auto_lock(cache_lock_); + + return pt_->policy_table.app_policies_section.apps[application] + .encryption_required; +} + +EncryptionRequired CacheManager::GetFunctionalGroupingEncryptionRequiredFlag( + const std::string& functional_group) const { + LOG4CXX_AUTO_TRACE(logger_); + sync_primitives::AutoLock auto_lock(cache_lock_); + + const auto& functional_groupings = pt_->policy_table.functional_groupings; + + const auto& grouping_itr = functional_groupings.find(functional_group); + if (grouping_itr == functional_groupings.end()) { + LOG4CXX_WARN(logger_, "Group " << functional_group << " not found"); + return rpc::Optional(rpc::Boolean(false)); + } + + return (*grouping_itr).second.encryption_required; +} + +void CacheManager::GetApplicationParams( + const std::string& application_name, + policy_table::ApplicationParams& application_params) const { + LOG4CXX_AUTO_TRACE(logger_); + sync_primitives::AutoLock auto_lock(cache_lock_); + + const auto apps = pt_->policy_table.app_policies_section.apps; + const auto it = apps.find(application_name); + if (apps.end() == it) { + LOG4CXX_WARN(logger_, + "Application " << application_name << " was not found"); + return; + } + + application_params = (*it).second; +} + } // namespace policy diff --git a/src/components/policy/policy_external/src/policy_helper.cc b/src/components/policy/policy_external/src/policy_helper.cc index c9df969bd1b..98e5b5b3c17 100644 --- a/src/components/policy/policy_external/src/policy_helper.cc +++ b/src/components/policy/policy_external/src/policy_helper.cc @@ -30,13 +30,13 @@ POSSIBILITY OF SUCH DAMAGE. */ +#include "policy/policy_helper.h" +#include #include #include -#include -#include "utils/logger.h" -#include "utils/custom_string.h" -#include "policy/policy_helper.h" #include "policy/policy_manager_impl.h" +#include "utils/custom_string.h" +#include "utils/logger.h" namespace policy { @@ -46,7 +46,8 @@ namespace { CREATE_LOGGERPTR_GLOBAL(logger_, "Policy") -bool Compare(const StringsValueType& first, const StringsValueType& second) { +bool CompareStrings(const StringsValueType& first, + const StringsValueType& second) { const std::string& first_str = first; const std::string& second_str = second; return (strcasecmp(first_str.c_str(), second_str.c_str()) < 0); @@ -113,7 +114,7 @@ bool operator!=(const policy_table::ApplicationParams& first, for (; it_first != it_first_end; ++it_first) { CompareGroupName gp(*it_first); StringsConstItr it = std::find_if(it_second, it_second_end, gp); - if (it_first_end == it) { + if (it_second_end == it) { return true; } } @@ -137,10 +138,10 @@ bool policy::CheckAppPolicy::HasRevokedGroups( snapshot_->policy_table.app_policies_section.apps.find(app_policy.first); policy_table::Strings groups_new = app_policy.second.groups; - std::sort(groups_new.begin(), groups_new.end(), Compare); + std::sort(groups_new.begin(), groups_new.end(), CompareStrings); policy_table::Strings groups_curr = (*it).second.groups; - std::sort(groups_curr.begin(), groups_curr.end(), Compare); + std::sort(groups_curr.begin(), groups_curr.end(), CompareStrings); StringsConstItr it_groups_new = groups_new.begin(); StringsConstItr it_groups_new_end = groups_new.end(); @@ -154,7 +155,7 @@ bool policy::CheckAppPolicy::HasRevokedGroups( it_groups_new, it_groups_new_end, std::back_inserter(revoked_group_list), - Compare); + CompareStrings); // Remove groups which are not required user consent policy_table::Strings::iterator it_revoked = revoked_group_list.begin(); @@ -174,6 +175,76 @@ bool policy::CheckAppPolicy::HasRevokedGroups( return !revoked_group_list.empty(); } +bool policy::CheckAppPolicy::HasUpdatedGroups( + const policy::AppPoliciesValueType& app_policy, + policy_table::Strings* updated_groups) const { + AppPoliciesConstItr it = + snapshot_->policy_table.app_policies_section.apps.find(app_policy.first); + + policy_table::Strings groups_new = app_policy.second.groups; + std::sort(groups_new.begin(), groups_new.end(), CompareStrings); + + policy_table::Strings groups_curr = (*it).second.groups; + std::sort(groups_curr.begin(), groups_curr.end(), CompareStrings); + + policy_table::Strings intersection_list; + std::set_intersection(groups_new.begin(), + groups_new.end(), + groups_curr.begin(), + groups_curr.end(), + std::back_inserter(intersection_list)); + + auto IsGroupContentUpdated = + [this](const StringsValueType& groupName) -> bool { + const auto& func_group_from_update = + update_->policy_table.functional_groupings.find(groupName); + const auto& func_group_from_snapshot = + snapshot_->policy_table.functional_groupings.find(groupName); + + const auto& update_fg_rpcs = func_group_from_update->second.rpcs; + const auto& snapshot_fg_rpcs = func_group_from_snapshot->second.rpcs; + + if (update_fg_rpcs.is_null() || snapshot_fg_rpcs.is_null()) { + return !(update_fg_rpcs.is_null() && snapshot_fg_rpcs.is_null()); + } + + if (update_fg_rpcs.size() != snapshot_fg_rpcs.size()) { + return true; + } + + for (const auto& rpc : update_fg_rpcs) { + const auto& old_rpc = snapshot_fg_rpcs.find(rpc.first); + if (snapshot_fg_rpcs.end() == old_rpc) { + return true; + } + + const bool hmi_levels_same = + old_rpc->second.hmi_levels == rpc.second.hmi_levels; + const bool parameters_same = + *(old_rpc->second.parameters) == *(rpc.second.parameters); + + if (!hmi_levels_same || !parameters_same) { + return true; + } + } + + return false; + }; + + policy_table::Strings updated_group_list; + for (const auto& item : intersection_list) { + if (IsGroupContentUpdated(item)) { + updated_group_list.push_back(item); + } + } + + if (updated_groups) { + *updated_groups = updated_group_list; + } + + return !updated_group_list.empty(); +} + bool policy::CheckAppPolicy::HasNewGroups( const policy::AppPoliciesValueType& app_policy, policy_table::Strings* new_groups) const { @@ -181,10 +252,10 @@ bool policy::CheckAppPolicy::HasNewGroups( snapshot_->policy_table.app_policies_section.apps.find(app_policy.first); policy_table::Strings groups_new = app_policy.second.groups; - std::sort(groups_new.begin(), groups_new.end(), Compare); + std::sort(groups_new.begin(), groups_new.end(), CompareStrings); policy_table::Strings groups_curr = (*it).second.groups; - std::sort(groups_curr.begin(), groups_curr.end(), Compare); + std::sort(groups_curr.begin(), groups_curr.end(), CompareStrings); StringsConstItr it_groups_new = groups_new.begin(); StringsConstItr it_groups_new_end = groups_new.end(); @@ -192,13 +263,55 @@ bool policy::CheckAppPolicy::HasNewGroups( StringsConstItr it_groups_curr = groups_curr.begin(); StringsConstItr it_groups_curr_end = groups_curr.end(); + auto CompareGroupContent = + [this](const StringsValueType& update_group_name, + const StringsValueType& snapshot_group_name) -> bool { + if (CompareStrings(update_group_name, snapshot_group_name)) { + return true; + } + + const auto& func_group_from_update = + update_->policy_table.functional_groupings.find(update_group_name); + const auto& func_group_from_snapshot = + snapshot_->policy_table.functional_groupings.find(snapshot_group_name); + + const auto& update_fg_rpcs = func_group_from_update->second.rpcs; + const auto& snapshot_fg_rpcs = func_group_from_snapshot->second.rpcs; + + if (update_fg_rpcs.is_null() || snapshot_fg_rpcs.is_null()) { + return !(update_fg_rpcs.is_null() && snapshot_fg_rpcs.is_null()); + } + + if (update_fg_rpcs.size() != snapshot_fg_rpcs.size()) { + return true; + } + + for (const auto& rpc : update_fg_rpcs) { + const auto& old_rpc = snapshot_fg_rpcs.find(rpc.first); + if (snapshot_fg_rpcs.end() == old_rpc) { + return true; + } + + const bool hmi_levels_same = + old_rpc->second.hmi_levels == rpc.second.hmi_levels; + const bool parameters_same = + *(old_rpc->second.parameters) == *(rpc.second.parameters); + + if (!hmi_levels_same || !parameters_same) { + return true; + } + } + + return false; + }; + policy_table::Strings new_group_list; std::set_difference(it_groups_new, it_groups_new_end, it_groups_curr, it_groups_curr_end, std::back_inserter(new_group_list), - Compare); + CompareGroupContent); if (new_groups) { *new_groups = new_group_list; @@ -210,14 +323,23 @@ bool policy::CheckAppPolicy::HasNewGroups( bool policy::CheckAppPolicy::HasConsentNeededGroups( const policy::AppPoliciesValueType& app_policy) const { policy_table::Strings new_groups; - if (!HasNewGroups(app_policy, &new_groups)) { + policy_table::Strings updated_groups; + if (!HasNewGroups(app_policy, &new_groups) && + !HasUpdatedGroups(app_policy, &updated_groups)) { return false; } - StringsConstItr it_new = new_groups.begin(); - StringsConstItr it_new_end = new_groups.end(); - for (; it_new != it_new_end; ++it_new) { - if (IsConsentRequired(app_policy.first, *it_new)) { + policy_table::Strings groups_to_check_consent; + std::set_union(new_groups.begin(), + new_groups.end(), + updated_groups.begin(), + updated_groups.end(), + std::back_inserter(groups_to_check_consent)); + + StringsConstItr it = groups_to_check_consent.begin(); + StringsConstItr it_end = groups_to_check_consent.end(); + for (; it != it_end; ++it) { + if (IsConsentRequired(app_policy.first, *it)) { return true; } } @@ -360,16 +482,16 @@ bool CheckAppPolicy::operator()(const AppPoliciesValueType& app_policy) { } if (RESULT_NO_CHANGES == result) { - LOG4CXX_INFO(logger_, - "Permissions for application:" << app_id - << " wasn't changed."); + LOG4CXX_INFO( + logger_, + "Permissions for application:" << app_id << " wasn't changed."); AddResult(app_id, result); return true; } - LOG4CXX_INFO(logger_, - "Permissions for application:" << app_id - << " have been changed."); + LOG4CXX_INFO( + logger_, + "Permissions for application:" << app_id << " have been changed."); if (!IsPredefinedApp(app_policy)) { SetPendingPermissions(app_policy, result, permissions_diff); @@ -452,14 +574,20 @@ PermissionsCheckResult CheckAppPolicy::CheckPermissionsChanges( bool has_new_groups = HasNewGroups(app_policy); + const bool encryption_required_flag_changed = + IsEncryptionRequiredFlagChanged(app_policy); + bool has_updated_groups = HasUpdatedGroups(app_policy); + if (has_revoked_groups && has_consent_needed_groups) { return RESULT_PERMISSIONS_REVOKED_AND_CONSENT_NEEDED; } else if (has_revoked_groups) { return RESULT_PERMISSIONS_REVOKED; } else if (has_consent_needed_groups) { return RESULT_CONSENT_NEEDED; - } else if (has_new_groups) { - return RESULT_CONSENT_NOT_REQIURED; + } else if (has_new_groups || has_updated_groups) { + return RESULT_CONSENT_NOT_REQUIRED; + } else if (encryption_required_flag_changed) { + return RESULT_ENCRYPTION_REQUIRED_FLAG_CHANGED; } return RESULT_NO_CHANGES; @@ -540,11 +668,98 @@ bool CheckAppPolicy::IsRequestSubTypeChanged( return diff.size(); } +bool CheckAppPolicy::IsEncryptionRequiredFlagChanged( + const AppPoliciesValueType& app_policy) const { + LOG4CXX_AUTO_TRACE(logger_); + auto get_app_encryption_needed = + [](const std::string& policy_app_id, + policy_table::ApplicationPolicies& policies) + -> rpc::Optional { + auto it = policies.find(policy_app_id); + if (policies.end() == it) { + LOG4CXX_WARN(logger_, "App is not present in policies" << policy_app_id); + return rpc::Optional(false); + } + return it->second.encryption_required; + }; + + auto get_app_groups = + [](const std::string& policy_app_id, + policy_table::ApplicationPolicies& policies) -> policy_table::Strings { + policy_table::Strings result; + auto it = policies.find(policy_app_id); + if (policies.end() == it) { + LOG4CXX_WARN(logger_, "App is not present in policies" << policy_app_id); + return result; + } + auto& groups = it->second.groups; + std::copy(groups.begin(), groups.end(), std::back_inserter(result)); + return result; + }; + + auto get_app_rpcs = [](const std::string group_name, + const FunctionalGroupings& groups) + -> rpc::Optional { + auto it = groups.find(group_name); + if (it == groups.end()) { + return rpc::Optional(); + } + return rpc::Optional(it->second); + }; + + const auto snapshot_groups = get_app_groups( + app_policy.first, snapshot_->policy_table.app_policies_section.apps); + const auto update_groups = get_app_groups( + app_policy.first, update_->policy_table.app_policies_section.apps); + + auto get_resulting_encryption_required_flag_for_app_groups = + [this, &get_app_rpcs]( + const rpc::policy_table_interface_base::Strings& app_groups, + const std::shared_ptr pt) { + for (const auto& group : app_groups) { + const auto rpcs = + get_app_rpcs(group, pt->policy_table.functional_groupings); + if (*rpcs->encryption_required) { + return true; + } + } + + return false; + }; + + auto group_res_en_flag_changed = + [this, &get_resulting_encryption_required_flag_for_app_groups]( + const rpc::policy_table_interface_base::Strings& snapshot_groups, + const rpc::policy_table_interface_base::Strings& update_groups) { + return get_resulting_encryption_required_flag_for_app_groups( + snapshot_groups, snapshot_) != + get_resulting_encryption_required_flag_for_app_groups( + update_groups, update_); + }; + + const auto snapshot_app_encryption_needed = get_app_encryption_needed( + app_policy.first, snapshot_->policy_table.app_policies_section.apps); + const auto update_app_encryption_needed = get_app_encryption_needed( + app_policy.first, update_->policy_table.app_policies_section.apps); + + const bool app_encryption_needed_changed = + (snapshot_app_encryption_needed.is_initialized() != + update_app_encryption_needed.is_initialized()) || + (*snapshot_app_encryption_needed != *update_app_encryption_needed); + + if ((!update_app_encryption_needed.is_initialized() || + *update_app_encryption_needed) && + group_res_en_flag_changed(snapshot_groups, update_groups)) { + return true; + } + + return app_encryption_needed_changed; +} + void FillActionsForAppPolicies::operator()( const policy::CheckAppPolicyResults::value_type& value) { const std::string app_id = value.first; - const policy_table::ApplicationPolicies::const_iterator app_policy = - app_policies_.find(app_id); + const auto app_policy = app_policies_.find(app_id); if (app_policies_.end() == app_policy) { return; @@ -563,10 +778,11 @@ void FillActionsForAppPolicies::operator()( case RESULT_PERMISSIONS_REVOKED_AND_CONSENT_NEEDED: actions_[app_id].is_consent_needed = true; break; - case RESULT_CONSENT_NOT_REQIURED: + case RESULT_CONSENT_NOT_REQUIRED: case RESULT_PERMISSIONS_REVOKED: case RESULT_REQUEST_TYPE_CHANGED: case RESULT_REQUEST_SUBTYPE_CHANGED: + case RESULT_ENCRYPTION_REQUIRED_FLAG_CHANGED: break; case RESULT_NO_CHANGES: default: @@ -641,9 +857,11 @@ void FillNotificationData::UpdateParameters( // 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 + // 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 + // among all of the possible allowed permissions scenarios for the RPC + // (and // parameter/or HMI level) defined by each of the functional groups. // Due to requirements SDL must consider cases when 'parameters' section is @@ -668,8 +886,7 @@ void FillNotificationData::UpdateParameters( } for (; it_parameters != it_parameters_end; ++it_parameters) { - out_parameter[current_key_].insert( - policy_table::EnumToJsonString(*it_parameters)); + out_parameter[current_key_].insert(*it_parameters); } // We should reset ALL DISALLOWED flags if at least one parameter is allowed @@ -734,7 +951,8 @@ void FillNotificationData::ExcludeSame(RpcPermissions& rpc) { } } - // Removing disallowed parameters from allowed and undefined (by user consent) + // Removing disallowed parameters from allowed and undefined (by user + // consent) if (rpc.parameter_permissions.end() != it_parameter_user_disallowed) { if (rpc.parameter_permissions.end() != it_parameter_allowed) { ExcludeSameParameters(rpc.parameter_permissions[kAllowedKey], @@ -841,10 +1059,31 @@ bool ProcessFunctionalGroup::operator()(const StringsValueType& group_name) { undefined_group_consent_, does_require_user_consent); std::for_each(rpcs.begin(), rpcs.end(), filler); + const auto encryption_required = (*it).second.encryption_required; + FillEncryptionFlagForRpcs(rpcs, encryption_required); } return true; } +void ProcessFunctionalGroup::FillEncryptionFlagForRpcs( + const policy_table::Rpc& rpcs, + const EncryptionRequired encryption_required) { + auto update_encryption_required = [](EncryptionRequired& current, + const EncryptionRequired& incoming) { + if (!incoming.is_initialized()) { + return; + } + if (current.is_initialized() && *current) { + return; + } + current = incoming; + }; + for (const auto& rpc : rpcs) { + auto& item = data_[rpc.first]; + update_encryption_required(item.require_encryption, encryption_required); + } +} + GroupConsent ProcessFunctionalGroup::GetGroupState( const std::string& group_name) { std::vector::const_iterator it = 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 742435098ee..6868b9060c1 100644 --- a/src/components/policy/policy_external/src/policy_manager_impl.cc +++ b/src/components/policy/policy_external/src/policy_manager_impl.cc @@ -32,33 +32,28 @@ #include "policy/policy_manager_impl.h" #include -#include -#include +#include #include #include +#include +#include #include -#include +#include "config_profile/profile.h" #include "json/reader.h" #include "json/writer.h" +#include "policy/cache_manager.h" +#include "policy/policy_helper.h" #include "policy/policy_table.h" #include "policy/pt_representation.h" -#include "policy/policy_helper.h" +#include "policy/update_status_manager.h" +#include "utils/date_time.h" #include "utils/file_system.h" #include "utils/logger.h" -#include "utils/date_time.h" -#include "policy/cache_manager.h" -#include "policy/update_status_manager.h" -#include "config_profile/profile.h" #include "policy/access_remote.h" #include "policy/access_remote_impl.h" +#include "utils/timer_task_impl.h" -policy::PolicyManager* CreateManager() { - return new policy::PolicyManagerImpl(); -} -void DeleteManager(policy::PolicyManager* pm) { - delete pm; -} namespace { /** @@ -218,7 +213,8 @@ PolicyManagerImpl::PolicyManagerImpl() , retry_sequence_timeout_(60) , retry_sequence_index_(0) , ignition_check(true) - , retry_sequence_url_(0, 0, "") {} + , retry_sequence_url_(0, 0, "") + , is_ptu_in_progress_(false) {} PolicyManagerImpl::PolicyManagerImpl(bool in_memory) : PolicyManager() @@ -230,9 +226,9 @@ PolicyManagerImpl::PolicyManagerImpl(bool in_memory) , retry_sequence_index_(0) , ignition_check(true) , retry_sequence_url_(0, 0, "") - , wrong_ptu_update_received_(false) , send_on_update_sent_out_(false) - , trigger_ptu_(false) {} + , trigger_ptu_(false) + , is_ptu_in_progress_(false) {} void PolicyManagerImpl::set_listener(PolicyListener* listener) { listener_ = listener; @@ -297,7 +293,9 @@ void FilterInvalidFunctions(policy_table::Rpc& rpcs) { * schema * @param rpc_parameters parameters to filter */ -void FilterInvalidRPCParameters(policy_table::RpcParameters& rpc_parameters) { +void FilterInvalidRPCParameters( + policy_table::RpcParameters& rpc_parameters, + const std::vector& vehicle_data_items) { policy_table::HmiLevels valid_hmi_levels; for (const auto& hmi_level : rpc_parameters.hmi_levels) { if (hmi_level.is_valid()) { @@ -306,10 +304,31 @@ void FilterInvalidRPCParameters(policy_table::RpcParameters& rpc_parameters) { } rpc_parameters.hmi_levels.swap(valid_hmi_levels); + auto ParamExists = + [&vehicle_data_items](const rpc::String<0, 255>& param_name) { + policy_table::Parameter parameter_enum; + if (policy_table::EnumFromJsonString(param_name, ¶meter_enum)) { + return true; + } + + // In case when this collection is empty that means collection is not + // initialized + if (vehicle_data_items.empty()) { + return false; + } + + for (const auto& vdi : vehicle_data_items) { + if (param_name == vdi.name) { + return true; + } + } + return false; + }; + policy_table::Parameters valid_params; const policy_table::Parameters& params = *(rpc_parameters.parameters); for (const auto& param : params) { - if (param.is_valid()) { + if (param.is_valid() && ParamExists(param)) { valid_params.push_back(param); } } @@ -399,7 +418,9 @@ void FilterInvalidApplicationParameters( * @brief FilterPolicyTable filter values that not present in schema * @param pt policy table to filter */ -void FilterPolicyTable(policy_table::PolicyTable& pt) { +void FilterPolicyTable( + policy_table::PolicyTable& pt, + const std::vector& current_vd_items) { policy_table::ModuleConfig& module_config = pt.module_config; if (module_config.is_initialized() && module_config.notifications_per_minute_by_priority.is_initialized()) { @@ -418,14 +439,24 @@ void FilterPolicyTable(policy_table::PolicyTable& pt) { policy_table::Rpc& rpcs = group.second.rpcs; FilterInvalidFunctions(rpcs); + policy_table::VehicleDataItems vehicle_data_items; + + if (!pt.vehicle_data->struct_empty()) { + vehicle_data_items = + pt.vehicle_data.is_initialized() && + pt.vehicle_data->schema_items.is_initialized() + ? *pt.vehicle_data->schema_items + : current_vd_items; + } + for (auto& func : rpcs) { - FilterInvalidRPCParameters(func.second); + FilterInvalidRPCParameters(func.second, vehicle_data_items); } } } -bool PolicyManagerImpl::LoadPT(const std::string& file, - const BinaryMessage& pt_content) { +PolicyManager::PtProcessingResult PolicyManagerImpl::LoadPT( + const std::string& file, const BinaryMessage& pt_content) { LOG4CXX_INFO(logger_, "LoadPT of size " << pt_content.size()); LOG4CXX_DEBUG( logger_, @@ -435,96 +466,114 @@ bool PolicyManagerImpl::LoadPT(const std::string& file, std::shared_ptr pt_update = Parse(pt_content); if (!pt_update) { LOG4CXX_WARN(logger_, "Parsed table pointer is NULL."); - update_status_manager_.OnWrongUpdateReceived(); - return false; + return PtProcessingResult::kWrongPtReceived; } file_system::DeleteFile(file); - FilterPolicyTable(pt_update->policy_table); + auto current_vd_items = GetVehicleDataItems(); + + FilterPolicyTable(pt_update->policy_table, current_vd_items); if (!IsPTValid(pt_update, policy_table::PT_UPDATE)) { - wrong_ptu_update_received_ = true; - update_status_manager_.OnWrongUpdateReceived(); - return false; + LOG4CXX_WARN(logger_, "Received policy table update is not valid"); + return PtProcessingResult::kWrongPtReceived; } - update_status_manager_.OnValidUpdateReceived(); cache_->SaveUpdateRequired(false); + sync_primitives::AutoLock lock(apps_registration_lock_); - { - sync_primitives::AutoLock lock(apps_registration_lock_); + // Get current DB data, since it could be updated during awaiting of PTU + auto policy_table_snapshot = cache_->GenerateSnapshot(); + if (!policy_table_snapshot) { + LOG4CXX_ERROR( + logger_, + "Failed to create snapshot of policy table, trying another exchange"); + return PtProcessingResult::kNewPtRequired; + } - // Get current DB data, since it could be updated during awaiting of PTU - std::shared_ptr policy_table_snapshot = - cache_->GenerateSnapshot(); - if (!policy_table_snapshot) { - LOG4CXX_ERROR( - logger_, - "Failed to create snapshot of policy table, trying another exchange"); - ForcePTExchange(); - return false; - } + // Checking of difference between PTU and current policy state + // Must to be done before PTU applying since it is possible, that functional + // groups, which had been present before are absent in PTU and will be + // removed after update. So in case of revoked groups system has to know + // names and ids of revoked groups before they will be removed. + CheckAppPolicyResults results = + CheckPermissionsChanges(pt_update, policy_table_snapshot); - // Checking of difference between PTU and current policy state - // Must to be done before PTU applying since it is possible, that functional - // groups, which had been present before are absent in PTU and will be - // removed after update. So in case of revoked groups system has to know - // names and ids of revoked groups before they will be removed. - CheckAppPolicyResults results = - CheckPermissionsChanges(pt_update, policy_table_snapshot); - - // Replace current data with updated - if (!cache_->ApplyUpdate(*pt_update)) { - LOG4CXX_WARN( - logger_, - "Unsuccessful save of updated policy table, trying another exchange"); - ForcePTExchange(); - return false; - } + // Replace current data with updated + if (!cache_->ApplyUpdate(*pt_update)) { + LOG4CXX_WARN( + logger_, + "Unsuccessful save of updated policy table, trying another exchange"); + return PtProcessingResult::kNewPtRequired; + } - ExternalConsentStatus status = cache_->GetExternalConsentStatus(); - GroupsByExternalConsentStatus groups_by_status = - cache_->GetGroupsWithSameEntities(status); + ExternalConsentStatus status = cache_->GetExternalConsentStatus(); + GroupsByExternalConsentStatus groups_by_status = + cache_->GetGroupsWithSameEntities(status); - ProcessExternalConsentStatusUpdate( - groups_by_status, ConsentProcessingPolicy::kExternalConsentBased); + ProcessExternalConsentStatusUpdate( + groups_by_status, ConsentProcessingPolicy::kExternalConsentBased); - ProcessAppPolicyCheckResults( - results, pt_update->policy_table.app_policies_section.apps); + ProcessAppPolicyCheckResults( + results, pt_update->policy_table.app_policies_section.apps); - listener_->OnCertificateUpdated( - *(pt_update->policy_table.module_config.certificate)); + CheckPermissionsChangesAfterUpdate(*pt_update, *policy_table_snapshot); - std::map app_hmi_types; - cache_->GetHMIAppTypeAfterUpdate(app_hmi_types); - if (!app_hmi_types.empty()) { - LOG4CXX_INFO(logger_, "app_hmi_types is full calling OnUpdateHMIAppType"); - listener_->OnUpdateHMIAppType(app_hmi_types); - } else { - LOG4CXX_INFO(logger_, "app_hmi_types empty"); - } + listener_->OnCertificateUpdated( + *(pt_update->policy_table.module_config.certificate)); - std::vector enabled_apps; - cache_->GetEnabledCloudApps(enabled_apps); - for (auto it = enabled_apps.begin(); it != enabled_apps.end(); ++it) { - SendAuthTokenUpdated(*it); - } + std::map app_hmi_types; + cache_->GetHMIAppTypeAfterUpdate(app_hmi_types); + if (!app_hmi_types.empty()) { + LOG4CXX_INFO(logger_, "app_hmi_types is full calling OnUpdateHMIAppType"); + listener_->OnUpdateHMIAppType(app_hmi_types); + } else { + LOG4CXX_INFO(logger_, "app_hmi_types empty"); + } + + std::vector enabled_apps; + cache_->GetEnabledCloudApps(enabled_apps); + for (auto it = enabled_apps.begin(); it != enabled_apps.end(); ++it) { + SendAuthTokenUpdated(*it); + } + + return PtProcessingResult::kSuccess; +} + +void PolicyManagerImpl::OnPTUFinished(const PtProcessingResult ptu_result) { + LOG4CXX_AUTO_TRACE(logger_); + + if (PtProcessingResult::kWrongPtReceived == ptu_result) { + LOG4CXX_DEBUG(logger_, "Wrong PT was received"); + update_status_manager_.OnWrongUpdateReceived(); + return; } + update_status_manager_.OnValidUpdateReceived(); + + if (PtProcessingResult::kNewPtRequired == ptu_result) { + LOG4CXX_DEBUG(logger_, "New PTU interation is required"); + ForcePTExchange(); + return; + } + + ResumePendingAppPolicyActions(); + // If there was a user request for policy table update, it should be started // right after current update is finished if (update_status_manager_.IsUpdateRequired()) { + LOG4CXX_DEBUG(logger_, + "PTU was successful and new PTU iteration was scheduled"); StartPTExchange(); - return true; + return; } RefreshRetrySequence(); - return true; } CheckAppPolicyResults PolicyManagerImpl::CheckPermissionsChanges( const std::shared_ptr pt_update, const std::shared_ptr snapshot) { - LOG4CXX_INFO(logger_, "Checking incoming permissions."); + LOG4CXX_AUTO_TRACE(logger_); // Replace predefined policies with its actual setting, e.g. "123":"default" // to actual values of default section @@ -538,6 +587,17 @@ CheckAppPolicyResults PolicyManagerImpl::CheckPermissionsChanges( return out_results; } +void PolicyManagerImpl::CheckPermissionsChangesAfterUpdate( + const policy_table::Table& update, const policy_table::Table& snapshot) { + const auto new_lock_screen_dismissal_enabled = + update.policy_table.module_config.lock_screen_dismissal_enabled; + const auto old_lock_screen_dismissal_enabled = + snapshot.policy_table.module_config.lock_screen_dismissal_enabled; + if (new_lock_screen_dismissal_enabled != old_lock_screen_dismissal_enabled) { + listener()->OnLockScreenDismissalStateChanged(); + } +} + void PolicyManagerImpl::ProcessAppPolicyCheckResults( const CheckAppPolicyResults& results, const policy_table::ApplicationPolicies& app_policies) { @@ -552,33 +612,39 @@ void PolicyManagerImpl::ProcessAppPolicyCheckResults( void PolicyManagerImpl::ProcessActionsForAppPolicies( const ApplicationsPoliciesActions& actions, const policy_table::ApplicationPolicies& app_policies) { - ApplicationsPoliciesActions::const_iterator it_actions = actions.begin(); - for (; it_actions != actions.end(); ++it_actions) { - policy_table::ApplicationPolicies::const_iterator app_policy = - app_policies.find(it_actions->first); + notify_system_list_.clear(); + send_permissions_list_.clear(); + + for (const auto& action : actions) { + const auto& app_policy = app_policies.find(action.first); if (app_policies.end() == app_policy) { continue; } - if (it_actions->second.is_consent_needed) { - // Post-check after ExternalConsent consent changes - const std::string& policy_app_id = app_policy->first; - if (!IsConsentNeeded(policy_app_id)) { - sync_primitives::AutoLock lock(app_permissions_diff_lock_); + const auto devices_ids = listener()->GetDevicesIds(app_policy->first); + for (const auto& device_id : devices_ids) { + if (action.second.is_consent_needed) { + // Post-check after ExternalConsent consent changes + const auto& policy_app_id = app_policy->first; + if (!IsConsentNeeded(device_id, policy_app_id)) { + sync_primitives::AutoLock lock(app_permissions_diff_lock_); - PendingPermissions::iterator app_id_diff = - app_permissions_diff_.find(policy_app_id); + const auto& app_id_diff = app_permissions_diff_.find(policy_app_id); - if (app_permissions_diff_.end() != app_id_diff) { - app_id_diff->second.appPermissionsConsentNeeded = false; + if (app_permissions_diff_.end() != app_id_diff) { + app_id_diff->second.appPermissionsConsentNeeded = false; + } } } - } - if (it_actions->second.is_notify_system) { - NotifySystem(*app_policy); - } - if (it_actions->second.is_send_permissions_to_app) { - SendPermissionsToApp(*app_policy); + + if (action.second.is_notify_system) { + notify_system_list_.push_back(std::make_pair(device_id, *app_policy)); + } + + if (action.second.is_send_permissions_to_app) { + send_permissions_list_.push_back( + std::make_pair(device_id, *app_policy)); + } } } } @@ -702,10 +768,11 @@ void PolicyManagerImpl::OnAppsSearchCompleted(const bool trigger_ptu) { } const std::vector PolicyManagerImpl::GetAppRequestTypes( + const transport_manager::DeviceHandle& device_handle, const std::string policy_app_id) const { std::vector request_types; - if (kDeviceDisallowed == - cache_->GetDeviceConsent(GetCurrentDeviceId(policy_app_id))) { + if (kDeviceAllowed != cache_->GetDeviceConsent( + GetCurrentDeviceId(device_handle, policy_app_id))) { cache_->GetAppRequestTypes(kPreDataConsentId, request_types); } else { cache_->GetAppRequestTypes(policy_app_id, request_types); @@ -732,8 +799,18 @@ const std::vector PolicyManagerImpl::GetAppRequestSubTypes( return request_subtypes; } -const VehicleInfo PolicyManagerImpl::GetVehicleInfo() const { - return cache_->GetVehicleInfo(); +const std::vector +PolicyManagerImpl::GetVehicleDataItems() const { + return cache_->GetVehicleDataItems(); +} + +std::vector +PolicyManagerImpl::GetRemovedVehicleDataItems() const { + return cache_->GetRemovedVehicleDataItems(); +} + +Json::Value PolicyManagerImpl::GetPolicyTableData() const { + return cache_->GetPolicyTableData(); } void PolicyManagerImpl::GetEnabledCloudApps( @@ -805,7 +882,8 @@ bool PolicyManagerImpl::UnknownRPCPassthroughAllowed( return cache_->UnknownRPCPassthroughAllowed(policy_app_id); } -void PolicyManagerImpl::CheckPermissions(const PTString& app_id, +void PolicyManagerImpl::CheckPermissions(const PTString& device_id, + const PTString& app_id, const PTString& hmi_level, const PTString& rpc, const RPCParams& rpc_params, @@ -814,8 +892,6 @@ void PolicyManagerImpl::CheckPermissions(const PTString& app_id, "CheckPermissions for " << app_id << " and rpc " << rpc << " for " << hmi_level << " level."); - const std::string device_id = GetCurrentDeviceId(app_id); - Permissions rpc_permissions; // Check, if there are calculated permission present in cache @@ -954,8 +1030,9 @@ void PolicyManagerImpl::CheckPermissions(const PTString& app_id, for (; end != parameter; ++parameter) { if (!result.HasParameter(*parameter)) { LOG4CXX_DEBUG(logger_, - "Parameter " << *parameter << " is unknown." - " Adding to undefined list."); + "Parameter " << *parameter + << " is unknown." + " Adding to undefined list."); result.list_of_undefined_params.insert(*parameter); } } @@ -965,7 +1042,12 @@ void PolicyManagerImpl::CheckPermissions(const PTString& app_id, result.hmi_level_permitted = kRpcUserDisallowed; } else if (!result.IsAnyAllowed(rpc_params)) { LOG4CXX_DEBUG(logger_, "There are no parameters allowed."); - result.hmi_level_permitted = kRpcDisallowed; + + if (!result.list_of_undefined_params.empty()) { + result.hmi_level_permitted = kRpcAllowed; + } else { + result.hmi_level_permitted = kRpcDisallowed; + } } } @@ -984,13 +1066,13 @@ policy_table::Strings PolicyManagerImpl::GetGroupsNames( } void PolicyManagerImpl::SendNotificationOnPermissionsUpdated( - const std::string& application_id) { + const std::string& device_id, const std::string& application_id) { LOG4CXX_AUTO_TRACE(logger_); - const std::string device_id = GetCurrentDeviceId(application_id); if (device_id.empty()) { LOG4CXX_WARN(logger_, "Couldn't find device info for application id " - "'" << application_id << "'"); + "'" << application_id + << "'"); return; } @@ -1013,15 +1095,16 @@ void PolicyManagerImpl::SendNotificationOnPermissionsUpdated( const ApplicationOnDevice who = {device_id, application_id}; if (access_remote_->IsAppRemoteControl(who)) { - listener()->OnPermissionsUpdated(application_id, notification_data); + listener()->OnPermissionsUpdated( + device_id, application_id, notification_data); return; } std::string default_hmi; - GetDefaultHmi(application_id, &default_hmi); + GetDefaultHmi(device_id, application_id, &default_hmi); listener()->OnPermissionsUpdated( - application_id, notification_data, default_hmi); + device_id, application_id, notification_data, default_hmi); } bool PolicyManagerImpl::CleanupUnpairedDevices() { @@ -1047,21 +1130,25 @@ void PolicyManagerImpl::SetUserConsentForDevice(const std::string& device_id, "Event listener is not initialized. " "Can't call OnDeviceConsentChanged"); } - if (is_allowed) { + if (is_allowed && listener_->CanUpdate()) { update_status_manager_.OnDeviceConsented(); } StartPTExchange(); } bool PolicyManagerImpl::ReactOnUserDevConsentForApp( - const std::string& app_id, const bool is_device_allowed) { - std::vector current_request_types = GetAppRequestTypes(app_id); + const transport_manager::DeviceHandle& device_handle, + const std::string& app_id, + const bool is_device_allowed) { + std::vector current_request_types = + GetAppRequestTypes(device_handle, app_id); std::string current_priority, new_priority; GetPriority(app_id, ¤t_priority); bool result = cache_->ReactOnUserDevConsentForApp(app_id, is_device_allowed); - std::vector new_request_types = GetAppRequestTypes(app_id); + std::vector new_request_types = + GetAppRequestTypes(device_handle, app_id); GetPriority(app_id, &new_priority); std::sort(current_request_types.begin(), current_request_types.end()); std::sort(new_request_types.begin(), new_request_types.end()); @@ -1086,7 +1173,8 @@ bool PolicyManagerImpl::ReactOnUserDevConsentForApp( } if (permissions.requestTypeChanged || (!permissions.priority.empty())) { - listener_->SendOnAppPermissionsChanged(permissions, app_id); + const auto& device_id = GetCurrentDeviceId(device_handle, app_id); + listener_->SendOnAppPermissionsChanged(permissions, device_id, app_id); } return result; } @@ -1204,6 +1292,7 @@ void PolicyManagerImpl::CheckPendingPermissionsChanges( } void PolicyManagerImpl::NotifyPermissionsChanges( + const std::string& device_id, const std::string& policy_app_id, const std::vector& app_group_permissions) { LOG4CXX_AUTO_TRACE(logger_); @@ -1219,7 +1308,7 @@ void PolicyManagerImpl::NotifyPermissionsChanges( PrepareNotificationData( functional_groups, app_groups, app_group_permissions, notification_data); - listener()->OnPermissionsUpdated(policy_app_id, notification_data); + listener()->OnPermissionsUpdated(device_id, policy_app_id, notification_data); } void PolicyManagerImpl::SetUserConsentForApp( @@ -1258,14 +1347,51 @@ void PolicyManagerImpl::SetUserConsentForApp( CheckPendingPermissionsChanges(verified_permissions.policy_app_id, updated_app_group_permissons); - NotifyPermissionsChanges(verified_permissions.policy_app_id, + NotifyPermissionsChanges(verified_permissions.device_id, + verified_permissions.policy_app_id, updated_app_group_permissons); } -bool PolicyManagerImpl::GetDefaultHmi(const std::string& policy_app_id, +bool PolicyManagerImpl::IsAllowedRetryCountExceeded() const { + LOG4CXX_AUTO_TRACE(logger_); + sync_primitives::AutoLock auto_lock(retry_sequence_lock_); + + return retry_sequence_index_ > retry_sequence_seconds_.size(); +} + +void PolicyManagerImpl::IncrementRetryIndex() { + LOG4CXX_AUTO_TRACE(logger_); + sync_primitives::AutoLock auto_lock(retry_sequence_lock_); + + if (!is_ptu_in_progress_) { + LOG4CXX_TRACE(logger_, + "First PTU iteration, skipping incrementing retry index"); + is_ptu_in_progress_ = true; + return; + } + + ++retry_sequence_index_; + LOG4CXX_DEBUG(logger_, + "current retry_sequence_index_ is: " << retry_sequence_index_); +} + +void PolicyManagerImpl::RetrySequenceFailed() { + LOG4CXX_AUTO_TRACE(logger_); + + listener_->OnPTUFinished(false); + ResetRetrySequence(ResetRetryCountType::kResetWithStatusUpdate); +} + +void PolicyManagerImpl::OnSystemRequestReceived() { + LOG4CXX_AUTO_TRACE(logger_); + + IncrementRetryIndex(); +} + +bool PolicyManagerImpl::GetDefaultHmi(const std::string& device_id, + const std::string& policy_app_id, std::string* default_hmi) const { LOG4CXX_AUTO_TRACE(logger_); - const std::string device_id = GetCurrentDeviceId(policy_app_id); DeviceConsent device_consent = GetUserConsentForDevice(device_id); const std::string app_id = policy::kDeviceAllowed != device_consent ? kPreDataConsentId @@ -1370,11 +1496,13 @@ void PolicyManagerImpl::GetPermissionsForApp( } bool allowed_by_default = false; - if (cache_->IsDefaultPolicy(policy_app_id)) { + const auto device_consent = GetUserConsentForDevice(device_id); + if ((policy::kDeviceAllowed == device_consent) && + cache_->IsDefaultPolicy(policy_app_id)) { app_id_to_check = kDefaultId; allowed_by_default = true; } else if (cache_->IsPredataPolicy(policy_app_id) || - policy::kDeviceDisallowed == GetUserConsentForDevice(device_id)) { + policy::kDeviceAllowed != device_consent) { app_id_to_check = kPreDataConsentId; allowed_by_default = true; } @@ -1458,9 +1586,11 @@ void PolicyManagerImpl::GetPermissionsForApp( } std::string& PolicyManagerImpl::GetCurrentDeviceId( + const transport_manager::DeviceHandle& device_handle, const std::string& policy_app_id) const { LOG4CXX_INFO(logger_, "GetDeviceInfo"); - last_device_id_ = listener()->OnCurrentDeviceIdUpdateRequired(policy_app_id); + last_device_id_ = + listener()->OnCurrentDeviceIdUpdateRequired(device_handle, policy_app_id); return last_device_id_; } @@ -1563,16 +1693,32 @@ void PolicyManagerImpl::UpdateAppConsentWithExternalConsent( cache_->SetExternalConsentForApp(updated_external_consent_permissions); } +void PolicyManagerImpl::ResumePendingAppPolicyActions() { + LOG4CXX_AUTO_TRACE(logger_); + + for (auto& notify_system_params : notify_system_list_) { + NotifySystem(notify_system_params.first, notify_system_params.second); + } + notify_system_list_.clear(); + + for (auto& send_permissions_params : send_permissions_list_) { + SendPermissionsToApp(send_permissions_params.first, + send_permissions_params.second); + } + send_permissions_list_.clear(); +} + void PolicyManagerImpl::NotifySystem( + const std::string& device_id, const PolicyManagerImpl::AppPoliciesValueType& app_policy) const { - listener()->OnPendingPermissionChange(app_policy.first); + listener()->OnPendingPermissionChange(device_id, app_policy.first); } void PolicyManagerImpl::SendPermissionsToApp( + const std::string& device_id, const PolicyManagerImpl::AppPoliciesValueType& app_policy) { const std::string app_id = app_policy.first; - const std::string device_id = GetCurrentDeviceId(app_id); if (device_id.empty()) { LOG4CXX_WARN(logger_, "Couldn't find device info for application id: " << app_id); @@ -1595,6 +1741,7 @@ void PolicyManagerImpl::SendPermissionsToApp( LOG4CXX_INFO(logger_, "Send notification for application_id: " << app_id); listener()->OnPermissionsUpdated( + device_id, app_id, notification_data, policy_table::EnumToJsonString(app_policy.second.default_hmi)); @@ -1736,6 +1883,19 @@ void PolicyManagerImpl::KmsChanged(int kilometers) { } } +const boost::optional PolicyManagerImpl::LockScreenDismissalEnabledState() + const { + LOG4CXX_AUTO_TRACE(logger_); + return cache_->LockScreenDismissalEnabledState(); +} + +const boost::optional +PolicyManagerImpl::LockScreenDismissalWarningMessage( + const std::string& language) const { + LOG4CXX_AUTO_TRACE(logger_); + return cache_->LockScreenDismissalWarningMessage(language); +} + void PolicyManagerImpl::IncrementIgnitionCycles() { cache_->IncrementIgnitionCycles(); } @@ -1746,6 +1906,14 @@ std::string PolicyManagerImpl::ForcePTExchange() { return update_status_manager_.StringifiedUpdateStatus(); } +void policy::PolicyManagerImpl::StopRetrySequence() { + LOG4CXX_AUTO_TRACE(logger_); + + if (cache_->UpdateRequired()) { + ResetRetrySequence(ResetRetryCountType::kResetWithStatusUpdate); + } +} + std::string PolicyManagerImpl::ForcePTExchangeAtUserRequest() { LOG4CXX_AUTO_TRACE(logger_); update_status_manager_.ScheduleManualUpdate(); @@ -1761,10 +1929,11 @@ int PolicyManagerImpl::NextRetryTimeout() { sync_primitives::AutoLock auto_lock(retry_sequence_lock_); LOG4CXX_DEBUG(logger_, "Index: " << retry_sequence_index_); int next = 0; + if (!retry_sequence_seconds_.empty() && retry_sequence_index_ < retry_sequence_seconds_.size()) { - next = retry_sequence_seconds_[retry_sequence_index_]; - ++retry_sequence_index_; + next = retry_sequence_seconds_[retry_sequence_index_] * + date_time::MILLISECONDS_IN_SECOND; } return next; } @@ -1776,10 +1945,15 @@ void PolicyManagerImpl::RefreshRetrySequence() { cache_->SecondsBetweenRetries(retry_sequence_seconds_); } -void PolicyManagerImpl::ResetRetrySequence() { +void PolicyManagerImpl::ResetRetrySequence( + const ResetRetryCountType reset_type) { + LOG4CXX_AUTO_TRACE(logger_); sync_primitives::AutoLock auto_lock(retry_sequence_lock_); retry_sequence_index_ = 0; - update_status_manager_.OnResetRetrySequence(); + is_ptu_in_progress_ = false; + if (ResetRetryCountType::kResetWithStatusUpdate == reset_type) { + update_status_manager_.OnResetRetrySequence(); + } } uint32_t PolicyManagerImpl::TimeoutExchangeMSec() { @@ -1792,6 +1966,8 @@ const std::vector PolicyManagerImpl::RetrySequenceDelaysSeconds() { } void PolicyManagerImpl::OnExceededTimeout() { + LOG4CXX_AUTO_TRACE(logger_); + update_status_manager_.OnUpdateTimeoutOccurs(); } @@ -1842,10 +2018,10 @@ bool PolicyManagerImpl::IsApplicationRevoked(const std::string& app_id) const { return cache_->IsApplicationRevoked(app_id); } -bool PolicyManagerImpl::IsConsentNeeded(const std::string& app_id) { +bool PolicyManagerImpl::IsConsentNeeded(const std::string& device_id, + const std::string& app_id) { LOG4CXX_AUTO_TRACE(logger_); - const std::string device_id = GetCurrentDeviceId(app_id); - int count = cache_->CountUnconsentedGroups(app_id, device_id); + const int count = cache_->CountUnconsentedGroups(app_id, device_id); LOG4CXX_DEBUG(logger_, "There are: " << count << " unconsented groups."); return count != 0; } @@ -1855,7 +2031,7 @@ void PolicyManagerImpl::SetVINValue(const std::string& value) { } AppPermissions PolicyManagerImpl::GetAppPermissionsChanges( - const std::string& policy_app_id) { + const std::string& device_id, const std::string& policy_app_id) { PendingPermissions::iterator app_id_diff = app_permissions_diff_.find(policy_app_id); @@ -1864,8 +2040,10 @@ AppPermissions PolicyManagerImpl::GetAppPermissionsChanges( if (app_permissions_diff_.end() != app_id_diff) { permissions = app_id_diff->second; } else { - permissions.appPermissionsConsentNeeded = IsConsentNeeded(policy_app_id); + permissions.appPermissionsConsentNeeded = + IsConsentNeeded(device_id, policy_app_id); permissions.appRevoked = IsApplicationRevoked(policy_app_id); + permissions.isSDLAllowed = false; GetPriority(permissions.application_id, &permissions.priority); } return permissions; @@ -1893,9 +2071,9 @@ void PolicyManagerImpl::MarkUnpairedDevice(const std::string& device_id) { } void PolicyManagerImpl::OnAppRegisteredOnMobile( - const std::string& application_id) { + const std::string& device_id, const std::string& application_id) { StartPTExchange(); - SendNotificationOnPermissionsUpdated(application_id); + SendNotificationOnPermissionsUpdated(device_id, application_id); } void PolicyManagerImpl::OnDeviceSwitching(const std::string& device_id_from, @@ -1984,20 +2162,23 @@ class CallStatusChange : public utils::Callable { }; StatusNotifier PolicyManagerImpl::AddApplication( + const std::string& device_id, const std::string& application_id, const rpc::policy_table_interface_base::AppHmiTypes& hmi_types) { LOG4CXX_AUTO_TRACE(logger_); - const std::string device_id = GetCurrentDeviceId(application_id); - DeviceConsent device_consent = GetUserConsentForDevice(device_id); + auto device_consent = GetUserConsentForDevice(device_id); + LOG4CXX_DEBUG(logger_, + "check_device_id: " << device_id << " check_device_consent: " + << device_consent); sync_primitives::AutoLock lock(apps_registration_lock_); if (IsNewApplication(application_id)) { LOG4CXX_DEBUG(logger_, "Adding new application"); - AddNewApplication(application_id, device_consent); + AddNewApplication(device_id, application_id, device_consent); return std::make_shared(update_status_manager_, device_consent); } LOG4CXX_DEBUG(logger_, "Promote existed application"); - PromoteExistedApplication(application_id, device_consent); + PromoteExistedApplication(device_id, application_id, device_consent); update_status_manager_.OnExistedApplicationAdded(cache_->UpdateRequired()); return std::make_shared(); } @@ -2014,6 +2195,7 @@ bool PolicyManagerImpl::IsPredataPolicy( } void PolicyManagerImpl::ProcessExternalConsentStatusForApp( + const std::string& device_id, const std::string& application_id, const ConsentProcessingPolicy processing_policy) { ExternalConsentStatus status = cache_->GetExternalConsentStatus(); @@ -2025,7 +2207,7 @@ void PolicyManagerImpl::ProcessExternalConsentStatusForApp( CalculateGroupsConsentFromExternalConsent( groups_by_status, allowed_groups, disallowed_groups); - const std::string device_id = GetCurrentDeviceId(application_id); + LOG4CXX_DEBUG(logger_, "check device_id: " << device_id); UpdateAppConsentWithExternalConsent(device_id, application_id, allowed_groups, @@ -2033,7 +2215,8 @@ void PolicyManagerImpl::ProcessExternalConsentStatusForApp( processing_policy); } -void PolicyManagerImpl::AddNewApplication(const std::string& application_id, +void PolicyManagerImpl::AddNewApplication(const std::string& device_id, + const std::string& application_id, DeviceConsent device_consent) { LOG4CXX_AUTO_TRACE(logger_); @@ -2053,19 +2236,31 @@ void PolicyManagerImpl::AddNewApplication(const std::string& application_id, } ProcessExternalConsentStatusForApp( - application_id, ConsentProcessingPolicy::kExternalConsentBased); + device_id, + application_id, + ConsentProcessingPolicy::kExternalConsentBased); } void PolicyManagerImpl::PromoteExistedApplication( - const std::string& application_id, DeviceConsent device_consent) { + const std::string& device_id, + const std::string& application_id, + DeviceConsent device_consent) { // If device consent changed to allowed during application being // disconnected, app permissions should be changed also + LOG4CXX_DEBUG(logger_, + "kDeviceAllowed == device_consent: " + << (kDeviceAllowed == device_consent) + << " device_consent: " << device_consent); if (kDeviceAllowed == device_consent && cache_->IsPredataPolicy(application_id)) { + LOG4CXX_INFO(logger_, + "Setting " + << policy::kDefaultId + << " permissions for application id: " << application_id); cache_->SetDefaultPolicy(application_id); } - ProcessExternalConsentStatusForApp(application_id, - ConsentProcessingPolicy::kTimestampBased); + ProcessExternalConsentStatusForApp( + device_id, application_id, ConsentProcessingPolicy::kTimestampBased); } bool PolicyManagerImpl::IsNewApplication( @@ -2127,6 +2322,11 @@ uint32_t PolicyManagerImpl::HeartBeatTimeout(const std::string& app_id) const { } void PolicyManagerImpl::SaveUpdateStatusRequired(bool is_update_needed) { + LOG4CXX_AUTO_TRACE(logger_); + + if (!is_update_needed) { + ResetRetrySequence(ResetRetryCountType::kResetInternally); + } cache_->SaveUpdateRequired(is_update_needed); } @@ -2145,10 +2345,12 @@ std::ostream& operator<<(std::ostream& output, return output; } -void PolicyManagerImpl::SetDefaultHmiTypes(const std::string& application_id, - const std::vector& hmi_types) { +void PolicyManagerImpl::SetDefaultHmiTypes( + const transport_manager::DeviceHandle& device_handle, + const std::string& application_id, + const std::vector& hmi_types) { LOG4CXX_INFO(logger_, "SetDefaultHmiTypes"); - const std::string device_id = GetCurrentDeviceId(application_id); + const auto device_id = GetCurrentDeviceId(device_handle, application_id); ApplicationOnDevice who = {device_id, application_id}; access_remote_->SetDefaultHmiTypes(who, hmi_types); } @@ -2186,12 +2388,12 @@ bool PolicyManagerImpl::CheckModule(const PTString& app_id, void PolicyManagerImpl::SendHMILevelChanged(const ApplicationOnDevice& who) { std::string default_hmi("NONE"); - if (GetDefaultHmi(who.app_id, &default_hmi)) { + if (GetDefaultHmi(who.dev_id, who.app_id, &default_hmi)) { listener()->OnUpdateHMIStatus(who.dev_id, who.app_id, default_hmi); } else { - LOG4CXX_WARN(logger_, - "Couldn't get default HMI level for application " - << who.app_id); + LOG4CXX_WARN( + logger_, + "Couldn't get default HMI level for application " << who.app_id); } } @@ -2223,7 +2425,8 @@ void PolicyManagerImpl::SendAppPermissionsChanged( const std::string& device_id, const std::string& application_id) { Permissions notification_data; GetPermissions(device_id, application_id, ¬ification_data); - listener()->OnPermissionsUpdated(application_id, notification_data); + listener()->OnPermissionsUpdated( + device_id, application_id, notification_data); } void PolicyManagerImpl::SendAuthTokenUpdated(const std::string policy_app_id) { @@ -2260,4 +2463,104 @@ void PolicyManagerImpl::set_access_remote( access_remote_ = access_remote; } +bool PolicyManagerImpl::AppNeedEncryption( + const std::string& policy_app_id) const { + const auto encryption_required = + cache_->GetAppEncryptionRequiredFlag(policy_app_id); + + return encryption_required.is_initialized() ? *encryption_required : true; +} + +const rpc::Optional PolicyManagerImpl::GetAppEncryptionRequired( + const std::string& policy_app_id) const { + return cache_->GetAppEncryptionRequiredFlag(policy_app_id); +} + +const std::vector PolicyManagerImpl::GetFunctionalGroupsForApp( + const std::string& policy_app_id) const { + LOG4CXX_AUTO_TRACE(logger_); + using namespace rpc::policy_table_interface_base; + DCHECK(kDeviceId != policy_app_id); + + std::vector function_groups; + + ApplicationParams app_params; + cache_->GetApplicationParams(policy_app_id, app_params); + + const auto& policy_function_group = app_params.groups; + + for (const auto& group : policy_function_group) { + function_groups.push_back(group); + } + + return function_groups; +} + +const std::vector PolicyManagerImpl::GetApplicationPolicyIDs() + const { + LOG4CXX_AUTO_TRACE(logger_); + std::vector policy_app_ids; + + const auto apps = cache_->GetPolicyAppIDs(); + + for (const auto& app : apps) { + policy_app_ids.push_back(app); + } + + return policy_app_ids; +} + +bool PolicyManagerImpl::FunctionGroupNeedEncryption( + const std::string& policy_group) const { + LOG4CXX_AUTO_TRACE(logger_); + FunctionalGroupings functional_groupings; + cache_->GetFunctionalGroupings(functional_groupings); + + const auto& grouping_itr = functional_groupings.find(policy_group); + + if (grouping_itr == functional_groupings.end()) { + LOG4CXX_WARN(logger_, "Group " << policy_group << " not found"); + return false; + } + + const auto& grouping = (*grouping_itr).second; + + return grouping.encryption_required.is_initialized() + ? *grouping.encryption_required + : false; +} + +const std::string PolicyManagerImpl::GetPolicyFunctionName( + const uint32_t function_id) const { + LOG4CXX_AUTO_TRACE(logger_); + return policy_table::EnumToJsonString( + static_cast(function_id)); +} + +const std::vector PolicyManagerImpl::GetRPCsForFunctionGroup( + const std::string& group) const { + std::vector rpcs_for_group; + + FunctionalGroupings functional_groupings; + cache_->GetFunctionalGroupings(functional_groupings); + + const auto& rpcs = functional_groupings[group].rpcs; + + for (const auto& rpc : rpcs) { + rpcs_for_group.push_back(rpc.first); + } + + return rpcs_for_group; +} + } // namespace policy + +__attribute__((visibility("default"))) policy::PolicyManager* CreateManager() { + return new policy::PolicyManagerImpl(); +} + +__attribute__((visibility("default"))) void DeleteManager( + policy::PolicyManager* pm) { + delete pm; + DELETE_THREAD_LOGGER(policy::logger_); +} 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 bb25623b350..8f5d58aad20 100644 --- a/src/components/policy/policy_external/src/policy_table/enums.cc +++ b/src/components/policy/policy_external/src/policy_table/enums.cc @@ -3,555 +3,6 @@ namespace rpc { namespace policy_table_interface_base { -bool IsValidEnum(Priority val) { - switch (val) { - case P_EMERGENCY: - return true; - case P_NAVIGATION: - return true; - case P_VOICECOM: - return true; - case P_COMMUNICATION: - return true; - case P_NORMAL: - return true; - case P_PROJECTION: - return true; - case P_NONE: - return true; - default: - return false; - } -} -const char* EnumToJsonString(Priority val) { - switch (val) { - case P_EMERGENCY: - return "EMERGENCY"; - case P_NAVIGATION: - return "NAVIGATION"; - case P_VOICECOM: - return "VOICECOM"; - case P_COMMUNICATION: - return "COMMUNICATION"; - case P_NORMAL: - return "NORMAL"; - case P_PROJECTION: - return "PROJECTION"; - case P_NONE: - return "NONE"; - default: - return ""; - } -} -bool EnumFromJsonString(const std::string& literal, Priority* result) { - if ("EMERGENCY" == literal) { - *result = P_EMERGENCY; - return true; - } else if ("NAVIGATION" == literal) { - *result = P_NAVIGATION; - return true; - } else if ("VOICECOM" == literal) { - *result = P_VOICECOM; - return true; - } else if ("COMMUNICATION" == literal) { - *result = P_COMMUNICATION; - return true; - } else if ("NORMAL" == literal) { - *result = P_NORMAL; - return true; - } else if ("PROJECTION" == literal) { - *result = P_PROJECTION; - return true; - } else if ("NONE" == literal) { - *result = P_NONE; - return true; - } else { - return false; - } -} - -bool IsValidEnum(HmiLevel val) { - switch (val) { - case HL_BACKGROUND: - return true; - case HL_FULL: - return true; - case HL_LIMITED: - return true; - case HL_NONE: - return true; - default: - return false; - } -} -const char* EnumToJsonString(HmiLevel val) { - switch (val) { - case HL_BACKGROUND: - return "BACKGROUND"; - case HL_FULL: - return "FULL"; - case HL_LIMITED: - return "LIMITED"; - case HL_NONE: - return "NONE"; - default: - return ""; - } -} -bool EnumFromJsonString(const std::string& literal, HmiLevel* result) { - if ("BACKGROUND" == literal) { - *result = HL_BACKGROUND; - return true; - } else if ("FULL" == literal) { - *result = HL_FULL; - return true; - } else if ("LIMITED" == literal) { - *result = HL_LIMITED; - return true; - } else if ("NONE" == literal) { - *result = HL_NONE; - return true; - } else { - return false; - } -} - -bool IsValidEnum(Parameter val) { - switch (val) { - case P_GPS: - return true; - case P_SPEED: - return true; - case P_ENGINETORQUE: - return true; - case P_EXTERNALTEMPERATURE: - return true; - case P_TURNSIGNAL: - return true; - case P_FUELLEVEL: - return true; - case P_FUELLEVEL_STATE: - return true; - case P_HEADLAMPSTATUS: - return true; - case P_INSTANTFUELCONSUMPTION: - return true; - case P_FUELRANGE: - return true; - case P_CLOUD_APP_VEHICLE_ID: - return true; - case P_ODOMETER: - return true; - case P_TIREPRESSURE: - return true; - case P_WIPERSTATUS: - return true; - case P_VIN: - return true; - case P_ACCPEDALPOSITION: - return true; - case P_BELTSTATUS: - return true; - case P_ELECTRONICPARKBRAKESTATUS: - return true; - case P_DRIVERBRAKING: - return true; - case P_PRNDL: - return true; - case P_RPM: - return true; - case P_STEERINGWHEELANGLE: - return true; - case P_ENGINEOILLIFE: - return true; - case P_MYKEY: - return true; - case P_AIRBAGSTATUS: - return true; - case P_BODYINFORMATION: - return true; - case P_CLUSTERMODESTATUS: - return true; - case P_DEVICESTATUS: - return true; - case P_EMERGENCYEVENT: - return true; - case P_ECALLINFO: - return true; - case P_ABS_STATE: - return true; - case P_FUEL_RANGE: - return true; - case P_TIRE_PRESSURE_VALUE: - return true; - case P_TPMS: - return true; - case P_LONGTITUDE_DEGREES: - return true; - case P_LATITUDE_DEGREES: - return true; - case P_LOCATION_NAME: - return true; - case P_LOCATION_DESCRIPTION: - return true; - case P_ADDRESS_LINES: - return true; - case P_PHONE_NUMBER: - return true; - case P_LOCATION_IMAGE: - return true; - case P_DELIVERY_MODE: - return true; - case P_TIMESTAMP: - return true; - case P_ADDRESS: - return true; - case P_EMPTY: - return true; - default: - return false; - } -} - -const char* EnumToJsonString(Parameter val) { - switch (val) { - case P_GPS: - return "gps"; - case P_SPEED: - return "speed"; - case P_ENGINETORQUE: - return "engineTorque"; - case P_EXTERNALTEMPERATURE: - return "externalTemperature"; - case P_TURNSIGNAL: - return "turnSignal"; - case P_FUELLEVEL: - return "fuelLevel"; - case P_FUELLEVEL_STATE: - return "fuelLevel_State"; - case P_HEADLAMPSTATUS: - return "headLampStatus"; - case P_INSTANTFUELCONSUMPTION: - return "instantFuelConsumption"; - case P_FUELRANGE: - return "fuelRange"; - case P_CLOUD_APP_VEHICLE_ID: - return "cloudAppVehicleID"; - case P_ODOMETER: - return "odometer"; - case P_TIREPRESSURE: - return "tirePressure"; - case P_WIPERSTATUS: - return "wiperStatus"; - case P_VIN: - return "vin"; - case P_ACCPEDALPOSITION: - return "accPedalPosition"; - case P_BELTSTATUS: - return "beltStatus"; - case P_ELECTRONICPARKBRAKESTATUS: - return "electronicParkBrakeStatus"; - case P_DRIVERBRAKING: - return "driverBraking"; - case P_PRNDL: - return "prndl"; - case P_RPM: - return "rpm"; - case P_STEERINGWHEELANGLE: - return "steeringWheelAngle"; - case P_ENGINEOILLIFE: - return "engineOilLife"; - case P_MYKEY: - return "myKey"; - case P_AIRBAGSTATUS: - return "airbagStatus"; - case P_BODYINFORMATION: - return "bodyInformation"; - case P_CLUSTERMODESTATUS: - return "clusterModeStatus"; - case P_DEVICESTATUS: - return "deviceStatus"; - case P_EMERGENCYEVENT: - return "emergencyEvent"; - case P_ECALLINFO: - return "eCallInfo"; - case P_ABS_STATE: - return "abs_State"; - case P_FUEL_RANGE: - return "fuelRange"; - case P_TIRE_PRESSURE_VALUE: - return "tirePressureValue"; - case P_TPMS: - return "tpms"; - case P_LONGTITUDE_DEGREES: - return "longitudeDegrees"; - case P_LATITUDE_DEGREES: - return "latitudeDegrees"; - case P_LOCATION_NAME: - return "locationName"; - case P_LOCATION_DESCRIPTION: - return "locationDescription"; - case P_ADDRESS_LINES: - return "addressLines"; - case P_PHONE_NUMBER: - return "phoneNumber"; - case P_LOCATION_IMAGE: - return "locationImage"; - case P_DELIVERY_MODE: - return "deliveryMode"; - case P_TIMESTAMP: - return "timeStamp"; - case P_ADDRESS: - return "address"; - case P_EMPTY: - return "EMPTY"; - default: - return ""; - } -} - -bool EnumFromJsonString(const std::string& literal, Parameter* result) { - if ("gps" == literal) { - *result = P_GPS; - return true; - } else if ("speed" == literal) { - *result = P_SPEED; - return true; - } else if ("engineTorque" == literal) { - *result = P_ENGINETORQUE; - return true; - } else if ("externalTemperature" == literal) { - *result = P_EXTERNALTEMPERATURE; - return true; - } else if ("turnSignal" == literal) { - *result = P_TURNSIGNAL; - return true; - } else if ("fuelLevel" == literal) { - *result = P_FUELLEVEL; - return true; - } else if ("fuelLevel_State" == literal) { - *result = P_FUELLEVEL_STATE; - return true; - } else if ("headLampStatus" == literal) { - *result = P_HEADLAMPSTATUS; - return true; - } else if ("instantFuelConsumption" == literal) { - *result = P_INSTANTFUELCONSUMPTION; - return true; - } else if ("fuelRange" == literal) { - *result = P_FUELRANGE; - return true; - } else if ("cloudAppVehicleID" == literal) { - *result = P_CLOUD_APP_VEHICLE_ID; - return true; - } else if ("odometer" == literal) { - *result = P_ODOMETER; - return true; - } else if ("tirePressure" == literal) { - *result = P_TIREPRESSURE; - return true; - } else if ("wiperStatus" == literal) { - *result = P_WIPERSTATUS; - return true; - } else if ("vin" == literal) { - *result = P_VIN; - return true; - } else if ("accPedalPosition" == literal) { - *result = P_ACCPEDALPOSITION; - return true; - } else if ("beltStatus" == literal) { - *result = P_BELTSTATUS; - return true; - } else if ("electronicParkBrakeStatus" == literal) { - *result = P_ELECTRONICPARKBRAKESTATUS; - return true; - } else if ("driverBraking" == literal) { - *result = P_DRIVERBRAKING; - return true; - } else if ("prndl" == literal) { - *result = P_PRNDL; - return true; - } else if ("rpm" == literal) { - *result = P_RPM; - return true; - } else if ("steeringWheelAngle" == literal) { - *result = P_STEERINGWHEELANGLE; - return true; - } else if ("engineOilLife" == literal) { - *result = P_ENGINEOILLIFE; - return true; - } else if ("myKey" == literal) { - *result = P_MYKEY; - return true; - } else if ("airbagStatus" == literal) { - *result = P_AIRBAGSTATUS; - return true; - } else if ("bodyInformation" == literal) { - *result = P_BODYINFORMATION; - return true; - } else if ("clusterModeStatus" == literal) { - *result = P_CLUSTERMODESTATUS; - return true; - } else if ("deviceStatus" == literal) { - *result = P_DEVICESTATUS; - return true; - } else if ("emergencyEvent" == literal) { - *result = P_EMERGENCYEVENT; - return true; - } else if ("eCallInfo" == literal) { - *result = P_ECALLINFO; - return true; - } else if ("abs_State" == literal) { - *result = P_ABS_STATE; - return true; - } else if ("fuelRange" == literal) { - *result = P_FUEL_RANGE; - return true; - } else if ("tirePressureValue" == literal) { - *result = P_TIRE_PRESSURE_VALUE; - return true; - } else if ("tpms" == literal) { - *result = P_TPMS; - return true; - } else if ("longitudeDegrees" == literal) { - *result = P_LONGTITUDE_DEGREES; - return true; - } else if ("latitudeDegrees" == literal) { - *result = P_LATITUDE_DEGREES; - return true; - } else if ("locationName" == literal) { - *result = P_LOCATION_NAME; - return true; - } else if ("locationDescription" == literal) { - *result = P_LOCATION_DESCRIPTION; - return true; - } else if ("addressLines" == literal) { - *result = P_ADDRESS_LINES; - return true; - } else if ("phoneNumber" == literal) { - *result = P_PHONE_NUMBER; - return true; - } else if ("locationImage" == literal) { - *result = P_LOCATION_IMAGE; - return true; - } else if ("deliveryMode" == literal) { - *result = P_DELIVERY_MODE; - return true; - } else if ("timeStamp" == literal) { - *result = P_TIMESTAMP; - return true; - } else if ("address" == literal) { - *result = P_ADDRESS; - return true; - } else if ("EMPTY" == literal) { - *result = P_EMPTY; - return true; - } else { - return false; - } -} - -bool IsValidEnum(AppHMIType val) { - switch (val) { - case AHT_DEFAULT: - return true; - case AHT_COMMUNICATION: - return true; - case AHT_MEDIA: - return true; - case AHT_MESSAGING: - return true; - case AHT_NAVIGATION: - return true; - case AHT_INFORMATION: - return true; - case AHT_SOCIAL: - return true; - case AHT_BACKGROUND_PROCESS: - return true; - case AHT_TESTING: - return true; - case AHT_SYSTEM: - return true; - case AHT_PROJECTION: - return true; - case AHT_REMOTE_CONTROL: - return true; - default: - return false; - } -} -const char* EnumToJsonString(AppHMIType val) { - switch (val) { - case AHT_DEFAULT: - return "DEFAULT"; - case AHT_COMMUNICATION: - return "COMMUNICATION"; - case AHT_MEDIA: - return "MEDIA"; - case AHT_MESSAGING: - return "MESSAGING"; - case AHT_NAVIGATION: - return "NAVIGATION"; - case AHT_INFORMATION: - return "INFORMATION"; - case AHT_SOCIAL: - return "SOCIAL"; - case AHT_BACKGROUND_PROCESS: - return "BACKGROUND_PROCESS"; - case AHT_TESTING: - return "TESTING"; - case AHT_SYSTEM: - return "SYSTEM"; - case AHT_PROJECTION: - return "PROJECTION"; - case AHT_REMOTE_CONTROL: - return "REMOTE_CONTROL"; - default: - return ""; - } -} -bool EnumFromJsonString(const std::string& literal, AppHMIType* result) { - if ("DEFAULT" == literal) { - *result = AHT_DEFAULT; - return true; - } else if ("COMMUNICATION" == literal) { - *result = AHT_COMMUNICATION; - return true; - } else if ("MEDIA" == literal) { - *result = AHT_MEDIA; - return true; - } else if ("MESSAGING" == literal) { - *result = AHT_MESSAGING; - return true; - } else if ("NAVIGATION" == literal) { - *result = AHT_NAVIGATION; - return true; - } else if ("INFORMATION" == literal) { - *result = AHT_INFORMATION; - return true; - } else if ("SOCIAL" == literal) { - *result = AHT_SOCIAL; - return true; - } else if ("BACKGROUND_PROCESS" == literal) { - *result = AHT_BACKGROUND_PROCESS; - return true; - } else if ("TESTING" == literal) { - *result = AHT_TESTING; - return true; - } else if ("SYSTEM" == literal) { - *result = AHT_SYSTEM; - return true; - } else if ("PROJECTION" == literal) { - *result = AHT_PROJECTION; - return true; - } else if ("REMOTE_CONTROL" == literal) { - *result = AHT_REMOTE_CONTROL; - return true; - } else { - return false; - } -} bool IsValidEnum(Input val) { switch (val) { @@ -563,6 +14,7 @@ bool IsValidEnum(Input val) { return false; } } + const char* EnumToJsonString(Input val) { switch (val) { case I_GUI: @@ -585,702 +37,6 @@ bool EnumFromJsonString(const std::string& literal, Input* result) { } } -bool IsValidEnum(RequestType val) { - switch (val) { - case RT_HTTP: - return true; - case RT_FILE_RESUME: - return true; - case RT_AUTH_REQUEST: - return true; - case RT_AUTH_CHALLENGE: - return true; - case RT_AUTH_ACK: - return true; - case RT_PROPRIETARY: - return true; - case RT_QUERY_APPS: - return true; - case RT_LAUNCH_APP: - return true; - case RT_LOCK_SCREEN_ICON_URL: - return true; - case RT_TRAFFIC_MESSAGE_CHANNEL: - return true; - case RT_DRIVER_PROFILE: - return true; - case RT_VOICE_SEARCH: - return true; - case RT_NAVIGATION: - return true; - case RT_PHONE: - return true; - case RT_CLIMATE: - return true; - case RT_SETTINGS: - return true; - case RT_VEHICLE_DIAGNOSTICS: - return true; - case RT_EMERGENCY: - return true; - case RT_MEDIA: - return true; - case RT_FOTA: - return true; - case RT_OEM_SPECIFIC: - return true; - case RT_ICON_URL: - return true; - case RT_EMPTY: - return true; - default: - return false; - } -} - -const char* EnumToJsonString(RequestType val) { - switch (val) { - case RT_HTTP: - return "HTTP"; - case RT_FILE_RESUME: - return "FILE_RESUME"; - case RT_AUTH_REQUEST: - return "AUTH_REQUEST"; - case RT_AUTH_CHALLENGE: - return "AUTH_CHALLENGE"; - case RT_AUTH_ACK: - return "AUTH_ACK"; - case RT_PROPRIETARY: - return "PROPRIETARY"; - case RT_QUERY_APPS: - return "QUERY_APPS"; - case RT_LAUNCH_APP: - return "LAUNCH_APP"; - case RT_LOCK_SCREEN_ICON_URL: - return "LOCK_SCREEN_ICON_URL"; - case RT_TRAFFIC_MESSAGE_CHANNEL: - return "TRAFFIC_MESSAGE_CHANNEL"; - case RT_DRIVER_PROFILE: - return "DRIVER_PROFILE"; - case RT_VOICE_SEARCH: - return "VOICE_SEARCH"; - case RT_NAVIGATION: - return "NAVIGATION"; - case RT_PHONE: - return "PHONE"; - case RT_CLIMATE: - return "CLIMATE"; - case RT_SETTINGS: - return "SETTINGS"; - case RT_VEHICLE_DIAGNOSTICS: - return "VEHICLE_DIAGNOSTICS"; - case RT_EMERGENCY: - return "EMERGENCY"; - case RT_MEDIA: - return "MEDIA"; - case RT_FOTA: - return "FOTA"; - case RT_OEM_SPECIFIC: - return "OEM_SPECIFIC"; - case RT_ICON_URL: - return "ICON_URL"; - case RT_EMPTY: - return "EMPTY"; - default: - return ""; - } -} - -bool EnumFromJsonString(const std::string& literal, RequestType* result) { - if ("HTTP" == literal) { - *result = RT_HTTP; - return true; - } - if ("FILE_RESUME" == literal) { - *result = RT_FILE_RESUME; - return true; - } - if ("AUTH_REQUEST" == literal) { - *result = RT_AUTH_REQUEST; - return true; - } - if ("AUTH_CHALLENGE" == literal) { - *result = RT_AUTH_CHALLENGE; - return true; - } - if ("AUTH_ACK" == literal) { - *result = RT_AUTH_ACK; - return true; - } - if ("PROPRIETARY" == literal) { - *result = RT_PROPRIETARY; - return true; - } - if ("QUERY_APPS" == literal) { - *result = RT_QUERY_APPS; - return true; - } - if ("LAUNCH_APP" == literal) { - *result = RT_LAUNCH_APP; - return true; - } - if ("LOCK_SCREEN_ICON_URL" == literal) { - *result = RT_LOCK_SCREEN_ICON_URL; - return true; - } - if ("TRAFFIC_MESSAGE_CHANNEL" == literal) { - *result = RT_TRAFFIC_MESSAGE_CHANNEL; - return true; - } - if ("DRIVER_PROFILE" == literal) { - *result = RT_DRIVER_PROFILE; - return true; - } - if ("VOICE_SEARCH" == literal) { - *result = RT_VOICE_SEARCH; - return true; - } - if ("NAVIGATION" == literal) { - *result = RT_NAVIGATION; - return true; - } - if ("PHONE" == literal) { - *result = RT_PHONE; - return true; - } - if ("CLIMATE" == literal) { - *result = RT_CLIMATE; - return true; - } - if ("SETTINGS" == literal) { - *result = RT_SETTINGS; - return true; - } - if ("VEHICLE_DIAGNOSTICS" == literal) { - *result = RT_VEHICLE_DIAGNOSTICS; - return true; - } - if ("EMERGENCY" == literal) { - *result = RT_EMERGENCY; - return true; - } - if ("MEDIA" == literal) { - *result = RT_MEDIA; - return true; - } - if ("FOTA" == literal) { - *result = RT_FOTA; - return true; - } - if ("OEM_SPECIFIC" == literal) { - *result = RT_OEM_SPECIFIC; - return true; - } - if ("ICON_URL" == literal) { - *result = RT_ICON_URL; - return true; - } - if ("EMPTY" == literal) { - *result = RT_EMPTY; - return true; - } else { - return false; - } -} - -bool IsValidEnum(ModuleType val) { - switch (val) { - case MT_CLIMATE: - 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; - case MT_EMPTY: - return true; - default: - return false; - } -} -const char* EnumToJsonString(ModuleType val) { - switch (val) { - case MT_CLIMATE: - 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"; - case MT_EMPTY: - return "EMPTY"; - default: - return ""; - } -} - -bool EnumFromJsonString(const std::string& literal, ModuleType* result) { - if ("CLIMATE" == literal) { - *result = MT_CLIMATE; - return true; - } else if ("RADIO" == literal) { - *result = MT_RADIO; - return true; - } 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 if ("EMPTY" == literal) { - *result = MT_EMPTY; - return true; - } else { - return false; - } -} - -bool IsValidEnum(HybridAppPreference val) { - return strlen(EnumToJsonString(val)) > 0; -} - -const char* EnumToJsonString(HybridAppPreference val) { - switch (val) { - case HAP_MOBILE: - return "MOBILE"; - case HAP_CLOUD: - return "CLOUD"; - case HAP_BOTH: - return "BOTH"; - default: - return ""; - } -} - -bool EnumFromJsonString(const std::string& literal, - HybridAppPreference* result) { - if ("MOBILE" == literal) { - *result = HAP_MOBILE; - return true; - } else if ("CLOUD" == literal) { - *result = HAP_CLOUD; - return true; - } else if ("BOTH" == literal) { - *result = HAP_BOTH; - return true; - } - return false; -} - -bool EnumFromJsonString(const std::string& literal, FunctionID* result) { - if ("RegisterAppInterface" == literal) { - *result = RegisterAppInterfaceID; - return true; - } - - if ("UnregisterAppInterface" == literal) { - *result = UnregisterAppInterfaceID; - return true; - } - - if ("SetGlobalProperties" == literal) { - *result = SetGlobalPropertiesID; - return true; - } - - if ("ResetGlobalProperties" == literal) { - *result = ResetGlobalPropertiesID; - return true; - } - - if ("AddCommand" == literal) { - *result = AddCommandID; - return true; - } - - if ("DeleteCommand" == literal) { - *result = DeleteCommandID; - return true; - } - - if ("AddSubMenu" == literal) { - *result = AddSubMenuID; - return true; - } - - if ("DeleteSubMenu" == literal) { - *result = DeleteSubMenuID; - return true; - } - - if ("CreateInteractionChoiceSet" == literal) { - *result = CreateInteractionChoiceSetID; - return true; - } - - if ("PerformInteraction" == literal) { - *result = PerformInteractionID; - return true; - } - - if ("DeleteInteractionChoiceSet" == literal) { - *result = DeleteInteractionChoiceSetID; - return true; - } - - if ("Alert" == literal) { - *result = AlertID; - return true; - } - - if ("Show" == literal) { - *result = ShowID; - return true; - } - - if ("Speak" == literal) { - *result = SpeakID; - return true; - } - - if ("SetMediaClockTimer" == literal) { - *result = SetMediaClockTimerID; - return true; - } - - if ("PerformAudioPassThru" == literal) { - *result = PerformAudioPassThruID; - return true; - } - - if ("EndAudioPassThru" == literal) { - *result = EndAudioPassThruID; - return true; - } - - if ("SubscribeButton" == literal) { - *result = SubscribeButtonID; - return true; - } - - if ("UnsubscribeButton" == literal) { - *result = UnsubscribeButtonID; - return true; - } - - if ("SubscribeVehicleData" == literal) { - *result = SubscribeVehicleDataID; - return true; - } - - if ("UnsubscribeVehicleData" == literal) { - *result = UnsubscribeVehicleDataID; - return true; - } - - if ("GetVehicleData" == literal) { - *result = GetVehicleDataID; - return true; - } - - if ("ReadDID" == literal) { - *result = ReadDIDID; - return true; - } - - if ("GetDTCs" == literal) { - *result = GetDTCsID; - return true; - } - - if ("ScrollableMessage" == literal) { - *result = ScrollableMessageID; - return true; - } - - if ("Slider" == literal) { - *result = SliderID; - return true; - } - - if ("ShowConstantTBT" == literal) { - *result = ShowConstantTBTID; - return true; - } - - if ("AlertManeuver" == literal) { - *result = AlertManeuverID; - return true; - } - - if ("UpdateTurnList" == literal) { - *result = UpdateTurnListID; - return true; - } - - if ("ChangeRegistration" == literal) { - *result = ChangeRegistrationID; - return true; - } - - if ("GenericResponse" == literal) { - *result = GenericResponseID; - return true; - } - - if ("PutFile" == literal) { - *result = PutFileID; - return true; - } - - if ("DeleteFile" == literal) { - *result = DeleteFileID; - return true; - } - - if ("ListFiles" == literal) { - *result = ListFilesID; - return true; - } - - if ("SetAppIcon" == literal) { - *result = SetAppIconID; - return true; - } - - if ("SetDisplayLayout" == literal) { - *result = SetDisplayLayoutID; - return true; - } - - if ("DiagnosticMessage" == literal) { - *result = DiagnosticMessageID; - return true; - } - - if ("SystemRequest" == literal) { - *result = SystemRequestID; - return true; - } - - if ("SendLocation" == literal) { - *result = SendLocationID; - return true; - } - - if ("DialNumber" == literal) { - *result = DialNumberID; - return true; - } - - if ("ButtonPress" == literal) { - *result = ButtonPressID; - return true; - } - - if ("GetInteriorVehicleData" == literal) { - *result = GetInteriorVehicleDataID; - return true; - } - - if ("SetInteriorVehicleData" == literal) { - *result = SetInteriorVehicleDataID; - return true; - } - - if ("GetWayPoints" == literal) { - *result = GetWayPointsID; - return true; - } - - if ("SubscribeWayPoints" == literal) { - *result = SubscribeWayPointsID; - return true; - } - - if ("UnsubscribeWayPoints" == literal) { - *result = UnsubscribeWayPointsID; - return true; - } - - if ("GetSystemCapability" == literal) { - *result = GetSystemCapabilityID; - return true; - } - - if ("SendHapticData" == literal) { - *result = SendHapticDataID; - return true; - } - - if ("SetCloudAppProperties" == literal) { - *result = SetCloudAppPropertiesID; - return true; - } - - if ("GetCloudAppProperties" == literal) { - *result = GetCloudAppPropertiesID; - return true; - } - - if ("PublishAppService" == literal) { - *result = PublishAppServiceID; - return true; - } - - if ("GetFile" == literal) { - *result = GetFileID; - return true; - } - - if ("GetAppServiceData" == literal) { - *result = GetAppServiceDataID; - return true; - } - - if ("PerformAppServiceInteraction" == literal) { - *result = PerformAppServiceInteractionID; - return true; - } - - if ("OnHMIStatus" == literal) { - *result = OnHMIStatusID; - return true; - } - - if ("OnAppInterfaceUnregistered" == literal) { - *result = OnAppInterfaceUnregisteredID; - return true; - } - - if ("OnButtonEvent" == literal) { - *result = OnButtonEventID; - return true; - } - - if ("OnButtonPress" == literal) { - *result = OnButtonPressID; - return true; - } - - if ("OnVehicleData" == literal) { - *result = OnVehicleDataID; - return true; - } - - if ("OnCommand" == literal) { - *result = OnCommandID; - return true; - } - - if ("OnTBTClientState" == literal) { - *result = OnTBTClientStateID; - return true; - } - - if ("OnDriverDistraction" == literal) { - *result = OnDriverDistractionID; - return true; - } - - if ("OnPermissionsChange" == literal) { - *result = OnPermissionsChangeID; - return true; - } - - if ("OnAudioPassThru" == literal) { - *result = OnAudioPassThruID; - return true; - } - - if ("OnLanguageChange" == literal) { - *result = OnLanguageChangeID; - return true; - } - - if ("OnKeyboardInput" == literal) { - *result = OnKeyboardInputID; - return true; - } - - if ("OnTouchEvent" == literal) { - *result = OnTouchEventID; - return true; - } - - if ("OnSystemRequest" == literal) { - *result = OnSystemRequestID; - return true; - } - - if ("OnHashChange" == literal) { - *result = OnHashChangeID; - return true; - } - - if ("OnInteriorVehicleData" == literal) { - *result = OnInteriorVehicleDataID; - return true; - } - - if ("OnWayPointChange" == literal) { - *result = OnWayPointChangeID; - return true; - } - - if ("OnRCStatus" == literal) { - *result = OnRCStatusID; - return true; - } - - if ("OnAppServiceData" == literal) { - *result = OnAppServiceDataID; - return true; - } - - if ("OnSystemCapabilityUpdated" == literal) { - *result = OnSystemCapabilityUpdatedID; - return true; - } - - if ("EncodedSyncPData" == literal) { - *result = EncodedSyncPDataID; - return true; - } - - if ("SyncPData" == literal) { - *result = SyncPDataID; - return true; - } - - if ("OnEncodedSyncPData" == literal) { - *result = OnEncodedSyncPDataID; - return true; - } - - if ("OnSyncPData" == literal) { - *result = OnSyncPDataID; - return true; - } - return false; -}; - const std::string kDefaultApp = "default"; const std::string kPreDataConsentApp = "pre_DataConsent"; const std::string kDeviceApp = "device"; diff --git a/src/components/policy/policy_external/src/policy_table/types.cc b/src/components/policy/policy_external/src/policy_table/types.cc index f95b270fdf1..f0ea154f94f 100644 --- a/src/components/policy/policy_external/src/policy_table/types.cc +++ b/src/components/policy/policy_external/src/policy_table/types.cc @@ -1,5 +1,5 @@ -#include #include "policy/policy_table/types.h" +#include #include "rpc_base/rpc_base_json_inl.h" namespace rpc { @@ -45,7 +45,6 @@ PolicyBase::PolicyBase(const Json::Value* value__) , default_hmi(impl::ValueMember(value__, "default_hmi")) , keep_context(impl::ValueMember(value__, "keep_context")) , steal_focus(impl::ValueMember(value__, "steal_focus")) {} - Json::Value PolicyBase::ToJsonValue() const { Json::Value result__(Json::objectValue); impl::WriteJsonField("groups", groups, &result__); @@ -355,7 +354,8 @@ ApplicationParams::ApplicationParams(const Json::Value* value__) , icon_url(impl::ValueMember(value__, "icon_url")) , app_service_parameters(impl::ValueMember(value__, "app_services")) , allow_unknown_rpc_passthrough( - impl::ValueMember(value__, "allow_unknown_rpc_passthrough")) {} + impl::ValueMember(value__, "allow_unknown_rpc_passthrough")) + , encryption_required(impl::ValueMember(value__, "encryption_required")) {} Json::Value ApplicationParams::ToJsonValue() const { Json::Value result__(PolicyBase::ToJsonValue()); @@ -379,6 +379,7 @@ Json::Value ApplicationParams::ToJsonValue() const { impl::WriteJsonField("allow_unknown_rpc_passthrough", allow_unknown_rpc_passthrough, &result__); + impl::WriteJsonField("encryption_required", encryption_required, &result__); return result__; } @@ -430,6 +431,9 @@ bool ApplicationParams::is_valid() const { if (!allow_unknown_rpc_passthrough.is_valid()) { return false; } + if (!encryption_required.is_valid()) { + return false; + } return Validate(); } @@ -489,6 +493,9 @@ bool ApplicationParams::struct_empty() const { if (allow_unknown_rpc_passthrough.is_initialized()) { return false; } + if (!encryption_required.is_valid()) { + return false; + } return true; } @@ -567,6 +574,10 @@ void ApplicationParams::ReportErrors(rpc::ValidationReport* report__) const { allow_unknown_rpc_passthrough.ReportErrors( &report__->ReportSubobject("allow_unknown_rpc_passthrough")); } + if (!encryption_required.is_valid()) { + encryption_required.ReportErrors( + &report__->ReportSubobject("encryption_required")); + } } void ApplicationParams::SetPolicyTableType(PolicyTableType pt_type) { @@ -663,7 +674,8 @@ Rpcs::Rpcs(const Json::Value* value__) , disallowed_by_external_consent_entities_on(impl::ValueMember( value__, "disallowed_by_external_consent_entities_on")) , disallowed_by_external_consent_entities_off(impl::ValueMember( - value__, "disallowed_by_external_consent_entities_off")) {} + value__, "disallowed_by_external_consent_entities_off")) + , encryption_required(impl::ValueMember(value__, "encryption_required")) {} Json::Value Rpcs::ToJsonValue() const { Json::Value result__(Json::objectValue); @@ -675,6 +687,7 @@ Json::Value Rpcs::ToJsonValue() const { impl::WriteJsonField("disallowed_by_external_consent_entities_off", disallowed_by_external_consent_entities_off, &result__); + impl::WriteJsonField("encryption_required", encryption_required, &result__); return result__; } @@ -691,6 +704,9 @@ bool Rpcs::is_valid() const { if (!disallowed_by_external_consent_entities_off.is_valid()) { return false; } + if (!encryption_required.is_valid()) { + return false; + } return Validate(); } @@ -711,6 +727,9 @@ bool Rpcs::struct_empty() const { if (disallowed_by_external_consent_entities_off.is_initialized()) { return false; } + if (encryption_required.is_initialized()) { + return false; + } return true; } @@ -735,6 +754,10 @@ void Rpcs::ReportErrors(rpc::ValidationReport* report__) const { &report__->ReportSubobject( "disallowed_by_external_consent_entities_off")); } + if (!encryption_required.is_valid()) { + encryption_required.ReportErrors( + &report__->ReportSubobject("encryption_required")); + } } void Rpcs::SetPolicyTableType(PolicyTableType pt_type) { @@ -745,9 +768,60 @@ void Rpcs::SetPolicyTableType(PolicyTableType pt_type) { disallowed_by_external_consent_entities_on.SetPolicyTableType(pt_type); } +// EndpointProperties methods +EndpointProperty::EndpointProperty() : CompositeType(kUninitialized) {} + +EndpointProperty::~EndpointProperty() {} + +EndpointProperty::EndpointProperty(const Json::Value* value__) + : CompositeType(InitHelper(value__, &Json::Value::isObject)) + , version(impl::ValueMember(value__, "version")) {} + +Json::Value EndpointProperty::ToJsonValue() const { + Json::Value result__(Json::objectValue); + impl::WriteJsonField("version", version, &result__); + return result__; +} + +bool EndpointProperty::is_valid() const { + if (!version.is_valid()) { + return false; + } + return Validate(); +} + +bool EndpointProperty::is_initialized() const { + return (initialization_state__ != kUninitialized) || (!struct_empty()); +} + +bool EndpointProperty::struct_empty() const { + if (version.is_initialized()) { + return false; + } + + return true; +} + +void EndpointProperty::ReportErrors(rpc::ValidationReport* report__) const { + if (struct_empty()) { + rpc::CompositeType::ReportErrors(report__); + } + if (!version.is_valid()) { + version.ReportErrors(&report__->ReportSubobject("version")); + } +} + +void EndpointProperty::SetPolicyTableType(PolicyTableType pt_type) { + CompositeType::SetPolicyTableType(pt_type); + version.SetPolicyTableType(pt_type); +} + // ModuleConfig methods ModuleConfig::ModuleConfig() : CompositeType(kUninitialized) {} +const std::string ModuleConfig::kDefaultOemMappingServiceName = + "custom_vehicle_data_mapping_url"; + ModuleConfig::ModuleConfig( uint8_t exchange_after_x_ignition_cycles, int64_t exchange_after_x_kilometers, @@ -755,6 +829,7 @@ ModuleConfig::ModuleConfig( uint16_t timeout_after_x_seconds, const SecondsBetweenRetries& seconds_between_retries, const ServiceEndpoints& endpoints, + const ServiceEndpointProperties& endpoint_properties, const NumberOfNotificationsPerMinute& notifications_per_minute_by_priority) : CompositeType(kUninitialized) , exchange_after_x_ignition_cycles(exchange_after_x_ignition_cycles) @@ -763,6 +838,7 @@ ModuleConfig::ModuleConfig( , timeout_after_x_seconds(timeout_after_x_seconds) , seconds_between_retries(seconds_between_retries) , endpoints(endpoints) + , endpoint_properties(endpoint_properties) , notifications_per_minute_by_priority( notifications_per_minute_by_priority) {} @@ -780,6 +856,7 @@ ModuleConfig::ModuleConfig(const Json::Value* value__) , seconds_between_retries( impl::ValueMember(value__, "seconds_between_retries")) , endpoints(impl::ValueMember(value__, "endpoints")) + , endpoint_properties(impl::ValueMember(value__, "endpoint_properties")) , notifications_per_minute_by_priority( impl::ValueMember(value__, "notifications_per_minute_by_priority")) , vehicle_make(impl::ValueMember(value__, "vehicle_make")) @@ -788,8 +865,9 @@ ModuleConfig::ModuleConfig(const Json::Value* value__) , preloaded_date(impl::ValueMember(value__, "preloaded_date")) , certificate(impl::ValueMember(value__, "certificate")) , preloaded_pt(impl::ValueMember(value__, "preloaded_pt")) - , full_app_id_supported( - impl::ValueMember(value__, "full_app_id_supported")) {} + , full_app_id_supported(impl::ValueMember(value__, "full_app_id_supported")) + , lock_screen_dismissal_enabled( + impl::ValueMember(value__, "lock_screen_dismissal_enabled")) {} void ModuleConfig::SafeCopyFrom(const ModuleConfig& from) { exchange_after_x_days = from.exchange_after_x_days; @@ -799,8 +877,10 @@ void ModuleConfig::SafeCopyFrom(const ModuleConfig& from) { timeout_after_x_seconds = from.timeout_after_x_seconds; seconds_between_retries = from.seconds_between_retries; endpoints = from.endpoints; + endpoint_properties = from.endpoint_properties; notifications_per_minute_by_priority = from.notifications_per_minute_by_priority; + lock_screen_dismissal_enabled = from.lock_screen_dismissal_enabled; certificate.assign_if_valid(from.certificate); vehicle_make.assign_if_valid(from.vehicle_make); @@ -826,6 +906,7 @@ Json::Value ModuleConfig::ToJsonValue() const { impl::WriteJsonField( "seconds_between_retries", seconds_between_retries, &result__); impl::WriteJsonField("endpoints", endpoints, &result__); + impl::WriteJsonField("endpoint_properties", endpoint_properties, &result__); impl::WriteJsonField("notifications_per_minute_by_priority", notifications_per_minute_by_priority, &result__); @@ -834,6 +915,9 @@ Json::Value ModuleConfig::ToJsonValue() const { impl::WriteJsonField("vehicle_year", vehicle_year, &result__); impl::WriteJsonField("certificate", certificate, &result__); impl::WriteJsonField("preloaded_date", preloaded_date, &result__); + impl::WriteJsonField("lock_screen_dismissal_enabled", + lock_screen_dismissal_enabled, + &result__); return result__; } @@ -865,6 +949,9 @@ bool ModuleConfig::is_valid() const { if (!endpoints.is_valid()) { return false; } + if (!endpoint_properties.is_valid()) { + return false; + } if (!notifications_per_minute_by_priority.is_valid()) { return false; } @@ -883,6 +970,9 @@ bool ModuleConfig::is_valid() const { if (!preloaded_date.is_valid()) { return false; } + if (!lock_screen_dismissal_enabled.is_valid()) { + return false; + } return Validate(); } @@ -922,9 +1012,16 @@ bool ModuleConfig::struct_empty() const { return false; } + if (endpoint_properties.is_initialized()) { + return false; + } + if (notifications_per_minute_by_priority.is_initialized()) { return false; } + if (lock_screen_dismissal_enabled.is_initialized()) { + return false; + } if (vehicle_make.is_initialized()) { return false; } @@ -975,10 +1072,18 @@ void ModuleConfig::ReportErrors(rpc::ValidationReport* report__) const { if (!endpoints.is_valid()) { endpoints.ReportErrors(&report__->ReportSubobject("endpoints")); } + if (!endpoint_properties.is_valid()) { + endpoint_properties.ReportErrors( + &report__->ReportSubobject("endpoint_properties")); + } if (!notifications_per_minute_by_priority.is_valid()) { notifications_per_minute_by_priority.ReportErrors( &report__->ReportSubobject("notifications_per_minute_by_priority")); } + if (!lock_screen_dismissal_enabled.is_valid()) { + lock_screen_dismissal_enabled.ReportErrors( + &report__->ReportSubobject("lock_screen_dismissal_enabled")); + } if (!vehicle_make.is_valid()) { vehicle_make.ReportErrors(&report__->ReportSubobject("vehicle_make")); } @@ -1036,7 +1141,9 @@ void ModuleConfig::SetPolicyTableType(PolicyTableType pt_type) { timeout_after_x_seconds.SetPolicyTableType(pt_type); seconds_between_retries.SetPolicyTableType(pt_type); endpoints.SetPolicyTableType(pt_type); + endpoint_properties.SetPolicyTableType(pt_type); notifications_per_minute_by_priority.SetPolicyTableType(pt_type); + lock_screen_dismissal_enabled.SetPolicyTableType(pt_type); vehicle_make.SetPolicyTableType(pt_type); vehicle_model.SetPolicyTableType(pt_type); vehicle_year.SetPolicyTableType(pt_type); @@ -2076,6 +2183,416 @@ void DeviceParams::SetPolicyTableType(PolicyTableType pt_type) { connection_type.SetPolicyTableType(pt_type); } +// VehicleDataItem methods +VehicleDataItem::VehicleDataItem() : CompositeType(kUninitialized) {} + +VehicleDataItem::VehicleDataItem(const VehicleDataItem& vehicle_data) + : CompositeType(vehicle_data.initialization_state__) + , name(vehicle_data.name) + , type(vehicle_data.type) + , key(vehicle_data.key) + , mandatory(vehicle_data.mandatory) + , params(vehicle_data.params) + , array(vehicle_data.array) + , since(vehicle_data.since) + , until(vehicle_data.until) + , removed(vehicle_data.removed) + , deprecated(vehicle_data.deprecated) + , minvalue(vehicle_data.minvalue) + , maxvalue(vehicle_data.maxvalue) + , minsize(vehicle_data.minsize) + , maxsize(vehicle_data.maxsize) + , minlength(vehicle_data.minlength) + , maxlength(vehicle_data.maxlength) {} + +VehicleDataItem::VehicleDataItem(const Json::Value* value__) + : CompositeType(InitHelper(value__, &Json::Value::isObject)) + , name(impl::ValueMember(value__, "name")) + , type(impl::ValueMember(value__, "type")) + , key(impl::ValueMember(value__, "key")) + , mandatory(impl::ValueMember(value__, "mandatory")) + , params(impl::ValueMember(value__, "params")) + , array(impl::ValueMember(value__, "array")) + , since(impl::ValueMember(value__, "since")) + , until(impl::ValueMember(value__, "until")) + , removed(impl::ValueMember(value__, "removed")) + , deprecated(impl::ValueMember(value__, "deprecated")) + , minvalue(impl::ValueMember(value__, "minvalue")) + , maxvalue(impl::ValueMember(value__, "maxvalue")) + , minsize(impl::ValueMember(value__, "minsize")) + , maxsize(impl::ValueMember(value__, "maxsize")) + , minlength(impl::ValueMember(value__, "minlength")) + , maxlength(impl::ValueMember(value__, "maxlength")) {} + +VehicleDataItem::~VehicleDataItem() {} + +const std::string VehicleDataItem::kInteger = "Integer"; +const std::string VehicleDataItem::kStruct = "Struct"; +const std::string VehicleDataItem::kString = "String"; +const std::string VehicleDataItem::kFloat = "Float"; +const std::string VehicleDataItem::kDouble = "Double"; +const std::string VehicleDataItem::kBoolean = "Boolean"; + +const std::vector VehicleDataItem::kPODTypes = { + kInteger, kFloat, kDouble, kString, kBoolean}; + +Json::Value VehicleDataItem::ToJsonValue() const { + Json::Value ret(Json::objectValue); + impl::WriteJsonField("name", name, &ret); + impl::WriteJsonField("type", type, &ret); + impl::WriteJsonField("key", key, &ret); + impl::WriteJsonField("array", array, &ret); + impl::WriteJsonField("mandatory", mandatory, &ret); + impl::WriteJsonField("params", params, &ret); + impl::WriteJsonField("since", since, &ret); + impl::WriteJsonField("until", until, &ret); + impl::WriteJsonField("removed", removed, &ret); + impl::WriteJsonField("deprecated", deprecated, &ret); + impl::WriteJsonField("minvalue", minvalue, &ret); + impl::WriteJsonField("maxvalue", maxvalue, &ret); + impl::WriteJsonField("minsize", minsize, &ret); + impl::WriteJsonField("maxsize", maxsize, &ret); + impl::WriteJsonField("minlength", minlength, &ret); + impl::WriteJsonField("maxlength", maxlength, &ret); + return ret; +} + +bool VehicleDataItem::operator==(const VehicleDataItem& vd) { + return (name == vd.name && type == vd.type && key == vd.key && + mandatory == vd.mandatory && params == vd.params && + array == vd.array && since == vd.since && until == vd.until && + removed == vd.removed && deprecated == vd.deprecated && + minvalue == vd.minvalue && maxvalue == vd.maxvalue && + minsize == vd.minsize && maxsize == vd.maxsize && + minlength == vd.minlength && maxlength == vd.maxlength); +} + +bool VehicleDataItem::is_valid() const { + if (!name.is_valid()) { + return false; + } + if (!type.is_valid()) { + return false; + } + if (!key.is_valid()) { + return false; + } + if (!array.is_valid()) { + return false; + } + if (!mandatory.is_valid()) { + return false; + } + if (!params.is_valid()) { + return false; + } + if (!since.is_valid()) { + return false; + } + if (!until.is_valid()) { + return false; + } + if (!removed.is_valid()) { + return false; + } + if (!deprecated.is_valid()) { + return false; + } + if (!minvalue.is_valid()) { + return false; + } + if (!maxvalue.is_valid()) { + return false; + } + if (!minsize.is_valid()) { + return false; + } + if (!maxsize.is_valid()) { + return false; + } + if (!minlength.is_valid()) { + return false; + } + if (!maxlength.is_valid()) { + return false; + } + return Validate(); +} + +bool VehicleDataItem::is_initialized() const { + return (initialization_state__ != kUninitialized) || (struct_not_empty()); +} + +bool VehicleDataItem::struct_not_empty() const { + if (!name.is_initialized()) { + return false; + } + if (!type.is_initialized()) { + return false; + } + if (!key.is_initialized()) { + return false; + } + if (!array.is_initialized()) { + return false; + } + if (!mandatory.is_initialized()) { + return false; + } + if (!params.is_initialized()) { + return false; + } + if (!since.is_initialized()) { + return false; + } + if (!until.is_initialized()) { + return false; + } + if (!removed.is_initialized()) { + return false; + } + if (!deprecated.is_initialized()) { + return false; + } + if (!minvalue.is_initialized()) { + return false; + } + if (!maxvalue.is_initialized()) { + return false; + } + if (!minsize.is_initialized()) { + return false; + } + if (!maxsize.is_initialized()) { + return false; + } + if (!minlength.is_initialized()) { + return false; + } + if (!maxlength.is_initialized()) { + return false; + } + return true; +} + +void VehicleDataItem::ReportErrors(rpc::ValidationReport* report__) const { + if (!struct_not_empty()) { + rpc::CompositeType::ReportErrors(report__); + } + if (!name.is_valid()) { + name.ReportErrors(&report__->ReportSubobject("name")); + } + + if (!ValidateNaming(std::string(name))) { + report__->set_validation_info( + "Invalid name values [" + std::string(name) + + "]. It should not contain spaces or invalid chars."); + } + if (!type.is_valid()) { + type.ReportErrors(&report__->ReportSubobject("type")); + } + if (type.is_initialized() && !ValidateTypes()) { + report__->set_validation_info("Unknown type [" + std::string(name) + + "]: '" + std::string(type) + "'."); + } + if (!key.is_valid()) { + key.ReportErrors(&report__->ReportSubobject("key")); + } + if (!ValidateNaming(std::string(key))) { + report__->set_validation_info( + "Invalid key values [" + std::string(key) + + "]. It should not contain spaces or invalid chars."); + } + if (!array.is_valid()) { + array.ReportErrors(&report__->ReportSubobject("array")); + } + if (!mandatory.is_valid()) { + mandatory.ReportErrors(&report__->ReportSubobject("mandatory")); + } + if (!params.is_valid()) { + params.ReportErrors(&report__->ReportSubobject("params")); + } + if (!since.is_valid()) { + since.ReportErrors(&report__->ReportSubobject("since")); + } + if (!until.is_valid()) { + until.ReportErrors(&report__->ReportSubobject("until")); + } + if (!removed.is_valid()) { + removed.ReportErrors(&report__->ReportSubobject("removed")); + } + if (!deprecated.is_valid()) { + deprecated.ReportErrors(&report__->ReportSubobject("deprecated")); + } + if (!minvalue.is_valid()) { + minvalue.ReportErrors(&report__->ReportSubobject("minvalue")); + } + if (!maxvalue.is_valid()) { + maxvalue.ReportErrors(&report__->ReportSubobject("maxvalue")); + } + if (!minsize.is_valid()) { + minsize.ReportErrors(&report__->ReportSubobject("minsize")); + } + if (!maxsize.is_valid()) { + maxsize.ReportErrors(&report__->ReportSubobject("maxsize")); + } + if (!minlength.is_valid()) { + minlength.ReportErrors(&report__->ReportSubobject("minlength")); + } + if (!maxlength.is_valid()) { + maxlength.ReportErrors(&report__->ReportSubobject("maxlength")); + } +} + +void VehicleDataItem::SetPolicyTableType(PolicyTableType pt_type) { + CompositeType::SetPolicyTableType(pt_type); + name.SetPolicyTableType(pt_type); + type.SetPolicyTableType(pt_type); + key.SetPolicyTableType(pt_type); + array.SetPolicyTableType(pt_type); + mandatory.SetPolicyTableType(pt_type); + params.SetPolicyTableType(pt_type); + since.SetPolicyTableType(pt_type); + until.SetPolicyTableType(pt_type); + removed.SetPolicyTableType(pt_type); + deprecated.SetPolicyTableType(pt_type); + minvalue.SetPolicyTableType(pt_type); + maxvalue.SetPolicyTableType(pt_type); + minsize.SetPolicyTableType(pt_type); + maxsize.SetPolicyTableType(pt_type); + minlength.SetPolicyTableType(pt_type); + maxlength.SetPolicyTableType(pt_type); +} + +bool VehicleDataItem::ValidateNaming(std::string str) const { + auto contains_spec_chars = [](std::string str) { + const auto invalid_chars = "!@#$%^&*"; + return str.npos != str.find_first_of(invalid_chars); + }; + + auto contains_spaces = [](std::string str) { + const auto found_space = + std::find_if(str.begin(), str.end(), [](unsigned char ch) { + return std::isspace(ch); + }); + + return found_space != str.end(); + }; + + auto empty_string = [](std::string str) { + str.erase(std::remove_if(str.begin(), + str.end(), + [](unsigned char ch) { return std::isspace(ch); }), + str.end()); + return str.length() < 1; + }; + + return !empty_string(str) && !contains_spaces(str) && + !contains_spec_chars(str); +} + +bool VehicleDataItem::ValidateTypes() const { + if (VehicleDataItem::kStruct == std::string(type)) { + return params.is_initialized() && !(params->empty()) && params.is_valid(); + } + // params should be empty for POD types and for enum values + return (!(params.is_initialized()) || params->empty()); +} + +bool VehicleDataItem::IsPrimitiveType() const { + return helpers::in_range(kPODTypes, std::string(type)); +} + +// VehicleData methods +VehicleData::VehicleData() : CompositeType(kUninitialized) {} + +VehicleData::VehicleData(const VehicleData& vehicle_data) + : CompositeType(vehicle_data.initialization_state__) + , schema_version(vehicle_data.schema_version) + , schema_items(vehicle_data.schema_items) {} + +VehicleData::VehicleData(const Json::Value* value__) + : CompositeType(InitHelper(value__, &Json::Value::isObject)) + , schema_version(impl::ValueMember(value__, "schema_version")) + , schema_items(impl::ValueMember(value__, "schema_items")) {} + +VehicleData::~VehicleData() {} + +bool VehicleData::is_valid() const { + if (!schema_version.is_valid()) { + return false; + } + if (!schema_items.is_valid()) { + return false; + } + return Validate(); +} + +bool VehicleData::is_initialized() const { + return (initialization_state__ != kUninitialized) || (!struct_empty()); +} + +bool VehicleData::struct_empty() const { + if (schema_version.is_initialized()) { + return false; + } + if (schema_items.is_initialized()) { + return false; + } + return true; +} + +Json::Value VehicleData::ToJsonValue() const { + Json::Value ret(Json::objectValue); + impl::WriteJsonField("schema_version", schema_version, &ret); + impl::WriteJsonField("schema_items", schema_items, &ret); + return ret; +} + +void VehicleData::ReportErrors(rpc::ValidationReport* report__) const { + if (struct_empty()) { + rpc::CompositeType::ReportErrors(report__); + } + const auto pt_type = GetPolicyTableType(); + const auto pt_type_str = PolicyTableTypeToString(pt_type); + std::string validation_info = ""; + + if (PT_SNAPSHOT == pt_type) { + if (schema_items.is_initialized()) { + validation_info += + "; schema_items " + omitted_validation_info + pt_type_str; + } + if (!schema_version.is_initialized()) { + validation_info += + "; schema_version " + required_validation_info + pt_type_str; + } + report__->set_validation_info(validation_info); + } + if (PT_UPDATE == pt_type || PT_PRELOADED == pt_type) { + if ((schema_version.is_initialized() && !schema_items.is_initialized()) || + (!schema_version.is_initialized() && schema_items.is_initialized())) { + validation_info += + "; if schema_version exist, schema_items should " + "also exist in " + + pt_type_str; + } + report__->set_validation_info(validation_info); + } + + if (!schema_version.is_valid()) { + schema_version.ReportErrors(&report__->ReportSubobject("schema_version")); + } + if (!schema_items.is_valid()) { + schema_items.ReportErrors(&report__->ReportSubobject("schema_items")); + } +} + +void VehicleData::SetPolicyTableType(PolicyTableType pt_type) { + CompositeType::SetPolicyTableType(pt_type); + schema_version.SetPolicyTableType(pt_type); + schema_items.SetPolicyTableType(pt_type); +} + // PolicyTable methods PolicyTable::PolicyTable() : CompositeType(kUninitialized) {} @@ -2102,7 +2619,8 @@ PolicyTable::PolicyTable(const Json::Value* value__) , module_meta(impl::ValueMember(value__, "module_meta")) , usage_and_error_counts( impl::ValueMember(value__, "usage_and_error_counts")) - , device_data(impl::ValueMember(value__, "device_data")) {} + , device_data(impl::ValueMember(value__, "device_data")) + , vehicle_data(impl::ValueMember(value__, "vehicle_data")) {} Json::Value PolicyTable::ToJsonValue() const { Json::Value result__(Json::objectValue); @@ -2115,6 +2633,7 @@ Json::Value PolicyTable::ToJsonValue() const { impl::WriteJsonField( "usage_and_error_counts", usage_and_error_counts, &result__); impl::WriteJsonField("device_data", device_data, &result__); + impl::WriteJsonField("vehicle_data", vehicle_data, &result__); return result__; } @@ -2140,6 +2659,9 @@ bool PolicyTable::is_valid() const { if (!device_data.is_valid()) { return false; } + if (!vehicle_data.is_valid()) { + return false; + } return Validate(); } @@ -2172,6 +2694,10 @@ bool PolicyTable::struct_empty() const { if (device_data.is_initialized()) { return false; } + + if (vehicle_data.is_initialized()) { + return false; + } return true; } @@ -2214,6 +2740,9 @@ void PolicyTable::ReportErrors(rpc::ValidationReport* report__) const { if (!device_data.is_valid()) { device_data.ReportErrors(&report__->ReportSubobject("device_data")); } + if (!vehicle_data.is_valid()) { + vehicle_data.ReportErrors(&report__->ReportSubobject("vehicle_data")); + } } void PolicyTable::SetPolicyTableType(PolicyTableType pt_type) { @@ -2225,6 +2754,7 @@ void PolicyTable::SetPolicyTableType(PolicyTableType pt_type) { module_meta.SetPolicyTableType(pt_type); usage_and_error_counts.SetPolicyTableType(pt_type); device_data.SetPolicyTableType(pt_type); + vehicle_data.SetPolicyTableType(pt_type); } // Table methods diff --git a/src/components/policy/policy_external/src/policy_table/validation.cc b/src/components/policy/policy_external/src/policy_table/validation.cc index fad8509711f..12a79748d71 100644 --- a/src/components/policy/policy_external/src/policy_table/validation.cc +++ b/src/components/policy/policy_external/src/policy_table/validation.cc @@ -1,15 +1,15 @@ -#include #include +#include #include "policy/policy_table/types.h" -#include "utils/logger.h" #include "utils/helpers.h" +#include "utils/logger.h" namespace { bool IsPredefinedApplication(const std::string& app_id) { using namespace rpc::policy_table_interface_base; return kPreDataConsentApp == app_id || kDefaultApp == app_id; } -} +} // namespace namespace rpc { namespace policy_table_interface_base { @@ -102,9 +102,9 @@ bool ApplicationPoliciesSection::Validate() const { } if (!app_request_types.is_valid()) { - LOG4CXX_WARN(logger_, - "Invalid RequestTypes for " << app_id - << " Will be cleaned up."); + LOG4CXX_WARN( + logger_, + "Invalid RequestTypes for " << app_id << " Will be cleaned up."); app_request_types.CleanUp(); if (app_request_types.is_cleaned_up()) { if (PT_PRELOADED == pt_type) { @@ -221,6 +221,15 @@ bool RpcParameters::Validate() const { bool Rpcs::Validate() const { return true; } + +bool EndpointProperty::Validate() const { + if (!version.is_valid()) { + return false; + } + + return true; +} + bool ModuleConfig::Validate() const { switch (GetPolicyTableType()) { case PT_PRELOADED: { @@ -258,6 +267,14 @@ bool ModuleConfig::Validate() const { } } + if (endpoint_properties.is_initialized()) { + const auto& endpoint_property = + endpoint_properties->find(kDefaultOemMappingServiceName); + if (endpoint_properties->end() != endpoint_property) { + return (*endpoint_property).second.version.is_initialized(); + } + } + return true; } @@ -304,6 +321,40 @@ bool ConsentRecords::Validate() const { bool DeviceParams::Validate() const { return true; } + +bool VehicleDataItem::Validate() const { + if (!ValidateNaming(std::string(name))) { + return false; + }; + + if (!ValidateNaming(std::string(key))) { + return false; + }; + + if (!ValidateTypes()) { + LOG4CXX_ERROR( + logger_, + "Unknown type: " << std::string(type) << " of " << std::string(key)); + return false; + } + return true; +} + +bool VehicleData::Validate() const { + const PolicyTableType policy_table_type = GetPolicyTableType(); + bool result = true; + if (PT_SNAPSHOT == policy_table_type) { + result = + (!schema_items.is_initialized()) && schema_version.is_initialized(); + } + if (PT_UPDATE == policy_table_type || PT_PRELOADED == policy_table_type) { + result = + (schema_version.is_initialized() && schema_items.is_initialized()) || + (!schema_version.is_initialized() && !schema_items.is_initialized()); + } + return result; +} + bool PolicyTable::Validate() const { PolicyTableType policy_table_type = GetPolicyTableType(); diff --git a/src/components/policy/policy_external/src/sql_pt_ext_queries.cc b/src/components/policy/policy_external/src/sql_pt_ext_queries.cc index 2c24bbc5221..ea323908c03 100644 --- a/src/components/policy/policy_external/src/sql_pt_ext_queries.cc +++ b/src/components/policy/policy_external/src/sql_pt_ext_queries.cc @@ -207,9 +207,10 @@ const std::string kInsertApplication = " `default_hmi`, `priority_value`, `is_revoked`, `memory_kb`, " " `heart_beat_timeout_ms`, `certificate`, `hybrid_app_preference_value`, " " `endpoint`, `enabled`, `auth_token`, " - " `cloud_transport_type`, `icon_url`, `allow_unknown_rpc_passthrough`) " + " `cloud_transport_type`, `icon_url`, `allow_unknown_rpc_passthrough`, " + "`encryption_required`) " "VALUES " - "(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"; + "(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"; const std::string kCollectFriendlyMsg = "SELECT * FROM `message`"; @@ -238,7 +239,8 @@ const std::string kSelectAppPolicies = "SELECT `id`, `priority_value`, `default_hmi`, `keep_context`, " " `steal_focus`, `memory_kb`, `heart_beat_timeout_ms`, `certificate`, " " `hybrid_app_preference_value`, `endpoint`, `enabled`, `auth_token`, " - " `cloud_transport_type`, `icon_url`, `allow_unknown_rpc_passthrough` " + " `cloud_transport_type`, `icon_url`, `allow_unknown_rpc_passthrough`, " + "`encryption_required`" "FROM `application`"; const std::string kSelectFunctionalGroupNames = 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 b19feddee65..c8a1b5d7ea3 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 @@ -29,15 +29,15 @@ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#include "policy/sql_pt_ext_representation.h" #include #include -#include "utils/logger.h" -#include "policy/sql_pt_ext_representation.h" -#include "policy/sql_wrapper.h" -#include "policy/sql_pt_queries.h" -#include "policy/sql_pt_ext_queries.h" -#include "policy/policy_helper.h" #include "policy/cache_manager.h" +#include "policy/policy_helper.h" +#include "policy/sql_pt_ext_queries.h" +#include "policy/sql_pt_queries.h" +#include "policy/sql_wrapper.h" +#include "utils/logger.h" namespace policy { @@ -563,25 +563,23 @@ bool SQLPTExtRepresentation::GatherConsumerFriendlyMessages( msg.message_code = query.GetString(7); std::string language = query.GetString(6); + policy_table::Languages& languages = + (*messages->messages)[msg.message_code].languages; + policy_table::MessageString& specific_message = languages[language]; if (!msg.tts.empty()) { - *(*messages->messages)[msg.message_code].languages[language].tts = - msg.tts; + *(specific_message).tts = msg.tts; } if (!msg.label.empty()) { - *(*messages->messages)[msg.message_code].languages[language].label = - msg.label; + *(specific_message).label = msg.label; } if (!msg.line1.empty()) { - *(*messages->messages)[msg.message_code].languages[language].line1 = - msg.line1; + *(specific_message).line1 = msg.line1; } if (!msg.line2.empty()) { - *(*messages->messages)[msg.message_code].languages[language].line2 = - msg.line2; + *(specific_message).line2 = msg.line2; } if (!msg.text_body.empty()) { - *(*messages->messages)[msg.message_code].languages[language].textBody = - msg.text_body; + *(specific_message).textBody = msg.text_body; } } } else { @@ -796,6 +794,9 @@ bool SQLPTExtRepresentation::SaveSpecificAppPolicy( app.second.allow_unknown_rpc_passthrough.is_initialized() ? app_query.Bind(15, *app.second.allow_unknown_rpc_passthrough) : app_query.Bind(15); + app.second.encryption_required.is_initialized() + ? app_query.Bind(16, *app.second.encryption_required) + : app_query.Bind(16); if (!app_query.Exec() || !app_query.Reset()) { LOG4CXX_WARN(logger_, "Incorrect insert into application."); @@ -940,6 +941,9 @@ bool SQLPTExtRepresentation::GatherApplicationPoliciesSection( *params.cloud_transport_type = query.GetString(12); *params.icon_url = query.GetString(13); *params.allow_unknown_rpc_passthrough = query.GetBoolean(14); + if (!query.IsNull(15)) { + *params.encryption_required = query.GetBoolean(15); + } const auto& gather_app_id = ((*policies).apps[app_id].is_string()) ? (*policies).apps[app_id].get_string() : app_id; diff --git a/src/components/policy/policy_external/src/sql_pt_queries.cc b/src/components/policy/policy_external/src/sql_pt_queries.cc index f4cac214a59..e5fde1abf9e 100644 --- a/src/components/policy/policy_external/src/sql_pt_queries.cc +++ b/src/components/policy/policy_external/src/sql_pt_queries.cc @@ -76,12 +76,14 @@ const std::string kCreateSchema = " `vehicle_model` VARCHAR(45), " " `vehicle_year` VARCHAR(4), " " `preloaded_date` VARCHAR (10), " - " `certificate` VARCHAR (45) " + " `certificate` VARCHAR (45), " + " `lock_screen_dismissal_enabled` BOOL" "); " "CREATE TABLE IF NOT EXISTS `functional_group`( " " `id` INTEGER PRIMARY KEY NOT NULL, " " `user_consent_prompt` TEXT, " - " `name` VARCHAR(100) NOT NULL " + " `name` VARCHAR(100) NOT NULL, " + " `encryption_required` BOOLEAN " "); " "CREATE TABLE IF NOT EXISTS `external_consent_entities`( " " `group_id` INTEGER NOT NULL, " @@ -159,6 +161,7 @@ const std::string kCreateSchema = " `icon_url` VARCHAR(65535), " " `allow_unknown_rpc_passthrough` BOOLEAN, " " `remote_control_denied` BOOLEAN NOT NULL DEFAULT 0, " + " `encryption_required` BOOLEAN, " " CONSTRAINT `fk_application_hmi_level1` " " FOREIGN KEY(`default_hmi`) " " REFERENCES `hmi_level`(`value`), " @@ -383,6 +386,11 @@ const std::string kCreateSchema = "); " "CREATE INDEX IF NOT EXISTS `endpoint.fk_endpoint_application1_idx` " " ON `endpoint`(`application_id` COLLATE NOCASE); " + /*endpoint properties*/ + "CREATE TABLE IF NOT EXISTS `endpoint_properties`( " + " `service` VARCHAR(100) NOT NULL, " + " `version` VARCHAR(100) NOT NULL " + ");" "CREATE TABLE IF NOT EXISTS `message`( " " `id` INTEGER PRIMARY KEY NOT NULL, " " `tts` TEXT, " @@ -446,6 +454,40 @@ const std::string kCreateSchema = " `entity_id` INTEGER NOT NULL, " " `on_off` TEXT NOT NULL " " ); " + /*vehicle data*/ + "CREATE TABLE IF NOT EXISTS `vehicle_data`( " + " `schema_version` VARCHAR(100) NOT NULL " + ");" + /* vehicle data item definition*/ + "CREATE TABLE IF NOT EXISTS `vehicle_data_item_definition`( " + " `name` VARCHAR(255) NOT NULL, " + " `type` VARCHAR(255) NOT NULL, " + " `key` VARCHAR(255) NOT NULL, " + " `mandatory` BOOL NOT NULL, " + " `array` BOOL, " + " `since` VARCHAR(45), " + " `until` VARCHAR(45), " + " `removed` BOOL, " + " `deprecated` BOOL, " + " `minvalue` INTEGER, " + " `maxvalue` INTEGER, " + " `minsize` INTEGER, " + " `maxsize` INTEGER, " + " `minlength` INTEGER, " + " `maxlength` INTEGER " + "); " + "CREATE TABLE IF NOT EXISTS `vehicle_data_item_parameters`( " + " `parent_name` VARCHAR(255) NOT NULL, " + " `parent_key` VARCHAR(255) NOT NULL, " + " `param_name` VARCHAR(255) NOT NULL, " + " `param_key` VARCHAR(255) NOT NULL, " + " CONSTRAINT `fk_vdi_id` " + " FOREIGN KEY(`parent_name`, `parent_key`) " + " REFERENCES `vehicle_data_item_definition`(`name`, `key`), " + " CONSTRAINT `fk_vdi_param_id` " + " FOREIGN KEY(`param_name`, `param_key`) " + " REFERENCES `vehicle_data_item_definition`(`name`, `key`) " + "); " "COMMIT;"; const std::string kInsertInitData = @@ -459,8 +501,10 @@ const std::string kInsertInitData = " VALUES (0, 0, 0, 0); " "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`) " + " `exchange_after_x_days`, `timeout_after_x_seconds`)" " VALUES(1, 0, 0, 0, 0, 0); " + "INSERT OR IGNORE INTO `vehicle_data` (" + " `schema_version`) VALUES('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'); " @@ -525,6 +569,7 @@ const std::string kDropSchema = "DROP TABLE IF EXISTS `message`; " "DROP INDEX IF EXISTS `endpoint.fk_endpoint_application1_idx`; " "DROP TABLE IF EXISTS `endpoint`; " + "DROP TABLE IF EXISTS `endpoint_properties`; " "DROP INDEX IF EXISTS `consent_group.fk_consent_group_device1_idx`; " "DROP INDEX IF EXISTS " "`consent_group.fk_consent_group_functional_group1_idx`; " @@ -590,6 +635,9 @@ const std::string kDropSchema = "DROP TABLE IF EXISTS `device`; " "DROP TABLE IF EXISTS `_internal_data`; " "DROP TABLE IF EXISTS `_internal_external_consent_status`; " + "DROP TABLE IF EXISTS `vehicle_data`; " + "DROP TABLE IF EXISTS `vehicle_data_item_definition`; " + "DROP TABLE IF EXISTS `vehicle_data_item_parameters`; " "COMMIT; " "VACUUM;"; @@ -598,6 +646,7 @@ const std::string kDeleteData = "DELETE FROM `message`; " "DELETE FROM `module_type`; " "DELETE FROM `endpoint`; " + "DELETE FROM `endpoint_properties`; " "DELETE FROM `consent_group`; " "DELETE FROM `external_consent_status_group`; " "DELETE FROM `external_consent_entities`; " @@ -624,6 +673,9 @@ const std::string kDeleteData = "DELETE FROM `usage_and_error_count`; " "DELETE FROM `device`; " "DELETE FROM `request_type`; " + "DELETE FROM `vehicle_data`; " + "DELETE FROM `vehicle_data_item_definition`; " + "DELETE FROM `vehicle_data_item_parameters`; " "COMMIT; " "VACUUM;"; @@ -631,6 +683,82 @@ const std::string kCheckDBIntegrity = "PRAGMA integrity_check"; const std::string kCheckPgNumber = "PRAGMA page_count"; +const std::string kSelectEndpointProperties = + "SELECT `service`, `version` FROM `endpoint_properties`"; + +const std::string kSelectVehicleDataSchemaVersion = + "SELECT `schema_version` FROM `vehicle_data` "; + +const std::string kSelectVehicleDataItem = + "SELECT * FROM `vehicle_data_item_definition` " + "WHERE `key` = ? AND `name` = ?"; + +const std::string kSelectVehicleDataItemWithVersion = + "SELECT * FROM `vehicle_data_item_definition` " + "WHERE `name` IS ? AND `key` IS ? AND `since` IS ? AND `until` IS ?"; + +const std::string kSelectVehicleDataItemParams = + "SELECT * FROM `vehicle_data_item_parameters` " + "WHERE `parent_name` = ? AND `parent_key` = ?"; + +const std::string kSelectCompositeVehicleDataItemsKey = + "SELECT DISTINCT `parent_name`, `parent_key` FROM " + "`vehicle_data_item_parameters` " + "LEFT JOIN " + "(SELECT DISTINCT `param_name`, `param_key` FROM " + "`vehicle_data_item_parameters`) `vdi_params` ON " + "`vehicle_data_item_parameters`.`parent_name` = `vdi_params`.`param_name` " + "AND " + "`vehicle_data_item_parameters`.`parent_key` = `vdi_params`.`param_key` " + "WHERE `vdi_params`.`param_key` IS NULL"; + +const std::string kSelectPrimitiveVehicleDataItems = + "SELECT * FROM `vehicle_data_item_definition` " + "LEFT JOIN ( " + "SELECT `parent_name`, `parent_key` FROM `vehicle_data_item_parameters` " + "UNION " + "SELECT `param_name`, `param_key` FROM `vehicle_data_item_parameters`) " + "`vdi_params` ON " + "`vehicle_data_item_definition`.`name` = `vdi_params`.`parent_name` " + "AND " + "`vehicle_data_item_definition`.`key` = `vdi_params`.`parent_key` " + "WHERE `vdi_params`.`parent_key` IS NULL"; + +const std::string kInsertVehicleDataSchemaVersion = + "UPDATE `vehicle_data` SET `schema_version` = ?"; + +const std::string kInsertEndpointVersion = + "INSERT OR REPLACE INTO `endpoint_properties`(`service`, " + "`version`) " + "VALUES(?, ?)"; + +const std::string kInsertVehicleDataItem = + "INSERT INTO `vehicle_data_item_definition` (" + " `name`, " + " `type`, " + " `key`, " + " `mandatory`, " + " `array`, " + " `since`, " + " `until`, " + " `removed`, " + " `deprecated`, " + " `minvalue`, " + " `maxvalue`, " + " `minsize`, " + " `maxsize`, " + " `minlength`, " + " `maxlength`) " + "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) "; + +const std::string kInsertVehicleDataItemParams = + "INSERT INTO `vehicle_data_item_parameters` (" + " `parent_name`, " + " `parent_key`, " + " `param_name`, " + " `param_key`) " + "VALUES (?, ?, ?, ?) "; + const std::string kSelectRpc = "SELECT DISTINCT `rpc`.`parameter` FROM `rpc` " " JOIN `app_group` AS `g` ON (`g`.`functional_group_id` = " @@ -657,8 +785,9 @@ const std::string kSelectLockScreenIcon = "SELECT `url` FROM `endpoint` WHERE `service` = ? AND `application_id` = ?"; const std::string kInsertFunctionalGroup = - "INSERT INTO `functional_group` (`id`, `name`, `user_consent_prompt`) " - " VALUES (?, ?, ?)"; + "INSERT INTO `functional_group` (`id`, `name`, `user_consent_prompt`, " + "`encryption_required`) " + " VALUES (?, ?, ?, ?)"; const std::string kInsertRpc = "INSERT INTO `rpc` (`name`, `hmi_level_value`, `functional_group_id`) " @@ -678,9 +807,10 @@ const std::string kInsertApplication = "INSERT OR IGNORE INTO `application` (`id`, `priority_value`, " "`is_revoked`, `memory_kb`, `heart_beat_timeout_ms`, `certificate`, " "`hybrid_app_preference_value`, `endpoint`, `enabled`, `auth_token`, " - "`cloud_transport_type`, `icon_url`, `allow_unknown_rpc_passthrough`) " + "`cloud_transport_type`, `icon_url`, `allow_unknown_rpc_passthrough`, " + "`encryption_required`) " "VALUES " - "(?,?,?,?,?,?,?,?,?,?,?,?,?)"; + "(?,?,?,?,?,?,?,?,?,?,?,?,?,?)"; const std::string kInsertAppGroup = "INSERT INTO `app_group` (`application_id`, `functional_group_id`)" @@ -734,7 +864,7 @@ const std::string kUpdateModuleConfig = " `exchange_after_x_kilometers` = ?, `exchange_after_x_days` = ?, " " `timeout_after_x_seconds` = ?, `vehicle_make` = ?, " " `vehicle_model` = ?, `vehicle_year` = ?, `preloaded_date` = ?, " - " `certificate` = ? "; + " `certificate` = ?, lock_screen_dismissal_enabled = ?"; const std::string kInsertEndpoint = "INSERT INTO `endpoint` (`service`, `url`, `application_id`) " @@ -785,7 +915,8 @@ const std::string kSelectModuleConfig = "SELECT `preloaded_pt`, `exchange_after_x_ignition_cycles`, " " `exchange_after_x_kilometers`, `exchange_after_x_days`, " " `timeout_after_x_seconds`, `vehicle_make`," - " `vehicle_model`, `vehicle_year`, `preloaded_date`, `certificate` " + " `vehicle_model`, `vehicle_year`, `preloaded_date`, `certificate`, " + " `lock_screen_dismissal_enabled` " " FROM `module_config`"; const std::string kSelectEndpoints = @@ -802,7 +933,7 @@ const std::string kSelectAppLevels = "SELECT `application_id` FROM `app_level`"; const std::string kSelectDeviceData = "SELECT * FROM `device`"; const std::string kSelectFunctionalGroups = - "SELECT `id`,`name`, `user_consent_prompt` " + "SELECT `id`,`name`, `user_consent_prompt`, `encryption_required` " "FROM `functional_group`"; const std::string kSelectAllRpcs = @@ -820,7 +951,7 @@ const std::string kSelectAppPolicies = "SELECT `id`, `priority_value`, `memory_kb`, " " `heart_beat_timeout_ms`, `certificate`, `hybrid_app_preference_value`, " " `endpoint`, `enabled`, `auth_token`, `cloud_transport_type`, `icon_url`, " - " `allow_unknown_rpc_passthrough` " + " `allow_unknown_rpc_passthrough`, `encryption_required` " "FROM " " `application`"; @@ -918,6 +1049,12 @@ const std::string kDeleteAppServiceNames = "DELETE FROM `app_service_names`"; const std::string kDeleteAppServiceHandledRpcs = "DELETE FROM `app_service_handled_rpcs`"; +const std::string kDeleteVehicleDataItems = + "DELETE FROM `vehicle_data_item_definition`"; + +const std::string kDeleteVehicleDataItemParams = + "DELETE FROM `vehicle_data_item_parameters`"; + const std::string kSelectApplicationRevoked = "SELECT `is_revoked` FROM `application` WHERE `id` = ?"; @@ -945,8 +1082,8 @@ const std::string kInsertApplicationFull = " `is_predata`, `memory_kb`, `heart_beat_timeout_ms`, " " `certificate`, `hybrid_app_preference_value`, `endpoint`, `enabled`, " " `auth_token`, `cloud_transport_type`, `icon_url`, " - "`allow_unknown_rpc_passthrough`) " - " VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"; + "`allow_unknown_rpc_passthrough`, `encryption_required`) " + " VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"; const std::string kSelectApplicationFull = "SELECT `keep_context`, `steal_focus`, `default_hmi`, `priority_value`, " @@ -954,7 +1091,7 @@ const std::string kSelectApplicationFull = " `heart_beat_timeout_ms`, `certificate`, `hybrid_app_preference_value`, " " `endpoint`, `enabled`, `auth_token`, `cloud_transport_type`, " "`icon_url`, " - " `allow_unknown_rpc_passthrough` " + " `allow_unknown_rpc_passthrough`, `encryption_required` " "FROM `application` " "WHERE `id` = ?"; 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 dce86f6d52f..5af4cc54402 100644 --- a/src/components/policy/policy_external/src/sql_pt_representation.cc +++ b/src/components/policy/policy_external/src/sql_pt_representation.cc @@ -30,24 +30,24 @@ POSSIBILITY OF SUCH DAMAGE. */ -#include -#include -#include #include +#include +#include #include +#include -#include "utils/logger.h" +#include "config_profile/profile.h" +#include "policy/cache_manager.h" +#include "policy/policy_helper.h" +#include "policy/sql_pt_ext_queries.h" +#include "policy/sql_pt_queries.h" +#include "policy/sql_pt_representation.h" +#include "policy/sql_wrapper.h" #include "utils/date_time.h" -#include "utils/sqlite_wrapper/sql_database.h" #include "utils/file_system.h" #include "utils/gen_hash.h" -#include "policy/sql_pt_representation.h" -#include "policy/sql_wrapper.h" -#include "policy/sql_pt_ext_queries.h" -#include "policy/sql_pt_queries.h" -#include "policy/policy_helper.h" -#include "policy/cache_manager.h" -#include "config_profile/profile.h" +#include "utils/logger.h" +#include "utils/sqlite_wrapper/sql_database.h" namespace policy { @@ -130,9 +130,9 @@ void SQLPTRepresentation::CheckPermissions(const PTString& app_id, utils::dbms::SQLQuery query(db()); if (!query.Prepare(sql_pt::kSelectRpc)) { - LOG4CXX_WARN(logger_, - "Incorrect select statement from rpcs" - << query.LastError().text()); + LOG4CXX_WARN( + logger_, + "Incorrect select statement from rpcs" << query.LastError().text()); return; } query.Bind(0, app_id); @@ -408,9 +408,9 @@ InitResult SQLPTRepresentation::Init(const PolicySettings* settings) { utils::dbms::SQLQuery check_first_run(db()); if (check_first_run.Prepare(sql_pt::kIsFirstRun) && check_first_run.Next()) { - LOG4CXX_INFO(logger_, - "Selecting is first run " - << check_first_run.GetBoolean(0)); + LOG4CXX_INFO( + logger_, + "Selecting is first run " << check_first_run.GetBoolean(0)); if (check_first_run.GetBoolean(0)) { utils::dbms::SQLQuery set_not_first_run(db()); set_not_first_run.Exec(sql_pt::kSetNotFirstRun); @@ -451,16 +451,6 @@ bool SQLPTRepresentation::Close() { return db_->LastError().number() == utils::dbms::OK; } -const VehicleInfo SQLPTRepresentation::GetVehicleInfo() const { - policy_table::ModuleConfig module_config; - GatherModuleConfig(&module_config); - VehicleInfo vehicle_info; - vehicle_info.vehicle_make = *module_config.vehicle_make; - vehicle_info.vehicle_model = *module_config.vehicle_model; - vehicle_info.vehicle_year = *module_config.vehicle_year; - return vehicle_info; -} - bool SQLPTRepresentation::Drop() { utils::dbms::SQLQuery query(db()); if (!query.Exec(sql_pt::kDropSchema)) { @@ -525,6 +515,11 @@ std::shared_ptr SQLPTRepresentation::GenerateSnapshot() GatherConsumerFriendlyMessages( &*table->policy_table.consumer_friendly_messages); GatherApplicationPoliciesSection(&table->policy_table.app_policies_section); + GatherVehicleData(&*table->policy_table.vehicle_data); + if (!table->policy_table.vehicle_data.is_initialized()) { + rpc::Optional > null_version; + table->policy_table.vehicle_data->schema_version = null_version; + } return table; } @@ -552,6 +547,9 @@ void SQLPTRepresentation::GatherModuleConfig( *config->vehicle_year = query.GetString(7); *config->preloaded_date = query.GetString(8); *config->certificate = query.GetString(9); + if (!query.IsNull(10)) { + *config->lock_screen_dismissal_enabled = query.GetBoolean(10); + } } utils::dbms::SQLQuery endpoints(db()); @@ -566,6 +564,18 @@ void SQLPTRepresentation::GatherModuleConfig( } } + utils::dbms::SQLQuery endpoint_properties(db()); + if (!endpoint_properties.Prepare(sql_pt::kSelectEndpointProperties)) { + LOG4CXX_ERROR(logger_, "Incorrect statement for Endpoint properties"); + } else { + while (endpoint_properties.Next()) { + const std::string& service = endpoint_properties.GetString(0); + const std::string& version = endpoint_properties.GetString(1); + auto& ep_properties = (*config->endpoint_properties); + *ep_properties[service].version = version; + } + } + utils::dbms::SQLQuery notifications(db()); if (!notifications.Prepare(sql_pt::kSelectNotificationsPerMin)) { LOG4CXX_WARN(logger_, "Incorrect select statement for notifications"); @@ -645,6 +655,10 @@ bool SQLPTRepresentation::GatherFunctionalGroupings( *rpcs_tbl.user_consent_prompt = func_group.GetString(2); } + if (!func_group.IsNull(3)) { + *rpcs_tbl.encryption_required = func_group.GetBoolean(3); + } + const int group_id = func_group.GetInteger(0); rpcs.Bind(0, group_id); @@ -657,16 +671,15 @@ bool SQLPTRepresentation::GatherFunctionalGroupings( } } if (!rpcs.IsNull(2)) { - policy_table::Parameter param; - if (policy_table::EnumFromJsonString(rpcs.GetString(2), ¶m)) { - // EMPTY is a special mark to specify that 'parameters' section is - // present, but has no parameters. It is not valid parameter value. - if (policy_table::P_EMPTY == param) { - (*rpcs_tbl.rpcs[rpcs.GetString(0)].parameters).mark_initialized(); - continue; - } - InsertUnique(param, &(*rpcs_tbl.rpcs[rpcs.GetString(0)].parameters)); + std::string param = rpcs.GetString(2); + // EMPTY is a special mark to specify that 'parameters' section is + // present, but has no parameters. It is not valid parameter value. + if (policy_table::EnumToJsonString(policy_table::P_EMPTY) == param) { + (*rpcs_tbl.rpcs[rpcs.GetString(0)].parameters).mark_initialized(); + continue; } + InsertUnique(rpcs.GetString(2), + &(*rpcs_tbl.rpcs[rpcs.GetString(0)].parameters)); } } @@ -712,10 +725,33 @@ bool SQLPTRepresentation::GatherConsumerFriendlyMessages( if (query.Prepare(sql_pt::kCollectFriendlyMsg)) { while (query.Next()) { UserFriendlyMessage msg; + + msg.tts = query.GetString(1); + msg.label = query.GetString(2); + msg.line1 = query.GetString(3); + msg.line2 = query.GetString(4); + msg.text_body = query.GetString(5); msg.message_code = query.GetString(7); - std::string language = query.GetString(6); - (*messages->messages)[msg.message_code].languages[language]; + std::string language = query.GetString(6); + policy_table::Languages& languages = + (*messages->messages)[msg.message_code].languages; + policy_table::MessageString& specific_message = languages[language]; + if (!msg.tts.empty()) { + *(specific_message).tts = msg.tts; + } + if (!msg.label.empty()) { + *(specific_message).label = msg.label; + } + if (!msg.line1.empty()) { + *(specific_message).line1 = msg.line1; + } + if (!msg.line2.empty()) { + *(specific_message).line2 = msg.line2; + } + if (!msg.text_body.empty()) { + *(specific_message).textBody = msg.text_body; + } } } else { LOG4CXX_WARN(logger_, "Incorrect statement for select friendly messages."); @@ -782,6 +818,10 @@ bool SQLPTRepresentation::GatherApplicationPoliciesSection( const auto& gather_app_id = ((*policies).apps[app_id].is_string()) ? (*policies).apps[app_id].get_string() : app_id; + + if (!query.IsNull(12)) { + *params.encryption_required = query.GetBoolean(12); + } // Data should be gathered from db by "default" key if application has // default policies @@ -821,6 +861,43 @@ bool SQLPTRepresentation::GatherApplicationPoliciesSection( return true; } +bool SQLPTRepresentation::GatherVehicleData( + policy_table::VehicleData* vehicle_data) const { + utils::dbms::SQLQuery query(db()); + if (!query.Prepare(sql_pt::kSelectVehicleDataSchemaVersion) || + !query.Next()) { + LOG4CXX_ERROR(logger_, + "Incorrect statement for vehicle data schema version"); + return false; + } + *vehicle_data->schema_version = query.GetString(0); + + vehicle_data->mark_initialized(); + return GatherVehicleDataItems(&*vehicle_data->schema_items); +} + +bool SQLPTRepresentation::GatherVehicleDataItems( + policy_table::VehicleDataItems* vehicle_data_items) const { + auto parameterized_vdi = SelectCompositeVehicleDataItems(); + if (!parameterized_vdi.is_initialized()) { + return false; + } + + auto non_parameterized_vdi = SelectPrimitiveVehicleDataItems(); + if (!non_parameterized_vdi.is_initialized()) { + return false; + } + + vehicle_data_items->insert(vehicle_data_items->end(), + parameterized_vdi.begin(), + parameterized_vdi.end()); + vehicle_data_items->insert(vehicle_data_items->end(), + non_parameterized_vdi.begin(), + non_parameterized_vdi.end()); + + return true; +} + bool SQLPTRepresentation::Save(const policy_table::Table& table) { LOG4CXX_AUTO_TRACE(logger_); db_->BeginTransaction(); @@ -855,6 +932,10 @@ bool SQLPTRepresentation::Save(const policy_table::Table& table) { db_->RollbackTransaction(); return false; } + if (!SaveVehicleData(*table.policy_table.vehicle_data)) { + db_->RollbackTransaction(); + return false; + } db_->CommitTransaction(); return true; } @@ -900,7 +981,9 @@ bool SQLPTRepresentation::SaveFunctionalGroupings( groups_it->second.user_consent_prompt.is_initialized() ? query.Bind(2, *(groups_it->second.user_consent_prompt)) : query.Bind(2); - + groups_it->second.encryption_required.is_initialized() + ? query.Bind(3, *(groups_it->second.encryption_required)) + : query.Bind(3); if (!query.Exec() || !query.Reset()) { LOG4CXX_WARN(logger_, "Incorrect insert into functional groups"); return false; @@ -953,8 +1036,7 @@ bool SQLPTRepresentation::SaveRpcs(int64_t group_id, query_parameter.Bind(0, it->first); query_parameter.Bind( 1, std::string(policy_table::EnumToJsonString(*hmi_it))); - query_parameter.Bind( - 2, std::string(policy_table::EnumToJsonString(*ps_it))); + query_parameter.Bind(2, std::string(*ps_it)); query_parameter.Bind(3, group_id); if (!query_parameter.Exec() || !query_parameter.Reset()) { LOG4CXX_WARN(logger_, "Incorrect insert into rpc with parameter"); @@ -1097,6 +1179,10 @@ bool SQLPTRepresentation::SaveSpecificAppPolicy( ? app_query.Bind(12, *app.second.allow_unknown_rpc_passthrough) : app_query.Bind(12); + app.second.encryption_required.is_initialized() + ? app_query.Bind(13, *app.second.encryption_required) + : app_query.Bind(13); + if (!app_query.Exec() || !app_query.Reset()) { LOG4CXX_WARN(logger_, "Incorrect insert into application."); return false; @@ -1168,6 +1254,44 @@ bool policy::SQLPTRepresentation::SaveDevicePolicy( return true; } +bool SQLPTRepresentation::SaveVehicleDataItems( + const policy_table::VehicleDataItems& vehicle_data_items) { + LOG4CXX_AUTO_TRACE(logger_); + DeleteVehicleDataItems(); + for (const auto& item : vehicle_data_items) { + if (!InsertVehicleDataItem(item)) { + return false; + } + } + return true; +} + +bool SQLPTRepresentation::SaveVehicleData( + const policy_table::VehicleData& vehicle_data) { + LOG4CXX_AUTO_TRACE(logger_); + if (vehicle_data.is_initialized() && + vehicle_data.schema_version.is_initialized()) { + utils::dbms::SQLQuery query(db()); + if (!query.Prepare(sql_pt::kInsertVehicleDataSchemaVersion)) { + LOG4CXX_WARN(logger_, + "Incorrect insert of schema_version to vehicle_data."); + return false; + } + query.Bind(0, *vehicle_data.schema_version); + if (!query.Exec() || !query.Reset()) { + LOG4CXX_WARN(logger_, "Failed to insert schema_version to vehicle_data."); + return false; + } + } + + auto vehicle_data_items = vehicle_data.is_initialized() && + vehicle_data.schema_items.is_initialized() + ? *(vehicle_data.schema_items) + : policy_table::VehicleDataItems(); + + return SaveVehicleDataItems(vehicle_data_items); +} + bool SQLPTRepresentation::SaveAppGroup( const std::string& app_id, const policy_table::Strings& app_groups) { utils::dbms::SQLQuery query(db()); @@ -1183,9 +1307,9 @@ bool SQLPTRepresentation::SaveAppGroup( query.Bind(0, app_id); query.Bind(1, *it); if (!query.Exec() || !query.Reset()) { - LOG4CXX_WARN(logger_, - "Incorrect insert into app group." - << query.LastError().text()); + LOG4CXX_WARN( + logger_, + "Incorrect insert into app group." << query.LastError().text()); return false; } } @@ -1291,7 +1415,9 @@ bool SQLPTRepresentation::SaveRequestSubType( } else if (request_subtypes.is_initialized()) { LOG4CXX_WARN(logger_, "Request subtypes empty."); query.Bind(0, app_id); - query.Bind(1, std::string("EMPTY")); + query.Bind(1, + std::string(policy_table::EnumToJsonString( + policy_table::RequestType::RT_EMPTY))); if (!query.Exec() || !query.Reset()) { LOG4CXX_WARN(logger_, "Incorrect insert into request subtypes."); return false; @@ -1412,6 +1538,10 @@ bool SQLPTRepresentation::SaveModuleConfig( config.certificate.is_initialized() ? query.Bind(9, *(config.certificate)) : query.Bind(9); + config.lock_screen_dismissal_enabled.is_initialized() + ? query.Bind(10, *(config.lock_screen_dismissal_enabled)) + : query.Bind(10); + if (!query.Exec()) { LOG4CXX_WARN(logger_, "Incorrect update module config"); return false; @@ -1430,6 +1560,10 @@ bool SQLPTRepresentation::SaveModuleConfig( return false; } + if (!SaveServiceEndpointProperties(*config.endpoint_properties)) { + return false; + } + return true; } @@ -1468,6 +1602,31 @@ bool SQLPTRepresentation::SaveServiceEndpoints( return true; } +bool SQLPTRepresentation::SaveServiceEndpointProperties( + const policy_table::ServiceEndpointProperties& endpoint_properties) { + utils::dbms::SQLQuery query(db()); + if (!query.Prepare(sql_pt::kInsertEndpointVersion)) { + LOG4CXX_WARN( + logger_, + "Incorrect insert of endpoint property to endpoint_properties."); + return false; + } + + for (auto& endpoint_property : endpoint_properties) { + query.Bind(0, endpoint_property.first); + query.Bind(1, endpoint_property.second.version); + + if (!query.Exec() || !query.Reset()) { + LOG4CXX_WARN( + logger_, + "Failed to insert endpoint property into endpoint_properties."); + return false; + } + } + + return true; +} + bool SQLPTRepresentation::SaveConsumerFriendlyMessages( const policy_table::ConsumerFriendlyMessages& messages) { LOG4CXX_AUTO_TRACE(logger_); @@ -1554,6 +1713,120 @@ bool SQLPTRepresentation::SaveLanguage(const std::string& code) { return true; } +policy_table::VehicleDataItem SQLPTRepresentation::PopulateVDIFromQuery( + const utils::dbms::SQLQuery& query) const { + policy_table::VehicleDataItem result; + + result.name = query.GetString(0); + result.type = query.GetString(1); + result.key = query.GetString(2); + result.mandatory = query.GetBoolean(3); + + if (!query.IsNull(4)) { + *result.array = query.GetBoolean(4); + } + if (!query.IsNull(5)) { + *result.since = query.GetString(5); + } + if (!query.IsNull(6)) { + *result.until = query.GetString(6); + } + if (!query.IsNull(7)) { + *result.removed = query.GetBoolean(7); + } + if (!query.IsNull(8)) { + *result.deprecated = query.GetBoolean(8); + } + if (!query.IsNull(9)) { + *result.minvalue = query.GetInteger(9); + } + if (!query.IsNull(10)) { + *result.maxvalue = query.GetInteger(10); + } + if (!query.IsNull(11)) { + *result.minsize = query.GetUInteger(11); + } + if (!query.IsNull(12)) { + *result.maxsize = query.GetUInteger(12); + } + if (!query.IsNull(13)) { + *result.minlength = query.GetUInteger(13); + } + if (!query.IsNull(14)) { + *result.maxlength = query.GetUInteger(14); + } + result.params->mark_initialized(); + + result.mark_initialized(); + return result; +} + +policy_table::VehicleDataItems +SQLPTRepresentation::SelectCompositeVehicleDataItems() const { + utils::dbms::SQLQuery query(db()); + if (!query.Prepare(sql_pt::kSelectCompositeVehicleDataItemsKey)) { + LOG4CXX_ERROR(logger_, + "Incorrect statement for parameterized vehicle data items"); + return policy_table::VehicleDataItems(); + } + + policy_table::VehicleDataItems result; + result.mark_initialized(); + + while (query.Next()) { + const auto vdi = GetVehicleDataItem(query.GetString(0), query.GetString(1)); + if (!vdi.is_initialized()) { + return policy_table::VehicleDataItems(); + } + for (const auto& item : vdi) { + result.push_back(item); + } + } + + return result; +} + +policy_table::VehicleDataItems +SQLPTRepresentation::SelectPrimitiveVehicleDataItems() const { + utils::dbms::SQLQuery query(db()); + if (!query.Prepare(sql_pt::kSelectPrimitiveVehicleDataItems)) { + LOG4CXX_ERROR( + logger_, + "Incorrect statement for non parameterized vehicle data items"); + return policy_table::VehicleDataItems(); + } + + auto result = policy_table::VehicleDataItems(); + result.mark_initialized(); + + while (query.Next()) { + const auto vdi = PopulateVDIFromQuery(query); + if (!vdi.is_initialized()) { + return policy_table::VehicleDataItems(); + } + result.push_back(vdi); + } + return result; +} + +bool SQLPTRepresentation::DeleteVehicleDataItems() const { + utils::dbms::SQLQuery query(db()); + LOG4CXX_AUTO_TRACE(logger_); + + if (!query.Exec(sql_pt::kDeleteVehicleDataItems)) { + LOG4CXX_ERROR(logger_, + "Failed clearing database: " << query.LastError().text()); + return false; + } + + if (!query.Exec(sql_pt::kDeleteVehicleDataItemParams)) { + LOG4CXX_ERROR(logger_, + "Failed clearing database: " << query.LastError().text()); + return false; + } + return true; +} + bool SQLPTRepresentation::SaveMessageString( const std::string& type, const std::string& lang, @@ -1796,7 +2069,8 @@ bool SQLPTRepresentation::GatherRequestSubType( query.Bind(0, app_id); while (query.Next()) { const std::string request_subtype = query.GetString(0); - if ("EMPTY" == request_subtype) { + if (policy_table::EnumToJsonString(policy_table::RequestType::RT_EMPTY) == + request_subtype) { request_subtypes->mark_initialized(); continue; } @@ -2285,6 +2559,198 @@ bool SQLPTRepresentation::UpdateDBVersion() const { return true; } +policy_table::VehicleDataItems SQLPTRepresentation::GetVehicleDataItem( + const std::string& name, const std::string& key) const { + policy_table::VehicleDataItems result; + utils::dbms::SQLQuery query(db()); + + if (!query.Prepare(sql_pt::kSelectVehicleDataItem)) { + LOG4CXX_ERROR(logger_, + "Incorrent select statement of vehicle data item. " + << query.LastError().text()); + return result; + } + + query.Bind(0, key); + query.Bind(1, name); + + while (query.Next()) { + auto vdi = PopulateVDIFromQuery(query); + if (!vdi.is_initialized()) { + return policy_table::VehicleDataItems(); + } + + utils::dbms::SQLQuery param_query(db()); + if (policy_table::VehicleDataItem::kStruct == + static_cast(vdi.type)) { + if (!param_query.Prepare(sql_pt::kSelectVehicleDataItemParams)) { + LOG4CXX_ERROR(logger_, + "Incorrent select statement of vehicle data item. " + << param_query.LastError().text()); + return policy_table::VehicleDataItems(); + } + + param_query.Bind(0, name); + param_query.Bind(1, key); + + while (param_query.Next()) { + const auto param_with_diff_versions = GetVehicleDataItem( + param_query.GetString(2), param_query.GetString(3)); + if (!param_with_diff_versions.is_initialized()) { + return policy_table::VehicleDataItems(); + } + for (const auto& param : param_with_diff_versions) { + vdi.params->push_back(param); + } + } + } + result.push_back(vdi); + } + if (!result.empty()) { + result.mark_initialized(); + } + + return result; +} + +bool SQLPTRepresentation::InsertVehicleDataItem( + const policy_table::VehicleDataItem& vehicle_data_item) { + utils::dbms::SQLQuery query(db()); + + if (!vehicle_data_item.is_initialized() || !vehicle_data_item.is_valid()) { + LOG4CXX_ERROR(logger_, "Vehicle data item is not initialized."); + return false; + } + + if (VehicleDataItemExists(vehicle_data_item)) { + LOG4CXX_INFO(logger_, + static_cast(vehicle_data_item.key) + << " is already stored."); + return true; + } + + if (!query.Prepare(sql_pt::kInsertVehicleDataItem)) { + LOG4CXX_ERROR(logger_, + "Incorrent select statement of vehicle data item. " + << query.LastError().text()); + return false; + } + + query.Bind(0, vehicle_data_item.name); + query.Bind(1, vehicle_data_item.type); + query.Bind(2, vehicle_data_item.key); + query.Bind(3, vehicle_data_item.mandatory); + vehicle_data_item.array.is_initialized() + ? query.Bind(4, *vehicle_data_item.array) + : query.Bind(4); + vehicle_data_item.since.is_initialized() + ? query.Bind(5, *vehicle_data_item.since) + : query.Bind(5); + vehicle_data_item.until.is_initialized() + ? query.Bind(6, *vehicle_data_item.until) + : query.Bind(6); + vehicle_data_item.removed.is_initialized() + ? query.Bind(7, *vehicle_data_item.removed) + : query.Bind(7); + vehicle_data_item.deprecated.is_initialized() + ? query.Bind(8, *vehicle_data_item.deprecated) + : query.Bind(8); + vehicle_data_item.minvalue.is_initialized() + ? query.Bind(9, *vehicle_data_item.minvalue) + : query.Bind(9); + vehicle_data_item.maxvalue.is_initialized() + ? query.Bind(10, *vehicle_data_item.maxvalue) + : query.Bind(10); + vehicle_data_item.minsize.is_initialized() + ? query.Bind(11, static_cast(*vehicle_data_item.minsize)) + : query.Bind(11); + vehicle_data_item.maxsize.is_initialized() + ? query.Bind(12, static_cast(*vehicle_data_item.maxsize)) + : query.Bind(12); + vehicle_data_item.minlength.is_initialized() + ? query.Bind(13, static_cast(*vehicle_data_item.minlength)) + : query.Bind(13); + vehicle_data_item.maxlength.is_initialized() + ? query.Bind(14, static_cast(*vehicle_data_item.maxlength)) + : query.Bind(14); + + if (!query.Exec() || !query.Reset()) { + LOG4CXX_ERROR(logger_, + "Failed to insert vehicle data item: " + << static_cast(vehicle_data_item.key) + << ". Error: " << query.LastError().text()); + return false; + } + + if (vehicle_data_item.params->is_initialized()) { + std::map stored_vehicle_data_item_params; + for (const auto& param : *(vehicle_data_item.params)) { + if (!InsertVehicleDataItem(param)) { + return false; + } + + if (stored_vehicle_data_item_params.end() != + stored_vehicle_data_item_params.find(param.name)) { + LOG4CXX_DEBUG(logger_, "Parameter already stored."); + continue; + } + + if (!query.Prepare(sql_pt::kInsertVehicleDataItemParams)) { + LOG4CXX_ERROR(logger_, + "Incorrent select statement of vehicle data item. " + << query.LastError().text()); + return false; + } + + query.Bind(0, vehicle_data_item.name); + query.Bind(1, vehicle_data_item.key); + query.Bind(2, param.name); + query.Bind(3, param.key); + + if (!query.Exec() || !query.Reset()) { + LOG4CXX_ERROR( + logger_, + "Failed to insert to vehicle data item relations helper table: " + << static_cast(param.key) + << ". Error: " << query.LastError().text()); + return false; + } + stored_vehicle_data_item_params[param.name] = param.key; + } + } + + return true; +} + +bool SQLPTRepresentation::VehicleDataItemExists( + const policy_table::VehicleDataItem& vehicle_data_item) const { + utils::dbms::SQLQuery query(db()); + if (!query.Prepare(sql_pt::kSelectVehicleDataItemWithVersion)) { + LOG4CXX_ERROR(logger_, + "Incorrent select statement for vehicle data item. " + << query.LastError().text()); + return false; + } + + query.Bind(0, vehicle_data_item.name); + query.Bind(1, vehicle_data_item.key); + vehicle_data_item.since.is_initialized() + ? query.Bind(2, std::string(*vehicle_data_item.since)) + : query.Bind(2); + vehicle_data_item.until.is_initialized() + ? query.Bind(3, std::string(*vehicle_data_item.until)) + : query.Bind(3); + + if (!query.Exec()) { + LOG4CXX_ERROR(logger_, + "Failed to retrieve vehicle data item: " + << std::string(vehicle_data_item.key) + << ". Error: " << query.LastError().text()); + return false; + } + return !query.IsNull(0); +} + const int32_t SQLPTRepresentation::GetDBVersion() const { return utils::Djb2HashFromString(sql_pt::kCreateSchema); } @@ -2348,6 +2814,8 @@ bool SQLPTRepresentation::CopyApplication(const std::string& source, : query.Bind(16, source_app.GetString(15)); source_app.IsNull(16) ? query.Bind(17) : query.Bind(17, source_app.GetBoolean(16)); + source_app.IsNull(17) ? query.Bind(18) + : query.Bind(18, source_app.GetBoolean(17)); if (!query.Exec()) { LOG4CXX_WARN(logger_, "Failed inserting into application."); diff --git a/src/components/policy/policy_external/src/status.cc b/src/components/policy/policy_external/src/status.cc index c2ee4e4bbcb..3d1cae3eba2 100644 --- a/src/components/policy/policy_external/src/status.cc +++ b/src/components/policy/policy_external/src/status.cc @@ -99,9 +99,11 @@ void policy::UpdatingStatus::ProcessEvent(policy::UpdateStatusManager* manager, break; case kScheduleUpdate: case kScheduleManualUpdate: - case kOnResetRetrySequence: manager->SetPostponedStatus(std::make_shared()); break; + case kOnResetRetrySequence: + manager->SetNextStatus(std::make_shared()); + break; default: break; } 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 b352b5ea39e..050908f3a02 100644 --- a/src/components/policy/policy_external/src/update_status_manager.cc +++ b/src/components/policy/policy_external/src/update_status_manager.cc @@ -32,6 +32,7 @@ #include "policy/update_status_manager.h" #include "policy/policy_listener.h" +#include "policy/ptu_retry_handler.h" #include "utils/logger.h" namespace policy { @@ -87,6 +88,14 @@ void UpdateStatusManager::OnUpdateSentOut(uint32_t update_timeout) { void UpdateStatusManager::OnUpdateTimeoutOccurs() { LOG4CXX_AUTO_TRACE(logger_); + + auto& ptu_retry_handler = listener_->ptu_retry_handler(); + + if (ptu_retry_handler.IsAllowedRetryCountExceeded()) { + ptu_retry_handler.RetrySequenceFailed(); + return; + } + ProcessEvent(kOnUpdateTimeout); DCHECK(update_status_thread_delegate_); update_status_thread_delegate_->updateTimeOut(0); // Stop Timer 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 d46f6a315ad..5165c46edbf 100644 --- a/src/components/policy/policy_external/src/usage_statistics/counter.cc +++ b/src/components/policy/policy_external/src/usage_statistics/counter.cc @@ -33,8 +33,8 @@ #ifndef SRC_COMPONENTS_POLICY_INCLUDE_POLICY_STATISTICS_MANAGER_H_ #define SRC_COMPONENTS_POLICY_INCLUDE_POLICY_STATISTICS_MANAGER_H_ -#include #include "policy/usage_statistics/counter.h" +#include #include "utils/date_time.h" #include "utils/timer_task_impl.h" diff --git a/src/components/policy/policy_external/test/CMakeLists.txt b/src/components/policy/policy_external/test/CMakeLists.txt index 8b77c90dd28..77b1b35973d 100644 --- a/src/components/policy/policy_external/test/CMakeLists.txt +++ b/src/components/policy/policy_external/test/CMakeLists.txt @@ -42,7 +42,7 @@ include_directories( set(testLibraries gmock Utils - Policy + PolicyStatic UsageStatistics ConfigProfile ) diff --git a/src/components/policy/policy_external/test/counter_test.cc b/src/components/policy/policy_external/test/counter_test.cc index 22b19c878ef..af166f96ade 100644 --- a/src/components/policy/policy_external/test/counter_test.cc +++ b/src/components/policy/policy_external/test/counter_test.cc @@ -29,12 +29,12 @@ * POSSIBILITY OF SUCH DAMAGE. */ +#include "policy/usage_statistics/counter.h" #include "gtest/gtest.h" #include "policy/usage_statistics/mock_statistics_manager.h" -#include "policy/usage_statistics/counter.h" -using ::testing::StrictMock; using ::testing::InSequence; +using ::testing::StrictMock; namespace test { namespace components { @@ -179,6 +179,6 @@ TEST( // Act hmi_full_stopwatch.WriteTime(); } -} // namespace usage_statistics -} // components +} // namespace usage_statistics_test +} // namespace components } // namespace test diff --git a/src/components/policy/policy_external/test/include/policy/mock_pt_ext_representation.h b/src/components/policy/policy_external/test/include/policy/mock_pt_ext_representation.h index 3225e79e010..b307270b100 100644 --- a/src/components/policy/policy_external/test/include/policy/mock_pt_ext_representation.h +++ b/src/components/policy/policy_external/test/include/policy/mock_pt_ext_representation.h @@ -37,10 +37,10 @@ #include "gmock/gmock.h" +#include "mock_pt_representation.h" +#include "policy/policy_table/types.h" #include "policy/pt_ext_representation.h" #include "rpc_base/rpc_base.h" -#include "policy/policy_table/types.h" -#include "mock_pt_representation.h" namespace policy_table = ::rpc::policy_table_interface_base; diff --git a/src/components/policy/policy_external/test/include/policy/mock_pt_representation.h b/src/components/policy/policy_external/test/include/policy/mock_pt_representation.h index 3870e4ece14..0b3fe7aef72 100644 --- a/src/components/policy/policy_external/test/include/policy/mock_pt_representation.h +++ b/src/components/policy/policy_external/test/include/policy/mock_pt_representation.h @@ -37,9 +37,9 @@ #include "gmock/gmock.h" +#include "policy/policy_table/types.h" #include "policy/pt_representation.h" #include "rpc_base/rpc_base.h" -#include "policy/policy_table/types.h" namespace policy_table = ::rpc::policy_table_interface_base; @@ -66,7 +66,6 @@ class MockPTRepresentation : virtual public ::policy::PTRepresentation { MOCK_METHOD1(SecondsBetweenRetries, bool(std::vector* seconds)); MOCK_METHOD2(GetPriority, bool(const std::string& app_id, std::string* priority)); - MOCK_CONST_METHOD0(GetVehicleInfo, const ::policy::VehicleInfo()); MOCK_METHOD1(SetVINValue, bool(const std::string& value)); MOCK_METHOD2(GetUserFriendlyMsg, std::vector< ::policy::UserFriendlyMessage>( diff --git a/src/components/policy/policy_external/test/include/policy/policy_manager_impl_test_base.h b/src/components/policy/policy_external/test/include/policy/policy_manager_impl_test_base.h index 23701e86de3..816b99cc2f4 100644 --- a/src/components/policy/policy_external/test/include/policy/policy_manager_impl_test_base.h +++ b/src/components/policy/policy_external/test/include/policy/policy_manager_impl_test_base.h @@ -40,16 +40,17 @@ #include "policy/policy_manager_impl.h" #include "policy/mock_cache_manager.h" -#include "policy/mock_update_status_manager.h" #include "policy/mock_policy_listener.h" #include "policy/mock_policy_settings.h" +#include "policy/mock_ptu_retry_handler.h" +#include "policy/mock_update_status_manager.h" namespace test { namespace components { namespace policy_test { -using ::testing::NiceMock; using ::policy::PolicyManagerImpl; +using ::testing::NiceMock; typedef std::multimap UserConsentPromptToRpcsConnections; @@ -112,9 +113,10 @@ class PolicyManagerImplTest : public ::testing::Test { const std::string unpaired_device_id_; PolicyManagerImpl* policy_manager_; - MockCacheManagerInterface* cache_manager_; + NiceMock* cache_manager_; MockUpdateStatusManager update_manager_; NiceMock listener_; + NiceMock ptu_retry_handler_; void SetUp() OVERRIDE; @@ -140,6 +142,7 @@ class PolicyManagerImplTest2 : public ::testing::Test { PolicyManagerImpl* policy_manager_; NiceMock listener_; + NiceMock ptu_retry_handler_; ::policy::StringArray hmi_level_; ::policy::StringArray pt_request_types_; size_t ptu_request_types_size_; 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 93d4e197510..333f4e8f84c 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 @@ -30,19 +30,19 @@ * POSSIBILITY OF SUCH DAMAGE. */ +#include #include #include #include -#include #include "gtest/gtest.h" #include "policy/policy_manager_impl_test_base.h" #include "policy/policy_table/types.h" +#include "json/reader.h" #include "utils/date_time.h" #include "utils/gen_hash.h" -#include "json/reader.h" namespace test { namespace components { @@ -92,7 +92,8 @@ TEST_F(PolicyManagerImplTest, EXPECT_CALL(*cache_manager_, IsApplicationRepresented(_)) .WillOnce(Return(true)); EXPECT_EQ(policy_manager_->GetPolicyTableStatus(), "UP_TO_DATE"); - policy_manager_->AddApplication(kDefaultId, + policy_manager_->AddApplication(kDefaultDeviceMacAddress, + kDefaultId, HmiTypes(policy_table::AHT_DEFAULT)); EXPECT_EQ(policy_manager_->GetPolicyTableStatus(), "UP_TO_DATE"); } @@ -109,10 +110,13 @@ TEST_F(PolicyManagerImplTest2, GetNotificationsNumberAfterPTUpdate) { // Act std::string json = table.toStyledString(); ::policy::BinaryMessage msg(json.begin(), json.end()); - EXPECT_CALL(listener_, OnUpdateStatusChanged(_)); - EXPECT_TRUE(policy_manager_->LoadPT(kFilePtUpdateJson, msg)); + ASSERT_EQ(PolicyManager::PtProcessingResult::kSuccess, + policy_manager_->LoadPT(kFilePtUpdateJson, msg)); EXPECT_FALSE(policy_manager_->GetCache()->IsPTPreloaded()); + EXPECT_CALL(listener_, OnUpdateStatusChanged(_)); + policy_manager_->OnPTUFinished(PolicyManager::PtProcessingResult::kSuccess); + std::string priority = "EMERGENCY"; uint32_t notif_number = policy_manager_->GetNotificationsNumber(priority); EXPECT_EQ(1u, notif_number); @@ -142,8 +146,11 @@ TEST_F(PolicyManagerImplTest2, IsAppRevoked_SetRevokedAppID_ExpectAppRevoked) { // Arrange CreateLocalPT(preloaded_pt_filename_); - policy_manager_->AddApplication(app_id_1_, - HmiTypes(policy_table::AHT_DEFAULT)); + EXPECT_CALL(listener_, GetDevicesIds(app_id_1_)) + .WillRepeatedly(Return(transport_manager::DeviceList())); + + policy_manager_->AddApplication( + device_id_1_, app_id_1_, HmiTypes(policy_table::AHT_DEFAULT)); std::ifstream ifile(kValidSdlPtUpdateJson); Json::Reader reader; @@ -158,7 +165,10 @@ TEST_F(PolicyManagerImplTest2, IsAppRevoked_SetRevokedAppID_ExpectAppRevoked) { ifile.close(); ::policy::BinaryMessage msg(json.begin(), json.end()); - ASSERT_TRUE(policy_manager_->LoadPT(kFilePtUpdateJson, msg)); + ASSERT_EQ(PolicyManager::PtProcessingResult::kSuccess, + policy_manager_->LoadPT(kFilePtUpdateJson, msg)); + policy_manager_->OnPTUFinished(PolicyManager::PtProcessingResult::kSuccess); + EXPECT_FALSE(policy_manager_->GetCache()->IsPTPreloaded()); CheckRpcPermissions( app_id_1_, "UnregisterAppInterface", ::policy::kRpcDisallowed); @@ -174,8 +184,8 @@ TEST_F(PolicyManagerImplTest2, AppRevokedOne_AppRegistered) { EXPECT_FALSE(policy_manager_->GetCache()->IsPTPreloaded()); ASSERT_TRUE( (policy_manager_->GetCache())->AddDevice(device_id_2_, "Bluetooth")); - policy_manager_->AddApplication(application_id_, - HmiTypes(policy_table::AHT_DEFAULT)); + policy_manager_->AddApplication( + device_id_2_, application_id_, HmiTypes(policy_table::AHT_DEFAULT)); // Registration is allowed CheckRpcPermissions("RegisterAppInterface", ::policy::kRpcAllowed); } @@ -187,12 +197,13 @@ TEST_F(PolicyManagerImplTest2, AppRevokedOne_AppRegistered_HMIDefault) { EmulatePTAppRevoked(kPtu2Json); EXPECT_FALSE(policy_manager_->GetCache()->IsPTPreloaded()); - policy_manager_->AddApplication(application_id_, - HmiTypes(policy_table::AHT_DEFAULT)); + policy_manager_->AddApplication( + device_id_1_, application_id_, HmiTypes(policy_table::AHT_DEFAULT)); std::string default_hmi; // Default HMI level is NONE - EXPECT_TRUE(policy_manager_->GetDefaultHmi(application_id_, &default_hmi)); + EXPECT_TRUE(policy_manager_->GetDefaultHmi( + device_id_1_, application_id_, &default_hmi)); EXPECT_EQ("NONE", default_hmi); } @@ -210,12 +221,16 @@ TEST_F(PolicyManagerImplTest2, "Life", 2, "Bluetooth"); - EXPECT_CALL(listener_, OnCurrentDeviceIdUpdateRequired(app_id_1_)) - .WillRepeatedly(Return(device_id_1_)); + + EXPECT_CALL(listener_, OnCurrentDeviceIdUpdateRequired(_, app_id_1_)) + .Times(0); + EXPECT_CALL(listener_, GetDevicesIds(app_id_1_)) + .WillRepeatedly(Return(transport_manager::DeviceList(1, device_id_1_))); + policy_manager_->SetUserConsentForDevice(device_id_1_, true); // Add app from consented device. App will be assigned with default policies - policy_manager_->AddApplication(app_id_1_, - HmiTypes(policy_table::AHT_DEFAULT)); + policy_manager_->AddApplication( + device_id_1_, app_id_1_, HmiTypes(policy_table::AHT_DEFAULT)); // Check before action policy_table::RpcParameters rpc_parameters; rpc_parameters.hmi_levels.push_back(policy_table::HL_FULL); @@ -227,7 +242,7 @@ TEST_F(PolicyManagerImplTest2, ::policy::CheckPermissionResult output; policy_manager_->CheckPermissions( - app_id_1_, kHmiLevelFull, "Alert", input_params, output); + device_id_1_, app_id_1_, kHmiLevelFull, "Alert", input_params, output); // Check RPC is allowed EXPECT_EQ(::policy::kRpcAllowed, output.hmi_level_permitted); @@ -244,11 +259,14 @@ TEST_F(PolicyManagerImplTest2, ifile.close(); ::policy::BinaryMessage msg(json.begin(), json.end()); - ASSERT_TRUE(policy_manager_->LoadPT(kFilePtUpdateJson, msg)); + ASSERT_EQ(PolicyManager::PtProcessingResult::kSuccess, + policy_manager_->LoadPT(kFilePtUpdateJson, msg)); + policy_manager_->OnPTUFinished(PolicyManager::PtProcessingResult::kSuccess); + EXPECT_FALSE(cache->IsPTPreloaded()); policy_manager_->CheckPermissions( - app_id_1_, kHmiLevelFull, "Alert", input_params, output); + device_id_1_, app_id_1_, kHmiLevelFull, "Alert", input_params, output); // Check RPC is disallowed EXPECT_EQ(::policy::kRpcDisallowed, output.hmi_level_permitted); ASSERT_TRUE(output.list_of_allowed_params.empty()); @@ -269,12 +287,14 @@ TEST_F(PolicyManagerImplTest2, "Life", 2, "Bluetooth")); - EXPECT_CALL(listener_, OnCurrentDeviceIdUpdateRequired(application_id_)) - .WillRepeatedly(Return(device_id_1_)); + EXPECT_CALL(listener_, OnCurrentDeviceIdUpdateRequired(_, application_id_)) + .Times(0); + EXPECT_CALL(listener_, GetDevicesIds(application_id_)) + .WillRepeatedly(Return(transport_manager::DeviceList(1, device_id_1_))); policy_manager_->SetUserConsentForDevice(device_id_1_, true); // Add app from consented device. App will be assigned with default policies - policy_manager_->AddApplication(application_id_, - HmiTypes(policy_table::AHT_MEDIA)); + policy_manager_->AddApplication( + device_id_1_, application_id_, HmiTypes(policy_table::AHT_MEDIA)); // Emulate PTU with new policies for app added above std::ifstream ifile(kValidSdlPtUpdateJson); Json::Reader reader; @@ -312,7 +332,10 @@ TEST_F(PolicyManagerImplTest2, ::policy::BinaryMessage msg(json.begin(), json.end()); // Load Json to cache - EXPECT_TRUE(policy_manager_->LoadPT(kFilePtUpdateJson, msg)); + ASSERT_EQ(PolicyManager::PtProcessingResult::kSuccess, + policy_manager_->LoadPT(kFilePtUpdateJson, msg)); + policy_manager_->OnPTUFinished(PolicyManager::PtProcessingResult::kSuccess); + EXPECT_FALSE(cache->IsPTPreloaded()); policy_table::RpcParameters rpc_parameters; @@ -323,8 +346,6 @@ TEST_F(PolicyManagerImplTest2, ::policy::RPCParams input_params; ::policy::CheckPermissionResult output; - EXPECT_CALL(listener_, OnCurrentDeviceIdUpdateRequired(application_id_)) - .WillOnce(Return(device_id_1_)); cache->AddDevice(device_id_1_, "Bluetooth"); cache->SetDeviceData(device_id_1_, "hardware IPX", @@ -334,8 +355,12 @@ TEST_F(PolicyManagerImplTest2, "Life", 2, "Bluetooth"); - policy_manager_->CheckPermissions( - application_id_, kHmiLevelFull, "Alert", input_params, output); + policy_manager_->CheckPermissions(device_id_1_, + application_id_, + kHmiLevelFull, + "Alert", + input_params, + output); // Check RPC is allowed EXPECT_EQ(::policy::kRpcAllowed, output.hmi_level_permitted); // Check list of parameters empty @@ -344,21 +369,22 @@ TEST_F(PolicyManagerImplTest2, TEST_F(PolicyManagerImplTest2, CheckPermissions_NoParametersInPT_CheckRpcsInDifferentLevels) { + EXPECT_CALL(listener_, GetDevicesIds(application_id_)) + .WillRepeatedly(Return(transport_manager::DeviceList())); // Arrange AddSetDeviceData(); LoadPTUFromJsonFile("json/sdl_update_pt_send_location.json"); - // Will be called each time permissions are checked - EXPECT_CALL(listener_, OnCurrentDeviceIdUpdateRequired(application_id_)) - .Times(4) - .WillRepeatedly(Return(device_id_1_)); - // Check RPC in each level ::policy::RPCParams input_params; ::policy::CheckPermissionResult output; // Rpc in FULL level - policy_manager_->CheckPermissions( - application_id_, kHmiLevelFull, "SendLocation", input_params, output); + policy_manager_->CheckPermissions(device_id_1_, + application_id_, + kHmiLevelFull, + "SendLocation", + input_params, + output); // Check RPC is allowed EXPECT_EQ(::policy::kRpcAllowed, output.hmi_level_permitted); ASSERT_TRUE(output.list_of_allowed_params.empty()); @@ -367,8 +393,12 @@ TEST_F(PolicyManagerImplTest2, ResetOutputList(output); // Rpc in LIMITED level - policy_manager_->CheckPermissions( - application_id_, kHmiLevelLimited, "SendLocation", input_params, output); + policy_manager_->CheckPermissions(device_id_1_, + application_id_, + kHmiLevelLimited, + "SendLocation", + input_params, + output); // Check RPC is allowed EXPECT_EQ(::policy::kRpcAllowed, output.hmi_level_permitted); ASSERT_TRUE(output.list_of_allowed_params.empty()); @@ -376,7 +406,8 @@ TEST_F(PolicyManagerImplTest2, ResetOutputList(output); // Rpc in BACKGROUND level - policy_manager_->CheckPermissions(application_id_, + policy_manager_->CheckPermissions(device_id_1_, + application_id_, kHmiLevelBackground, "SendLocation", input_params, @@ -388,8 +419,12 @@ TEST_F(PolicyManagerImplTest2, ResetOutputList(output); // Rpc in NONE level - policy_manager_->CheckPermissions( - application_id_, kHmiLevelNone, "SendLocation", input_params, output); + policy_manager_->CheckPermissions(device_id_1_, + application_id_, + kHmiLevelNone, + "SendLocation", + input_params, + output); // Check RPC is disallowed EXPECT_EQ(::policy::kRpcDisallowed, output.hmi_level_permitted); // Check list of parameters is empty @@ -399,24 +434,25 @@ TEST_F(PolicyManagerImplTest2, TEST_F( PolicyManagerImplTest2, CheckPermissions_ParamsNotAllowedInPT_AddAppWithAllParams_CheckRpcsInDiffLvls) { + EXPECT_CALL(listener_, GetDevicesIds(application_id_)) + .WillRepeatedly(Return(transport_manager::DeviceList())); // Arrange AddSetDeviceData(); // File have empty parameters, so they are forbidden LoadPTUFromJsonFile("json/sdl_update_pt_send_location_no_params.json"); - // Will be called each time permissions are checked - EXPECT_CALL(listener_, OnCurrentDeviceIdUpdateRequired(application_id_)) - .Times(4) - .WillRepeatedly(Return(device_id_1_)); - // Check RPC in each level ::policy::RPCParams input_params; InsertRpcParametersInList(input_params); ::policy::CheckPermissionResult output; // Rpc in FULL level - policy_manager_->CheckPermissions( - application_id_, kHmiLevelFull, "SendLocation", input_params, output); + policy_manager_->CheckPermissions(device_id_1_, + application_id_, + kHmiLevelFull, + "SendLocation", + input_params, + output); // Group which has RPC does not require user consent, so its auto-allowed for // user. Since RPC 'parameters' section is present, but empty, that means @@ -431,8 +467,12 @@ TEST_F( ResetOutputList(output); // Rpc in LIMITED level - policy_manager_->CheckPermissions( - application_id_, kHmiLevelLimited, "SendLocation", input_params, output); + policy_manager_->CheckPermissions(device_id_1_, + application_id_, + kHmiLevelLimited, + "SendLocation", + input_params, + output); EXPECT_EQ(::policy::kRpcDisallowed, output.hmi_level_permitted); @@ -443,7 +483,8 @@ TEST_F( ResetOutputList(output); // Rpc in BACKGROUND level - policy_manager_->CheckPermissions(application_id_, + policy_manager_->CheckPermissions(device_id_1_, + application_id_, kHmiLevelBackground, "SendLocation", input_params, @@ -459,8 +500,12 @@ TEST_F( ResetOutputList(output); // Rpc in NONE level - policy_manager_->CheckPermissions( - application_id_, kHmiLevelNone, "SendLocation", input_params, output); + policy_manager_->CheckPermissions(device_id_1_, + application_id_, + kHmiLevelNone, + "SendLocation", + input_params, + output); EXPECT_EQ(::policy::kRpcDisallowed, output.hmi_level_permitted); @@ -472,6 +517,8 @@ TEST_F( TEST_F(PolicyManagerImplTest2, CheckPermissions_SomeParamsAllowedInPT_CheckRpcsInDiffLvls) { + EXPECT_CALL(listener_, GetDevicesIds(application_id_)) + .WillRepeatedly(Return(transport_manager::DeviceList())); // Arrange AddSetDeviceData(); @@ -479,19 +526,18 @@ TEST_F(PolicyManagerImplTest2, //"locationDescription", "phoneNumber" are allowed LoadPTUFromJsonFile("json/sdl_update_pt_send_location_some_params.json"); - // Will be called each time permissions are checked - EXPECT_CALL(listener_, OnCurrentDeviceIdUpdateRequired(application_id_)) - .Times(4) - .WillRepeatedly(Return(device_id_1_)); - // Check RPC in each level ::policy::RPCParams input_params; InsertRpcParametersInList(input_params); ::policy::CheckPermissionResult output; // Rpc in FULL level - policy_manager_->CheckPermissions( - application_id_, kHmiLevelFull, "SendLocation", input_params, output); + policy_manager_->CheckPermissions(device_id_1_, + application_id_, + kHmiLevelFull, + "SendLocation", + input_params, + output); // Check RPC is allowed EXPECT_EQ(::policy::kRpcAllowed, output.hmi_level_permitted); @@ -520,8 +566,12 @@ TEST_F(PolicyManagerImplTest2, output.list_of_undefined_params.clear(); // Rpc in LIMITED level - policy_manager_->CheckPermissions( - application_id_, kHmiLevelLimited, "SendLocation", input_params, output); + policy_manager_->CheckPermissions(device_id_1_, + application_id_, + kHmiLevelLimited, + "SendLocation", + input_params, + output); // Check RPC is allowed EXPECT_EQ(::policy::kRpcAllowed, output.hmi_level_permitted); @@ -539,7 +589,8 @@ TEST_F(PolicyManagerImplTest2, ResetOutputList(output); // Rpc in BACKGROUND level - policy_manager_->CheckPermissions(application_id_, + policy_manager_->CheckPermissions(device_id_1_, + application_id_, kHmiLevelBackground, "SendLocation", input_params, @@ -559,8 +610,12 @@ TEST_F(PolicyManagerImplTest2, ResetOutputList(output); // Rpc in NONE level - policy_manager_->CheckPermissions( - application_id_, kHmiLevelNone, "SendLocation", input_params, output); + policy_manager_->CheckPermissions(device_id_1_, + application_id_, + kHmiLevelNone, + "SendLocation", + input_params, + output); // Check RPC is disallowed EXPECT_EQ(::policy::kRpcDisallowed, output.hmi_level_permitted); // Check lists of parameters are empty @@ -585,10 +640,12 @@ TEST_F(PolicyManagerImplTest2, GetCorrectStatus_PTUSuccessful) { CreateLocalPT(preloaded_pt_filename_); // Check EXPECT_EQ("UP_TO_DATE", policy_manager_->GetPolicyTableStatus()); + EXPECT_CALL(listener_, GetDevicesIds(application_id_)) + .WillRepeatedly(Return(transport_manager::DeviceList())); // Adding changes PT status - policy_manager_->AddApplication(application_id_, - HmiTypes(policy_table::AHT_DEFAULT)); + policy_manager_->AddApplication( + device_id_1_, application_id_, HmiTypes(policy_table::AHT_DEFAULT)); EXPECT_EQ("UP_TO_DATE", policy_manager_->GetPolicyTableStatus()); // Before load PT we should send notification about start updating policy_manager_->OnUpdateStarted(); @@ -613,6 +670,8 @@ TEST_F(PolicyManagerImplTest2, TEST_F(PolicyManagerImplTest2, CheckPermissions_DiffParamsAllowedInGroups_CheckRpcsInDiffLvls) { + EXPECT_CALL(listener_, GetDevicesIds(application_id_)) + .WillRepeatedly(Return(transport_manager::DeviceList())); // Arrange AddSetDeviceData(); // Load Json to cache @@ -621,19 +680,18 @@ TEST_F(PolicyManagerImplTest2, // Allowed both groups of parameters LoadPTUFromJsonFile("json/sdl_update_pt_2_groups_have_params.json"); - // Will be called each time permissions are checked - EXPECT_CALL(listener_, OnCurrentDeviceIdUpdateRequired(application_id_)) - .Times(4) - .WillRepeatedly(Return(device_id_1_)); - // Check RPC in each level ::policy::RPCParams input_params; InsertRpcParametersInList(input_params); ::policy::CheckPermissionResult output; // Rpc in FULL level - policy_manager_->CheckPermissions( - application_id_, kHmiLevelFull, "SendLocation", input_params, output); + policy_manager_->CheckPermissions(device_id_1_, + application_id_, + kHmiLevelFull, + "SendLocation", + input_params, + output); // Check RPC is allowed EXPECT_EQ(::policy::kRpcAllowed, output.hmi_level_permitted); // Check list of allowed parameters is not empty @@ -652,8 +710,12 @@ TEST_F(PolicyManagerImplTest2, ResetOutputList(output); // Rpc in LIMITED level - policy_manager_->CheckPermissions( - application_id_, kHmiLevelLimited, "SendLocation", input_params, output); + policy_manager_->CheckPermissions(device_id_1_, + application_id_, + kHmiLevelLimited, + "SendLocation", + input_params, + output); // Check RPC is allowed EXPECT_EQ(::policy::kRpcAllowed, output.hmi_level_permitted); // Check list of allowed parameters is not empty @@ -672,7 +734,8 @@ TEST_F(PolicyManagerImplTest2, ResetOutputList(output); // Rpc in BACKGROUND level - policy_manager_->CheckPermissions(application_id_, + policy_manager_->CheckPermissions(device_id_1_, + application_id_, kHmiLevelBackground, "SendLocation", input_params, @@ -696,8 +759,12 @@ TEST_F(PolicyManagerImplTest2, ResetOutputList(output); // Rpc in NONE level - policy_manager_->CheckPermissions( - application_id_, kHmiLevelNone, "SendLocation", input_params, output); + policy_manager_->CheckPermissions(device_id_1_, + application_id_, + kHmiLevelNone, + "SendLocation", + input_params, + output); // Check RPC is disallowed EXPECT_EQ(::policy::kRpcDisallowed, output.hmi_level_permitted); // Check lists of parameters are empty @@ -726,9 +793,12 @@ TEST_F(PolicyManagerImplTest2, 2, "Bluetooth")); + EXPECT_CALL(listener_, GetDevicesIds(application_id_)) + .WillRepeatedly(Return(transport_manager::DeviceList())); // Add app from consented device. App will be assigned with default policies - policy_manager_->AddApplication(application_id_, - HmiTypes(policy_table::AHT_DEFAULT)); + policy_manager_->SetUserConsentForDevice(device_id_1_, true); + policy_manager_->AddApplication( + device_id_1_, application_id_, HmiTypes(policy_table::AHT_DEFAULT)); std::ifstream ifile("json/sdl_update_pt_2_groups_no_params_in1.json"); Json::Reader reader; @@ -740,13 +810,11 @@ TEST_F(PolicyManagerImplTest2, json = root.toStyledString(); ifile.close(); ::policy::BinaryMessage msg(json.begin(), json.end()); - EXPECT_TRUE(policy_manager_->LoadPT(kFilePtUpdateJson, msg)); - EXPECT_FALSE(cache->IsPTPreloaded()); + ASSERT_EQ(PolicyManager::PtProcessingResult::kSuccess, + policy_manager_->LoadPT(kFilePtUpdateJson, msg)); + policy_manager_->OnPTUFinished(PolicyManager::PtProcessingResult::kSuccess); - // Will be called each time permissions are checked - EXPECT_CALL(listener_, OnCurrentDeviceIdUpdateRequired(application_id_)) - .Times(4) - .WillRepeatedly(Return(device_id_1_)); + EXPECT_FALSE(cache->IsPTPreloaded()); // Check RPC in each level ::policy::RPCParams input_params; @@ -754,8 +822,12 @@ TEST_F(PolicyManagerImplTest2, ::policy::CheckPermissionResult output; // Rpc in FULL level - policy_manager_->CheckPermissions( - application_id_, kHmiLevelFull, "SendLocation", input_params, output); + policy_manager_->CheckPermissions(device_id_1_, + application_id_, + kHmiLevelFull, + "SendLocation", + input_params, + output); EXPECT_EQ(::policy::kRpcAllowed, output.hmi_level_permitted); EXPECT_TRUE(output.list_of_undefined_params.empty()); @@ -763,8 +835,12 @@ TEST_F(PolicyManagerImplTest2, ResetOutputList(output); // Rpc in LIMITED level - policy_manager_->CheckPermissions( - application_id_, kHmiLevelLimited, "SendLocation", input_params, output); + policy_manager_->CheckPermissions(device_id_1_, + application_id_, + kHmiLevelLimited, + "SendLocation", + input_params, + output); EXPECT_EQ(::policy::kRpcAllowed, output.hmi_level_permitted); EXPECT_TRUE(output.list_of_undefined_params.empty()); @@ -772,7 +848,8 @@ TEST_F(PolicyManagerImplTest2, ResetOutputList(output); // Rpc in BACKGROUND level - policy_manager_->CheckPermissions(application_id_, + policy_manager_->CheckPermissions(device_id_1_, + application_id_, kHmiLevelBackground, "SendLocation", input_params, @@ -785,8 +862,12 @@ TEST_F(PolicyManagerImplTest2, ResetOutputList(output); // Rpc in NONE level - policy_manager_->CheckPermissions( - application_id_, kHmiLevelNone, "SendLocation", input_params, output); + policy_manager_->CheckPermissions(device_id_1_, + application_id_, + kHmiLevelNone, + "SendLocation", + input_params, + output); EXPECT_EQ(::policy::kRpcDisallowed, output.hmi_level_permitted); EXPECT_TRUE(output.list_of_allowed_params.empty()); @@ -813,9 +894,12 @@ TEST_F(PolicyManagerImplTest2, 2, "Bluetooth")); + EXPECT_CALL(listener_, GetDevicesIds(application_id_)) + .WillRepeatedly(Return(transport_manager::DeviceList())); // Add app from consented device. App will be assigned with default policies - policy_manager_->AddApplication(application_id_, - HmiTypes(policy_table::AHT_DEFAULT)); + policy_manager_->SetUserConsentForDevice(device_id_1_, true); + policy_manager_->AddApplication( + device_id_1_, application_id_, HmiTypes(policy_table::AHT_DEFAULT)); std::ifstream ifile( "json/sdl_update_pt_2_groups_no_params_in1_omitted_in2.json"); @@ -828,13 +912,11 @@ TEST_F(PolicyManagerImplTest2, json = root.toStyledString(); ifile.close(); ::policy::BinaryMessage msg(json.begin(), json.end()); - EXPECT_TRUE(policy_manager_->LoadPT(kFilePtUpdateJson, msg)); - EXPECT_FALSE(cache->IsPTPreloaded()); + ASSERT_EQ(PolicyManager::PtProcessingResult::kSuccess, + policy_manager_->LoadPT(kFilePtUpdateJson, msg)); + policy_manager_->OnPTUFinished(PolicyManager::PtProcessingResult::kSuccess); - // Will be called each time permissions are checked - EXPECT_CALL(listener_, OnCurrentDeviceIdUpdateRequired(application_id_)) - .Times(4) - .WillRepeatedly(Return(device_id_1_)); + EXPECT_FALSE(cache->IsPTPreloaded()); // Check RPC in each level ::policy::RPCParams input_params; @@ -842,8 +924,12 @@ TEST_F(PolicyManagerImplTest2, ::policy::CheckPermissionResult output; // Rpc in FULL level - policy_manager_->CheckPermissions( - application_id_, kHmiLevelFull, "SendLocation", input_params, output); + policy_manager_->CheckPermissions(device_id_1_, + application_id_, + kHmiLevelFull, + "SendLocation", + input_params, + output); EXPECT_EQ(::policy::kRpcAllowed, output.hmi_level_permitted); EXPECT_TRUE(output.list_of_undefined_params.empty()); @@ -851,15 +937,20 @@ TEST_F(PolicyManagerImplTest2, ResetOutputList(output); // Rpc in LIMITED level - policy_manager_->CheckPermissions( - application_id_, kHmiLevelLimited, "SendLocation", input_params, output); + policy_manager_->CheckPermissions(device_id_1_, + application_id_, + kHmiLevelLimited, + "SendLocation", + input_params, + output); 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 - policy_manager_->CheckPermissions(application_id_, + policy_manager_->CheckPermissions(device_id_1_, + application_id_, kHmiLevelBackground, "SendLocation", input_params, @@ -871,8 +962,12 @@ TEST_F(PolicyManagerImplTest2, ResetOutputList(output); // Rpc in NONE level - policy_manager_->CheckPermissions( - application_id_, kHmiLevelNone, "SendLocation", input_params, output); + policy_manager_->CheckPermissions(device_id_1_, + application_id_, + kHmiLevelNone, + "SendLocation", + input_params, + output); EXPECT_EQ(::policy::kRpcDisallowed, output.hmi_level_permitted); EXPECT_TRUE(output.list_of_allowed_params.empty()); EXPECT_TRUE(output.list_of_disallowed_params.empty()); @@ -895,17 +990,26 @@ TEST_F(PolicyManagerImplTest, LoadPT_SetInvalidUpdatePT_PTIsNotLoaded) { std::string json = table.toStyledString(); ::policy::BinaryMessage msg(json.begin(), json.end()); + auto pt = std::make_shared(); + *pt = update; + // Assert - EXPECT_CALL(*cache_manager_, GenerateSnapshot()).Times(0); EXPECT_CALL(*cache_manager_, ApplyUpdate(_)).Times(0); EXPECT_CALL(listener_, GetAppName(_)).Times(0); - EXPECT_CALL(listener_, OnUpdateStatusChanged(_)).Times(1); EXPECT_CALL(*cache_manager_, SaveUpdateRequired(false)).Times(0); EXPECT_CALL(*cache_manager_, TimeoutResponse()).Times(0); EXPECT_CALL(*cache_manager_, SecondsBetweenRetries(_)).Times(0); - EXPECT_FALSE(policy_manager_->LoadPT(kFilePtUpdateJson, msg)); + EXPECT_CALL(*cache_manager_, GetVehicleDataItems()) + .WillOnce(Return(std::vector())); + ASSERT_EQ(PolicyManager::PtProcessingResult::kWrongPtReceived, + policy_manager_->LoadPT(kFilePtUpdateJson, msg)); + EXPECT_CALL(*cache_manager_, IsPTPreloaded()); EXPECT_FALSE(policy_manager_->GetCache()->IsPTPreloaded()); + + EXPECT_CALL(listener_, OnUpdateStatusChanged(_)).Times(1); + policy_manager_->OnPTUFinished( + PolicyManager::PtProcessingResult::kWrongPtReceived); } TEST_F( @@ -917,8 +1021,8 @@ TEST_F( GetPTU(kValidSdlPtUpdateJson); EXPECT_EQ("UP_TO_DATE", policy_manager_->GetPolicyTableStatus()); // Try to add existing app - policy_manager_->AddApplication(app_id_2_, - HmiTypes(policy_table::AHT_DEFAULT)); + policy_manager_->AddApplication( + device_id_1_, app_id_2_, HmiTypes(policy_table::AHT_DEFAULT)); // Check no update required EXPECT_EQ("UP_TO_DATE", policy_manager_->GetPolicyTableStatus()); } @@ -939,14 +1043,14 @@ TEST_F(PolicyManagerImplTest2, GetPTU(kValidSdlPtUpdateJson); EXPECT_EQ("UP_TO_DATE", policy_manager_->GetPolicyTableStatus()); - policy_manager_->AddApplication(app_id_2_, - HmiTypes(policy_table::AHT_DEFAULT)); + policy_manager_->AddApplication( + device_id_2_, app_id_2_, HmiTypes(policy_table::AHT_DEFAULT)); EXPECT_EQ("UP_TO_DATE", policy_manager_->GetPolicyTableStatus()); ::policy::Counters counter = ::policy::Counters::DAYS_AFTER_EPOCH; // Set PT was updated 10 days ago (limit is 30 days for now) // So no limit exceeded policy_manager_->PTUpdatedAt(counter, days - 10); - policy_manager_->OnAppRegisteredOnMobile(app_id_2_); + policy_manager_->OnAppRegisteredOnMobile(device_id_2_, app_id_2_); EXPECT_EQ("UP_TO_DATE", policy_manager_->GetPolicyTableStatus()); } @@ -959,13 +1063,13 @@ TEST_F(PolicyManagerImplTest2, GetPTU(kValidSdlPtUpdateJson); EXPECT_EQ("UP_TO_DATE", policy_manager_->GetPolicyTableStatus()); - policy_manager_->AddApplication(app_id_2_, - HmiTypes(policy_table::AHT_DEFAULT)); + policy_manager_->AddApplication( + device_id_2_, app_id_2_, HmiTypes(policy_table::AHT_DEFAULT)); EXPECT_EQ("UP_TO_DATE", policy_manager_->GetPolicyTableStatus()); ::policy::Counters counter = ::policy::Counters::DAYS_AFTER_EPOCH; // Set PT was updated 50 days ago (limit is 30 days for now) policy_manager_->PTUpdatedAt(counter, days - 50); - policy_manager_->OnAppRegisteredOnMobile(app_id_2_); + policy_manager_->OnAppRegisteredOnMobile(device_id_2_, app_id_2_); EXPECT_EQ("UPDATE_NEEDED", policy_manager_->GetPolicyTableStatus()); } @@ -979,8 +1083,8 @@ TEST_F( GetPTU(kValidSdlPtUpdateJson); EXPECT_EQ("UP_TO_DATE", policy_manager_->GetPolicyTableStatus()); // Try to add existing app - policy_manager_->AddApplication(app_id_2_, - HmiTypes(policy_table::AHT_DEFAULT)); + policy_manager_->AddApplication( + device_id_2_, app_id_2_, HmiTypes(policy_table::AHT_DEFAULT)); EXPECT_EQ("UP_TO_DATE", policy_manager_->GetPolicyTableStatus()); ::policy::Counters counter = ::policy::Counters::DAYS_AFTER_EPOCH; // Set PT was updated 10 days ago (limit is 30 days for now) @@ -993,7 +1097,7 @@ TEST_F( for (int i = 0; i < ign_cycles; ++i) { policy_manager_->IncrementIgnitionCycles(); } - policy_manager_->OnAppRegisteredOnMobile(app_id_2_); + policy_manager_->OnAppRegisteredOnMobile(device_id_2_, app_id_2_); // Check update required EXPECT_EQ("UPDATE_NEEDED", policy_manager_->GetPolicyTableStatus()); } @@ -1022,10 +1126,10 @@ TEST_F(PolicyManagerImplTest2, ->SetUserPermissionsForDevice( device_id_2_, consented_groups, disallowed_groups); policy_manager_->SetUserConsentForDevice(device_id_2_, true); - EXPECT_CALL(listener_, OnCurrentDeviceIdUpdateRequired(app_id_2_)) - .WillRepeatedly(Return(device_id_2_)); - policy_manager_->AddApplication(app_id_2_, - HmiTypes(policy_table::AHT_DEFAULT)); + EXPECT_CALL(listener_, GetDevicesIds(app_id_2_)) + .WillRepeatedly(Return(transport_manager::DeviceList())); + policy_manager_->AddApplication( + device_id_2_, app_id_2_, HmiTypes(policy_table::AHT_DEFAULT)); GetPTU(kValidSdlPtUpdateJson); ::policy::PermissionConsent perm_consent; @@ -1045,7 +1149,8 @@ TEST_F(PolicyManagerImplTest2, policy_manager_->SetUserConsentForApp(perm_consent, policy::PolicyManager::kSilentMode); - policy_manager_->SendNotificationOnPermissionsUpdated(app_id_2_); + policy_manager_->SendNotificationOnPermissionsUpdated(device_id_2_, + app_id_2_); std::vector< ::policy::FunctionalGroupPermission> actual_groups_permissions; std::vector< ::policy::FunctionalGroupPermission>::iterator it; policy_manager_->GetUserConsentForApp( @@ -1069,8 +1174,10 @@ TEST_F(PolicyManagerImplTest2, CanAppKeepContext_SetPoliciesForAppUpdated_ExpectAppCanKeepContext) { // Arrange CreateLocalPT(preloaded_pt_filename_); - policy_manager_->AddApplication(app_id_2_, - HmiTypes(policy_table::AHT_DEFAULT)); + EXPECT_CALL(listener_, GetDevicesIds(app_id_2_)) + .WillRepeatedly(Return(transport_manager::DeviceList())); + policy_manager_->AddApplication( + device_id_2_, app_id_2_, HmiTypes(policy_table::AHT_DEFAULT)); GetPTU(kValidSdlPtUpdateJson); // Check keep context in updated policies for app EXPECT_TRUE(policy_manager_->CanAppKeepContext(app_id_2_)); @@ -1080,31 +1187,15 @@ TEST_F(PolicyManagerImplTest2, CanAppStealFocus_SetPoliciesForAppUpdated_ExpectAppCanStealFocus) { // Arrange CreateLocalPT(preloaded_pt_filename_); - policy_manager_->AddApplication(app_id_2_, - HmiTypes(policy_table::AHT_DEFAULT)); + EXPECT_CALL(listener_, GetDevicesIds(app_id_2_)) + .WillRepeatedly(Return(transport_manager::DeviceList())); + policy_manager_->AddApplication( + device_id_2_, app_id_2_, HmiTypes(policy_table::AHT_DEFAULT)); GetPTU(kValidSdlPtUpdateJson); // Check keep context in updated policies for app EXPECT_TRUE(policy_manager_->CanAppKeepContext(app_id_2_)); } -TEST_F(PolicyManagerImplTest2, - GetVehicleInfo_SetVehicleInfo_ExpectReceivedInfoCorrect) { - // Arrange - CreateLocalPT(preloaded_pt_filename_); - GetPTU(kValidSdlPtUpdateJson); - std::shared_ptr pt = - (policy_manager_->GetCache())->GetPT(); - policy_table::ModuleConfig& module_config = pt->policy_table.module_config; - ::policy::VehicleInfo vehicle_info = policy_manager_->GetVehicleInfo(); - - EXPECT_EQ(static_cast(*module_config.vehicle_make), - vehicle_info.vehicle_make); - EXPECT_EQ(static_cast(*module_config.vehicle_model), - vehicle_info.vehicle_model); - EXPECT_EQ(static_cast(*module_config.vehicle_year), - vehicle_info.vehicle_year); -} - TEST_F( PolicyManagerImplTest2, GetPermissionsForApp_SetUserConsentForApp_ExpectReceivedPermissionsCorrect) { @@ -1130,10 +1221,10 @@ TEST_F( ->SetUserPermissionsForDevice( device_id_2_, consented_groups, disallowed_groups); policy_manager_->SetUserConsentForDevice(device_id_2_, true); - EXPECT_CALL(listener_, OnCurrentDeviceIdUpdateRequired(app_id_2_)) - .WillRepeatedly(Return(device_id_2_)); - policy_manager_->AddApplication(app_id_2_, - HmiTypes(policy_table::AHT_DEFAULT)); + EXPECT_CALL(listener_, GetDevicesIds(app_id_2_)) + .WillRepeatedly(Return(transport_manager::DeviceList(1, device_id_2_))); + policy_manager_->AddApplication( + device_id_2_, app_id_2_, HmiTypes(policy_table::AHT_DEFAULT)); GetPTU(kValidSdlPtUpdateJson); ::policy::PermissionConsent perm_consent; @@ -1153,7 +1244,8 @@ TEST_F( policy_manager_->SetUserConsentForApp(perm_consent, policy::PolicyManager::kSilentMode); - policy_manager_->SendNotificationOnPermissionsUpdated(app_id_2_); + policy_manager_->SendNotificationOnPermissionsUpdated(device_id_2_, + app_id_2_); std::vector< ::policy::FunctionalGroupPermission> actual_groups_permissions; std::vector< ::policy::FunctionalGroupPermission>::iterator it; policy_manager_->GetPermissionsForApp( @@ -1177,19 +1269,23 @@ TEST_F( PolicyManagerImplTest2, GetAppRequestTypes_AddApp_UpdateAppPolicies_ExpectReceivedRequestTypesCorrect) { // Arrange + const transport_manager::DeviceHandle handle = 1; CreateLocalPT(preloaded_pt_filename_); - - policy_manager_->AddApplication(app_id_3_, - HmiTypes(policy_table::AHT_DEFAULT)); + EXPECT_CALL(listener_, GetDevicesIds(app_id_3_)) + .WillRepeatedly(Return(transport_manager::DeviceList(1, device_id_1_))); + EXPECT_CALL(listener_, OnCurrentDeviceIdUpdateRequired(handle, app_id_3_)) + .WillRepeatedly(Return(device_id_1_)); + policy_manager_->AddApplication( + device_id_1_, app_id_3_, HmiTypes(policy_table::AHT_DEFAULT)); ::policy::StringArray app_requests = - policy_manager_->GetAppRequestTypes(app_id_3_); + policy_manager_->GetAppRequestTypes(handle, app_id_3_); EXPECT_EQ(1u, app_requests.size()); Json::Value root = GetPTU(kPtuRequestTypeJson); Json::Value request_Types = Json::Value(Json::arrayValue); request_Types = root["policy_table"]["app_policies"][app_id_3_]["RequestType"]; - app_requests = policy_manager_->GetAppRequestTypes(app_id_3_); + app_requests = policy_manager_->GetAppRequestTypes(handle, app_id_3_); EXPECT_EQ(request_Types.size(), app_requests.size()); // Check nicknames match for (uint32_t i = 0; i < request_Types.size(); ++i) { @@ -1213,9 +1309,11 @@ TEST_F( rpc::ValidationReport report("policy_table"); pt->ReportErrors(&report); } + EXPECT_CALL(listener_, GetDevicesIds(app_id_2_)) + .WillRepeatedly(Return(transport_manager::DeviceList())); // Add new app - policy_manager_->AddApplication(app_id_2_, - HmiTypes(policy_table::AHT_DEFAULT)); + policy_manager_->AddApplication( + device_id_2_, app_id_2_, HmiTypes(policy_table::AHT_DEFAULT)); uint32_t result = policy_manager_->HeartBeatTimeout(app_id_2_); // By default hertbeat timeout is 0 EXPECT_EQ(0u, result); @@ -1261,10 +1359,10 @@ TEST_F(PolicyManagerImplTest2, ->SetUserPermissionsForDevice( device_id_2_, consented_groups, disallowed_groups); policy_manager_->SetUserConsentForDevice(device_id_2_, true); - EXPECT_CALL(listener_, OnCurrentDeviceIdUpdateRequired(app_id_2_)) - .WillRepeatedly(Return(device_id_2_)); - policy_manager_->AddApplication(app_id_2_, - HmiTypes(policy_table::AHT_DEFAULT)); + EXPECT_CALL(listener_, GetDevicesIds(app_id_2_)) + .WillRepeatedly(Return(transport_manager::DeviceList(1, device_id_2_))); + policy_manager_->AddApplication( + device_id_2_, app_id_2_, HmiTypes(policy_table::AHT_DEFAULT)); GetPTU(kValidSdlPtUpdateJson); ::policy::PermissionConsent perm_consent; @@ -1284,7 +1382,8 @@ TEST_F(PolicyManagerImplTest2, policy_manager_->SetUserConsentForApp(perm_consent, policy::PolicyManager::kSilentMode); - policy_manager_->SendNotificationOnPermissionsUpdated(app_id_2_); + policy_manager_->SendNotificationOnPermissionsUpdated(device_id_2_, + app_id_2_); std::vector< ::policy::FunctionalGroupPermission> actual_groups_permissions; std::vector< ::policy::FunctionalGroupPermission>::iterator it; policy_manager_->GetPermissionsForApp( @@ -1330,20 +1429,22 @@ TEST_F(PolicyManagerImplTest2, SingleInvalidRequestTypeInPTU_ExpectReplaceWithDefaultValues) { // Arrange const std::string section_name = app_id_2_; + const transport_manager::DeviceHandle handle = 1; // Arrange CreateLocalPT(preloaded_pt_filename_); // Setting device consent to 'true' in order to have defult application // permissions, request type etc. - EXPECT_CALL(listener_, OnCurrentDeviceIdUpdateRequired(app_id_2_)) + EXPECT_CALL(listener_, OnCurrentDeviceIdUpdateRequired(handle, app_id_2_)) .WillRepeatedly(Return(device_id_1_)); policy_manager_->SetUserConsentForDevice(device_id_1_, true); - + EXPECT_CALL(listener_, GetDevicesIds(section_name)) + .WillRepeatedly(Return(transport_manager::DeviceList(1, device_id_1_))); // Add app - policy_manager_->AddApplication(section_name, - HmiTypes(policy_table::AHT_DEFAULT)); - EXPECT_CALL(listener_, OnPendingPermissionChange(section_name)); + policy_manager_->AddApplication( + device_id_1_, section_name, HmiTypes(policy_table::AHT_DEFAULT)); + EXPECT_CALL(listener_, OnPendingPermissionChange(device_id_1_, section_name)); // PTU has single invalid RequestTypes, which must be dropped and replaced // with default RT @@ -1351,18 +1452,18 @@ TEST_F(PolicyManagerImplTest2, // Get RequestTypes from section of app policies after PT update ::policy::StringArray app_request_types_after = - policy_manager_->GetAppRequestTypes(section_name); + policy_manager_->GetAppRequestTypes(handle, section_name); - EXPECT_CALL(listener_, OnCurrentDeviceIdUpdateRequired(kDefaultId)) + EXPECT_CALL(listener_, OnCurrentDeviceIdUpdateRequired(handle, kDefaultId)) .WillOnce(Return(device_id_1_)); ::policy::StringArray default_request_types_after = - policy_manager_->GetAppRequestTypes(kDefaultId); + policy_manager_->GetAppRequestTypes(handle, kDefaultId); // Check sizes of Request types of PT and PTU EXPECT_EQ(4u, app_request_types_after.size()); ::policy::AppPermissions permissions = - policy_manager_->GetAppPermissionsChanges(section_name); + policy_manager_->GetAppPermissionsChanges(device_id_1_, section_name); EXPECT_TRUE(permissions.requestTypeChanged); policy_table::RequestType temp_res1; @@ -1713,6 +1814,6 @@ TEST_F( CompareRequestTypesContainers(correct_types, received_types); } -} // namespace policy +} // namespace policy_test } // namespace components } // namespace test diff --git a/src/components/policy/policy_external/test/policy_manager_impl_snapshot_test.cc b/src/components/policy/policy_external/test/policy_manager_impl_snapshot_test.cc index c1ff31f748f..ddb5474df3e 100644 --- a/src/components/policy/policy_external/test/policy_manager_impl_snapshot_test.cc +++ b/src/components/policy/policy_external/test/policy_manager_impl_snapshot_test.cc @@ -63,9 +63,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_; } @@ -260,25 +259,30 @@ TEST_F( PolicyManagerImplTest2, AddValidRequestTypeToPT_GetNewAppWithSpecificPoliciesViaPTU_ExpectRTAdded) { const std::string& app_id = application_id_; + const transport_manager::DeviceHandle handle = 1; // Arrange CreateLocalPT(preloaded_pt_filename_); + EXPECT_CALL(listener_, GetDevicesIds(app_id)) + .WillRepeatedly(Return(transport_manager::DeviceList(1, device_id_1_))); // Add app - policy_manager_->AddApplication(app_id, HmiTypes(policy_table::AHT_DEFAULT)); + policy_manager_->AddApplication( + device_id_1_, app_id, HmiTypes(policy_table::AHT_DEFAULT)); // Check app gets RequestTypes from pre_DataConsent of app_policies // section - pt_request_types_ = policy_manager_->GetAppRequestTypes(app_id); + pt_request_types_ = policy_manager_->GetAppRequestTypes(handle, app_id); // Only single item as in pre_DataConsent in preloaded PT EXPECT_EQ(1u, pt_request_types_.size()); - EXPECT_CALL(listener_, OnPendingPermissionChange(app_id)).Times(1); + EXPECT_CALL(listener_, OnPendingPermissionChange(device_id_1_, app_id)) + .Times(1); // PTU has RequestTypes as [] - means 'all allowed' Json::Value root = GetPTU("json/PTU2.json"); // Setting device consent to 'true' in order to have appropriate application // permissions, request type etc. - EXPECT_CALL(listener_, OnCurrentDeviceIdUpdateRequired(application_id_)) + EXPECT_CALL(listener_, OnCurrentDeviceIdUpdateRequired(handle, app_id)) .WillRepeatedly(Return(device_id_1_)); policy_manager_->SetUserConsentForDevice(device_id_1_, true); @@ -289,13 +293,13 @@ TEST_F( pt_request_types_.clear(); // Get RequestTypes from section of app policies after PT update - pt_request_types_ = policy_manager_->GetAppRequestTypes(app_id); + pt_request_types_ = policy_manager_->GetAppRequestTypes(handle, app_id); // Check sizes of Request types of PT and PTU ASSERT_EQ(ptu_request_types_size_, pt_request_types_.size()); ::policy::AppPermissions permissions = - policy_manager_->GetAppPermissionsChanges(app_id); + policy_manager_->GetAppPermissionsChanges(device_id_1_, app_id); EXPECT_TRUE(permissions.requestTypeChanged); ::policy::StringArray result; @@ -333,6 +337,6 @@ TEST_F(PolicyManagerImplTest2, AddDevice_RegisterDevice_TRUE) { EXPECT_TRUE(result); } -} // namespace policy +} // namespace policy_test } // namespace components } // namespace test diff --git a/src/components/policy/policy_external/test/policy_manager_impl_stress_test.cc b/src/components/policy/policy_external/test/policy_manager_impl_stress_test.cc index 2f1cc5a9d39..f886108463a 100644 --- a/src/components/policy/policy_external/test/policy_manager_impl_stress_test.cc +++ b/src/components/policy/policy_external/test/policy_manager_impl_stress_test.cc @@ -29,15 +29,15 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include "gtest/gtest.h" #include +#include "gtest/gtest.h" #include "mock_policy_listener.h" #include "policy/policy_manager_impl.h" -using ::testing::_; -using ::policy::PolicyManagerImpl; using ::policy::BinaryMessage; using ::policy::MockPolicyListener; +using ::policy::PolicyManagerImpl; +using ::testing::_; namespace test { namespace components { diff --git a/src/components/policy/policy_external/test/policy_manager_impl_test.cc b/src/components/policy/policy_external/test/policy_manager_impl_test.cc index 1916e09efc8..809c0b55990 100644 --- a/src/components/policy/policy_external/test/policy_manager_impl_test.cc +++ b/src/components/policy/policy_external/test/policy_manager_impl_test.cc @@ -32,45 +32,22 @@ #include -#include "json/reader.h" -#include "gtest/gtest.h" #include +#include "gtest/gtest.h" +#include "json/reader.h" #include "policy/policy_manager_impl_test_base.h" +#include "utils/date_time.h" using ::testing::_; +using ::testing::AtLeast; using ::testing::Return; using ::testing::SetArgReferee; -using ::testing::AtLeast; namespace test { namespace components { namespace policy_test { -TEST_F( - PolicyManagerImplTest, - RefreshRetrySequence_SetSecondsBetweenRetries_ExpectRetryTimeoutSequenceWithSameSeconds) { - // Arrange - std::vector seconds; - seconds.push_back(50); - seconds.push_back(100); - seconds.push_back(200); - - // Assert - EXPECT_CALL(*cache_manager_, TimeoutResponse()).WillOnce(Return(60)); - EXPECT_CALL(*cache_manager_, SecondsBetweenRetries(_)) - .WillOnce(DoAll(SetArgReferee<0>(seconds), Return(true))); - - // Act - policy_manager_->RefreshRetrySequence(); - - // Assert - EXPECT_EQ(50, policy_manager_->NextRetryTimeout()); - EXPECT_EQ(100, policy_manager_->NextRetryTimeout()); - EXPECT_EQ(200, policy_manager_->NextRetryTimeout()); - EXPECT_EQ(0, policy_manager_->NextRetryTimeout()); -} - TEST_F(PolicyManagerImplTest, GetNotificationsNumber) { std::string priority = "EMERGENCY"; uint32_t notif_number = 100; @@ -130,7 +107,7 @@ TEST_F(PolicyManagerImplTest, LoadPT_SetPT_PTIsLoaded) { EXPECT_CALL(*cache_manager_, DaysBeforeExchange(_)) .WillOnce(Return(kNonZero)); policy_manager_->ForcePTExchange(); - policy_manager_->SetSendOnUpdateFlags(true, false); + policy_manager_->SetSendOnUpdateFlags(true); policy_manager_->OnUpdateStarted(); Json::Value table = createPTforLoad(); @@ -148,19 +125,26 @@ TEST_F(PolicyManagerImplTest, LoadPT_SetPT_PTIsLoaded) { std::shared_ptr snapshot = std::make_shared(update.policy_table); + ON_CALL(*cache_manager_, GenerateSnapshot()).WillByDefault(Return(snapshot)); + // Assert - EXPECT_CALL(*cache_manager_, GenerateSnapshot()).WillOnce(Return(snapshot)); EXPECT_CALL(*cache_manager_, ApplyUpdate(_)).WillOnce(Return(true)); - EXPECT_CALL(listener_, GetAppName("1234")) - .WillOnce(Return(custom_str::CustomString(""))); - EXPECT_CALL(listener_, OnUpdateStatusChanged(_)); + EXPECT_CALL(listener_, GetDevicesIds("1234")) + .WillRepeatedly(Return(transport_manager::DeviceList())); EXPECT_CALL(*cache_manager_, SaveUpdateRequired(false)); - EXPECT_CALL(*cache_manager_, TimeoutResponse()); - EXPECT_CALL(*cache_manager_, SecondsBetweenRetries(_)); - EXPECT_TRUE(policy_manager_->LoadPT(kFilePtUpdateJson, msg)); + EXPECT_CALL(*cache_manager_, GetVehicleDataItems()) + .WillOnce(Return(std::vector())); + ASSERT_EQ(PolicyManager::PtProcessingResult::kSuccess, + policy_manager_->LoadPT(kFilePtUpdateJson, msg)); + EXPECT_CALL(*cache_manager_, IsPTPreloaded()); EXPECT_FALSE(policy_manager_->GetCache()->IsPTPreloaded()); + + EXPECT_CALL(*cache_manager_, TimeoutResponse()); + EXPECT_CALL(*cache_manager_, SecondsBetweenRetries(_)); + EXPECT_CALL(listener_, OnUpdateStatusChanged(_)); + policy_manager_->OnPTUFinished(PolicyManager::PtProcessingResult::kSuccess); } TEST_F(PolicyManagerImplTest2, @@ -199,31 +183,14 @@ TEST_F(PolicyManagerImplTest2, OnSystemReady) { TEST_F(PolicyManagerImplTest2, ResetRetrySequence) { // Arrange CreateLocalPT(preloaded_pt_filename_); - policy_manager_->ResetRetrySequence(); + policy_manager_->ResetRetrySequence( + policy::ResetRetryCountType::kResetWithStatusUpdate); EXPECT_EQ("UPDATE_NEEDED", policy_manager_->GetPolicyTableStatus()); - policy_manager_->SetSendOnUpdateFlags(false, false); + policy_manager_->SetSendOnUpdateFlags(false); policy_manager_->OnUpdateStarted(); EXPECT_EQ("UPDATING", policy_manager_->GetPolicyTableStatus()); } -TEST_F(PolicyManagerImplTest2, NextRetryTimeout_ExpectTimeoutsFromPT) { - // Arrange - std::ifstream ifile(preloaded_pt_filename_); - Json::Reader reader; - Json::Value root(Json::objectValue); - if (ifile.is_open() && reader.parse(ifile, root, true)) { - Json::Value seconds_between_retries = Json::Value(Json::arrayValue); - seconds_between_retries = - root["policy_table"]["module_config"]["seconds_between_retries"]; - uint32_t size = seconds_between_retries.size(); - CreateLocalPT(preloaded_pt_filename_); - for (uint32_t i = 0; i < size; ++i) { - EXPECT_EQ(seconds_between_retries[i], - policy_manager_->NextRetryTimeout()); - } - } -} - TEST_F(PolicyManagerImplTest2, TimeOutExchange) { // Arrange CreateLocalPT(preloaded_pt_filename_); @@ -319,6 +286,8 @@ TEST_F(PolicyManagerImplTest2, OnExceededTimeout_GetPolicyTableStatus_ExpectUpdateNeeded) { // Arrange CreateLocalPT(preloaded_pt_filename_); + ON_CALL(ptu_retry_handler_, IsAllowedRetryCountExceeded()) + .WillByDefault(Return(false)); policy_manager_->ForcePTExchange(); policy_manager_->OnExceededTimeout(); // Check @@ -341,8 +310,10 @@ TEST_F(PolicyManagerImplTest, MarkUnpairedDevice) { TEST_F(PolicyManagerImplTest2, GetCurrentDeviceId) { // Arrange - EXPECT_CALL(listener_, OnCurrentDeviceIdUpdateRequired(app_id_2_)).Times(1); - EXPECT_EQ("", policy_manager_->GetCurrentDeviceId(app_id_2_)); + const transport_manager::DeviceHandle handle = 1; + EXPECT_CALL(listener_, OnCurrentDeviceIdUpdateRequired(handle, app_id_2_)) + .Times(1); + EXPECT_EQ("", policy_manager_->GetCurrentDeviceId(handle, app_id_2_)); } TEST_F(PolicyManagerImplTest2, UpdateApplication_AppServices) { @@ -424,7 +395,7 @@ TEST_F( status.insert(ExternalConsentStatusItem(type_2_, id_2_, kStatusOn)); status.insert(ExternalConsentStatusItem(type_3_, id_3_, kStatusOn)); - EXPECT_CALL(listener_, OnPermissionsUpdated(app_id_1_, _)); + EXPECT_CALL(listener_, OnPermissionsUpdated(device_id_1_, app_id_1_, _)); EXPECT_TRUE(policy_manager_->SetExternalConsentStatus(status)); @@ -473,7 +444,7 @@ TEST_F( status.insert(ExternalConsentStatusItem(type_2_, id_2_, kStatusOn)); status.insert(ExternalConsentStatusItem(type_3_, id_3_, kStatusOn)); - EXPECT_CALL(listener_, OnPermissionsUpdated(app_id_1_, _)); + EXPECT_CALL(listener_, OnPermissionsUpdated(device_id_1_, app_id_1_, _)); EXPECT_TRUE(policy_manager_->SetExternalConsentStatus(status)); @@ -529,12 +500,12 @@ TEST_F( EXPECT_FALSE(pt->policy_table.device_data->end() != updated_device_data); - EXPECT_CALL(listener_, OnPermissionsUpdated(app_id_1_, _)); - EXPECT_CALL(listener_, OnCurrentDeviceIdUpdateRequired(app_id_1_)) + EXPECT_CALL(listener_, OnPermissionsUpdated(device_id_1_, app_id_1_, _)); + EXPECT_CALL(listener_, OnCurrentDeviceIdUpdateRequired(_, app_id_1_)) .WillRepeatedly(Return(device_id_1_)); - policy_manager_->AddApplication(app_id_1_, - HmiTypes(policy_table::AHT_DEFAULT)); + policy_manager_->AddApplication( + device_id_1_, app_id_1_, HmiTypes(policy_table::AHT_DEFAULT)); // Check ExternalConsent consents for application updated_device_data = pt->policy_table.device_data->find(device_id_1_); @@ -597,12 +568,12 @@ TEST_F( EXPECT_FALSE(pt->policy_table.device_data->end() != updated_device_data); - EXPECT_CALL(listener_, OnPermissionsUpdated(app_id_1_, _)); - EXPECT_CALL(listener_, OnCurrentDeviceIdUpdateRequired(app_id_1_)) + EXPECT_CALL(listener_, OnPermissionsUpdated(device_id_1_, app_id_1_, _)); + EXPECT_CALL(listener_, OnCurrentDeviceIdUpdateRequired(_, app_id_1_)) .WillRepeatedly(Return(device_id_1_)); - policy_manager_->AddApplication(app_id_1_, - HmiTypes(policy_table::AHT_DEFAULT)); + policy_manager_->AddApplication( + device_id_1_, app_id_1_, HmiTypes(policy_table::AHT_DEFAULT)); // Checking ExternalConsent consents after setting new ExternalConsent status ApplicationPolicies::const_iterator app_parameters = @@ -652,15 +623,12 @@ TEST_F( EXPECT_TRUE(policy_manager_->GetCache()->ApplyUpdate(t)); - EXPECT_CALL(listener_, OnPermissionsUpdated(app_id_1_, _)); - EXPECT_CALL(listener_, OnCurrentDeviceIdUpdateRequired(app_id_1_)) - .WillOnce(Return(device_id_1_)) // registered - .WillOnce(Return("")) // not registered - .WillRepeatedly(Return(device_id_1_)); // again registered - + EXPECT_CALL(listener_, OnPermissionsUpdated(device_id_1_, app_id_1_, _)); + EXPECT_CALL(listener_, GetDevicesIds(app_id_1_)) + .WillRepeatedly(Return(transport_manager::DeviceList())); // First register w/o app having groups to consent - policy_manager_->AddApplication(app_id_1_, - HmiTypes(policy_table::AHT_DEFAULT)); + policy_manager_->AddApplication( + device_id_1_, app_id_1_, HmiTypes(policy_table::AHT_DEFAULT)); // Act std::shared_ptr pt = @@ -691,8 +659,8 @@ TEST_F( EXPECT_TRUE(policy_manager_->GetCache()->ApplyUpdate(t)); // Second time register w/ app having groups to consent - policy_manager_->AddApplication(app_id_1_, - HmiTypes(policy_table::AHT_DEFAULT)); + policy_manager_->AddApplication( + device_id_1_, app_id_1_, HmiTypes(policy_table::AHT_DEFAULT)); // Checking ExternalConsent consents after setting new ExternalConsent status ApplicationPolicies::const_iterator app_parameters = @@ -742,15 +710,11 @@ TEST_F( EXPECT_TRUE(policy_manager_->GetCache()->ApplyUpdate(t)); - EXPECT_CALL(listener_, OnPermissionsUpdated(app_id_1_, _)); - EXPECT_CALL(listener_, OnCurrentDeviceIdUpdateRequired(app_id_1_)) - .WillOnce(Return(device_id_1_)) // registered - .WillOnce(Return("")) // not registered - .WillRepeatedly(Return(device_id_1_)); // registered again + EXPECT_CALL(listener_, OnPermissionsUpdated(device_id_1_, app_id_1_, _)); // First register w/o app having groups to consent - policy_manager_->AddApplication(app_id_1_, - HmiTypes(policy_table::AHT_DEFAULT)); + policy_manager_->AddApplication( + device_id_1_, app_id_1_, HmiTypes(policy_table::AHT_DEFAULT)); // Act std::shared_ptr pt = @@ -781,8 +745,8 @@ TEST_F( EXPECT_TRUE(policy_manager_->GetCache()->ApplyUpdate(t)); // Second time register w/ app having groups to consent - policy_manager_->AddApplication(app_id_1_, - HmiTypes(policy_table::AHT_DEFAULT)); + policy_manager_->AddApplication( + device_id_1_, app_id_1_, HmiTypes(policy_table::AHT_DEFAULT)); // Check ExternalConsent consents for application updated_device_data = pt->policy_table.device_data->find(device_id_1_); @@ -840,12 +804,11 @@ TEST_F(PolicyManagerImplTest_ExternalConsent, EXPECT_TRUE(policy_manager_->SetExternalConsentStatus(status)); - EXPECT_CALL(listener_, OnPermissionsUpdated(app_id_1_, _)); - EXPECT_CALL(listener_, OnCurrentDeviceIdUpdateRequired(app_id_1_)) - .WillRepeatedly(Return(device_id_1_)); - - policy_manager_->AddApplication(app_id_1_, - HmiTypes(policy_table::AHT_DEFAULT)); + EXPECT_CALL(listener_, OnPermissionsUpdated(device_id_1_, app_id_1_, _)); + EXPECT_CALL(listener_, GetDevicesIds(app_id_1_)) + .WillRepeatedly(Return(transport_manager::DeviceList())); + policy_manager_->AddApplication( + device_id_1_, app_id_1_, HmiTypes(policy_table::AHT_DEFAULT)); std::shared_ptr pt = policy_manager_->GetCache()->GetPT(); @@ -904,7 +867,9 @@ TEST_F(PolicyManagerImplTest_ExternalConsent, EXPECT_CALL(listener_, OnCertificateUpdated(_)); - EXPECT_TRUE(policy_manager_->LoadPT("DummyFileName", msg)); + ASSERT_EQ(PolicyManager::PtProcessingResult::kSuccess, + policy_manager_->LoadPT("DummyFileName", msg)); + policy_manager_->OnPTUFinished(PolicyManager::PtProcessingResult::kSuccess); pt = policy_manager_->GetCache()->GetPT(); @@ -965,12 +930,11 @@ TEST_F(PolicyManagerImplTest_ExternalConsent, EXPECT_TRUE(policy_manager_->SetExternalConsentStatus(status)); - EXPECT_CALL(listener_, OnPermissionsUpdated(app_id_1_, _)); - EXPECT_CALL(listener_, OnCurrentDeviceIdUpdateRequired(app_id_1_)) - .WillRepeatedly(Return(device_id_1_)); - - policy_manager_->AddApplication(app_id_1_, - HmiTypes(policy_table::AHT_DEFAULT)); + EXPECT_CALL(listener_, OnPermissionsUpdated(device_id_1_, app_id_1_, _)); + EXPECT_CALL(listener_, GetDevicesIds(app_id_1_)) + .WillRepeatedly(Return(transport_manager::DeviceList())); + policy_manager_->AddApplication( + device_id_1_, app_id_1_, HmiTypes(policy_table::AHT_DEFAULT)); std::shared_ptr pt = policy_manager_->GetCache()->GetPT(); @@ -1024,7 +988,9 @@ TEST_F(PolicyManagerImplTest_ExternalConsent, EXPECT_CALL(listener_, OnCertificateUpdated(_)); - EXPECT_TRUE(policy_manager_->LoadPT("DummyFileName", msg)); + ASSERT_EQ(PolicyManager::PtProcessingResult::kSuccess, + policy_manager_->LoadPT("DummyFileName", msg)); + policy_manager_->OnPTUFinished(PolicyManager::PtProcessingResult::kSuccess); pt = policy_manager_->GetCache()->GetPT(); @@ -1099,7 +1065,7 @@ TEST_F( status_on.insert(ExternalConsentStatusItem(type_2_, id_2_, kStatusOn)); status_on.insert(ExternalConsentStatusItem(type_3_, id_3_, kStatusOn)); - EXPECT_CALL(listener_, OnPermissionsUpdated(app_id_1_, _)); + EXPECT_CALL(listener_, OnPermissionsUpdated(device_id_1_, app_id_1_, _)); EXPECT_TRUE(policy_manager_->SetExternalConsentStatus(status_on)); @@ -1135,7 +1101,8 @@ TEST_F( status_off.insert(ExternalConsentStatusItem(type_2_, id_2_, kStatusOff)); status_off.insert(ExternalConsentStatusItem(type_3_, id_3_, kStatusOff)); - EXPECT_CALL(listener_, OnPermissionsUpdated(app_id_1_, _)).Times(1); + EXPECT_CALL(listener_, OnPermissionsUpdated(device_id_1_, app_id_1_, _)) + .Times(1); EXPECT_TRUE(policy_manager_->SetExternalConsentStatus(status_off)); @@ -1151,6 +1118,6 @@ TEST_F( EXPECT_EQ(Boolean(false), updated_group_2->second); } -} // namespace policy +} // namespace policy_test } // namespace components } // namespace test diff --git a/src/components/policy/policy_external/test/policy_manager_impl_test_base.cc b/src/components/policy/policy_external/test/policy_manager_impl_test_base.cc index 13efa39805c..b3c85df65b0 100644 --- a/src/components/policy/policy_external/test/policy_manager_impl_test_base.cc +++ b/src/components/policy/policy_external/test/policy_manager_impl_test_base.cc @@ -30,17 +30,17 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include -#include #include +#include +#include #include #include "policy/policy_manager_impl_test_base.h" #include "utils/file_system.h" -#include "utils/gen_hash.h" #include "json/reader.h" +#include "utils/gen_hash.h" #include "policy/mock_pt_ext_representation.h" @@ -48,10 +48,10 @@ namespace test { namespace components { namespace policy_test { +using ::testing::_; +using ::testing::ContainerEq; using ::testing::Return; using ::testing::ReturnRef; -using ::testing::ContainerEq; -using ::testing::_; // Help functions char GenRandomChar(char range_from, char range_to) { @@ -207,7 +207,7 @@ PolicyManagerImplTest::PolicyManagerImplTest() void PolicyManagerImplTest::SetUp() { policy_manager_ = new PolicyManagerImpl(); - cache_manager_ = new MockCacheManagerInterface(); + cache_manager_ = new NiceMock(); policy_manager_->set_cache_manager(cache_manager_); policy_manager_->set_listener(&listener_); @@ -218,6 +218,8 @@ void PolicyManagerImplTest::SetUp() { ON_CALL(*cache_manager_, GetKnownLinksFromPT()) .WillByDefault(Return(std::map())); ON_CALL(listener_, GetRegisteredLinks(_)).WillByDefault(Return()); + ON_CALL(listener_, ptu_retry_handler()) + .WillByDefault(ReturnRef(ptu_retry_handler_)); } void PolicyManagerImplTest::TearDown() { @@ -253,6 +255,8 @@ PolicyManagerImplTest2::PolicyManagerImplTest2() void PolicyManagerImplTest2::SetUp() { ON_CALL(listener_, GetRegisteredLinks(_)).WillByDefault(Return()); + ON_CALL(listener_, ptu_retry_handler()) + .WillByDefault(ReturnRef(ptu_retry_handler_)); file_system::CreateDirectory(app_storage_folder_); @@ -260,7 +264,7 @@ void PolicyManagerImplTest2::SetUp() { ON_CALL(policy_settings_, app_storage_folder()) .WillByDefault(ReturnRef(app_storage_folder_)); policy_manager_->set_listener(&listener_); - const char* levels[] = {"BACKGROUND", "FULL", "LIMITED", "NONE"}; + const char* levels[] = {"FULL", "LIMITED", "BACKGROUND", "NONE"}; hmi_level_.assign(levels, levels + sizeof(levels) / sizeof(levels[0])); srand(time(NULL)); index_ = rand() % 3; @@ -287,7 +291,9 @@ const Json::Value PolicyManagerImplTest2::GetPTU(const std::string& file_name) { ifile.close(); ::policy::BinaryMessage msg(json.begin(), json.end()); // Load Json to cache - EXPECT_TRUE(policy_manager_->LoadPT(kFilePtUpdateJson, msg)); + EXPECT_EQ(PolicyManager::PtProcessingResult::kSuccess, + policy_manager_->LoadPT(kFilePtUpdateJson, msg)); + policy_manager_->OnPTUFinished(PolicyManager::PtProcessingResult::kSuccess); EXPECT_FALSE(policy_manager_->GetCache()->IsPTPreloaded()); return root; } @@ -307,7 +313,10 @@ void PolicyManagerImplTest2::AddRTtoPT(const std::string& update_file_name, // Arrange CreateLocalPT(preloaded_pt_filename_); // Get RequestTypes from section of preloaded_pt app_policies - pt_request_types_ = policy_manager_->GetAppRequestTypes(section_name); + const transport_manager::DeviceHandle handle = 1; + EXPECT_CALL(listener_, OnCurrentDeviceIdUpdateRequired(handle, section_name)) + .WillRepeatedly(Return(device_id_1_)); + pt_request_types_ = policy_manager_->GetAppRequestTypes(handle, section_name); EXPECT_EQ(rt_number, pt_request_types_.size()); Json::Value root = GetPTU(update_file_name); // Get Request Types from JSON (PTU) @@ -316,7 +325,7 @@ void PolicyManagerImplTest2::AddRTtoPT(const std::string& update_file_name, ptu_request_types_size_ = ptu_request_types_.size(); pt_request_types_.clear(); // Get RequestTypes from section of PT app policies after update - pt_request_types_ = policy_manager_->GetAppRequestTypes(section_name); + pt_request_types_ = policy_manager_->GetAppRequestTypes(handle, section_name); // Check number of RT in PTU and PT now are equal ASSERT_EQ(ptu_request_types_size_ - invalid_rt_number, pt_request_types_.size()); @@ -329,14 +338,17 @@ void PolicyManagerImplTest2::AddRTtoAppSectionPT( const uint32_t invalid_rt_number) { // Arrange CreateLocalPT(preloaded_pt_filename_); + const transport_manager::DeviceHandle handle = 1; + EXPECT_CALL(listener_, OnCurrentDeviceIdUpdateRequired(handle, section_name)) + .WillRepeatedly(Return(device_id_1_)); // Add app - policy_manager_->AddApplication(section_name, - HmiTypes(policy_table::AHT_DEFAULT)); + policy_manager_->AddApplication( + device_id_1_, section_name, HmiTypes(policy_table::AHT_DEFAULT)); // Check app gets RequestTypes from pre_DataConsent of app_policies // section - pt_request_types_ = policy_manager_->GetAppRequestTypes(section_name); + pt_request_types_ = policy_manager_->GetAppRequestTypes(handle, section_name); EXPECT_EQ(rt_number, pt_request_types_.size()); - EXPECT_CALL(listener_, OnPendingPermissionChange(section_name)).Times(1); + EXPECT_CALL(listener_, OnPendingPermissionChange(_, section_name)).Times(1); Json::Value root = GetPTU(update_file_name); // Get App Request Types from PTU @@ -346,13 +358,13 @@ void PolicyManagerImplTest2::AddRTtoAppSectionPT( pt_request_types_.clear(); // Get RequestTypes from section of app policies after PT update - pt_request_types_ = policy_manager_->GetAppRequestTypes(section_name); + pt_request_types_ = policy_manager_->GetAppRequestTypes(handle, section_name); // Check sizes of Request types of PT and PTU ASSERT_EQ(ptu_request_types_size_ - invalid_rt_number, pt_request_types_.size()); ::policy::AppPermissions permissions = - policy_manager_->GetAppPermissionsChanges(section_name); + policy_manager_->GetAppPermissionsChanges(device_id_1_, section_name); EXPECT_TRUE(permissions.requestTypeChanged); } @@ -449,9 +461,13 @@ void PolicyManagerImplTest2:: 2, "Bluetooth")); + EXPECT_CALL(listener_, GetDevicesIds(application_id_)) + .WillRepeatedly(Return(transport_manager::DeviceList())); + // Add app from consented device. App will be assigned with default policies - policy_manager_->AddApplication(application_id_, - HmiTypes(policy_table::AHT_DEFAULT)); + policy_manager_->SetUserConsentForDevice(device_id_1_, true); + policy_manager_->AddApplication( + device_id_1_, application_id_, HmiTypes(policy_table::AHT_DEFAULT)); // Expect all parameters are allowed std::ifstream ifile(update_file); @@ -464,13 +480,11 @@ void PolicyManagerImplTest2:: json = root.toStyledString(); ifile.close(); ::policy::BinaryMessage msg(json.begin(), json.end()); - EXPECT_TRUE(policy_manager_->LoadPT(kFilePtUpdateJson, msg)); - EXPECT_FALSE(cache->IsPTPreloaded()); + ASSERT_EQ(PolicyManager::PtProcessingResult::kSuccess, + policy_manager_->LoadPT(kFilePtUpdateJson, msg)); + policy_manager_->OnPTUFinished(PolicyManager::PtProcessingResult::kSuccess); - // Will be called each time permissions are checked - EXPECT_CALL(listener_, OnCurrentDeviceIdUpdateRequired(application_id_)) - .Times(4) - .WillRepeatedly(Return(device_id_1_)); + EXPECT_FALSE(cache->IsPTPreloaded()); // Check RPC in each level ::policy::RPCParams input_params; @@ -478,8 +492,12 @@ void PolicyManagerImplTest2:: ::policy::CheckPermissionResult output; // Rpc in FULL level - policy_manager_->CheckPermissions( - application_id_, kHmiLevelFull, "SendLocation", input_params, output); + policy_manager_->CheckPermissions(device_id_1_, + application_id_, + kHmiLevelFull, + "SendLocation", + input_params, + output); // Check RPC is allowed EXPECT_EQ(::policy::kRpcAllowed, output.hmi_level_permitted); // Check list of allowed parameters is not empty @@ -489,8 +507,12 @@ void PolicyManagerImplTest2:: ResetOutputList(output); // Rpc in LIMITED level - policy_manager_->CheckPermissions( - application_id_, kHmiLevelLimited, "SendLocation", input_params, output); + policy_manager_->CheckPermissions(device_id_1_, + application_id_, + kHmiLevelLimited, + "SendLocation", + input_params, + output); // Check RPC is allowed EXPECT_EQ(::policy::kRpcAllowed, output.hmi_level_permitted); // Check list of allowed parameters is not empty @@ -500,7 +522,8 @@ void PolicyManagerImplTest2:: ResetOutputList(output); // Rpc in BACKGROUND level - policy_manager_->CheckPermissions(application_id_, + policy_manager_->CheckPermissions(device_id_1_, + application_id_, kHmiLevelBackground, "SendLocation", input_params, @@ -515,8 +538,12 @@ void PolicyManagerImplTest2:: ResetOutputList(output); // Rpc in NONE level - policy_manager_->CheckPermissions( - application_id_, kHmiLevelNone, "SendLocation", input_params, output); + policy_manager_->CheckPermissions(device_id_1_, + application_id_, + kHmiLevelNone, + "SendLocation", + input_params, + output); // Check RPC is disallowed EXPECT_EQ(::policy::kRpcDisallowed, output.hmi_level_permitted); // Check lists of parameters are empty @@ -529,8 +556,12 @@ void PolicyManagerImplTest2::CheckRpcPermissions( const std::string& rpc_name, const PermitResult& expected_permission) { ::policy::RPCParams input_params; ::policy::CheckPermissionResult output; - policy_manager_->CheckPermissions( - application_id_, kHmiLevelFull, rpc_name, input_params, output); + policy_manager_->CheckPermissions(device_id_1_, + application_id_, + kHmiLevelFull, + rpc_name, + input_params, + output); EXPECT_EQ(expected_permission, output.hmi_level_permitted); } @@ -541,7 +572,7 @@ void PolicyManagerImplTest2::CheckRpcPermissions( ::policy::RPCParams input_params; ::policy::CheckPermissionResult output; policy_manager_->CheckPermissions( - app_id, kHmiLevelFull, rpc_name, input_params, output); + device_id_1_, app_id, kHmiLevelFull, rpc_name, input_params, output); EXPECT_EQ(out_expected_permission, output.hmi_level_permitted); } @@ -558,7 +589,9 @@ void PolicyManagerImplTest2::EmulatePTAppRevoked(const std::string& ptu_name) { ifile.close(); ::policy::BinaryMessage msg(json.begin(), json.end()); - ASSERT_TRUE(policy_manager_->LoadPT(kDummyUpdateFileName, msg)); + ASSERT_EQ(PolicyManager::PtProcessingResult::kSuccess, + policy_manager_->LoadPT(kDummyUpdateFileName, msg)); + policy_manager_->OnPTUFinished(PolicyManager::PtProcessingResult::kSuccess); } // To avoid duplicate arrange of test @@ -576,8 +609,9 @@ void PolicyManagerImplTest2::AddSetDeviceData() { "Bluetooth")); // Add app from consented device. App will be assigned with default policies - policy_manager_->AddApplication(application_id_, - HmiTypes(policy_table::AHT_DEFAULT)); + policy_manager_->SetUserConsentForDevice(device_id_1_, true); + policy_manager_->AddApplication( + device_id_1_, application_id_, HmiTypes(policy_table::AHT_DEFAULT)); (policy_manager_->GetCache())->AddDevice(device_id_1_, "Bluetooth"); } @@ -595,7 +629,10 @@ void PolicyManagerImplTest2::LoadPTUFromJsonFile( json = root.toStyledString(); ifile.close(); ::policy::BinaryMessage msg(json.begin(), json.end()); - EXPECT_TRUE(policy_manager_->LoadPT(kFilePtUpdateJson, msg)); + ASSERT_EQ(PolicyManager::PtProcessingResult::kSuccess, + policy_manager_->LoadPT(kFilePtUpdateJson, msg)); + policy_manager_->OnPTUFinished(PolicyManager::PtProcessingResult::kSuccess); + EXPECT_FALSE(policy_manager_->GetCache()->IsPTPreloaded()); } @@ -656,7 +693,11 @@ const Json::Value PolicyManagerImplTest_RequestTypes::GetPTU( ifile.close(); ::policy::BinaryMessage msg(json.begin(), json.end()); // Load Json to cache - EXPECT_TRUE(policy_manager_impl_sptr_->LoadPT(kFilePtUpdateJson, msg)); + EXPECT_EQ(PolicyManager::PtProcessingResult::kSuccess, + policy_manager_impl_sptr_->LoadPT(kFilePtUpdateJson, msg)); + policy_manager_impl_sptr_->OnPTUFinished( + PolicyManager::PtProcessingResult::kSuccess); + EXPECT_FALSE(policy_manager_impl_sptr_->GetCache()->IsPTPreloaded()); return root; } 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 93cfa362772..1db23260a81 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 @@ -34,6 +34,7 @@ #include "policy/policy_manager_impl_test_base.h" #include "utils/date_time.h" +#include "utils/macro.h" namespace test { namespace components { @@ -49,13 +50,15 @@ TEST_F( // Arrange CreateLocalPT(preloaded_pt_filename_); - EXPECT_CALL(listener_, OnCurrentDeviceIdUpdateRequired(app_id_1_)) + EXPECT_CALL(listener_, OnCurrentDeviceIdUpdateRequired(_, app_id_1_)) .WillRepeatedly(Return(device_id_1_)); + EXPECT_CALL(listener_, CanUpdate()).WillRepeatedly(Return(true)); + policy_manager_->SetUserConsentForDevice(device_id_1_, true); - policy_manager_->AddApplication(app_id_1_, - HmiTypes(policy_table::AHT_DEFAULT)); + policy_manager_->AddApplication( + device_id_1_, app_id_1_, HmiTypes(policy_table::AHT_DEFAULT)); EXPECT_EQ("UPDATE_NEEDED", policy_manager_->GetPolicyTableStatus()); } @@ -76,13 +79,14 @@ TEST_F( policy_manager_->PTUpdatedAt(DAYS_AFTER_EPOCH, days_after_epoch); policy_manager_->PTUpdatedAt(KILOMETERS, 1000); - EXPECT_CALL(listener_, OnCurrentDeviceIdUpdateRequired(app_id_1_)) + const transport_manager::DeviceHandle handle = 1; + EXPECT_CALL(listener_, OnCurrentDeviceIdUpdateRequired(handle, app_id_1_)) .WillRepeatedly(Return(device_id_1_)); policy_manager_->SetUserConsentForDevice(device_id_1_, false); - policy_manager_->AddApplication(app_id_1_, - HmiTypes(policy_table::AHT_DEFAULT)); + policy_manager_->AddApplication( + device_id_1_, app_id_1_, HmiTypes(policy_table::AHT_DEFAULT)); EXPECT_EQ("UP_TO_DATE", policy_manager_->GetPolicyTableStatus()); } @@ -92,10 +96,13 @@ TEST_F( ReactOnUserDevConsentForApp_AddNewApplicationFromDeviceWithoutConsent_ExpectPreDataConsent) { // Arrange CreateLocalPT(preloaded_pt_filename_); - policy_manager_->AddApplication(app_id_1_, - HmiTypes(policy_table::AHT_DEFAULT)); + const transport_manager::DeviceHandle handle = 1; + EXPECT_CALL(listener_, OnCurrentDeviceIdUpdateRequired(handle, app_id_1_)) + .WillRepeatedly(Return(device_id_1_)); + policy_manager_->AddApplication( + device_id_1_, app_id_1_, HmiTypes(policy_table::AHT_DEFAULT)); ASSERT_TRUE(policy_manager_->IsPredataPolicy(app_id_1_)); - policy_manager_->ReactOnUserDevConsentForApp(app_id_1_, false); + policy_manager_->ReactOnUserDevConsentForApp(handle, app_id_1_, false); EXPECT_TRUE(policy_manager_->IsPredataPolicy(app_id_1_)); } @@ -106,8 +113,8 @@ TEST_F(PolicyManagerImplTest2, CreateLocalPT(kSdlPreloadedPtJson2); ASSERT_TRUE( (policy_manager_->GetCache())->AddDevice(device_id_2_, "Bluetooth")); - policy_manager_->AddApplication(application_id_, - HmiTypes(policy_table::AHT_DEFAULT)); + policy_manager_->AddApplication( + device_id_2_, application_id_, HmiTypes(policy_table::AHT_DEFAULT)); // Expect RPCs from pre_dataConsent group are allowed // Next checks are equal to BaseBeforeDataConsent_APIs.xml checks from task @@ -155,11 +162,11 @@ TEST_F(PolicyManagerImplTest2, TEST_F(PolicyManagerImplTest2, CheckPreDataConsent_GetDefaultHmiLevel_NONE) { // Arrange CreateLocalPT(preloaded_pt_filename_); - policy_manager_->AddApplication(app_id_2_, - HmiTypes(policy_table::AHT_DEFAULT)); + policy_manager_->AddApplication( + device_id_1_, app_id_2_, HmiTypes(policy_table::AHT_DEFAULT)); std::string default_hmi; // Default HMI level is NONE - policy_manager_->GetDefaultHmi(app_id_2_, &default_hmi); + policy_manager_->GetDefaultHmi(device_id_1_, app_id_2_, &default_hmi); EXPECT_EQ("NONE", default_hmi); // Default priority level is NONE @@ -173,11 +180,11 @@ TEST_F(PolicyManagerImplTest2, CheckPreDataConsent_GetDefaultHmiLevel_BACKGROUNG) { // Arrange CreateLocalPT(kSdlPreloadedPtJson2); - policy_manager_->AddApplication(app_id_2_, - HmiTypes(policy_table::AHT_DEFAULT)); + policy_manager_->AddApplication( + device_id_1_, app_id_2_, HmiTypes(policy_table::AHT_DEFAULT)); std::string default_hmi; // Default HMI level is BACKGROUND - policy_manager_->GetDefaultHmi(app_id_2_, &default_hmi); + policy_manager_->GetDefaultHmi(device_id_1_, app_id_2_, &default_hmi); EXPECT_EQ("BACKGROUND", default_hmi); // Default priority level is EMERGENCY std::string priority1; @@ -191,10 +198,13 @@ TEST_F( // Arrange // RequestTypes for default & preDataConsent are different CreateLocalPT("json/ptu_requestType.json"); - policy_manager_->AddApplication(app_id_1_, - HmiTypes(policy_table::AHT_DEFAULT)); + const transport_manager::DeviceHandle handle = 1; + EXPECT_CALL(listener_, OnCurrentDeviceIdUpdateRequired(handle, app_id_1_)) + .WillRepeatedly(Return(device_id_1_)); + policy_manager_->AddApplication( + device_id_1_, app_id_1_, HmiTypes(policy_table::AHT_DEFAULT)); ASSERT_TRUE(policy_manager_->IsPredataPolicy(app_id_1_)); - policy_manager_->ReactOnUserDevConsentForApp(app_id_1_, true); + policy_manager_->ReactOnUserDevConsentForApp(handle, app_id_1_, true); EXPECT_FALSE(policy_manager_->IsPredataPolicy(app_id_1_)); // Expect app_id_1_ has default policy EXPECT_TRUE((policy_manager_->GetCache())->IsDefaultPolicy(app_id_1_)); @@ -206,11 +216,14 @@ TEST_F( // Arrange // RequestTypes for default & preDataConsent are the same CreateLocalPT(kPtu2RequestTypeJson); - policy_manager_->AddApplication(app_id_1_, - HmiTypes(policy_table::AHT_DEFAULT)); + const transport_manager::DeviceHandle handle = 1; + EXPECT_CALL(listener_, OnCurrentDeviceIdUpdateRequired(handle, app_id_1_)) + .WillRepeatedly(Return(device_id_1_)); + policy_manager_->AddApplication( + device_id_1_, app_id_1_, HmiTypes(policy_table::AHT_DEFAULT)); ASSERT_TRUE(policy_manager_->IsPredataPolicy(app_id_1_)); - EXPECT_CALL(listener_, OnPendingPermissionChange(app_id_1_)).Times(0); - policy_manager_->ReactOnUserDevConsentForApp(app_id_1_, true); + EXPECT_CALL(listener_, OnPendingPermissionChange(_, app_id_1_)).Times(0); + policy_manager_->ReactOnUserDevConsentForApp(handle, app_id_1_, true); EXPECT_FALSE(policy_manager_->IsPredataPolicy(app_id_1_)); EXPECT_TRUE((policy_manager_->GetCache())->IsDefaultPolicy(app_id_1_)); } @@ -297,12 +310,12 @@ TEST_F(PolicyManagerImplTest2, policy_manager_->GetUserConsentForDevice(device_id_2_); // Check EXPECT_EQ(::policy::DeviceConsent::kDeviceDisallowed, consent); - EXPECT_CALL(listener_, OnCurrentDeviceIdUpdateRequired(app_id_2_)) + EXPECT_CALL(listener_, OnCurrentDeviceIdUpdateRequired(_, app_id_2_)) .WillRepeatedly(Return(device_id_2_)); - policy_manager_->AddApplication(app_id_2_, - HmiTypes(policy_table::AHT_DEFAULT)); + policy_manager_->AddApplication( + device_id_2_, app_id_2_, HmiTypes(policy_table::AHT_DEFAULT)); std::string default_hmi; - policy_manager_->GetDefaultHmi(app_id_2_, &default_hmi); + policy_manager_->GetDefaultHmi(device_id_2_, app_id_2_, &default_hmi); EXPECT_EQ("NONE", default_hmi); } @@ -310,12 +323,12 @@ TEST_F(PolicyManagerImplTest2, GetDefaultHmi_SetDeviceAllowed_ExpectReceivedHmiCorrect) { // Arrange CreateLocalPT(kPtu2RequestTypeJson); - policy_manager_->AddApplication(app_id_2_, - HmiTypes(policy_table::AHT_DEFAULT)); + policy_manager_->AddApplication( + device_id_1_, app_id_2_, HmiTypes(policy_table::AHT_DEFAULT)); // Check if app has preData policy EXPECT_TRUE(policy_manager_->IsPredataPolicy(app_id_2_)); std::string default_hmi1; - policy_manager_->GetDefaultHmi(app_id_2_, &default_hmi1); + policy_manager_->GetDefaultHmi(device_id_1_, app_id_2_, &default_hmi1); EXPECT_EQ("NONE", default_hmi1); ASSERT_TRUE( (policy_manager_->GetCache())->AddDevice(device_id_2_, "Bluetooth")); @@ -333,13 +346,13 @@ TEST_F(PolicyManagerImplTest2, policy_manager_->GetUserConsentForDevice(device_id_2_); // Check EXPECT_EQ(::policy::DeviceConsent::kDeviceAllowed, consent); - EXPECT_CALL(listener_, OnCurrentDeviceIdUpdateRequired(app_id_2_)) + EXPECT_CALL(listener_, OnCurrentDeviceIdUpdateRequired(_, app_id_2_)) .WillRepeatedly(Return(device_id_2_)); - policy_manager_->AddApplication(app_id_2_, - HmiTypes(policy_table::AHT_DEFAULT)); + policy_manager_->AddApplication( + device_id_2_, app_id_2_, HmiTypes(policy_table::AHT_DEFAULT)); EXPECT_TRUE((policy_manager_->GetCache())->IsDefaultPolicy(app_id_2_)); std::string default_hmi2; - policy_manager_->GetDefaultHmi(app_id_2_, &default_hmi2); + policy_manager_->GetDefaultHmi(device_id_2_, app_id_2_, &default_hmi2); EXPECT_EQ("LIMITED", default_hmi2); } @@ -347,8 +360,8 @@ TEST_F(PolicyManagerImplTest2, GetDefaultPriority_SetDeviceAllowed_ExpectReceivedPriorityCorrect) { // Arrange CreateLocalPT(kPtu2RequestTypeJson); - policy_manager_->AddApplication(app_id_2_, - HmiTypes(policy_table::AHT_DEFAULT)); + policy_manager_->AddApplication( + device_id_1_, app_id_2_, HmiTypes(policy_table::AHT_DEFAULT)); // Check if app has preData policy EXPECT_TRUE(policy_manager_->IsPredataPolicy(app_id_2_)); std::string priority1; @@ -370,10 +383,10 @@ TEST_F(PolicyManagerImplTest2, policy_manager_->GetUserConsentForDevice(device_id_2_); // Check EXPECT_EQ(::policy::DeviceConsent::kDeviceAllowed, consent); - EXPECT_CALL(listener_, OnCurrentDeviceIdUpdateRequired(app_id_2_)) + EXPECT_CALL(listener_, OnCurrentDeviceIdUpdateRequired(_, app_id_2_)) .WillRepeatedly(Return(device_id_2_)); - policy_manager_->AddApplication(app_id_2_, - HmiTypes(policy_table::AHT_DEFAULT)); + policy_manager_->AddApplication( + device_id_2_, app_id_2_, HmiTypes(policy_table::AHT_DEFAULT)); EXPECT_TRUE((policy_manager_->GetCache())->IsDefaultPolicy(app_id_2_)); std::string priority2; EXPECT_TRUE(policy_manager_->GetPriority(app_id_2_, &priority2)); @@ -490,8 +503,10 @@ TEST_F(PolicyManagerImplTest2, SetDeviceInfo_ExpectDevInfoAddedToPT) { TEST_F(PolicyManagerImplTest2, GetInitialAppData_ExpectReceivedConsentCorrect) { // Arrange CreateLocalPT(preloaded_pt_filename_); - policy_manager_->AddApplication(app_id_2_, - HmiTypes(policy_table::AHT_DEFAULT)); + EXPECT_CALL(listener_, GetDevicesIds(app_id_2_)) + .WillRepeatedly(Return(transport_manager::DeviceList())); + policy_manager_->AddApplication( + device_id_1_, app_id_2_, HmiTypes(policy_table::AHT_DEFAULT)); ::policy::StringArray app_nicknames; ::policy::StringArray app_hmi_types; policy_manager_->GetInitialAppData(app_id_2_, &app_nicknames, &app_hmi_types); @@ -534,8 +549,8 @@ TEST_F( CanAppKeepContext_AddAppFromUnconsentedDevice_ExpectAppCannotKeepContext) { // Arrange CreateLocalPT(preloaded_pt_filename_); - policy_manager_->AddApplication(app_id_2_, - HmiTypes(policy_table::AHT_DEFAULT)); + policy_manager_->AddApplication( + device_id_1_, app_id_2_, HmiTypes(policy_table::AHT_DEFAULT)); // Check if app has preData policy EXPECT_TRUE(policy_manager_->IsPredataPolicy(app_id_2_)); // Check keep context in preData policy @@ -548,8 +563,8 @@ TEST_F(PolicyManagerImplTest2, CreateLocalPT(preloaded_pt_filename_); ASSERT_TRUE( (policy_manager_->GetCache())->AddDevice(device_id_2_, "Bluetooth")); - policy_manager_->AddApplication(app_id_2_, - HmiTypes(policy_table::AHT_DEFAULT)); + policy_manager_->AddApplication( + device_id_1_, app_id_2_, HmiTypes(policy_table::AHT_DEFAULT)); ASSERT_TRUE((policy_manager_->GetCache()) ->SetDeviceData(device_id_2_, "hardware IPX", @@ -563,10 +578,10 @@ TEST_F(PolicyManagerImplTest2, ::policy::DeviceConsent consent = policy_manager_->GetUserConsentForDevice(device_id_2_); EXPECT_EQ(::policy::DeviceConsent::kDeviceAllowed, consent); - EXPECT_CALL(listener_, OnCurrentDeviceIdUpdateRequired(app_id_2_)) + EXPECT_CALL(listener_, OnCurrentDeviceIdUpdateRequired(_, app_id_2_)) .WillRepeatedly(Return(device_id_2_)); - policy_manager_->AddApplication(app_id_2_, - HmiTypes(policy_table::AHT_DEFAULT)); + policy_manager_->AddApplication( + device_id_2_, app_id_2_, HmiTypes(policy_table::AHT_DEFAULT)); EXPECT_TRUE((policy_manager_->GetCache())->IsDefaultPolicy(app_id_2_)); // Check keep context in default policy EXPECT_FALSE(policy_manager_->CanAppKeepContext(app_id_2_)); @@ -576,8 +591,8 @@ TEST_F(PolicyManagerImplTest2, CanAppStealFocus_AddAppFromUnconsentedDevice_ExpectAppCannotStealFocus) { // Arrange CreateLocalPT(preloaded_pt_filename_); - policy_manager_->AddApplication(app_id_2_, - HmiTypes(policy_table::AHT_DEFAULT)); + policy_manager_->AddApplication( + device_id_1_, app_id_2_, HmiTypes(policy_table::AHT_DEFAULT)); // Check if app has preData policy EXPECT_TRUE(policy_manager_->IsPredataPolicy(app_id_2_)); // Check keep context in preData policy @@ -590,8 +605,8 @@ TEST_F(PolicyManagerImplTest2, CreateLocalPT(preloaded_pt_filename_); ASSERT_TRUE( (policy_manager_->GetCache())->AddDevice(device_id_2_, "Bluetooth")); - policy_manager_->AddApplication(app_id_2_, - HmiTypes(policy_table::AHT_DEFAULT)); + policy_manager_->AddApplication( + device_id_1_, app_id_2_, HmiTypes(policy_table::AHT_DEFAULT)); ASSERT_TRUE((policy_manager_->GetCache()) ->SetDeviceData(device_id_2_, "hardware IPX", @@ -605,10 +620,10 @@ TEST_F(PolicyManagerImplTest2, ::policy::DeviceConsent consent = policy_manager_->GetUserConsentForDevice(device_id_2_); EXPECT_EQ(::policy::DeviceConsent::kDeviceAllowed, consent); - EXPECT_CALL(listener_, OnCurrentDeviceIdUpdateRequired(app_id_2_)) + EXPECT_CALL(listener_, OnCurrentDeviceIdUpdateRequired(_, app_id_2_)) .WillRepeatedly(Return(device_id_2_)); - policy_manager_->AddApplication(app_id_2_, - HmiTypes(policy_table::AHT_DEFAULT)); + policy_manager_->AddApplication( + device_id_2_, app_id_2_, HmiTypes(policy_table::AHT_DEFAULT)); EXPECT_TRUE((policy_manager_->GetCache())->IsDefaultPolicy(app_id_2_)); // Check keep context in default policy EXPECT_FALSE(policy_manager_->CanAppStealFocus(app_id_2_)); @@ -618,8 +633,8 @@ TEST_F(PolicyManagerImplTest2, IsPredataPolicy_SetAppWIthPredataPolicy_ExpectPredataPolicy) { // Arrange CreateLocalPT(preloaded_pt_filename_); - policy_manager_->AddApplication(app_id_2_, - HmiTypes(policy_table::AHT_DEFAULT)); + policy_manager_->AddApplication( + device_id_1_, app_id_2_, HmiTypes(policy_table::AHT_DEFAULT)); // Check if app has preData policy EXPECT_TRUE(policy_manager_->IsPredataPolicy(app_id_2_)); } @@ -629,18 +644,18 @@ TEST_F( SendNotificationOnPermissionsUpdated_SetDeviceAllowed_ExpectNotificationSent) { // Arrange CreateLocalPT(kPtu2RequestTypeJson); - policy_manager_->AddApplication(app_id_2_, - HmiTypes(policy_table::AHT_DEFAULT)); + EXPECT_CALL(listener_, GetDevicesIds(app_id_2_)).Times(0); + policy_manager_->AddApplication( + device_id_1_, app_id_2_, HmiTypes(policy_table::AHT_DEFAULT)); // Check if app has preData policy EXPECT_TRUE(policy_manager_->IsPredataPolicy(app_id_2_)); std::string default_hmi1; - policy_manager_->GetDefaultHmi(app_id_2_, &default_hmi1); + policy_manager_->GetDefaultHmi(device_id_1_, app_id_2_, &default_hmi1); EXPECT_EQ("NONE", default_hmi1); - EXPECT_CALL(listener_, OnCurrentDeviceIdUpdateRequired(app_id_2_)) - .WillOnce(Return("")); - EXPECT_CALL(listener_, OnPermissionsUpdated(app_id_2_, _, default_hmi1)) + EXPECT_CALL(listener_, OnPermissionsUpdated(device_id_1_, app_id_2_, _)) .Times(0); - policy_manager_->SendNotificationOnPermissionsUpdated(app_id_2_); + policy_manager_->SendNotificationOnPermissionsUpdated(device_id_1_, + app_id_2_); ASSERT_TRUE( (policy_manager_->GetCache())->AddDevice(device_id_2_, "Bluetooth")); @@ -658,18 +673,19 @@ TEST_F( policy_manager_->GetUserConsentForDevice(device_id_2_); // Check EXPECT_EQ(::policy::DeviceConsent::kDeviceAllowed, consent); - EXPECT_CALL(listener_, OnCurrentDeviceIdUpdateRequired(app_id_2_)) - .WillRepeatedly(Return(device_id_2_)); - policy_manager_->AddApplication(app_id_2_, - HmiTypes(policy_table::AHT_DEFAULT)); + EXPECT_CALL(listener_, GetDevicesIds(app_id_2_)).Times(0); + policy_manager_->AddApplication( + device_id_2_, app_id_2_, HmiTypes(policy_table::AHT_DEFAULT)); EXPECT_TRUE((policy_manager_->GetCache())->IsDefaultPolicy(app_id_2_)); std::string default_hmi2; - policy_manager_->GetDefaultHmi(app_id_2_, &default_hmi2); + policy_manager_->GetDefaultHmi(device_id_2_, app_id_2_, &default_hmi2); EXPECT_EQ("LIMITED", default_hmi2); - EXPECT_CALL(listener_, OnPermissionsUpdated(app_id_2_, _, default_hmi2)); - policy_manager_->SendNotificationOnPermissionsUpdated(app_id_2_); + EXPECT_CALL(listener_, + OnPermissionsUpdated(device_id_2_, app_id_2_, _, default_hmi2)); + policy_manager_->SendNotificationOnPermissionsUpdated(device_id_2_, + app_id_2_); } -} // namespace policy +} // namespace policy_test } // namespace components } // namespace test diff --git a/src/components/policy/policy_external/test/sql_pt_ext_representation_test.cc b/src/components/policy/policy_external/test/sql_pt_ext_representation_test.cc index b87598b986b..7d40210ba48 100644 --- a/src/components/policy/policy_external/test/sql_pt_ext_representation_test.cc +++ b/src/components/policy/policy_external/test/sql_pt_ext_representation_test.cc @@ -29,27 +29,27 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include -#include +#include "policy/sql_pt_ext_representation.h" #include -#include -#include -#include #include +#include +#include +#include +#include +#include #include "gtest/gtest.h" -#include "policy/sql_pt_ext_representation.h" -#include "utils/gen_hash.h" -#include "utils/file_system.h" -#include "sqlite_wrapper/sql_query.h" -#include "rpc_base/rpc_base.h" -#include "policy/policy_table/types.h" #include "policy/mock_policy_settings.h" +#include "policy/policy_table/types.h" +#include "rpc_base/rpc_base.h" +#include "sqlite_wrapper/sql_query.h" +#include "utils/file_system.h" +#include "utils/gen_hash.h" using namespace ::policy; namespace policy_table = rpc::policy_table_interface_base; -using std::string; using std::map; using std::pair; +using std::string; using std::vector; using testing::ReturnRef; @@ -1541,8 +1541,8 @@ TEST_F(SQLPTExtRepresentationTest, SaveFunctionalGroupings_ExpectedSaved) { const HmiLevel test_level_1 = HL_FULL; const HmiLevel test_level_2 = HL_LIMITED; - const policy_table::Parameter test_parameter_1 = P_GPS; - const policy_table::Parameter test_parameter_2 = P_SPEED; + const std::string test_parameter_1 = "P_GPS"; + const std::string test_parameter_2 = "P_SPEED"; Rpcs rpcs; @@ -1578,7 +1578,7 @@ TEST_F(SQLPTExtRepresentationTest, SaveFunctionalGroupings_ExpectedSaved) { *another_rpcs.user_consent_prompt = another_user_consent_prompt; const HmiLevel test_level_3 = HL_BACKGROUND; - const policy_table::Parameter test_parameter_3 = P_BELTSTATUS; + const std::string test_parameter_3 = "P_BELTSTATUS"; RpcParameters another_parameters; another_parameters.hmi_levels.push_back(test_level_3); @@ -1615,10 +1615,10 @@ TEST_F(SQLPTExtRepresentationTest, SaveFunctionalGroupings_ExpectedSaved) { EXPECT_TRUE( (IsKeyExist(loaded_parameters.hmi_levels, test_level_2))); - EXPECT_TRUE(( - IsKeyExist(*loaded_parameters.parameters, test_parameter_1))); - EXPECT_TRUE(( - IsKeyExist(*loaded_parameters.parameters, test_parameter_2))); + EXPECT_TRUE((IsKeyExist( + *loaded_parameters.parameters, test_parameter_1))); + EXPECT_TRUE((IsKeyExist( + *loaded_parameters.parameters, test_parameter_2))); Rpcs another_loaded_rpcs = GetKeyData( loaded_groupings, another_group_name); @@ -1637,8 +1637,8 @@ TEST_F(SQLPTExtRepresentationTest, SaveFunctionalGroupings_ExpectedSaved) { EXPECT_TRUE((IsKeyExist(another_loaded_parameters.hmi_levels, test_level_3))); - EXPECT_TRUE((IsKeyExist(*another_loaded_parameters.parameters, - test_parameter_3))); + EXPECT_TRUE((IsKeyExist( + *another_loaded_parameters.parameters, test_parameter_3))); } TEST_F(SQLPTExtRepresentationTest, JsonContentsExternalConsent_ExpectParsed) { diff --git a/src/components/policy/policy_external/test/sql_pt_representation_test.cc b/src/components/policy/policy_external/test/sql_pt_representation_test.cc index c43c9dace6b..67702ab4d27 100644 --- a/src/components/policy/policy_external/test/sql_pt_representation_test.cc +++ b/src/components/policy/policy_external/test/sql_pt_representation_test.cc @@ -29,38 +29,38 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include -#include -#include -#include #include #include +#include +#include #include +#include +#include #include "gtest/gtest.h" -#include "policy/sql_pt_representation.h" -#include "utils/file_system.h" -#include "utils/system.h" -#include "policy/sql_wrapper.h" -#include "policy/policy_types.h" -#include "json/writer.h" #include "json/reader.h" -#include "policy/policy_table/types.h" +#include "json/writer.h" +#include "policy/mock_policy_settings.h" #include "policy/policy_table/enums.h" +#include "policy/policy_table/types.h" +#include "policy/policy_types.h" +#include "policy/sql_pt_representation.h" +#include "policy/sql_wrapper.h" #include "rpc_base/rpc_base.h" -#include "policy/mock_policy_settings.h" +#include "utils/file_system.h" +#include "utils/system.h" namespace policy_table = rpc::policy_table_interface_base; -using policy::SQLPTRepresentation; using policy::CheckPermissionResult; -using policy::UserFriendlyMessage; using policy::EndpointUrls; +using policy::SQLPTRepresentation; +using policy::UserFriendlyMessage; using policy::VehicleInfo; -using testing::ReturnRef; -using testing::Return; -using testing::NiceMock; using testing::Mock; +using testing::NiceMock; +using testing::Return; +using testing::ReturnRef; namespace test { namespace components { @@ -176,7 +176,7 @@ class SQLPTRepresentationTest : public SQLPTRepresentation, policy_table::Strings& temp_groups = apps_iter->second.groups; StringsCompare(groups, temp_groups); EXPECT_EQ(0u, (*(apps_iter->second.nicknames)).size()); - EXPECT_EQ(prio, apps_iter->second.priority); + EXPECT_EQ(prio, (apps_iter->second).priority); EXPECT_EQ(0u, (*(apps_iter->second.AppHMIType)).size()); EXPECT_EQ(memory_kb, (*(apps_iter->second.memory_kb))); EXPECT_EQ(heart_beat_timeout_ms, @@ -376,6 +376,99 @@ class SQLPTRepresentationTest2 : public ::testing::Test { const uint16_t kAttemptsToOpenPolicyDB = 2u; }; +TEST_F(SQLPTRepresentationTest, VehicleDataItem_Store_Item) { + policy_table::VehicleDataItem rpm; + rpm.mark_initialized(); + rpm.name = "rpm"; + rpm.type = "Integer"; + rpm.key = "OEM_REF_RPM"; + rpm.mandatory = false; + *rpm.array = false; + rpm.params->mark_initialized(); + ASSERT_FALSE(reps->VehicleDataItemExists(rpm)); + ASSERT_TRUE(reps->InsertVehicleDataItem(rpm)); + ASSERT_TRUE(reps->VehicleDataItemExists(rpm)); + + auto rpm_retrieved = reps->GetVehicleDataItem(rpm.name, rpm.key); + + std::cout << rpm.ToJsonValue().toStyledString() << std::endl; + std::cout << rpm_retrieved.ToJsonValue().toStyledString() << std::endl; + + ASSERT_EQ(rpm.ToJsonValue(), rpm_retrieved.begin()->ToJsonValue()); +} + +TEST_F(SQLPTRepresentationTest, VehicleDataItem_Store_Complete_Item) { + policy_table::VehicleDataItem message; + message.name = "messsageName"; + message.type = "String"; + message.key = "OEM_REF_MSG"; + message.mandatory = false; + *message.array = false; + *message.since = "1.0"; + *message.until = "5.0"; + *message.removed = false; + *message.deprecated = false; + *message.minvalue = 0; + *message.maxvalue = 255; + *message.minsize = 0; + *message.maxsize = 255; + *message.minlength = 0; + *message.maxlength = 255; + message.params->mark_initialized(); + ASSERT_TRUE(reps->InsertVehicleDataItem(message)); + + auto message_retrieved = reps->GetVehicleDataItem(message.name, message.key); + ASSERT_EQ(message.ToJsonValue(), message_retrieved.begin()->ToJsonValue()); +} + +TEST_F(SQLPTRepresentationTest, VehicleDataItem_Store_Struct) { + policy_table::VehicleDataItem alss; + alss.mark_initialized(); + alss.name = "ambientLightSensorStatus"; + alss.type = "AmbientLightStatus"; + alss.key = "OEM_REF_AMB_LIGHT"; + alss.mandatory = false; + alss.params->mark_initialized(); + policy_table::VehicleDataItem lss; + lss.mark_initialized(); + lss.name = "LightSensorStatus"; + lss.type = "Struct"; + lss.key = "OEM_REF_SEN_LIGHT"; + lss.mandatory = false; + lss.params->mark_initialized(); + (*lss.params).push_back(alss); + + policy_table::VehicleDataItem hbo; + hbo.mark_initialized(); + hbo.name = "highBeamsOn"; + hbo.type = "Boolean"; + hbo.key = "OEM_REF_HIGH_BEAM"; + hbo.mandatory = true; + hbo.params->mark_initialized(); + policy_table::VehicleDataItem lbo; + lbo.mark_initialized(); + lbo.name = "lowBeamsOn"; + lbo.type = "Boolean"; + lbo.key = "OEM_REF_LOW_BEAM"; + lbo.mandatory = false; + lbo.params->mark_initialized(); + policy_table::VehicleDataItem hls; + hls.mark_initialized(); + hls.name = "headLampStatus"; + hls.type = "Struct"; + hls.key = "OEM_REF_HLSTATUS"; + hls.mandatory = false; + hls.params->mark_initialized(); + (*hls.params).push_back(lss); + (*hls.params).push_back(lbo); + (*hls.params).push_back(hbo); + ASSERT_TRUE(reps->InsertVehicleDataItem(alss)); + ASSERT_TRUE(reps->InsertVehicleDataItem(hls)); + + auto hls_retrieved = reps->GetVehicleDataItem(hls.name, hls.key); + ASSERT_EQ(hls.ToJsonValue(), hls_retrieved.begin()->ToJsonValue()); +} + TEST_F(SQLPTRepresentationTest2, CheckActualAttemptsToOpenDB_ExpectCorrectNumber) { EXPECT_EQ(::policy::FAIL, reps->Init(&policy_settings_)); @@ -406,8 +499,8 @@ TEST_F(SQLPTRepresentationTest, query.Prepare(query_select); query.Next(); - // 37 - is current total tables number created by schema - const int policy_tables_number = 37; + // 41 - is current total tables number created by schema + const int policy_tables_number = 41; ASSERT_EQ(policy_tables_number, query.GetInteger(0)); const std::string query_select_count_of_iap_buffer_full = @@ -965,25 +1058,6 @@ TEST_F( ASSERT_EQ(0, query.GetInteger(0)); } -TEST_F( - SQLPTRepresentationTest, - GetVehicleInfo_ManuallySetVehcleInfoThenCallGetVehicleInfo_ExpectValuesReceived) { - // Check - const std::string query_insert_module_config = - "UPDATE `module_config` SET `preloaded_pt` = 1, " - " `exchange_after_x_ignition_cycles` = 50," - " `exchange_after_x_kilometers` = 2000, `exchange_after_x_days` = 30," - " `timeout_after_x_seconds` = 5, `vehicle_make` = 'FORD', " - " `vehicle_model` = 'MUSTANG', `vehicle_year` = '2003', " - "`preloaded_date` = '25.04.2015'"; - ASSERT_TRUE(query_wrapper_->Exec(query_insert_module_config)); - VehicleInfo info = reps->GetVehicleInfo(); - - ASSERT_EQ("FORD", info.vehicle_make); - ASSERT_EQ("MUSTANG", info.vehicle_model); - ASSERT_EQ("2003", info.vehicle_year); -} - TEST_F(SQLPTRepresentationTest, GetUserFriendlyMsg_SetMsg_ExpectReceivedMsgSetInParams) { // Arrange @@ -1695,9 +1769,8 @@ TEST_F(SQLPTRepresentationTest, const ::policy_table::Parameters& parameters = *(rpc_iter->second.parameters); EXPECT_EQ(1u, parameters.size()); - EXPECT_TRUE(parameters.end() != std::find(parameters.begin(), - parameters.end(), - policy_table::Parameter::P_SPEED)); + EXPECT_TRUE(parameters.end() != + std::find(parameters.begin(), parameters.end(), "P_SPEED")); // Check Application Policies Section GatherApplicationPoliciesSection(&policies); const uint32_t apps_size = 3u; diff --git a/src/components/policy/policy_external/test/update_status_manager_test.cc b/src/components/policy/policy_external/test/update_status_manager_test.cc index bf443bb2012..9f684567504 100644 --- a/src/components/policy/policy_external/test/update_status_manager_test.cc +++ b/src/components/policy/policy_external/test/update_status_manager_test.cc @@ -30,10 +30,11 @@ * POSSIBILITY OF SUCH DAMAGE. */ +#include "policy/update_status_manager.h" #include "gtest/gtest.h" #include "policy/mock_policy_listener.h" +#include "policy/mock_ptu_retry_handler.h" #include "policy/policy_manager_impl.h" -#include "policy/update_status_manager.h" #include "utils/conditional_variable.h" @@ -43,8 +44,8 @@ namespace policy_test { using namespace ::policy; using ::testing::_; -using ::testing::Return; using testing::NiceMock; +using ::testing::Return; class UpdateStatusManagerTest : public ::testing::Test { protected: @@ -52,6 +53,7 @@ class UpdateStatusManagerTest : public ::testing::Test { PolicyTableStatus status_; const uint32_t k_timeout_; NiceMock listener_; + NiceMock mock_ptu_retry_handler_; const std::string up_to_date_status_; const std::string update_needed_status_; const std::string updating_status_; @@ -61,6 +63,7 @@ class UpdateStatusManagerTest : public ::testing::Test { : manager_(std::make_shared()) , k_timeout_(1000) , listener_() + , mock_ptu_retry_handler_() , up_to_date_status_("UP_TO_DATE") , update_needed_status_("UPDATE_NEEDED") , updating_status_("UPDATING") {} @@ -68,6 +71,8 @@ class UpdateStatusManagerTest : public ::testing::Test { void SetUp() OVERRIDE { manager_->set_listener(&listener_); ON_CALL(listener_, OnUpdateStatusChanged(_)).WillByDefault(Return()); + ON_CALL(listener_, ptu_retry_handler()) + .WillByDefault(ReturnRef(mock_ptu_retry_handler_)); } void TearDown() OVERRIDE {} @@ -105,12 +110,17 @@ class WaitAsync { const uint32_t timeout_; sync_primitives::ConditionalVariable cond_var_; }; -} +} // namespace ACTION_P(NotifyAsync, waiter) { waiter->Notify(); } +ACTION_P2(RetryFailed, manager, listener) { + manager->OnResetRetrySequence(); + listener->OnPTUFinished(false); +} + TEST_F(UpdateStatusManagerTest, OnUpdateSentOut_WaitForTimeoutExpired_ExpectStatusUpdateNeeded) { // Arrange @@ -131,6 +141,38 @@ TEST_F(UpdateStatusManagerTest, EXPECT_EQ(StatusUpdateRequired, status_); } +TEST_F( + UpdateStatusManagerTest, + OnUpdateSentOut_WaitForTimeoutExpired_ExpectStatusUpdateNeeded_RetryExceeded) { + sync_primitives::Lock lock; + sync_primitives::AutoLock auto_lock(lock); + const uint32_t count = 3u; + const uint32_t timeout = 2u * k_timeout_; + WaitAsync waiter(count, timeout); + EXPECT_CALL(listener_, OnUpdateStatusChanged(_)) + .WillRepeatedly(NotifyAsync(&waiter)); + EXPECT_CALL(mock_ptu_retry_handler_, RetrySequenceFailed()) + .WillOnce(RetryFailed(manager_, &listener_)); + manager_->ScheduleUpdate(); + manager_->OnUpdateSentOut(k_timeout_); + status_ = manager_->GetLastUpdateStatus(); + { + ::testing::InSequence s; + EXPECT_CALL(mock_ptu_retry_handler_, IsAllowedRetryCountExceeded()) + .WillRepeatedly(Return(false)); + EXPECT_CALL(mock_ptu_retry_handler_, IsAllowedRetryCountExceeded()) + .WillRepeatedly(Return(false)); + EXPECT_CALL(mock_ptu_retry_handler_, IsAllowedRetryCountExceeded()) + .WillRepeatedly(Return(true)); + EXPECT_CALL(listener_, OnPTUFinished(false)); + } + EXPECT_EQ(StatusUpdatePending, status_); + EXPECT_TRUE(waiter.Wait(auto_lock)); + status_ = manager_->GetLastUpdateStatus(); + // Check + EXPECT_EQ(StatusUpdateRequired, status_); +} + TEST_F(UpdateStatusManagerTest, OnUpdateTimeOutOccurs_ExpectStatusUpdateNeeded) { // Arrange @@ -245,7 +287,7 @@ TEST_F(UpdateStatusManagerTest, OnResetRetrySequence_ExpectStatusUpToDate) { manager_->OnResetRetrySequence(); status_ = manager_->GetLastUpdateStatus(); // Check - EXPECT_EQ(StatusUpdatePending, status_); + EXPECT_EQ(StatusUpdateRequired, status_); } TEST_F(UpdateStatusManagerTest, @@ -298,6 +340,6 @@ TEST_F(UpdateStatusManagerTest, EXPECT_FALSE(manager_->IsAppsSearchInProgress()); } -} // namespace policy +} // namespace policy_test } // namespace components } // namespace test diff --git a/src/components/policy/policy_regular/CMakeLists.txt b/src/components/policy/policy_regular/CMakeLists.txt index 3679b2efeaa..e14057ec891 100644 --- a/src/components/policy/policy_regular/CMakeLists.txt +++ b/src/components/policy/policy_regular/CMakeLists.txt @@ -30,25 +30,81 @@ include(${CMAKE_SOURCE_DIR}/tools/cmake/helpers/platform.cmake) include(${CMAKE_SOURCE_DIR}/tools/cmake/helpers/sources.cmake) +include(${CMAKE_SOURCE_DIR}/tools/cmake/helpers/generators.cmake) include_directories ( - ${POLICY_PATH}/include - ${POLICY_GLOBAL_INCLUDE_PATH}/ - ${COMPONENTS_DIR}/rpc_base/include - ${JSONCPP_INCLUDE_DIRECTORY} + ${POLICY_PATH}/include/ + ${COMPONENTS_DIR}/ ${COMPONENTS_DIR}/utils/include/ ${COMPONENTS_DIR}/config_profile/include - ${LOG4CXX_INCLUDE_DIRECTORY} - ${BOOST_INCLUDE_DIR} + ${COMPONENTS_DIR}/connection_handler/include/ + ${COMPONENTS_DIR}/protocol_handler/include/ + ${COMPONENTS_DIR}/config_profile/include/ + ${COMPONENTS_DIR}/smart_objects/include/ + ${COMPONENTS_DIR}/rpc_base/include/ + ${CMAKE_BINARY_DIR}/src/components/ + ${POLICY_GLOBAL_INCLUDE_PATH}/ + ${BOOST_INCLUDE_DIR}/ + ${JSONCPP_INCLUDE_DIRECTORY}/ + ${LOG4CXX_INCLUDE_DIRECTORY}/ ) +set(GENERATED_MOBILE_POLICY_TYPES_CPP + "${CMAKE_CURRENT_BINARY_DIR}/generated_MOBILE_API_policy_types.cc" + "${CMAKE_CURRENT_BINARY_DIR}/generated_MOBILE_API_enum_schema_factory.cc") + +set(GENERATED_MOBILE_POLICY_TYPES_HPP + "${CMAKE_CURRENT_BINARY_DIR}/generated_MOBILE_API_policy_types.h") + +set(GENERATED_MOBILE_POLICY_TYPES + ${GENERATED_MOBILE_POLICY_TYPES_HPP} + ${GENERATED_MOBILE_POLICY_TYPES_CPP}) + +generate_policy_types("${GENERATED_MOBILE_POLICY_TYPES}" + "${COMPONENTS_DIR}/interfaces/MOBILE_API.xml" + "rpc::policy_table_interface_base" + "mobile-policy-types") + + +set(GENERATED_HMI_POLICY_TYPES_CPP + "${CMAKE_CURRENT_BINARY_DIR}/generated_HMI_API_policy_types.cc") + +set(GENERATED_HMI_POLICY_TYPES_HPP + "${CMAKE_CURRENT_BINARY_DIR}/generated_HMI_API_policy_types.h") + +set(GENERATED_HMI_POLICY_TYPES + ${GENERATED_HMI_POLICY_TYPES_HPP} + ${GENERATED_HMI_POLICY_TYPES_CPP}) + + +generate_policy_types("${GENERATED_HMI_POLICY_TYPES}" + "${COMPONENTS_DIR}/interfaces/HMI_API.xml" + "rpc::policy_table_interface_base" + "hmi-policy-types") + set(POLICY_TABLE_PATHS ${CMAKE_CURRENT_SOURCE_DIR}/include/policy/policy_table ${CMAKE_CURRENT_SOURCE_DIR}/src/policy_table + ${CMAKE_CURRENT_BINARY_DIR}/ +) + +set(POLICY_TABLE_SOURCES + ${GENERATED_MOBILE_POLICY_TYPES_CPP} + ${GENERATED_HMI_POLICY_TYPES_CPP} + ${POLICY_PATH}/src/policy_table/enums.cc + ${POLICY_PATH}/src/policy_table/types.cc + ${POLICY_PATH}/src/policy_table/validation.cc ) -collect_sources(POLICY_TABLE_SOURCES "${POLICY_TABLE_PATHS}") + add_library(policy_struct ${POLICY_TABLE_SOURCES}) -target_link_libraries(policy_struct Utils) +target_link_libraries(policy_struct + MOBILE_API + HMI_API + Utils + SmartObjects + formatters + jsoncpp +) set(USAGE_STATISTICS_PATHS ${CMAKE_CURRENT_SOURCE_DIR}/include/policy/usage_statistics @@ -74,7 +130,6 @@ set(LIBRARIES ConfigProfile policy_struct dbms - jsoncpp Utils ) @@ -87,8 +142,13 @@ else () list(APPEND LIBRARIES sqlite3) endif () -add_library(Policy SHARED ${SOURCES}) -target_link_libraries(Policy ${LIBRARIES}) + +add_library(PolicyStatic ${SOURCES}) +target_link_libraries(PolicyStatic ${LIBRARIES}) + + +add_library(Policy SHARED "src/policy_manager_impl.cc") +target_link_libraries(Policy PolicyStatic) if(ENABLE_LOG) target_link_libraries(Policy log4cxx -L${LOG4CXX_LIBS_DIRECTORY}) diff --git a/src/components/policy/policy_regular/include/policy/access_remote.h b/src/components/policy/policy_regular/include/policy/access_remote.h index c4de9b7e1f6..c0df6b729f7 100644 --- a/src/components/policy/policy_regular/include/policy/access_remote.h +++ b/src/components/policy/policy_regular/include/policy/access_remote.h @@ -32,9 +32,9 @@ #ifndef SRC_COMPONENTS_POLICY_POLICY_REGULAR_INCLUDE_POLICY_ACCESS_REMOTE_H_ #define SRC_COMPONENTS_POLICY_POLICY_REGULAR_INCLUDE_POLICY_ACCESS_REMOTE_H_ -#include #include #include +#include #include "policy/policy_table/types.h" #include "policy/policy_types.h" diff --git a/src/components/policy/policy_regular/include/policy/cache_manager.h b/src/components/policy/policy_regular/include/policy/cache_manager.h index 840b706c8b1..6bd2c4840b3 100644 --- a/src/components/policy/policy_regular/include/policy/cache_manager.h +++ b/src/components/policy/policy_regular/include/policy/cache_manager.h @@ -35,15 +35,15 @@ #include +#include "policy/cache_manager_interface.h" #include "policy/pt_representation.h" #include "policy/usage_statistics/statistics_manager.h" -#include "policy/cache_manager_interface.h" #include "utils/threads/thread.h" #include "utils/threads/thread_delegate.h" -#include "utils/lock.h" -#include "utils/conditional_variable.h" #include "policy/policy_types.h" +#include "utils/conditional_variable.h" +#include "utils/lock.h" namespace policy { class PolicySettings; @@ -142,10 +142,25 @@ class CacheManager : public CacheManagerInterface { virtual bool SecondsBetweenRetries(std::vector& seconds); /** - * @brief Get information about vehicle + * @brief Gets copy of current policy table data + * @return policy_table as json object */ - virtual const VehicleInfo GetVehicleInfo() const; + virtual Json::Value GetPolicyTableData() const OVERRIDE; + /** + * @brief Gets vehicle data items + * @return Structure with vehicle data items + */ + virtual const std::vector GetVehicleDataItems() + const; + + std::vector GetRemovedVehicleDataItems() + const OVERRIDE; + + const boost::optional LockScreenDismissalEnabledState() const OVERRIDE; + + const boost::optional LockScreenDismissalWarningMessage( + const std::string& language) const OVERRIDE; /** * @brief Get a list of enabled cloud applications * @param enabled_apps List filled with the policy app id of each enabled @@ -244,7 +259,7 @@ class CacheManager : public CacheManagerInterface { * @brief Check if an app can send unknown rpc requests to an app service * provider * @param policy_app_id Unique application id - */ + */ virtual bool UnknownRPCPassthroughAllowed( const std::string& policy_app_id) const; @@ -267,7 +282,8 @@ class CacheManager : public CacheManagerInterface { * @return Array of appropriate messages parameters */ std::vector GetUserFriendlyMsg( - const std::vector& msg_codes, const std::string& language); + const std::vector& msg_codes, + const std::string& language) const; /** * @brief Get list of URLs related to particular service @@ -390,6 +406,12 @@ class CacheManager : public CacheManagerInterface { */ bool GetFunctionalGroupings(policy_table::FunctionalGroupings& groups); + /** + * @brief Get policy app names from PT + * @return container of strings representing policy application names + */ + const policy_table::Strings GetPolicyAppIDs() const OVERRIDE; + /** * Checks if the application is represented in policy table * @param app_id application id @@ -830,6 +852,24 @@ class CacheManager : public CacheManagerInterface { void MergeCFM(const policy_table::PolicyTable& new_pt, policy_table::PolicyTable& pt); + /** + * @brief MergeVD allows to merge VehicleDataItems section by + *definite rules. + * + * The rules are: + * 1. If vehicle_data_items key is not presented in the updated PolicyTable, + * update for VehicleDataItems should be ignored. + * 2. If vehicle_data_items presented in updated PolicyTable, the + * VehicleDataItems in the database (LocalPT) should be overwritten with + * updated data. + * + * @param new_pt the policy table loaded from updated preload JSON file. + * + * @param pt the exists database + */ + void MergeVD(const policy_table::PolicyTable& new_pt, + policy_table::PolicyTable& pt); + const PolicySettings& get_settings() const; std::shared_ptr pt() const { @@ -845,6 +885,24 @@ class CacheManager : public CacheManagerInterface { void OnDeviceSwitching(const std::string& device_id_from, const std::string& device_id_to) OVERRIDE; + EncryptionRequired GetAppEncryptionRequiredFlag( + const std::string& application_policy_name) const OVERRIDE; + + EncryptionRequired GetFunctionalGroupingEncryptionRequiredFlag( + const std::string& functional_group) const OVERRIDE; + + void GetApplicationParams( + const std::string& application_name, + policy_table::ApplicationParams& application_policies) const OVERRIDE; + + /** + * @brief Method for separate RPCSpec vehicle data items from custom + * @param full vehicle data items during PTU + * @return array with only custom vehicle items + */ + static policy_table::VehicleDataItems CollectCustomVDItems( + const policy_table::VehicleDataItems& vd_items); + private: std::string currentDateTime(); struct AppHMITypeToString { @@ -864,6 +922,24 @@ class CacheManager : public CacheManagerInterface { */ void CheckSnapshotInitialization(); + /** + * @brief Calculates difference between two provided custom vehicle data items + * @param items_before list of vehicle data items before PTU was applied + * @param items_after list of vehicle data items after PTU was applied + * @return list with calculated difference or empty list if two input lists + * are equal + */ + policy_table::VehicleDataItems CalculateCustomVdItemsDiff( + const policy_table::VehicleDataItems& items_before, + const policy_table::VehicleDataItems& items_after) const; + + /** + * @brief Sets the custom vehicle data items + * @param removed_items list of vehicle data items to set + */ + void SetRemovedCustomVdItems( + const policy_table::VehicleDataItems& removed_items); + void PersistData(); /** @@ -890,6 +966,7 @@ class CacheManager : public CacheManagerInterface { bool update_required; typedef std::set UnpairedDevices; UnpairedDevices is_unpaired_; + policy_table::VehicleDataItems removed_custom_vd_items_; mutable sync_primitives::RecursiveLock cache_lock_; sync_primitives::Lock unpaired_lock_; diff --git a/src/components/policy/policy_regular/include/policy/cache_manager_interface.h b/src/components/policy/policy_regular/include/policy/cache_manager_interface.h index 2c14fd8cbae..a1b4af0f397 100644 --- a/src/components/policy/policy_regular/include/policy/cache_manager_interface.h +++ b/src/components/policy/policy_regular/include/policy/cache_manager_interface.h @@ -35,11 +35,13 @@ #include #include +#include "boost/optional.hpp" -#include "policy/usage_statistics/counter.h" -#include "policy/policy_types.h" #include "policy/policy_settings.h" #include "policy/policy_table/types.h" +#include "policy/policy_types.h" +#include "policy/usage_statistics/counter.h" +#include "utils/optional.h" namespace policy_table = rpc::policy_table_interface_base; @@ -147,9 +149,24 @@ class CacheManagerInterface { virtual bool SecondsBetweenRetries(std::vector& seconds) = 0; /** - * @brief Get information about vehicle + * @brief Gets copy of current policy table data + * @return policy_table as json object */ - virtual const VehicleInfo GetVehicleInfo() const = 0; + virtual Json::Value GetPolicyTableData() const = 0; + + /** + * @brief Gets vehicle data items + * @return Structure with vehicle data items + */ + virtual const std::vector GetVehicleDataItems() + const = 0; + + /** + * @brief Gets vehicle data items removed after the last PTU + * @return List of removed vehicle data items + */ + virtual std::vector + GetRemovedVehicleDataItems() const = 0; /** * @brief Get a list of enabled cloud applications @@ -250,10 +267,27 @@ class CacheManagerInterface { * @brief Check if an app can send unknown rpc requests to an app service * provider * @param policy_app_id Unique application id - */ + */ virtual bool UnknownRPCPassthroughAllowed( const std::string& policy_app_id) const = 0; + /** + * @brief Returns state of the lock screen that could be able to be dismissed + * while connected to SDL, allowing users the ability to interact with the + * app. + * @return bool True if lock screen can be dismissed. + */ + virtual const boost::optional LockScreenDismissalEnabledState() + const = 0; + + /** + * @brief Returns lock screen warning message. In case when specified language + * is absent in policy table will be returned message on default language + * ("en-us"). Otherwise returns uninitialized boost::optional + * @return std::string Lock screen warning message + */ + virtual const boost::optional LockScreenDismissalWarningMessage( + const std::string& language_code) const = 0; /** * @brief Allows to update 'vin' field in module_meta table. * @@ -274,7 +308,7 @@ class CacheManagerInterface { */ virtual std::vector GetUserFriendlyMsg( const std::vector& msg_codes, - const std::string& language) = 0; + const std::string& language) const = 0; /** * @brief Get list of URLs related to particular service @@ -399,6 +433,12 @@ class CacheManagerInterface { virtual bool GetFunctionalGroupings( policy_table::FunctionalGroupings& groups) = 0; + /** + * @brief Get policy app names from PT + * @return container of strings representing policy application names + */ + virtual const policy_table::Strings GetPolicyAppIDs() const = 0; + /** * Checks if the application is represented in policy table * @param app_id application id @@ -460,10 +500,10 @@ class CacheManagerInterface { std::string& default_hmi) const = 0; /** - * Gets HMI types from specific policy - * @param app_id ID application - * @return list of HMI types - */ + * Gets HMI types from specific policy + * @param app_id ID application + * @return list of HMI types + */ virtual const policy_table::AppHMITypes* GetHMITypes( const std::string& app_id) = 0; @@ -796,6 +836,36 @@ class CacheManagerInterface { */ virtual void OnDeviceSwitching(const std::string& device_id_from, const std::string& device_id_to) = 0; + + /** + * @brief GetAppEncryptionRequiredFlag retrieves encryption required flag for + * given application + * @param application policy application name + * @return optional object containing encryption required flag + */ + virtual rpc::Optional GetAppEncryptionRequiredFlag( + const std::string& application_policy_name) const = 0; + + /** + * @brief GetFunctionalGroupingEncryptionRequiredFlag retrieves encryption + * required flag + * for + * given functional grouping + * @param functional_group policy functional group name + * @return optional object containing encryption required flag + */ + virtual rpc::Optional + GetFunctionalGroupingEncryptionRequiredFlag( + const std::string& functional_group) const = 0; + + /** + * @brief retreives application params + * @param application_name policy applicatoin name + * @param application_params application params + */ + virtual void GetApplicationParams( + const std::string& application_name, + policy_table::ApplicationParams& application_params) const = 0; }; typedef std::shared_ptr CacheManagerInterfaceSPtr; diff --git a/src/components/policy/policy_regular/include/policy/policy_helper.h b/src/components/policy/policy_regular/include/policy/policy_helper.h index 3ca0f93ebdc..a8cec417158 100644 --- a/src/components/policy/policy_regular/include/policy/policy_helper.h +++ b/src/components/policy/policy_regular/include/policy/policy_helper.h @@ -1,4 +1,4 @@ -/* +/* Copyright (c) 2013, Ford Motor Company All rights reserved. @@ -83,22 +83,11 @@ bool operator!=(const policy_table::ApplicationParams& first, struct CheckAppPolicy { CheckAppPolicy(PolicyManagerImpl* pm, const std::shared_ptr update, - const std::shared_ptr snapshot); + const std::shared_ptr snapshot, + CheckAppPolicyResults& out_results); bool operator()(const AppPoliciesValueType& app_policy); private: - enum PermissionsCheckResult { - RESULT_NO_CHANGES, - RESULT_APP_REVOKED, - RESULT_NICKNAME_MISMATCH, - RESULT_PERMISSIONS_REVOKED, - RESULT_CONSENT_NEEDED, - RESULT_CONSENT_NOT_REQIURED, - RESULT_PERMISSIONS_REVOKED_AND_CONSENT_NEEDED, - RESULT_REQUEST_TYPE_CHANGED, - RESULT_REQUEST_SUBTYPE_CHANGED - }; - void SetPendingPermissions(const AppPoliciesValueType& app_policy, PermissionsCheckResult result) const; PermissionsCheckResult CheckPermissionsChanges( @@ -107,6 +96,8 @@ struct CheckAppPolicy { policy_table::Strings* revoked_groups = NULL) const; bool HasNewGroups(const AppPoliciesValueType& app_policy, policy_table::Strings* new_groups = NULL) const; + bool HasUpdatedGroups(const policy::AppPoliciesValueType& app_policy, + policy_table::Strings* updated_groups = NULL) const; bool HasConsentNeededGroups(const AppPoliciesValueType& app_policy) const; std::vector GetRevokedGroups( const AppPoliciesValueType& app_policy) const; @@ -115,10 +106,18 @@ struct CheckAppPolicy { const std::vector& revoked_groups) const; bool IsKnownAppication(const std::string& application_id) const; void NotifySystem(const AppPoliciesValueType& app_policy) const; - void SendPermissionsToApp(const std::string& app_id, - const policy_table::Strings& groups) const; bool IsAppRevoked(const AppPoliciesValueType& app_policy) const; bool NicknamesMatch(const AppPoliciesValueType& app_policy) const; + + /** + * @brief Check of current policy against incoming updated policy is + * performed. + * This function adds result code of this check to container. + * @param app_id Application id + * @param result Result value + */ + void AddResult(const std::string& app_id, PermissionsCheckResult result); + /** * @brief Allows to check if appropriate group requires any consent. * @param group_name the group for which consent will be checked. @@ -129,10 +128,31 @@ struct CheckAppPolicy { bool IsRequestTypeChanged(const AppPoliciesValueType& app_policy) const; bool IsRequestSubTypeChanged(const AppPoliciesValueType& app_policy) const; + bool IsEncryptionRequiredFlagChanged( + const AppPoliciesValueType& app_policy) const; + private: PolicyManagerImpl* pm_; const std::shared_ptr update_; const std::shared_ptr snapshot_; + CheckAppPolicyResults& out_results_; +}; + +/** + * @brief Helper struct for filling actions to be done for processed application + * using CheckAppPolicyResults data as a source + */ +struct FillActionsForAppPolicies { + FillActionsForAppPolicies( + ApplicationsPoliciesActions& actions, + const policy_table::ApplicationPolicies& app_policies) + : actions_(actions), app_policies_(app_policies) {} + + void operator()(const policy::CheckAppPolicyResults::value_type& value); + + private: + ApplicationsPoliciesActions& actions_; + const policy_table::ApplicationPolicies& app_policies_; }; /* @@ -174,6 +194,9 @@ struct ProcessFunctionalGroup { private: GroupConsent GetGroupState(const std::string& group_name); + void FillEncryptionFlagForRpcs( + const policy_table::Rpc& rpcs, + const policy::EncryptionRequired encryption_required); const policy_table::FunctionalGroupings& fg_; const std::vector& group_permissions_; Permissions& data_; @@ -246,6 +269,6 @@ FunctionalGroupIDs FindSame(const FunctionalGroupIDs& first, * @return true, if succeded, otherwise - false */ bool UnwrapAppPolicies(policy_table::ApplicationPolicies& app_policies); -} +} // namespace policy #endif // SRC_COMPONENTS_POLICY_POLICY_REGULAR_INCLUDE_POLICY_POLICY_HELPER_H_ diff --git a/src/components/policy/policy_regular/include/policy/policy_manager_impl.h b/src/components/policy/policy_regular/include/policy/policy_manager_impl.h index 911ce65a11f..fc6ec369dc0 100644 --- a/src/components/policy/policy_regular/include/policy/policy_manager_impl.h +++ b/src/components/policy/policy_regular/include/policy/policy_manager_impl.h @@ -33,21 +33,22 @@ #ifndef SRC_COMPONENTS_POLICY_POLICY_REGULAR_INCLUDE_POLICY_POLICY_MANAGER_IMPL_H_ #define SRC_COMPONENTS_POLICY_POLICY_REGULAR_INCLUDE_POLICY_POLICY_MANAGER_IMPL_H_ -#include -#include #include +#include +#include -#include "utils/lock.h" +#include "application_manager/policies/policy_encryption_flag_getter.h" +#include "policy/access_remote.h" +#include "policy/access_remote_impl.h" +#include "policy/cache_manager_interface.h" +#include "policy/policy_helper.h" #include "policy/policy_manager.h" #include "policy/policy_table.h" -#include "policy/cache_manager_interface.h" -#include "policy/update_status_manager.h" #include "policy/policy_table/functions.h" +#include "policy/update_status_manager.h" #include "policy/usage_statistics/statistics_manager.h" -#include "policy/policy_helper.h" +#include "utils/lock.h" #include "utils/timer.h" -#include "policy/access_remote.h" -#include "policy/access_remote_impl.h" namespace policy_table = rpc::policy_table_interface_base; @@ -57,6 +58,45 @@ struct CheckAppPolicy; class PolicyManagerImpl : public PolicyManager { public: PolicyManagerImpl(); + /* + * \param policy_app_id policy app id + * \return true if the app need encryption + */ + bool AppNeedEncryption(const std::string& policy_app_id) const OVERRIDE; + + /* + * \param policy_app_id policy app id + * \return Optional app need encryption + */ + const rpc::Optional GetAppEncryptionRequired( + const std::string& policy_app_id) const OVERRIDE; + /* + * \param policy_app_id policy app id + * \return groups that exist for app + */ + const std::vector GetFunctionalGroupsForApp( + const std::string& policy_app_id) const OVERRIDE; + + const std::vector GetApplicationPolicyIDs() const OVERRIDE; + + /* + * \param policy_group group + * \return true if the group need encryption + */ + bool FunctionGroupNeedEncryption( + const std::string& policy_group) const OVERRIDE; + /* + * \param policy_group group + * \return RPCs that exists in group + */ + const std::vector GetRPCsForFunctionGroup( + const std::string& group) const OVERRIDE; + /* + * \param function_id function id + * \return policy function name + */ + const std::string GetPolicyFunctionName( + const uint32_t function_id) const OVERRIDE; /** * @brief set_listener set new policy listener instance @@ -89,8 +129,35 @@ class PolicyManagerImpl : public PolicyManager { * @param pt_content PTU as binary string * @return true if successfully */ - bool LoadPT(const std::string& file, - const BinaryMessage& pt_content) OVERRIDE; + PtProcessingResult LoadPT(const std::string& file, + const BinaryMessage& pt_content) OVERRIDE; + + void OnPTUFinished(const PtProcessingResult ptu_result) OVERRIDE; + + typedef policy_table::ApplicationPolicies::value_type AppPoliciesValueType; + + /** + * @brief Notifies system by sending OnAppPermissionChanged notification + * @param device_id device identifier + * @param app_policy Reference to application policy + */ + void NotifySystem(const std::string& device_id, + const AppPoliciesValueType& app_policy) const; + + /** + * @brief Sends OnPermissionChange notification to application if its + * currently registered + * @param device_id device identifier + * @param app_policy Reference to application policy + */ + void SendPermissionsToApp(const std::string& device_id, + const AppPoliciesValueType& app_policy); + + /** + * @brief Resumes all policy actions for all apps, suspended during + * PTU applying + */ + void ResumePendingAppPolicyActions(); /** * @brief Resets Policy Table @@ -128,7 +195,7 @@ class PolicyManagerImpl : public PolicyManager { /** * @brief PTU is needed, for this PTS has to be formed and sent. */ - bool RequestPTUpdate() OVERRIDE; + bool RequestPTUpdate(const PTUIterationType iteration_type) OVERRIDE; /** * @brief Check if specified RPC for specified application @@ -162,6 +229,11 @@ class PolicyManagerImpl : public PolicyManager { */ void KmsChanged(int kilometers) OVERRIDE; + const boost::optional LockScreenDismissalEnabledState() const OVERRIDE; + + const boost::optional LockScreenDismissalWarningMessage( + const std::string& language) const OVERRIDE; + /** * @brief Increments counter of ignition cycles */ @@ -173,6 +245,8 @@ class PolicyManagerImpl : public PolicyManager { */ std::string ForcePTExchange() OVERRIDE; + void StopRetrySequence() OVERRIDE; + /** * @brief Exchange by user request * @return Current status of policy table @@ -187,8 +261,10 @@ class PolicyManagerImpl : public PolicyManager { /** * @brief Resets retry sequence + * @param send_event - if true corresponding event is sent to + * UpdateStatusManager */ - void ResetRetrySequence(); + void ResetRetrySequence(const ResetRetryCountType reset_type) OVERRIDE; /** * @brief Gets timeout to wait before next retry updating PT @@ -260,12 +336,15 @@ class PolicyManagerImpl : public PolicyManager { /** * @brief Update Application Policies as reaction * on User allowing/disallowing device this app is running on. + * @param device_handle device identifier * @param app_id Unique application id * @param is_device_allowed true if user allowing device otherwise false * @return true if operation was successful */ - bool ReactOnUserDevConsentForApp(const std::string app_id, - const bool is_device_allowed) OVERRIDE; + bool ReactOnUserDevConsentForApp( + const transport_manager::DeviceHandle& device_handle, + const std::string app_id, + const bool is_device_allowed) OVERRIDE; /** * @brief Retrieves data from app_policies about app on its registration: @@ -306,12 +385,14 @@ class PolicyManagerImpl : public PolicyManager { /** * @brief Get default HMI level for application + * @param device_id device identifier * @param policy_app_id Unique application id * @param default_hmi Default HMI level for application or empty, if value * was not set * @return true, if succedeed, otherwise - false */ - bool GetDefaultHmi(const std::string& policy_app_id, + bool GetDefaultHmi(const std::string& device_id, + const std::string& policy_app_id, std::string* default_hmi) const OVERRIDE; /** @@ -354,9 +435,11 @@ class PolicyManagerImpl : public PolicyManager { /** * @brief Return device id, which hosts specific application + * @param device_handle device identifier * @param policy_app_id Application id, which is required to update device id */ std::string& GetCurrentDeviceId( + const transport_manager::DeviceHandle& device_handle, const std::string& policy_app_id) const OVERRIDE; /** @@ -398,11 +481,12 @@ class PolicyManagerImpl : public PolicyManager { /** * @brief Gets specific application permissions changes since last policy * table update + * @param device_id device identifier * @param policy_app_id Unique application id * @return Permissions changes */ AppPermissions GetAppPermissionsChanges( - const std::string& policy_app_id) OVERRIDE; + const std::string& device_id, const std::string& policy_app_id) OVERRIDE; /** * @brief Removes specific application permissions changes @@ -412,10 +496,11 @@ class PolicyManagerImpl : public PolicyManager { /** * @brief Send OnPermissionsUpdated for choosen application + * @param device_id device identifier * @param application_id Unique application id */ void SendNotificationOnPermissionsUpdated( - const std::string& application_id) OVERRIDE; + const std::string& device_id, const std::string& application_id) OVERRIDE; /** * @brief Removes unpaired device records and related records from DB @@ -446,20 +531,24 @@ class PolicyManagerImpl : public PolicyManager { /** * @brief Adds, application to the db or update existed one * run PTU if policy update is necessary for application. + * @param device_id device identifier * @param application_id Unique application id * @param hmi_types application HMI types * @return function that will notify update manager about new application */ StatusNotifier AddApplication( + const std::string& device_id, const std::string& application_id, const rpc::policy_table_interface_base::AppHmiTypes& hmi_types) OVERRIDE; /** * @brief Assigns new HMI types for specified application + * @param device_handle device identifier * @param application_id Unique application id * @param hmi_types new HMI types list */ - void SetDefaultHmiTypes(const std::string& application_id, + void SetDefaultHmiTypes(const transport_manager::DeviceHandle& device_handle, + const std::string& application_id, const std::vector& hmi_types) OVERRIDE; /** @@ -568,11 +657,20 @@ class PolicyManagerImpl : public PolicyManager { const std::string& policy_app_id) const OVERRIDE; /** - * @brief Get information about vehicle - * @return vehicle information + * @brief Gets vehicle data items + * @return Structure with vehicle data items */ - const VehicleInfo GetVehicleInfo() const OVERRIDE; + const std::vector GetVehicleDataItems() + const OVERRIDE; + std::vector GetRemovedVehicleDataItems() + const OVERRIDE; + + /** + * @brief Gets copy of current policy table data + * @return policy_table as json object + */ + Json::Value GetPolicyTableData() const OVERRIDE; /** * @brief Get a list of enabled cloud applications * @param enabled_apps List filled with the policy app id of each enabled @@ -672,17 +770,20 @@ class PolicyManagerImpl : public PolicyManager { * provider * @param policy_app_id Unique application id * @return bool true if allowed - */ + */ bool UnknownRPCPassthroughAllowed( const std::string& policy_app_id) const OVERRIDE; /** * @brief OnAppRegisteredOnMobile allows to handle event when application were * succesfully registered on mobile device. - * It will send OnAppPermissionSend notification and will try to start PTU. * + * It will send OnAppPermissionSend notification and will try to start PTU. + * + * @param device_id device identifier * @param application_id registered application. */ - void OnAppRegisteredOnMobile(const std::string& application_id) OVERRIDE; + void OnAppRegisteredOnMobile(const std::string& device_id, + const std::string& application_id) OVERRIDE; void OnDeviceSwitching(const std::string& device_id_from, const std::string& device_id_to) OVERRIDE; @@ -815,10 +916,30 @@ class PolicyManagerImpl : public PolicyManager { * @param snapshot Shared pointer to current copy of policy table * @return Collection per-application results */ - void CheckPermissionsChanges( + CheckAppPolicyResults CheckPermissionsChanges( const std::shared_ptr update, const std::shared_ptr snapshot); + void ProcessAppPolicyCheckResults( + const CheckAppPolicyResults& results, + const rpc::policy_table_interface_base::ApplicationPolicies& + app_policies); + + void ProcessActionsForAppPolicies( + const ApplicationsPoliciesActions& actions, + const policy_table::ApplicationPolicies& app_policies); + + /** + * @brief Compares current policies to the updated one. + * Trigger actions in case if certain fields after update were changed. + * This function should be called after PT update. + * Actions require already updated policy table + * @param update Shared pointer to policy table update + * @param snapshot Shared pointer to old copy of policy table + */ + void CheckPermissionsChangesAfterUpdate(const policy_table::Table& update, + const policy_table::Table& snapshot); + /** * @brief Fill structure to be sent with OnPermissionsChanged notification * @@ -875,9 +996,12 @@ class PolicyManagerImpl : public PolicyManager { /** * @brief Checks whether need ask the permission of users + * @param device_id device identifier + * @param app_id policy application id * @return true if user consent is needed */ - virtual bool IsConsentNeeded(const std::string& app_id); + virtual bool IsConsentNeeded(const std::string& device_id, + const std::string& app_id); /** * @brief Changes isConsentNeeded for app pending permissions, in case @@ -920,7 +1044,7 @@ class PolicyManagerImpl : public PolicyManager { /** * @brief Starts new retry sequence */ - void RetrySequence(); + void OnPTUIterationTimeout(); private: /** @@ -958,11 +1082,11 @@ class PolicyManagerImpl : public PolicyManager { void SendAuthTokenUpdated(const std::string policy_app_id); /** - * @brief Gets all allowed module types - * @param policy_app_id unique identifier of application - * @param modules list of allowed module types - * @return true if application has allowed modules - */ + * @brief Gets all allowed module types + * @param policy_app_id unique identifier of application + * @param modules list of allowed module types + * @return true if application has allowed modules + */ bool GetModuleTypes(const std::string& policy_app_id, std::vector* modules) const OVERRIDE; @@ -1053,11 +1177,6 @@ class PolicyManagerImpl : public PolicyManager { */ RetrySequenceURL retry_sequence_url_; - /** - * @brief Flag for notifying that invalid PTU was received - */ - bool wrong_ptu_update_received_; - /** * @brief Flag for notifying that PTU was started */ @@ -1067,6 +1186,21 @@ class PolicyManagerImpl : public PolicyManager { * @brief Flag for notifying that invalid PTU should be triggered */ bool trigger_ptu_; + + typedef std::list > + PendingAppPolicyActionsList; + + /** + * @brief List containing device_id and pending permissions structure pairs + * which can be processed later on demand + */ + PendingAppPolicyActionsList notify_system_list_; + + /** + * @brief List containing device_id and pending permissions structure pairs + * which can be processed later on demand + */ + PendingAppPolicyActionsList send_permissions_list_; }; } // namespace policy 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 679950277d8..05b39a0082f 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 @@ -34,552 +34,12 @@ #define SRC_COMPONENTS_POLICY_POLICY_REGULAR_INCLUDE_POLICY_POLICY_TABLE_ENUMS_H_ #include +#include "generated_HMI_API_policy_types.h" +#include "generated_MOBILE_API_policy_types.h" namespace rpc { namespace policy_table_interface_base { -enum Priority { - P_EMERGENCY, - P_NAVIGATION, - P_VOICECOM, - P_COMMUNICATION, - P_NORMAL, - P_PROJECTION, - P_NONE, -}; - -bool IsValidEnum(Priority val); -const char* EnumToJsonString(Priority val); -bool EnumFromJsonString(const std::string& literal, Priority* result); - -enum HmiLevel { - HL_BACKGROUND, - HL_FULL, - HL_LIMITED, - HL_NONE, -}; -bool IsValidEnum(HmiLevel val); -const char* EnumToJsonString(HmiLevel val); -bool EnumFromJsonString(const std::string& literal, HmiLevel* result); - -enum Parameter { - P_GPS, - P_SPEED, - P_ENGINETORQUE, - P_EXTERNALTEMPERATURE, - P_TURNSIGNAL, - P_FUELLEVEL, - P_FUELLEVEL_STATE, - P_HEADLAMPSTATUS, - P_INSTANTFUELCONSUMPTION, - P_FUELRANGE, - P_ODOMETER, - P_TIREPRESSURE, - P_WIPERSTATUS, - P_VIN, - P_ACCPEDALPOSITION, - P_BELTSTATUS, - P_ELECTRONICPARKBRAKESTATUS, - P_DRIVERBRAKING, - P_PRNDL, - P_RPM, - P_STEERINGWHEELANGLE, - P_ENGINEOILLIFE, - P_MYKEY, - P_CLOUD_APP_VEHICLE_ID, - P_AIRBAGSTATUS, - P_BODYINFORMATION, - P_CLUSTERMODESTATUS, - P_DEVICESTATUS, - P_EMERGENCYEVENT, - P_ECALLINFO, - P_EMPTY // Added to allow empty parameters handling -}; - -bool IsValidEnum(Parameter val); -const char* EnumToJsonString(Parameter val); -bool EnumFromJsonString(const std::string& literal, Parameter* result); - -enum AppHMIType { - AHT_DEFAULT, - AHT_COMMUNICATION, - AHT_MEDIA, - AHT_MESSAGING, - AHT_NAVIGATION, - AHT_INFORMATION, - AHT_SOCIAL, - AHT_BACKGROUND_PROCESS, - AHT_TESTING, - AHT_SYSTEM, - AHT_PROJECTION, - AHT_REMOTE_CONTROL -}; -bool IsValidEnum(AppHMIType val); -const char* EnumToJsonString(AppHMIType val); -bool EnumFromJsonString(const std::string& literal, AppHMIType* result); - -enum RequestType { - RT_HTTP, - RT_FILE_RESUME, - RT_AUTH_REQUEST, - RT_AUTH_CHALLENGE, - RT_AUTH_ACK, - RT_PROPRIETARY, - RT_QUERY_APPS, - RT_LAUNCH_APP, - RT_LOCK_SCREEN_ICON_URL, - RT_TRAFFIC_MESSAGE_CHANNEL, - RT_DRIVER_PROFILE, - RT_VOICE_SEARCH, - RT_NAVIGATION, - RT_PHONE, - RT_CLIMATE, - RT_SETTINGS, - RT_VEHICLE_DIAGNOSTICS, - RT_EMERGENCY, - RT_MEDIA, - RT_FOTA, - RT_OEM_SPECIFIC, - RT_EMPTY // Added to allow empty Request Types handling -}; - -bool IsValidEnum(RequestType val); -const char* EnumToJsonString(RequestType val); -bool EnumFromJsonString(const std::string& literal, RequestType* result); - -enum Input { - I_GUI, - I_VUI, -}; -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, - MT_AUDIO, - MT_LIGHT, - MT_HMI_SETTINGS, - MT_EMPTY -}; -bool IsValidEnum(ModuleType val); -const char* EnumToJsonString(ModuleType val); -bool EnumFromJsonString(const std::string& literal, ModuleType* result); - -enum HybridAppPreference { HAP_MOBILE, HAP_CLOUD, HAP_BOTH }; -bool IsValidEnum(HybridAppPreference val); -const char* EnumToJsonString(HybridAppPreference val); -bool EnumFromJsonString(const std::string& literal, - HybridAppPreference* result); - -/** - * @brief Enumeration FunctionID. - * - * Enumeration linking function names with function IDs in AppLink protocol. - * Assumes enumeration starts at value 0. - */ -enum FunctionID { - /** - * @brief RESERVED. - */ - RESERVED = 0, - - /** - * @brief RegisterAppInterfaceID. - */ - RegisterAppInterfaceID = 1, - - /** - * @brief UnregisterAppInterfaceID. - */ - UnregisterAppInterfaceID = 2, - - /** - * @brief SetGlobalPropertiesID. - */ - SetGlobalPropertiesID = 3, - - /** - * @brief ResetGlobalPropertiesID. - */ - ResetGlobalPropertiesID = 4, - - /** - * @brief AddCommandID. - */ - AddCommandID = 5, - - /** - * @brief DeleteCommandID. - */ - DeleteCommandID = 6, - - /** - * @brief AddSubMenuID. - */ - AddSubMenuID = 7, - - /** - * @brief DeleteSubMenuID. - */ - DeleteSubMenuID = 8, - - /** - * @brief CreateInteractionChoiceSetID. - */ - CreateInteractionChoiceSetID = 9, - - /** - * @brief PerformInteractionID. - */ - PerformInteractionID = 10, - - /** - * @brief DeleteInteractionChoiceSetID. - */ - DeleteInteractionChoiceSetID = 11, - - /** - * @brief AlertID. - */ - AlertID = 12, - - /** - * @brief ShowID. - */ - ShowID = 13, - - /** - * @brief SpeakID. - */ - SpeakID = 14, - - /** - * @brief SetMediaClockTimerID. - */ - SetMediaClockTimerID = 15, - - /** - * @brief PerformAudioPassThruID. - */ - PerformAudioPassThruID = 16, - - /** - * @brief EndAudioPassThruID. - */ - EndAudioPassThruID = 17, - - /** - * @brief SubscribeButtonID. - */ - SubscribeButtonID = 18, - - /** - * @brief UnsubscribeButtonID. - */ - UnsubscribeButtonID = 19, - - /** - * @brief SubscribeVehicleDataID. - */ - SubscribeVehicleDataID = 20, - - /** - * @brief UnsubscribeVehicleDataID. - */ - UnsubscribeVehicleDataID = 21, - - /** - * @brief GetVehicleDataID. - */ - GetVehicleDataID = 22, - - /** - * @brief ReadDIDID. - */ - ReadDIDID = 23, - - /** - * @brief GetDTCsID. - */ - GetDTCsID = 24, - - /** - * @brief ScrollableMessageID. - */ - ScrollableMessageID = 25, - - /** - * @brief SliderID. - */ - SliderID = 26, - - /** - * @brief ShowConstantTBTID. - */ - ShowConstantTBTID = 27, - - /** - * @brief AlertManeuverID. - */ - AlertManeuverID = 28, - - /** - * @brief UpdateTurnListID. - */ - UpdateTurnListID = 29, - - /** - * @brief ChangeRegistrationID. - */ - ChangeRegistrationID = 30, - - /** - * @brief GenericResponseID. - */ - GenericResponseID = 31, - - /** - * @brief PutFileID. - */ - PutFileID = 32, - - /** - * @brief DeleteFileID. - */ - DeleteFileID = 33, - - /** - * @brief ListFilesID. - */ - ListFilesID = 34, - - /** - * @brief SetAppIconID. - */ - SetAppIconID = 35, - - /** - * @brief SetDisplayLayoutID. - */ - SetDisplayLayoutID = 36, - - /** - * @brief DiagnosticMessageID. - */ - DiagnosticMessageID = 37, - - /** - * @brief SystemRequestID. - */ - SystemRequestID = 38, - - /** - * @brief SendLocationID. - */ - SendLocationID = 39, - - /** - * @brief DialNumberID. - */ - DialNumberID = 40, - - /** - * @brief ButtonPressID. - */ - ButtonPressID = 41, - - /** - * @brief GetInteriorVehicleDataID. - */ - GetInteriorVehicleDataID = 43, - - /** - * @brief SetInteriorVehicleDataID. - */ - SetInteriorVehicleDataID = 44, - - /** - * @brief GetWayPointsID. - */ - GetWayPointsID = 45, - - /** - * @brief SubscribeWayPointsID. - */ - SubscribeWayPointsID = 46, - - /** - * @brief UnsubscribeWayPointsID. - */ - UnsubscribeWayPointsID = 47, - - /** - * @brief GetSystemCapabilityID. - */ - GetSystemCapabilityID = 48, - - /** - * @brief SendHapticDataID. - */ - SendHapticDataID = 49, - - /** - * @brief SetCloudAppPropertiesID. - */ - SetCloudAppPropertiesID = 50, - - /** - * @brief GetCloudAppPropertiesID. - */ - GetCloudAppPropertiesID = 51, - - /** - * @brief PublishAppServiceID. - */ - PublishAppServiceID = 52, - - /** - * @brief GetAppServiceDataID. - */ - GetAppServiceDataID = 53, - - /** - * @brief GetFileID - */ - GetFileID = 54, - - /** - * @brief PerformAppServiceInteractionID. - */ - PerformAppServiceInteractionID = 55, - - /** - * @brief OnHMIStatusID. - */ - OnHMIStatusID = 32768, - - /** - * @brief OnAppInterfaceUnregisteredID. - */ - OnAppInterfaceUnregisteredID = 32769, - - /** - * @brief OnButtonEventID. - */ - OnButtonEventID = 32770, - - /** - * @brief OnButtonPressID. - */ - OnButtonPressID = 32771, - - /** - * @brief OnVehicleDataID. - */ - OnVehicleDataID = 32772, - - /** - * @brief OnCommandID. - */ - OnCommandID = 32773, - - /** - * @brief OnTBTClientStateID. - */ - OnTBTClientStateID = 32774, - - /** - * @brief OnDriverDistractionID. - */ - OnDriverDistractionID = 32775, - - /** - * @brief OnPermissionsChangeID. - */ - OnPermissionsChangeID = 32776, - - /** - * @brief OnAudioPassThruID. - */ - OnAudioPassThruID = 32777, - - /** - * @brief OnLanguageChangeID. - */ - OnLanguageChangeID = 32778, - - /** - * @brief OnKeyboardInputID. - */ - OnKeyboardInputID = 32779, - - /** - * @brief OnTouchEventID. - */ - OnTouchEventID = 32780, - - /** - * @brief OnSystemRequestID. - */ - OnSystemRequestID = 32781, - - /** - * @brief OnHashChangeID. - */ - OnHashChangeID = 32782, - - /** - * @brief OnInteriorVehicleDataID. - */ - OnInteriorVehicleDataID = 32783, - - /** - * @brief OnWayPointChangeID. - */ - OnWayPointChangeID = 32784, - - /** - * @brief OnRCStatusID. - */ - OnRCStatusID = 32785, - - /** - * @brief OnAppServiceDataID. - */ - OnAppServiceDataID = 32786, - - /** - * @brief OnSystemCapabilityUpdatedID - */ - OnSystemCapabilityUpdatedID = 32787, - - /** - * @brief EncodedSyncPDataID. - */ - EncodedSyncPDataID = 65536, - - /** - * @brief SyncPDataID. - */ - SyncPDataID = 65537, - - /** - * @brief OnEncodedSyncPDataID. - */ - OnEncodedSyncPDataID = 98304, - - /** - * @brief OnSyncPDataID. - */ - OnSyncPDataID = 98305 -}; -bool IsValidEnum(FunctionID val); -const char* EnumToJsonString(FunctionID val); -bool EnumFromJsonString(const std::string& literal, FunctionID* result); - extern const std::string kDefaultApp; extern const std::string kPreDataConsentApp; extern const std::string kDeviceApp; diff --git a/src/components/policy/policy_regular/include/policy/policy_table/policy_enum_schema_factory.h b/src/components/policy/policy_regular/include/policy/policy_table/policy_enum_schema_factory.h new file mode 100644 index 00000000000..2053923cfe5 --- /dev/null +++ b/src/components/policy/policy_regular/include/policy/policy_table/policy_enum_schema_factory.h @@ -0,0 +1,60 @@ +/** + * 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. + */ + +#ifndef SRC_COMPONENTS_POLICY_POLICY_REGULAR_INCLUDE_POLICY_POLICY_TABLE_POLICY_ENUM_SCHEMA_FACTORY_H +#define SRC_COMPONENTS_POLICY_POLICY_REGULAR_INCLUDE_POLICY_POLICY_TABLE_POLICY_ENUM_SCHEMA_FACTORY_H +#include +#include + +#include "smart_objects/smart_schema.h" + +namespace rpc { +namespace policy_table_interface_base { + +class EnumSchemaItemFactory { + public: + /** + * @brief Get enum schema from enum name + * Implementation of this function should be generated from MOBILE_API.xml + * @param enum_name enum name to get schema factory for + * @return shared pointer to schema factory or empty shared pointer if + * enum_name is wrong + */ + static std::shared_ptr + Get(const std::string& enum_name); + + static bool IsRPCSpecVehicleDataType(const std::string& vd_name); +}; + +} // namespace policy_table_interface_base +} // namespace rpc +#endif // SRC_COMPONENTS_POLICY_POLICY_REGULAR_INCLUDE_POLICY_POLICY_TABLE_POLICY_ENUM_SCHEMA_FACTORY_H diff --git a/src/components/policy/policy_regular/include/policy/policy_table/types.h b/src/components/policy/policy_regular/include/policy/policy_table/types.h index e41069a86c3..2ffbf2e7ecb 100644 --- a/src/components/policy/policy_regular/include/policy/policy_table/types.h +++ b/src/components/policy/policy_regular/include/policy/policy_table/types.h @@ -36,7 +36,9 @@ #include #include "policy/policy_table/enums.h" +#include "policy/policy_table/policy_enum_schema_factory.h" #include "rpc_base/rpc_message.h" +#include "utils/helpers.h" namespace Json { class Value; @@ -46,6 +48,7 @@ namespace policy_table_interface_base { struct AppLevel; struct ApplicationParams; struct DeviceParams; +struct EndpointProperty; struct MessageLanguages; struct MessageString; struct RpcParameters; @@ -67,16 +70,18 @@ typedef Array, 0, 255> AppHMITypes; typedef Array, 0, 4> HmiLevels; -typedef Array, 0, 255> Parameters; +typedef Array, 0, 255> Parameters; typedef Map Rpc; -typedef Array, 1, 3> URL; +typedef Array, 1, 3> URL; typedef Map URLList; typedef Map ServiceEndpoints; +typedef Map ServiceEndpointProperties; + typedef uint8_t NumberOfNotificationsType; typedef Map, 0, 7> NumberOfNotificationsPerMinute; @@ -203,6 +208,7 @@ struct ApplicationParams : PolicyBase { // App Service Params Optional app_service_parameters; Optional allow_unknown_rpc_passthrough; + Optional encryption_required; public: ApplicationParams(); @@ -268,6 +274,7 @@ struct Rpcs : CompositeType { public: Optional > user_consent_prompt; Nullable rpcs; + Optional encryption_required; public: Rpcs(); @@ -285,6 +292,24 @@ struct Rpcs : CompositeType { bool Validate() const; }; +struct EndpointProperty : CompositeType { + public: + Optional > version; + + EndpointProperty(); + ~EndpointProperty(); + explicit EndpointProperty(const Json::Value* value__); + Json::Value ToJsonValue() const; + bool is_valid() const; + bool is_initialized() const; + bool struct_empty() const; + void ReportErrors(rpc::ValidationReport* report__) const; + void SetPolicyTableType(PolicyTableType pt_type) OVERRIDE; + + private: + bool Validate() const; +}; + struct ModuleConfig : CompositeType { public: Optional, 0, 255> > device_certificates; @@ -296,12 +321,16 @@ struct ModuleConfig : CompositeType { Integer timeout_after_x_seconds; SecondsBetweenRetries seconds_between_retries; ServiceEndpoints endpoints; + Optional endpoint_properties; NumberOfNotificationsPerMinute notifications_per_minute_by_priority; Optional > vehicle_make; Optional > vehicle_model; Optional > vehicle_year; Optional > preloaded_date; Optional > certificate; + Optional lock_screen_dismissal_enabled; + + static const std::string kDefaultOemMappingServiceName; public: ModuleConfig(); @@ -311,6 +340,7 @@ struct ModuleConfig : CompositeType { uint16_t timeout_after_x_seconds, const SecondsBetweenRetries& seconds_between_retries, const ServiceEndpoints& endpoints, + const ServiceEndpointProperties& endpoint_properties, const NumberOfNotificationsPerMinute& notifications_per_minute_by_priority); ~ModuleConfig(); @@ -494,6 +524,88 @@ struct DeviceParams : CompositeType { bool Validate() const; }; +struct VehicleDataItem : CompositeType { + public: + static const std::vector kPODTypes; + + static const std::string kInteger; + static const std::string kStruct; + static const std::string kString; + static const std::string kFloat; + static const std::string kDouble; + static const std::string kBoolean; + static const std::string kName; + static const std::string kParams; + + String<1, 255> name; + String<0, 255> type; + String<1, 255> key; + Boolean mandatory; + Optional > params; + + Optional array; + Optional > since; + Optional > until; + Optional removed; + Optional deprecated; + Optional > minvalue; + Optional > maxvalue; + Optional > minsize; + Optional > maxsize; + Optional > minlength; + Optional > maxlength; + + VehicleDataItem(); + VehicleDataItem(const VehicleDataItem& policy_table); + explicit VehicleDataItem(const Json::Value* value__); + + bool operator==(const VehicleDataItem& vd); + + ~VehicleDataItem(); + + Json::Value ToJsonValue() const; + bool is_valid() const; + bool is_initialized() const; + bool struct_not_empty() const; + void ReportErrors(rpc::ValidationReport* report__) const; + virtual void SetPolicyTableType(PolicyTableType pt_type); + + /** + * @brief Validates type of vehicle data item according to + * POD types and generated from API enums. + * @return true if type is valid. + */ + bool ValidateTypes() const; + bool IsPrimitiveType() const; + bool ValidateNaming(std::string str) const; + + private: + bool Validate() const; +}; + +typedef Array VehicleDataItems; + +struct VehicleData : CompositeType { + public: + Optional > schema_version; + Optional schema_items; + + VehicleData(); + VehicleData(const VehicleData& vehicle_data); + VehicleData(const Json::Value* value__); + ~VehicleData(); + + Json::Value ToJsonValue() const; + bool is_valid() const; + bool is_initialized() const; + bool struct_empty() const; + void ReportErrors(rpc::ValidationReport* report__) const; + virtual void SetPolicyTableType(PolicyTableType pt_type); + + private: + bool Validate() const; +}; + struct PolicyTable : CompositeType { public: ApplicationPoliciesSection app_policies_section; @@ -503,6 +615,7 @@ struct PolicyTable : CompositeType { Optional module_meta; Optional usage_and_error_counts; Optional device_data; + Optional vehicle_data; public: PolicyTable(); diff --git a/src/components/policy/policy_regular/include/policy/policy_types.h b/src/components/policy/policy_regular/include/policy/policy_types.h index 276a0a5dca9..9fddb9761b2 100644 --- a/src/components/policy/policy_regular/include/policy/policy_types.h +++ b/src/components/policy/policy_regular/include/policy/policy_types.h @@ -34,15 +34,16 @@ #define SRC_COMPONENTS_POLICY_POLICY_EXTERNAL_INCLUDE_POLICY_POLICY_TYPES_H_ #include -#include -#include #include +#include #include +#include #include -#include +#include -#include "utils/helpers.h" +#include "policy/policy_table/types.h" #include "transport_manager/common.h" +#include "utils/helpers.h" namespace policy { @@ -77,6 +78,12 @@ enum PolicyTableStatus { StatusUnknown }; +enum class PTUIterationType { DefaultIteration = 0, RetryIteration }; + +enum class ResetRetryCountType { kResetWithStatusUpdate = 0, kResetInternally }; + +typedef rpc::Optional EncryptionRequired; + // Code generator uses String class name, so this typedef was renamed to PTSring typedef std::string PTString; typedef std::vector BinaryMessage; @@ -102,6 +109,7 @@ struct ParameterPermissions struct RpcPermissions { HMIPermissions hmi_permissions; ParameterPermissions parameter_permissions; + EncryptionRequired require_encryption; }; typedef std::map Permissions; @@ -119,10 +127,10 @@ typedef std::vector StringArray; enum PermitResult { kRpcAllowed = 0, kRpcDisallowed, kRpcUserDisallowed }; /** - * @struct Stores result of check: - * if HMI Level was allowed for RPC to work in - * and list of parameters allowed for RPC if specified in PT. - */ + * @struct Stores result of check: + * if HMI Level was allowed for RPC to work in + * and list of parameters allowed for RPC if specified in PT. + */ struct CheckPermissionResult { CheckPermissionResult() : hmi_level_permitted(kRpcDisallowed) {} @@ -427,6 +435,28 @@ struct ExternalConsentStatusItemSorter { } }; +/** + * @brief The ApplicationPolicyActions struct contains actions which should be + * done for some application + */ +struct ApplicationPolicyActions { + ApplicationPolicyActions() + : is_notify_system(false) + , is_send_permissions_to_app(false) + , is_consent_needed(false) {} + + bool is_notify_system; + bool is_send_permissions_to_app; + bool is_consent_needed; +}; + +/** + * @brief ApplicationsPoliciesActions map of actions to be done for every + * application + */ +typedef std::map + ApplicationsPoliciesActions; + /** * @brief Customer connectivity settings status */ @@ -473,10 +503,11 @@ enum PermissionsCheckResult { RESULT_NICKNAME_MISMATCH, RESULT_PERMISSIONS_REVOKED, RESULT_CONSENT_NEEDED, - RESULT_CONSENT_NOT_REQIURED, + RESULT_CONSENT_NOT_REQUIRED, RESULT_PERMISSIONS_REVOKED_AND_CONSENT_NEEDED, RESULT_REQUEST_TYPE_CHANGED, - RESULT_REQUEST_SUBTYPE_CHANGED + RESULT_REQUEST_SUBTYPE_CHANGED, + RESULT_ENCRYPTION_REQUIRED_FLAG_CHANGED }; /** diff --git a/src/components/policy/policy_regular/include/policy/pt_representation.h b/src/components/policy/policy_regular/include/policy/pt_representation.h index 378a2945328..1adf24ed19e 100644 --- a/src/components/policy/policy_regular/include/policy/pt_representation.h +++ b/src/components/policy/policy_regular/include/policy/pt_representation.h @@ -33,12 +33,12 @@ #ifndef SRC_COMPONENTS_POLICY_POLICY_REGULAR_INCLUDE_POLICY_PT_REPRESENTATION_H_ #define SRC_COMPONENTS_POLICY_POLICY_REGULAR_INCLUDE_POLICY_PT_REPRESENTATION_H_ -#include -#include #include -#include "policy/policy_types.h" -#include "policy/policy_table/types.h" +#include +#include #include "policy/policy_settings.h" +#include "policy/policy_table/types.h" +#include "policy/policy_types.h" #include "utils/macro.h" namespace policy { @@ -122,11 +122,6 @@ class PTRepresentation { */ virtual bool SecondsBetweenRetries(std::vector* seconds) = 0; - /** - * @brief Get information about vehicle - */ - virtual const VehicleInfo GetVehicleInfo() const = 0; - /** * @brief Allows to update 'vin' field in module_meta table. * @@ -265,10 +260,10 @@ class PTRepresentation { virtual bool IsDefaultPolicy(const std::string& app_id) const = 0; /** - * Checks if the application has pre_data policy - * @param app_id application id - * @return true if application has pre_data policy - */ + * Checks if the application has pre_data policy + * @param app_id application id + * @return true if application has pre_data policy + */ virtual bool IsPredataPolicy(const std::string& app_id) const = 0; /** diff --git a/src/components/policy/policy_regular/include/policy/sql_pt_queries.h b/src/components/policy/policy_regular/include/policy/sql_pt_queries.h index bada9a003a8..66637b78123 100644 --- a/src/components/policy/policy_regular/include/policy/sql_pt_queries.h +++ b/src/components/policy/policy_regular/include/policy/sql_pt_queries.h @@ -143,6 +143,19 @@ extern const std::string kSelectDBVersion; extern const std::string kUpdateDBVersion; extern const std::string kSaveModuleMeta; extern const std::string kSelectModuleMeta; +extern const std::string kInsertVehicleDataItem; +extern const std::string kSelectVehicleDataItem; +extern const std::string kDeleteVehicleDataItems; +extern const std::string kInsertVehicleDataItemParams; +extern const std::string kSelectVehicleDataItemParams; +extern const std::string kDeleteVehicleDataItemParams; +extern const std::string kSelectVehicleDataItemWithVersion; +extern const std::string kSelectPrimitiveVehicleDataItems; +extern const std::string kSelectCompositeVehicleDataItemsKey; +extern const std::string kSelectVehicleDataSchemaVersion; +extern const std::string kInsertVehicleDataSchemaVersion; +extern const std::string kSelectEndpointProperties; +extern const std::string kInsertEndpointVersion; } // namespace sql_pt } // namespace policy diff --git a/src/components/policy/policy_regular/include/policy/sql_pt_representation.h b/src/components/policy/policy_regular/include/policy/sql_pt_representation.h index dfa318454ba..216598850e5 100644 --- a/src/components/policy/policy_regular/include/policy/sql_pt_representation.h +++ b/src/components/policy/policy_regular/include/policy/sql_pt_representation.h @@ -35,15 +35,16 @@ #include #include +#include "policy/policy_table/types.h" #include "policy/pt_representation.h" #include "rpc_base/rpc_base.h" -#include "policy/policy_table/types.h" namespace policy_table = rpc::policy_table_interface_base; namespace utils { namespace dbms { class SQLDatabase; +class SQLQuery; } // namespace dbms } // namespace utils @@ -69,7 +70,6 @@ class SQLPTRepresentation : public virtual PTRepresentation { virtual int TimeoutResponse(); virtual bool SecondsBetweenRetries(std::vector* seconds); virtual bool RefreshDB(); - virtual const VehicleInfo GetVehicleInfo() const; virtual std::vector GetUserFriendlyMsg( const std::vector& msg_codes, const std::string& language); @@ -123,6 +123,9 @@ class SQLPTRepresentation : public virtual PTRepresentation { policy_table::ConsumerFriendlyMessages* messages) const; virtual bool GatherApplicationPoliciesSection( policy_table::ApplicationPoliciesSection* policies) const; + virtual bool GatherVehicleDataItems( + policy_table::VehicleDataItems* vehicle_data_items) const; + virtual bool GatherVehicleData(policy_table::VehicleData* vehicle_data) const; bool GatherAppGroup(const std::string& app_id, policy_table::Strings* app_groups) const; @@ -159,6 +162,9 @@ class SQLPTRepresentation : public virtual PTRepresentation { virtual bool SaveSpecificAppPolicy( const policy_table::ApplicationPolicies::value_type& app); virtual bool SaveDevicePolicy(const policy_table::DevicePolicy& device); + virtual bool SaveVehicleDataItems( + const policy_table::VehicleDataItems& vehicle_data_items); + virtual bool SaveVehicleData(const policy_table::VehicleData& vehicle_data); virtual bool SaveMessageString(const std::string& type, const std::string& lang, @@ -202,6 +208,26 @@ class SQLPTRepresentation : public virtual PTRepresentation { virtual bool IsDBVersionActual() const OVERRIDE; virtual bool UpdateDBVersion() const OVERRIDE; + policy_table::VehicleDataItems GetVehicleDataItem( + const std::string& name, const std::string& key) const; + bool InsertVehicleDataItem( + const policy_table::VehicleDataItem& vehicle_data_item); + bool VehicleDataItemExists( + const policy_table::VehicleDataItem& vehicle_data_item) const; + + /** + * @brief Retrieves vehicle data items of type Struct (which contains + * params) from the database including these parameters. + * @return Array of composite VehicleDataItems + */ + policy_table::VehicleDataItems SelectCompositeVehicleDataItems() const; + + /** + * @brief Retrieves vehicle data items of non Struct type from the database. + * @return Array of primitive VehicleDataItems + */ + policy_table::VehicleDataItems SelectPrimitiveVehicleDataItems() const; + private: static const std::string kDatabaseName; utils::dbms::SQLDatabase* db_; @@ -217,12 +243,17 @@ class SQLPTRepresentation : public virtual PTRepresentation { const int32_t GetDBVersion() const; bool SaveRpcs(int64_t group_id, const policy_table::Rpc& rpcs); bool SaveServiceEndpoints(const policy_table::ServiceEndpoints& endpoints); + bool SaveServiceEndpointProperties( + const policy_table::ServiceEndpointProperties& endpoint_properties); bool SaveSecondsBetweenRetries( const policy_table::SecondsBetweenRetries& seconds); bool SaveNumberOfNotificationsPerMinute( const policy_table::NumberOfNotificationsPerMinute& notifications); bool SaveMessageType(const std::string& type); bool SaveLanguage(const std::string& code); + policy_table::VehicleDataItem PopulateVDIFromQuery( + const utils::dbms::SQLQuery& query) const; + bool DeleteVehicleDataItems() const; bool is_in_memory; }; diff --git a/src/components/policy/policy_regular/include/policy/status.h b/src/components/policy/policy_regular/include/policy/status.h index c1ea2de4c14..8fd3ff559e2 100644 --- a/src/components/policy/policy_regular/include/policy/status.h +++ b/src/components/policy/policy_regular/include/policy/status.h @@ -75,41 +75,41 @@ class Status { const policy::PolicyTableStatus enum_status); /** - * @brief Destructor - */ + * @brief Destructor + */ virtual ~Status(); /** - * @brief Process event by setting next status in case event can affect - * current status or ignores the event - * @param manager Status manager pointer - * @param event Event which needs to be processed - */ + * @brief Process event by setting next status in case event can affect + * current status or ignores the event + * @param manager Status manager pointer + * @param event Event which needs to be processed + */ virtual void ProcessEvent(UpdateStatusManagerInterface* manager, UpdateEvent event) = 0; /** - * @brief Return current status as string value - * @return Status as string - */ + * @brief Return current status as string value + * @return Status as string + */ virtual const std::string get_status_string() const; /** - * @brief Return status as enum value - * @return Status as enum value - */ + * @brief Return status as enum value + * @return Status as enum value + */ virtual PolicyTableStatus get_status() const; /** - * @brief Check whether update is required in terms of status - * @return True if update is required, otherwise - false - */ + * @brief Check whether update is required in terms of status + * @return True if update is required, otherwise - false + */ virtual bool IsUpdateRequired() const; /** - * @brief Check whether update is pending in terms of status - * @return True if update is pending, otherwise - false - */ + * @brief Check whether update is pending in terms of status + * @return True if update is pending, otherwise - false + */ virtual bool IsUpdatePending() const; private: @@ -128,11 +128,11 @@ class UpToDateStatus : public Status { UpToDateStatus(); /** - * @brief Process event by setting next status in case event can affect - * current status or ignores the event - * @param manager Status manager pointer - * @param event Event which needs to be processed - */ + * @brief Process event by setting next status in case event can affect + * current status or ignores the event + * @param manager Status manager pointer + * @param event Event which needs to be processed + */ void ProcessEvent(UpdateStatusManagerInterface* manager, UpdateEvent event) OVERRIDE; }; @@ -148,18 +148,18 @@ class UpdateNeededStatus : public Status { UpdateNeededStatus(); /** - * @brief Process event by setting next status in case event can affect - * current status or ignores the event - * @param manager Status manager pointer - * @param event Event which needs to be processed - */ + * @brief Process event by setting next status in case event can affect + * current status or ignores the event + * @param manager Status manager pointer + * @param event Event which needs to be processed + */ void ProcessEvent(UpdateStatusManagerInterface* manager, UpdateEvent event) OVERRIDE; /** - * @brief Check whether update is required in terms of status - * @return True if update is required, otherwise - false - */ + * @brief Check whether update is required in terms of status + * @return True if update is required, otherwise - false + */ bool IsUpdateRequired() const OVERRIDE; }; @@ -174,26 +174,26 @@ class UpdatingStatus : public Status { UpdatingStatus(); /** - * @brief Process event by setting next status in case event can affect - * current status or ignores the event - * @param manager Status manager pointer - * @param event Event which needs to be processed - */ + * @brief Process event by setting next status in case event can affect + * current status or ignores the event + * @param manager Status manager pointer + * @param event Event which needs to be processed + */ void ProcessEvent(UpdateStatusManagerInterface* manager, UpdateEvent event) OVERRIDE; /** - * @brief Check whether update is required in terms of status - * @return True if update is required, otherwise - false - */ + * @brief Check whether update is required in terms of status + * @return True if update is required, otherwise - false + */ bool IsUpdateRequired() const OVERRIDE; /** - * @brief Check whether update is pending in terms of status - * @return True if update is pending, otherwise - false - */ + * @brief Check whether update is pending in terms of status + * @return True if update is pending, otherwise - false + */ bool IsUpdatePending() const OVERRIDE; }; -} +} // namespace policy #endif // SRC_COMPONENTS_POLICY_POLICY_EXTERNAL_INCLUDE_POLICY_STATUS_H_ diff --git a/src/components/policy/policy_regular/include/policy/update_status_manager.h b/src/components/policy/policy_regular/include/policy/update_status_manager.h index c90acd49573..0c79bf0ba44 100644 --- a/src/components/policy/policy_regular/include/policy/update_status_manager.h +++ b/src/components/policy/policy_regular/include/policy/update_status_manager.h @@ -33,15 +33,14 @@ #ifndef SRC_COMPONENTS_POLICY_POLICY_REGULAR_INCLUDE_POLICY_UPDATE_STATUS_MANAGER_H_ #define SRC_COMPONENTS_POLICY_POLICY_REGULAR_INCLUDE_POLICY_UPDATE_STATUS_MANAGER_H_ -#include "policy/update_status_manager_interface.h" #include "policy/policy_types.h" -#include "utils/lock.h" -#include "utils/threads/thread.h" -#include "utils/threads/thread_delegate.h" +#include "policy/update_status_manager_interface.h" #include "utils/conditional_variable.h" #include "utils/lock.h" #include "utils/logger.h" #include "utils/macro.h" +#include "utils/threads/thread.h" +#include "utils/threads/thread_delegate.h" namespace policy { @@ -216,6 +215,6 @@ class UpdateStatusManager : public UpdateStatusManagerInterface { bool app_registered_from_non_consented_device_; sync_primitives::Lock apps_search_in_progress_lock_; }; -} +} // namespace policy #endif // SRC_COMPONENTS_POLICY_POLICY_REGULAR_INCLUDE_POLICY_UPDATE_STATUS_MANAGER_H_ diff --git a/src/components/policy/policy_regular/include/policy/usage_statistics/counter.h b/src/components/policy/policy_regular/include/policy/usage_statistics/counter.h index 72ae5fd9e0d..bd88815012e 100644 --- a/src/components/policy/policy_regular/include/policy/usage_statistics/counter.h +++ b/src/components/policy/policy_regular/include/policy/usage_statistics/counter.h @@ -34,11 +34,11 @@ #define SRC_COMPONENTS_POLICY_POLICY_REGULAR_INCLUDE_POLICY_USAGE_STATISTICS_COUNTER_H_ #include -#include "policy/usage_statistics/statistics_manager.h" #include "policy/usage_statistics/app_stopwatch.h" +#include "policy/usage_statistics/statistics_manager.h" -#include "utils/timer.h" #include "utils/macro.h" +#include "utils/timer.h" namespace usage_statistics { diff --git a/src/components/policy/policy_regular/src/cache_manager.cc b/src/components/policy/policy_regular/src/cache_manager.cc index 2556a077097..9c73d88e637 100644 --- a/src/components/policy/policy_regular/src/cache_manager.cc +++ b/src/components/policy/policy_regular/src/cache_manager.cc @@ -33,19 +33,22 @@ #include "policy/cache_manager.h" #include -#include -#include +#include #include +#include +#include #include -#include "utils/file_system.h" -#include "utils/helpers.h" -#include "json/reader.h" +#include "interfaces/MOBILE_API.h" #include "json/features.h" +#include "json/reader.h" #include "json/writer.h" -#include "utils/logger.h" +#include "smart_objects/enum_schema_item.h" #include "utils/date_time.h" +#include "utils/file_system.h" #include "utils/gen_hash.h" +#include "utils/helpers.h" +#include "utils/logger.h" #include "utils/macro.h" #include "utils/threads/thread.h" #include "utils/threads/thread_delegate.h" @@ -104,6 +107,7 @@ CacheManager::CacheManager() , pt_(new policy_table::Table) , backup_(new SQLPTRepresentation()) , update_required(false) + , removed_custom_vd_items_() , settings_(nullptr) { LOG4CXX_AUTO_TRACE(logger_); backuper_ = new BackgroundBackuper(this); @@ -124,6 +128,20 @@ const policy_table::Strings& CacheManager::GetGroups(const PTString& app_id) { return pt_->policy_table.app_policies_section.apps[app_id].groups; } +const policy_table::Strings CacheManager::GetPolicyAppIDs() const { + LOG4CXX_AUTO_TRACE(logger_); + sync_primitives::AutoLock auto_lock(cache_lock_); + + const auto apps = pt_->policy_table.app_policies_section.apps; + + policy_table::Strings policy_app_ids; + for (const auto& app : apps) { + policy_app_ids.push_back(app.first); + } + + return policy_app_ids; +} + bool CacheManager::CanAppKeepContext(const std::string& app_id) const { CACHE_MANAGER_CHECK(false); bool result = true; @@ -282,11 +300,58 @@ bool CacheManager::ApplyUpdate(const policy_table::Table& update_pt) { pt_->policy_table.consumer_friendly_messages.assign_if_valid( update_pt.policy_table.consumer_friendly_messages); + pt_->policy_table.module_config.endpoint_properties = + update_pt.policy_table.module_config.endpoint_properties; + + // Apply update for vehicle data + if (update_pt.policy_table.vehicle_data.is_initialized()) { + policy_table::VehicleDataItems custom_items_before_apply; + if (pt_->policy_table.vehicle_data->schema_items.is_initialized()) { + custom_items_before_apply = + CollectCustomVDItems(*pt_->policy_table.vehicle_data->schema_items); + } + + if (!update_pt.policy_table.vehicle_data->schema_items.is_initialized() || + update_pt.policy_table.vehicle_data->schema_items->empty()) { + pt_->policy_table.vehicle_data->schema_items = + rpc::Optional(); + } else { + policy_table::VehicleDataItems custom_items = CollectCustomVDItems( + *update_pt.policy_table.vehicle_data->schema_items); + + pt_->policy_table.vehicle_data->schema_version = + update_pt.policy_table.vehicle_data->schema_version; + pt_->policy_table.vehicle_data->schema_items = + rpc::Optional(custom_items); + } + + policy_table::VehicleDataItems custom_items_after_apply = + *pt_->policy_table.vehicle_data->schema_items; + const auto& items_diff = CalculateCustomVdItemsDiff( + custom_items_before_apply, custom_items_after_apply); + SetRemovedCustomVdItems(items_diff); + } + ResetCalculatedPermissions(); Backup(); return true; } +policy_table::VehicleDataItems CacheManager::CollectCustomVDItems( + const policy_table::VehicleDataItems& vd_items) { + policy_table::VehicleDataItems result_items; + for (auto& item : vd_items) { + const std::string i_name = "VEHICLEDATA_" + std::string(item.name); + const std::string vd_name = boost::to_upper_copy(i_name); + const bool is_rpc_spec = + policy_table::EnumSchemaItemFactory::IsRPCSpecVehicleDataType(vd_name); + if (!is_rpc_spec) { + result_items.push_back(item); + } + } + return result_items; +} + void CacheManager::GetHMIAppTypeAfterUpdate( std::map& app_hmi_types) { LOG4CXX_AUTO_TRACE(logger_); @@ -512,14 +577,8 @@ void CacheManager::CheckPermissions(const policy_table::Strings& groups, if (rpc_param.hmi_levels.end() != hmi_iter) { result.hmi_level_permitted = PermitResult::kRpcAllowed; - policy_table::Parameters::const_iterator params_iter = - rpc_param.parameters->begin(); - policy_table::Parameters::const_iterator params_iter_end = - rpc_param.parameters->end(); - - for (; params_iter != params_iter_end; ++params_iter) { - result.list_of_allowed_params.insert( - policy_table::EnumToJsonString(*params_iter)); + for (const auto& param : *rpc_param.parameters) { + result.list_of_allowed_params.insert(std::string(param)); } } } @@ -666,20 +725,26 @@ bool CacheManager::SecondsBetweenRetries(std::vector& seconds) { return true; } -const policy::VehicleInfo CacheManager::GetVehicleInfo() const { - CACHE_MANAGER_CHECK(VehicleInfo()); +const std::vector +CacheManager::GetVehicleDataItems() const { + CACHE_MANAGER_CHECK(std::vector()); sync_primitives::AutoLock auto_lock(cache_lock_); - policy_table::ModuleConfig& module_config = pt_->policy_table.module_config; - VehicleInfo vehicle_info; - vehicle_info.vehicle_make = *module_config.vehicle_make; - vehicle_info.vehicle_model = *module_config.vehicle_model; - vehicle_info.vehicle_year = *module_config.vehicle_year; - LOG4CXX_DEBUG( - logger_, - "Vehicle info (make, model, year):" << vehicle_info.vehicle_make << "," - << vehicle_info.vehicle_model << "," - << vehicle_info.vehicle_year); - return vehicle_info; + if (pt_->policy_table.vehicle_data.is_initialized() && + pt_->policy_table.vehicle_data->schema_items.is_initialized()) { + return *(pt_->policy_table.vehicle_data->schema_items); + } + + return std::vector(); +} + +std::vector +CacheManager::GetRemovedVehicleDataItems() const { + CACHE_MANAGER_CHECK(std::vector()); + return removed_custom_vd_items_; +} + +Json::Value CacheManager::GetPolicyTableData() const { + return pt_->policy_table.ToJsonValue(); } void CacheManager::GetEnabledCloudApps( @@ -856,8 +921,47 @@ bool CacheManager::UnknownRPCPassthroughAllowed( return false; } +const boost::optional CacheManager::LockScreenDismissalEnabledState() + const { + LOG4CXX_AUTO_TRACE(logger_); + boost::optional empty; + CACHE_MANAGER_CHECK(empty); + sync_primitives::AutoLock auto_lock(cache_lock_); + policy_table::ModuleConfig& module_config = pt_->policy_table.module_config; + if (module_config.lock_screen_dismissal_enabled.is_initialized()) { + LOG4CXX_TRACE(logger_, + "state = " << *module_config.lock_screen_dismissal_enabled); + return boost::optional(*module_config.lock_screen_dismissal_enabled); + } + LOG4CXX_TRACE(logger_, "state = empty"); + return empty; +} + +const boost::optional +CacheManager::LockScreenDismissalWarningMessage( + const std::string& language) const { + LOG4CXX_AUTO_TRACE(logger_); + boost::optional empty; + CACHE_MANAGER_CHECK(empty); + + const std::string lock_screen_dismissal_warning_message = + "LockScreenDismissalWarning"; + sync_primitives::AutoLock auto_lock(cache_lock_); + + std::vector msg_codes{lock_screen_dismissal_warning_message}; + + const auto messages = GetUserFriendlyMsg(msg_codes, language); + + if (messages.empty() || messages[0].text_body.empty()) { + return empty; + } + + return boost::optional(messages[0].text_body); +} + std::vector CacheManager::GetUserFriendlyMsg( - const std::vector& msg_codes, const std::string& language) { + const std::vector& msg_codes, + const std::string& language) const { LOG4CXX_AUTO_TRACE(logger_); std::vector result; CACHE_MANAGER_CHECK(result); @@ -903,6 +1007,12 @@ std::vector CacheManager::GetUserFriendlyMsg( UserFriendlyMessage msg; msg.message_code = *it; + msg.tts = *message_string.tts; + msg.label = *message_string.label; + msg.line1 = *message_string.line1; + msg.line2 = *message_string.line2; + msg.text_body = *message_string.textBody; + result.push_back(msg); } return result; @@ -910,11 +1020,19 @@ std::vector CacheManager::GetUserFriendlyMsg( void CacheManager::GetUpdateUrls(const uint32_t service_type, EndpointUrls& out_end_points) { - std::stringstream service_type_stream; - service_type_stream << (service_type <= 9 ? "0x0" : "0x") << service_type; - - const std::string service_type_str = service_type_stream.str(); - GetUpdateUrls(service_type_str, out_end_points); + auto find_hexademical = + [service_type](policy_table::ServiceEndpoints::value_type end_point) { + uint32_t decimal; + std::istringstream(end_point.first) >> std::hex >> decimal; + return end_point.first.compare(0, 2, "0x") == 0 && + decimal == service_type; + }; + auto& end_points = pt_->policy_table.module_config.endpoints; + const auto end_point = + std::find_if(end_points.begin(), end_points.end(), find_hexademical); + if (end_point != end_points.end()) { + GetUpdateUrls(end_point->first, out_end_points); + } } void CacheManager::GetUpdateUrls(const std::string& service_type, @@ -1124,6 +1242,46 @@ void CacheManager::CheckSnapshotInitialization() { } } +policy_table::VehicleDataItems CacheManager::CalculateCustomVdItemsDiff( + const policy_table::VehicleDataItems& items_before, + const policy_table::VehicleDataItems& items_after) const { + LOG4CXX_AUTO_TRACE(logger_); + if (items_before.empty()) { + LOG4CXX_DEBUG(logger_, "No custom VD items found in policy"); + return policy_table::VehicleDataItems(); + } + + if (items_after.empty()) { + LOG4CXX_DEBUG(logger_, + "All custom VD items were removed after policy update"); + return items_before; + } + + policy_table::VehicleDataItems removed_items; + for (auto& item_to_search : items_before) { + auto item_predicate = + [&item_to_search](const policy_table::VehicleDataItem& item_to_check) { + return item_to_search.name == item_to_check.name; + }; + + auto it = + std::find_if(items_after.begin(), items_after.end(), item_predicate); + if (items_after.end() == it) { + removed_items.push_back(item_to_search); + } + } + + LOG4CXX_DEBUG(logger_, + "Found " << removed_items.size() << " removed VD items"); + return removed_items; +} + +void CacheManager::SetRemovedCustomVdItems( + const policy_table::VehicleDataItems& removed_items) { + LOG4CXX_AUTO_TRACE(logger_); + removed_custom_vd_items_ = removed_items; +} + void CacheManager::PersistData() { LOG4CXX_AUTO_TRACE(logger_); if (backup_.use_count() != 0) { @@ -1242,6 +1400,14 @@ std::shared_ptr CacheManager::GenerateSnapshot() { pt_->policy_table.usage_and_error_counts; snapshot_->policy_table.device_data = pt_->policy_table.device_data; + if (pt_->policy_table.vehicle_data.is_initialized()) { + snapshot_->policy_table.vehicle_data = + rpc::Optional(); + snapshot_->policy_table.vehicle_data->mark_initialized(); + snapshot_->policy_table.vehicle_data->schema_version = + pt_->policy_table.vehicle_data->schema_version; + } + // Set policy table type to Snapshot snapshot_->SetPolicyTableType( rpc::policy_table_interface_base::PolicyTableType::PT_SNAPSHOT); @@ -1625,6 +1791,8 @@ bool CacheManager::Init(const std::string& file_name, if (!result) { rpc::ValidationReport report("policy_table"); snapshot->ReportErrors(&report); + LOG4CXX_DEBUG(logger_, + "Validation report: " << rpc::PrettyFormat(report)); return result; } @@ -1875,6 +2043,7 @@ bool CacheManager::MergePreloadPT(const std::string& file_name) { MergeFG(new_table, current); MergeAP(new_table, current); MergeCFM(new_table, current); + MergeVD(new_table, current); Backup(); } return true; @@ -1906,8 +2075,9 @@ void CacheManager::MergeFG(const policy_table::PolicyTable& new_pt, void CacheManager::MergeAP(const policy_table::PolicyTable& new_pt, policy_table::PolicyTable& pt) { LOG4CXX_AUTO_TRACE(logger_); - pt.app_policies_section.device = const_cast( - new_pt).app_policies_section.device; + pt.app_policies_section.device = + const_cast(new_pt) + .app_policies_section.device; pt.app_policies_section.apps[kDefaultId] = const_cast(new_pt) @@ -1941,6 +2111,12 @@ void CacheManager::MergeCFM(const policy_table::PolicyTable& new_pt, } } +void CacheManager::MergeVD(const policy_table::PolicyTable& new_pt, + policy_table::PolicyTable& pt) { + LOG4CXX_AUTO_TRACE(logger_); + pt.vehicle_data.assign_if_valid(new_pt.vehicle_data); +} + const PolicySettings& CacheManager::get_settings() const { DCHECK(settings_); @@ -2006,4 +2182,46 @@ void CacheManager::BackgroundBackuper::DoBackup() { backup_notifier_.NotifyOne(); } +EncryptionRequired CacheManager::GetAppEncryptionRequiredFlag( + const std::string& application) const { + LOG4CXX_AUTO_TRACE(logger_); + sync_primitives::AutoLock auto_lock(cache_lock_); + + return pt_->policy_table.app_policies_section.apps[application] + .encryption_required; +} + +EncryptionRequired CacheManager::GetFunctionalGroupingEncryptionRequiredFlag( + const std::string& functional_group) const { + LOG4CXX_AUTO_TRACE(logger_); + sync_primitives::AutoLock auto_lock(cache_lock_); + + const auto& functional_groupings = pt_->policy_table.functional_groupings; + + const auto& grouping_itr = functional_groupings.find(functional_group); + if (grouping_itr == functional_groupings.end()) { + LOG4CXX_WARN(logger_, "Group " << functional_group << " not found"); + return EncryptionRequired(rpc::Boolean(false)); + } + + return (*grouping_itr).second.encryption_required; +} + +void CacheManager::GetApplicationParams( + const std::string& application_name, + policy_table::ApplicationParams& application_params) const { + LOG4CXX_AUTO_TRACE(logger_); + sync_primitives::AutoLock auto_lock(cache_lock_); + + const auto apps = pt_->policy_table.app_policies_section.apps; + const auto it = apps.find(application_name); + if (apps.end() == it) { + LOG4CXX_WARN(logger_, + "Application " << application_name << " was not found"); + return; + } + + application_params = (*it).second; +} + } // namespace policy diff --git a/src/components/policy/policy_regular/src/policy_helper.cc b/src/components/policy/policy_regular/src/policy_helper.cc index bae9fceb49e..b689ed81bab 100644 --- a/src/components/policy/policy_regular/src/policy_helper.cc +++ b/src/components/policy/policy_regular/src/policy_helper.cc @@ -1,4 +1,4 @@ -/* +/* Copyright (c) 2013, Ford Motor Company All rights reserved. @@ -30,13 +30,13 @@ POSSIBILITY OF SUCH DAMAGE. */ +#include "policy/policy_helper.h" +#include #include #include -#include -#include "utils/logger.h" -#include "utils/custom_string.h" -#include "policy/policy_helper.h" #include "policy/policy_manager_impl.h" +#include "utils/custom_string.h" +#include "utils/logger.h" namespace policy { @@ -46,7 +46,8 @@ namespace { CREATE_LOGGERPTR_GLOBAL(logger_, "Policy") -bool Compare(const StringsValueType& first, const StringsValueType& second) { +bool CompareStrings(const StringsValueType& first, + const StringsValueType& second) { const std::string& first_str = first; const std::string& second_str = second; return (strcasecmp(first_str.c_str(), second_str.c_str()) < 0); @@ -112,7 +113,7 @@ bool operator!=(const policy_table::ApplicationParams& first, for (; it_first != it_first_end; ++it_first) { CompareGroupName gp(*it_first); StringsConstItr it = std::find_if(it_second, it_second_end, gp); - if (it_first_end == it) { + if (it_second_end == it) { return true; } } @@ -122,8 +123,12 @@ bool operator!=(const policy_table::ApplicationParams& first, CheckAppPolicy::CheckAppPolicy( PolicyManagerImpl* pm, const std::shared_ptr update, - const std::shared_ptr snapshot) - : pm_(pm), update_(update), snapshot_(snapshot) {} + const std::shared_ptr snapshot, + CheckAppPolicyResults& out_results) + : pm_(pm) + , update_(update) + , snapshot_(snapshot) + , out_results_(out_results) {} bool policy::CheckAppPolicy::HasRevokedGroups( const policy::AppPoliciesValueType& app_policy, @@ -132,10 +137,10 @@ bool policy::CheckAppPolicy::HasRevokedGroups( snapshot_->policy_table.app_policies_section.apps.find(app_policy.first); policy_table::Strings groups_new = app_policy.second.groups; - std::sort(groups_new.begin(), groups_new.end(), Compare); + std::sort(groups_new.begin(), groups_new.end(), CompareStrings); policy_table::Strings groups_curr = (*it).second.groups; - std::sort(groups_curr.begin(), groups_curr.end(), Compare); + std::sort(groups_curr.begin(), groups_curr.end(), CompareStrings); StringsConstItr it_groups_new = groups_new.begin(); StringsConstItr it_groups_new_end = groups_new.end(); @@ -149,18 +154,7 @@ bool policy::CheckAppPolicy::HasRevokedGroups( it_groups_new, it_groups_new_end, std::back_inserter(revoked_group_list), - Compare); - - // Remove groups which are not required user consent - policy_table::Strings::iterator it_revoked = revoked_group_list.begin(); - for (; revoked_group_list.end() != it_revoked;) { - if (!IsConsentRequired(app_policy.first, std::string(*it_revoked))) { - revoked_group_list.erase(it_revoked); - it_revoked = revoked_group_list.begin(); - } else { - ++it_revoked; - } - } + CompareStrings); if (revoked_groups) { *revoked_groups = revoked_group_list; @@ -169,6 +163,76 @@ bool policy::CheckAppPolicy::HasRevokedGroups( return !revoked_group_list.empty(); } +bool policy::CheckAppPolicy::HasUpdatedGroups( + const policy::AppPoliciesValueType& app_policy, + policy_table::Strings* updated_groups) const { + AppPoliciesConstItr it = + snapshot_->policy_table.app_policies_section.apps.find(app_policy.first); + + policy_table::Strings groups_new = app_policy.second.groups; + std::sort(groups_new.begin(), groups_new.end(), CompareStrings); + + policy_table::Strings groups_curr = (*it).second.groups; + std::sort(groups_curr.begin(), groups_curr.end(), CompareStrings); + + policy_table::Strings intersection_list; + std::set_intersection(groups_new.begin(), + groups_new.end(), + groups_curr.begin(), + groups_curr.end(), + std::back_inserter(intersection_list)); + + auto IsGroupContentUpdated = + [this](const StringsValueType& groupName) -> bool { + const auto& func_group_from_update = + update_->policy_table.functional_groupings.find(groupName); + const auto& func_group_from_snapshot = + snapshot_->policy_table.functional_groupings.find(groupName); + + const auto& update_fg_rpcs = func_group_from_update->second.rpcs; + const auto& snapshot_fg_rpcs = func_group_from_snapshot->second.rpcs; + + if (update_fg_rpcs.is_null() || snapshot_fg_rpcs.is_null()) { + return !(update_fg_rpcs.is_null() && snapshot_fg_rpcs.is_null()); + } + + if (update_fg_rpcs.size() != snapshot_fg_rpcs.size()) { + return true; + } + + for (const auto& rpc : update_fg_rpcs) { + const auto& old_rpc = snapshot_fg_rpcs.find(rpc.first); + if (snapshot_fg_rpcs.end() == old_rpc) { + return true; + } + + const bool hmi_levels_same = + old_rpc->second.hmi_levels == rpc.second.hmi_levels; + const bool parameters_same = + *(old_rpc->second.parameters) == *(rpc.second.parameters); + + if (!hmi_levels_same || !parameters_same) { + return true; + } + } + + return false; + }; + + policy_table::Strings updated_group_list; + for (const auto& item : intersection_list) { + if (IsGroupContentUpdated(item)) { + updated_group_list.push_back(item); + } + } + + if (updated_groups) { + *updated_groups = updated_group_list; + } + + return !updated_group_list.empty(); +} + bool policy::CheckAppPolicy::HasNewGroups( const policy::AppPoliciesValueType& app_policy, policy_table::Strings* new_groups) const { @@ -176,10 +240,10 @@ bool policy::CheckAppPolicy::HasNewGroups( snapshot_->policy_table.app_policies_section.apps.find(app_policy.first); policy_table::Strings groups_new = app_policy.second.groups; - std::sort(groups_new.begin(), groups_new.end(), Compare); + std::sort(groups_new.begin(), groups_new.end(), CompareStrings); policy_table::Strings groups_curr = (*it).second.groups; - std::sort(groups_curr.begin(), groups_curr.end(), Compare); + std::sort(groups_curr.begin(), groups_curr.end(), CompareStrings); StringsConstItr it_groups_new = groups_new.begin(); StringsConstItr it_groups_new_end = groups_new.end(); @@ -193,7 +257,7 @@ bool policy::CheckAppPolicy::HasNewGroups( it_groups_curr, it_groups_curr_end, std::back_inserter(new_group_list), - Compare); + CompareStrings); if (new_groups) { *new_groups = new_group_list; @@ -205,14 +269,23 @@ bool policy::CheckAppPolicy::HasNewGroups( bool policy::CheckAppPolicy::HasConsentNeededGroups( const policy::AppPoliciesValueType& app_policy) const { policy_table::Strings new_groups; - if (!HasNewGroups(app_policy, &new_groups)) { + policy_table::Strings updated_groups; + if (!HasNewGroups(app_policy, &new_groups) && + !HasUpdatedGroups(app_policy, &updated_groups)) { return false; } - StringsConstItr it_new = new_groups.begin(); - StringsConstItr it_new_end = new_groups.end(); - for (; it_new != it_new_end; ++it_new) { - if (IsConsentRequired(app_policy.first, *it_new)) { + policy_table::Strings groups_to_check_consent; + std::set_union(new_groups.begin(), + new_groups.end(), + updated_groups.begin(), + updated_groups.end(), + std::back_inserter(groups_to_check_consent)); + + StringsConstItr it = groups_to_check_consent.begin(); + StringsConstItr it_end = groups_to_check_consent.end(); + for (; it != it_end; ++it) { + if (IsConsentRequired(app_policy.first, *it)) { return true; } } @@ -263,30 +336,18 @@ bool CheckAppPolicy::IsKnownAppication( void policy::CheckAppPolicy::NotifySystem( const policy::AppPoliciesValueType& app_policy) const { - pm_->listener()->OnPendingPermissionChange(app_policy.first); -} - -void CheckAppPolicy::SendPermissionsToApp( - const std::string& app_id, const policy_table::Strings& groups) const { - const std::string device_id = pm_->GetCurrentDeviceId(app_id); - if (device_id.empty()) { - LOG4CXX_WARN(logger_, - "Couldn't find device info for application id: " << app_id); + auto& listener = *pm_->listener(); + const auto devices_ids = listener.GetDevicesIds(app_policy.first); + if (devices_ids.empty()) { + LOG4CXX_WARN( + logger_, + "Couldn't find device info for application id: " << app_policy.first); return; } - std::vector group_permissons; - pm_->GetPermissionsForApp(device_id, app_id, group_permissons); - - Permissions notification_data; - pm_->PrepareNotificationData(update_->policy_table.functional_groupings, - groups, - group_permissons, - notification_data); - LOG4CXX_INFO(logger_, "Send notification for application_id: " << app_id); - // Default_hmi is Ford-specific and should not be used with basic policy - const std::string default_hmi; - pm_->listener()->OnPermissionsUpdated(app_id, notification_data, default_hmi); + for (const auto& device_id : devices_ids) { + listener.OnPendingPermissionChange(device_id, app_policy.first); + } } bool CheckAppPolicy::IsAppRevoked( @@ -317,6 +378,13 @@ bool CheckAppPolicy::NicknamesMatch( return true; } +void CheckAppPolicy::AddResult(const std::string& app_id, + PermissionsCheckResult result) { + LOG4CXX_AUTO_TRACE(logger_); + const auto item = std::make_pair(app_id, result); + out_results_.insert(item); +} + bool CheckAppPolicy::operator()(const AppPoliciesValueType& app_policy) { const std::string app_id = app_policy.first; @@ -328,13 +396,13 @@ bool CheckAppPolicy::operator()(const AppPoliciesValueType& app_policy) { if (!IsPredefinedApp(app_policy) && IsAppRevoked(app_policy)) { SetPendingPermissions(app_policy, RESULT_APP_REVOKED); - NotifySystem(app_policy); + AddResult(app_id, RESULT_APP_REVOKED); return true; } if (!IsPredefinedApp(app_policy) && !NicknamesMatch(app_policy)) { SetPendingPermissions(app_policy, RESULT_NICKNAME_MISMATCH); - NotifySystem(app_policy); + AddResult(app_id, RESULT_NICKNAME_MISMATCH); return true; } @@ -345,49 +413,53 @@ bool CheckAppPolicy::operator()(const AppPoliciesValueType& app_policy) { if (is_request_type_changed) { SetPendingPermissions(app_policy, RESULT_REQUEST_TYPE_CHANGED); + AddResult(app_id, RESULT_REQUEST_TYPE_CHANGED); } if (is_request_subtype_changed) { SetPendingPermissions(app_policy, RESULT_REQUEST_SUBTYPE_CHANGED); - } - - if (is_request_type_changed || is_request_subtype_changed) { - NotifySystem(app_policy); + AddResult(app_id, RESULT_REQUEST_SUBTYPE_CHANGED); } } if (RESULT_NO_CHANGES == result) { - LOG4CXX_INFO(logger_, - "Permissions for application:" << app_id - << " wasn't changed."); + LOG4CXX_INFO( + logger_, + "Permissions for application:" << app_id << " wasn't changed."); + AddResult(app_id, RESULT_NO_CHANGES); return true; } - LOG4CXX_INFO(logger_, - "Permissions for application:" << app_id - << " have been changed."); + LOG4CXX_INFO( + logger_, + "Permissions for application:" << app_id << " have been changed."); if (IsPredefinedApp(app_policy)) { - for (const policy_table::ApplicationPolicies::value_type& app : - snapshot_->policy_table.app_policies_section.apps) { - if (app_policy.first == app.second.get_string()) { - if (RESULT_CONSENT_NOT_REQIURED != result) { - SetPendingPermissions(app, result); - NotifySystem(app); - } - SendPermissionsToApp(app.first, app_policy.second.groups); - } + const auto& snapshot_app_policy_begin = + snapshot_->policy_table.app_policies_section.apps.begin(); + const auto& snapshot_app_policy_end = + snapshot_->policy_table.app_policies_section.apps.end(); + + auto find_app = [&app_id](AppPoliciesValueType& app) { + return app_id == app.second.get_string(); + }; + + const auto& app = std::find_if( + snapshot_app_policy_begin, snapshot_app_policy_end, find_app); + + if ((snapshot_app_policy_end != app) && + (RESULT_CONSENT_NOT_REQUIRED != result)) { + SetPendingPermissions(*app, result); + AddResult(app_id, RESULT_CONSENT_NEEDED); } return true; } - if (!IsPredefinedApp(app_policy) && RESULT_CONSENT_NOT_REQIURED != result) { - SetPendingPermissions(app_policy, result); - NotifySystem(app_policy); + SetPendingPermissions(app_policy, result); + if (RESULT_CONSENT_NOT_REQUIRED != result) { + AddResult(app_id, RESULT_CONSENT_NEEDED); + return true; } - // Don't sent notification for predefined apps (e.g. default, device etc.) - if (!IsPredefinedApp(app_policy)) { - SendPermissionsToApp(app_policy.first, app_policy.second.groups); - } + AddResult(app_id, result); return true; } @@ -445,14 +517,18 @@ void policy::CheckAppPolicy::SetPendingPermissions( pm_->app_permissions_diff_lock_.Release(); } -policy::CheckAppPolicy::PermissionsCheckResult -policy::CheckAppPolicy::CheckPermissionsChanges( +policy::PermissionsCheckResult policy::CheckAppPolicy::CheckPermissionsChanges( const policy::AppPoliciesValueType& app_policy) const { - bool has_revoked_groups = HasRevokedGroups(app_policy); + const bool has_revoked_groups = HasRevokedGroups(app_policy); + + const bool has_consent_needed_groups = HasConsentNeededGroups(app_policy); + + const bool has_new_groups = HasNewGroups(app_policy); - bool has_consent_needed_groups = HasConsentNeededGroups(app_policy); + const bool has_updated_groups = HasUpdatedGroups(app_policy); - bool has_new_groups = HasNewGroups(app_policy); + const bool encryption_required_flag_changed = + IsEncryptionRequiredFlagChanged(app_policy); if (has_revoked_groups && has_consent_needed_groups) { return RESULT_PERMISSIONS_REVOKED_AND_CONSENT_NEEDED; @@ -460,8 +536,10 @@ policy::CheckAppPolicy::CheckPermissionsChanges( return RESULT_PERMISSIONS_REVOKED; } else if (has_consent_needed_groups) { return RESULT_CONSENT_NEEDED; - } else if (has_new_groups) { - return RESULT_CONSENT_NOT_REQIURED; + } else if (has_new_groups || has_updated_groups) { + return RESULT_CONSENT_NOT_REQUIRED; + } else if (encryption_required_flag_changed) { + return RESULT_ENCRYPTION_REQUIRED_FLAG_CHANGED; } return RESULT_NO_CHANGES; @@ -530,6 +608,130 @@ bool CheckAppPolicy::IsRequestSubTypeChanged( return diff.size(); } +bool CheckAppPolicy::IsEncryptionRequiredFlagChanged( + const AppPoliciesValueType& app_policy) const { + auto get_app_encryption_needed = + [](const std::string& policy_app_id, + policy_table::ApplicationPolicies& policies) + -> rpc::Optional { + auto it = policies.find(policy_app_id); + if (policies.end() == it) { + LOG4CXX_WARN(logger_, "App is not present in policies" << policy_app_id); + return rpc::Optional(false); + } + return it->second.encryption_required; + }; + + auto get_app_groups = + [](const std::string& policy_app_id, + policy_table::ApplicationPolicies& policies) -> policy_table::Strings { + policy_table::Strings result; + auto it = policies.find(policy_app_id); + if (policies.end() == it) { + LOG4CXX_WARN(logger_, "App is not present in policies" << policy_app_id); + return result; + } + auto& groups = it->second.groups; + std::copy(groups.begin(), groups.end(), std::back_inserter(result)); + return result; + }; + + auto get_app_rpcs = [](const std::string group_name, + const FunctionalGroupings& groups) + -> rpc::Optional { + auto it = groups.find(group_name); + if (it == groups.end()) { + return rpc::Optional(); + } + return rpc::Optional(it->second); + }; + + const auto snapshot_groups = get_app_groups( + app_policy.first, snapshot_->policy_table.app_policies_section.apps); + const auto update_groups = get_app_groups( + app_policy.first, update_->policy_table.app_policies_section.apps); + + auto get_resulting_encryption_required_flag_for_app_groups = + [this, &get_app_rpcs]( + const rpc::policy_table_interface_base::Strings& app_groups, + const std::shared_ptr pt) { + for (const auto& group : app_groups) { + const auto rpcs = + get_app_rpcs(group, pt->policy_table.functional_groupings); + if (*rpcs->encryption_required) { + return true; + } + } + + return false; + }; + + auto group_res_en_flag_changed = + [this, &get_resulting_encryption_required_flag_for_app_groups]( + const rpc::policy_table_interface_base::Strings& snapshot_groups, + const rpc::policy_table_interface_base::Strings& update_groups) { + return get_resulting_encryption_required_flag_for_app_groups( + snapshot_groups, snapshot_) != + get_resulting_encryption_required_flag_for_app_groups( + update_groups, update_); + }; + + const auto snapshot_app_encryption_needed = get_app_encryption_needed( + app_policy.first, snapshot_->policy_table.app_policies_section.apps); + const auto update_app_encryption_needed = get_app_encryption_needed( + app_policy.first, update_->policy_table.app_policies_section.apps); + + const bool app_encryption_needed_changed = + (snapshot_app_encryption_needed.is_initialized() != + update_app_encryption_needed.is_initialized()) || + (*snapshot_app_encryption_needed != *update_app_encryption_needed); + + if ((!update_app_encryption_needed.is_initialized() || + *update_app_encryption_needed) && + group_res_en_flag_changed(snapshot_groups, update_groups)) { + return true; + } + + return app_encryption_needed_changed; +} + +void FillActionsForAppPolicies::operator()( + const policy::CheckAppPolicyResults::value_type& value) { + const std::string app_id = value.first; + const auto app_policy = app_policies_.find(app_id); + + if (app_policies_.end() == app_policy) { + return; + } + + if (IsPredefinedApp(*app_policy)) { + return; + } + + switch (value.second) { + case RESULT_APP_REVOKED: + case RESULT_NICKNAME_MISMATCH: + actions_[app_id].is_notify_system = true; + return; + case RESULT_CONSENT_NEEDED: + case RESULT_PERMISSIONS_REVOKED_AND_CONSENT_NEEDED: + actions_[app_id].is_consent_needed = true; + break; + case RESULT_CONSENT_NOT_REQUIRED: + case RESULT_PERMISSIONS_REVOKED: + case RESULT_REQUEST_TYPE_CHANGED: + case RESULT_REQUEST_SUBTYPE_CHANGED: + case RESULT_ENCRYPTION_REQUIRED_FLAG_CHANGED: + break; + case RESULT_NO_CHANGES: + default: + return; + } + + actions_[app_id].is_notify_system = true; + actions_[app_id].is_send_permissions_to_app = true; +} + FillNotificationData::FillNotificationData(Permissions& data, GroupConsent group_state, GroupConsent undefined_group_consent) @@ -595,7 +797,7 @@ void FillNotificationData::UpdateParameters( ParametersConstItr it_parameters_end = in_parameters.end(); for (; it_parameters != it_parameters_end; ++it_parameters) { - out_parameter.insert(policy_table::EnumToJsonString(*it_parameters)); + out_parameter.insert(*it_parameters); } } @@ -713,10 +915,31 @@ bool ProcessFunctionalGroup::operator()(const StringsValueType& group_name) { FillNotificationData filler( data_, GetGroupState(group_name_str), undefined_group_consent_); std::for_each(rpcs.begin(), rpcs.end(), filler); + FillEncryptionFlagForRpcs(rpcs, (*it).second.encryption_required); } return true; } +void ProcessFunctionalGroup::FillEncryptionFlagForRpcs( + const policy_table::Rpc& rpcs, + const EncryptionRequired encryption_required) { + auto update_encryption_required = [](EncryptionRequired& current, + const EncryptionRequired& incoming) { + if (!incoming.is_initialized()) { + return; + } + if (current.is_initialized() && *current) { + return; + } + current = incoming; + }; + + for (const auto& rpc : rpcs) { + auto& item = data_[rpc.first]; + update_encryption_required(item.require_encryption, encryption_required); + } +} + GroupConsent ProcessFunctionalGroup::GetGroupState( const std::string& group_name) { std::vector::const_iterator it = @@ -853,4 +1076,4 @@ bool UnwrapAppPolicies(policy_table::ApplicationPolicies& app_policies) { return true; } -} +} // namespace policy 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 10e1c73e9ac..2fef8de1d8b 100644 --- a/src/components/policy/policy_regular/src/policy_manager_impl.cc +++ b/src/components/policy/policy_regular/src/policy_manager_impl.cc @@ -32,34 +32,27 @@ #include "policy/policy_manager_impl.h" #include -#include -#include #include #include +#include +#include #include "json/reader.h" #include "json/writer.h" +#include "policy/policy_helper.h" #include "policy/policy_table.h" #include "policy/pt_representation.h" -#include "policy/policy_helper.h" +#include "utils/date_time.h" #include "utils/file_system.h" #include "utils/logger.h" -#include "utils/date_time.h" +#include "config_profile/profile.h" #include "policy/cache_manager.h" #include "policy/update_status_manager.h" -#include "config_profile/profile.h" #include "utils/timer_task_impl.h" #include "policy/access_remote.h" #include "policy/access_remote_impl.h" -policy::PolicyManager* CreateManager() { - return new policy::PolicyManagerImpl(); -} -void DeleteManager(policy::PolicyManager* pm) { - delete pm; -} - namespace { const uint32_t kDefaultRetryTimeoutInMSec = 60u * date_time::MILLISECONDS_IN_SECOND; @@ -77,12 +70,12 @@ PolicyManagerImpl::PolicyManagerImpl() new AccessRemoteImpl(std::static_pointer_cast(cache_))) , retry_sequence_timeout_(kDefaultRetryTimeoutInMSec) , retry_sequence_index_(0) - , timer_retry_sequence_("Retry sequence timer", - new timer::TimerTaskImpl( - this, &PolicyManagerImpl::RetrySequence)) + , timer_retry_sequence_( + "Retry sequence timer", + new timer::TimerTaskImpl( + this, &PolicyManagerImpl::OnPTUIterationTimeout)) , ignition_check(true) , retry_sequence_url_(0, 0, "") - , wrong_ptu_update_received_(false) , send_on_update_sent_out_(false) , trigger_ptu_(false) {} @@ -164,7 +157,9 @@ void FilterInvalidFunctions(policy_table::Rpc& rpcs) { * schema * @param rpc_parameters parameters to filter */ -void FilterInvalidRPCParameters(policy_table::RpcParameters& rpc_parameters) { +void FilterInvalidRPCParameters( + policy_table::RpcParameters& rpc_parameters, + const std::vector& vehicle_data_items) { policy_table::HmiLevels valid_hmi_levels; for (const auto& hmi_level : rpc_parameters.hmi_levels) { if (hmi_level.is_valid()) { @@ -173,10 +168,31 @@ void FilterInvalidRPCParameters(policy_table::RpcParameters& rpc_parameters) { } rpc_parameters.hmi_levels.swap(valid_hmi_levels); + auto ParamExists = + [&vehicle_data_items](const rpc::String<0, 255>& param_name) { + policy_table::Parameter parameter_enum; + if (policy_table::EnumFromJsonString(param_name, ¶meter_enum)) { + return true; + } + + // In case when this collection is empty that means collection is not + // initialized + if (vehicle_data_items.empty()) { + return false; + } + + for (const auto& vdi : vehicle_data_items) { + if (param_name == vdi.name) { + return true; + } + } + return false; + }; + policy_table::Parameters valid_params; const policy_table::Parameters& params = *(rpc_parameters.parameters); for (const auto& param : params) { - if (param.is_valid()) { + if (param.is_valid() && ParamExists(param)) { valid_params.push_back(param); } } @@ -261,7 +277,9 @@ void FilterInvalidApplicationParameters( * @brief FilterPolicyTable filter values that not present in schema * @param pt policy table to filter */ -void FilterPolicyTable(policy_table::PolicyTable& pt) { +void FilterPolicyTable( + policy_table::PolicyTable& pt, + const std::vector& current_vd_items) { policy_table::ModuleConfig& module_config = pt.module_config; if (module_config.is_initialized() && module_config.notifications_per_minute_by_priority.is_initialized()) { @@ -280,14 +298,24 @@ void FilterPolicyTable(policy_table::PolicyTable& pt) { policy_table::Rpc& rpcs = group.second.rpcs; FilterInvalidFunctions(rpcs); + policy_table::VehicleDataItems vehicle_data_items; + + if (!pt.vehicle_data->struct_empty()) { + vehicle_data_items = + pt.vehicle_data.is_initialized() && + pt.vehicle_data->schema_items.is_initialized() + ? *pt.vehicle_data->schema_items + : current_vd_items; + } + for (auto& func : rpcs) { - FilterInvalidRPCParameters(func.second); + FilterInvalidRPCParameters(func.second, vehicle_data_items); } } } -bool PolicyManagerImpl::LoadPT(const std::string& file, - const BinaryMessage& pt_content) { +PolicyManager::PtProcessingResult PolicyManagerImpl::LoadPT( + const std::string& file, const BinaryMessage& pt_content) { LOG4CXX_INFO(logger_, "LoadPT of size " << pt_content.size()); LOG4CXX_DEBUG( logger_, @@ -304,101 +332,238 @@ bool PolicyManagerImpl::LoadPT(const std::string& file, std::shared_ptr pt_update = ParseArray(pt_content); #endif if (!pt_update) { - LOG4CXX_WARN(logger_, "Parsed table pointer is 0."); - update_status_manager_.OnWrongUpdateReceived(); - return false; + LOG4CXX_WARN(logger_, "Parsed table pointer is NULL."); + ; + return PtProcessingResult::kWrongPtReceived; } file_system::DeleteFile(file); - FilterPolicyTable(pt_update->policy_table); + auto current_vd_items = GetVehicleDataItems(); + + FilterPolicyTable(pt_update->policy_table, current_vd_items); if (!IsPTValid(pt_update, policy_table::PT_UPDATE)) { - wrong_ptu_update_received_ = true; - update_status_manager_.OnWrongUpdateReceived(); - return false; + LOG4CXX_WARN(logger_, "Received policy table update is not valid"); + return PtProcessingResult::kWrongPtReceived; } - update_status_manager_.OnValidUpdateReceived(); - cache_->SaveUpdateRequired(false); - // Update finished, no need retry if (timer_retry_sequence_.is_running()) { LOG4CXX_INFO(logger_, "Stop retry sequence"); timer_retry_sequence_.Stop(); } - { - sync_primitives::AutoLock lock(apps_registration_lock_); + cache_->SaveUpdateRequired(false); - // Get current DB data, since it could be updated during awaiting of PTU - std::shared_ptr policy_table_snapshot = - cache_->GenerateSnapshot(); - if (!policy_table_snapshot) { - LOG4CXX_ERROR( - logger_, - "Failed to create snapshot of policy table, trying another exchange"); - ForcePTExchange(); - return false; - } + sync_primitives::AutoLock lock(apps_registration_lock_); - // Checking of difference between PTU and current policy state - // Must to be done before PTU applying since it is possible, that functional - // groups, which had been present before are absent in PTU and will be - // removed after update. So in case of revoked groups system has to know - // names and ids of revoked groups before they will be removed. - CheckPermissionsChanges(pt_update, policy_table_snapshot); + // Get current DB data, since it could be updated during awaiting of PTU + auto policy_table_snapshot = cache_->GenerateSnapshot(); + if (!policy_table_snapshot) { + LOG4CXX_ERROR( + logger_, + "Failed to create snapshot of policy table, trying another exchange"); + return PtProcessingResult::kNewPtRequired; + } - // Replace current data with updated - if (!cache_->ApplyUpdate(*pt_update)) { - LOG4CXX_WARN( - logger_, - "Unsuccessful save of updated policy table, trying another exchange"); - ForcePTExchange(); - return false; - } + // Checking of difference between PTU and current policy state + // Must to be done before PTU applying since it is possible, that functional + // groups, which had been present before are absent in PTU and will be + // removed after update. So in case of revoked groups system has to know + // names and ids of revoked groups before they will be removed. + const auto results = + CheckPermissionsChanges(pt_update, policy_table_snapshot); + + // Replace current data with updated + if (!cache_->ApplyUpdate(*pt_update)) { + LOG4CXX_WARN( + logger_, + "Unsuccessful save of updated policy table, trying another exchange"); + return PtProcessingResult::kNewPtRequired; + } + CheckPermissionsChangesAfterUpdate(*pt_update, *policy_table_snapshot); - listener_->OnCertificateUpdated( - *(pt_update->policy_table.module_config.certificate)); + ProcessAppPolicyCheckResults( + results, pt_update->policy_table.app_policies_section.apps); - std::map app_hmi_types; - cache_->GetHMIAppTypeAfterUpdate(app_hmi_types); - if (!app_hmi_types.empty()) { - LOG4CXX_INFO(logger_, "app_hmi_types is full calling OnUpdateHMIAppType"); - listener_->OnUpdateHMIAppType(app_hmi_types); - } else { - LOG4CXX_INFO(logger_, "app_hmi_types empty" << pt_content.size()); - } + listener_->OnCertificateUpdated( + *(pt_update->policy_table.module_config.certificate)); - std::vector enabled_apps; - cache_->GetEnabledCloudApps(enabled_apps); - for (auto it = enabled_apps.begin(); it != enabled_apps.end(); ++it) { - SendAuthTokenUpdated(*it); - } + std::map app_hmi_types; + cache_->GetHMIAppTypeAfterUpdate(app_hmi_types); + if (!app_hmi_types.empty()) { + LOG4CXX_INFO(logger_, "app_hmi_types is full calling OnUpdateHMIAppType"); + listener_->OnUpdateHMIAppType(app_hmi_types); + } else { + LOG4CXX_INFO(logger_, "app_hmi_types empty" << pt_content.size()); } + std::vector enabled_apps; + cache_->GetEnabledCloudApps(enabled_apps); + for (auto it = enabled_apps.begin(); it != enabled_apps.end(); ++it) { + SendAuthTokenUpdated(*it); + } + + return PtProcessingResult::kSuccess; +} + +void PolicyManagerImpl::OnPTUFinished(const PtProcessingResult ptu_result) { + LOG4CXX_AUTO_TRACE(logger_); + + if (PtProcessingResult::kWrongPtReceived == ptu_result) { + LOG4CXX_DEBUG(logger_, "Wrong PT was received"); + update_status_manager_.OnWrongUpdateReceived(); + return; + } + + update_status_manager_.OnValidUpdateReceived(); + + if (PtProcessingResult::kNewPtRequired == ptu_result) { + LOG4CXX_DEBUG(logger_, "New PTU interation is required"); + ForcePTExchange(); + return; + } + + ResumePendingAppPolicyActions(); + // If there was a user request for policy table update, it should be started // right after current update is finished if (update_status_manager_.IsUpdateRequired()) { + LOG4CXX_DEBUG(logger_, + "PTU was successful and new PTU iteration was scheduled"); StartPTExchange(); - return true; + return; } RefreshRetrySequence(); - return true; } -void PolicyManagerImpl::CheckPermissionsChanges( +void PolicyManagerImpl::ProcessAppPolicyCheckResults( + const CheckAppPolicyResults& results, + const rpc::policy_table_interface_base::ApplicationPolicies& app_policies) { + LOG4CXX_AUTO_TRACE(logger_); + + ApplicationsPoliciesActions actions_for_apps_policies; + FillActionsForAppPolicies filler(actions_for_apps_policies, app_policies); + + std::for_each(results.begin(), results.end(), filler); + + ProcessActionsForAppPolicies(actions_for_apps_policies, app_policies); +} + +void PolicyManagerImpl::ProcessActionsForAppPolicies( + const ApplicationsPoliciesActions& actions, + const policy_table::ApplicationPolicies& app_policies) { + notify_system_list_.clear(); + send_permissions_list_.clear(); + + ApplicationsPoliciesActions::const_iterator it_actions = actions.begin(); + for (; it_actions != actions.end(); ++it_actions) { + auto app_policy = app_policies.find(it_actions->first); + if (app_policies.end() == app_policy) { + continue; + } + + const auto devices_ids = listener()->GetDevicesIds(app_policy->first); + for (const auto& device_id : devices_ids) { + if (it_actions->second.is_consent_needed) { + // Post-check after ExternalConsent consent changes + const std::string& policy_app_id = app_policy->first; + if (!IsConsentNeeded(device_id, policy_app_id)) { + sync_primitives::AutoLock lock(app_permissions_diff_lock_); + + PendingPermissions::iterator app_id_diff = + app_permissions_diff_.find(policy_app_id); + + if (app_permissions_diff_.end() != app_id_diff) { + app_id_diff->second.appPermissionsConsentNeeded = false; + } + } + } + if (it_actions->second.is_notify_system) { + notify_system_list_.push_back(std::make_pair(device_id, *app_policy)); + } + if (it_actions->second.is_send_permissions_to_app) { + send_permissions_list_.push_back( + std::make_pair(device_id, *app_policy)); + } + } + } +} + +void PolicyManagerImpl::ResumePendingAppPolicyActions() { + LOG4CXX_AUTO_TRACE(logger_); + + for (auto& notify_system_params : notify_system_list_) { + NotifySystem(notify_system_params.first, notify_system_params.second); + } + notify_system_list_.clear(); + + for (auto& send_permissions_params : send_permissions_list_) { + SendPermissionsToApp(send_permissions_params.first, + send_permissions_params.second); + } + send_permissions_list_.clear(); +} + +void PolicyManagerImpl::NotifySystem( + const std::string& device_id, + const PolicyManagerImpl::AppPoliciesValueType& app_policy) const { + listener()->OnPendingPermissionChange(device_id, app_policy.first); +} + +void PolicyManagerImpl::SendPermissionsToApp( + const std::string& device_id, + const PolicyManagerImpl::AppPoliciesValueType& app_policy) { + const std::string app_id = app_policy.first; + + std::vector group_permissons; + GetPermissionsForApp(device_id, app_id, group_permissons); + + Permissions notification_data; + + // Need to get rid of this call + auto policy_table_snapshot = cache_->GenerateSnapshot(); + + PrepareNotificationData( + policy_table_snapshot->policy_table.functional_groupings, + app_policy.second.groups, + group_permissons, + notification_data); + + std::string default_hmi; + default_hmi = "NONE"; + listener()->OnPermissionsUpdated( + device_id, app_id, notification_data, default_hmi); +} + +CheckAppPolicyResults PolicyManagerImpl::CheckPermissionsChanges( const std::shared_ptr pt_update, const std::shared_ptr snapshot) { - LOG4CXX_INFO(logger_, "Checking incoming permissions."); + LOG4CXX_AUTO_TRACE(logger_); // Replace predefined policies with its actual setting, e.g. "123":"default" // to actual values of default section UnwrapAppPolicies(pt_update->policy_table.app_policies_section.apps); + CheckAppPolicyResults out_results; + std::for_each(pt_update->policy_table.app_policies_section.apps.begin(), pt_update->policy_table.app_policies_section.apps.end(), - CheckAppPolicy(this, pt_update, snapshot)); + CheckAppPolicy(this, pt_update, snapshot, out_results)); + + return out_results; +} + +void PolicyManagerImpl::CheckPermissionsChangesAfterUpdate( + const policy_table::Table& update, const policy_table::Table& snapshot) { + const auto new_lock_screen_dismissal_enabled = + update.policy_table.module_config.lock_screen_dismissal_enabled; + const auto old_lock_screen_dismissal_enabled = + snapshot.policy_table.module_config.lock_screen_dismissal_enabled; + if (new_lock_screen_dismissal_enabled != old_lock_screen_dismissal_enabled) { + listener()->OnLockScreenDismissalStateChanged(); + } } void PolicyManagerImpl::PrepareNotificationData( @@ -406,7 +571,7 @@ void PolicyManagerImpl::PrepareNotificationData( const policy_table::Strings& group_names, const std::vector& group_permission, Permissions& notification_data) { - LOG4CXX_INFO(logger_, "Preparing data for notification."); + LOG4CXX_AUTO_TRACE(logger_); ProcessFunctionalGroup processor(groups, group_permission, notification_data); std::for_each(group_names.begin(), group_names.end(), processor); } @@ -422,7 +587,7 @@ void PolicyManagerImpl::GetUpdateUrls(const uint32_t service_type, cache_->GetUpdateUrls(service_type, out_end_points); } -bool PolicyManagerImpl::RequestPTUpdate() { +bool PolicyManagerImpl::RequestPTUpdate(const PTUIterationType iteration_type) { LOG4CXX_AUTO_TRACE(logger_); std::shared_ptr policy_table_snapshot = cache_->GenerateSnapshot(); @@ -441,7 +606,7 @@ bool PolicyManagerImpl::RequestPTUpdate() { BinaryMessage update(message_string.begin(), message_string.end()); - listener_->OnSnapshotCreated(update); + listener_->OnSnapshotCreated(update, iteration_type); return true; } @@ -483,7 +648,8 @@ void PolicyManagerImpl::StartPTExchange() { } if (update_status_manager_.IsUpdateRequired()) { - if (RequestPTUpdate() && !timer_retry_sequence_.is_running()) { + if (RequestPTUpdate(PTUIterationType::DefaultIteration) && + !timer_retry_sequence_.is_running()) { // Start retry sequency const uint32_t timeout_msec = NextRetryTimeout(); @@ -514,9 +680,9 @@ void PolicyManagerImpl::OnAppsSearchCompleted(const bool trigger_ptu) { } void PolicyManagerImpl::OnAppRegisteredOnMobile( - const std::string& application_id) { + const std::string& device_id, const std::string& application_id) { StartPTExchange(); - SendNotificationOnPermissionsUpdated(application_id); + SendNotificationOnPermissionsUpdated(device_id, application_id); } void PolicyManagerImpl::OnDeviceSwitching(const std::string& device_id_from, @@ -550,9 +716,18 @@ const std::vector PolicyManagerImpl::GetAppRequestSubTypes( cache_->GetAppRequestSubTypes(policy_app_id, request_subtypes); return request_subtypes; } +const std::vector +PolicyManagerImpl::GetVehicleDataItems() const { + return cache_->GetVehicleDataItems(); +} -const VehicleInfo PolicyManagerImpl::GetVehicleInfo() const { - return cache_->GetVehicleInfo(); +std::vector +PolicyManagerImpl::GetRemovedVehicleDataItems() const { + return cache_->GetRemovedVehicleDataItems(); +} + +Json::Value PolicyManagerImpl::GetPolicyTableData() const { + return cache_->GetPolicyTableData(); } void PolicyManagerImpl::GetEnabledCloudApps( @@ -669,15 +844,8 @@ bool PolicyManagerImpl::ResetUserConsent() { } void PolicyManagerImpl::SendNotificationOnPermissionsUpdated( - const std::string& application_id) { + const std::string& device_id, const std::string& application_id) { LOG4CXX_AUTO_TRACE(logger_); - const std::string device_id = GetCurrentDeviceId(application_id); - if (device_id.empty()) { - LOG4CXX_WARN(logger_, - "Couldn't find device info for application id " - "'" << application_id << "'"); - return; - } std::vector app_group_permissions; GetPermissionsForApp(device_id, application_id, app_group_permissions); @@ -686,12 +854,8 @@ void PolicyManagerImpl::SendNotificationOnPermissionsUpdated( cache_->GetFunctionalGroupings(functional_groupings); policy_table::Strings app_groups; - std::vector::const_iterator it = - app_group_permissions.begin(); - std::vector::const_iterator it_end = - app_group_permissions.end(); - for (; it != it_end; ++it) { - app_groups.push_back((*it).group_name); + for (const auto& group_permission : app_group_permissions) { + app_groups.push_back(group_permission.group_name); } Permissions notification_data; @@ -701,19 +865,19 @@ void PolicyManagerImpl::SendNotificationOnPermissionsUpdated( notification_data); LOG4CXX_INFO(logger_, - "Send notification for application_id:" << application_id); + "Send notification for application_id: " << application_id); - std::string default_hmi; - default_hmi = "NONE"; + std::string default_hmi = "NONE"; const ApplicationOnDevice who = {device_id, application_id}; if (access_remote_->IsAppRemoteControl(who)) { - listener()->OnPermissionsUpdated(application_id, notification_data); + listener()->OnPermissionsUpdated( + device_id, application_id, notification_data); return; } listener()->OnPermissionsUpdated( - application_id, notification_data, default_hmi); + device_id, application_id, notification_data, default_hmi); } bool PolicyManagerImpl::CleanupUnpairedDevices() { @@ -743,8 +907,13 @@ void PolicyManagerImpl::SetUserConsentForDevice(const std::string& device_id, } } -bool PolicyManagerImpl::ReactOnUserDevConsentForApp(const std::string app_id, - bool is_device_allowed) { +bool PolicyManagerImpl::ReactOnUserDevConsentForApp( + const transport_manager::DeviceHandle& device_handle, + const std::string app_id, + bool is_device_allowed) { + UNUSED(device_handle); + UNUSED(app_id); + UNUSED(is_device_allowed); return true; } @@ -855,11 +1024,11 @@ void PolicyManagerImpl::SetUserConsentForApp( LOG4CXX_AUTO_TRACE(logger_); } -bool PolicyManagerImpl::GetDefaultHmi(const std::string& policy_app_id, +bool PolicyManagerImpl::GetDefaultHmi(const std::string& device_id, + const std::string& policy_app_id, std::string* default_hmi) const { LOG4CXX_AUTO_TRACE(logger_); - const std::string device_id = GetCurrentDeviceId(policy_app_id); - DeviceConsent device_consent = GetUserConsentForDevice(device_id); + const DeviceConsent device_consent = GetUserConsentForDevice(device_id); const std::string app_id = policy::kDeviceAllowed != device_consent ? kPreDataConsentId : policy_app_id; @@ -942,7 +1111,7 @@ void PolicyManagerImpl::GetPermissionsForApp( app_id_to_check = kDefaultId; allowed_by_default = true; } else if (cache_->IsPredataPolicy(policy_app_id) || - policy::kDeviceDisallowed == GetUserConsentForDevice(device_id)) { + policy::kDeviceAllowed != GetUserConsentForDevice(device_id)) { app_id_to_check = kPreDataConsentId; allowed_by_default = true; } @@ -997,9 +1166,11 @@ void PolicyManagerImpl::GetPermissionsForApp( } std::string& PolicyManagerImpl::GetCurrentDeviceId( + const transport_manager::DeviceHandle& device_handle, const std::string& policy_app_id) const { LOG4CXX_AUTO_TRACE(logger_); - last_device_id_ = listener()->OnCurrentDeviceIdUpdateRequired(policy_app_id); + last_device_id_ = + listener()->OnCurrentDeviceIdUpdateRequired(device_handle, policy_app_id); return last_device_id_; } @@ -1067,6 +1238,17 @@ void PolicyManagerImpl::KmsChanged(int kilometers) { } } +const boost::optional PolicyManagerImpl::LockScreenDismissalEnabledState() + const { + return cache_->LockScreenDismissalEnabledState(); +} + +const boost::optional +PolicyManagerImpl::LockScreenDismissalWarningMessage( + const std::string& language) const { + return cache_->LockScreenDismissalWarningMessage(language); +} + void PolicyManagerImpl::IncrementIgnitionCycles() { cache_->IncrementIgnitionCycles(); } @@ -1077,6 +1259,18 @@ std::string PolicyManagerImpl::ForcePTExchange() { return update_status_manager_.StringifiedUpdateStatus(); } +void PolicyManagerImpl::StopRetrySequence() { + LOG4CXX_AUTO_TRACE(logger_); + + if (timer_retry_sequence_.is_running()) { + timer_retry_sequence_.Stop(); + } + + if (cache_->UpdateRequired()) { + ResetRetrySequence(ResetRetryCountType::kResetWithStatusUpdate); + } +} + std::string PolicyManagerImpl::ForcePTExchangeAtUserRequest() { update_status_manager_.ScheduleManualUpdate(); StartPTExchange(); @@ -1088,6 +1282,7 @@ std::string PolicyManagerImpl::GetPolicyTableStatus() const { } uint32_t PolicyManagerImpl::NextRetryTimeout() { + LOG4CXX_AUTO_TRACE(logger_); sync_primitives::AutoLock auto_lock(retry_sequence_lock_); LOG4CXX_DEBUG(logger_, "Index: " << retry_sequence_index_); uint32_t next = 0u; @@ -1113,16 +1308,21 @@ uint32_t PolicyManagerImpl::NextRetryTimeout() { } void PolicyManagerImpl::RefreshRetrySequence() { + LOG4CXX_AUTO_TRACE(logger_); sync_primitives::AutoLock auto_lock(retry_sequence_lock_); retry_sequence_timeout_ = cache_->TimeoutResponse(); retry_sequence_seconds_.clear(); cache_->SecondsBetweenRetries(retry_sequence_seconds_); } -void PolicyManagerImpl::ResetRetrySequence() { +void PolicyManagerImpl::ResetRetrySequence( + const ResetRetryCountType reset_type) { + LOG4CXX_AUTO_TRACE(logger_); sync_primitives::AutoLock auto_lock(retry_sequence_lock_); retry_sequence_index_ = 0; - update_status_manager_.OnResetRetrySequence(); + if (ResetRetryCountType::kResetWithStatusUpdate == reset_type) { + update_status_manager_.OnResetRetrySequence(); + } } uint32_t PolicyManagerImpl::TimeoutExchangeMSec() { @@ -1178,7 +1378,8 @@ bool PolicyManagerImpl::IsApplicationRevoked(const std::string& app_id) const { return cache_->IsApplicationRevoked(app_id); } -bool PolicyManagerImpl::IsConsentNeeded(const std::string& app_id) { +bool PolicyManagerImpl::IsConsentNeeded(const std::string& device_id, + const std::string& app_id) { LOG4CXX_AUTO_TRACE(logger_); return false; } @@ -1186,15 +1387,17 @@ bool PolicyManagerImpl::IsConsentNeeded(const std::string& app_id) { void PolicyManagerImpl::SetVINValue(const std::string& value) {} AppPermissions PolicyManagerImpl::GetAppPermissionsChanges( - const std::string& policy_app_id) { + const std::string& device_id, const std::string& policy_app_id) { typedef std::map::iterator PermissionsIt; PermissionsIt app_id_diff = app_permissions_diff_.find(policy_app_id); AppPermissions permissions(policy_app_id); if (app_permissions_diff_.end() != app_id_diff) { permissions = app_id_diff->second; } else { - permissions.appPermissionsConsentNeeded = IsConsentNeeded(policy_app_id); + permissions.appPermissionsConsentNeeded = + IsConsentNeeded(device_id, policy_app_id); permissions.appRevoked = IsApplicationRevoked(policy_app_id); + permissions.isSDLAllowed = true; GetPriority(permissions.application_id, &permissions.priority); } return permissions; @@ -1281,11 +1484,11 @@ class CallStatusChange : public utils::Callable { }; StatusNotifier PolicyManagerImpl::AddApplication( + const std::string& device_id, const std::string& application_id, const rpc::policy_table_interface_base::AppHmiTypes& hmi_types) { LOG4CXX_AUTO_TRACE(logger_); - const std::string device_id = GetCurrentDeviceId(application_id); - DeviceConsent device_consent = GetUserConsentForDevice(device_id); + auto device_consent = GetUserConsentForDevice(device_id); sync_primitives::AutoLock lock(apps_registration_lock_); if (IsNewApplication(application_id)) { AddNewApplication(application_id, device_consent); @@ -1332,6 +1535,7 @@ bool PolicyManagerImpl::IsNewApplication( } bool PolicyManagerImpl::ResetPT(const std::string& file_name) { + LOG4CXX_AUTO_TRACE(logger_); cache_->ResetCalculatedPermissions(); const bool result = cache_->ResetPT(file_name); if (result) { @@ -1388,6 +1592,11 @@ uint32_t PolicyManagerImpl::HeartBeatTimeout(const std::string& app_id) const { } void PolicyManagerImpl::SaveUpdateStatusRequired(bool is_update_needed) { + LOG4CXX_AUTO_TRACE(logger_); + + if (!is_update_needed) { + ResetRetrySequence(ResetRetryCountType::kResetInternally); + } cache_->SaveUpdateRequired(is_update_needed); } @@ -1396,8 +1605,22 @@ void PolicyManagerImpl::set_cache_manager( cache_ = std::shared_ptr(cache_manager); } -void PolicyManagerImpl::RetrySequence() { - LOG4CXX_INFO(logger_, "Start new retry sequence"); +void PolicyManagerImpl::OnPTUIterationTimeout() { + LOG4CXX_DEBUG(logger_, "Start new retry sequence"); + + const bool is_exceeded_retries_count = + (retry_sequence_seconds_.size() < retry_sequence_index_); + + if (is_exceeded_retries_count) { + LOG4CXX_WARN(logger_, "Exceeded allowed PTU retry count"); + listener_->OnPTUTimeOut(); + ResetRetrySequence(ResetRetryCountType::kResetWithStatusUpdate); + if (timer_retry_sequence_.is_running()) { + timer_retry_sequence_.Stop(); + } + return; + } + update_status_manager_.OnUpdateTimeoutOccurs(); const uint32_t timeout_msec = NextRetryTimeout(); @@ -1409,14 +1632,17 @@ void PolicyManagerImpl::RetrySequence() { return; } - RequestPTUpdate(); + RequestPTUpdate(PTUIterationType::RetryIteration); timer_retry_sequence_.Start(timeout_msec, timer::kPeriodic); } -void PolicyManagerImpl::SetDefaultHmiTypes(const std::string& application_id, - const std::vector& hmi_types) { +void PolicyManagerImpl::SetDefaultHmiTypes( + const transport_manager::DeviceHandle& device_handle, + const std::string& application_id, + const std::vector& hmi_types) { LOG4CXX_INFO(logger_, "SetDefaultHmiTypes"); - const std::string device_id = GetCurrentDeviceId(application_id); + const std::string device_id = + GetCurrentDeviceId(device_handle, application_id); ApplicationOnDevice who = {device_id, application_id}; access_remote_->SetDefaultHmiTypes(who, hmi_types); } @@ -1454,12 +1680,12 @@ bool PolicyManagerImpl::CheckModule(const PTString& app_id, void PolicyManagerImpl::SendHMILevelChanged(const ApplicationOnDevice& who) { std::string default_hmi("NONE"); - if (GetDefaultHmi(who.app_id, &default_hmi)) { + if (GetDefaultHmi(who.dev_id, who.app_id, &default_hmi)) { listener()->OnUpdateHMIStatus(who.dev_id, who.app_id, default_hmi); } else { - LOG4CXX_WARN(logger_, - "Couldn't get default HMI level for application " - << who.app_id); + LOG4CXX_WARN( + logger_, + "Couldn't get default HMI level for application " << who.app_id); } } @@ -1491,7 +1717,8 @@ void PolicyManagerImpl::SendAppPermissionsChanged( const std::string& device_id, const std::string& application_id) { Permissions notification_data; GetPermissions(device_id, application_id, ¬ification_data); - listener()->OnPermissionsUpdated(application_id, notification_data); + listener()->OnPermissionsUpdated( + device_id, application_id, notification_data); } void PolicyManagerImpl::SendAuthTokenUpdated(const std::string policy_app_id) { @@ -1528,4 +1755,104 @@ void PolicyManagerImpl::set_access_remote( access_remote_ = access_remote; } +bool PolicyManagerImpl::AppNeedEncryption( + const std::string& policy_app_id) const { + LOG4CXX_AUTO_TRACE(logger_); + const auto encryption_required = + cache_->GetAppEncryptionRequiredFlag(policy_app_id); + + return encryption_required.is_initialized() ? *encryption_required : true; +} + +const rpc::Optional PolicyManagerImpl::GetAppEncryptionRequired( + const std::string& policy_app_id) const { + LOG4CXX_AUTO_TRACE(logger_); + return cache_->GetAppEncryptionRequiredFlag(policy_app_id); +} + +const std::vector PolicyManagerImpl::GetFunctionalGroupsForApp( + const std::string& policy_app_id) const { + LOG4CXX_AUTO_TRACE(logger_); + using namespace rpc::policy_table_interface_base; + DCHECK(kDeviceId != policy_app_id); + + std::vector function_groups; + + ApplicationParams app_policies; + cache_->GetApplicationParams(policy_app_id, app_policies); + + const auto& policy_function_group = app_policies.groups; + + for (const auto& group : policy_function_group) { + function_groups.push_back(group); + } + + return function_groups; +} + +const std::vector PolicyManagerImpl::GetApplicationPolicyIDs() + const { + LOG4CXX_AUTO_TRACE(logger_); + std::vector policy_app_ids; + + const auto apps = cache_->GetPolicyAppIDs(); + + for (const auto& app : apps) { + policy_app_ids.push_back(app); + } + + return policy_app_ids; +} + +bool PolicyManagerImpl::FunctionGroupNeedEncryption( + const std::string& policy_group) const { + LOG4CXX_AUTO_TRACE(logger_); + FunctionalGroupings functional_groupings; + cache_->GetFunctionalGroupings(functional_groupings); + + const auto& grouping_itr = functional_groupings.find(policy_group); + if (grouping_itr == functional_groupings.end()) { + LOG4CXX_WARN(logger_, "Group " << policy_group << " not found"); + return false; + } + + const auto& grouping = (*grouping_itr).second; + + return grouping.encryption_required.is_initialized() + ? *grouping.encryption_required + : false; +} + +const std::string PolicyManagerImpl::GetPolicyFunctionName( + const uint32_t function_id) const { + return policy_table::EnumToJsonString( + static_cast(function_id)); +} + +const std::vector PolicyManagerImpl::GetRPCsForFunctionGroup( + const std::string& group) const { + std::vector rpcs_for_group; + + FunctionalGroupings functional_groupings; + cache_->GetFunctionalGroupings(functional_groupings); + + const auto& rpcs = functional_groupings[group].rpcs; + + for (const auto& rpc : rpcs) { + rpcs_for_group.push_back(rpc.first); + } + + return rpcs_for_group; +} + } // namespace policy + +__attribute__((visibility("default"))) policy::PolicyManager* CreateManager() { + return new policy::PolicyManagerImpl(); +} + +__attribute__((visibility("default"))) void DeleteManager( + policy::PolicyManager* pm) { + delete pm; + DELETE_THREAD_LOGGER(policy::logger_); +} 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 421ccacded0..8aabf54c5d0 100644 --- a/src/components/policy/policy_regular/src/policy_table/enums.cc +++ b/src/components/policy/policy_regular/src/policy_table/enums.cc @@ -3,1470 +3,6 @@ namespace rpc { namespace policy_table_interface_base { -bool IsValidEnum(Priority val) { - switch (val) { - case P_EMERGENCY: - return true; - case P_NAVIGATION: - return true; - case P_VOICECOM: - return true; - case P_COMMUNICATION: - return true; - case P_NORMAL: - return true; - case P_PROJECTION: - return true; - case P_NONE: - return true; - default: - return false; - } -} -const char* EnumToJsonString(Priority val) { - switch (val) { - case P_EMERGENCY: - return "EMERGENCY"; - case P_NAVIGATION: - return "NAVIGATION"; - case P_VOICECOM: - return "VOICECOM"; - case P_COMMUNICATION: - return "COMMUNICATION"; - case P_NORMAL: - return "NORMAL"; - case P_PROJECTION: - return "PROJECTION"; - case P_NONE: - return "NONE"; - default: - return ""; - } -} -bool EnumFromJsonString(const std::string& literal, Priority* result) { - if ("EMERGENCY" == literal) { - *result = P_EMERGENCY; - return true; - } else if ("NAVIGATION" == literal) { - *result = P_NAVIGATION; - return true; - } else if ("VOICECOM" == literal) { - *result = P_VOICECOM; - return true; - } else if ("COMMUNICATION" == literal) { - *result = P_COMMUNICATION; - return true; - } else if ("NORMAL" == literal) { - *result = P_NORMAL; - return true; - } else if ("PROJECTION" == literal) { - *result = P_PROJECTION; - return true; - } else if ("NONE" == literal) { - *result = P_NONE; - return true; - } else { - return false; - } -} - -bool IsValidEnum(HmiLevel val) { - switch (val) { - case HL_BACKGROUND: - return true; - case HL_FULL: - return true; - case HL_LIMITED: - return true; - case HL_NONE: - return true; - default: - return false; - } -} -const char* EnumToJsonString(HmiLevel val) { - switch (val) { - case HL_BACKGROUND: - return "BACKGROUND"; - case HL_FULL: - return "FULL"; - case HL_LIMITED: - return "LIMITED"; - case HL_NONE: - return "NONE"; - default: - return ""; - } -} -bool EnumFromJsonString(const std::string& literal, HmiLevel* result) { - if ("BACKGROUND" == literal) { - *result = HL_BACKGROUND; - return true; - } else if ("FULL" == literal) { - *result = HL_FULL; - return true; - } else if ("LIMITED" == literal) { - *result = HL_LIMITED; - return true; - } else if ("NONE" == literal) { - *result = HL_NONE; - return true; - } else { - return false; - } -} - -bool IsValidEnum(Parameter val) { - switch (val) { - case P_GPS: - return true; - case P_SPEED: - return true; - case P_ENGINETORQUE: - return true; - case P_EXTERNALTEMPERATURE: - return true; - case P_TURNSIGNAL: - return true; - case P_FUELLEVEL: - return true; - case P_FUELLEVEL_STATE: - return true; - case P_HEADLAMPSTATUS: - return true; - case P_INSTANTFUELCONSUMPTION: - return true; - case P_FUELRANGE: - return true; - case P_CLOUD_APP_VEHICLE_ID: - return true; - case P_ODOMETER: - return true; - case P_TIREPRESSURE: - return true; - case P_WIPERSTATUS: - return true; - case P_VIN: - return true; - case P_ACCPEDALPOSITION: - return true; - case P_BELTSTATUS: - return true; - case P_ELECTRONICPARKBRAKESTATUS: - return true; - case P_DRIVERBRAKING: - return true; - case P_PRNDL: - return true; - case P_RPM: - return true; - case P_STEERINGWHEELANGLE: - return true; - case P_ENGINEOILLIFE: - return true; - case P_MYKEY: - return true; - case P_AIRBAGSTATUS: - return true; - case P_BODYINFORMATION: - return true; - case P_CLUSTERMODESTATUS: - return true; - case P_DEVICESTATUS: - return true; - case P_EMERGENCYEVENT: - return true; - case P_ECALLINFO: - return true; - case P_EMPTY: - return true; - default: - return false; - } -} -const char* EnumToJsonString(Parameter val) { - switch (val) { - case P_GPS: - return "gps"; - case P_SPEED: - return "speed"; - case P_ENGINETORQUE: - return "engineTorque"; - case P_EXTERNALTEMPERATURE: - return "externalTemperature"; - case P_TURNSIGNAL: - return "turnSignal"; - case P_FUELLEVEL: - return "fuelLevel"; - case P_FUELLEVEL_STATE: - return "fuelLevel_State"; - case P_HEADLAMPSTATUS: - return "headLampStatus"; - case P_INSTANTFUELCONSUMPTION: - return "instantFuelConsumption"; - case P_FUELRANGE: - return "fuelRange"; - case P_CLOUD_APP_VEHICLE_ID: - return "cloudAppVehicleID"; - case P_ODOMETER: - return "odometer"; - case P_TIREPRESSURE: - return "tirePressure"; - case P_WIPERSTATUS: - return "wiperStatus"; - case P_VIN: - return "vin"; - case P_ACCPEDALPOSITION: - return "accPedalPosition"; - case P_BELTSTATUS: - return "beltStatus"; - case P_ELECTRONICPARKBRAKESTATUS: - return "electronicParkBrakeStatus"; - case P_DRIVERBRAKING: - return "driverBraking"; - case P_PRNDL: - return "prndl"; - case P_RPM: - return "rpm"; - case P_STEERINGWHEELANGLE: - return "steeringWheelAngle"; - case P_ENGINEOILLIFE: - return "engineOilLife"; - case P_MYKEY: - return "myKey"; - case P_AIRBAGSTATUS: - return "airbagStatus"; - case P_BODYINFORMATION: - return "bodyInformation"; - case P_CLUSTERMODESTATUS: - return "clusterModeStatus"; - case P_DEVICESTATUS: - return "deviceStatus"; - case P_EMERGENCYEVENT: - return "emergencyEvent"; - case P_ECALLINFO: - return "eCallInfo"; - case P_EMPTY: - return "EMPTY"; - default: - return ""; - } -} - -bool EnumFromJsonString(const std::string& literal, Parameter* result) { - if ("gps" == literal) { - *result = P_GPS; - return true; - } else if ("speed" == literal) { - *result = P_SPEED; - return true; - } else if ("engineTorque" == literal) { - *result = P_ENGINETORQUE; - return true; - } else if ("externalTemperature" == literal) { - *result = P_EXTERNALTEMPERATURE; - return true; - } else if ("turnSignal" == literal) { - *result = P_TURNSIGNAL; - return true; - } else if ("fuelLevel" == literal) { - *result = P_FUELLEVEL; - return true; - } else if ("fuelLevel_State" == literal) { - *result = P_FUELLEVEL_STATE; - return true; - } else if ("headLampStatus" == literal) { - *result = P_HEADLAMPSTATUS; - return true; - } else if ("instantFuelConsumption" == literal) { - *result = P_INSTANTFUELCONSUMPTION; - return true; - } else if ("fuelRange" == literal) { - *result = P_FUELRANGE; - return true; - } else if ("cloudAppVehicleID" == literal) { - *result = P_CLOUD_APP_VEHICLE_ID; - return true; - } else if ("odometer" == literal) { - *result = P_ODOMETER; - return true; - } else if ("tirePressure" == literal) { - *result = P_TIREPRESSURE; - return true; - } else if ("wiperStatus" == literal) { - *result = P_WIPERSTATUS; - return true; - } else if ("vin" == literal) { - *result = P_VIN; - return true; - } else if ("accPedalPosition" == literal) { - *result = P_ACCPEDALPOSITION; - return true; - } else if ("beltStatus" == literal) { - *result = P_BELTSTATUS; - return true; - } else if ("electronicParkBrakeStatus" == literal) { - *result = P_ELECTRONICPARKBRAKESTATUS; - return true; - } else if ("driverBraking" == literal) { - *result = P_DRIVERBRAKING; - return true; - } else if ("prndl" == literal) { - *result = P_PRNDL; - return true; - } else if ("rpm" == literal) { - *result = P_RPM; - return true; - } else if ("steeringWheelAngle" == literal) { - *result = P_STEERINGWHEELANGLE; - return true; - } else if ("engineOilLife" == literal) { - *result = P_ENGINEOILLIFE; - return true; - } else if ("myKey" == literal) { - *result = P_MYKEY; - return true; - } else if ("airbagStatus" == literal) { - *result = P_AIRBAGSTATUS; - return true; - } else if ("bodyInformation" == literal) { - *result = P_BODYINFORMATION; - return true; - } else if ("clusterModeStatus" == literal) { - *result = P_CLUSTERMODESTATUS; - return true; - } else if ("deviceStatus" == literal) { - *result = P_DEVICESTATUS; - return true; - } else if ("emergencyEvent" == literal) { - *result = P_EMERGENCYEVENT; - return true; - } else if ("eCallInfo" == literal) { - *result = P_ECALLINFO; - return true; - } else if ("EMPTY" == literal) { - *result = P_EMPTY; - return true; - } else { - return false; - } -} - -bool IsValidEnum(AppHMIType val) { - switch (val) { - case AHT_DEFAULT: - return true; - case AHT_COMMUNICATION: - return true; - case AHT_MEDIA: - return true; - case AHT_MESSAGING: - return true; - case AHT_NAVIGATION: - return true; - case AHT_INFORMATION: - return true; - case AHT_SOCIAL: - return true; - case AHT_BACKGROUND_PROCESS: - return true; - case AHT_TESTING: - return true; - case AHT_SYSTEM: - return true; - case AHT_PROJECTION: - return true; - case AHT_REMOTE_CONTROL: - return true; - default: - return false; - } -} -const char* EnumToJsonString(AppHMIType val) { - switch (val) { - case AHT_DEFAULT: - return "DEFAULT"; - case AHT_COMMUNICATION: - return "COMMUNICATION"; - case AHT_MEDIA: - return "MEDIA"; - case AHT_MESSAGING: - return "MESSAGING"; - case AHT_NAVIGATION: - return "NAVIGATION"; - case AHT_INFORMATION: - return "INFORMATION"; - case AHT_SOCIAL: - return "SOCIAL"; - case AHT_BACKGROUND_PROCESS: - return "BACKGROUND_PROCESS"; - case AHT_TESTING: - return "TESTING"; - case AHT_SYSTEM: - return "SYSTEM"; - case AHT_PROJECTION: - return "PROJECTION"; - case AHT_REMOTE_CONTROL: - return "REMOTE_CONTROL"; - default: - return ""; - } -} -bool EnumFromJsonString(const std::string& literal, AppHMIType* result) { - if ("DEFAULT" == literal) { - *result = AHT_DEFAULT; - return true; - } else if ("COMMUNICATION" == literal) { - *result = AHT_COMMUNICATION; - return true; - } else if ("MEDIA" == literal) { - *result = AHT_MEDIA; - return true; - } else if ("MESSAGING" == literal) { - *result = AHT_MESSAGING; - return true; - } else if ("NAVIGATION" == literal) { - *result = AHT_NAVIGATION; - return true; - } else if ("INFORMATION" == literal) { - *result = AHT_INFORMATION; - return true; - } else if ("SOCIAL" == literal) { - *result = AHT_SOCIAL; - return true; - } else if ("BACKGROUND_PROCESS" == literal) { - *result = AHT_BACKGROUND_PROCESS; - return true; - } else if ("TESTING" == literal) { - *result = AHT_TESTING; - return true; - } else if ("SYSTEM" == literal) { - *result = AHT_SYSTEM; - return true; - } else if ("PROJECTION" == literal) { - *result = AHT_PROJECTION; - return true; - } else if ("REMOTE_CONTROL" == literal) { - *result = AHT_REMOTE_CONTROL; - return true; - } else { - return false; - } -} - -bool IsValidEnum(RequestType val) { - switch (val) { - case RT_HTTP: - return true; - case RT_FILE_RESUME: - return true; - case RT_AUTH_REQUEST: - return true; - case RT_AUTH_CHALLENGE: - return true; - case RT_AUTH_ACK: - return true; - case RT_PROPRIETARY: - return true; - case RT_QUERY_APPS: - return true; - case RT_LAUNCH_APP: - return true; - case RT_LOCK_SCREEN_ICON_URL: - return true; - case RT_TRAFFIC_MESSAGE_CHANNEL: - return true; - case RT_DRIVER_PROFILE: - return true; - case RT_VOICE_SEARCH: - return true; - case RT_NAVIGATION: - return true; - case RT_PHONE: - return true; - case RT_CLIMATE: - return true; - case RT_SETTINGS: - return true; - case RT_VEHICLE_DIAGNOSTICS: - return true; - case RT_EMERGENCY: - return true; - case RT_MEDIA: - return true; - case RT_FOTA: - return true; - case RT_OEM_SPECIFIC: - return true; - case RT_EMPTY: - return true; - default: - return false; - } -} - -const char* EnumToJsonString(RequestType val) { - switch (val) { - case RT_HTTP: - return "HTTP"; - case RT_FILE_RESUME: - return "FILE_RESUME"; - case RT_AUTH_REQUEST: - return "AUTH_REQUEST"; - case RT_AUTH_CHALLENGE: - return "AUTH_CHALLENGE"; - case RT_AUTH_ACK: - return "AUTH_ACK"; - case RT_PROPRIETARY: - return "PROPRIETARY"; - case RT_QUERY_APPS: - return "QUERY_APPS"; - case RT_LAUNCH_APP: - return "LAUNCH_APP"; - case RT_LOCK_SCREEN_ICON_URL: - return "LOCK_SCREEN_ICON_URL"; - case RT_TRAFFIC_MESSAGE_CHANNEL: - return "TRAFFIC_MESSAGE_CHANNEL"; - case RT_DRIVER_PROFILE: - return "DRIVER_PROFILE"; - case RT_VOICE_SEARCH: - return "VOICE_SEARCH"; - case RT_NAVIGATION: - return "NAVIGATION"; - case RT_PHONE: - return "PHONE"; - case RT_CLIMATE: - return "CLIMATE"; - case RT_SETTINGS: - return "SETTINGS"; - case RT_VEHICLE_DIAGNOSTICS: - return "VEHICLE_DIAGNOSTICS"; - case RT_EMERGENCY: - return "EMERGENCY"; - case RT_MEDIA: - return "MEDIA"; - case RT_FOTA: - return "FOTA"; - case RT_OEM_SPECIFIC: - return "OEM_SPECIFIC"; - case RT_EMPTY: - return "EMPTY"; - default: - return ""; - } -} - -bool EnumFromJsonString(const std::string& literal, RequestType* result) { - if ("HTTP" == literal) { - *result = RT_HTTP; - return true; - } - if ("FILE_RESUME" == literal) { - *result = RT_FILE_RESUME; - return true; - } - if ("AUTH_REQUEST" == literal) { - *result = RT_AUTH_REQUEST; - return true; - } - if ("AUTH_CHALLENGE" == literal) { - *result = RT_AUTH_CHALLENGE; - return true; - } - if ("AUTH_ACK" == literal) { - *result = RT_AUTH_ACK; - return true; - } - if ("PROPRIETARY" == literal) { - *result = RT_PROPRIETARY; - return true; - } - if ("QUERY_APPS" == literal) { - *result = RT_QUERY_APPS; - return true; - } - if ("LAUNCH_APP" == literal) { - *result = RT_LAUNCH_APP; - return true; - } - if ("LOCK_SCREEN_ICON_URL" == literal) { - *result = RT_LOCK_SCREEN_ICON_URL; - return true; - } - if ("TRAFFIC_MESSAGE_CHANNEL" == literal) { - *result = RT_TRAFFIC_MESSAGE_CHANNEL; - return true; - } - if ("DRIVER_PROFILE" == literal) { - *result = RT_DRIVER_PROFILE; - return true; - } - if ("VOICE_SEARCH" == literal) { - *result = RT_VOICE_SEARCH; - return true; - } - if ("NAVIGATION" == literal) { - *result = RT_NAVIGATION; - return true; - } - if ("PHONE" == literal) { - *result = RT_PHONE; - return true; - } - if ("CLIMATE" == literal) { - *result = RT_CLIMATE; - return true; - } - if ("SETTINGS" == literal) { - *result = RT_SETTINGS; - return true; - } - if ("VEHICLE_DIAGNOSTICS" == literal) { - *result = RT_VEHICLE_DIAGNOSTICS; - return true; - } - if ("EMERGENCY" == literal) { - *result = RT_EMERGENCY; - return true; - } - if ("MEDIA" == literal) { - *result = RT_MEDIA; - return true; - } - if ("FOTA" == literal) { - *result = RT_FOTA; - return true; - } - if ("OEM_SPECIFIC" == literal) { - *result = RT_OEM_SPECIFIC; - return true; - } - if ("EMPTY" == literal) { - *result = RT_EMPTY; - return true; - } else { - return false; - } -} - -bool IsValidEnum(ModuleType val) { - switch (val) { - case MT_CLIMATE: - return true; - case MT_RADIO: - return true; - case MT_SEAT: - return true; - case MT_AUDIO: - return true; - case MT_LIGHT: - return true; - case MT_HMI_SETTINGS: - return true; - case MT_EMPTY: - return true; - default: - return false; - } -} - -const char* EnumToJsonString(ModuleType val) { - switch (val) { - case MT_CLIMATE: - return "CLIMATE"; - case MT_RADIO: - return "RADIO"; - case MT_SEAT: - return "SEAT"; - case MT_AUDIO: - return "AUDIO"; - case MT_LIGHT: - return "LIGHT"; - case MT_HMI_SETTINGS: - return "HMI_SETTINGS"; - case MT_EMPTY: - return "EMPTY"; - default: - return ""; - } -} - -bool EnumFromJsonString(const std::string& literal, ModuleType* result) { - if ("CLIMATE" == literal) { - *result = MT_CLIMATE; - return true; - } else if ("RADIO" == literal) { - *result = MT_RADIO; - return true; - } 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 if ("EMPTY" == literal) { - *result = MT_EMPTY; - return true; - } - return false; -} - -bool IsValidEnum(HybridAppPreference val) { - return strlen(EnumToJsonString(val)) > 0; -} - -const char* EnumToJsonString(HybridAppPreference val) { - switch (val) { - case HAP_MOBILE: - return "MOBILE"; - case HAP_CLOUD: - return "CLOUD"; - case HAP_BOTH: - return "BOTH"; - default: - return ""; - } -} - -bool EnumFromJsonString(const std::string& literal, - HybridAppPreference* result) { - if ("MOBILE" == literal) { - *result = HAP_MOBILE; - return true; - } else if ("CLOUD" == literal) { - *result = HAP_CLOUD; - return true; - } else if ("BOTH" == literal) { - *result = HAP_BOTH; - return true; - } - return false; -} - -bool IsValidEnum(FunctionID val) { - switch (val) { - case RegisterAppInterfaceID: - return true; - case UnregisterAppInterfaceID: - return true; - case SetGlobalPropertiesID: - return true; - case ResetGlobalPropertiesID: - return true; - case AddCommandID: - return true; - case DeleteCommandID: - return true; - case AddSubMenuID: - return true; - case DeleteSubMenuID: - return true; - case CreateInteractionChoiceSetID: - return true; - case PerformInteractionID: - return true; - case DeleteInteractionChoiceSetID: - return true; - case AlertID: - return true; - case ShowID: - return true; - case SpeakID: - return true; - case SetMediaClockTimerID: - return true; - case PerformAudioPassThruID: - return true; - case EndAudioPassThruID: - return true; - case SubscribeButtonID: - return true; - case UnsubscribeButtonID: - return true; - case SubscribeVehicleDataID: - return true; - case UnsubscribeVehicleDataID: - return true; - case GetVehicleDataID: - return true; - case ReadDIDID: - return true; - case GetDTCsID: - return true; - case ScrollableMessageID: - return true; - case SliderID: - return true; - case ShowConstantTBTID: - return true; - case AlertManeuverID: - return true; - case UpdateTurnListID: - return true; - case ChangeRegistrationID: - return true; - case GenericResponseID: - return true; - case PutFileID: - return true; - case DeleteFileID: - return true; - case ListFilesID: - return true; - case SetAppIconID: - return true; - case SetDisplayLayoutID: - return true; - case DiagnosticMessageID: - return true; - case SystemRequestID: - return true; - case SendLocationID: - return true; - case DialNumberID: - return true; - case ButtonPressID: - return true; - case GetInteriorVehicleDataID: - return true; - case SetInteriorVehicleDataID: - return true; - case GetWayPointsID: - return true; - case SubscribeWayPointsID: - return true; - case UnsubscribeWayPointsID: - return true; - case GetSystemCapabilityID: - return true; - case SendHapticDataID: - return true; - case SetCloudAppPropertiesID: - return true; - case GetCloudAppPropertiesID: - return true; - case PublishAppServiceID: - return true; - case GetFileID: - return true; - case GetAppServiceDataID: - return true; - case PerformAppServiceInteractionID: - return true; - case OnHMIStatusID: - return true; - case OnAppInterfaceUnregisteredID: - return true; - case OnButtonEventID: - return true; - case OnButtonPressID: - return true; - case OnVehicleDataID: - return true; - case OnCommandID: - return true; - case OnTBTClientStateID: - return true; - case OnDriverDistractionID: - return true; - case OnPermissionsChangeID: - return true; - case OnAudioPassThruID: - return true; - case OnLanguageChangeID: - return true; - case OnKeyboardInputID: - return true; - case OnTouchEventID: - return true; - case OnSystemRequestID: - return true; - case OnHashChangeID: - return true; - case OnInteriorVehicleDataID: - return true; - case OnWayPointChangeID: - return true; - case OnRCStatusID: - return true; - case OnAppServiceDataID: - return true; - case EncodedSyncPDataID: - return true; - case SyncPDataID: - return true; - case OnEncodedSyncPDataID: - return true; - case OnSyncPDataID: - return true; - case OnSystemCapabilityUpdatedID: - return true; - default: - return false; - } -}; - -const char* EnumToJsonString(FunctionID val) { - switch (val) { - case RegisterAppInterfaceID: - return "RegisterAppInterface"; - case UnregisterAppInterfaceID: - return "UnregisterAppInterface"; - case SetGlobalPropertiesID: - return "SetGlobalProperties"; - case ResetGlobalPropertiesID: - return "ResetGlobalProperties"; - case AddCommandID: - return "AddCommand"; - case DeleteCommandID: - return "DeleteCommand"; - case AddSubMenuID: - return "AddSubMenu"; - case DeleteSubMenuID: - return "DeleteSubMenu"; - case CreateInteractionChoiceSetID: - return "CreateInteractionChoiceSet"; - case PerformInteractionID: - return "PerformInteraction"; - case DeleteInteractionChoiceSetID: - return "DeleteInteractionChoiceSet"; - case AlertID: - return "Alert"; - case ShowID: - return "Show"; - case SpeakID: - return "Speak"; - case SetMediaClockTimerID: - return "SetMediaClockTimer"; - case PerformAudioPassThruID: - return "PerformAudioPassThru"; - case EndAudioPassThruID: - return "EndAudioPassThru"; - case SubscribeButtonID: - return "SubscribeButton"; - case UnsubscribeButtonID: - return "UnsubscribeButton"; - case SubscribeVehicleDataID: - return "SubscribeVehicleData"; - case UnsubscribeVehicleDataID: - return "UnsubscribeVehicleData"; - case GetVehicleDataID: - return "GetVehicleData"; - case ReadDIDID: - return "ReadDID"; - case GetDTCsID: - return "GetDTCs"; - case ScrollableMessageID: - return "ScrollableMessage"; - case SliderID: - return "Slider"; - case ShowConstantTBTID: - return "ShowConstantTBT"; - case AlertManeuverID: - return "AlertManeuver"; - case UpdateTurnListID: - return "UpdateTurnList"; - case ChangeRegistrationID: - return "ChangeRegistration"; - case GenericResponseID: - return "GenericResponse"; - case PutFileID: - return "PutFile"; - case DeleteFileID: - return "DeleteFile"; - case ListFilesID: - return "ListFiles"; - case SetAppIconID: - return "SetAppIcon"; - case SetDisplayLayoutID: - return "SetDisplayLayout"; - case DiagnosticMessageID: - return "DiagnosticMessage"; - case SystemRequestID: - return "SystemRequest"; - case SendLocationID: - return "SendLocation"; - case DialNumberID: - return "DialNumber"; - case ButtonPressID: - return "ButtonPress"; - case GetInteriorVehicleDataID: - return "GetInteriorVehicleData"; - case SetInteriorVehicleDataID: - return "SetInteriorVehicleData"; - case GetWayPointsID: - return "GetWayPoints"; - case SubscribeWayPointsID: - return "SubscribeWayPoints"; - case UnsubscribeWayPointsID: - return "UnsubscribeWayPoints"; - case GetSystemCapabilityID: - return "GetSystemCapability"; - case SendHapticDataID: - return "SendHapticData"; - case SetCloudAppPropertiesID: - return "SetCloudAppProperties"; - case GetCloudAppPropertiesID: - return "GetCloudAppProperties"; - case PublishAppServiceID: - return "PublishAppService"; - case GetFileID: - return "GetFile"; - case GetAppServiceDataID: - return "GetAppServiceData"; - case PerformAppServiceInteractionID: - return "PerformAppServiceInteraction"; - case OnHMIStatusID: - return "OnHMIStatus"; - case OnAppInterfaceUnregisteredID: - return "OnAppInterfaceUnregistered"; - case OnButtonEventID: - return "OnButtonEvent"; - case OnButtonPressID: - return "OnButtonPress"; - case OnVehicleDataID: - return "OnVehicleData"; - case OnCommandID: - return "OnCommand"; - case OnTBTClientStateID: - return "OnTBTClientState"; - case OnDriverDistractionID: - return "OnDriverDistraction"; - case OnPermissionsChangeID: - return "OnPermissionsChange"; - case OnAudioPassThruID: - return "OnAudioPassThru"; - case OnLanguageChangeID: - return "OnLanguageChange"; - case OnKeyboardInputID: - return "OnKeyboardInput"; - case OnTouchEventID: - return "OnTouchEvent"; - case OnSystemRequestID: - return "OnSystemRequest"; - case OnHashChangeID: - return "OnHashChange"; - case OnInteriorVehicleDataID: - return "OnInteriorVehicleData"; - case OnWayPointChangeID: - return "OnWayPointChange"; - case OnRCStatusID: - return "OnRCStatus"; - case OnAppServiceDataID: - return "OnAppServiceData"; - case EncodedSyncPDataID: - return "EncodedSyncPData"; - case SyncPDataID: - return "SyncPData"; - case OnEncodedSyncPDataID: - return "OnEncodedSyncPData"; - case OnSyncPDataID: - return "OnSyncPData"; - case OnSystemCapabilityUpdatedID: - return "OnSystemCapabilityUpdated"; - default: - return ""; - } -}; - -bool EnumFromJsonString(const std::string& literal, FunctionID* result) { - if ("RegisterAppInterface" == literal) { - *result = RegisterAppInterfaceID; - return true; - } - - if ("UnregisterAppInterface" == literal) { - *result = UnregisterAppInterfaceID; - return true; - } - - if ("SetGlobalProperties" == literal) { - *result = SetGlobalPropertiesID; - return true; - } - - if ("ResetGlobalProperties" == literal) { - *result = ResetGlobalPropertiesID; - return true; - } - - if ("AddCommand" == literal) { - *result = AddCommandID; - return true; - } - - if ("DeleteCommand" == literal) { - *result = DeleteCommandID; - return true; - } - - if ("AddSubMenu" == literal) { - *result = AddSubMenuID; - return true; - } - - if ("DeleteSubMenu" == literal) { - *result = DeleteSubMenuID; - return true; - } - - if ("CreateInteractionChoiceSet" == literal) { - *result = CreateInteractionChoiceSetID; - return true; - } - - if ("PerformInteraction" == literal) { - *result = PerformInteractionID; - return true; - } - - if ("DeleteInteractionChoiceSet" == literal) { - *result = DeleteInteractionChoiceSetID; - return true; - } - - if ("Alert" == literal) { - *result = AlertID; - return true; - } - - if ("Show" == literal) { - *result = ShowID; - return true; - } - - if ("Speak" == literal) { - *result = SpeakID; - return true; - } - - if ("SetMediaClockTimer" == literal) { - *result = SetMediaClockTimerID; - return true; - } - - if ("PerformAudioPassThru" == literal) { - *result = PerformAudioPassThruID; - return true; - } - - if ("EndAudioPassThru" == literal) { - *result = EndAudioPassThruID; - return true; - } - - if ("SubscribeButton" == literal) { - *result = SubscribeButtonID; - return true; - } - - if ("UnsubscribeButton" == literal) { - *result = UnsubscribeButtonID; - return true; - } - - if ("SubscribeVehicleData" == literal) { - *result = SubscribeVehicleDataID; - return true; - } - - if ("UnsubscribeVehicleData" == literal) { - *result = UnsubscribeVehicleDataID; - return true; - } - - if ("GetVehicleData" == literal) { - *result = GetVehicleDataID; - return true; - } - - if ("ReadDID" == literal) { - *result = ReadDIDID; - return true; - } - - if ("GetDTCs" == literal) { - *result = GetDTCsID; - return true; - } - - if ("ScrollableMessage" == literal) { - *result = ScrollableMessageID; - return true; - } - - if ("Slider" == literal) { - *result = SliderID; - return true; - } - - if ("ShowConstantTBT" == literal) { - *result = ShowConstantTBTID; - return true; - } - - if ("AlertManeuver" == literal) { - *result = AlertManeuverID; - return true; - } - - if ("UpdateTurnList" == literal) { - *result = UpdateTurnListID; - return true; - } - - if ("ChangeRegistration" == literal) { - *result = ChangeRegistrationID; - return true; - } - - if ("GenericResponse" == literal) { - *result = GenericResponseID; - return true; - } - - if ("PutFile" == literal) { - *result = PutFileID; - return true; - } - - if ("DeleteFile" == literal) { - *result = DeleteFileID; - return true; - } - - if ("ListFiles" == literal) { - *result = ListFilesID; - return true; - } - - if ("SetAppIcon" == literal) { - *result = SetAppIconID; - return true; - } - - if ("SetDisplayLayout" == literal) { - *result = SetDisplayLayoutID; - return true; - } - - if ("DiagnosticMessage" == literal) { - *result = DiagnosticMessageID; - return true; - } - - if ("SystemRequest" == literal) { - *result = SystemRequestID; - return true; - } - - if ("SendLocation" == literal) { - *result = SendLocationID; - return true; - } - - if ("DialNumber" == literal) { - *result = DialNumberID; - return true; - } - - if ("ButtonPress" == literal) { - *result = ButtonPressID; - return true; - } - - if ("GetInteriorVehicleData" == literal) { - *result = GetInteriorVehicleDataID; - return true; - } - - if ("SetInteriorVehicleData" == literal) { - *result = SetInteriorVehicleDataID; - return true; - } - - if ("GetWayPoints" == literal) { - *result = GetWayPointsID; - return true; - } - - if ("SubscribeWayPoints" == literal) { - *result = SubscribeWayPointsID; - return true; - } - - if ("UnsubscribeWayPoints" == literal) { - *result = UnsubscribeWayPointsID; - return true; - } - - if ("GetSystemCapability" == literal) { - *result = GetSystemCapabilityID; - return true; - } - - if ("SendHapticData" == literal) { - *result = SendHapticDataID; - return true; - } - - if ("SetCloudAppProperties" == literal) { - *result = SetCloudAppPropertiesID; - return true; - } - - if ("GetCloudAppProperties" == literal) { - *result = GetCloudAppPropertiesID; - return true; - } - - if ("PublishAppService" == literal) { - *result = PublishAppServiceID; - return true; - } - - if ("GetFile" == literal) { - *result = GetFileID; - return true; - } - - if ("GetAppServiceData" == literal) { - *result = GetAppServiceDataID; - return true; - } - - if ("PerformAppServiceInteraction" == literal) { - *result = PerformAppServiceInteractionID; - return true; - } - - if ("OnHMIStatus" == literal) { - *result = OnHMIStatusID; - return true; - } - - if ("OnAppInterfaceUnregistered" == literal) { - *result = OnAppInterfaceUnregisteredID; - return true; - } - - if ("OnButtonEvent" == literal) { - *result = OnButtonEventID; - return true; - } - - if ("OnButtonPress" == literal) { - *result = OnButtonPressID; - return true; - } - - if ("OnVehicleData" == literal) { - *result = OnVehicleDataID; - return true; - } - - if ("OnCommand" == literal) { - *result = OnCommandID; - return true; - } - - if ("OnTBTClientState" == literal) { - *result = OnTBTClientStateID; - return true; - } - - if ("OnDriverDistraction" == literal) { - *result = OnDriverDistractionID; - return true; - } - - if ("OnPermissionsChange" == literal) { - *result = OnPermissionsChangeID; - return true; - } - - if ("OnAudioPassThru" == literal) { - *result = OnAudioPassThruID; - return true; - } - - if ("OnLanguageChange" == literal) { - *result = OnLanguageChangeID; - return true; - } - - if ("OnKeyboardInput" == literal) { - *result = OnKeyboardInputID; - return true; - } - - if ("OnTouchEvent" == literal) { - *result = OnTouchEventID; - return true; - } - - if ("OnSystemRequest" == literal) { - *result = OnSystemRequestID; - return true; - } - - if ("OnHashChange" == literal) { - *result = OnHashChangeID; - return true; - } - - if ("OnInteriorVehicleData" == literal) { - *result = OnInteriorVehicleDataID; - return true; - } - - if ("OnWayPointChange" == literal) { - *result = OnWayPointChangeID; - return true; - } - - if ("OnRCStatus" == literal) { - *result = OnRCStatusID; - return true; - } - - if ("OnAppServiceData" == literal) { - *result = OnAppServiceDataID; - return true; - } - - if ("OnSystemCapabilityUpdated" == literal) { - *result = OnSystemCapabilityUpdatedID; - return true; - } - - if ("EncodedSyncPData" == literal) { - *result = EncodedSyncPDataID; - return true; - } - - if ("SyncPData" == literal) { - *result = SyncPDataID; - return true; - } - - if ("OnEncodedSyncPData" == literal) { - *result = OnEncodedSyncPDataID; - return true; - } - - if ("OnSyncPData" == literal) { - *result = OnSyncPDataID; - return true; - } - return false; -}; const std::string kDefaultApp = "default"; const std::string kPreDataConsentApp = "pre_DataConsent"; diff --git a/src/components/policy/policy_regular/src/policy_table/types.cc b/src/components/policy/policy_regular/src/policy_table/types.cc index bdf1329dee0..3029ebb0675 100644 --- a/src/components/policy/policy_regular/src/policy_table/types.cc +++ b/src/components/policy/policy_regular/src/policy_table/types.cc @@ -31,7 +31,6 @@ PolicyBase::~PolicyBase() {} PolicyBase::PolicyBase(const Json::Value* value__) : CompositeType(InitHelper(value__, &Json::Value::isObject)) , priority(impl::ValueMember(value__, "priority")) {} - Json::Value PolicyBase::ToJsonValue() const { Json::Value result__(Json::objectValue); impl::WriteJsonField("priority", priority, &result__); @@ -280,7 +279,8 @@ ApplicationParams::ApplicationParams(const Json::Value* value__) , icon_url(impl::ValueMember(value__, "icon_url")) , app_service_parameters(impl::ValueMember(value__, "app_services")) , allow_unknown_rpc_passthrough( - impl::ValueMember(value__, "allow_unknown_rpc_passthrough")) {} + impl::ValueMember(value__, "allow_unknown_rpc_passthrough")) + , encryption_required(impl::ValueMember(value__, "encryption_required")) {} Json::Value ApplicationParams::ToJsonValue() const { Json::Value result__(PolicyBase::ToJsonValue()); @@ -305,6 +305,8 @@ Json::Value ApplicationParams::ToJsonValue() const { impl::WriteJsonField("allow_unknown_rpc_passthrough", allow_unknown_rpc_passthrough, &result__); + impl::WriteJsonField("encryption_required", encryption_required, &result__); + return result__; } @@ -360,6 +362,9 @@ bool ApplicationParams::is_valid() const { if (!allow_unknown_rpc_passthrough.is_valid()) { return false; } + if (!encryption_required.is_valid()) { + return false; + } return Validate(); } @@ -422,6 +427,9 @@ bool ApplicationParams::struct_empty() const { if (allow_unknown_rpc_passthrough.is_initialized()) { return false; } + if (encryption_required.is_initialized()) { + return false; + } return true; } @@ -487,6 +495,10 @@ void ApplicationParams::ReportErrors(rpc::ValidationReport* report__) const { allow_unknown_rpc_passthrough.ReportErrors( &report__->ReportSubobject("allow_unknown_rpc_passthrough")); } + if (!encryption_required.is_valid()) { + encryption_required.ReportErrors( + &report__->ReportSubobject("encryption_required")); + } } void ApplicationParams::SetPolicyTableType(PolicyTableType pt_type) { @@ -535,6 +547,7 @@ bool RpcParameters::is_valid() const { if (!parameters.is_valid()) { return false; } + return Validate(); } @@ -581,12 +594,14 @@ Rpcs::~Rpcs() {} Rpcs::Rpcs(const Json::Value* value__) : CompositeType(InitHelper(value__, &Json::Value::isObject)) , user_consent_prompt(impl::ValueMember(value__, "user_consent_prompt")) - , rpcs(impl::ValueMember(value__, "rpcs")) {} + , rpcs(impl::ValueMember(value__, "rpcs")) + , encryption_required(impl::ValueMember(value__, "encryption_required")) {} Json::Value Rpcs::ToJsonValue() const { Json::Value result__(Json::objectValue); impl::WriteJsonField("user_consent_prompt", user_consent_prompt, &result__); impl::WriteJsonField("rpcs", rpcs, &result__); + impl::WriteJsonField("encryption_required", encryption_required, &result__); return result__; } @@ -597,6 +612,9 @@ bool Rpcs::is_valid() const { if (!rpcs.is_valid()) { return false; } + if (!encryption_required.is_valid()) { + return false; + } return Validate(); } @@ -611,7 +629,9 @@ bool Rpcs::struct_empty() const { if (rpcs.is_initialized()) { return false; } - + if (encryption_required.is_initialized()) { + return false; + } return true; } @@ -626,6 +646,10 @@ void Rpcs::ReportErrors(rpc::ValidationReport* report__) const { if (!rpcs.is_valid()) { rpcs.ReportErrors(&report__->ReportSubobject("rpcs")); } + if (!encryption_required.is_valid()) { + encryption_required.ReportErrors( + &report__->ReportSubobject("encryption_required")); + } } void Rpcs::SetPolicyTableType(PolicyTableType pt_type) { @@ -634,9 +658,60 @@ void Rpcs::SetPolicyTableType(PolicyTableType pt_type) { rpcs.SetPolicyTableType(pt_type); } +// EndpointProperties methods +EndpointProperty::EndpointProperty() : CompositeType(kUninitialized) {} + +EndpointProperty::~EndpointProperty() {} + +EndpointProperty::EndpointProperty(const Json::Value* value__) + : CompositeType(InitHelper(value__, &Json::Value::isObject)) + , version(impl::ValueMember(value__, "version")) {} + +Json::Value EndpointProperty::ToJsonValue() const { + Json::Value result__(Json::objectValue); + impl::WriteJsonField("version", version, &result__); + return result__; +} + +bool EndpointProperty::is_valid() const { + if (!version.is_valid()) { + return false; + } + return Validate(); +} + +bool EndpointProperty::is_initialized() const { + return (initialization_state__ != kUninitialized) || (!struct_empty()); +} + +bool EndpointProperty::struct_empty() const { + if (version.is_initialized()) { + return false; + } + + return true; +} + +void EndpointProperty::ReportErrors(rpc::ValidationReport* report__) const { + if (struct_empty()) { + rpc::CompositeType::ReportErrors(report__); + } + if (!version.is_valid()) { + version.ReportErrors(&report__->ReportSubobject("version")); + } +} + +void EndpointProperty::SetPolicyTableType(PolicyTableType pt_type) { + CompositeType::SetPolicyTableType(pt_type); + version.SetPolicyTableType(pt_type); +} + // ModuleConfig methods ModuleConfig::ModuleConfig() : CompositeType(kUninitialized) {} +const std::string ModuleConfig::kDefaultOemMappingServiceName = + "custom_vehicle_data_mapping_url"; + ModuleConfig::ModuleConfig( uint8_t exchange_after_x_ignition_cycles, int64_t exchange_after_x_kilometers, @@ -644,6 +719,7 @@ ModuleConfig::ModuleConfig( uint16_t timeout_after_x_seconds, const SecondsBetweenRetries& seconds_between_retries, const ServiceEndpoints& endpoints, + const ServiceEndpointProperties& endpoint_properties, const NumberOfNotificationsPerMinute& notifications_per_minute_by_priority) : CompositeType(kUninitialized) , exchange_after_x_ignition_cycles(exchange_after_x_ignition_cycles) @@ -652,6 +728,7 @@ ModuleConfig::ModuleConfig( , timeout_after_x_seconds(timeout_after_x_seconds) , seconds_between_retries(seconds_between_retries) , endpoints(endpoints) + , endpoint_properties(endpoint_properties) , notifications_per_minute_by_priority( notifications_per_minute_by_priority) {} @@ -672,13 +749,16 @@ ModuleConfig::ModuleConfig(const Json::Value* value__) , seconds_between_retries( impl::ValueMember(value__, "seconds_between_retries")) , endpoints(impl::ValueMember(value__, "endpoints")) + , endpoint_properties(impl::ValueMember(value__, "endpoint_properties")) , notifications_per_minute_by_priority( impl::ValueMember(value__, "notifications_per_minute_by_priority")) , vehicle_make(impl::ValueMember(value__, "vehicle_make")) , vehicle_model(impl::ValueMember(value__, "vehicle_model")) , vehicle_year(impl::ValueMember(value__, "vehicle_year")) , preloaded_date(impl::ValueMember(value__, "preloaded_date")) - , certificate(impl::ValueMember(value__, "certificate")) {} + , certificate(impl::ValueMember(value__, "certificate")) + , lock_screen_dismissal_enabled( + impl::ValueMember(value__, "lock_screen_dismissal_enabled")) {} void ModuleConfig::SafeCopyFrom(const ModuleConfig& from) { // device_certificates = from.device_certificates; // According to the @@ -689,9 +769,12 @@ void ModuleConfig::SafeCopyFrom(const ModuleConfig& from) { timeout_after_x_seconds = from.timeout_after_x_seconds; seconds_between_retries = from.seconds_between_retries; endpoints = from.endpoints; + endpoint_properties = from.endpoint_properties; notifications_per_minute_by_priority = from.notifications_per_minute_by_priority; + lock_screen_dismissal_enabled = from.lock_screen_dismissal_enabled; + vehicle_make.assign_if_valid(from.vehicle_make); vehicle_model.assign_if_valid(from.vehicle_model); vehicle_year.assign_if_valid(from.vehicle_year); @@ -715,6 +798,7 @@ Json::Value ModuleConfig::ToJsonValue() const { impl::WriteJsonField( "seconds_between_retries", seconds_between_retries, &result__); impl::WriteJsonField("endpoints", endpoints, &result__); + impl::WriteJsonField("endpoint_properties", endpoint_properties, &result__); impl::WriteJsonField("notifications_per_minute_by_priority", notifications_per_minute_by_priority, &result__); @@ -723,6 +807,9 @@ Json::Value ModuleConfig::ToJsonValue() const { impl::WriteJsonField("vehicle_year", vehicle_year, &result__); impl::WriteJsonField("certificate", certificate, &result__); impl::WriteJsonField("preloaded_date", preloaded_date, &result__); + impl::WriteJsonField("lock_screen_dismissal_enabled", + lock_screen_dismissal_enabled, + &result__); return result__; } @@ -751,9 +838,15 @@ bool ModuleConfig::is_valid() const { if (!endpoints.is_valid()) { return false; } + if (!endpoint_properties.is_valid()) { + return false; + } if (!notifications_per_minute_by_priority.is_valid()) { return false; } + if (!lock_screen_dismissal_enabled.is_valid()) { + return false; + } if (!vehicle_make.is_valid()) { return false; } @@ -801,13 +894,21 @@ bool ModuleConfig::struct_empty() const { if (seconds_between_retries.is_initialized()) { return false; } + if (endpoints.is_initialized()) { return false; } + if (endpoint_properties.is_initialized()) { + return false; + } + if (notifications_per_minute_by_priority.is_initialized()) { return false; } + if (lock_screen_dismissal_enabled.is_initialized()) { + return false; + } if (vehicle_make.is_initialized()) { return false; } @@ -859,10 +960,18 @@ void ModuleConfig::ReportErrors(rpc::ValidationReport* report__) const { if (!endpoints.is_valid()) { endpoints.ReportErrors(&report__->ReportSubobject("endpoints")); } + if (!endpoint_properties.is_valid()) { + endpoint_properties.ReportErrors( + &report__->ReportSubobject("endpoint_properties")); + } if (!notifications_per_minute_by_priority.is_valid()) { notifications_per_minute_by_priority.ReportErrors( &report__->ReportSubobject("notifications_per_minute_by_priority")); } + if (!lock_screen_dismissal_enabled.is_valid()) { + lock_screen_dismissal_enabled.ReportErrors( + &report__->ReportSubobject("lock_screen_dismissal_enabled")); + } if (!vehicle_make.is_valid()) { vehicle_make.ReportErrors(&report__->ReportSubobject("vehicle_make")); } @@ -901,7 +1010,9 @@ void ModuleConfig::SetPolicyTableType(PolicyTableType pt_type) { timeout_after_x_seconds.SetPolicyTableType(pt_type); seconds_between_retries.SetPolicyTableType(pt_type); endpoints.SetPolicyTableType(pt_type); + endpoint_properties.SetPolicyTableType(pt_type); notifications_per_minute_by_priority.SetPolicyTableType(pt_type); + lock_screen_dismissal_enabled.SetPolicyTableType(pt_type); vehicle_make.SetPolicyTableType(pt_type); vehicle_model.SetPolicyTableType(pt_type); vehicle_year.SetPolicyTableType(pt_type); @@ -1521,6 +1632,414 @@ void DeviceParams::ReportErrors(rpc::ValidationReport* report__) const { } } +// VehicleDataItem methods +VehicleDataItem::VehicleDataItem() : CompositeType(kUninitialized) {} + +VehicleDataItem::VehicleDataItem(const VehicleDataItem& vehicle_data) + : CompositeType(vehicle_data.initialization_state__) + , name(vehicle_data.name) + , type(vehicle_data.type) + , key(vehicle_data.key) + , mandatory(vehicle_data.mandatory) + , params(vehicle_data.params) + , array(vehicle_data.array) + , since(vehicle_data.since) + , until(vehicle_data.until) + , removed(vehicle_data.removed) + , deprecated(vehicle_data.deprecated) + , minvalue(vehicle_data.minvalue) + , maxvalue(vehicle_data.maxvalue) + , minsize(vehicle_data.minsize) + , maxsize(vehicle_data.maxsize) + , minlength(vehicle_data.minlength) + , maxlength(vehicle_data.maxlength) {} + +VehicleDataItem::VehicleDataItem(const Json::Value* value__) + : CompositeType(InitHelper(value__, &Json::Value::isObject)) + , name(impl::ValueMember(value__, "name")) + , type(impl::ValueMember(value__, "type")) + , key(impl::ValueMember(value__, "key")) + , mandatory(impl::ValueMember(value__, "mandatory")) + , params(impl::ValueMember(value__, "params")) + , array(impl::ValueMember(value__, "array")) + , since(impl::ValueMember(value__, "since")) + , until(impl::ValueMember(value__, "until")) + , removed(impl::ValueMember(value__, "removed")) + , deprecated(impl::ValueMember(value__, "deprecated")) + , minvalue(impl::ValueMember(value__, "minvalue")) + , maxvalue(impl::ValueMember(value__, "maxvalue")) + , minsize(impl::ValueMember(value__, "minsize")) + , maxsize(impl::ValueMember(value__, "maxsize")) + , minlength(impl::ValueMember(value__, "minlength")) + , maxlength(impl::ValueMember(value__, "maxlength")) {} + +VehicleDataItem::~VehicleDataItem() {} + +const std::string VehicleDataItem::kInteger = "Integer"; +const std::string VehicleDataItem::kStruct = "Struct"; +const std::string VehicleDataItem::kString = "String"; +const std::string VehicleDataItem::kFloat = "Float"; +const std::string VehicleDataItem::kDouble = "Double"; +const std::string VehicleDataItem::kBoolean = "Boolean"; + +const std::vector VehicleDataItem::kPODTypes = { + kInteger, kFloat, kDouble, kString, kBoolean}; + +Json::Value VehicleDataItem::ToJsonValue() const { + Json::Value ret(Json::objectValue); + impl::WriteJsonField("name", name, &ret); + impl::WriteJsonField("type", type, &ret); + impl::WriteJsonField("key", key, &ret); + impl::WriteJsonField("array", array, &ret); + impl::WriteJsonField("mandatory", mandatory, &ret); + impl::WriteJsonField("params", params, &ret); + impl::WriteJsonField("since", since, &ret); + impl::WriteJsonField("until", until, &ret); + impl::WriteJsonField("removed", removed, &ret); + impl::WriteJsonField("deprecated", deprecated, &ret); + impl::WriteJsonField("minvalue", minvalue, &ret); + impl::WriteJsonField("maxvalue", maxvalue, &ret); + impl::WriteJsonField("minsize", minsize, &ret); + impl::WriteJsonField("maxsize", maxsize, &ret); + impl::WriteJsonField("minlength", minlength, &ret); + impl::WriteJsonField("maxlength", maxlength, &ret); + return ret; +} + +bool VehicleDataItem::operator==(const VehicleDataItem& vd) { + return (name == vd.name && type == vd.type && key == vd.key && + mandatory == vd.mandatory && params == vd.params && + array == vd.array && since == vd.since && until == vd.until && + removed == vd.removed && deprecated == vd.deprecated && + minvalue == vd.minvalue && maxvalue == vd.maxvalue && + minsize == vd.minsize && maxsize == vd.maxsize && + minlength == vd.minlength && maxlength == vd.maxlength); +} + +bool VehicleDataItem::is_valid() const { + if (!name.is_valid()) { + return false; + } + if (!type.is_valid()) { + return false; + } + if (!key.is_valid()) { + return false; + } + if (!array.is_valid()) { + return false; + } + if (!mandatory.is_valid()) { + return false; + } + if (!params.is_valid()) { + return false; + } + if (!since.is_valid()) { + return false; + } + if (!until.is_valid()) { + return false; + } + if (!removed.is_valid()) { + return false; + } + if (!deprecated.is_valid()) { + return false; + } + if (!minvalue.is_valid()) { + return false; + } + if (!maxvalue.is_valid()) { + return false; + } + if (!minsize.is_valid()) { + return false; + } + if (!maxsize.is_valid()) { + return false; + } + if (!minlength.is_valid()) { + return false; + } + if (!maxlength.is_valid()) { + return false; + } + return Validate(); +} + +bool VehicleDataItem::is_initialized() const { + return (initialization_state__ != kUninitialized) || (struct_not_empty()); +} + +bool VehicleDataItem::struct_not_empty() const { + if (!name.is_initialized()) { + return false; + } + if (!type.is_initialized()) { + return false; + } + if (!key.is_initialized()) { + return false; + } + if (!array.is_initialized()) { + return false; + } + if (!mandatory.is_initialized()) { + return false; + } + if (!params.is_initialized()) { + return false; + } + if (!since.is_initialized()) { + return false; + } + if (!until.is_initialized()) { + return false; + } + if (!removed.is_initialized()) { + return false; + } + if (!deprecated.is_initialized()) { + return false; + } + if (!minvalue.is_initialized()) { + return false; + } + if (!maxvalue.is_initialized()) { + return false; + } + if (!minsize.is_initialized()) { + return false; + } + if (!maxsize.is_initialized()) { + return false; + } + if (!minlength.is_initialized()) { + return false; + } + if (!maxlength.is_initialized()) { + return false; + } + return true; +} + +void VehicleDataItem::ReportErrors(rpc::ValidationReport* report__) const { + if (!struct_not_empty()) { + rpc::CompositeType::ReportErrors(report__); + } + if (!name.is_valid()) { + name.ReportErrors(&report__->ReportSubobject("name")); + } + if (!ValidateNaming(std::string(name))) { + report__->set_validation_info( + "Invalid name values [" + std::string(name) + + "]. It should not contain spaces or invalid chars."); + } + if (!type.is_valid()) { + type.ReportErrors(&report__->ReportSubobject("type")); + } + if (type.is_initialized() && !ValidateTypes()) { + report__->set_validation_info("Unknown type [" + std::string(name) + + "]: '" + std::string(type) + "'."); + } + if (!key.is_valid()) { + key.ReportErrors(&report__->ReportSubobject("key")); + } + if (!ValidateNaming(std::string(key))) { + report__->set_validation_info( + "Invalid key values [" + std::string(key) + + "]. It should not contain spaces or invalid chars."); + } + if (!array.is_valid()) { + array.ReportErrors(&report__->ReportSubobject("array")); + } + if (!mandatory.is_valid()) { + mandatory.ReportErrors(&report__->ReportSubobject("mandatory")); + } + if (!params.is_valid()) { + params.ReportErrors(&report__->ReportSubobject("params")); + } + if (!since.is_valid()) { + since.ReportErrors(&report__->ReportSubobject("since")); + } + if (!until.is_valid()) { + until.ReportErrors(&report__->ReportSubobject("until")); + } + if (!removed.is_valid()) { + removed.ReportErrors(&report__->ReportSubobject("removed")); + } + if (!deprecated.is_valid()) { + deprecated.ReportErrors(&report__->ReportSubobject("deprecated")); + } + if (!minvalue.is_valid()) { + minvalue.ReportErrors(&report__->ReportSubobject("minvalue")); + } + if (!maxvalue.is_valid()) { + maxvalue.ReportErrors(&report__->ReportSubobject("maxvalue")); + } + if (!minsize.is_valid()) { + minsize.ReportErrors(&report__->ReportSubobject("minsize")); + } + if (!maxsize.is_valid()) { + maxsize.ReportErrors(&report__->ReportSubobject("maxsize")); + } + if (!minlength.is_valid()) { + minlength.ReportErrors(&report__->ReportSubobject("minlength")); + } + if (!maxlength.is_valid()) { + maxlength.ReportErrors(&report__->ReportSubobject("maxlength")); + } +} + +void VehicleDataItem::SetPolicyTableType(PolicyTableType pt_type) { + CompositeType::SetPolicyTableType(pt_type); + name.SetPolicyTableType(pt_type); + type.SetPolicyTableType(pt_type); + key.SetPolicyTableType(pt_type); + array.SetPolicyTableType(pt_type); + mandatory.SetPolicyTableType(pt_type); + params.SetPolicyTableType(pt_type); + since.SetPolicyTableType(pt_type); + until.SetPolicyTableType(pt_type); + removed.SetPolicyTableType(pt_type); + deprecated.SetPolicyTableType(pt_type); + minvalue.SetPolicyTableType(pt_type); + maxvalue.SetPolicyTableType(pt_type); + minsize.SetPolicyTableType(pt_type); + maxsize.SetPolicyTableType(pt_type); + minlength.SetPolicyTableType(pt_type); + maxlength.SetPolicyTableType(pt_type); +} + +bool VehicleDataItem::ValidateNaming(std::string str) const { + auto contains_spec_chars = [](std::string str) { + const auto invalid_chars = "!@#$%^&*"; + return str.npos != str.find_first_of(invalid_chars); + }; + + auto contains_spaces = [](std::string str) { + const auto found_space = + std::find_if(str.begin(), str.end(), [](unsigned char ch) { + return std::isspace(ch); + }); + + return found_space != str.end(); + }; + + auto empty_string = [](std::string str) { + str.erase(std::remove_if(str.begin(), + str.end(), + [](unsigned char ch) { return std::isspace(ch); }), + str.end()); + return str.length() < 1; + }; + + return !empty_string(str) && !contains_spaces(str) && + !contains_spec_chars(str); +} + +bool VehicleDataItem::ValidateTypes() const { + if (VehicleDataItem::kStruct == std::string(type)) { + return params.is_initialized() && !(params->empty()) && params.is_valid(); + } + // params should be empty for POD types and for enum values + return (!(params.is_initialized()) || params->empty()); +} + +bool VehicleDataItem::IsPrimitiveType() const { + return helpers::in_range(kPODTypes, std::string(type)); +} + +// VehicleData methods +VehicleData::VehicleData() : CompositeType(kUninitialized) {} + +VehicleData::VehicleData(const VehicleData& vehicle_data) + : CompositeType(vehicle_data.initialization_state__) + , schema_version(vehicle_data.schema_version) + , schema_items(vehicle_data.schema_items) {} + +VehicleData::VehicleData(const Json::Value* value__) + : CompositeType(InitHelper(value__, &Json::Value::isObject)) + , schema_version(impl::ValueMember(value__, "schema_version")) + , schema_items(impl::ValueMember(value__, "schema_items")) {} + +VehicleData::~VehicleData() {} + +bool VehicleData::is_valid() const { + if (!schema_version.is_valid()) { + return false; + } + if (!schema_items.is_valid()) { + return false; + } + return Validate(); +} + +bool VehicleData::is_initialized() const { + return (initialization_state__ != kUninitialized) || (!struct_empty()); +} + +bool VehicleData::struct_empty() const { + if (schema_version.is_initialized()) { + return false; + } + if (schema_items.is_initialized()) { + return false; + } + return true; +} + +Json::Value VehicleData::ToJsonValue() const { + Json::Value ret(Json::objectValue); + impl::WriteJsonField("schema_version", schema_version, &ret); + impl::WriteJsonField("schema_items", schema_items, &ret); + return ret; +} + +void VehicleData::ReportErrors(rpc::ValidationReport* report__) const { + if (struct_empty()) { + rpc::CompositeType::ReportErrors(report__); + } + const auto pt_type = GetPolicyTableType(); + const auto pt_type_str = PolicyTableTypeToString(pt_type); + std::string validation_info = ""; + + if (PT_SNAPSHOT == pt_type) { + if (schema_items.is_initialized()) { + validation_info += + "; schema_items " + omitted_validation_info + pt_type_str; + } + if (!schema_version.is_initialized()) { + validation_info += + "; schema_version " + required_validation_info + pt_type_str; + } + report__->set_validation_info(validation_info); + } + + if (PT_UPDATE == pt_type || PT_PRELOADED == pt_type) { + if ((schema_version.is_initialized() && !schema_items.is_initialized()) || + (!schema_version.is_initialized() && schema_items.is_initialized())) { + validation_info += "; schema_version and schema_items " + + required_validation_info + pt_type_str; + } + report__->set_validation_info(validation_info); + } + + if (!schema_version.is_valid()) { + schema_version.ReportErrors(&report__->ReportSubobject("schema_version")); + } + if (!schema_items.is_valid()) { + schema_items.ReportErrors(&report__->ReportSubobject("schema_items")); + } +} + +void VehicleData::SetPolicyTableType(PolicyTableType pt_type) { + CompositeType::SetPolicyTableType(pt_type); + schema_version.SetPolicyTableType(pt_type); + schema_items.SetPolicyTableType(pt_type); +} + // PolicyTable methods PolicyTable::PolicyTable() : CompositeType(kUninitialized) {} @@ -1547,7 +2066,8 @@ PolicyTable::PolicyTable(const Json::Value* value__) , module_meta(impl::ValueMember(value__, "module_meta")) , usage_and_error_counts( impl::ValueMember(value__, "usage_and_error_counts")) - , device_data(impl::ValueMember(value__, "device_data")) {} + , device_data(impl::ValueMember(value__, "device_data")) + , vehicle_data(impl::ValueMember(value__, "vehicle_data")) {} Json::Value PolicyTable::ToJsonValue() const { Json::Value result__(Json::objectValue); @@ -1560,6 +2080,7 @@ Json::Value PolicyTable::ToJsonValue() const { impl::WriteJsonField( "usage_and_error_counts", usage_and_error_counts, &result__); impl::WriteJsonField("device_data", device_data, &result__); + impl::WriteJsonField("vehicle_data", vehicle_data, &result__); return result__; } @@ -1585,6 +2106,9 @@ bool PolicyTable::is_valid() const { if (!device_data.is_valid()) { return false; } + if (!vehicle_data.is_valid()) { + return false; + } return Validate(); } @@ -1617,6 +2141,9 @@ bool PolicyTable::struct_empty() const { if (device_data.is_initialized()) { return false; } + if (vehicle_data.is_initialized()) { + return false; + } return true; } @@ -1659,6 +2186,9 @@ void PolicyTable::ReportErrors(rpc::ValidationReport* report__) const { if (!device_data.is_valid()) { device_data.ReportErrors(&report__->ReportSubobject("device_data")); } + if (!vehicle_data.is_valid()) { + vehicle_data.ReportErrors(&report__->ReportSubobject("vehicle_data")); + } } void PolicyTable::SetPolicyTableType(PolicyTableType pt_type) { @@ -1670,6 +2200,7 @@ void PolicyTable::SetPolicyTableType(PolicyTableType pt_type) { module_meta.SetPolicyTableType(pt_type); usage_and_error_counts.SetPolicyTableType(pt_type); device_data.SetPolicyTableType(pt_type); + vehicle_data.SetPolicyTableType(pt_type); } // Table methods diff --git a/src/components/policy/policy_regular/src/policy_table/validation.cc b/src/components/policy/policy_regular/src/policy_table/validation.cc index 4db84e06ffc..14b6d657c28 100644 --- a/src/components/policy/policy_regular/src/policy_table/validation.cc +++ b/src/components/policy/policy_regular/src/policy_table/validation.cc @@ -7,7 +7,7 @@ bool IsTypeInvalid( rpc::Enum request) { return !request.is_valid(); } -} +} // namespace namespace rpc { namespace policy_table_interface_base { @@ -196,6 +196,14 @@ bool Rpcs::Validate() const { return true; } +bool EndpointProperty::Validate() const { + if (!version.is_valid()) { + return false; + } + + return true; +} + bool ModuleConfig::Validate() const { if (PT_PRELOADED == GetPolicyTableType()) { if (vehicle_make.is_initialized()) { @@ -221,6 +229,14 @@ bool ModuleConfig::Validate() const { } } + if (endpoint_properties.is_initialized()) { + const auto& endpoint_property = + endpoint_properties->find(kDefaultOemMappingServiceName); + if (endpoint_properties->end() != endpoint_property) { + return (*endpoint_property).second.version.is_initialized(); + } + } + return true; } @@ -268,6 +284,39 @@ bool DeviceParams::Validate() const { return true; } +bool VehicleDataItem::Validate() const { + if (!ValidateNaming(std::string(name))) { + return false; + }; + + if (!ValidateNaming(std::string(key))) { + return false; + }; + + if (!ValidateTypes()) { + LOG4CXX_ERROR( + logger_, + "Unknown type: " << std::string(type) << " of " << std::string(key)); + return false; + } + return true; +} + +bool VehicleData::Validate() const { + const PolicyTableType policy_table_type = GetPolicyTableType(); + bool result = true; + if (PT_SNAPSHOT == policy_table_type) { + result = + (!schema_items.is_initialized()) && schema_version.is_initialized(); + } + if (PT_UPDATE == policy_table_type || PT_PRELOADED == policy_table_type) { + result = + (schema_version.is_initialized() && schema_items.is_initialized()) || + (!schema_version.is_initialized() && !schema_items.is_initialized()); + } + return result; +} + bool PolicyTable::Validate() const { const PolicyTableType policy_table_type = GetPolicyTableType(); 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 a97b0ab1539..6c961a8db37 100644 --- a/src/components/policy/policy_regular/src/sql_pt_queries.cc +++ b/src/components/policy/policy_regular/src/sql_pt_queries.cc @@ -71,12 +71,14 @@ const std::string kCreateSchema = " `certificate` TEXT, " " `vehicle_make` VARCHAR(45), " " `vehicle_model` VARCHAR(45), " - " `vehicle_year` VARCHAR(4) " + " `vehicle_year` VARCHAR(4), " + " `lock_screen_dismissal_enabled` BOOL" "); " "CREATE TABLE IF NOT EXISTS `functional_group`( " " `id` INTEGER PRIMARY KEY NOT NULL, " " `user_consent_prompt` TEXT, " - " `name` VARCHAR(100) NOT NULL " + " `name` VARCHAR(100) NOT NULL, " + " `encryption_required` BOOLEAN " "); " "CREATE TABLE IF NOT EXISTS `priority`( " " `value` VARCHAR(45) PRIMARY KEY NOT NULL " @@ -145,6 +147,7 @@ const std::string kCreateSchema = " `icon_url` VARCHAR(65535), " " `allow_unknown_rpc_passthrough` BOOLEAN, " " `remote_control_denied` BOOLEAN NOT NULL DEFAULT 0, " + " `encryption_required` BOOLEAN, " " CONSTRAINT `fk_application_hmi_level1` " " FOREIGN KEY(`default_hmi`) " " REFERENCES `hmi_level`(`value`), " @@ -349,6 +352,13 @@ const std::string kCreateSchema = "); " "CREATE INDEX IF NOT EXISTS `endpoint.fk_endpoint_application1_idx` " " ON `endpoint`(`application_id` COLLATE NOCASE); " + + /*endpoint properties*/ + "CREATE TABLE IF NOT EXISTS `endpoint_properties`( " + " `service` VARCHAR(100) NOT NULL, " + " `version` VARCHAR(100) NOT NULL " + ");" + "CREATE TABLE IF NOT EXISTS `message`( " " `id` INTEGER PRIMARY KEY NOT NULL, " " `tts` TEXT, " @@ -406,6 +416,42 @@ const std::string kCreateSchema = "CREATE TABLE IF NOT EXISTS `_internal_data`( " " `db_version_hash` INTEGER " " ); " + + /*vehicle data*/ + "CREATE TABLE IF NOT EXISTS `vehicle_data`( " + " `schema_version` VARCHAR(100) NOT NULL " + ");" + + /* vehicle data item definition*/ + "CREATE TABLE IF NOT EXISTS `vehicle_data_item_definition`( " + " `name` VARCHAR(255) NOT NULL, " + " `type` VARCHAR(255) NOT NULL, " + " `key` VARCHAR(255) NOT NULL, " + " `mandatory` BOOL NOT NULL, " + " `array` BOOL, " + " `since` VARCHAR(45), " + " `until` VARCHAR(45), " + " `removed` BOOL, " + " `deprecated` BOOL, " + " `minvalue` INTEGER, " + " `maxvalue` INTEGER, " + " `minsize` INTEGER, " + " `maxsize` INTEGER, " + " `minlength` INTEGER, " + " `maxlength` INTEGER " + "); " + "CREATE TABLE IF NOT EXISTS `vehicle_data_item_parameters`( " + " `parent_name` VARCHAR(255) NOT NULL, " + " `parent_key` VARCHAR(255) NOT NULL, " + " `param_name` VARCHAR(255) NOT NULL, " + " `param_key` VARCHAR(255) NOT NULL, " + " CONSTRAINT `fk_vdi_id` " + " FOREIGN KEY(`parent_name`, `parent_key`) " + " REFERENCES `vehicle_data_item_definition`(`name`, `key`), " + " CONSTRAINT `fk_vdi_param_id` " + " FOREIGN KEY(`param_name`, `param_key`) " + " REFERENCES `vehicle_data_item_definition`(`name`, `key`) " + "); " "COMMIT;"; const std::string kInsertInitData = @@ -419,8 +465,10 @@ const std::string kInsertInitData = " VALUES (0, 0, 0, 0); " "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`) " + " `exchange_after_x_days`, `timeout_after_x_seconds`)" " VALUES(1, 0, 0, 0, 0, 0); " + "INSERT OR IGNORE INTO `vehicle_data` (`schema_version`) " + "VALUES('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'); " @@ -485,6 +533,7 @@ const std::string kDropSchema = "DROP TABLE IF EXISTS `message`; " "DROP INDEX IF EXISTS `endpoint.fk_endpoint_application1_idx`; " "DROP TABLE IF EXISTS `endpoint`; " + "DROP TABLE IF EXISTS `endpoint_properties`; " "DROP INDEX IF EXISTS `consent_group.fk_consent_group_device1_idx`; " "DROP INDEX IF EXISTS " "`consent_group.fk_consent_group_functional_group1_idx`; " @@ -547,6 +596,9 @@ const std::string kDropSchema = "DROP TABLE IF EXISTS `usage_and_error_count`; " "DROP TABLE IF EXISTS `device`; " "DROP TABLE IF EXISTS `_internal_data`; " + "DROP TABLE IF EXISTS `vehicle_data`; " + "DROP TABLE IF EXISTS `vehicle_data_item_definition`; " + "DROP TABLE IF EXISTS `vehicle_data_item_parameters`; " "COMMIT; " "VACUUM;"; @@ -555,6 +607,7 @@ const std::string kDeleteData = "DELETE FROM `message`; " "DELETE FROM `module_type`; " "DELETE FROM `endpoint`; " + "DELETE FROM `endpoint_properties`; " "DELETE FROM `consent_group`; " "DELETE FROM `app_type`; " "DELETE FROM `nickname`; " @@ -578,6 +631,9 @@ const std::string kDeleteData = "DELETE FROM `remote_rpc`; " "DELETE FROM `usage_and_error_count`; " "DELETE FROM `device`; " + "DELETE FROM `vehicle_data`; " + "DELETE FROM `vehicle_data_item_definition`; " + "DELETE FROM `vehicle_data_item_parameters`; " "COMMIT; " "VACUUM;"; @@ -585,6 +641,82 @@ const std::string kCheckDBIntegrity = "PRAGMA integrity_check"; const std::string kCheckPgNumber = "PRAGMA page_count"; +const std::string kSelectEndpointProperties = + "SELECT `service`, `version` FROM `endpoint_properties`"; + +const std::string kSelectVehicleDataSchemaVersion = + "SELECT `schema_version` FROM `vehicle_data` "; + +const std::string kSelectVehicleDataItem = + "SELECT * FROM `vehicle_data_item_definition` " + "WHERE `name` IS ? AND `key` IS ?"; + +const std::string kSelectVehicleDataItemWithVersion = + "SELECT * FROM `vehicle_data_item_definition` " + "WHERE `name` IS ? AND `key` IS ? AND `since` IS ? AND `until` IS ?"; + +const std::string kSelectVehicleDataItemParams = + "SELECT * FROM `vehicle_data_item_parameters` " + "WHERE `parent_name` IS ? AND `parent_key` IS ?"; + +const std::string kSelectCompositeVehicleDataItemsKey = + "SELECT DISTINCT `parent_name`, `parent_key` FROM " + "`vehicle_data_item_parameters` " + "LEFT JOIN " + "(SELECT DISTINCT `param_name`, `param_key` FROM " + "`vehicle_data_item_parameters`) `vdi_params` ON " + "`vehicle_data_item_parameters`.`parent_name` = `vdi_params`.`param_name` " + "AND " + "`vehicle_data_item_parameters`.`parent_key` = `vdi_params`.`param_key` " + "where `vdi_params`.`param_key` is null"; + +const std::string kSelectPrimitiveVehicleDataItems = + "SELECT * FROM `vehicle_data_item_definition` " + "LEFT JOIN ( " + "SELECT `parent_name`, `parent_key` FROM `vehicle_data_item_parameters` " + "UNION " + "SELECT `param_name`, `param_key` FROM `vehicle_data_item_parameters`) " + "`vdi_params` ON " + "`vehicle_data_item_definition`.`name` = `vdi_params`.`parent_name` " + "AND " + "`vehicle_data_item_definition`.`key` = `vdi_params`.`parent_key` " + "WHERE `vdi_params`.`parent_key` IS NULL"; + +const std::string kInsertVehicleDataSchemaVersion = + "UPDATE `vehicle_data` SET `schema_version` = ?"; + +const std::string kInsertEndpointVersion = + "INSERT OR REPLACE INTO `endpoint_properties`(`service`, " + "`version`) " + "VALUES(?, ?)"; + +const std::string kInsertVehicleDataItem = + "INSERT INTO `vehicle_data_item_definition` (" + " `name`, " + " `type`, " + " `key`, " + " `mandatory`, " + " `array`, " + " `since`, " + " `until`, " + " `removed`, " + " `deprecated`, " + " `minvalue`, " + " `maxvalue`, " + " `minsize`, " + " `maxsize`, " + " `minlength`, " + " `maxlength`) " + "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) "; + +const std::string kInsertVehicleDataItemParams = + "INSERT INTO `vehicle_data_item_parameters` (" + " `parent_name`, " + " `parent_key`, " + " `param_name`, " + " `param_key`) " + "VALUES (?, ?, ?, ?) "; + const std::string kSelectRpc = "SELECT DISTINCT `rpc`.`parameter` FROM `rpc` " " JOIN `app_group` AS `g` ON (`g`.`functional_group_id` = " @@ -611,8 +743,9 @@ const std::string kSelectLockScreenIcon = "SELECT `url` FROM `endpoint` WHERE `service` = ? AND `application_id` = ?"; const std::string kInsertFunctionalGroup = - "INSERT INTO `functional_group` (`id`, `name`, `user_consent_prompt`) " - " VALUES (?, ?, ?)"; + "INSERT INTO `functional_group` (`id`, `name`, `user_consent_prompt`, " + "`encryption_required`) " + " VALUES (?, ?, ?, ?)"; const std::string kInsertRpc = "INSERT INTO `rpc` (`name`, `hmi_level_value`, `functional_group_id`) " @@ -627,9 +760,10 @@ const std::string kInsertApplication = "INSERT OR IGNORE INTO `application` (`id`, `priority_value`, " "`is_revoked`, `memory_kb`, `heart_beat_timeout_ms`, `certificate`, " "`hybrid_app_preference_value`, `endpoint`, `enabled`, `auth_token`, " - "`cloud_transport_type`, `icon_url`, `allow_unknown_rpc_passthrough`) " + "`cloud_transport_type`, `icon_url`, `allow_unknown_rpc_passthrough` " + ",`encryption_required`) " "VALUES " - "(?,?,?,?,?,?,?,?,?,?,?,?,?)"; + "(?,?,?,?,?,?,?,?,?,?,?,?,?,?)"; const std::string kInsertAppGroup = "INSERT INTO `app_group` (`application_id`, `functional_group_id`)" @@ -674,15 +808,17 @@ const std::string kInsertLanguage = "INSERT OR IGNORE INTO `language` (`code`) VALUES (?)"; const std::string kInsertMessageString = - "INSERT INTO `message` (`language_code`, `message_type_name`) " - "VALUES (?, ?)"; + "INSERT INTO `message` (`language_code`, `message_type_name`, `tts`, " + "`label`, `line1`, `line2`, `textBody`) " + "VALUES (?, ?, ?, ?, ?, ?, ?)"; const std::string kUpdateModuleConfig = "UPDATE `module_config` SET `preloaded_pt` = ?, " " `exchange_after_x_ignition_cycles` = ?," " `exchange_after_x_kilometers` = ?, `exchange_after_x_days` = ?, " " `timeout_after_x_seconds` = ?, `certificate` = ?, `vehicle_make` = ?, " - " `vehicle_model` = ?, `vehicle_year` = ? "; + " `vehicle_model` = ?, `vehicle_year` = ?, lock_screen_dismissal_enabled " + "= ?"; const std::string kInsertEndpoint = "INSERT INTO `endpoint` (`service`, `url`, `application_id`) " @@ -722,7 +858,7 @@ const std::string kSelectModuleConfig = "SELECT `preloaded_pt`, `exchange_after_x_ignition_cycles`, " " `exchange_after_x_kilometers`, `exchange_after_x_days`, " " `timeout_after_x_seconds`, `certificate`, `vehicle_make`," - " `vehicle_model`, `vehicle_year` " + " `vehicle_model`, `vehicle_year` ,`lock_screen_dismissal_enabled`" " FROM `module_config`"; const std::string kSelectEndpoints = @@ -741,7 +877,7 @@ const std::string kSelectAppLevels = const std::string kSelectDeviceData = "SELECT * FROM `device`"; const std::string kSelectFunctionalGroups = - "SELECT `id`,`name`, `user_consent_prompt` " + "SELECT `id`,`name`, `user_consent_prompt`, `encryption_required` " "FROM `functional_group`"; const std::string kSelectAllRpcs = @@ -755,7 +891,7 @@ const std::string kSelectAppPolicies = "SELECT `id`, `priority_value`, `memory_kb`, " " `heart_beat_timeout_ms`, `certificate`, `hybrid_app_preference_value`, " " `endpoint`, `enabled`, `auth_token`, `cloud_transport_type`, `icon_url`, " - " `allow_unknown_rpc_passthrough` " + " `allow_unknown_rpc_passthrough`, `encryption_required`" "FROM " " `application`"; @@ -853,6 +989,12 @@ const std::string kDeleteAppServiceNames = "DELETE FROM `app_service_names`"; const std::string kDeleteAppServiceHandledRpcs = "DELETE FROM `app_service_handled_rpcs`"; +const std::string kDeleteVehicleDataItems = + "DELETE FROM `vehicle_data_item_definition`"; + +const std::string kDeleteVehicleDataItemParams = + "DELETE FROM `vehicle_data_item_parameters`"; + const std::string kSelectApplicationRevoked = "SELECT `is_revoked` FROM `application` WHERE `id` = ?"; @@ -880,16 +1022,17 @@ const std::string kInsertApplicationFull = " `is_predata`, `memory_kb`, `heart_beat_timeout_ms`, " " `certificate`, `hybrid_app_preference_value`, `endpoint`, `enabled`, " " `auth_token`, `cloud_transport_type`, `icon_url`, " - "`allow_unknown_rpc_passthrough`) " - " VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"; + "`allow_unknown_rpc_passthrough`, `encryption_required`)" + " VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"; const std::string kSelectApplicationFull = - "SELECT `keep_context`, `steal_focus`, `default_hmi`, `priority_value`, " + "SELECT `keep_context`, `steal_focus`, `default_hmi`, " + "`priority_value`, " " `is_revoked`, `is_default`, `is_predata`, `memory_kb`," " `heart_beat_timeout_ms`, `certificate`, `hybrid_app_preference_value`, " " `endpoint`, `enabled`, `auth_token`, `cloud_transport_type`, " "`icon_url`, " - " `allow_unknown_rpc_passthrough` " + " `allow_unknown_rpc_passthrough`, `encryption_required`" "FROM `application` " "WHERE `id` = " "?"; @@ -907,6 +1050,5 @@ const std::string kSaveModuleMeta = "`ignition_cycles_since_last_exchange` = ? "; const std::string kSelectModuleMeta = "SELECT* FROM `module_meta`"; - } // namespace sql_pt } // namespace policy 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 c6f78d6d700..7b2d01ef530 100644 --- a/src/components/policy/policy_regular/src/sql_pt_representation.cc +++ b/src/components/policy/policy_regular/src/sql_pt_representation.cc @@ -30,22 +30,22 @@ POSSIBILITY OF SUCH DAMAGE. */ -#include -#include -#include #include +#include +#include #include +#include -#include "utils/logger.h" +#include "config_profile/profile.h" +#include "policy/cache_manager.h" +#include "policy/policy_helper.h" +#include "policy/sql_pt_queries.h" +#include "policy/sql_pt_representation.h" +#include "policy/sql_wrapper.h" #include "utils/date_time.h" #include "utils/file_system.h" #include "utils/gen_hash.h" -#include "policy/sql_pt_representation.h" -#include "policy/sql_wrapper.h" -#include "policy/sql_pt_queries.h" -#include "policy/policy_helper.h" -#include "policy/cache_manager.h" -#include "config_profile/profile.h" +#include "utils/logger.h" namespace policy { @@ -81,9 +81,9 @@ void SQLPTRepresentation::CheckPermissions(const PTString& app_id, utils::dbms::SQLQuery query(db()); if (!query.Prepare(sql_pt::kSelectRpc)) { - LOG4CXX_WARN(logger_, - "Incorrect select statement from rpcs" - << query.LastError().text()); + LOG4CXX_WARN( + logger_, + "Incorrect select statement from rpcs" << query.LastError().text()); return; } query.Bind(0, app_id); @@ -378,9 +378,9 @@ InitResult SQLPTRepresentation::Init(const PolicySettings* settings) { utils::dbms::SQLQuery check_first_run(db()); if (check_first_run.Prepare(sql_pt::kIsFirstRun) && check_first_run.Next()) { - LOG4CXX_INFO(logger_, - "Selecting is first run " - << check_first_run.GetBoolean(0)); + LOG4CXX_INFO( + logger_, + "Selecting is first run " << check_first_run.GetBoolean(0)); if (check_first_run.GetBoolean(0)) { utils::dbms::SQLQuery set_not_first_run(db()); set_not_first_run.Exec(sql_pt::kSetNotFirstRun); @@ -421,16 +421,6 @@ bool SQLPTRepresentation::Close() { return db_->LastError().number() == utils::dbms::OK; } -const VehicleInfo SQLPTRepresentation::GetVehicleInfo() const { - policy_table::ModuleConfig module_config; - GatherModuleConfig(&module_config); - VehicleInfo vehicle_info; - vehicle_info.vehicle_make = *module_config.vehicle_make; - vehicle_info.vehicle_model = *module_config.vehicle_model; - vehicle_info.vehicle_year = *module_config.vehicle_year; - return vehicle_info; -} - bool SQLPTRepresentation::Drop() { utils::dbms::SQLQuery query(db()); if (!query.Exec(sql_pt::kDropSchema)) { @@ -495,6 +485,11 @@ std::shared_ptr SQLPTRepresentation::GenerateSnapshot() GatherConsumerFriendlyMessages( &*table->policy_table.consumer_friendly_messages); GatherApplicationPoliciesSection(&table->policy_table.app_policies_section); + GatherVehicleData(&*table->policy_table.vehicle_data); + if (!table->policy_table.vehicle_data.is_initialized()) { + rpc::Optional > null_version; + table->policy_table.vehicle_data->schema_version = null_version; + } return table; } @@ -525,7 +520,9 @@ void SQLPTRepresentation::GatherModuleConfig( *config->vehicle_make = query.GetString(6); *config->vehicle_model = query.GetString(7); *config->vehicle_year = query.GetString(8); - *config->preloaded_date = query.GetString(9); + if (!query.IsNull(9)) { + *config->lock_screen_dismissal_enabled = query.GetBoolean(9); + } } utils::dbms::SQLQuery endpoints(db()); @@ -540,6 +537,18 @@ void SQLPTRepresentation::GatherModuleConfig( } } + utils::dbms::SQLQuery endpoint_properties(db()); + if (!endpoint_properties.Prepare(sql_pt::kSelectEndpointProperties)) { + LOG4CXX_ERROR(logger_, "Incorrect statement for Endpoint properties"); + } else { + while (endpoint_properties.Next()) { + const std::string& service = endpoint_properties.GetString(0); + const std::string& version = endpoint_properties.GetString(1); + auto& ep_properties = (*config->endpoint_properties); + *ep_properties[service].version = version; + } + } + utils::dbms::SQLQuery notifications(db()); if (!notifications.Prepare(sql_pt::kSelectNotificationsPerMin)) { LOG4CXX_WARN(logger_, "Incorrect select statement for notifications"); @@ -614,6 +623,10 @@ bool SQLPTRepresentation::GatherFunctionalGroupings( *rpcs_structure.user_consent_prompt = functional_group.GetString(2); } + if (!functional_group.IsNull(3)) { + *rpcs_structure.encryption_required = functional_group.GetBoolean(3); + } + const int group_id = functional_group.GetInteger(0); // Collecting RPCs with their HMI levels and parameters (if any) @@ -627,18 +640,17 @@ bool SQLPTRepresentation::GatherFunctionalGroupings( } } if (!rpcs.IsNull(2)) { - policy_table::Parameter param; - if (EnumFromJsonString(rpcs.GetString(2), ¶m)) { - // EMPTY is a special mark to specify that 'parameters' section is - // present, but has no parameters. It is not valid parameter value. - if (policy_table::P_EMPTY == param) { - (*rpcs_structure.rpcs[rpcs.GetString(0)].parameters) - .mark_initialized(); - continue; - } - InsertUnique(param, - &(*rpcs_structure.rpcs[rpcs.GetString(0)].parameters)); + std::string param = rpcs.GetString(2); + // EMPTY is a special mark to specify that 'parameters' section is + // present, but has no parameters. It is not valid parameter value. + if (policy_table::EnumToJsonString(policy_table::P_EMPTY) == param) { + (*rpcs_structure.rpcs[rpcs.GetString(0)].parameters) + .mark_initialized(); + continue; } + + InsertUnique(param, + &(*rpcs_structure.rpcs[rpcs.GetString(0)].parameters)); } } @@ -668,10 +680,33 @@ bool SQLPTRepresentation::GatherConsumerFriendlyMessages( if (query.Prepare(sql_pt::kCollectFriendlyMsg)) { while (query.Next()) { UserFriendlyMessage msg; + + msg.tts = query.GetString(1); + msg.label = query.GetString(2); + msg.line1 = query.GetString(3); + msg.line2 = query.GetString(4); + msg.text_body = query.GetString(5); msg.message_code = query.GetString(7); - std::string language = query.GetString(6); - (*messages->messages)[msg.message_code].languages[language]; + std::string language = query.GetString(6); + policy_table::Languages& languages = + (*messages->messages)[msg.message_code].languages; + policy_table::MessageString& specific_message = languages[language]; + if (!msg.tts.empty()) { + *(specific_message).tts = msg.tts; + } + if (!msg.label.empty()) { + *(specific_message).label = msg.label; + } + if (!msg.line1.empty()) { + *(specific_message).line1 = msg.line1; + } + if (!msg.line2.empty()) { + *(specific_message).line2 = msg.line2; + } + if (!msg.text_body.empty()) { + *(specific_message).textBody = msg.text_body; + } } } else { LOG4CXX_WARN(logger_, "Incorrect statement for select friendly messages."); @@ -716,6 +751,7 @@ bool SQLPTRepresentation::GatherApplicationPoliciesSection( params.priority = priority; *params.memory_kb = query.GetInteger(2); + *params.heart_beat_timeout_ms = query.GetUInteger(3); if (!query.IsNull(4)) { *params.certificate = query.GetString(4); @@ -736,6 +772,10 @@ bool SQLPTRepresentation::GatherApplicationPoliciesSection( *params.icon_url = query.GetString(10); *params.allow_unknown_rpc_passthrough = query.GetBoolean(11); + if (!query.IsNull(12)) { + *params.encryption_required = query.GetBoolean(12); + } + const auto& gather_app_id = ((*policies).apps[app_id].is_string()) ? (*policies).apps[app_id].get_string() : app_id; @@ -778,6 +818,44 @@ bool SQLPTRepresentation::GatherApplicationPoliciesSection( return true; } +bool SQLPTRepresentation::GatherVehicleData( + policy_table::VehicleData* vehicle_data) const { + utils::dbms::SQLQuery query(db()); + if (!query.Prepare(sql_pt::kSelectVehicleDataSchemaVersion) || + !query.Next()) { + LOG4CXX_ERROR(logger_, + "Incorrect statement for vehicle data schema version"); + return false; + } + *vehicle_data->schema_version = query.GetString(0); + + vehicle_data->mark_initialized(); + return GatherVehicleDataItems(&*vehicle_data->schema_items); +} + +bool SQLPTRepresentation::GatherVehicleDataItems( + policy_table::VehicleDataItems* vehicle_data_items) const { + LOG4CXX_AUTO_TRACE(logger_); + auto parameterized_vdi = SelectCompositeVehicleDataItems(); + if (!parameterized_vdi.is_initialized()) { + return false; + } + + auto non_parameterized_vdi = SelectPrimitiveVehicleDataItems(); + if (!non_parameterized_vdi.is_initialized()) { + return false; + } + + vehicle_data_items->insert(vehicle_data_items->end(), + parameterized_vdi.begin(), + parameterized_vdi.end()); + vehicle_data_items->insert(vehicle_data_items->end(), + non_parameterized_vdi.begin(), + non_parameterized_vdi.end()); + + return true; +} + bool SQLPTRepresentation::Save(const policy_table::Table& table) { LOG4CXX_AUTO_TRACE(logger_); db_->BeginTransaction(); @@ -812,6 +890,10 @@ bool SQLPTRepresentation::Save(const policy_table::Table& table) { db_->RollbackTransaction(); return false; } + if (!SaveVehicleData(*table.policy_table.vehicle_data)) { + db_->RollbackTransaction(); + return false; + } db_->CommitTransaction(); return true; } @@ -851,7 +933,9 @@ bool SQLPTRepresentation::SaveFunctionalGroupings( it->second.user_consent_prompt.is_initialized() ? query.Bind(2, *(it->second.user_consent_prompt)) : query.Bind(2); - + it->second.encryption_required.is_initialized() + ? query.Bind(3, *(it->second.encryption_required)) + : query.Bind(3); if (!query.Exec() || !query.Reset()) { LOG4CXX_WARN(logger_, "Incorrect insert into functional groups"); return false; @@ -888,8 +972,7 @@ bool SQLPTRepresentation::SaveRpcs(int64_t group_id, query_parameter.Bind(0, it->first); query_parameter.Bind( 1, std::string(policy_table::EnumToJsonString(*hmi_it))); - query_parameter.Bind( - 2, std::string(policy_table::EnumToJsonString(*ps_it))); + query_parameter.Bind(2, std::string(*ps_it)); query_parameter.Bind(3, group_id); if (!query_parameter.Exec() || !query_parameter.Reset()) { LOG4CXX_WARN(logger_, "Incorrect insert into rpc with parameter"); @@ -1040,6 +1123,10 @@ bool SQLPTRepresentation::SaveSpecificAppPolicy( ? app_query.Bind(12, *app.second.allow_unknown_rpc_passthrough) : app_query.Bind(12); + app.second.encryption_required.is_initialized() + ? app_query.Bind(13, *app.second.encryption_required) + : app_query.Bind(13); + if (!app_query.Exec() || !app_query.Reset()) { LOG4CXX_WARN(logger_, "Incorrect insert into application."); return false; @@ -1101,7 +1188,6 @@ bool policy::SQLPTRepresentation::SaveDevicePolicy( app_query.Bind(3, 0); app_query.Bind(4, 0); app_query.Bind(5); - if (!app_query.Exec() || !app_query.Reset()) { LOG4CXX_WARN(logger_, "Incorrect insert into application."); return false; @@ -1125,9 +1211,9 @@ bool SQLPTRepresentation::SaveAppGroup( query.Bind(0, app_id); query.Bind(1, *it); if (!query.Exec() || !query.Reset()) { - LOG4CXX_WARN(logger_, - "Incorrect insert into app group." - << query.LastError().text()); + LOG4CXX_WARN( + logger_, + "Incorrect insert into app group." << query.LastError().text()); return false; } } @@ -1233,7 +1319,9 @@ bool SQLPTRepresentation::SaveRequestSubType( } else if (request_subtypes.is_initialized()) { LOG4CXX_WARN(logger_, "Request subtypes empty."); query.Bind(0, app_id); - query.Bind(1, std::string("EMPTY")); + query.Bind(1, + std::string(policy_table::EnumToJsonString( + policy_table::RequestType::RT_EMPTY))); if (!query.Exec() || !query.Reset()) { LOG4CXX_WARN(logger_, "Incorrect insert into request subtypes."); return false; @@ -1365,6 +1453,9 @@ bool SQLPTRepresentation::SaveModuleConfig( : query.Bind(7); config.vehicle_year.is_initialized() ? query.Bind(8, *(config.vehicle_year)) : query.Bind(8); + config.lock_screen_dismissal_enabled.is_initialized() + ? query.Bind(9, *(config.lock_screen_dismissal_enabled)) + : query.Bind(9); if (!query.Exec()) { LOG4CXX_WARN(logger_, "Incorrect update module config"); return false; @@ -1383,6 +1474,10 @@ bool SQLPTRepresentation::SaveModuleConfig( return false; } + if (!SaveServiceEndpointProperties(*config.endpoint_properties)) { + return false; + } + return true; } @@ -1421,6 +1516,31 @@ bool SQLPTRepresentation::SaveServiceEndpoints( return true; } +bool SQLPTRepresentation::SaveServiceEndpointProperties( + const policy_table::ServiceEndpointProperties& endpoint_properties) { + utils::dbms::SQLQuery query(db()); + if (!query.Prepare(sql_pt::kInsertEndpointVersion)) { + LOG4CXX_WARN( + logger_, + "Incorrect insert of endpoint property to endpoint_properties."); + return false; + } + + for (auto& endpoint_property : endpoint_properties) { + query.Bind(0, endpoint_property.first); + query.Bind(1, endpoint_property.second.version); + + if (!query.Exec() || !query.Reset()) { + LOG4CXX_WARN( + logger_, + "Failed to insert endpoint property into endpoint_properties."); + return false; + } + } + + return true; +} + bool SQLPTRepresentation::SaveConsumerFriendlyMessages( const policy_table::ConsumerFriendlyMessages& messages) { LOG4CXX_AUTO_TRACE(logger_); @@ -1519,6 +1639,25 @@ bool SQLPTRepresentation::SaveMessageString( query.Bind(0, lang); query.Bind(1, type); + if (strings.tts.is_valid() && strings.tts.is_initialized()) { + query.Bind(2, (*strings.tts)); + } + + if (strings.label.is_valid() && strings.label.is_initialized()) { + query.Bind(3, (*strings.label)); + } + + if (strings.line1.is_valid() && strings.line1.is_initialized()) { + query.Bind(4, *(strings.line1)); + } + + if (strings.line2.is_valid() && strings.line2.is_initialized()) { + query.Bind(5, (*strings.line2)); + } + + if (strings.textBody.is_valid() && strings.textBody.is_initialized()) { + query.Bind(6, (*strings.textBody)); + } if (!query.Exec() || !query.Reset()) { LOG4CXX_WARN(logger_, "Incorrect insert into message."); @@ -1621,6 +1760,44 @@ bool SQLPTRepresentation::SaveUsageAndErrorCounts( return true; } +bool SQLPTRepresentation::SaveVehicleData( + const policy_table::VehicleData& vehicle_data) { + LOG4CXX_AUTO_TRACE(logger_); + if (vehicle_data.is_initialized() && + vehicle_data.schema_version.is_initialized()) { + utils::dbms::SQLQuery query(db()); + if (!query.Prepare(sql_pt::kInsertVehicleDataSchemaVersion)) { + LOG4CXX_WARN(logger_, + "Incorrect insert of schema_version to vehicle_data."); + return false; + } + query.Bind(0, (*vehicle_data.schema_version)); + if (!query.Exec() || !query.Reset()) { + LOG4CXX_WARN(logger_, "Failed to insert schema_version to vehicle_data."); + return false; + } + } + + auto vehicle_data_items = vehicle_data.is_initialized() && + vehicle_data.schema_items.is_initialized() + ? *(vehicle_data.schema_items) + : policy_table::VehicleDataItems(); + + return SaveVehicleDataItems(vehicle_data_items); +} + +bool SQLPTRepresentation::SaveVehicleDataItems( + const policy_table::VehicleDataItems& vehicle_data_items) { + LOG4CXX_AUTO_TRACE(logger_); + DeleteVehicleDataItems(); + for (const auto& item : vehicle_data_items) { + if (!InsertVehicleDataItem(item)) { + return false; + } + } + return true; +} + void SQLPTRepresentation::IncrementIgnitionCycles() { utils::dbms::SQLQuery query(db()); if (!query.Exec(sql_pt::kIncrementIgnitionCycles)) { @@ -1750,7 +1927,8 @@ bool SQLPTRepresentation::GatherRequestSubType( query.Bind(0, app_id); while (query.Next()) { const std::string request_subtype = query.GetString(0); - if ("EMPTY" == request_subtype) { + if (policy_table::EnumToJsonString(policy_table::RT_EMPTY) == + request_subtype) { request_subtypes->mark_initialized(); continue; } @@ -2302,6 +2480,8 @@ bool SQLPTRepresentation::CopyApplication(const std::string& source, : query.Bind(16, source_app.GetString(15)); source_app.IsNull(16) ? query.Bind(17) : query.Bind(17, source_app.GetBoolean(16)); + source_app.IsNull(17) ? query.Bind(18) + : query.Bind(18, source_app.GetBoolean(17)); if (!query.Exec()) { LOG4CXX_WARN(logger_, "Failed inserting into application."); @@ -2328,4 +2508,314 @@ bool SQLPTRepresentation::SetVINValue(const std::string& value) { return true; } +bool SQLPTRepresentation::VehicleDataItemExists( + const policy_table::VehicleDataItem& vehicle_data_item) const { + utils::dbms::SQLQuery query(db()); + if (!query.Prepare(sql_pt::kSelectVehicleDataItemWithVersion)) { + LOG4CXX_ERROR(logger_, + "Incorrent select statement for vehicle data item. " + << query.LastError().text()); + return false; + } + + query.Bind(0, vehicle_data_item.name); + query.Bind(1, vehicle_data_item.key); + vehicle_data_item.since.is_initialized() + ? query.Bind(2, std::string(*vehicle_data_item.since)) + : query.Bind(2); + vehicle_data_item.until.is_initialized() + ? query.Bind(3, std::string(*vehicle_data_item.until)) + : query.Bind(3); + + if (!query.Exec()) { + LOG4CXX_ERROR(logger_, + "Failed to retrieve vehicle data item: " + << std::string(vehicle_data_item.key) + << ". Error: " << query.LastError().text()); + return false; + } + return !query.IsNull(0); +} + +policy_table::VehicleDataItems SQLPTRepresentation::GetVehicleDataItem( + const std::string& name, const std::string& key) const { + policy_table::VehicleDataItems result; + utils::dbms::SQLQuery query(db()); + + if (!query.Prepare(sql_pt::kSelectVehicleDataItem)) { + LOG4CXX_ERROR(logger_, + "Incorrent select statement of vehicle data item. " + << query.LastError().text()); + return result; + } + + query.Bind(0, name); + query.Bind(1, key); + + while (query.Next()) { + auto vdi = PopulateVDIFromQuery(query); + if (!vdi.is_initialized()) { + return policy_table::VehicleDataItems(); + } + + utils::dbms::SQLQuery param_query(db()); + if (policy_table::VehicleDataItem::kStruct == + static_cast(vdi.type)) { + if (!param_query.Prepare(sql_pt::kSelectVehicleDataItemParams)) { + LOG4CXX_ERROR(logger_, + "Incorrent select statement of vehicle data item. " + << param_query.LastError().text()); + return policy_table::VehicleDataItems(); + } + + param_query.Bind(0, name); + param_query.Bind(1, key); + + while (param_query.Next()) { + const auto param_with_diff_versions = GetVehicleDataItem( + param_query.GetString(2), param_query.GetString(3)); + if (!param_with_diff_versions.is_initialized()) { + return policy_table::VehicleDataItems(); + } + for (const auto& param : param_with_diff_versions) { + vdi.params->push_back(param); + } + } + } + + result.push_back(vdi); + } + if (!result.empty()) { + result.mark_initialized(); + } + + return result; +} + +policy_table::VehicleDataItem SQLPTRepresentation::PopulateVDIFromQuery( + const utils::dbms::SQLQuery& query) const { + policy_table::VehicleDataItem result; + + result.name = query.GetString(0); + result.type = query.GetString(1); + result.key = query.GetString(2); + result.mandatory = query.GetBoolean(3); + + if (!query.IsNull(4)) { + *result.array = query.GetBoolean(4); + } + if (!query.IsNull(5)) { + *result.since = query.GetString(5); + } + if (!query.IsNull(6)) { + *result.until = query.GetString(6); + } + if (!query.IsNull(7)) { + *result.removed = query.GetBoolean(7); + } + if (!query.IsNull(8)) { + *result.deprecated = query.GetBoolean(8); + } + if (!query.IsNull(9)) { + *result.minvalue = query.GetInteger(9); + } + if (!query.IsNull(10)) { + *result.maxvalue = query.GetInteger(10); + } + if (!query.IsNull(11)) { + *result.minsize = query.GetUInteger(11); + } + if (!query.IsNull(12)) { + *result.maxsize = query.GetUInteger(12); + } + if (!query.IsNull(13)) { + *result.minlength = query.GetUInteger(13); + } + if (!query.IsNull(14)) { + *result.maxlength = query.GetUInteger(14); + } + result.params->mark_initialized(); + + result.mark_initialized(); + return result; +} + +bool SQLPTRepresentation::InsertVehicleDataItem( + const policy_table::VehicleDataItem& vehicle_data_item) { + utils::dbms::SQLQuery query(db()); + + if (!vehicle_data_item.is_initialized() || !vehicle_data_item.is_valid()) { + LOG4CXX_ERROR(logger_, "Vehicle data item is not initialized."); + return false; + } + + if (VehicleDataItemExists(vehicle_data_item)) { + LOG4CXX_INFO(logger_, + static_cast(vehicle_data_item.key) + << " is already stored."); + return true; + } + + if (!query.Prepare(sql_pt::kInsertVehicleDataItem)) { + LOG4CXX_ERROR(logger_, + "Incorrent select statement of vehicle data item. " + << query.LastError().text()); + return false; + } + + query.Bind(0, vehicle_data_item.name); + query.Bind(1, vehicle_data_item.type); + query.Bind(2, vehicle_data_item.key); + query.Bind(3, vehicle_data_item.mandatory); + vehicle_data_item.array.is_initialized() + ? query.Bind(4, *vehicle_data_item.array) + : query.Bind(4); + vehicle_data_item.since.is_initialized() + ? query.Bind(5, *vehicle_data_item.since) + : query.Bind(5); + vehicle_data_item.until.is_initialized() + ? query.Bind(6, *vehicle_data_item.until) + : query.Bind(6); + vehicle_data_item.removed.is_initialized() + ? query.Bind(7, *vehicle_data_item.removed) + : query.Bind(7); + vehicle_data_item.deprecated.is_initialized() + ? query.Bind(8, *vehicle_data_item.deprecated) + : query.Bind(8); + vehicle_data_item.minvalue.is_initialized() + ? query.Bind(9, *vehicle_data_item.minvalue) + : query.Bind(9); + vehicle_data_item.maxvalue.is_initialized() + ? query.Bind(10, *vehicle_data_item.maxvalue) + : query.Bind(10); + vehicle_data_item.minsize.is_initialized() + ? query.Bind(11, static_cast(*vehicle_data_item.minsize)) + : query.Bind(11); + vehicle_data_item.maxsize.is_initialized() + ? query.Bind(12, static_cast(*vehicle_data_item.maxsize)) + : query.Bind(12); + vehicle_data_item.minlength.is_initialized() + ? query.Bind(13, static_cast(*vehicle_data_item.minlength)) + : query.Bind(13); + vehicle_data_item.maxlength.is_initialized() + ? query.Bind(14, static_cast(*vehicle_data_item.maxlength)) + : query.Bind(14); + + if (!query.Exec() || !query.Reset()) { + LOG4CXX_ERROR(logger_, + "Failed to insert vehicle data item: " + << static_cast(vehicle_data_item.key) + << ". Error: " << query.LastError().text()); + return false; + } + + if (vehicle_data_item.params->is_initialized()) { + std::map stored_vehicle_data_item_params; + for (const auto& param : *(vehicle_data_item.params)) { + if (!InsertVehicleDataItem(param)) { + return false; + } + + if (stored_vehicle_data_item_params.end() != + stored_vehicle_data_item_params.find(param.name)) { + LOG4CXX_DEBUG(logger_, "Parameter already stored."); + continue; + }; + + if (!query.Prepare(sql_pt::kInsertVehicleDataItemParams)) { + LOG4CXX_ERROR(logger_, + "Incorrent select statement of vehicle data item. " + << query.LastError().text()); + return false; + } + + query.Bind(0, vehicle_data_item.name); + query.Bind(1, vehicle_data_item.key); + query.Bind(2, param.name); + query.Bind(3, param.key); + + if (!query.Exec() || !query.Reset()) { + LOG4CXX_ERROR( + logger_, + "Failed to insert to vehicle data item relations helper table: " + << static_cast(param.key) + << ". Error: " << query.LastError().text()); + return false; + } + stored_vehicle_data_item_params[param.name] = param.key; + } + } + + return true; +} + +policy_table::VehicleDataItems +SQLPTRepresentation::SelectCompositeVehicleDataItems() const { + utils::dbms::SQLQuery query(db()); + LOG4CXX_AUTO_TRACE(logger_); + if (!query.Prepare(sql_pt::kSelectCompositeVehicleDataItemsKey)) { + LOG4CXX_ERROR(logger_, + "Incorrect statement for parameterized vehicle data items"); + return policy_table::VehicleDataItems(); + } + + policy_table::VehicleDataItems result; + result.mark_initialized(); + + while (query.Next()) { + const auto vdi = GetVehicleDataItem(query.GetString(0), query.GetString(1)); + if (!vdi.is_initialized()) { + return policy_table::VehicleDataItems(); + } + for (const auto& item : vdi) { + result.push_back(item); + } + } + + return result; +} + +policy_table::VehicleDataItems +SQLPTRepresentation::SelectPrimitiveVehicleDataItems() const { + utils::dbms::SQLQuery query(db()); + LOG4CXX_AUTO_TRACE(logger_); + if (!query.Prepare(sql_pt::kSelectPrimitiveVehicleDataItems)) { + LOG4CXX_ERROR( + logger_, + "Incorrect statement for non parameterized vehicle data items"); + return policy_table::VehicleDataItems(); + } + + auto result = policy_table::VehicleDataItems(); + result.mark_initialized(); + + while (query.Next()) { + const auto vdi = PopulateVDIFromQuery(query); + if (!vdi.is_initialized()) { + return policy_table::VehicleDataItems(); + } + result.push_back(vdi); + } + return result; +} + +bool SQLPTRepresentation::DeleteVehicleDataItems() const { + utils::dbms::SQLQuery query(db()); + LOG4CXX_AUTO_TRACE(logger_); + + if (!query.Exec(sql_pt::kDeleteVehicleDataItems)) { + LOG4CXX_ERROR(logger_, + "Failed clearing database: " << query.LastError().text()); + return false; + } + + if (!query.Exec(sql_pt::kDeleteVehicleDataItemParams)) { + LOG4CXX_ERROR(logger_, + "Failed clearing database: " << query.LastError().text()); + return false; + } + + return true; +} + } // namespace policy diff --git a/src/components/policy/policy_regular/src/status.cc b/src/components/policy/policy_regular/src/status.cc index 00a6a95af34..114ecb9f97b 100644 --- a/src/components/policy/policy_regular/src/status.cc +++ b/src/components/policy/policy_regular/src/status.cc @@ -101,9 +101,11 @@ void policy::UpdatingStatus::ProcessEvent( manager->SetPostponedStatus(std::make_shared()); break; case kScheduleUpdate: - case kOnResetRetrySequence: manager->SetPostponedStatus(std::make_shared()); break; + case kOnResetRetrySequence: + manager->SetNextStatus(std::make_shared()); + break; default: break; } 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 ed16fa3e8d3..340f900cac8 100644 --- a/src/components/policy/policy_regular/src/usage_statistics/counter.cc +++ b/src/components/policy/policy_regular/src/usage_statistics/counter.cc @@ -33,8 +33,8 @@ #ifndef SRC_COMPONENTS_POLICY_INCLUDE_POLICY_STATISTICS_MANAGER_H_ #define SRC_COMPONENTS_POLICY_INCLUDE_POLICY_STATISTICS_MANAGER_H_ -#include #include "policy/usage_statistics/counter.h" +#include #include "utils/date_time.h" #include "utils/timer_task_impl.h" diff --git a/src/components/policy/policy_regular/test/CMakeLists.txt b/src/components/policy/policy_regular/test/CMakeLists.txt index bd6af968677..428a0568821 100644 --- a/src/components/policy/policy_regular/test/CMakeLists.txt +++ b/src/components/policy/policy_regular/test/CMakeLists.txt @@ -49,7 +49,7 @@ collect_sources(SOURCES "${CMAKE_CURRENT_SOURCE_DIR}") set(LIBRARIES gmock Utils - Policy + PolicyStatic UsageStatistics ) diff --git a/src/components/policy/policy_regular/test/access_remote_impl_test.cc b/src/components/policy/policy_regular/test/access_remote_impl_test.cc index f79bb683f8a..d9dba45ef2a 100644 --- a/src/components/policy/policy_regular/test/access_remote_impl_test.cc +++ b/src/components/policy/policy_regular/test/access_remote_impl_test.cc @@ -30,8 +30,8 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include "gtest/gtest.h" #include "policy/access_remote_impl.h" +#include "gtest/gtest.h" namespace policy { diff --git a/src/components/policy/policy_regular/test/counter_test.cc b/src/components/policy/policy_regular/test/counter_test.cc index d11bcec2ac9..c09347fd9cd 100644 --- a/src/components/policy/policy_regular/test/counter_test.cc +++ b/src/components/policy/policy_regular/test/counter_test.cc @@ -31,11 +31,11 @@ #include "gmock/gmock.h" -#include "policy/usage_statistics/mock_statistics_manager.h" #include "policy/usage_statistics/counter.h" +#include "policy/usage_statistics/mock_statistics_manager.h" -using ::testing::StrictMock; using ::testing::InSequence; +using ::testing::StrictMock; namespace test { namespace components { diff --git a/src/components/policy/policy_regular/test/include/policy/driver_dbms.h b/src/components/policy/policy_regular/test/include/policy/driver_dbms.h index 78b7add6432..aa6fb0828b1 100644 --- a/src/components/policy/policy_regular/test/include/policy/driver_dbms.h +++ b/src/components/policy/policy_regular/test/include/policy/driver_dbms.h @@ -152,7 +152,7 @@ class DBMS { }; #endif // __QNX__ -} // namespace policy +} // namespace policy_test } // namespace components } // namespace test diff --git a/src/components/policy/policy_regular/test/include/policy/mock_pt_representation.h b/src/components/policy/policy_regular/test/include/policy/mock_pt_representation.h index 72f183175cd..8cf3884c11d 100644 --- a/src/components/policy/policy_regular/test/include/policy/mock_pt_representation.h +++ b/src/components/policy/policy_regular/test/include/policy/mock_pt_representation.h @@ -37,9 +37,9 @@ #include "gmock/gmock.h" +#include "policy/policy_table/types.h" #include "policy/pt_representation.h" #include "rpc_base/rpc_base.h" -#include "policy/policy_table/types.h" namespace policy_table = ::rpc::policy_table_interface_base; @@ -64,7 +64,6 @@ class MockPTRepresentation : virtual public PTRepresentation { MOCK_METHOD1(SecondsBetweenRetries, bool(std::vector* seconds)); MOCK_METHOD2(GetPriority, bool(const std::string& app_id, std::string* priority)); - MOCK_CONST_METHOD0(GetVehicleInfo, const VehicleInfo()); MOCK_METHOD1(SetVINValue, bool(const std::string& value)); MOCK_METHOD2( GetUserFriendlyMsg, 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 97b1768666d..e1f916e72fd 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 @@ -30,39 +30,39 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include +#include #include #include -#include +#include +#include "gtest/gtest.h" #include "json/reader.h" #include "json/writer.h" -#include "gtest/gtest.h" #include "config_profile/profile.h" +#include "connection_handler/connection_handler.h" +#include "policy/mock_cache_manager.h" +#include "policy/mock_policy_listener.h" +#include "policy/mock_policy_settings.h" +#include "policy/mock_update_status_manager.h" #include "policy/policy_manager_impl.h" #include "policy/policy_table/enums.h" #include "policy/policy_table/types.h" -#include "policy/mock_policy_settings.h" -#include "policy/mock_policy_listener.h" -#include "policy/mock_cache_manager.h" -#include "policy/mock_update_status_manager.h" -#include "utils/macro.h" -#include "utils/file_system.h" #include "utils/date_time.h" - +#include "utils/file_system.h" #include "utils/gen_hash.h" +#include "utils/macro.h" + #include "policy/mock_access_remote.h" -using ::testing::ReturnRef; -using ::testing::DoAll; -using ::testing::SetArgReferee; -using ::testing::NiceMock; using ::testing::_; -using ::testing::SetArgReferee; using ::testing::AtLeast; +using ::testing::DoAll; +using ::testing::NiceMock; using ::testing::Return; +using ::testing::ReturnRef; +using ::testing::SetArgReferee; using ::policy::PolicyManagerImpl; using ::policy::PolicyTable; @@ -77,6 +77,12 @@ namespace custom_str = utils::custom_string; typedef std::multimap UserConsentPromptToRpcsConnections; +namespace { +std::string kSpeed = "speed"; +std::string kRPM = "rpm"; +std::string kFuelLevel = "fuelLevel"; +} // namespace + template std::string NumberToString(T Number) { std::ostringstream ss; @@ -142,17 +148,18 @@ class PolicyManagerImplTest : public ::testing::Test { protected: PolicyManagerImpl* manager; - MockCacheManagerInterface* cache_manager; + NiceMock* cache_manager; NiceMock listener; + NiceMock update_status_manager; const std::string device_id; std::shared_ptr access_remote; void SetUp() OVERRIDE { manager = new PolicyManagerImpl(); manager->set_listener(&listener); - cache_manager = new MockCacheManagerInterface(); + cache_manager = new NiceMock(); manager->set_cache_manager(cache_manager); - access_remote = std::shared_ptr(); + access_remote = std::make_shared(); manager->set_access_remote(access_remote); } @@ -169,6 +176,78 @@ class PolicyManagerImplTest : public ::testing::Test { return ::testing::AssertionFailure() << ::rpc::PrettyFormat(report); } } + + void PrepareUpdateWithFunctionalGroupingContent(policy_table::Table& update) { + using namespace application_manager; + + update.SetPolicyTableType(rpc::policy_table_interface_base::PT_UPDATE); + + policy_table::Rpcs rpcs; + rpcs.mark_initialized(); + + policy_table::Rpc rpc; + rpc.mark_initialized(); + + policy_table::RpcParameters rpc_params; + rpc_params.mark_initialized(); + rpc_params.hmi_levels.push_back( + rpc::policy_table_interface_base::HmiLevel::HL_FULL); + rpc_params.hmi_levels.push_back( + rpc::policy_table_interface_base::HmiLevel::HL_BACKGROUND); + + (*rpc_params.parameters).push_back(kRPM); + (*rpc_params.parameters).push_back(kSpeed); + + rpc["GetVehicleData"] = rpc_params; + rpcs.rpcs = rpc; + + policy_table::FunctionalGroupings fg; + fg["TestGroup1"] = rpcs; + + update.policy_table.functional_groupings = fg; + + policy_table::ApplicationParams app_params; + app_params.mark_initialized(); + app_params.priority = + rpc::policy_table_interface_base::Priority::P_COMMUNICATION; + app_params.groups.push_back("TestGroup1"); + update.policy_table.app_policies_section.apps["1234"] = app_params; + } + + void ExpectOnPermissionsUpdated() { + std::string dev_id_1 = "dev_id_1"; + std::string app_id = "1234"; + + EXPECT_CALL(*cache_manager, IsDefaultPolicy(app_id)).WillOnce(Return(true)); + EXPECT_CALL(*access_remote, IsAppRemoteControl(_)).WillOnce(Return(true)); + + FunctionalGroupNames fg_names; + fg_names[0] = + std::make_pair("fg_name_1", "fg_name_2"); + EXPECT_CALL(*cache_manager, GetFunctionalGroupNames(_)) + .WillOnce(DoAll(SetArgReferee<0>(fg_names), Return(true))); + + std::vector device_ids; + device_ids.push_back(dev_id_1); + EXPECT_CALL(listener, GetDevicesIds(app_id)) + .WillRepeatedly(Return(device_ids)); + + int32_t group_id = 0; + FunctionalGroupIDs group_ids; + group_ids.push_back(group_id); + FunctionalIdType group_types; + group_types[GroupType::kTypeGeneral] = group_ids; + EXPECT_CALL(*access_remote, GetPermissionsForApp(dev_id_1, app_id, _)) + .WillRepeatedly(DoAll(SetArgReferee<2>(group_types), Return(true))); + + EXPECT_CALL(listener, OnPermissionsUpdated(dev_id_1, app_id, _, _)) + .Times(1); + + EXPECT_CALL(listener, GetAppName(_)) + .WillOnce(Return(custom_str::CustomString(""))); + + EXPECT_CALL(listener, OnUpdateStatusChanged(_)).Times(1); + } }; class PolicyManagerImplTest2 : public ::testing::Test { @@ -178,6 +257,8 @@ class PolicyManagerImplTest2 : public ::testing::Test { , app_id2("1010101010") , dev_id1("XXX123456789ZZZ") , dev_id2("08-00-27-CE-76-FE") + , dev_handle1(123456789) + , dev_handle2(1010101010) , PTU_request_types(Json::arrayValue) {} protected: @@ -191,6 +272,8 @@ class PolicyManagerImplTest2 : public ::testing::Test { const std::string app_id2; const std::string dev_id1; const std::string dev_id2; + const connection_handler::DeviceHandle dev_handle1; + const connection_handler::DeviceHandle dev_handle2; Json::Value PTU_request_types; NiceMock policy_settings_; const std::string kAppStorageFolder = "storage_PolicyManagerImplTest2"; @@ -204,7 +287,7 @@ class PolicyManagerImplTest2 : public ::testing::Test { .WillByDefault(ReturnRef(kAppStorageFolder)); ON_CALL(policy_settings_, use_full_app_id()).WillByDefault(Return(true)); manager->set_listener(&listener); - const char* levels[] = {"BACKGROUND", "FULL", "LIMITED", "NONE"}; + const char* levels[] = {"FULL", "LIMITED", "BACKGROUND", "NONE"}; hmi_level.assign(levels, levels + sizeof(levels) / sizeof(levels[0])); srand(time(NULL)); index = rand() % 3; @@ -231,7 +314,9 @@ class PolicyManagerImplTest2 : public ::testing::Test { ifile.close(); ::policy::BinaryMessage msg(json.begin(), json.end()); // Load Json to cache - EXPECT_TRUE(manager->LoadPT("file_pt_update.json", msg)); + EXPECT_EQ(PolicyManager::PtProcessingResult::kSuccess, + manager->LoadPT("file_pt_update.json", msg)); + manager->OnPTUFinished(PolicyManager::PtProcessingResult::kSuccess); return root; } @@ -243,6 +328,53 @@ class PolicyManagerImplTest2 : public ::testing::Test { ASSERT_TRUE(manager->InitPT(file_name, &policy_settings_)); } + Json::Value AddWidgetSupportToPt(const std::string& section_name, + const uint32_t group_number) { + std::ifstream ifile("sdl_preloaded_pt.json"); + Json::Reader reader; + Json::Value root(Json::objectValue); + if (ifile.is_open() && reader.parse(ifile, root, true)) { + auto& groups = + root["policy_table"]["app_policies"][section_name]["groups"]; + if (groups.empty()) { + groups = Json::Value(Json::arrayValue); + } + groups[group_number] = Json::Value("WidgetSupport"); + } + ifile.close(); + return root; + } + + std::string AddWidgetSupportToPt(Json::Value* root, + const std::string& section_name, + const uint32_t group_number) { + if (root) { + auto& groups = + (*root)["policy_table"]["app_policies"][section_name]["groups"]; + if (groups.empty()) { + groups = Json::Value(Json::arrayValue); + } + groups[group_number] = Json::Value("WidgetSupport"); + return root->toStyledString(); + } + return std::string(); + } + + std::string AddWidgetSupportToFunctionalGroups(Json::Value* root, + const std::string& rpc_name, + const std::string& hmi_level) { + if (root) { + Json::Value val(Json::objectValue); + Json::Value val2(Json::arrayValue); + val2[0] = hmi_level; + val[rpc_name]["hmi_levels"] = val2; + (*root)["policy_table"]["functional_groupings"]["WidgetSupport"]["rpcs"] = + val; + return root->toStyledString(); + } + return std::string(); + } + void AddRTtoPT(const std::string& update_file_name, const std::string& section_name, const uint32_t rt_number, @@ -272,12 +404,13 @@ class PolicyManagerImplTest2 : public ::testing::Test { // Arrange CreateLocalPT("sdl_preloaded_pt.json"); // Add app - manager->AddApplication(section_name, HmiTypes(policy_table::AHT_DEFAULT)); + manager->AddApplication( + dev_id1, section_name, HmiTypes(policy_table::AHT_DEFAULT)); // Check app gets RequestTypes from pre_DataConsent of app_policies // section PT_request_types = manager->GetAppRequestTypes(section_name); EXPECT_EQ(rt_number, PT_request_types.size()); - EXPECT_CALL(listener, OnPendingPermissionChange(section_name)).Times(1); + EXPECT_CALL(listener, OnPendingPermissionChange(_, section_name)).Times(1); Json::Value root = GetPTU(update_file_name); // Get App Request Types from PTU @@ -293,7 +426,7 @@ class PolicyManagerImplTest2 : public ::testing::Test { PT_request_types.size()); ::policy::AppPermissions permissions = - manager->GetAppPermissionsChanges(section_name); + manager->GetAppPermissionsChanges(dev_id1, section_name); EXPECT_TRUE(permissions.requestTypeChanged); } @@ -478,8 +611,11 @@ TEST_F(PolicyManagerImplTest2, GetNotificationsNumberAfterPTUpdate) { // Act const std::string json = table.toStyledString(); ::policy::BinaryMessage msg(json.begin(), json.end()); + ASSERT_EQ(PolicyManager::PtProcessingResult::kSuccess, + manager->LoadPT("file_pt_update.json", msg)); + EXPECT_CALL(listener, OnUpdateStatusChanged(_)); - EXPECT_TRUE(manager->LoadPT("file_pt_update.json", msg)); + manager->OnPTUFinished(PolicyManager::PtProcessingResult::kSuccess); std::string priority = "EMERGENCY"; uint32_t notif_number = manager->GetNotificationsNumber(priority); @@ -520,7 +656,10 @@ TEST_F(PolicyManagerImplTest2, IsAppRevoked_SetRevokedAppID_ExpectAppRevoked) { ifile.close(); ::policy::BinaryMessage msg(json.begin(), json.end()); - ASSERT_TRUE(manager->LoadPT("file_pt_update.json", msg)); + ASSERT_EQ(PolicyManager::PtProcessingResult::kSuccess, + manager->LoadPT("file_pt_update.json", msg)); + manager->OnPTUFinished(PolicyManager::PtProcessingResult::kSuccess); + EXPECT_TRUE(manager->IsApplicationRevoked(app_id1)); } @@ -538,11 +677,14 @@ TEST_F(PolicyManagerImplTest2, "Life", 2, "Bluetooth"); - EXPECT_CALL(listener, OnCurrentDeviceIdUpdateRequired(app_id1)) + EXPECT_CALL(listener, OnCurrentDeviceIdUpdateRequired(_, app_id1)) .WillRepeatedly(Return(dev_id1)); manager->SetUserConsentForDevice(dev_id1, true); // Add app from consented device. App will be assigned with default policies - manager->AddApplication(app_id1, HmiTypes(policy_table::AHT_DEFAULT)); + manager->AddApplication( + dev_id1, app_id1, HmiTypes(policy_table::AHT_DEFAULT)); + EXPECT_CALL(listener, GetDevicesIds(app_id1)) + .WillRepeatedly(Return(transport_manager::DeviceList())); // Check before action policy_table::RpcParameters rpc_parameters; rpc_parameters.hmi_levels.push_back(policy_table::HL_FULL); @@ -571,7 +713,9 @@ TEST_F(PolicyManagerImplTest2, ifile.close(); ::policy::BinaryMessage msg(json.begin(), json.end()); - ASSERT_TRUE(manager->LoadPT("file_pt_update.json", msg)); + ASSERT_EQ(PolicyManager::PtProcessingResult::kSuccess, + manager->LoadPT("file_pt_update.json", msg)); + manager->OnPTUFinished(PolicyManager::PtProcessingResult::kSuccess); manager->CheckPermissions( dev_id1, app_id1, std::string("FULL"), "Alert", input_params, output); @@ -580,6 +724,130 @@ TEST_F(PolicyManagerImplTest2, ASSERT_TRUE(output.list_of_allowed_params.empty()); } +TEST_F( + PolicyManagerImplTest2, + CheckPermissions_PersistsWidgetAppPermissionsAfter_PTU_ExpectRPCAllowed) { + // Arrange + CreateLocalPT("sdl_preloaded_pt.json"); + (manager->GetCache())->AddDevice(dev_id1, "Bluetooth"); + (manager->GetCache()) + ->SetDeviceData(dev_id1, + "hardware IPX", + "v.8.0.1", + "Android", + "4.4.2", + "Life", + 2, + "Bluetooth"); + EXPECT_CALL(listener, OnCurrentDeviceIdUpdateRequired(_, app_id1)) + .WillRepeatedly(Return(dev_id1)); + manager->SetUserConsentForDevice(dev_id1, true); + // Add app from consented device. App will be assigned with default policies + manager->AddApplication( + app_id1, app_id1, HmiTypes(policy_table::AHT_DEFAULT)); + EXPECT_CALL(listener, GetDevicesIds(app_id1)) + .WillRepeatedly(Return(transport_manager::DeviceList())); + // Act + const char* const rpc_name = "CreateWindow"; + const char* const hmi_level = "NONE"; + const uint32_t group_number = 0; + Json::Value root = AddWidgetSupportToPt("default", group_number); + std::string json = + AddWidgetSupportToFunctionalGroups(&root, rpc_name, hmi_level); + + ::policy::BinaryMessage msg(json.begin(), json.end()); + ASSERT_EQ(PolicyManager::PtProcessingResult::kSuccess, + manager->LoadPT("file_pt_update.json", msg)); + manager->OnPTUFinished(PolicyManager::PtProcessingResult::kSuccess); + + ::policy::RPCParams input_params; + ::policy::CheckPermissionResult output; + + manager->CheckPermissions( + dev_id1, app_id1, hmi_level, rpc_name, input_params, output); + + // Check RPC is allowed + EXPECT_EQ(::policy::kRpcAllowed, output.hmi_level_permitted); + ASSERT_TRUE(output.list_of_allowed_params.empty()); + // Act + json = AddWidgetSupportToPt(&root, app_id1, group_number); + msg = BinaryMessage(json.begin(), json.end()); + ASSERT_EQ(PolicyManager::PtProcessingResult::kSuccess, + manager->LoadPT("file_pt_update.json", msg)); + manager->OnPTUFinished(PolicyManager::PtProcessingResult::kSuccess); + + output.hmi_level_permitted = ::policy::kRpcDisallowed; + manager->CheckPermissions( + dev_id1, app_id1, hmi_level, rpc_name, input_params, output); + // Check RPC is allowed + EXPECT_EQ(::policy::kRpcAllowed, output.hmi_level_permitted); + ASSERT_TRUE(output.list_of_allowed_params.empty()); +} + +TEST_F( + PolicyManagerImplTest2, + CheckPermissions_AbsenceOfWidgetPermissionsAfter_PTU_ExpectRPCDisallowed) { + // Arrange + CreateLocalPT("sdl_preloaded_pt.json"); + (manager->GetCache())->AddDevice(dev_id1, "Bluetooth"); + (manager->GetCache()) + ->SetDeviceData(dev_id1, + "hardware IPX", + "v.8.0.1", + "Android", + "4.4.2", + "Life", + 2, + "Bluetooth"); + EXPECT_CALL(listener, OnCurrentDeviceIdUpdateRequired(_, app_id1)) + .WillRepeatedly(Return(dev_id1)); + manager->SetUserConsentForDevice(dev_id1, true); + // Add app from consented device. App will be assigned with default policies + manager->AddApplication( + dev_id1, app_id1, HmiTypes(policy_table::AHT_DEFAULT)); + EXPECT_CALL(listener, GetDevicesIds(app_id1)) + .WillRepeatedly(Return(transport_manager::DeviceList())); + // Act + const char* const rpc_name = "DeleteWindow"; + const char* const hmi_level = "NONE"; + const uint32_t group_number = 0; + Json::Value root = AddWidgetSupportToPt("default", group_number); + std::string json = + AddWidgetSupportToFunctionalGroups(&root, rpc_name, hmi_level); + + ::policy::BinaryMessage msg(json.begin(), json.end()); + ASSERT_EQ(PolicyManager::PtProcessingResult::kSuccess, + manager->LoadPT("file_pt_update.json", msg)); + manager->OnPTUFinished(PolicyManager::PtProcessingResult::kSuccess); + + ::policy::RPCParams input_params; + ::policy::CheckPermissionResult output; + + manager->CheckPermissions( + dev_id1, app_id1, hmi_level, rpc_name, input_params, output); + + // Check RPC is allowed + EXPECT_EQ(::policy::kRpcAllowed, output.hmi_level_permitted); + ASSERT_TRUE(output.list_of_allowed_params.empty()); + output.hmi_level_permitted = ::policy::kRpcDisallowed; + // Act + root["policy_table"]["app_policies"][app_id1]["groups"] = + Json::Value(Json::arrayValue); + root["policy_table"]["app_policies"][app_id1]["groups"][group_number] = + Json::Value("Base-4"); + json = root.toStyledString(); + msg = BinaryMessage(json.begin(), json.end()); + ASSERT_EQ(PolicyManager::PtProcessingResult::kSuccess, + manager->LoadPT("file_pt_update.json", msg)); + manager->OnPTUFinished(PolicyManager::PtProcessingResult::kSuccess); + + manager->CheckPermissions( + dev_id1, app_id1, hmi_level, rpc_name, input_params, output); + // Check RPC is disallowed + EXPECT_EQ(::policy::kRpcDisallowed, output.hmi_level_permitted); + ASSERT_TRUE(output.list_of_allowed_params.empty()); +} + TEST_F(PolicyManagerImplTest2, CheckPermissions_SetAppIDwithPolicies_ExpectRPCAllowed) { // Arrange @@ -595,11 +863,11 @@ TEST_F(PolicyManagerImplTest2, "Life", 2, "Bluetooth")); - EXPECT_CALL(listener, OnCurrentDeviceIdUpdateRequired("1234")) + EXPECT_CALL(listener, OnCurrentDeviceIdUpdateRequired(_, "1234")) .WillRepeatedly(Return(dev_id1)); manager->SetUserConsentForDevice(dev_id1, true); // Add app from consented device. App will be assigned with default policies - manager->AddApplication("1234", HmiTypes(policy_table::AHT_MEDIA)); + manager->AddApplication(dev_id1, "1234", HmiTypes(policy_table::AHT_MEDIA)); // Emulate PTU with new policies for app added above std::ifstream ifile("sdl_preloaded_pt.json"); Json::Reader reader; @@ -636,7 +904,9 @@ TEST_F(PolicyManagerImplTest2, ::policy::BinaryMessage msg(json.begin(), json.end()); // Load Json to cache - EXPECT_TRUE(manager->LoadPT("file_pt_update.json", msg)); + ASSERT_EQ(PolicyManager::PtProcessingResult::kSuccess, + manager->LoadPT("file_pt_update.json", msg)); + manager->OnPTUFinished(PolicyManager::PtProcessingResult::kSuccess); policy_table::RpcParameters rpc_parameters; rpc_parameters.hmi_levels.push_back(policy_table::HL_FULL); @@ -728,15 +998,231 @@ TEST_F(PolicyManagerImplTest, LoadPT_SetPT_PTIsLoaded) { std::make_shared(update.policy_table); // Assert EXPECT_CALL(*cache_manager, GenerateSnapshot()).WillOnce(Return(snapshot)); + EXPECT_CALL(*cache_manager, GetVehicleDataItems()) + .WillOnce(Return(std::vector())); EXPECT_CALL(*cache_manager, ApplyUpdate(_)).WillOnce(Return(true)); - EXPECT_CALL(listener, GetAppName("1234")) - .WillOnce(Return(custom_str::CustomString(""))); - EXPECT_CALL(listener, OnUpdateStatusChanged(_)); + EXPECT_CALL(listener, GetDevicesIds("1234")) + .WillRepeatedly(Return(transport_manager::DeviceList())); EXPECT_CALL(*cache_manager, SaveUpdateRequired(false)); + ASSERT_EQ(PolicyManager::PtProcessingResult::kSuccess, + manager->LoadPT("file_pt_update.json", msg)); + EXPECT_CALL(*cache_manager, TimeoutResponse()); EXPECT_CALL(*cache_manager, SecondsBetweenRetries(_)); + EXPECT_CALL(listener, OnUpdateStatusChanged(_)); + manager->OnPTUFinished(PolicyManager::PtProcessingResult::kSuccess); +} + +TEST_F(PolicyManagerImplTest, LoadPT_FunctionalGroup_removeRPC_SendUpdate) { + // Arrange + manager->ForcePTExchange(); + manager->OnUpdateStarted(); + Json::Value table = CreatePTforLoad(); + policy_table::Table update(&table); - EXPECT_TRUE(manager->LoadPT("file_pt_update.json", msg)); + PrepareUpdateWithFunctionalGroupingContent(update); + + std::shared_ptr snapshot = + std::make_shared(update.policy_table); + + const auto& fg_found = + update.policy_table.functional_groupings.find("TestGroup1"); + fg_found->second.rpcs.erase("GetVehicleData"); + + ASSERT_TRUE(IsValid(update)); + + const std::string json = update.ToJsonValue().toStyledString(); + ::policy::BinaryMessage msg(json.begin(), json.end()); + + // Assert + EXPECT_CALL(*cache_manager, GetVehicleDataItems()) + .WillOnce(Return(std::vector())); + EXPECT_CALL(*cache_manager, GenerateSnapshot()) + .WillRepeatedly(Return(snapshot)); + EXPECT_CALL(*cache_manager, ApplyUpdate(_)).WillOnce(Return(true)); + ExpectOnPermissionsUpdated(); + + ASSERT_EQ(PolicyManager::PtProcessingResult::kSuccess, + manager->LoadPT("file_pt_update.json", msg)); + manager->OnPTUFinished(PolicyManager::PtProcessingResult::kSuccess); +} + +TEST_F(PolicyManagerImplTest, + LoadPT_FunctionalGroup_removeRPCParams_SendUpdate) { + // Arrange + manager->ForcePTExchange(); + manager->OnUpdateStarted(); + Json::Value table = CreatePTforLoad(); + policy_table::Table update(&table); + + PrepareUpdateWithFunctionalGroupingContent(update); + + std::shared_ptr snapshot = + std::make_shared(update.policy_table); + + const auto& fg_found = + update.policy_table.functional_groupings.find("TestGroup1"); + policy_table::RpcParameters& new_rpc_params = + fg_found->second.rpcs["GetVehicleData"]; + new_rpc_params.parameters->erase(new_rpc_params.parameters->begin()); + + ASSERT_TRUE(IsValid(update)); + + const std::string json = update.ToJsonValue().toStyledString(); + ::policy::BinaryMessage msg(json.begin(), json.end()); + + // Assert + EXPECT_CALL(*cache_manager, GenerateSnapshot()) + .WillRepeatedly(Return(snapshot)); + EXPECT_CALL(*cache_manager, GetVehicleDataItems()) + .WillOnce(Return(std::vector())); + EXPECT_CALL(*cache_manager, ApplyUpdate(_)).WillOnce(Return(true)); + ExpectOnPermissionsUpdated(); + + ASSERT_EQ(PolicyManager::PtProcessingResult::kSuccess, + manager->LoadPT("file_pt_update.json", msg)); + manager->OnPTUFinished(PolicyManager::PtProcessingResult::kSuccess); +} + +TEST_F(PolicyManagerImplTest, + LoadPT_FunctionalGroup_removeRPC_HMILevels_SendUpdate) { + // Arrange + manager->ForcePTExchange(); + manager->OnUpdateStarted(); + Json::Value table = CreatePTforLoad(); + policy_table::Table update(&table); + + PrepareUpdateWithFunctionalGroupingContent(update); + + std::shared_ptr snapshot = + std::make_shared(update.policy_table); + + const auto& fg_found = + update.policy_table.functional_groupings.find("TestGroup1"); + policy_table::RpcParameters& new_rpc_params = + fg_found->second.rpcs["GetVehicleData"]; + new_rpc_params.hmi_levels.erase(new_rpc_params.hmi_levels.begin()); + + ASSERT_TRUE(IsValid(update)); + + const std::string json = update.ToJsonValue().toStyledString(); + ::policy::BinaryMessage msg(json.begin(), json.end()); + + // Assert + EXPECT_CALL(*cache_manager, GenerateSnapshot()) + .WillRepeatedly(Return(snapshot)); + EXPECT_CALL(*cache_manager, GetVehicleDataItems()) + .WillOnce(Return(std::vector())); + EXPECT_CALL(*cache_manager, ApplyUpdate(_)).WillOnce(Return(true)); + ExpectOnPermissionsUpdated(); + + ASSERT_EQ(PolicyManager::PtProcessingResult::kSuccess, + manager->LoadPT("file_pt_update.json", msg)); + manager->OnPTUFinished(PolicyManager::PtProcessingResult::kSuccess); +} + +TEST_F(PolicyManagerImplTest, + LoadPT_FunctionalGroup_addRPC_HMILevels_SendUpdate) { + // Arrange + manager->ForcePTExchange(); + manager->OnUpdateStarted(); + Json::Value table = CreatePTforLoad(); + policy_table::Table update(&table); + + PrepareUpdateWithFunctionalGroupingContent(update); + + std::shared_ptr snapshot = + std::make_shared(update.policy_table); + + const auto& fg_found = + update.policy_table.functional_groupings.find("TestGroup1"); + policy_table::RpcParameters& new_rpc_params = + fg_found->second.rpcs["GetVehicleData"]; + new_rpc_params.hmi_levels.push_back( + rpc::policy_table_interface_base::HmiLevel::HL_LIMITED); + + ASSERT_TRUE(IsValid(update)); + + const std::string json = update.ToJsonValue().toStyledString(); + ::policy::BinaryMessage msg(json.begin(), json.end()); + + // Assert + EXPECT_CALL(*cache_manager, GenerateSnapshot()) + .WillRepeatedly(Return(snapshot)); + EXPECT_CALL(*cache_manager, GetVehicleDataItems()) + .WillOnce(Return(std::vector())); + EXPECT_CALL(*cache_manager, ApplyUpdate(_)).WillOnce(Return(true)); + ExpectOnPermissionsUpdated(); + + ASSERT_EQ(PolicyManager::PtProcessingResult::kSuccess, + manager->LoadPT("file_pt_update.json", msg)); + manager->OnPTUFinished(PolicyManager::PtProcessingResult::kSuccess); +} + +TEST_F(PolicyManagerImplTest, LoadPT_FunctionalGroup_addRPCParams_SendUpdate) { + using namespace application_manager; + // Arrange + manager->ForcePTExchange(); + manager->OnUpdateStarted(); + Json::Value table = CreatePTforLoad(); + policy_table::Table update(&table); + + PrepareUpdateWithFunctionalGroupingContent(update); + + std::shared_ptr snapshot = + std::make_shared(update.policy_table); + + const auto& fg_found = + update.policy_table.functional_groupings.find("TestGroup1"); + policy_table::RpcParameters& new_rpc_params = + fg_found->second.rpcs["GetVehicleData"]; + (*new_rpc_params.parameters).push_back(kFuelLevel); + + ASSERT_TRUE(IsValid(update)); + + const std::string json = update.ToJsonValue().toStyledString(); + ::policy::BinaryMessage msg(json.begin(), json.end()); + + // Assert + EXPECT_CALL(*cache_manager, GenerateSnapshot()) + .WillRepeatedly(Return(snapshot)); + EXPECT_CALL(*cache_manager, GetVehicleDataItems()) + .WillOnce(Return(std::vector())); + EXPECT_CALL(*cache_manager, ApplyUpdate(_)).WillOnce(Return(true)); + ExpectOnPermissionsUpdated(); + + ASSERT_EQ(PolicyManager::PtProcessingResult::kSuccess, + manager->LoadPT("file_pt_update.json", msg)); + manager->OnPTUFinished(PolicyManager::PtProcessingResult::kSuccess); +} + +TEST_F(PolicyManagerImplTest, LoadPT_FunctionalGroup_NoUpdate_DONT_SendUpdate) { + // Arrange + manager->ForcePTExchange(); + manager->OnUpdateStarted(); + Json::Value table = CreatePTforLoad(); + policy_table::Table update(&table); + + PrepareUpdateWithFunctionalGroupingContent(update); + + std::shared_ptr snapshot = + std::make_shared(update.policy_table); + + ASSERT_TRUE(IsValid(update)); + + const std::string json = update.ToJsonValue().toStyledString(); + ::policy::BinaryMessage msg(json.begin(), json.end()); + + // Assert + EXPECT_CALL(*cache_manager, GenerateSnapshot()) + .WillRepeatedly(Return(snapshot)); + EXPECT_CALL(*cache_manager, GetVehicleDataItems()) + .WillOnce(Return(std::vector())); + EXPECT_CALL(*cache_manager, ApplyUpdate(_)).WillOnce(Return(true)); + + ASSERT_EQ(PolicyManager::PtProcessingResult::kSuccess, + manager->LoadPT("file_pt_update.json", msg)); + manager->OnPTUFinished(PolicyManager::PtProcessingResult::kSuccess); } TEST_F(PolicyManagerImplTest, LoadPT_SetInvalidUpdatePT_PTIsNotLoaded) { @@ -755,15 +1241,23 @@ TEST_F(PolicyManagerImplTest, LoadPT_SetInvalidUpdatePT_PTIsNotLoaded) { std::string json = table.toStyledString(); ::policy::BinaryMessage msg(json.begin(), json.end()); + std::shared_ptr snapshot = + std::make_shared(update.policy_table); + ON_CALL(*cache_manager, GenerateSnapshot()).WillByDefault(Return(snapshot)); + ON_CALL(*cache_manager, GetVehicleDataItems()) + .WillByDefault(Return(std::vector())); + // Assert - EXPECT_CALL(*cache_manager, GenerateSnapshot()).Times(0); EXPECT_CALL(*cache_manager, ApplyUpdate(_)).Times(0); EXPECT_CALL(listener, GetAppName(_)).Times(0); - EXPECT_CALL(listener, OnUpdateStatusChanged(_)).Times(1); EXPECT_CALL(*cache_manager, SaveUpdateRequired(false)).Times(0); EXPECT_CALL(*cache_manager, TimeoutResponse()).Times(0); EXPECT_CALL(*cache_manager, SecondsBetweenRetries(_)).Times(0); - EXPECT_FALSE(manager->LoadPT("file_pt_update.json", msg)); + ASSERT_EQ(PolicyManager::PtProcessingResult::kWrongPtReceived, + manager->LoadPT("file_pt_update.json", msg)); + + EXPECT_CALL(listener, OnUpdateStatusChanged(_)); + manager->OnPTUFinished(PolicyManager::PtProcessingResult::kWrongPtReceived); } TEST_F(PolicyManagerImplTest2, @@ -786,8 +1280,8 @@ TEST_F( AddApplication_AddNewApplicationFromDeviceWithoutConsent_ExpectUpdateRequired) { // Arrange CreateLocalPT("sdl_preloaded_pt.json"); - ::policy::StatusNotifier notifyer = - manager->AddApplication(app_id1, HmiTypes(policy_table::AHT_DEFAULT)); + ::policy::StatusNotifier notifyer = manager->AddApplication( + dev_id1, app_id1, HmiTypes(policy_table::AHT_DEFAULT)); DCHECK(notifyer); (*notifyer)(); EXPECT_EQ("UPDATE_NEEDED", manager->GetPolicyTableStatus()); @@ -799,9 +1293,10 @@ TEST_F( // Arrange // RequestTypes for default & preDataConsent are different CreateLocalPT("ptu_requestType.json"); - manager->AddApplication(app_id1, HmiTypes(policy_table::AHT_DEFAULT)); + manager->AddApplication( + dev_id1, app_id1, HmiTypes(policy_table::AHT_DEFAULT)); EXPECT_FALSE(manager->IsPredataPolicy(app_id1)); - manager->ReactOnUserDevConsentForApp(app_id1, true); + manager->ReactOnUserDevConsentForApp(dev_handle1, app_id1, true); EXPECT_FALSE(manager->IsPredataPolicy(app_id1)); EXPECT_TRUE((manager->GetCache())->IsDefaultPolicy(app_id1)); } @@ -812,10 +1307,11 @@ TEST_F( // Arrange // RequestTypes for default & preDataConsent are the same CreateLocalPT("ptu2_requestType.json"); - manager->AddApplication(app_id1, HmiTypes(policy_table::AHT_DEFAULT)); + manager->AddApplication( + dev_id1, app_id1, HmiTypes(policy_table::AHT_DEFAULT)); EXPECT_FALSE(manager->IsPredataPolicy(app_id1)); - EXPECT_CALL(listener, OnPendingPermissionChange(app_id1)).Times(0); - manager->ReactOnUserDevConsentForApp(app_id1, true); + EXPECT_CALL(listener, OnPendingPermissionChange(_, app_id1)).Times(0); + manager->ReactOnUserDevConsentForApp(dev_handle1, app_id1, true); EXPECT_FALSE(manager->IsPredataPolicy(app_id1)); EXPECT_TRUE((manager->GetCache())->IsDefaultPolicy(app_id1)); } @@ -829,7 +1325,8 @@ TEST_F( GetPTU("valid_sdl_pt_update.json"); EXPECT_EQ("UP_TO_DATE", manager->GetPolicyTableStatus()); // Try to add existing app - manager->AddApplication(app_id2, HmiTypes(policy_table::AHT_DEFAULT)); + manager->AddApplication( + dev_id2, app_id2, HmiTypes(policy_table::AHT_DEFAULT)); // Check no update required EXPECT_EQ("UP_TO_DATE", manager->GetPolicyTableStatus()); } @@ -877,13 +1374,14 @@ TEST_F(PolicyManagerImplTest2, GetPTU("valid_sdl_pt_update.json"); EXPECT_EQ("UP_TO_DATE", manager->GetPolicyTableStatus()); - manager->AddApplication(app_id2, HmiTypes(policy_table::AHT_DEFAULT)); + manager->AddApplication( + dev_id2, app_id2, HmiTypes(policy_table::AHT_DEFAULT)); EXPECT_EQ("UP_TO_DATE", manager->GetPolicyTableStatus()); ::policy::Counters counter = ::policy::Counters::DAYS_AFTER_EPOCH; // Set PT was updated 10 days ago (limit is 30 days for now) // So no limit exceeded manager->PTUpdatedAt(counter, days - 10); - manager->OnAppRegisteredOnMobile(app_id2); + manager->OnAppRegisteredOnMobile(dev_id2, app_id2); EXPECT_EQ("UP_TO_DATE", manager->GetPolicyTableStatus()); } @@ -908,7 +1406,7 @@ TEST_F(PolicyManagerImplTest2, OnSystemReady) { TEST_F(PolicyManagerImplTest2, ResetRetrySequence) { // Arrange CreateLocalPT("sdl_preloaded_pt.json"); - manager->ResetRetrySequence(); + manager->ResetRetrySequence(ResetRetryCountType::kResetWithStatusUpdate); EXPECT_EQ("UPDATE_NEEDED", manager->GetPolicyTableStatus()); manager->SetSendOnUpdateSentOut(false); manager->OnUpdateStarted(); @@ -932,9 +1430,8 @@ 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 + @@ -977,9 +1474,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_; } @@ -1090,11 +1586,12 @@ TEST_F(PolicyManagerImplTest2, DISABLED_GetDefaultHmi_SetDeviceAllowed_ExpectReceivedHmiCorrect) { // Arrange CreateLocalPT("ptu2_requestType.json"); - manager->AddApplication(app_id2, HmiTypes(policy_table::AHT_DEFAULT)); + manager->AddApplication( + dev_id2, app_id2, HmiTypes(policy_table::AHT_DEFAULT)); // Check if app has preData policy EXPECT_FALSE(manager->IsPredataPolicy(app_id2)); std::string default_hmi1; - manager->GetDefaultHmi(app_id2, &default_hmi1); + manager->GetDefaultHmi(dev_id2, app_id2, &default_hmi1); EXPECT_EQ("", default_hmi1); ASSERT_TRUE((manager->GetCache())->AddDevice(dev_id2, "Bluetooth")); ASSERT_TRUE((manager->GetCache()) @@ -1110,12 +1607,13 @@ TEST_F(PolicyManagerImplTest2, ::policy::DeviceConsent consent = manager->GetUserConsentForDevice(dev_id2); // Check EXPECT_EQ(::policy::DeviceConsent::kDeviceAllowed, consent); - EXPECT_CALL(listener, OnCurrentDeviceIdUpdateRequired(app_id2)) + EXPECT_CALL(listener, OnCurrentDeviceIdUpdateRequired(_, app_id2)) .WillRepeatedly(Return(dev_id2)); - manager->AddApplication(app_id2, HmiTypes(policy_table::AHT_DEFAULT)); + manager->AddApplication( + dev_id2, app_id2, HmiTypes(policy_table::AHT_DEFAULT)); EXPECT_TRUE((manager->GetCache())->IsDefaultPolicy(app_id2)); std::string default_hmi2; - manager->GetDefaultHmi(app_id2, &default_hmi2); + manager->GetDefaultHmi(dev_id2, app_id2, &default_hmi2); EXPECT_EQ("", default_hmi2); } @@ -1123,7 +1621,8 @@ TEST_F(PolicyManagerImplTest2, GetDefaultPriority_SetDeviceAllowed_ExpectReceivedPriorityCorrect) { // Arrange CreateLocalPT("ptu2_requestType.json"); - manager->AddApplication(app_id2, HmiTypes(policy_table::AHT_DEFAULT)); + manager->AddApplication( + dev_id2, app_id2, HmiTypes(policy_table::AHT_DEFAULT)); // Check if app has preData policy EXPECT_FALSE(manager->IsPredataPolicy(app_id2)); std::string priority1; @@ -1143,9 +1642,10 @@ TEST_F(PolicyManagerImplTest2, ::policy::DeviceConsent consent = manager->GetUserConsentForDevice(dev_id2); // Check EXPECT_EQ(::policy::DeviceConsent::kDeviceAllowed, consent); - EXPECT_CALL(listener, OnCurrentDeviceIdUpdateRequired(app_id2)) + EXPECT_CALL(listener, OnCurrentDeviceIdUpdateRequired(_, app_id2)) .WillRepeatedly(Return(dev_id2)); - manager->AddApplication(app_id2, HmiTypes(policy_table::AHT_DEFAULT)); + manager->AddApplication( + dev_id2, app_id2, HmiTypes(policy_table::AHT_DEFAULT)); EXPECT_TRUE((manager->GetCache())->IsDefaultPolicy(app_id2)); std::string priority2; EXPECT_TRUE(manager->GetPriority(app_id2, &priority2)); @@ -1155,7 +1655,10 @@ TEST_F(PolicyManagerImplTest2, TEST_F(PolicyManagerImplTest2, GetInitialAppData_ExpectReceivedConsentCorrect) { // Arrange CreateLocalPT("sdl_preloaded_pt.json"); - manager->AddApplication(app_id2, HmiTypes(policy_table::AHT_DEFAULT)); + manager->AddApplication( + dev_id2, app_id2, HmiTypes(policy_table::AHT_DEFAULT)); + EXPECT_CALL(listener, GetDevicesIds(app_id2)) + .WillRepeatedly(Return(transport_manager::DeviceList())); ::policy::StringArray app_nicknames; ::policy::StringArray app_hmi_types; manager->GetInitialAppData(app_id2, &app_nicknames, &app_hmi_types); @@ -1197,7 +1700,8 @@ TEST_F( CanAppKeepContext_AddAppFromUnconsentedDevice_ExpectAppCannotKeepContext) { // Arrange CreateLocalPT("sdl_preloaded_pt.json"); - manager->AddApplication(app_id2, HmiTypes(policy_table::AHT_DEFAULT)); + manager->AddApplication( + dev_id2, app_id2, HmiTypes(policy_table::AHT_DEFAULT)); // Check if app has preData policy EXPECT_FALSE(manager->IsPredataPolicy(app_id2)); // Check keep context in preData policy @@ -1209,7 +1713,8 @@ TEST_F(PolicyManagerImplTest2, // Arrange CreateLocalPT("sdl_preloaded_pt.json"); ASSERT_TRUE((manager->GetCache())->AddDevice(dev_id2, "Bluetooth")); - manager->AddApplication(app_id2, HmiTypes(policy_table::AHT_DEFAULT)); + manager->AddApplication( + dev_id2, app_id2, HmiTypes(policy_table::AHT_DEFAULT)); ASSERT_TRUE((manager->GetCache()) ->SetDeviceData(dev_id2, "hardware IPX", @@ -1222,9 +1727,10 @@ TEST_F(PolicyManagerImplTest2, manager->SetUserConsentForDevice(dev_id2, true); ::policy::DeviceConsent consent = manager->GetUserConsentForDevice(dev_id2); EXPECT_EQ(::policy::DeviceConsent::kDeviceAllowed, consent); - EXPECT_CALL(listener, OnCurrentDeviceIdUpdateRequired(app_id2)) + EXPECT_CALL(listener, OnCurrentDeviceIdUpdateRequired(_, app_id2)) .WillRepeatedly(Return(dev_id2)); - manager->AddApplication(app_id2, HmiTypes(policy_table::AHT_DEFAULT)); + manager->AddApplication( + dev_id2, app_id2, HmiTypes(policy_table::AHT_DEFAULT)); EXPECT_TRUE((manager->GetCache())->IsDefaultPolicy(app_id2)); // Check keep context in default policy EXPECT_TRUE(manager->CanAppKeepContext(app_id2)); @@ -1234,7 +1740,10 @@ TEST_F(PolicyManagerImplTest2, CanAppKeepContext_SetPoliciesForAppUpdated_ExpectAppCanKeepContext) { // Arrange CreateLocalPT("sdl_preloaded_pt.json"); - manager->AddApplication(app_id2, HmiTypes(policy_table::AHT_DEFAULT)); + manager->AddApplication( + dev_id2, app_id2, HmiTypes(policy_table::AHT_DEFAULT)); + EXPECT_CALL(listener, GetDevicesIds(app_id2)) + .WillRepeatedly(Return(transport_manager::DeviceList())); GetPTU("valid_sdl_pt_update.json"); // Check keep context in updated policies for app EXPECT_TRUE(manager->CanAppKeepContext(app_id2)); @@ -1245,7 +1754,8 @@ TEST_F(PolicyManagerImplTest2, // Arrange CreateLocalPT("sdl_preloaded_pt.json"); ASSERT_TRUE((manager->GetCache())->AddDevice(dev_id2, "Bluetooth")); - manager->AddApplication(app_id2, HmiTypes(policy_table::AHT_DEFAULT)); + manager->AddApplication( + dev_id2, app_id2, HmiTypes(policy_table::AHT_DEFAULT)); ASSERT_TRUE((manager->GetCache()) ->SetDeviceData(dev_id2, "hardware IPX", @@ -1258,9 +1768,10 @@ TEST_F(PolicyManagerImplTest2, manager->SetUserConsentForDevice(dev_id2, true); ::policy::DeviceConsent consent = manager->GetUserConsentForDevice(dev_id2); EXPECT_EQ(::policy::DeviceConsent::kDeviceAllowed, consent); - EXPECT_CALL(listener, OnCurrentDeviceIdUpdateRequired(app_id2)) + EXPECT_CALL(listener, OnCurrentDeviceIdUpdateRequired(_, app_id2)) .WillRepeatedly(Return(dev_id2)); - manager->AddApplication(app_id2, HmiTypes(policy_table::AHT_DEFAULT)); + manager->AddApplication( + dev_id2, app_id2, HmiTypes(policy_table::AHT_DEFAULT)); EXPECT_TRUE((manager->GetCache())->IsDefaultPolicy(app_id2)); // Check keep context in default policy EXPECT_TRUE(manager->CanAppStealFocus(app_id2)); @@ -1270,7 +1781,10 @@ TEST_F(PolicyManagerImplTest2, CanAppStealFocus_SetPoliciesForAppUpdated_ExpectAppCanStealFocus) { // Arrange CreateLocalPT("sdl_preloaded_pt.json"); - manager->AddApplication(app_id2, HmiTypes(policy_table::AHT_DEFAULT)); + manager->AddApplication( + dev_id2, app_id2, HmiTypes(policy_table::AHT_DEFAULT)); + EXPECT_CALL(listener, GetDevicesIds(app_id2)) + .WillRepeatedly(Return(transport_manager::DeviceList())); GetPTU("valid_sdl_pt_update.json"); // Check keep context in updated policies for app EXPECT_TRUE(manager->CanAppKeepContext(app_id2)); @@ -1278,26 +1792,11 @@ TEST_F(PolicyManagerImplTest2, TEST_F(PolicyManagerImplTest2, GetCurrentDeviceId) { // Arrange - EXPECT_CALL(listener, OnCurrentDeviceIdUpdateRequired(app_id2)).Times(2); - EXPECT_EQ(custom_str::CustomString(""), manager->GetCurrentDeviceId(app_id2)); - EXPECT_EQ("", manager->GetCurrentDeviceId(app_id2)); -} - -TEST_F(PolicyManagerImplTest2, - GetVehicleInfo_SetVehicleInfo_ExpectReceivedInfoCorrect) { - // Arrange - CreateLocalPT("sdl_preloaded_pt.json"); - GetPTU("valid_sdl_pt_update.json"); - std::shared_ptr pt = (manager->GetCache())->pt(); - policy_table::ModuleConfig& module_config = pt->policy_table.module_config; - ::policy::VehicleInfo vehicle_info = manager->GetVehicleInfo(); - - EXPECT_EQ(static_cast(*module_config.vehicle_make), - vehicle_info.vehicle_make); - EXPECT_EQ(static_cast(*module_config.vehicle_model), - vehicle_info.vehicle_model); - EXPECT_EQ(static_cast(*module_config.vehicle_year), - vehicle_info.vehicle_year); + EXPECT_CALL(listener, OnCurrentDeviceIdUpdateRequired(dev_handle2, app_id2)) + .Times(2); + EXPECT_EQ(custom_str::CustomString(""), + manager->GetCurrentDeviceId(dev_handle2, app_id2)); + EXPECT_EQ("", manager->GetCurrentDeviceId(dev_handle2, app_id2)); } TEST_F( @@ -1324,9 +1823,12 @@ TEST_F( ->SetUserPermissionsForDevice( dev_id2, consented_groups, disallowed_groups); manager->SetUserConsentForDevice(dev_id2, true); - EXPECT_CALL(listener, OnCurrentDeviceIdUpdateRequired(app_id2)) + EXPECT_CALL(listener, OnCurrentDeviceIdUpdateRequired(_, app_id2)) .WillRepeatedly(Return(dev_id2)); - manager->AddApplication(app_id2, HmiTypes(policy_table::AHT_DEFAULT)); + manager->AddApplication( + dev_id2, app_id2, HmiTypes(policy_table::AHT_DEFAULT)); + EXPECT_CALL(listener, GetDevicesIds(app_id2)) + .WillRepeatedly(Return(transport_manager::DeviceList())); GetPTU("valid_sdl_pt_update.json"); ::policy::PermissionConsent perm_consent; @@ -1345,7 +1847,7 @@ TEST_F( perm_consent.group_permissions = groups_permissions; manager->SetUserConsentForApp(perm_consent); - manager->SendNotificationOnPermissionsUpdated(app_id2); + manager->SendNotificationOnPermissionsUpdated(dev_id2, app_id2); std::vector< ::policy::FunctionalGroupPermission> actual_groups_permissions; std::vector< ::policy::FunctionalGroupPermission>::iterator it; manager->GetPermissionsForApp(dev_id2, app_id2, actual_groups_permissions); @@ -1380,7 +1882,10 @@ TEST_F( pt->ReportErrors(&report); } // Add new app - manager->AddApplication(app_id2, HmiTypes(policy_table::AHT_DEFAULT)); + manager->AddApplication( + dev_id2, app_id2, HmiTypes(policy_table::AHT_DEFAULT)); + EXPECT_CALL(listener, GetDevicesIds(app_id2)) + .WillRepeatedly(Return(transport_manager::DeviceList())); uint32_t result = manager->HeartBeatTimeout(app_id2); // By default hertbeat timeout is 0 EXPECT_EQ(0u, result); @@ -1403,6 +1908,80 @@ TEST_F( EXPECT_EQ(heart_beat_timeout.asUInt(), result); } +TEST_F(PolicyManagerImplTest2, CacheManager_RemoveRPCSpecVehicleDataItems) { + policy_table::VehicleDataItems init; + policy_table::VehicleDataItem test_item; + test_item.name = "headLampStatus"; + init.push_back(test_item); + + const auto ret = CacheManager::CollectCustomVDItems(init); + + EXPECT_EQ(0u, ret.size()); +} + +TEST_F(PolicyManagerImplTest2, + CacheManager_RemoveRPCSpecVehicleDataItemsAndRemainCustom) { + policy_table::VehicleDataItems init; + policy_table::VehicleDataItem rpc_spec_item; + rpc_spec_item.name = "headLampStatus"; + policy_table::VehicleDataItem custom_item; + custom_item.name = "Custom"; + init.push_back(rpc_spec_item); + init.push_back(custom_item); + + EXPECT_EQ(2u, init.size()); + + const auto ret = CacheManager::CollectCustomVDItems(init); + + EXPECT_EQ(1u, ret.size()); + EXPECT_EQ(ret.at(0).name, "Custom"); +} + +TEST_F(PolicyManagerImplTest2, CacheManager_RemainCustomVehicleDataItems) { + policy_table::VehicleDataItems init; + policy_table::VehicleDataItem custom_item; + custom_item.name = "Custom"; + init.push_back(custom_item); + + EXPECT_EQ(1u, init.size()); + + const auto& ret = CacheManager::CollectCustomVDItems(init); + + EXPECT_EQ(1u, ret.size()); +} + +TEST_F(PolicyManagerImplTest2, + CacheManager_CollectCustomItemWithRemainingRPCSpecItem) { + policy_table::VehicleDataItems init; + policy_table::VehicleDataItem rpc_spec_item; + rpc_spec_item.name = "headLampStatus"; + policy_table::VehicleDataItem custom_item; + custom_item.name = "Custom"; + init.push_back(rpc_spec_item); + init.push_back(custom_item); + + EXPECT_EQ(2u, init.size()); + + const auto& ret = CacheManager::CollectCustomVDItems(init); + + EXPECT_EQ(1u, ret.size()); + EXPECT_EQ(ret.at(0).name, custom_item.name); +} + +TEST_F(PolicyManagerImplTest2, + CacheManager_RemainRPCSpecVehicleDataItemsNoCustomItems) { + policy_table::VehicleDataItems init; + policy_table::VehicleDataItem custom_item; + custom_item.name = "headLampStatus"; + init.push_back(custom_item); + + EXPECT_EQ(1u, init.size()); + + const auto& ret = CacheManager::CollectCustomVDItems(init); + + EXPECT_EQ(0u, ret.size()); +} + } // namespace policy_test } // namespace components } // namespace test diff --git a/src/components/policy/policy_regular/test/sql_pt_representation_test.cc b/src/components/policy/policy_regular/test/sql_pt_representation_test.cc index 675d7088436..8bb0fb22c6a 100644 --- a/src/components/policy/policy_regular/test/sql_pt_representation_test.cc +++ b/src/components/policy/policy_regular/test/sql_pt_representation_test.cc @@ -29,39 +29,39 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include -#include +#include +#include #include #include #include -#include -#include +#include +#include #include "gtest/gtest.h" +#include "json/reader.h" +#include "json/writer.h" #include "policy/driver_dbms.h" -#include "policy/sql_pt_representation.h" -#include "policy/policy_types.h" #include "policy/mock_policy_settings.h" -#include "policy/policy_table/types.h" #include "policy/policy_table/enums.h" -#include "json/writer.h" -#include "json/reader.h" +#include "policy/policy_table/types.h" +#include "policy/policy_types.h" +#include "policy/sql_pt_representation.h" #include "rpc_base/rpc_base.h" #include "utils/file_system.h" #include "utils/sqlite_wrapper/sql_database.h" namespace policy_table = rpc::policy_table_interface_base; -using policy::SQLPTRepresentation; using policy::CheckPermissionResult; -using policy::UserFriendlyMessage; using policy::EndpointUrls; +using policy::SQLPTRepresentation; +using policy::UserFriendlyMessage; using policy::VehicleInfo; -using testing::ReturnRef; -using testing::Return; -using testing::NiceMock; using testing::Mock; +using testing::NiceMock; +using testing::Return; +using testing::ReturnRef; namespace test { namespace components { @@ -69,7 +69,7 @@ namespace policy_test { using policy_handler_test::MockPolicySettings; -class SQLPTRepresentationTest : public SQLPTRepresentation, +class SQLPTRepresentationTest : protected SQLPTRepresentation, public ::testing::Test { protected: DBMS* dbms; @@ -322,6 +322,8 @@ class SQLPTRepresentationTest : public SQLPTRepresentation, app_policies["1234"]["steal_focus"] = Json::Value(false); app_policies["1234"]["RequestType"] = Json::Value(Json::arrayValue); app_policies["1234"]["app_services"] = Json::Value(Json::objectValue); + app_policies["1234"]["icon_url"] = + Json::Value("http:://www.sdl.com/image.png"); app_policies["1234"]["app_services"]["MEDIA"] = Json::Value(Json::objectValue); app_policies["1234"]["app_services"]["MEDIA"]["service_names"] = @@ -396,7 +398,7 @@ class SQLPTRepresentationTest2 : public ::testing::Test { } void TearDown() OVERRIDE { - file_system::RemoveDirectory(kAppStorageFolder, true); + ASSERT_TRUE(file_system::RemoveDirectory(kAppStorageFolder, true)); delete reps; } @@ -426,6 +428,148 @@ class SQLPTRepresentationTest3 : public ::testing::Test { const std::string kAppStorageFolder; }; +TEST_F(SQLPTRepresentationTest, VehicleDataItem_Store_Item) { + policy_table::VehicleDataItem rpm; + rpm.mark_initialized(); + rpm.name = "rpm"; + rpm.type = "Integer"; + rpm.key = "OEM_REF_RPM"; + rpm.mandatory = false; + *rpm.array = false; + rpm.params->mark_initialized(); + ASSERT_FALSE(reps->VehicleDataItemExists(rpm)); + ASSERT_TRUE(reps->InsertVehicleDataItem(rpm)); + ASSERT_TRUE(reps->VehicleDataItemExists(rpm)); + + auto rpm_retrieved = reps->GetVehicleDataItem(rpm.name, rpm.key); + ASSERT_EQ(rpm.ToJsonValue(), rpm_retrieved.begin()->ToJsonValue()); +} + +TEST_F(SQLPTRepresentationTest, VehicleDataItem_Store_Complete_Item) { + policy_table::VehicleDataItem message; + message.mark_initialized(); + message.name = "messsageName"; + message.type = "String"; + message.key = "OEM_REF_MSG"; + message.mandatory = false; + *message.array = false; + message.params->mark_initialized(); + *message.since = "1.0"; + *message.until = "5.0"; + *message.removed = false; + *message.deprecated = false; + *message.minvalue = 0; + *message.maxvalue = 255; + *message.minsize = 0; + *message.maxsize = 255; + *message.minlength = 0; + *message.maxlength = 255; + ASSERT_TRUE(reps->InsertVehicleDataItem(message)); + + auto message_retrieved = reps->GetVehicleDataItem(message.name, message.key); + ASSERT_EQ(message.ToJsonValue(), message_retrieved.begin()->ToJsonValue()); +} + +TEST_F(SQLPTRepresentationTest, VehicleDataItem_Store_Struct) { + policy_table::VehicleDataItem alss; + alss.mark_initialized(); + alss.name = "ambientLightSensorStatus"; + alss.type = "AmbientLightStatus"; + alss.key = "OEM_REF_AMB_LIGHT"; + alss.mandatory = false; + alss.params->mark_initialized(); + policy_table::VehicleDataItem lss; + lss.mark_initialized(); + lss.name = "LightSensorStatus"; + lss.type = "Struct"; + lss.key = "OEM_REF_SEN_LIGHT"; + lss.mandatory = false; + lss.params->mark_initialized(); + lss.params->push_back(alss); + + policy_table::VehicleDataItem hbo; + hbo.mark_initialized(); + hbo.name = "highBeamsOn"; + hbo.type = "Boolean"; + hbo.key = "OEM_REF_HIGH_BEAM"; + hbo.mandatory = true; + hbo.params->mark_initialized(); + policy_table::VehicleDataItem lbo; + lbo.mark_initialized(); + lbo.name = "lowBeamsOn"; + lbo.type = "Boolean"; + lbo.key = "OEM_REF_LOW_BEAM"; + lbo.mandatory = false; + lbo.params->mark_initialized(); + policy_table::VehicleDataItem hls; + hls.mark_initialized(); + hls.name = "headLampStatus"; + hls.type = "Struct"; + hls.key = "OEM_REF_HLSTATUS"; + hls.mandatory = false; + hls.params->mark_initialized(); + hls.params->push_back(lss); + hls.params->push_back(lbo); + hls.params->push_back(hbo); + ASSERT_TRUE(reps->InsertVehicleDataItem(alss)); + ASSERT_TRUE(reps->InsertVehicleDataItem(hls)); + + auto hls_retrieved = reps->GetVehicleDataItem(hls.name, hls.key); + ASSERT_EQ(hls.ToJsonValue(), hls_retrieved.begin()->ToJsonValue()); +} + +TEST_F(SQLPTRepresentationTest, VehicleDataItem_Select_NonParameterizedVDI) { + policy_table::VehicleDataItems non_parameterized_vdis; + policy_table::VehicleDataItem rpm; + rpm.mark_initialized(); + rpm.name = "rpm"; + rpm.type = "Integer"; + rpm.key = "OEM_REF_RPM"; + rpm.mandatory = false; + *rpm.array = false; + rpm.params->mark_initialized(); + ASSERT_TRUE(reps->InsertVehicleDataItem(rpm)); + policy_table::VehicleDataItem message; + message.mark_initialized(); + message.name = "rpm"; + message.type = "String"; + message.key = "OEM_REF_MSG"; + message.mandatory = false; + *message.array = false; + message.params->mark_initialized(); + ASSERT_TRUE(reps->InsertVehicleDataItem(message)); + non_parameterized_vdis.push_back(rpm); + non_parameterized_vdis.push_back(message); + + policy_table::VehicleDataItems parameterized_vdis; + policy_table::VehicleDataItem alss; + alss.mark_initialized(); + alss.name = "ambientLightSensorStatus"; + alss.type = "AmbientLightStatus"; + alss.key = "OEM_REF_AMB_LIGHT"; + alss.mandatory = false; + alss.params->mark_initialized(); + policy_table::VehicleDataItem lss; + lss.mark_initialized(); + lss.name = "LightSensorStatus"; + lss.type = "Struct"; + lss.key = "OEM_REF_SEN_LIGHT"; + lss.mandatory = false; + lss.params->mark_initialized(); + lss.params->push_back(alss); + ASSERT_TRUE(reps->InsertVehicleDataItem(lss)); + parameterized_vdis.push_back(lss); + + auto non_param_vdi_retrieved = reps->SelectPrimitiveVehicleDataItems(); + + ASSERT_EQ(non_parameterized_vdis.ToJsonValue(), + non_param_vdi_retrieved.ToJsonValue()); + + auto param_vdi_retrieved = reps->SelectCompositeVehicleDataItems(); + ASSERT_EQ(parameterized_vdis.ToJsonValue(), + param_vdi_retrieved.ToJsonValue()); +} + // {AKozoriz} : Unknown behavior (must try 8 times, tried 2 and opened) TEST_F(SQLPTRepresentationTest2, DISABLED_OpenAttemptTimeOut_ExpectCorrectNumber) { @@ -448,8 +592,8 @@ TEST_F(SQLPTRepresentationTest, ASSERT_TRUE(reps->RefreshDB()); // Check PT structure destroyed and tables number is 0 - // There are 33 tables in the database, now. - const int32_t total_tables_number = 33; + // There are 35 tables in the database, now. + const int32_t total_tables_number = 37; ASSERT_EQ(total_tables_number, dbms->FetchOneInt(query_select)); const char* query_select_count_of_iap_buffer_full = "SELECT `count_of_iap_buffer_full` FROM `usage_and_error_count`"; @@ -1642,9 +1786,11 @@ TEST_F(SQLPTRepresentationTest, Save_SetPolicyTableThenSave_ExpectSavedToPT) { const ::policy_table::Parameters& parameters = *(rpc_iter->second.parameters); EXPECT_EQ(1u, parameters.size()); - EXPECT_TRUE(parameters.end() != std::find(parameters.begin(), - parameters.end(), - policy_table::Parameter::P_SPEED)); + EXPECT_TRUE(parameters.end() != + std::find(parameters.begin(), + parameters.end(), + policy_table::EnumToJsonString( + policy_table::Parameter::P_SPEED))); // Check Application Policies Section GatherApplicationPoliciesSection(&policies); const uint32_t apps_size = 3u; @@ -1745,6 +1891,11 @@ TEST_F(SQLPTRepresentationTest, Save_SetPolicyTableThenSave_ExpectSavedToPT) { EXPECT_TRUE(handled_rpcs.is_initialized()); EXPECT_EQ(handled_rpcs[0].function_id, 41); + + policy_table::ApplicationPolicies& apps = policies.apps; + auto icon_url = *(apps[kAppId].icon_url); + + EXPECT_EQ(std::string(icon_url), "http:://www.sdl.com/image.png"); } } // namespace policy_test diff --git a/src/components/policy/policy_regular/test/update_status_manager_test.cc b/src/components/policy/policy_regular/test/update_status_manager_test.cc index 244858554f4..459913fe727 100644 --- a/src/components/policy/policy_regular/test/update_status_manager_test.cc +++ b/src/components/policy/policy_regular/test/update_status_manager_test.cc @@ -30,10 +30,10 @@ * POSSIBILITY OF SUCH DAMAGE. */ +#include "policy/update_status_manager.h" #include "gtest/gtest.h" #include "policy/mock_policy_listener.h" #include "policy/policy_manager_impl.h" -#include "policy/update_status_manager.h" namespace test { namespace components { diff --git a/src/components/policy/policy_regular/test/vehicle_data_item_type_test.cc b/src/components/policy/policy_regular/test/vehicle_data_item_type_test.cc new file mode 100644 index 00000000000..a2f7757936a --- /dev/null +++ b/src/components/policy/policy_regular/test/vehicle_data_item_type_test.cc @@ -0,0 +1,250 @@ +/* + * Copyright (c) 2019, 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 "json/reader.h" +#include "policy/policy_table/types.h" + +#include + +namespace test { +namespace vehicle_info_plugin_test { + +using namespace rpc::policy_table_interface_base; + +namespace { +/* + * class TestString should be used for compact string creation with json value + */ +class TestString { + /** + * @brief Field contains json structure + */ + std::string text_; + /** + * @brief Need for validate should not be returned closed json or empty string + */ + bool is_initialized_; + + public: + TestString() : is_initialized_(false) {} + + /** + * @brief This method handling all types except string + * the name:value will be added to json string + * @param std::string& name - name of json filed + * @param const T& value - value of json filed + */ + template + void AddField(const std::string& name, const T& value) { + const bool is_bool = std::is_same::value; + // Should be writed to json true/false not 1/0 + const std::string text_value = + (is_bool ? (value ? "true" : "false") : std::to_string(value)); + if (text_.empty()) { + is_initialized_ = true; + text_ = "{\"" + name + "\":" + text_value; + return; + } + text_ += ",\"" + name + "\":" + text_value; + } + + /** + * @brief This method handling only string values + * the name:"value" will be added to json string + * this method is coverring value in quotes + * @param std::string& name - name of json filed + * @param const T& value - value of json filed + */ + void AddField(const std::string& name, const char* value) { + if (text_.empty()) { + is_initialized_ = true; + text_ = "{\"" + name + "\":"; + } else { + text_ += ",\"" + name + "\":"; + } + + text_ += value[0] == '{' || value[0] == '[' + ? std::string(value) + : "\"" + std::string(value) + "\""; + } + + /** + * @brief This method close json string before return + * @return all string and close json form by right bracket "}" + * or empty string if json structure is empty + */ + std::string GetValue() { + return is_initialized_ ? text_ + "}" : ""; + } +}; + +} // namespace + +class VehicleDataItemTypeTest : public ::testing::Test { + public: + std::string GetFullJsonString(const std::string& params_array = "") { + TestString str; + str.AddField("name", "VehicleDataItem"); + str.AddField("type", "String"); + str.AddField("key", "OEMDataRef"); + str.AddField("array", true); + str.AddField("mandatory", true); + str.AddField("params", ("[" + params_array + "]").c_str()); + str.AddField("since", "4.0"); + str.AddField("until", "5.0"); + str.AddField("removed", true); + str.AddField("deprecated", true); + str.AddField("minvalue", 1); + str.AddField("maxvalue", 2); + str.AddField("minsize", 10); + str.AddField("maxsize", 20); + str.AddField("minlength", 100); + str.AddField("maxlength", 200); + + return str.GetValue(); + } + + protected: + virtual void TearDown() { + json_.clear(); + } + + Json::Value json_; + Json::Reader reader_; +}; + +TEST_F(VehicleDataItemTypeTest, Initialize_Success) { + reader_.parse(GetFullJsonString(), json_); + VehicleDataItem vdi(&json_); + + EXPECT_TRUE(vdi.is_initialized()); +} + +TEST_F(VehicleDataItemTypeTest, Initialize_Failed) { + VehicleDataItem vdi; + + EXPECT_FALSE(vdi.is_initialized()); +} + +TEST_F(VehicleDataItemTypeTest, CheckConvertFromJsonToVehicleDataItem_Success) { + reader_.parse(GetFullJsonString(), json_); + VehicleDataItem vdi(&json_); + + EXPECT_TRUE((std::string)vdi.name == "VehicleDataItem"); + EXPECT_TRUE((std::string)vdi.type == "String"); + EXPECT_TRUE((std::string)vdi.key == "OEMDataRef"); + EXPECT_TRUE(*vdi.array == true); + EXPECT_TRUE(vdi.mandatory == true); + EXPECT_TRUE(vdi.params->empty()); + EXPECT_TRUE((std::string)*vdi.since == "4.0"); + EXPECT_TRUE((std::string)*vdi.until == "5.0"); + EXPECT_TRUE(*vdi.removed == true); + EXPECT_TRUE(*vdi.deprecated == true); + EXPECT_TRUE(*vdi.minvalue == 1); + EXPECT_TRUE(*vdi.maxvalue == 2); + EXPECT_TRUE(*vdi.minsize == 10); + EXPECT_TRUE(*vdi.maxsize == 20); + EXPECT_TRUE(*vdi.minlength == 100); + EXPECT_TRUE(*vdi.maxlength == 200); +} + +TEST_F(VehicleDataItemTypeTest, CheckConvertFromVehicleDataItemToJson_Success) { + reader_.parse(GetFullJsonString(), json_); + VehicleDataItem vdi(&json_); + + auto jsonFrom = vdi.ToJsonValue(); + VehicleDataItem vdi2(&jsonFrom); + EXPECT_TRUE(vdi == vdi2); +} + +TEST_F(VehicleDataItemTypeTest, CheckIsValid_Failed) { + VehicleDataItem vdi; + + EXPECT_FALSE(vdi.is_valid()); +} + +TEST_F(VehicleDataItemTypeTest, CheckIsValid_Struct_Success) { + reader_.parse(GetFullJsonString(GetFullJsonString()), json_); + VehicleDataItem vdi(&json_); + + vdi.type = "Struct"; + EXPECT_TRUE(vdi.is_valid()); +} + +TEST_F(VehicleDataItemTypeTest, CheckIsValid_Struct_EmptyParams_Failed) { + reader_.parse(GetFullJsonString(), json_); + VehicleDataItem vdi(&json_); + + vdi.type = "Struct"; + EXPECT_FALSE(vdi.is_valid()); +} + +TEST_F(VehicleDataItemTypeTest, CheckIsValid_PODTypes_Success) { + reader_.parse(GetFullJsonString(), json_); + VehicleDataItem vdi(&json_); + + vdi.type = "Integer"; + EXPECT_TRUE(vdi.is_valid()); + + vdi.type = "Float"; + EXPECT_TRUE(vdi.is_valid()); + + vdi.type = "String"; + EXPECT_TRUE(vdi.is_valid()); + + vdi.type = "Boolean"; + EXPECT_TRUE(vdi.is_valid()); +} + +TEST_F(VehicleDataItemTypeTest, CheckEmptiness_True) { + VehicleDataItem vdi; + EXPECT_FALSE(vdi.struct_not_empty()); +} + +TEST_F(VehicleDataItemTypeTest, CheckEmptiness_False) { + reader_.parse(GetFullJsonString(), json_); + + VehicleDataItem vdi(&json_); + EXPECT_TRUE(vdi.struct_not_empty()); +} + +TEST_F(VehicleDataItemTypeTest, CheckCopyConstructor) { + reader_.parse(GetFullJsonString(), json_); + + VehicleDataItem vdi1(&json_); + VehicleDataItem vdi2(vdi1); + + EXPECT_TRUE(vdi1 == vdi2); +} + +} // namespace vehicle_info_plugin_test +} // namespace test diff --git a/src/components/protocol/src/raw_message.cc b/src/components/protocol/src/raw_message.cc index daffd0f2bda..72eb82394bb 100644 --- a/src/components/protocol/src/raw_message.cc +++ b/src/components/protocol/src/raw_message.cc @@ -40,12 +40,14 @@ RawMessage::RawMessage(uint32_t connection_key, uint32_t protocol_version, const uint8_t* const data_param, uint32_t data_sz, + bool protection, uint8_t type, uint32_t payload_size) : connection_key_(connection_key) , data_(NULL) , data_size_(data_sz) , protocol_version_(protocol_version) + , protection_(protection) , service_type_(ServiceTypeFromByte(type)) , payload_size_(payload_size) , waiting_(false) { @@ -87,6 +89,10 @@ bool RawMessage::IsWaiting() const { return waiting_; } +bool RawMessage::protection_flag() const { + return protection_; +} + void RawMessage::set_waiting(bool v) { waiting_ = v; } diff --git a/src/components/protocol_handler/CMakeLists.txt b/src/components/protocol_handler/CMakeLists.txt index ed3aaaf24cf..90dd2c9eda9 100644 --- a/src/components/protocol_handler/CMakeLists.txt +++ b/src/components/protocol_handler/CMakeLists.txt @@ -34,8 +34,11 @@ include_directories( ${COMPONENTS_DIR}/utils/include/ ${COMPONENTS_DIR}/protocol_handler/include/ ${COMPONENTS_DIR}/connection_handler/include/ + ${COMPONENTS_DIR}/application_manager/include + ${CMAKE_BINARY_DIR}/src/components/ ${LOG4CXX_INCLUDE_DIRECTORY} ${BSON_INCLUDE_DIRECTORY} + ${BOOST_INCLUDE_DIR} ) set(PATHS diff --git a/src/components/protocol_handler/docs/SDL.SDD.ServiceStatusUpdate.dox b/src/components/protocol_handler/docs/SDL.SDD.ServiceStatusUpdate.dox new file mode 100644 index 00000000000..dea9ae5d0b6 --- /dev/null +++ b/src/components/protocol_handler/docs/SDL.SDD.ServiceStatusUpdate.dox @@ -0,0 +1,116 @@ +/** +\page service_status_update Service Status Update Detailed Design +## Table of contents +- \subpage service_status_update_intoduction + + \ref service_status_update_rationale "1.1 Rationale" + + \ref service_status_update_scope "1.2 Scope" +- \subpage service_status_update_detail_design + + \ref service_status_update_design_solutions "2.1 Design solutions" + + \ref service_status_update_class_structure "2.2 Class Structure" + + \ref service_status_update_sequence_diagram "2.3 Sequence diagram" +- \subpage service_status_update_data_structures + + \ref service_status_update_data_structure "3.1 Data structures" +- \subpage service_status_update_references_and_history + + \ref service_status_update_history "4.1 References" +*/ +//----------------------------------------------------------- +/** +\page service_status_update_intoduction 1 Introduction +The document is intended to support software developers, +maintenance and integration engineers with sufficient, +detailed information concerning the design, development and +deployment concepts, to accomplish their respective tasks without reliance on the authors. + +\anchor service_status_update_rationale +## 1.1 Rationale +ServiceStatusUpdateHandler and ServiceStatusUpdateHandlerListener classes are +implemented to provide adequate levels of abstraction when passing data between ProtocolHandler, +SecurityManager, ApplicationManager and PolicyHandler + +\anchor service_status_update_scope +## 1.2 Scope +ServiceStatusUpdateHandler is a part of protocol_handler namespace + +*/ +//----------------------------------------------------------- +/** +\page service_status_update_detail_design 2 Component detail design +\anchor service_status_update_design_solutions +### 2.1 Design solutions +The following design approaches and patterns was used for ServiceStatusUpdateHandler: +- Introducing extra layer to process data relevant only for ProtocolHandler or ApplicationManager + + ServiceStatusUpdateHandler converts ServiceStatus value relevant only for ProtocolHandler to + HMI API values relevant only for ApplicationManager +- [Builder design pattern](https://sourcemaking.com/design_patterns/builder) + used for construction of OnServiceUpdate notification object +- [Observer design pattern] + used for notifying ApplicationManager of service update occured + + +#### Design description +protocol_handler::ServiceStatusUpdateHandler is an entity to establish data transfer between +ProtocolHandler and ApplicationManager about occuring service updates +protocol_handler::ServiceStatusUpdateHandlerListener is an interface used +to provide adequate level of abstraction between broadcasting and listening entity +MessageHelper::ServiceStatusUpdateNotificationBuilder is an entity used +for flexible construction of OnServiceUpdate notification object + +\anchor service_status_update_class_structure +### 2.2 Class Structure +The following UML class diagram shows the component structure. +![Service Status Update class diagram](ServiceStatusUpdate_classes.png) +For more information about class diagram follow: +- http://www.uml-diagrams.org/class-diagrams-overview.htqml +- https://sourcemaking.com/uml/modeling-it-systems/structural-view/class-diagram + +\anchor service_status_update_sequence_diagram +### 2.3 Sequence diagram +The following UML sequence diagram shows the component dynamic behavior. +For more information about sequence diagram follow: +- http://www.uml-diagrams.org/sequence-diagrams.html +- https://sourcemaking.com/uml/modeling-it-systems/external-view/use-case-sequence-diagram + +Service Status Update basic flow: +![Basic flow](ServiceStatusUpdate_sequence.png) + +Service Status Update invalid certificate: +![Invalid Cert](invalid_cert.png) + +Service Status Update PTU failed: +![PTU Failed](ptu_failed.png) + +Service Status Update PTU failed (EXTERNAL_PROPRIETARY): +![PTU Failed EXTERNAL_PROPRIETARY](PTU_for_EXTERNAL_PROPRIETARY.png) + +Service Status Update GetSystemTime failed: +![GetSystemTime failed](invalid_time.png) +*/ + +//----------------------------------------------------------- +/** +\page service_status_update_data_structures 3 Component data and resources +\anchor service_status_update_data_structure +### 3.1 Element Data Structure +The following data types are used by the ServiceStatusUpdateHandler: + - protocol_handler::ServiceStatus + +//----------------------------------------------------------- +/** +\page service_status_update_references_and_history 4 References and history +\anchor service_status_update_history +### 4.1 Document history +Document change history + +| Version | Date | Author/Editor | Change description | +|-------------|------------|----------------------------------------|---------------------| +| 0.1 | 02/21/2019 | [MKed](https://github.com/mked-luxoft) | Initial version from the previous [SDL SDD](https://adc.luxoft.com/confluence/pages/viewpage.action?pageId=279677125) | + +Document approve history + +| Version | Date | Author/Editor | Change description | +|-------------|------------|-----------------------------|---------------------| +| | | | | + +For more precise document change history follow github history - +- https://github.com/smartdevicelink/sdl_core/commits/develop/src/components/protocol_handler/docs/SDL.SDD.ServiceStatusUpdate.dox +*/ \ No newline at end of file diff --git a/src/components/protocol_handler/docs/assets/PTU_for_EXTERNAL_PROPRIETARY.png b/src/components/protocol_handler/docs/assets/PTU_for_EXTERNAL_PROPRIETARY.png new file mode 100644 index 00000000000..5962a1f08b5 Binary files /dev/null and b/src/components/protocol_handler/docs/assets/PTU_for_EXTERNAL_PROPRIETARY.png differ diff --git a/src/components/protocol_handler/docs/assets/ServiceStatusUpdate_classes.png b/src/components/protocol_handler/docs/assets/ServiceStatusUpdate_classes.png new file mode 100644 index 00000000000..f604a80aa98 Binary files /dev/null and b/src/components/protocol_handler/docs/assets/ServiceStatusUpdate_classes.png differ diff --git a/src/components/protocol_handler/docs/assets/ServiceStatusUpdate_sequence.png b/src/components/protocol_handler/docs/assets/ServiceStatusUpdate_sequence.png new file mode 100644 index 00000000000..ac58aa9c48a Binary files /dev/null and b/src/components/protocol_handler/docs/assets/ServiceStatusUpdate_sequence.png differ diff --git a/src/components/protocol_handler/docs/assets/invalid_cert.png b/src/components/protocol_handler/docs/assets/invalid_cert.png new file mode 100644 index 00000000000..e208e27a52b Binary files /dev/null and b/src/components/protocol_handler/docs/assets/invalid_cert.png differ diff --git a/src/components/protocol_handler/docs/assets/invalid_time.png b/src/components/protocol_handler/docs/assets/invalid_time.png new file mode 100644 index 00000000000..c9c88a5ed34 Binary files /dev/null and b/src/components/protocol_handler/docs/assets/invalid_time.png differ diff --git a/src/components/protocol_handler/docs/assets/ptu_failed.png b/src/components/protocol_handler/docs/assets/ptu_failed.png new file mode 100644 index 00000000000..f9f5a6d144c Binary files /dev/null and b/src/components/protocol_handler/docs/assets/ptu_failed.png differ 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 cb52c9d3752..9552d4c420b 100644 --- a/src/components/protocol_handler/include/protocol_handler/handshake_handler.h +++ b/src/components/protocol_handler/include/protocol_handler/handshake_handler.h @@ -57,7 +57,8 @@ class HandshakeHandler : public security_manager::SecurityManagerListener { utils::SemanticVersion& full_version, const SessionContext& context, const uint8_t protocol_version, - std::shared_ptr payload); + std::shared_ptr payload, + ServiceStatusUpdateHandler& service_status_update_handler); ~HandshakeHandler(); @@ -82,19 +83,40 @@ class HandshakeHandler : public security_manager::SecurityManagerListener { * @brief Notification about handshake failure * @return true on success notification handling or false otherwise */ - bool OnHandshakeFailed() OVERRIDE; + bool OnGetSystemTimeFailed() OVERRIDE; /** * @brief Notification that certificate update is required. */ void OnCertificateUpdateRequired() OVERRIDE; + bool OnPTUFailed() OVERRIDE; + +#ifdef EXTERNAL_PROPRIETARY_MODE + /** + * @brief OnCertDecryptFailed is called when certificate decryption fails in + * external flow + * @return since this callback is a part of SecurityManagerListener, bool + * return value is used to indicate whether listener instance can be deleted + * by calling entity. if true - listener can be deleted and removed from + * listeners by SecurityManager, false - listener retains its place within + * SecurityManager. + */ + bool OnCertDecryptFailed() OVERRIDE; +#endif + /** * @brief Get connection key of this handler * @return connection key */ uint32_t connection_key() const; + /** + * @brief Get primary connection key of this handler + * @return primary connection key + */ + uint32_t primary_connection_key() const; + private: /** * @brief Performs related actions if handshake was successfully finished @@ -107,8 +129,21 @@ class HandshakeHandler : public security_manager::SecurityManagerListener { /** * @brief Performs related actions if handshake was failed * @param params set of params used in bson part of message + * @param service_status - service status to be sent to HMI + */ + void ProcessFailedHandshake(BsonObject& params, ServiceStatus service_status); + + /** + * @brief Determines whether service can be protected + * @return true is service can be protected, otherwise - false + */ + bool CanBeProtected() const; + + /** + * @brief Determines whether service is already protected + * @return true is service is already protected, otherwise - false */ - void ProcessFailedHandshake(BsonObject& params); + bool IsAlreadyProtected() const; ProtocolHandlerImpl& protocol_handler_; SessionObserver& session_observer_; @@ -116,6 +151,7 @@ class HandshakeHandler : public security_manager::SecurityManagerListener { utils::SemanticVersion full_version_; const uint8_t protocol_version_; std::shared_ptr payload_; + ServiceStatusUpdateHandler& service_status_update_handler_; }; } // namespace protocol_handler diff --git a/src/components/protocol_handler/include/protocol_handler/incoming_data_handler.h b/src/components/protocol_handler/include/protocol_handler/incoming_data_handler.h index 4633be6c6e4..82bf563bc56 100644 --- a/src/components/protocol_handler/include/protocol_handler/incoming_data_handler.h +++ b/src/components/protocol_handler/include/protocol_handler/incoming_data_handler.h @@ -34,9 +34,9 @@ #include #include -#include "utils/macro.h" #include "protocol_handler/protocol_packet.h" #include "transport_manager/common.h" +#include "utils/macro.h" namespace protocol_handler { 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 84ec3c9e30b..3da63bd79f3 100644 --- a/src/components/protocol_handler/include/protocol_handler/multiframe_builder.h +++ b/src/components/protocol_handler/include/protocol_handler/multiframe_builder.h @@ -33,13 +33,13 @@ #ifndef SRC_COMPONENTS_PROTOCOL_HANDLER_INCLUDE_PROTOCOL_HANDLER_MULTIFRAME_BUILDER_H_ #define SRC_COMPONENTS_PROTOCOL_HANDLER_INCLUDE_PROTOCOL_HANDLER_MULTIFRAME_BUILDER_H_ -#include -#include // std::basic_ostream -#include // std::ostream_iterator #include // std::copy +#include // std::ostream_iterator +#include +#include // std::basic_ostream -#include "utils/date_time.h" #include "protocol_handler/protocol_packet.h" +#include "utils/date_time.h" /** *\namespace protocol_handlerHandler @@ -86,36 +86,36 @@ typedef std::map MultiFrameMap; class MultiFrameBuilder { public: /** - * @brief Constructor - */ + * @brief Constructor + */ MultiFrameBuilder(); /** - *\brief Set timeout of waiting CONSECUTIVE frames - */ + *\brief Set timeout of waiting CONSECUTIVE frames + */ void set_waiting_timeout(const uint32_t consecutive_frame_wait_msecs); /** - * @brief Add connection for pending data - * @return true on success - */ + * @brief Add connection for pending data + * @return true on success + */ bool AddConnection(const ConnectionID connection_id); /** - * @brief Clear all data related to connection_id - * @return true on success - */ + * @brief Clear all data related to connection_id + * @return true on success + */ bool RemoveConnection(const ConnectionID connection_id); /** - *\brief Pop assembled and expired frames - */ + *\brief Pop assembled and expired frames + */ ProtocolFramePtrList PopMultiframes(); /** - *\brief Handle Single or Consecutive frame - * @return RESULT_OK on success, or RESULT_FAIL in case of any error - */ + *\brief Handle Single or Consecutive frame + * @return RESULT_OK on success, or RESULT_FAIL in case of any error + */ RESULT_CODE AddFrame(const ProtocolFramePtr packet); private: 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 7c2b411dcbb..8dbfc4ed4d2 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 @@ -33,33 +33,34 @@ #ifndef SRC_COMPONENTS_PROTOCOL_HANDLER_INCLUDE_PROTOCOL_HANDLER_PROTOCOL_HANDLER_IMPL_H_ #define SRC_COMPONENTS_PROTOCOL_HANDLER_INCLUDE_PROTOCOL_HANDLER_PROTOCOL_HANDLER_IMPL_H_ +#include #include #include #include -#include #include // std::make_pair #include -#include "utils/prioritized_queue.h" #include "utils/message_queue.h" +#include "utils/prioritized_queue.h" #include "utils/threads/message_loop_thread.h" -#include "utils/messagemeter.h" #include "utils/custom_string.h" +#include "utils/messagemeter.h" #include "utils/semantic_version.h" +#include "application_manager/policies/policy_handler_observer.h" +#include "connection_handler/connection_handler.h" +#include "protocol_handler/incoming_data_handler.h" +#include "protocol_handler/multiframe_builder.h" #include "protocol_handler/protocol_handler.h" -#include "protocol_handler/protocol_packet.h" #include "protocol_handler/protocol_handler_settings.h" -#include "protocol_handler/session_observer.h" #include "protocol_handler/protocol_observer.h" -#include "protocol_handler/incoming_data_handler.h" -#include "protocol_handler/multiframe_builder.h" +#include "protocol_handler/protocol_packet.h" +#include "protocol_handler/service_status_update_handler.h" +#include "protocol_handler/session_observer.h" #include "transport_manager/common.h" +#include "transport_manager/transport_adapter/transport_adapter.h" #include "transport_manager/transport_manager.h" #include "transport_manager/transport_manager_listener_empty.h" -#include "transport_manager/transport_adapter/transport_adapter.h" -#include "connection_handler/connection_handler.h" -#include "application_manager/policies/policy_handler_observer.h" #ifdef TELEMETRY_MONITOR #include "protocol_handler/telemetry_observer.h" @@ -67,8 +68,8 @@ #endif // TELEMETRY_MONITOR #ifdef ENABLE_SECURITY -#include "security_manager/security_manager.h" #include "protocol_handler/handshake_handler.h" +#include "security_manager/security_manager.h" #endif // ENABLE_SECURITY namespace connection_handler { @@ -110,7 +111,8 @@ struct RawFordMessageFromMobile : public ProtocolFramePtr { // PrioritizedQueue requires this method to decide which priority to assign size_t PriorityOrder() const { return MessagePriority::FromServiceType( - ServiceTypeFromByte(get()->service_type())).OrderingValue(); + ServiceTypeFromByte(get()->service_type())) + .OrderingValue(); } }; @@ -122,7 +124,8 @@ struct RawFordMessageToMobile : public ProtocolFramePtr { // PrioritizedQueue requires this method to decide which priority to assign size_t PriorityOrder() const { return MessagePriority::FromServiceType( - ServiceTypeFromByte(get()->service_type())).OrderingValue(); + ServiceTypeFromByte(get()->service_type())) + .OrderingValue(); } // Signals whether connection to mobile must be closed after processing this // message @@ -131,9 +134,11 @@ struct RawFordMessageToMobile : public ProtocolFramePtr { // Short type names for prioritized message queues typedef threads::MessageLoopThread< - utils::PrioritizedQueue > FromMobileQueue; + utils::PrioritizedQueue > + FromMobileQueue; typedef threads::MessageLoopThread< - utils::PrioritizedQueue > ToMobileQueue; + utils::PrioritizedQueue > + ToMobileQueue; // Type to allow easy mapping between a device type and transport // characteristics @@ -176,10 +181,10 @@ class ProtocolHandlerImpl public impl::FromMobileQueue::Handler, public impl::ToMobileQueue::Handler #ifdef TELEMETRY_MONITOR - , + , public telemetry_monitor::TelemetryObservable #endif // TELEMETRY_MONITOR - { +{ public: /** * @brief Constructor @@ -206,6 +211,16 @@ class ProtocolHandlerImpl void RemoveProtocolObserver(ProtocolObserver* observer) OVERRIDE; + void ProcessFailedPTU() OVERRIDE; + +#ifdef EXTERNAL_PROPRIETARY_MODE + /** + * @brief ProcessFailedCertDecrypt is called to notify security manager that + * certificate decryption failed in the external flow + */ + void ProcessFailedCertDecrypt() OVERRIDE; +#endif + #ifdef ENABLE_SECURITY /** * \brief Sets pointer for SecurityManager layer for managing protection @@ -216,6 +231,9 @@ class ProtocolHandlerImpl security_manager::SecurityManager* security_manager); #endif // ENABLE_SECURITY + void set_service_status_update_handler( + std::unique_ptr handler); + /** * \brief Stop all handling activity */ @@ -226,8 +244,11 @@ class ProtocolHandlerImpl * \param message Message with params to be sent to Mobile App */ void SendMessageToMobileApp(const RawMessagePtr message, + bool needs_encryption, bool final_message) OVERRIDE; + bool IsRPCServiceSecure(const uint32_t connection_key) const OVERRIDE; + /** * \brief Sends number of processed frames in case of binary nav streaming * \param connection_key Unique key used by other components as session @@ -252,26 +273,26 @@ class ProtocolHandlerImpl void SendHeartBeat(int32_t connection_id, uint8_t session_id); /** - * \brief Sends ending session to mobile application - * \param connection_id Identifier of connection within which - * session exists - * \param session_id ID of session to be ended - */ + * \brief Sends ending session to mobile application + * \param connection_id Identifier of connection within which + * session exists + * \param session_id ID of session to be ended + */ void SendEndSession(int32_t connection_id, uint8_t session_id); /** - * \brief Sends ending session to mobile application - * \param primary_connection_id Identifier of connection within which - * service exists - * \param connection_id Identifier of the actual transport for the service - * \param session_id ID of session to be ended - */ + * \brief Sends ending session to mobile application + * \param primary_connection_id Identifier of connection within which + * service exists + * \param connection_id Identifier of the actual transport for the service + * \param session_id ID of session to be ended + */ void SendEndService(int32_t primary_connection_id, int32_t connection_id, uint8_t session_id, uint8_t service_type); - void NotifyOnFailedHandshake() OVERRIDE; + void NotifyOnGetSystemTimeFailed() OVERRIDE; // TODO(Ezamakhov): move Ack/Nack as interface for StartSessionHandler /** @@ -429,9 +450,6 @@ class ProtocolHandlerImpl void NotifySessionStarted(const SessionContext& context, std::vector& rejected_params) OVERRIDE; - void OnAuthTokenUpdated(const std::string& policy_app_id, - const std::string& auth_token) OVERRIDE; - #ifdef BUILD_TESTS const impl::FromMobileQueue& get_from_mobile_queue() const { return raw_ford_messages_from_mobile_; @@ -450,6 +468,8 @@ class ProtocolHandlerImpl } #endif + void OnAuthTokenUpdated(const std::string&, const std::string&) OVERRIDE; + private: void SendEndServicePrivate(int32_t primary_connection_id, int32_t connection_id, @@ -516,10 +536,6 @@ class ProtocolHandlerImpl void OnTMMessageSendFailed(const transport_manager::DataSendError& error, const RawMessagePtr message) OVERRIDE; - void OnConnectionPending( - const transport_manager::DeviceInfo& device_info, - const transport_manager::ConnectionUID connection_id) OVERRIDE; - void OnConnectionEstablished( const transport_manager::DeviceInfo& device_info, const transport_manager::ConnectionUID connection_id) OVERRIDE; @@ -531,6 +547,10 @@ class ProtocolHandlerImpl const transport_manager::ConnectionUID connection_id, const transport_manager::CommunicationError& error) OVERRIDE; + void OnConnectionPending( + const transport_manager::DeviceInfo& device_info, + const transport_manager::ConnectionUID connection_id) OVERRIDE; + /** * @brief Notifies that configuration of a transport has been updated. * @@ -565,6 +585,7 @@ class ProtocolHandlerImpl const uint8_t service_type, const size_t data_size, const uint8_t* data, + const bool needs_encryption, const bool is_final_message); /** @@ -587,6 +608,7 @@ class ProtocolHandlerImpl const size_t data_size, const uint8_t* data, const size_t max_frame_size, + const bool needs_encryption, const bool is_final_message); /** @@ -695,6 +717,12 @@ class ProtocolHandlerImpl const std::string TransportTypeFromTransport( const utils::custom_string::CustomString& transport) const; + const ServiceStatus ServiceDisallowedBySettings( + const ServiceType service_type, + const ConnectionID connection_id, + const uint8_t session_id, + const bool protection) const; + const ProtocolHandlerSettings& settings_; /** @@ -781,6 +809,8 @@ class ProtocolHandlerImpl sync_primitives::Lock start_session_frame_map_lock_; StartSessionFrameMap start_session_frame_map_; + std::unique_ptr service_status_update_handler_; + // Map policy app id -> auth token sync_primitives::Lock auth_token_map_lock_; std::map auth_token_map_; diff --git a/src/components/protocol_handler/include/protocol_handler/protocol_packet.h b/src/components/protocol_handler/include/protocol_handler/protocol_packet.h index de4af849153..215c63c6859 100644 --- a/src/components/protocol_handler/include/protocol_handler/protocol_packet.h +++ b/src/components/protocol_handler/include/protocol_handler/protocol_packet.h @@ -34,9 +34,9 @@ #define SRC_COMPONENTS_PROTOCOL_HANDLER_INCLUDE_PROTOCOL_HANDLER_PROTOCOL_PACKET_H_ #include -#include "utils/macro.h" #include "protocol/common.h" #include "transport_manager/common.h" +#include "utils/macro.h" /** *\namespace protocol_handlerHandler @@ -275,8 +275,8 @@ class ProtocolPacket { /*End of Deserialization*/ /** - * \brief Getter for Connection Identifier - */ + * \brief Getter for Connection Identifier + */ ConnectionID connection_id() const; /** @@ -285,13 +285,13 @@ class ProtocolPacket { void set_connection_id(ConnectionID connection_id); /** - * \brief Getter for data payload size - */ + * \brief Getter for data payload size + */ uint32_t payload_size() const; /** - * \brief Getter for full header information - */ + * \brief Getter for full header information + */ const ProtocolHeader& packet_header() const; private: @@ -311,9 +311,9 @@ class ProtocolPacket { uint32_t payload_size_; /** - * \brief Connection Identifier - * Obtained from connection_handler - */ + * \brief Connection Identifier + * Obtained from connection_handler + */ ConnectionID connection_id_; DISALLOW_COPY_AND_ASSIGN(ProtocolPacket); diff --git a/src/components/protocol_handler/include/protocol_handler/service_status_update_handler.h b/src/components/protocol_handler/include/protocol_handler/service_status_update_handler.h new file mode 100644 index 00000000000..c94ddb91e4b --- /dev/null +++ b/src/components/protocol_handler/include/protocol_handler/service_status_update_handler.h @@ -0,0 +1,89 @@ +/* + Copyright (c) 2019, 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_PROTOCOL_HANDLER_INCLUDE_PROTOCOL_HANDLER_SERVICE_STATUS_UPDATE_HANDLER_H_ +#define SRC_COMPONENTS_PROTOCOL_HANDLER_INCLUDE_PROTOCOL_HANDLER_SERVICE_STATUS_UPDATE_HANDLER_H_ + +#include "protocol_handler/service_status_update_handler_listener.h" + +namespace protocol_handler { + +/** + * @brief ServiceStatus helper enum containing reasons for + * service + * status to be updated + */ +enum class ServiceStatus { + INVALID_ENUM = -1, + SERVICE_RECEIVED, + SERVICE_ACCEPTED, + SERVICE_START_FAILED, + PTU_FAILED, + CERT_INVALID, + INVALID_TIME, + PROTECTION_ENFORCED, + PROTECTION_DISABLED, + UNSECURE_START_FAILED +}; + +/** + * @brief ServiceStatusUpdateHandler class is used to notify listeners about + * occured events during service start + */ +class ServiceStatusUpdateHandler { + public: + /** + * @brief ServiceStatusUpdateHandler class constructor + * @param listener pointer to ServiceStatusUpdateHandlerListener instance + */ + ServiceStatusUpdateHandler(ServiceStatusUpdateHandlerListener* listener) + : listener_(listener) {} + + /** + * @brief OnServiceUpdate callback that is invoked in case of + * service status update needed + * @param connection_key - connection key + * @param service_type enum value containing type of service. + * @param service_status enum value containing status of service. + * received + */ + void OnServiceUpdate(const uint32_t connection_key, + const protocol_handler::ServiceType service_type, + const ServiceStatus service_status); + + private: + ServiceStatusUpdateHandlerListener* listener_; +}; + +} // namespace protocol_handler + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_SERVICE_STATUS_UPDATE_HANDLER_H_ diff --git a/src/components/protocol_handler/include/protocol_handler/service_status_update_handler_listener.h b/src/components/protocol_handler/include/protocol_handler/service_status_update_handler_listener.h new file mode 100644 index 00000000000..3c782f72f83 --- /dev/null +++ b/src/components/protocol_handler/include/protocol_handler/service_status_update_handler_listener.h @@ -0,0 +1,77 @@ +/* + * Copyright (c) 2019, 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_PROTOCOL_HANDLER_INCLUDE_PROTOCOL_HANDLER_SERVICE_STATUS_UPDATE_HANDLER_LISTENER_H_ +#define SRC_COMPONENTS_PROTOCOL_HANDLER_INCLUDE_PROTOCOL_HANDLER_SERVICE_STATUS_UPDATE_HANDLER_LISTENER_H_ + +#include "interfaces/HMI_API.h" +#include "protocol_handler/protocol_handler.h" +#include "transport_manager/transport_manager.h" +#include "utils/optional.h" + +namespace protocol_handler { +/** + * @brief Converts service type enum value from protocol_handler to hmi_apis. + * @param service_type protocol_handler enum value. + */ +hmi_apis::Common_ServiceType::eType GetHMIServiceType( + protocol_handler::ServiceType service_type); + +/** + * @brief ServiceStatusUpdateHandlerListener provides callbacks interface with + * a purpose to notify HMI on successful or failed state updates of different + * services + */ +class ServiceStatusUpdateHandlerListener { + public: + /** + * @brief ProcessServiceStatusUpdate callback that is invoked in case of + * service + * status update + * @param connection_key - connection key + * @param service_type enum value containing type of service. + * @param service_event enum value containing event that occured during + * service start. + * @param service_update_reason enum value containing reason why service_event + * occured. + */ + virtual void ProcessServiceStatusUpdate( + const uint32_t connection_key, + hmi_apis::Common_ServiceType::eType service_type, + hmi_apis::Common_ServiceEvent::eType service_event, + utils::Optional + service_update_reason) = 0; +}; + +} // namespace protocol_handler + +#endif diff --git a/src/components/protocol_handler/src/handshake_handler.cc b/src/components/protocol_handler/src/handshake_handler.cc index 775d77db66b..3b4ae6ef1f1 100644 --- a/src/components/protocol_handler/src/handshake_handler.cc +++ b/src/components/protocol_handler/src/handshake_handler.cc @@ -36,25 +36,29 @@ #include "protocol_handler/protocol_handler_impl.h" #include "protocol_handler/protocol_packet.h" -#include "security_manager/security_manager.h" #include "protocol_handler/session_observer.h" +#include "security_manager/security_manager.h" +#include "utils/helpers.h" namespace protocol_handler { CREATE_LOGGERPTR_GLOBAL(logger_, "ProtocolHandler") -HandshakeHandler::HandshakeHandler(ProtocolHandlerImpl& protocol_handler, - SessionObserver& session_observer, - utils::SemanticVersion& full_version, - const SessionContext& context, - const uint8_t protocol_version, - std::shared_ptr payload) +HandshakeHandler::HandshakeHandler( + ProtocolHandlerImpl& protocol_handler, + SessionObserver& session_observer, + utils::SemanticVersion& full_version, + const SessionContext& context, + const uint8_t protocol_version, + std::shared_ptr payload, + ServiceStatusUpdateHandler& service_status_update_handler) : protocol_handler_(protocol_handler) , session_observer_(session_observer) , context_(context) , full_version_(full_version) , protocol_version_(protocol_version) - , payload_(payload) {} + , payload_(payload) + , service_status_update_handler_(service_status_update_handler) {} HandshakeHandler::~HandshakeHandler() { LOG4CXX_DEBUG(logger_, "Destroying of HandshakeHandler: " << this); @@ -65,35 +69,67 @@ uint32_t HandshakeHandler::connection_key() const { context_.new_session_id_); } +uint32_t HandshakeHandler::primary_connection_key() const { + return session_observer_.KeyFromPair(context_.primary_connection_id_, + context_.new_session_id_); +} + bool HandshakeHandler::GetPolicyCertificateData(std::string& data) const { return false; } -void HandshakeHandler::OnCertificateUpdateRequired() {} +void HandshakeHandler::OnCertificateUpdateRequired() { + LOG4CXX_AUTO_TRACE(logger_); +} + +#if defined(EXTERNAL_PROPRIETARY_MODE) && defined(ENABLE_SECURITY) +bool HandshakeHandler::OnCertDecryptFailed() { + LOG4CXX_AUTO_TRACE(logger_); + if (payload_) { + ProcessFailedHandshake(*payload_, ServiceStatus::CERT_INVALID); + } + + return true; +} +#endif + +bool HandshakeHandler::OnGetSystemTimeFailed() { + LOG4CXX_AUTO_TRACE(logger_); -bool HandshakeHandler::OnHandshakeFailed() { if (payload_) { - ProcessFailedHandshake(*payload_); + ProcessFailedHandshake(*payload_, ServiceStatus::INVALID_TIME); } else { BsonObject params; bson_object_initialize_default(¶ms); - ProcessFailedHandshake(params); + ProcessFailedHandshake(params, ServiceStatus::INVALID_TIME); bson_object_deinitialize(¶ms); } return true; } +bool HandshakeHandler::OnPTUFailed() { + LOG4CXX_AUTO_TRACE(logger_); + if (payload_) { + ProcessFailedHandshake(*payload_, ServiceStatus::PTU_FAILED); + } + + return true; +} + bool HandshakeHandler::OnHandshakeDone( uint32_t connection_key, security_manager::SSLContext::HandshakeResult result) { LOG4CXX_AUTO_TRACE(logger_); - if (connection_key != this->connection_key()) { + LOG4CXX_DEBUG(logger_, + "OnHandshakeDone for service : " << context_.service_type_); + + if (connection_key != this->primary_connection_key()) { LOG4CXX_DEBUG(logger_, "Listener " << this << " expects notification for connection id: " - << this->connection_key() + << this->primary_connection_key() << ". Received notification for connection id " << connection_key << " will be ignored"); return false; @@ -106,7 +142,7 @@ bool HandshakeHandler::OnHandshakeDone( if (success) { ProcessSuccessfulHandshake(connection_key, *payload_); } else { - ProcessFailedHandshake(*payload_); + ProcessFailedHandshake(*payload_, ServiceStatus::CERT_INVALID); } } else { BsonObject params; @@ -114,7 +150,7 @@ bool HandshakeHandler::OnHandshakeDone( if (success) { ProcessSuccessfulHandshake(connection_key, params); } else { - ProcessFailedHandshake(params); + ProcessFailedHandshake(params, ServiceStatus::CERT_INVALID); } bson_object_deinitialize(¶ms); } @@ -122,20 +158,25 @@ bool HandshakeHandler::OnHandshakeDone( return true; } +bool HandshakeHandler::CanBeProtected() const { + const auto& force_unprotected = + protocol_handler_.get_settings().force_unprotected_service(); + + return !(helpers::in_range(force_unprotected, context_.service_type_)); +} + +bool HandshakeHandler::IsAlreadyProtected() const { + return (session_observer_.GetSSLContext(this->primary_connection_key(), + context_.service_type_) != NULL); +} + void HandshakeHandler::ProcessSuccessfulHandshake(const uint32_t connection_key, BsonObject& params) { LOG4CXX_AUTO_TRACE(logger_); - const std::vector& force_unprotected = - protocol_handler_.get_settings().force_unprotected_service(); - const bool can_be_protected = - std::find(force_unprotected.begin(), - force_unprotected.end(), - context_.service_type_) == force_unprotected.end(); + const bool is_service_already_protected = IsAlreadyProtected(); - const bool is_service_already_protected = - session_observer_.GetSSLContext(connection_key, context_.service_type_) != - NULL; + const bool can_be_protected = CanBeProtected(); LOG4CXX_DEBUG(logger_, "Service can be protected: " << can_be_protected @@ -144,6 +185,10 @@ void HandshakeHandler::ProcessSuccessfulHandshake(const uint32_t connection_key, if (can_be_protected && !is_service_already_protected) { session_observer_.SetProtectionFlag(connection_key, context_.service_type_); + service_status_update_handler_.OnServiceUpdate( + this->connection_key(), + context_.service_type_, + ServiceStatus::SERVICE_ACCEPTED); protocol_handler_.SendStartSessionAck(context_.connection_id_, context_.new_session_id_, protocol_version_, @@ -153,6 +198,10 @@ void HandshakeHandler::ProcessSuccessfulHandshake(const uint32_t connection_key, full_version_, params); } else { + service_status_update_handler_.OnServiceUpdate( + this->connection_key(), + context_.service_type_, + ServiceStatus::SERVICE_START_FAILED); protocol_handler_.SendStartSessionNAck(context_.connection_id_, context_.new_session_id_, protocol_version_, @@ -160,7 +209,8 @@ void HandshakeHandler::ProcessSuccessfulHandshake(const uint32_t connection_key, } } -void HandshakeHandler::ProcessFailedHandshake(BsonObject& params) { +void HandshakeHandler::ProcessFailedHandshake(BsonObject& params, + ServiceStatus service_status) { LOG4CXX_AUTO_TRACE(logger_); LOG4CXX_DEBUG(logger_, "Handshake failed"); const std::vector& force_protected = @@ -177,6 +227,10 @@ void HandshakeHandler::ProcessFailedHandshake(BsonObject& params) { << context_.is_new_service_); if (can_be_unprotected && context_.is_new_service_) { + service_status_update_handler_.OnServiceUpdate( + this->connection_key(), + context_.service_type_, + ServiceStatus::PROTECTION_DISABLED); protocol_handler_.SendStartSessionAck(context_.connection_id_, context_.new_session_id_, protocol_version_, @@ -186,6 +240,8 @@ void HandshakeHandler::ProcessFailedHandshake(BsonObject& params) { full_version_, params); } else { + service_status_update_handler_.OnServiceUpdate( + this->connection_key(), context_.service_type_, service_status); protocol_handler_.SendStartSessionNAck(context_.connection_id_, context_.new_session_id_, protocol_version_, diff --git a/src/components/protocol_handler/src/incoming_data_handler.cc b/src/components/protocol_handler/src/incoming_data_handler.cc index 4944ea9cc77..566b36f46dd 100644 --- a/src/components/protocol_handler/src/incoming_data_handler.cc +++ b/src/components/protocol_handler/src/incoming_data_handler.cc @@ -30,8 +30,8 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include "protocol_handler/incoming_data_handler.h" -#include "utils/logger.h" #include "protocol/common.h" +#include "utils/logger.h" namespace protocol_handler { diff --git a/src/components/protocol_handler/src/multiframe_builder.cc b/src/components/protocol_handler/src/multiframe_builder.cc index c34e2ec640a..fbfc0614904 100644 --- a/src/components/protocol_handler/src/multiframe_builder.cc +++ b/src/components/protocol_handler/src/multiframe_builder.cc @@ -36,8 +36,8 @@ #include "utils/logger.h" -#include "utils/lock.h" #include "utils/date_time.h" +#include "utils/lock.h" namespace protocol_handler { @@ -261,6 +261,11 @@ RESULT_CODE MultiFrameBuilder::HandleConsecutiveFrame( } } + const bool packet_protection_flag = packet->protection_flag(); + if (!assembling_frame->protection_flag() && packet_protection_flag) { + assembling_frame->set_protection_flag(packet_protection_flag); + } + assembling_frame->set_frame_data(new_frame_data); LOG4CXX_DEBUG(logger_, diff --git a/src/components/protocol_handler/src/protocol_handler_impl.cc b/src/components/protocol_handler/src/protocol_handler_impl.cc index 518509a0fb1..3b216c273c1 100644 --- a/src/components/protocol_handler/src/protocol_handler_impl.cc +++ b/src/components/protocol_handler/src/protocol_handler_impl.cc @@ -32,20 +32,20 @@ #include "protocol_handler/protocol_handler_impl.h" #include // for INET6_ADDRSTRLEN -#include -#include // std::find #include +#include #include +#include // std::find #include "connection_handler/connection_handler_impl.h" +#include "protocol/common.h" #include "protocol_handler/session_observer.h" #include "utils/byte_order.h" #include "utils/helpers.h" -#include "protocol/common.h" #ifdef ENABLE_SECURITY -#include "security_manager/ssl_context.h" #include "security_manager/security_manager.h" +#include "security_manager/ssl_context.h" #endif // ENABLE_SECURITY namespace protocol_handler { @@ -493,8 +493,9 @@ void ProtocolHandlerImpl::SendStartSessionNAck( BsonArray rejectedParamsArr; bson_array_initialize(&rejectedParamsArr, rejectedParams.size()); for (std::string param : rejectedParams) { - char paramPtr[255]; - strncpy(paramPtr, param.c_str(), 255); + char paramPtr[256]; + strncpy(paramPtr, param.c_str(), sizeof(paramPtr)); + paramPtr[sizeof(paramPtr) - 1] = '\0'; bson_array_add_string(&rejectedParamsArr, paramPtr); } bson_object_put_array( @@ -555,8 +556,9 @@ void ProtocolHandlerImpl::SendEndSessionNAck( BsonArray rejectedParamsArr; bson_array_initialize(&rejectedParamsArr, rejectedParams.size()); for (std::string param : rejectedParams) { - char paramPtr[255]; - strncpy(paramPtr, param.c_str(), 255); + char paramPtr[256]; + strncpy(paramPtr, param.c_str(), sizeof(paramPtr)); + paramPtr[sizeof(paramPtr) - 1] = '\0'; bson_array_add_string(&rejectedParamsArr, paramPtr); } bson_object_put_array( @@ -850,6 +852,7 @@ void ProtocolHandlerImpl::SendHeartBeat(int32_t connection_id, } void ProtocolHandlerImpl::SendMessageToMobileApp(const RawMessagePtr message, + bool needs_encryption, bool final_message) { #ifdef TELEMETRY_MONITOR const date_time::TimeDuration start_time = date_time::getCurrentTime(); @@ -917,6 +920,7 @@ void ProtocolHandlerImpl::SendMessageToMobileApp(const RawMessagePtr message, message->service_type(), message->data_size(), message->data(), + needs_encryption, final_message); if (result != RESULT_OK) { LOG4CXX_ERROR(logger_, @@ -934,6 +938,7 @@ void ProtocolHandlerImpl::SendMessageToMobileApp(const RawMessagePtr message, message->data_size(), message->data(), frame_size, + needs_encryption, final_message); if (result != RESULT_OK) { LOG4CXX_ERROR(logger_, @@ -975,9 +980,9 @@ void ProtocolHandlerImpl::OnTMMessageReceived(const RawMessagePtr tm_message) { LOG4CXX_DEBUG(logger_, "Proccessed " << protocol_frames.size() << " frames"); if (result != RESULT_OK) { if (result == RESULT_MALFORMED_OCCURS) { - LOG4CXX_WARN(logger_, - "Malformed message occurs, connection id " - << connection_key); + LOG4CXX_WARN( + logger_, + "Malformed message occurs, connection id " << connection_key); if (!get_settings().malformed_message_filtering()) { LOG4CXX_DEBUG(logger_, "Malformed message filterign disabled"); session_observer_.OnMalformedMessageCallback(connection_key); @@ -1126,13 +1131,27 @@ void ProtocolHandlerImpl::OnUnexpectedDisconnect( OnConnectionClosed(connection_id); } -void ProtocolHandlerImpl::NotifyOnFailedHandshake() { +void ProtocolHandlerImpl::NotifyOnGetSystemTimeFailed() { LOG4CXX_AUTO_TRACE(logger_); #ifdef ENABLE_SECURITY - security_manager_->NotifyListenersOnHandshakeFailed(); + security_manager_->ResetPendingSystemTimeRequests(); + security_manager_->NotifyListenersOnGetSystemTimeFailed(); +#endif // ENABLE_SECURITY +} + +void ProtocolHandlerImpl::ProcessFailedPTU() { +#ifdef ENABLE_SECURITY + security_manager_->ProcessFailedPTU(); #endif // ENABLE_SECURITY } +#ifdef EXTERNAL_PROPRIETARY_MODE +void ProtocolHandlerImpl::ProcessFailedCertDecrypt() { + LOG4CXX_AUTO_TRACE(logger_); + security_manager_->ProcessFailedCertDecrypt(); +} +#endif + void ProtocolHandlerImpl::OnTransportConfigUpdated( const transport_manager::transport_adapter::TransportConfig& configs) { LOG4CXX_AUTO_TRACE(logger_); @@ -1210,6 +1229,19 @@ void ProtocolHandlerImpl::OnAuthTokenUpdated(const std::string& policy_app_id, } } +bool ProtocolHandlerImpl::IsRPCServiceSecure( + const uint32_t connection_key) const { + LOG4CXX_AUTO_TRACE(logger_); +#ifdef ENABLE_SECURITY + + security_manager::SSLContext* context = + session_observer_.GetSSLContext(connection_key, ServiceType::kRpc); + return (context && context->IsInitCompleted()); +#else + return false; +#endif // ENABLE_SECURITY +} + RESULT_CODE ProtocolHandlerImpl::SendFrame(const ProtocolFramePtr packet) { LOG4CXX_AUTO_TRACE(logger_); if (!packet) { @@ -1254,13 +1286,18 @@ RESULT_CODE ProtocolHandlerImpl::SendSingleFrameMessage( const uint8_t service_type, const size_t data_size, const uint8_t* data, + const bool needs_encryption, const bool is_final_message) { LOG4CXX_AUTO_TRACE(logger_); + LOG4CXX_DEBUG( + logger_, + "Packet needs encryption: " << std::boolalpha << needs_encryption); + ProtocolFramePtr ptr( new protocol_handler::ProtocolPacket(connection_id, protocol_version, - PROTECTION_OFF, + needs_encryption, FRAME_TYPE_SINGLE, service_type, FRAME_DATA_SINGLE, @@ -1282,12 +1319,13 @@ RESULT_CODE ProtocolHandlerImpl::SendMultiFrameMessage( const size_t data_size, const uint8_t* data, const size_t max_frame_size, + const bool needs_encryption, const bool is_final_message) { LOG4CXX_AUTO_TRACE(logger_); - LOG4CXX_DEBUG(logger_, - " data size " << data_size << " max_frame_size " - << max_frame_size); + LOG4CXX_DEBUG( + logger_, + " data size " << data_size << " max_frame_size " << max_frame_size); // remainder of last frame const size_t lastframe_remainder = data_size % max_frame_size; @@ -1322,7 +1360,7 @@ RESULT_CODE ProtocolHandlerImpl::SendMultiFrameMessage( const ProtocolFramePtr firstPacket( new protocol_handler::ProtocolPacket(connection_id, protocol_version, - PROTECTION_OFF, + needs_encryption, FRAME_TYPE_FIRST, service_type, FRAME_DATA_FIRST, @@ -1346,7 +1384,7 @@ RESULT_CODE ProtocolHandlerImpl::SendMultiFrameMessage( const ProtocolFramePtr ptr( new protocol_handler::ProtocolPacket(connection_id, protocol_version, - PROTECTION_OFF, + needs_encryption, FRAME_TYPE_CONSECUTIVE, service_type, data_type, @@ -1408,6 +1446,7 @@ RESULT_CODE ProtocolHandlerImpl::HandleSingleFrameMessage( packet->protocol_version(), packet->data(), packet->total_data_bytes(), + packet->protection_flag(), packet->service_type(), packet->payload_size())); if (!rawMessage) { @@ -1565,6 +1604,59 @@ RESULT_CODE ProtocolHandlerImpl::HandleControlMessageEndSession( return RESULT_OK; } +const ServiceStatus ProtocolHandlerImpl::ServiceDisallowedBySettings( + const ServiceType service_type, + const ConnectionID connection_id, + const uint8_t session_id, + const bool protection) const { + LOG4CXX_AUTO_TRACE(logger_); + const std::string& transport = + session_observer_.TransportTypeProfileStringFromConnHandle(connection_id); + + const auto video_transports = settings_.video_service_transports(); + const bool is_video_allowed = + video_transports.empty() || + std::find(video_transports.begin(), video_transports.end(), transport) != + video_transports.end(); + + const auto audio_transports = settings_.audio_service_transports(); + const bool is_audio_allowed = + audio_transports.empty() || + std::find(audio_transports.begin(), audio_transports.end(), transport) != + audio_transports.end(); + +#ifdef ENABLE_SECURITY + const auto& force_protected = get_settings().force_protected_service(); + + const auto& force_unprotected = get_settings().force_unprotected_service(); + + const bool is_force_protected = + (helpers::in_range(force_protected, service_type)); + + const bool is_force_unprotected = + (helpers::in_range(force_unprotected, service_type)); + + const bool can_start_protected = is_force_protected && protection; + + const bool can_start_unprotected = is_force_unprotected && !protection; + + if (is_force_protected && !can_start_protected) { + return ServiceStatus::PROTECTION_ENFORCED; + } + + if (is_force_unprotected && !can_start_unprotected) { + return ServiceStatus::UNSECURE_START_FAILED; + } +#endif // ENABLE_SECURITY + + if ((ServiceType::kMobileNav == service_type && !is_video_allowed) || + (ServiceType::kAudio == service_type && !is_audio_allowed)) { + return ServiceStatus::SERVICE_START_FAILED; + } + + return ServiceStatus::INVALID_ENUM; +} + RESULT_CODE ProtocolHandlerImpl::HandleControlMessageEndServiceACK( const ProtocolPacket& packet) { LOG4CXX_AUTO_TRACE(logger_); @@ -1605,27 +1697,21 @@ RESULT_CODE ProtocolHandlerImpl::HandleControlMessageStartSession( const ConnectionID connection_id = packet->connection_id(); const uint8_t session_id = packet->session_id(); - const std::string& transport = - session_observer_.TransportTypeProfileStringFromConnHandle(connection_id); + const uint32_t connection_key = + session_observer_.KeyFromPair(connection_id, session_id); - const auto video_transports = settings_.video_service_transports(); - const bool is_video_allowed = - video_transports.empty() || - std::find(video_transports.begin(), video_transports.end(), transport) != - video_transports.end(); + service_status_update_handler_->OnServiceUpdate( + connection_key, service_type, ServiceStatus::SERVICE_RECEIVED); - const auto audio_transports = settings_.audio_service_transports(); - const bool is_audio_allowed = - audio_transports.empty() || - std::find(audio_transports.begin(), audio_transports.end(), transport) != - audio_transports.end(); + const auto settings_check = ServiceDisallowedBySettings( + service_type, connection_id, session_id, protection); - if ((ServiceType::kMobileNav == service_type && !is_video_allowed) || - (ServiceType::kAudio == service_type && !is_audio_allowed)) { + if (ServiceStatus::INVALID_ENUM != settings_check) { LOG4CXX_DEBUG(logger_, "Rejecting StartService for service:" - << service_type << ", over transport: " << transport - << ", disallowed by settings."); + << service_type << ", disallowed by settings."); + service_status_update_handler_->OnServiceUpdate( + connection_key, service_type, settings_check); SendStartSessionNAck( connection_id, session_id, protocol_version, service_type); return RESULT_OK; @@ -1723,14 +1809,22 @@ void ProtocolHandlerImpl::NotifySessionStarted( start_session_frame_map_.erase(it); } + const ServiceType service_type = ServiceTypeFromByte(packet->service_type()); const uint8_t protocol_version = packet->protocol_version(); if (0 == context.new_session_id_) { LOG4CXX_WARN(logger_, "Refused by session_observer to create service " - << packet->service_type() << " type."); + << static_cast(service_type) << " type."); + const auto session_id = packet->session_id(); + const auto connection_key = + session_observer_.KeyFromPair(context.connection_id_, session_id); + service_status_update_handler_->OnServiceUpdate( + connection_key, + context.service_type_, + ServiceStatus::SERVICE_START_FAILED); SendStartSessionNAck(context.connection_id_, - packet->session_id(), + session_id, protocol_version, packet->service_type(), rejected_params); @@ -1810,19 +1904,20 @@ void ProtocolHandlerImpl::NotifySessionStarted( } #ifdef ENABLE_SECURITY - const ServiceType service_type = ServiceTypeFromByte(packet->service_type()); // for packet is encrypted and security plugin is enable if (context.is_protected_ && security_manager_) { const uint32_t connection_key = session_observer_.KeyFromPair( context.connection_id_, context.new_session_id_); std::shared_ptr handler = - std::make_shared(*this, - session_observer_, - *fullVersion, - context, - packet->protocol_version(), - start_session_ack_params); + std::make_shared( + *this, + session_observer_, + *fullVersion, + context, + packet->protocol_version(), + start_session_ack_params, + *(service_status_update_handler_.get())); security_manager::SSLContext* ssl_context = security_manager_->CreateSSLContext( @@ -1853,6 +1948,10 @@ void ProtocolHandlerImpl::NotifySessionStarted( // mark service as protected session_observer_.SetProtectionFlag(connection_key, service_type); // Start service as protected with current SSLContext + service_status_update_handler_->OnServiceUpdate( + connection_key, + context.service_type_, + ServiceStatus::SERVICE_ACCEPTED); SendStartSessionAck(context.connection_id_, context.new_session_id_, packet->protocol_version(), @@ -1889,7 +1988,11 @@ void ProtocolHandlerImpl::NotifySessionStarted( return; } #endif // ENABLE_SECURITY + const uint32_t connection_key = session_observer_.KeyFromPair( + context.connection_id_, context.new_session_id_); if (rejected_params.empty()) { + service_status_update_handler_->OnServiceUpdate( + connection_key, context.service_type_, ServiceStatus::SERVICE_ACCEPTED); SendStartSessionAck(context.connection_id_, context.new_session_id_, packet->protocol_version(), @@ -1899,6 +2002,10 @@ void ProtocolHandlerImpl::NotifySessionStarted( *fullVersion, *start_session_ack_params); } else { + service_status_update_handler_->OnServiceUpdate( + connection_key, + context.service_type_, + ServiceStatus::SERVICE_START_FAILED); SendStartSessionNAck(context.connection_id_, packet->session_id(), protocol_version, @@ -1910,9 +2017,9 @@ void ProtocolHandlerImpl::NotifySessionStarted( RESULT_CODE ProtocolHandlerImpl::HandleControlMessageHeartBeat( const ProtocolPacket& packet) { const ConnectionID connection_id = packet.connection_id(); - LOG4CXX_DEBUG(logger_, - "Sending heart beat acknowledgment for connection " - << connection_id); + LOG4CXX_DEBUG( + logger_, + "Sending heart beat acknowledgment for connection " << connection_id); uint8_t protocol_version; if (session_observer_.ProtocolVersionUsed( connection_id, packet.session_id(), protocol_version)) { @@ -1948,13 +2055,14 @@ void ProtocolHandlerImpl::PopValideAndExpirateMultiframes() { const uint32_t connection_key = session_observer_.KeyFromPair( frame->connection_id(), frame->session_id()); - LOG4CXX_DEBUG(logger_, - "Result frame" << frame << "for connection " - << connection_key); + LOG4CXX_DEBUG( + logger_, + "Result frame" << frame << "for connection " << connection_key); const RawMessagePtr rawMessage(new RawMessage(connection_key, frame->protocol_version(), frame->data(), frame->total_data_bytes(), + frame->protection_flag(), frame->service_type(), frame->payload_size())); DCHECK(rawMessage); @@ -1977,9 +2085,9 @@ bool ProtocolHandlerImpl::TrackMessage(const uint32_t& connection_key) { if (frequency_time > 0u && frequency_count > 0u) { const size_t message_frequency = message_meter_.TrackMessage(connection_key); - LOG4CXX_DEBUG(logger_, - "Frequency of " << connection_key << " is " - << message_frequency); + LOG4CXX_DEBUG( + logger_, + "Frequency of " << connection_key << " is " << message_frequency); if (message_frequency > frequency_count) { LOG4CXX_WARN(logger_, "Frequency of " << connection_key << " is marked as high."); @@ -2005,9 +2113,9 @@ bool ProtocolHandlerImpl::TrackMalformedMessage(const uint32_t& connection_key, << malformed_message_frequency); if (!get_settings().malformed_message_filtering() || malformed_message_frequency > malformed_frequency_count) { - LOG4CXX_WARN(logger_, - "Malformed frequency of " << connection_key - << " is marked as high."); + LOG4CXX_WARN( + logger_, + "Malformed frequency of " << connection_key << " is marked as high."); session_observer_.OnMalformedMessageCallback(connection_key); malformed_message_meter_.RemoveIdentifier(connection_key); return true; @@ -2057,7 +2165,8 @@ void ProtocolHandlerImpl::Handle(const impl::RawFordMessageToMobile message) { "Message to mobile app: connection id " << static_cast(message->connection_id()) << ";" - " dataSize: " << message->data_size() + " dataSize: " + << message->data_size() << " ;" " protocolVersion " << static_cast(message->protocol_version())); @@ -2078,6 +2187,11 @@ void ProtocolHandlerImpl::Stop() { start_session_frame_map_.clear(); } +void ProtocolHandlerImpl::set_service_status_update_handler( + std::unique_ptr handler) { + service_status_update_handler_ = std::move(handler); +} + #ifdef ENABLE_SECURITY void ProtocolHandlerImpl::set_security_manager( security_manager::SecurityManager* security_manager) { @@ -2105,7 +2219,12 @@ RESULT_CODE ProtocolHandlerImpl::EncryptFrame(ProtocolFramePtr packet) { packet->connection_id(), packet->session_id()); security_manager::SSLContext* context = session_observer_.GetSSLContext( connection_key, ServiceTypeFromByte(packet->service_type())); - if (!context || !context->IsInitCompleted()) { + + LOG4CXX_DEBUG( + logger_, + "Protection flag is: " << packet->protection_flag() << std::boolalpha); + if ((!context || !context->IsInitCompleted()) || !packet->protection_flag()) { + LOG4CXX_DEBUG(logger_, "Ecryption is skipped!"); return RESULT_OK; } const uint8_t* out_data; @@ -2462,9 +2581,9 @@ void ProtocolHandlerImpl::GenerateServiceTransportsForStartSessionAck( std::vector::const_iterator it = service_transports.begin(); for (; it != service_transports.end(); it++) { const utils::custom_string::CustomString transport(*it); - LOG4CXX_TRACE(logger_, - "Service Allowed to run on " << transport.c_str() - << " transport"); + LOG4CXX_TRACE( + logger_, + "Service Allowed to run on " << transport.c_str() << " transport"); if (!fPrimaryAdded && (transport.CompareIgnoreCase(primary_connection_type.c_str()) || diff --git a/src/components/protocol_handler/src/protocol_packet.cc b/src/components/protocol_handler/src/protocol_packet.cc index d5422e11bc5..4b4e988f891 100644 --- a/src/components/protocol_handler/src/protocol_packet.cc +++ b/src/components/protocol_handler/src/protocol_packet.cc @@ -30,17 +30,17 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include #include -#include -#include +#include #include #include +#include +#include #include "protocol/common.h" #include "protocol_handler/protocol_packet.h" -#include "utils/macro.h" #include "utils/byte_order.h" +#include "utils/macro.h" #include "utils/semantic_version.h" namespace protocol_handler { @@ -118,9 +118,9 @@ void ProtocolPacket::ProtocolHeader::deserialize(const uint8_t* message, case PROTOCOL_VERSION_4: case PROTOCOL_VERSION_5: { if (messageSize < PROTOCOL_HEADER_V2_SIZE) { - LOG4CXX_DEBUG(logger_, - "Message size less " << PROTOCOL_HEADER_V2_SIZE - << " bytes"); + LOG4CXX_DEBUG( + logger_, + "Message size less " << PROTOCOL_HEADER_V2_SIZE << " bytes"); return; } messageId = read_be_uint32(message + 8); @@ -255,9 +255,9 @@ RESULT_CODE ProtocolPacket::ProtocolHeaderValidator::validate( // ServiceType shall be equal 0x0 (Control), 0x07 (RPC), 0x0A (PCM), 0x0B // (Video), 0x0F (Bulk) if (ServiceTypeFromByte(header.serviceType) == kInvalidServiceType) { - LOG4CXX_WARN(logger_, - "Invalide service type" - << static_cast(header.serviceType)); + LOG4CXX_WARN( + logger_, + "Invalide service type" << static_cast(header.serviceType)); return RESULT_FAIL; } // Check frame info for each frame type @@ -433,6 +433,7 @@ RawMessagePtr ProtocolPacket::serializePacket() const { packet_header_.version, packet, total_packet_size, + false, packet_header_.serviceType)); delete[] packet; diff --git a/src/components/protocol_handler/src/protocol_payload.cc b/src/components/protocol_handler/src/protocol_payload.cc index aa011bdf0f5..8916fe91b0e 100644 --- a/src/components/protocol_handler/src/protocol_payload.cc +++ b/src/components/protocol_handler/src/protocol_payload.cc @@ -44,7 +44,7 @@ static const size_t kCorrelationIdBits = 32; static const size_t kJsonSizeBits = 32; static const size_t PayloadHeaderBits = kRpcTypeBits + kRpcFunctionIdBits + kCorrelationIdBits + kJsonSizeBits; -} +} // namespace namespace protocol_handler { diff --git a/src/components/protocol_handler/src/service_status_update_handler.cc b/src/components/protocol_handler/src/service_status_update_handler.cc new file mode 100644 index 00000000000..7b2c67ea23a --- /dev/null +++ b/src/components/protocol_handler/src/service_status_update_handler.cc @@ -0,0 +1,117 @@ +#include "protocol_handler/service_status_update_handler.h" +#include "interfaces/HMI_API.h" + +namespace protocol_handler { + +CREATE_LOGGERPTR_GLOBAL(logger_, "ServiceStatusUpdateHandler") + +hmi_apis::Common_ServiceType::eType GetHMIServiceType( + protocol_handler::ServiceType service_type) { + using namespace hmi_apis; + using namespace protocol_handler; + switch (service_type) { + case SERVICE_TYPE_RPC: { + return Common_ServiceType::RPC; + } + case SERVICE_TYPE_AUDIO: { + return Common_ServiceType::AUDIO; + } + case SERVICE_TYPE_NAVI: { + return Common_ServiceType::VIDEO; + } + default: { return Common_ServiceType::INVALID_ENUM; } + } +} + +void ServiceStatusUpdateHandler::OnServiceUpdate( + const uint32_t connection_key, + const protocol_handler::ServiceType service_type, + ServiceStatus service_status) { + using namespace hmi_apis; + typedef utils::Optional + UpdateReasonOptional; + LOG4CXX_AUTO_TRACE(logger_); + auto hmi_service_type = GetHMIServiceType(service_type); + + switch (service_status) { + case ServiceStatus::SERVICE_RECEIVED: { + return listener_->ProcessServiceStatusUpdate( + connection_key, + hmi_service_type, + Common_ServiceEvent::REQUEST_RECEIVED, + UpdateReasonOptional(UpdateReasonOptional::EMPTY)); + } + case ServiceStatus::SERVICE_ACCEPTED: { + return listener_->ProcessServiceStatusUpdate( + connection_key, + hmi_service_type, + Common_ServiceEvent::REQUEST_ACCEPTED, + UpdateReasonOptional(UpdateReasonOptional::EMPTY)); + } + case ServiceStatus::SERVICE_START_FAILED: { + return listener_->ProcessServiceStatusUpdate( + connection_key, + hmi_service_type, + Common_ServiceEvent::REQUEST_REJECTED, + UpdateReasonOptional(UpdateReasonOptional::EMPTY)); + } + case ServiceStatus::PTU_FAILED: { + auto update_reason = Common_ServiceStatusUpdateReason::PTU_FAILED; + return listener_->ProcessServiceStatusUpdate( + connection_key, + hmi_service_type, + Common_ServiceEvent::REQUEST_REJECTED, + update_reason); + } + case ServiceStatus::CERT_INVALID: { + auto update_reason = Common_ServiceStatusUpdateReason::INVALID_CERT; + return listener_->ProcessServiceStatusUpdate( + connection_key, + hmi_service_type, + Common_ServiceEvent::REQUEST_REJECTED, + update_reason); + } + case ServiceStatus::INVALID_TIME: { + auto update_reason = Common_ServiceStatusUpdateReason::INVALID_TIME; + return listener_->ProcessServiceStatusUpdate( + connection_key, + hmi_service_type, + Common_ServiceEvent::REQUEST_REJECTED, + update_reason); + } + case ServiceStatus::PROTECTION_ENFORCED: { + auto update_reason = + Common_ServiceStatusUpdateReason::PROTECTION_ENFORCED; + return listener_->ProcessServiceStatusUpdate( + connection_key, + hmi_service_type, + Common_ServiceEvent::REQUEST_REJECTED, + update_reason); + } + case ServiceStatus::PROTECTION_DISABLED: { + auto update_reason = + Common_ServiceStatusUpdateReason::PROTECTION_DISABLED; + return listener_->ProcessServiceStatusUpdate( + connection_key, + hmi_service_type, + Common_ServiceEvent::REQUEST_ACCEPTED, + update_reason); + } + case ServiceStatus::UNSECURE_START_FAILED: { + auto update_reason = + Common_ServiceStatusUpdateReason::PROTECTION_DISABLED; + return listener_->ProcessServiceStatusUpdate( + connection_key, + hmi_service_type, + Common_ServiceEvent::REQUEST_REJECTED, + update_reason); + } + default: { + LOG4CXX_WARN(logger_, + "Received unknown ServiceStatus: " + << static_cast(service_status)); + return; + } + } +} +} // namespace protocol_handler diff --git a/src/components/protocol_handler/test/include/protocol_handler/control_message_matcher.h b/src/components/protocol_handler/test/include/protocol_handler/control_message_matcher.h index 8f68003adaf..a099cff2253 100644 --- a/src/components/protocol_handler/test/include/protocol_handler/control_message_matcher.h +++ b/src/components/protocol_handler/test/include/protocol_handler/control_message_matcher.h @@ -32,10 +32,10 @@ #ifndef SRC_COMPONENTS_PROTOCOL_HANDLER_TEST_INCLUDE_PROTOCOL_HANDLER_CONTROL_MESSAGE_MATCHER_H_ #define SRC_COMPONENTS_PROTOCOL_HANDLER_TEST_INCLUDE_PROTOCOL_HANDLER_CONTROL_MESSAGE_MATCHER_H_ -#include "gmock/gmock.h" #include #include #include +#include "gmock/gmock.h" #include "protocol/raw_message.h" #include "protocol_handler/protocol_packet.h" @@ -43,11 +43,11 @@ namespace test { namespace components { namespace protocol_handler_test { +using protocol_handler::FRAME_DATA_START_SERVICE_NACK; +using protocol_handler::FRAME_TYPE_CONTROL; using protocol_handler::ProtocolPacket; using protocol_handler::RawMessagePtr; using protocol_handler::RESULT_CODE; -using protocol_handler::FRAME_TYPE_CONTROL; -using protocol_handler::FRAME_DATA_START_SERVICE_NACK; bool CheckRegularMatches(const ProtocolPacket& packet, RESULT_CODE result, diff --git a/src/components/protocol_handler/test/include/protocol_handler/mock_service_status_update_handler_listener.h b/src/components/protocol_handler/test/include/protocol_handler/mock_service_status_update_handler_listener.h new file mode 100644 index 00000000000..ccbfeb84388 --- /dev/null +++ b/src/components/protocol_handler/test/include/protocol_handler/mock_service_status_update_handler_listener.h @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2019, 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_PROTOCOL_HANDLER_TEST_INCLUDE_MOCK_SERVICE_STATUS_UPDATE_HANDLER_LISTENER_H +#define SRC_COMPONENTS_PROTOCOL_HANDLER_TEST_INCLUDE_MOCK_SERVICE_STATUS_UPDATE_HANDLER_LISTENER_H + +#include "gmock/gmock.h" +#include "protocol_handler/service_status_update_handler_listener.h" + +namespace test { +namespace components { +namespace protocol_handler_test { + +class MockServiceStatusUpdateHandlerListener + : public protocol_handler::ServiceStatusUpdateHandlerListener { + public: + MOCK_METHOD4( + ProcessServiceStatusUpdate, + void(const uint32_t, + hmi_apis::Common_ServiceType::eType, + hmi_apis::Common_ServiceEvent::eType, + utils::Optional)); +}; +} // namespace protocol_handler_test +} // namespace components +} // namespace test + +#endif // SRC_COMPONENTS_PROTOCOL_HANDLER_TEST_INCLUDE_MOCK_SERVICE_STATUS_UPDATE_HANDLER_LISTENER_H diff --git a/src/components/protocol_handler/test/incoming_data_handler_test.cc b/src/components/protocol_handler/test/incoming_data_handler_test.cc index 9abf5d69af6..a187fe6cb5c 100644 --- a/src/components/protocol_handler/test/incoming_data_handler_test.cc +++ b/src/components/protocol_handler/test/incoming_data_handler_test.cc @@ -30,11 +30,11 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include -#include #include +#include -#include "utils/macro.h" #include "protocol_handler/incoming_data_handler.h" +#include "utils/macro.h" namespace test { namespace components { @@ -68,8 +68,10 @@ class IncomingDataHandlerTest : public ::testing::Test { void ProcessData(transport_manager::ConnectionUID uid, const uint8_t* const data, const uint32_t data_size) { - actual_frames = data_handler.ProcessData( - RawMessage(uid, 0, data, data_size), &result_code, &malformed_occurs); + actual_frames = + data_handler.ProcessData(RawMessage(uid, 0, data, data_size, false), + &result_code, + &malformed_occurs); } void AppendPacketToTMData(const ProtocolPacket& packet) { @@ -91,7 +93,7 @@ class IncomingDataHandlerTest : public ::testing::Test { FrameList actual_frames; RESULT_CODE result_code; size_t malformed_occurs; - uint8_t* some_data, *some_data2; + uint8_t *some_data, *some_data2; size_t some_data_size, some_data2_size; uint32_t protov1_message_id; uint32_t some_message_id; @@ -117,15 +119,17 @@ TEST_F(IncomingDataHandlerTest, NullData) { TEST_F(IncomingDataHandlerTest, DataForUnknownConnection) { size_t malformed_count = 0; - actual_frames = data_handler.ProcessData( - RawMessage(uid_unknown, 0, NULL, 0), &result_code, &malformed_count); + actual_frames = + data_handler.ProcessData(RawMessage(uid_unknown, 0, NULL, 0, false), + &result_code, + &malformed_count); EXPECT_EQ(RESULT_FAIL, result_code); EXPECT_EQ(malformed_count, 0u); EXPECT_TRUE(actual_frames.empty()); AppendPacketToTMData(ProtocolPacket()); actual_frames = data_handler.ProcessData( - RawMessage(uid_unknown, 0, tm_data.data(), tm_data.size()), + RawMessage(uid_unknown, 0, tm_data.data(), tm_data.size(), false), &result_code, &malformed_count); EXPECT_EQ(RESULT_FAIL, result_code); @@ -251,8 +255,8 @@ TEST_F(IncomingDataHandlerTest, MixedPayloadData_TwoConnections) { it != actual_frames.end(); ++it, ++it_exp) { // TODO(EZamakhov): investigate valgrind warning (unitialized value) - EXPECT_EQ(**it, **it_exp) << "Element number " - << std::distance(mobile_packets.begin(), it_exp); + EXPECT_EQ(**it, **it_exp) + << "Element number " << std::distance(mobile_packets.begin(), it_exp); } } @@ -654,8 +658,8 @@ TEST_F(IncomingDataHandlerTest, MalformedPacket_AdditionalByte) { it != actual_frames.end(); ++it, ++it_exp) { // TODO(EZamakhov): investigate valgrind warning (unitialized value) - EXPECT_EQ(**it, **it_exp) << "Element number " - << std::distance(mobile_packets.begin(), it_exp); + EXPECT_EQ(**it, **it_exp) + << "Element number " << std::distance(mobile_packets.begin(), it_exp); } } @@ -754,8 +758,8 @@ TEST_F(IncomingDataHandlerTest, MalformedPacket_Mix) { it != actual_frames.end(); ++it, ++it_exp) { // TODO(EZamakhov): investigate valgrind warning (unitialized value) - EXPECT_EQ(**it, **it_exp) << "Element number " - << std::distance(mobile_packets.begin(), it_exp); + EXPECT_EQ(**it, **it_exp) + << "Element number " << std::distance(mobile_packets.begin(), it_exp); } } diff --git a/src/components/protocol_handler/test/multiframe_builder_test.cc b/src/components/protocol_handler/test/multiframe_builder_test.cc index f919ec92af1..2859aeb8aed 100644 --- a/src/components/protocol_handler/test/multiframe_builder_test.cc +++ b/src/components/protocol_handler/test/multiframe_builder_test.cc @@ -29,12 +29,12 @@ * 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 -#include #include -#include #include +#include +#include +#include +#include "gtest/gtest.h" #include "protocol_handler/multiframe_builder.h" diff --git a/src/components/protocol_handler/test/protocol_handler_tm_test.cc b/src/components/protocol_handler/test/protocol_handler_tm_test.cc index e1149fefb2b..07b562f3a2b 100644 --- a/src/components/protocol_handler/test/protocol_handler_tm_test.cc +++ b/src/components/protocol_handler/test/protocol_handler_tm_test.cc @@ -39,6 +39,7 @@ #include "protocol_handler/mock_protocol_handler.h" #include "protocol_handler/mock_protocol_handler_settings.h" #include "protocol_handler/mock_protocol_observer.h" +#include "protocol_handler/mock_service_status_update_handler_listener.h" #include "protocol_handler/mock_session_observer.h" #include "protocol_handler/protocol_handler.h" #include "protocol_handler/protocol_handler_impl.h" @@ -108,6 +109,7 @@ using protocol_handler::PROTOCOL_VERSION_MAX; using protocol_handler::ProtocolHandlerImpl; using protocol_handler::RawMessage; using protocol_handler::RawMessagePtr; +using protocol_handler::ServiceStatusUpdateHandler; using protocol_handler::ServiceType; // For TM states using test::components::security_manager_test::MockSystemTimeHandler; @@ -139,6 +141,9 @@ using ::testing::SetArgPointee; using ::testing::SetArgReferee; typedef std::vector UCharDataVector; +typedef std::shared_ptr< + testing::NiceMock > + MockServiceStatusUpdateHandlerListenerPtr; // custom action to call a member function with 6 arguments ACTION_P4(InvokeMemberFuncWithArg2, ptr, memberFunc, a, b) { @@ -186,10 +191,17 @@ class ProtocolHandlerImplTest : public ::testing::Test { session_observer_mock, connection_handler_mock, transport_manager_mock)); + std::unique_ptr service_status_update_handler_( + new ServiceStatusUpdateHandler( + &(*mock_service_status_update_handler_listener_))); + protocol_handler_impl->set_service_status_update_handler( + std::move(service_status_update_handler_)); tm_listener = protocol_handler_impl.get(); } void SetUp() OVERRIDE { + mock_service_status_update_handler_listener_ = std::make_shared< + testing::NiceMock >(); InitProtocolHandlerImpl(0u, 0u); connection_id = 0xAu; session_id = 0xFFu; @@ -214,9 +226,11 @@ class ProtocolHandlerImplTest : public ::testing::Test { void TearDown() OVERRIDE { const_cast( - protocol_handler_impl->get_from_mobile_queue()).WaitDumpQueue(); + protocol_handler_impl->get_from_mobile_queue()) + .WaitDumpQueue(); const_cast( - protocol_handler_impl->get_to_mobile_queue()).WaitDumpQueue(); + protocol_handler_impl->get_to_mobile_queue()) + .WaitDumpQueue(); } // Emulate connection establish @@ -388,6 +402,8 @@ class ProtocolHandlerImplTest : public ::testing::Test { testing::NiceMock protocol_handler_settings_mock; std::shared_ptr protocol_handler_impl; + MockServiceStatusUpdateHandlerListenerPtr + mock_service_status_update_handler_listener_; TransportManagerListener* tm_listener; // Uniq connection ::transport_manager::ConnectionUID connection_id; @@ -730,13 +746,12 @@ TEST_F(ProtocolHandlerImplTest, const uint8_t session_id1 = 1u; const ::transport_manager::ConnectionUID connection_id2 = 0xBu; const uint8_t session_id2 = 2u; + EXPECT_CALL(session_observer_mock, KeyFromPair(connection_id2, session_id2)) + .WillRepeatedly(Return(connection_key)); #ifdef ENABLE_SECURITY AddSecurityManager(); - EXPECT_CALL(session_observer_mock, KeyFromPair(connection_id2, session_id2)) - .WillOnce(Return(connection_key)); - EXPECT_CALL(session_observer_mock, GetSSLContext(connection_key, start_service)) .Times(2) @@ -1414,7 +1429,7 @@ TEST_F(ProtocolHandlerImplTest, services.push_back(0x0A); services.push_back(0x0B); EXPECT_CALL(protocol_handler_settings_mock, force_protected_service()) - .WillOnce(ReturnRefOfCopy(services)); + .WillRepeatedly(ReturnRefOfCopy(services)); // call new SSLContext creation EXPECT_CALL(security_manager_mock, CreateSSLContext(connection_key, _)) @@ -3638,7 +3653,8 @@ TEST_F(ProtocolHandlerImplTest, SendMessageToDevice(ExpectedMessage(FRAME_TYPE_CONTROL, FRAME_DATA_HEART_BEAT_ACK, PROTECTION_OFF, - kControl))).Times(0); + kControl))) + .Times(0); // Act SendControlMessage( PROTECTION_OFF, kControl, session_id, FRAME_DATA_HEART_BEAT); @@ -3659,8 +3675,12 @@ TEST_F(ProtocolHandlerImplTest, const bool is_final = true; const uint32_t total_data_size = 1; UCharDataVector data(total_data_size); - RawMessagePtr message = std::make_shared( - connection_key, PROTOCOL_VERSION_3, &data[0], total_data_size, kControl); + RawMessagePtr message = std::make_shared(connection_key, + PROTOCOL_VERSION_3, + &data[0], + total_data_size, + false, + kControl); // Expect getting pair from key from session observer EXPECT_CALL(session_observer_mock, PairFromKey(message->connection_key(), _, _)) @@ -3681,7 +3701,7 @@ TEST_F(ProtocolHandlerImplTest, times++; // Act - protocol_handler_impl->SendMessageToMobileApp(message, is_final); + protocol_handler_impl->SendMessageToMobileApp(message, false, is_final); EXPECT_TRUE(waiter->WaitFor(times, kAsyncExpectationsTimeout)); } @@ -3697,8 +3717,12 @@ TEST_F(ProtocolHandlerImplTest, const bool is_final = true; const uint32_t total_data_size = 1; UCharDataVector data(total_data_size); - RawMessagePtr message = std::make_shared( - connection_key, PROTOCOL_VERSION_3, &data[0], total_data_size, kRpc); + RawMessagePtr message = std::make_shared(connection_key, + PROTOCOL_VERSION_3, + &data[0], + total_data_size, + false, + kRpc); // Expect getting pair from key from session observer EXPECT_CALL(session_observer_mock, PairFromKey(message->connection_key(), _, _)) @@ -3724,7 +3748,7 @@ TEST_F(ProtocolHandlerImplTest, times++; // Act - protocol_handler_impl->SendMessageToMobileApp(message, is_final); + protocol_handler_impl->SendMessageToMobileApp(message, false, is_final); EXPECT_TRUE(waiter->WaitFor(times, kAsyncExpectationsTimeout)); } @@ -3740,8 +3764,12 @@ TEST_F(ProtocolHandlerImplTest, SendMessageToMobileApp_SendMultiframeMessage) { const uint32_t total_data_size = MAXIMUM_FRAME_DATA_V2_SIZE * 2; UCharDataVector data(total_data_size); const uint8_t first_consecutive_frame = 0x01; - RawMessagePtr message = std::make_shared( - connection_key, PROTOCOL_VERSION_3, &data[0], total_data_size, kBulk); + RawMessagePtr message = std::make_shared(connection_key, + PROTOCOL_VERSION_3, + &data[0], + total_data_size, + false, + kBulk); // Expect getting pair from key from session observer EXPECT_CALL(session_observer_mock, PairFromKey(message->connection_key(), _, _)) @@ -3779,7 +3807,7 @@ TEST_F(ProtocolHandlerImplTest, SendMessageToMobileApp_SendMultiframeMessage) { times++; // Act - protocol_handler_impl->SendMessageToMobileApp(message, is_final); + protocol_handler_impl->SendMessageToMobileApp(message, false, is_final); EXPECT_TRUE(waiter->WaitFor(times, kAsyncExpectationsTimeout)); } @@ -3828,7 +3856,8 @@ TEST_F(ProtocolHandlerImplTest, SendServiceDataAck_AfterVersion5) { SendMessageToDevice(ExpectedMessage(FRAME_TYPE_CONTROL, FRAME_DATA_SERVICE_DATA_ACK, PROTECTION_OFF, - kMobileNav))).Times(0); + kMobileNav))) + .Times(0); protocol_handler_impl->SendFramesNumber(connection_key, 0); diff --git a/src/components/protocol_handler/test/protocol_header_validator_test.cc b/src/components/protocol_handler/test/protocol_header_validator_test.cc index 5554bfd2807..e69e44dbacc 100644 --- a/src/components/protocol_handler/test/protocol_header_validator_test.cc +++ b/src/components/protocol_handler/test/protocol_header_validator_test.cc @@ -31,11 +31,11 @@ */ #include -#include #include +#include -#include "utils/macro.h" #include "protocol_handler/protocol_packet.h" +#include "utils/macro.h" namespace { const size_t MAXIMUM_FRAME_DATA_V3_SIZE = 131072; diff --git a/src/components/protocol_handler/test/protocol_packet_test.cc b/src/components/protocol_handler/test/protocol_packet_test.cc index 71c77262434..e4ea4be61f2 100644 --- a/src/components/protocol_handler/test/protocol_packet_test.cc +++ b/src/components/protocol_handler/test/protocol_packet_test.cc @@ -30,42 +30,42 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include "gtest/gtest.h" #include +#include "gtest/gtest.h" -#include "utils/macro.h" -#include "protocol_handler/protocol_packet.h" #include "protocol/common.h" +#include "protocol_handler/protocol_packet.h" +#include "utils/macro.h" namespace test { namespace components { namespace protocol_handler_test { -using protocol_handler::RawMessagePtr; -using protocol_handler::ProtocolPacket; using protocol_handler::ConnectionID; -using protocol_handler::FRAME_TYPE_MAX_VALUE; using protocol_handler::FRAME_DATA_FIRST; -using protocol_handler::FRAME_TYPE_FIRST; -using protocol_handler::PROTOCOL_VERSION_1; -using protocol_handler::PROTOCOL_VERSION_3; -using protocol_handler::PROTECTION_OFF; -using protocol_handler::RESULT_CODE; -using protocol_handler::RESULT_OK; -using protocol_handler::RESULT_FAIL; +using protocol_handler::FRAME_DATA_HEART_BEAT; +using protocol_handler::FRAME_DATA_LAST_CONSECUTIVE; +using protocol_handler::FRAME_DATA_START_SERVICE_ACK; using protocol_handler::FRAME_TYPE_CONTROL; -using protocol_handler::kControl; -using protocol_handler::kRpc; +using protocol_handler::FRAME_TYPE_FIRST; +using protocol_handler::FRAME_TYPE_MAX_VALUE; using protocol_handler::kAudio; -using protocol_handler::kMobileNav; using protocol_handler::kBulk; +using protocol_handler::kControl; using protocol_handler::kInvalidServiceType; -using protocol_handler::FRAME_DATA_HEART_BEAT; -using protocol_handler::FRAME_DATA_START_SERVICE_ACK; -using protocol_handler::FRAME_DATA_LAST_CONSECUTIVE; +using protocol_handler::kMobileNav; +using protocol_handler::kRpc; +using protocol_handler::PROTECTION_OFF; using protocol_handler::PROTOCOL_HEADER_V1_SIZE; using protocol_handler::PROTOCOL_HEADER_V2_SIZE; +using protocol_handler::PROTOCOL_VERSION_1; +using protocol_handler::PROTOCOL_VERSION_3; using protocol_handler::PROTOCOL_VERSION_MAX; +using protocol_handler::ProtocolPacket; +using protocol_handler::RawMessagePtr; +using protocol_handler::RESULT_CODE; +using protocol_handler::RESULT_FAIL; +using protocol_handler::RESULT_OK; class ProtocolPacketTest : public ::testing::Test { protected: diff --git a/src/components/protocol_handler/test/protocol_payload_test.cc b/src/components/protocol_handler/test/protocol_payload_test.cc index e56f8aadff2..e89e6c73957 100644 --- a/src/components/protocol_handler/test/protocol_payload_test.cc +++ b/src/components/protocol_handler/test/protocol_payload_test.cc @@ -33,10 +33,10 @@ #include #include -#include "utils/macro.h" -#include "utils/bitstream.h" -#include "protocol_handler/protocol_payload.h" #include "protocol/common.h" +#include "protocol_handler/protocol_payload.h" +#include "utils/bitstream.h" +#include "utils/macro.h" namespace test { namespace components { diff --git a/src/components/protocol_handler/test/service_status_update_handler_test.cc b/src/components/protocol_handler/test/service_status_update_handler_test.cc new file mode 100644 index 00000000000..7d4516a7ffa --- /dev/null +++ b/src/components/protocol_handler/test/service_status_update_handler_test.cc @@ -0,0 +1,225 @@ +/* + * Copyright (c) 2019, 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 "protocol_handler/service_status_update_handler.h" +#include "gtest/gtest.h" +#include "protocol_handler/mock_service_status_update_handler_listener.h" + +namespace test { +namespace components { +namespace protocol_handler_test { + +namespace { +const uint32_t kConnectionKey = 123u; +} + +using namespace protocol_handler; +using ::testing::_; +using ::testing::Return; +using namespace hmi_apis; +typedef utils::Optional + UpdateReasonOptional; +typedef std::shared_ptr + ServiceStatusUpdateHandlerPtr; +typedef std::shared_ptr + MockServiceStatusUpdateHandlerListenerPtr; + +struct ServiceUpdate { + ServiceType service_type_; + ServiceStatus service_status_; + ServiceUpdate(ServiceType type, ServiceStatus status) + : service_type_(type), service_status_(status) {} +}; + +class ServiceStatusUpdateHandlerTest + : public ::testing::TestWithParam { + public: + ServiceStatusUpdateHandlerTest() { + mock_service_status_update_handler_listener_.reset( + new MockServiceStatusUpdateHandlerListener); + service_status_update_handler_ = + std::make_shared( + &(*mock_service_status_update_handler_listener_)); + } + + Common_ServiceEvent::eType GetServiceEvent(ServiceStatus status) { + switch (status) { + case ServiceStatus::SERVICE_ACCEPTED: + case ServiceStatus::PROTECTION_DISABLED: { + return Common_ServiceEvent::REQUEST_ACCEPTED; + } + case ServiceStatus::SERVICE_RECEIVED: { + return Common_ServiceEvent::REQUEST_RECEIVED; + } + case ServiceStatus::SERVICE_START_FAILED: + case ServiceStatus::PTU_FAILED: + case ServiceStatus::CERT_INVALID: + case ServiceStatus::INVALID_TIME: + case ServiceStatus::PROTECTION_ENFORCED: { + return Common_ServiceEvent::REQUEST_REJECTED; + } + default: { return Common_ServiceEvent::INVALID_ENUM; } + } + } + + UpdateReasonOptional GetUpdateReason(ServiceStatus status) { + switch (status) { + case ServiceStatus::SERVICE_START_FAILED: + case ServiceStatus::SERVICE_ACCEPTED: + case ServiceStatus::SERVICE_RECEIVED: { + return UpdateReasonOptional::EMPTY; + } + case ServiceStatus::PTU_FAILED: { + auto reason = Common_ServiceStatusUpdateReason::PTU_FAILED; + return reason; + } + case ServiceStatus::CERT_INVALID: { + auto reason = Common_ServiceStatusUpdateReason::INVALID_CERT; + return reason; + } + case ServiceStatus::INVALID_TIME: { + auto reason = Common_ServiceStatusUpdateReason::INVALID_TIME; + return reason; + } + case ServiceStatus::PROTECTION_ENFORCED: { + auto reason = Common_ServiceStatusUpdateReason::PROTECTION_ENFORCED; + return reason; + } + case ServiceStatus::PROTECTION_DISABLED: { + auto reason = Common_ServiceStatusUpdateReason::PROTECTION_DISABLED; + return reason; + } + default: { + auto reason = Common_ServiceStatusUpdateReason::INVALID_ENUM; + return reason; + } + } + } + + public: + MockServiceStatusUpdateHandlerListenerPtr + mock_service_status_update_handler_listener_; + ServiceStatusUpdateHandlerPtr service_status_update_handler_; +}; + +INSTANTIATE_TEST_CASE_P( + OnServiceUpdate_SERVICE_ACCEPTED, + ServiceStatusUpdateHandlerTest, + ::testing::Values( + ServiceUpdate(ServiceType::kAudio, ServiceStatus::SERVICE_ACCEPTED), + ServiceUpdate(ServiceType::kMobileNav, ServiceStatus::SERVICE_ACCEPTED), + ServiceUpdate(ServiceType::kRpc, ServiceStatus::SERVICE_ACCEPTED))); + +INSTANTIATE_TEST_CASE_P( + OnServiceUpdate_SERVICE_RECEIVED, + ServiceStatusUpdateHandlerTest, + ::testing::Values( + ServiceUpdate(ServiceType::kAudio, ServiceStatus::SERVICE_RECEIVED), + ServiceUpdate(ServiceType::kMobileNav, ServiceStatus::SERVICE_RECEIVED), + ServiceUpdate(ServiceType::kRpc, ServiceStatus::SERVICE_RECEIVED))); + +INSTANTIATE_TEST_CASE_P( + OnServiceUpdate_SERVICE_START_FAILED, + ServiceStatusUpdateHandlerTest, + ::testing::Values( + ServiceUpdate(ServiceType::kAudio, ServiceStatus::SERVICE_START_FAILED), + ServiceUpdate(ServiceType::kMobileNav, + ServiceStatus::SERVICE_START_FAILED), + ServiceUpdate(ServiceType::kRpc, ServiceStatus::SERVICE_START_FAILED))); + +INSTANTIATE_TEST_CASE_P( + OnServiceUpdate_CERT_INVALID, + ServiceStatusUpdateHandlerTest, + ::testing::Values( + ServiceUpdate(ServiceType::kAudio, ServiceStatus::CERT_INVALID), + ServiceUpdate(ServiceType::kMobileNav, ServiceStatus::CERT_INVALID), + ServiceUpdate(ServiceType::kRpc, ServiceStatus::CERT_INVALID))); + +INSTANTIATE_TEST_CASE_P( + OnServiceUpdate_INVALID_TIME, + ServiceStatusUpdateHandlerTest, + ::testing::Values( + ServiceUpdate(ServiceType::kAudio, ServiceStatus::INVALID_TIME), + ServiceUpdate(ServiceType::kMobileNav, ServiceStatus::INVALID_TIME), + ServiceUpdate(ServiceType::kRpc, ServiceStatus::INVALID_TIME))); + +INSTANTIATE_TEST_CASE_P( + OnServiceUpdate_PTU_FAILED, + ServiceStatusUpdateHandlerTest, + ::testing::Values( + ServiceUpdate(ServiceType::kAudio, ServiceStatus::PTU_FAILED), + ServiceUpdate(ServiceType::kMobileNav, ServiceStatus::PTU_FAILED), + ServiceUpdate(ServiceType::kRpc, ServiceStatus::PTU_FAILED))); + +INSTANTIATE_TEST_CASE_P( + OnServiceUpdate_PROTECTION_ENFRORCED, + ServiceStatusUpdateHandlerTest, + ::testing::Values( + ServiceUpdate(ServiceType::kAudio, ServiceStatus::PROTECTION_ENFORCED), + ServiceUpdate(ServiceType::kMobileNav, + ServiceStatus::PROTECTION_ENFORCED), + ServiceUpdate(ServiceType::kRpc, ServiceStatus::PROTECTION_ENFORCED))); + +INSTANTIATE_TEST_CASE_P( + OnServiceUpdate_PROTECTION_DISABLED, + ServiceStatusUpdateHandlerTest, + ::testing::Values( + ServiceUpdate(ServiceType::kAudio, ServiceStatus::PROTECTION_DISABLED), + ServiceUpdate(ServiceType::kMobileNav, + ServiceStatus::PROTECTION_DISABLED), + ServiceUpdate(ServiceType::kRpc, ServiceStatus::PROTECTION_DISABLED))); + +TEST_P(ServiceStatusUpdateHandlerTest, OnServiceUpdate) { + auto service_event_ = GetServiceEvent(GetParam().service_status_); + auto reason_ = GetUpdateReason(GetParam().service_status_); + + EXPECT_CALL( + *mock_service_status_update_handler_listener_, + ProcessServiceStatusUpdate(kConnectionKey, _, service_event_, reason_)) + .Times(1); + + service_status_update_handler_->OnServiceUpdate( + kConnectionKey, GetParam().service_type_, GetParam().service_status_); +} + +TEST_F(ServiceStatusUpdateHandlerTest, GetHMIServiceType) { + EXPECT_EQ(Common_ServiceType::RPC, GetHMIServiceType(ServiceType::kRpc)); + EXPECT_EQ(Common_ServiceType::AUDIO, GetHMIServiceType(ServiceType::kAudio)); + EXPECT_EQ(Common_ServiceType::VIDEO, + GetHMIServiceType(ServiceType::kMobileNav)); + EXPECT_EQ(Common_ServiceType::INVALID_ENUM, + GetHMIServiceType(ServiceType::kInvalidServiceType)); +} + +} // namespace protocol_handler_test +} // namespace components +} // namespace test diff --git a/src/components/resumption/src/last_state_impl.cc b/src/components/resumption/src/last_state_impl.cc index 4d3fd1526c3..564266e19c0 100644 --- a/src/components/resumption/src/last_state_impl.cc +++ b/src/components/resumption/src/last_state_impl.cc @@ -78,4 +78,4 @@ void LastStateImpl::LoadStateFromFileSystem() { LOG4CXX_WARN(logger_, "No valid last state was found."); } -} // resumption +} // namespace resumption diff --git a/src/components/rpc_base/include/rpc_base/rpc_base.h b/src/components/rpc_base/include/rpc_base/rpc_base.h index 10b494465ce..6e06d61a7c3 100644 --- a/src/components/rpc_base/include/rpc_base/rpc_base.h +++ b/src/components/rpc_base/include/rpc_base/rpc_base.h @@ -57,7 +57,7 @@ const std::string omitted_validation_info = "should be omitted in "; const std::string required_validation_info = "is required in "; std::string PolicyTableTypeToString(const PolicyTableType pt_type); -} +} // namespace policy_table_interface_base template class Range; @@ -172,6 +172,7 @@ class Boolean : public PrimitiveType { Boolean& operator=(bool new_val); operator bool() const; Json::Value ToJsonValue() const; + bool operator==(const Boolean& that); private: // Fields @@ -233,6 +234,9 @@ class String : public PrimitiveType { String& operator=(const std::string& new_val); String& operator=(const String& new_val); bool operator==(const String& rhs) const; + bool operator==(const std::string& rhs) const; + bool operator!=(const String& rhs) const; + bool operator!=(const std::string& rhs) const; operator const std::string&() const; Json::Value ToJsonValue() const; @@ -282,6 +286,7 @@ class Array : public std::vector, public CompositeType { template void push_back(const U& value); Json::Value ToJsonValue() const; + bool operator==(const Array& that); virtual bool is_valid() const; bool is_initialized() const; @@ -395,6 +400,8 @@ class Optional { // casted to integral types operator const void*() const; + bool operator==(const Optional& that); + bool is_valid() const; bool is_initialized() const; void ReportErrors(ValidationReport* report) const; diff --git a/src/components/rpc_base/include/rpc_base/rpc_base_inl.h b/src/components/rpc_base/include/rpc_base/rpc_base_inl.h index b6b47c2ed88..a7b477c0099 100644 --- a/src/components/rpc_base/include/rpc_base/rpc_base_inl.h +++ b/src/components/rpc_base/include/rpc_base/rpc_base_inl.h @@ -46,8 +46,7 @@ namespace rpc { * Range helper class */ template -Range::Range(T min, T max) - : min_(min), max_(max) {} +Range::Range(T min, T max) : min_(min), max_(max) {} template T Range::min() const { @@ -139,6 +138,10 @@ inline Boolean::Boolean() : PrimitiveType(kUninitialized), value_(false) {} inline Boolean::Boolean(bool value) : PrimitiveType(kValid), value_(value) {} +inline bool Boolean::operator==(const Boolean& that) { + return value_ == that.value_; +} + inline Boolean& Boolean::operator=(bool new_val) { value_ = new_val; value_state_ = kValid; @@ -186,12 +189,14 @@ Integer& Integer::operator=( template Integer& Integer::operator++() { ++value_; + value_state_ = range_.Includes(value_) ? kValid : kInvalid; return *this; } template Integer& Integer::operator+=(int value) { value_ += value; + value_state_ = range_.Includes(value_) ? kValid : kInvalid; return *this; } @@ -236,8 +241,7 @@ template const Range String::length_range_(minlen, maxlen); template -String::String() - : PrimitiveType(kUninitialized) {} +String::String() : PrimitiveType(kUninitialized) {} template String::String(const std::string& value) @@ -279,6 +283,21 @@ bool String::operator==(const String& rhs) const { return value_ == rhs.value_; } +template +bool String::operator==(const std::string& rhs) const { + return value_ == rhs; +} + +template +bool String::operator!=(const String& rhs) const { + return value_ != rhs.value_; +} + +template +bool String::operator!=(const std::string& rhs) const { + return value_ != rhs; +} + template String::operator const std::string&() const { return value_; @@ -288,8 +307,7 @@ String::operator const std::string&() const { * Enum class */ template -Enum::Enum() - : PrimitiveType(kUninitialized), value_(EnumType()) {} +Enum::Enum() : PrimitiveType(kUninitialized), value_(EnumType()) {} template Enum::Enum(EnumType value) @@ -311,8 +329,7 @@ Enum::operator EnumType() const { * Array class */ template -Array::Array() - : CompositeType(kUninitialized) {} +Array::Array() : CompositeType(kUninitialized) {} template template @@ -366,6 +383,20 @@ bool Array::is_initialized() const { return false; } +template +bool Array::operator==(const Array& that) { + if (this->size() != that.size()) + return false; + + for (auto i = std::begin(*this), j = std::begin(that); i != std::end(*this); + ++i, ++j) { + if (!(*i == *j)) { + return false; + } + } + return true; +} + template void Array::ReportErrors(ValidationReport* report) const { if (this->empty()) { @@ -401,13 +432,11 @@ void Array::SetPolicyTableType( * Map class */ template -Map::Map() - : CompositeType(kUninitialized) {} +Map::Map() : CompositeType(kUninitialized) {} template template -Map::Map(const U& value) - : CompositeType(kUninitialized) { +Map::Map(const U& value) : CompositeType(kUninitialized) { for (typename U::const_iterator i = value.begin(), e = value.end(); i != e; ++i) { // Explicitly convert that value to T because all rpc_types have explicit @@ -499,13 +528,11 @@ void Map::SetPolicyTableType( * Nullable class */ template -Nullable::Nullable() - : marked_null_(false) {} +Nullable::Nullable() : marked_null_(false) {} template template -Nullable::Nullable(const U& value) - : T(value), marked_null_(false) {} +Nullable::Nullable(const U& value) : T(value), marked_null_(false) {} template template @@ -576,6 +603,11 @@ const T* Optional::operator->() const { return &value_; } +template +bool Optional::operator==(const Optional& that) { + return value_ == that.value_; +} + template void Optional::assign_if_valid(const Optional& value) { if (value.is_initialized()) { @@ -623,8 +655,7 @@ void rpc::Optional::SetPolicyTableType( * Stringifyable class */ template -Stringifyable::Stringifyable() - : predefined_string_("") {} +Stringifyable::Stringifyable() : predefined_string_("") {} template template diff --git a/src/components/rpc_base/include/rpc_base/rpc_base_json_inl.h b/src/components/rpc_base/include/rpc_base/rpc_base_json_inl.h index 960ca10e21c..80e11994f14 100644 --- a/src/components/rpc_base/include/rpc_base/rpc_base_json_inl.h +++ b/src/components/rpc_base/include/rpc_base/rpc_base_json_inl.h @@ -33,8 +33,8 @@ #ifndef SRC_COMPONENTS_RPC_BASE_INCLUDE_RPC_BASE_RPC_BASE_JSON_INL_H_ #define SRC_COMPONENTS_RPC_BASE_INCLUDE_RPC_BASE_RPC_BASE_JSON_INL_H_ -#include "rpc_base/rpc_base.h" #include "json/value.h" +#include "rpc_base/rpc_base.h" namespace rpc { @@ -164,7 +164,7 @@ Json::Value Integer::ToJsonValue() const { template Float::Float(const Json::Value* value) - : PrimitiveType(InitHelper(value, &Json::Value::isDouble)), value_() { + : PrimitiveType(InitHelper(value, &Json::Value::isNumeric)), value_() { if (is_valid()) { value_ = value->asDouble(); value_state_ = range_.Includes(value_) ? kValid : kInvalid; @@ -174,7 +174,7 @@ Float::Float(const Json::Value* value) template Float::Float(const Json::Value* value, double def_value) - : PrimitiveType(InitHelper(value, &Json::Value::isDouble)) + : PrimitiveType(InitHelper(value, &Json::Value::isNumeric)) , value_(def_value) { if (!is_initialized()) { value_state_ = kValid; diff --git a/src/components/rpc_base/test/rpc_base_test.cc b/src/components/rpc_base/test/rpc_base_test.cc index d81e01db6c0..dc0a1df128d 100644 --- a/src/components/rpc_base/test/rpc_base_test.cc +++ b/src/components/rpc_base/test/rpc_base_test.cc @@ -30,10 +30,10 @@ * POSSIBILITY OF SUCH DAMAGE. */ +#include "rpc_base/rpc_base.h" #include "gtest/gtest.h" #include "json/writer.h" #include "rpc_base/gtest_support.h" -#include "rpc_base/rpc_base.h" namespace test { namespace components { diff --git a/src/components/rpc_base/test/validation_report_test.cc b/src/components/rpc_base/test/validation_report_test.cc index 10effe7dd22..5d3785d6cb6 100644 --- a/src/components/rpc_base/test/validation_report_test.cc +++ b/src/components/rpc_base/test/validation_report_test.cc @@ -30,9 +30,9 @@ * POSSIBILITY OF SUCH DAMAGE. */ +#include "rpc_base/validation_report.h" #include #include "gtest/gtest.h" -#include "rpc_base/validation_report.h" namespace test { namespace components { diff --git a/src/components/security_manager/include/security_manager/crypto_manager_impl.h b/src/components/security_manager/include/security_manager/crypto_manager_impl.h index 5fd7a951553..46fd1a5995c 100644 --- a/src/components/security_manager/include/security_manager/crypto_manager_impl.h +++ b/src/components/security_manager/include/security_manager/crypto_manager_impl.h @@ -33,19 +33,19 @@ #ifndef SRC_COMPONENTS_SECURITY_MANAGER_INCLUDE_SECURITY_MANAGER_CRYPTO_MANAGER_IMPL_H_ #define SRC_COMPONENTS_SECURITY_MANAGER_INCLUDE_SECURITY_MANAGER_CRYPTO_MANAGER_IMPL_H_ -#include #include -#include #include -#include +#include +#include #include +#include #include "security_manager/crypto_manager.h" -#include "security_manager/ssl_context.h" #include "security_manager/security_manager_settings.h" +#include "security_manager/ssl_context.h" -#include "utils/macro.h" #include "utils/lock.h" +#include "utils/macro.h" namespace security_manager { class CryptoManagerImpl : public CryptoManager { diff --git a/src/components/security_manager/include/security_manager/crypto_manager_settings_impl.h b/src/components/security_manager/include/security_manager/crypto_manager_settings_impl.h index f20d3e40349..47cc557976b 100644 --- a/src/components/security_manager/include/security_manager/crypto_manager_settings_impl.h +++ b/src/components/security_manager/include/security_manager/crypto_manager_settings_impl.h @@ -1,8 +1,8 @@ #ifndef SRC_COMPONENTS_SECURITY_MANAGER_INCLUDE_SECURITY_MANAGER_CRYPTO_MANAGER_SETTINGS_IMPL_H_ #define SRC_COMPONENTS_SECURITY_MANAGER_INCLUDE_SECURITY_MANAGER_CRYPTO_MANAGER_SETTINGS_IMPL_H_ -#include "security_manager/security_manager_settings.h" #include "config_profile/profile.h" +#include "security_manager/security_manager_settings.h" namespace security_manager { 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 c53d39ba879..ee00e0774af 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 @@ -34,18 +34,18 @@ #define SRC_COMPONENTS_SECURITY_MANAGER_INCLUDE_SECURITY_MANAGER_SECURITY_MANAGER_IMPL_H_ #include -#include -#include #include +#include +#include #include "utils/macro.h" #include "utils/message_queue.h" #include "utils/threads/message_loop_thread.h" +#include "protocol/common.h" +#include "protocol_handler/protocol_handler.h" #include "security_manager/security_manager.h" #include "security_manager/security_query.h" -#include "protocol_handler/protocol_handler.h" -#include "protocol/common.h" #include "utils/system_time_handler.h" namespace security_manager { @@ -200,7 +200,7 @@ class SecurityManagerImpl : public SecurityManager, /** * @brief Notify all listeners that handshake was failed */ - void NotifyListenersOnHandshakeFailed() OVERRIDE; + void NotifyListenersOnGetSystemTimeFailed() OVERRIDE; /** * @brief Check is policy certificate data is empty @@ -214,6 +214,16 @@ class SecurityManagerImpl : public SecurityManager, */ static const char* ConfigSection(); + void ProcessFailedPTU() OVERRIDE; + +#ifdef EXTERNAL_PROPRIETARY_MODE + /** + * @brief ProcessFailedCertDecrypt is called to notify listeners that + * certificate decryption failed in the external flow + */ + void ProcessFailedCertDecrypt() OVERRIDE; +#endif + private: /** * \brief Sends Handshake binary data to mobile application @@ -280,6 +290,17 @@ class SecurityManagerImpl : public SecurityManager, */ void OnSystemTimeArrived(const time_t utc_time) OVERRIDE; + /** + * @brief OnSystemTimeFailed Notify about system request failure + */ + void OnSystemTimeFailed() OVERRIDE; + + /** + * @brief ResetPendingSystemTimeRequests resets waiting for system time + * requests flag + */ + void ResetPendingSystemTimeRequests(); + // Thread that pumps handshake data SecurityMessageLoop security_messages_; diff --git a/src/components/security_manager/src/crypto_manager_impl.cc b/src/components/security_manager/src/crypto_manager_impl.cc index 90ae0177ec6..cb42d5b46c3 100644 --- a/src/components/security_manager/src/crypto_manager_impl.cc +++ b/src/components/security_manager/src/crypto_manager_impl.cc @@ -33,22 +33,22 @@ #include "security_manager/crypto_manager_impl.h" #include -#include #include #include +#include -#include -#include #include -#include #include +#include +#include +#include #include "security_manager/security_manager.h" -#include "utils/logger.h" #include "utils/atomic.h" +#include "utils/date_time.h" +#include "utils/logger.h" #include "utils/macro.h" #include "utils/scope_guard.h" -#include "utils/date_time.h" #define TLS1_1_MINIMAL_VERSION 0x1000103fL #define CONST_SSL_METHOD_MINIMAL_VERSION 0x00909000L @@ -84,7 +84,7 @@ void free_ctx(SSL_CTX** ctx) { *ctx = NULL; } } -} +} // namespace CryptoManagerImpl::CryptoManagerImpl( const std::shared_ptr set) @@ -156,9 +156,9 @@ bool CryptoManagerImpl::Init() { LOG4CXX_DEBUG(logger_, "Peer verification " << (get_settings().verify_peer() ? "enabled" : "disabled")); - LOG4CXX_DEBUG(logger_, - "CA certificate file is \"" << get_settings().ca_cert_path() - << '"'); + LOG4CXX_DEBUG( + logger_, + "CA certificate file is \"" << get_settings().ca_cert_path() << '"'); #if OPENSSL_VERSION_NUMBER < CONST_SSL_METHOD_MINIMAL_VERSION SSL_METHOD* method; @@ -387,9 +387,9 @@ bool CryptoManagerImpl::SaveCertificateData( UNUSED(cert_guard); if (1 != BIO_reset(bio_cert)) { - LOG4CXX_WARN(logger_, - "Unabled to reset BIO in order to read private key, " - << LastError()); + LOG4CXX_WARN( + logger_, + "Unabled to reset BIO in order to read private key, " << LastError()); } EVP_PKEY* pkey = NULL; diff --git a/src/components/security_manager/src/security_manager_impl.cc b/src/components/security_manager/src/security_manager_impl.cc index 70f835fb933..41e2b07a030 100644 --- a/src/components/security_manager/src/security_manager_impl.cc +++ b/src/components/security_manager/src/security_manager_impl.cc @@ -32,12 +32,12 @@ #include "security_manager/security_manager_impl.h" #include -#include "security_manager/crypto_manager_impl.h" +#include "json/json.h" #include "protocol_handler/protocol_packet.h" -#include "utils/logger.h" +#include "security_manager/crypto_manager_impl.h" #include "utils/byte_order.h" -#include "json/json.h" #include "utils/helpers.h" +#include "utils/logger.h" namespace security_manager { @@ -213,6 +213,13 @@ void SecurityManagerImpl::ResumeHandshake(uint32_t connection_key) { return; } + LOG4CXX_DEBUG(logger_, + "Connection key : " + << connection_key + << " is waiting for certificate: " << std::boolalpha + << waiting_for_certificate_ << " and has certificate: " + << ssl_context->HasCertificate()); + ssl_context->ResetConnection(); if (!waiting_for_certificate_ && !ssl_context->HasCertificate()) { NotifyListenersOnHandshakeDone(connection_key, @@ -228,6 +235,7 @@ void SecurityManagerImpl::StartHandshake(uint32_t connection_key) { LOG4CXX_INFO(logger_, "StartHandshake: connection_key " << connection_key); security_manager::SSLContext* ssl_context = session_observer_->GetSSLContext( connection_key, protocol_handler::kControl); + if (!ssl_context) { const std::string error_text( "StartHandshake failed, " @@ -277,6 +285,7 @@ void SecurityManagerImpl::ProceedHandshake( time_t cert_due_date; if (!ssl_context->GetCertificateDueDate(cert_due_date)) { LOG4CXX_ERROR(logger_, "Failed to get certificate due date!"); + PostponeHandshake(connection_key); return; } @@ -388,6 +397,68 @@ void SecurityManagerImpl::OnSystemTimeArrived(const time_t utc_time) { awaiting_time_connections_.clear(); } +void SecurityManagerImpl::OnSystemTimeFailed() { + LOG4CXX_AUTO_TRACE(logger_); + { + sync_primitives::AutoLock lock(waiters_lock_); + waiting_for_time_ = false; + } + + NotifyListenersOnGetSystemTimeFailed(); + + awaiting_time_connections_.clear(); +} + +void SecurityManagerImpl::ProcessFailedPTU() { + LOG4CXX_AUTO_TRACE(logger_); + if (listeners_.empty()) { + LOG4CXX_DEBUG(logger_, "listeners arrays IS EMPTY!"); + return; + } + + std::list listeners_to_remove; + for (auto listener : listeners_) { + if (listener->OnPTUFailed()) { + listeners_to_remove.push_back(listener); + } + } + + for (auto& listener : listeners_to_remove) { + auto it = std::find(listeners_.begin(), listeners_.end(), listener); + DCHECK(it != listeners_.end()); + LOG4CXX_DEBUG(logger_, "Destroying listener: " << *it); + delete (*it); + listeners_.erase(it); + } +} + +#ifdef EXTERNAL_PROPRIETARY_MODE +void SecurityManagerImpl::ProcessFailedCertDecrypt() { + LOG4CXX_AUTO_TRACE(logger_); + { + sync_primitives::AutoLock lock(waiters_lock_); + waiting_for_certificate_ = false; + } + + std::list listeners_to_remove; + for (auto listener : listeners_) { + if (listener->OnCertDecryptFailed()) { + listeners_to_remove.push_back(listener); + } + } + + for (auto& listener : listeners_to_remove) { + auto it = std::find(listeners_.begin(), listeners_.end(), listener); + DCHECK(it != listeners_.end()); + LOG4CXX_DEBUG(logger_, "Destroying listener: " << *it); + delete (*it); + listeners_.erase(it); + } + + awaiting_certificate_connections_.clear(); +} +#endif + void SecurityManagerImpl::NotifyListenersOnHandshakeDone( const uint32_t& connection_key, SSLContext::HandshakeResult error) { LOG4CXX_AUTO_TRACE(logger_); @@ -412,11 +483,15 @@ void SecurityManagerImpl::NotifyOnCertificateUpdateRequired() { } } -void SecurityManagerImpl::NotifyListenersOnHandshakeFailed() { +void SecurityManagerImpl::ResetPendingSystemTimeRequests() { + system_time_handler_->ResetPendingSystemTimeRequests(); +} + +void SecurityManagerImpl::NotifyListenersOnGetSystemTimeFailed() { LOG4CXX_AUTO_TRACE(logger_); std::list::iterator it = listeners_.begin(); while (it != listeners_.end()) { - if ((*it)->OnHandshakeFailed()) { + if ((*it)->OnGetSystemTimeFailed()) { LOG4CXX_DEBUG(logger_, "Destroying listener: " << *it); delete (*it); it = listeners_.erase(it); @@ -448,9 +523,9 @@ bool SecurityManagerImpl::ProccessHandshakeData( const uint32_t seqNumber = inMessage->get_header().seq_number; const uint32_t connection_key = inMessage->get_connection_key(); - LOG4CXX_DEBUG(logger_, - "Received " << inMessage->get_data_size() - << " bytes handshake data "); + LOG4CXX_DEBUG( + logger_, + "Received " << inMessage->get_data_size() << " bytes handshake data "); if (!inMessage->get_data_size()) { const std::string error_text("SendHandshakeData: null arguments size."); @@ -582,10 +657,11 @@ void SecurityManagerImpl::SendQuery(const SecurityQuery& query, protocol_version, &data_sending[0], data_sending.size(), + false, protocol_handler::kControl)); DCHECK(protocol_handler_); // Add RawMessage to ProtocolHandler message query - protocol_handler_->SendMessageToMobileApp(rawMessagePtr, false); + protocol_handler_->SendMessageToMobileApp(rawMessagePtr, false, false); } } diff --git a/src/components/security_manager/src/security_query.cc b/src/components/security_manager/src/security_query.cc index 60233dde5ec..fecfc4d723f 100644 --- a/src/components/security_manager/src/security_query.cc +++ b/src/components/security_manager/src/security_query.cc @@ -32,8 +32,8 @@ #include "security_manager/security_query.h" #include -#include "utils/macro.h" #include "utils/byte_order.h" +#include "utils/macro.h" namespace security_manager { diff --git a/src/components/security_manager/src/ssl_context_impl.cc b/src/components/security_manager/src/ssl_context_impl.cc index 67be17db63d..d5c892c07a3 100644 --- a/src/components/security_manager/src/ssl_context_impl.cc +++ b/src/components/security_manager/src/ssl_context_impl.cc @@ -33,14 +33,14 @@ #include #include -#include +#include #include +#include #include -#include #include -#include #include +#include #include "utils/macro.h" @@ -249,9 +249,9 @@ CryptoManagerImpl::SSLContextImpl::CheckCertContext() { << start_seconds << " seconds"); return Handshake_Result_NotYetValid; } else { - LOG4CXX_DEBUG(logger_, - "Time since certificate validity " << start_seconds - << "seconds"); + LOG4CXX_DEBUG( + logger_, + "Time since certificate validity " << start_seconds << "seconds"); } if (end_seconds < 0) { @@ -529,13 +529,18 @@ bool CryptoManagerImpl::SSLContextImpl::Decrypt(const uint8_t* const in_data, } size_t CryptoManagerImpl::SSLContextImpl::get_max_block_size(size_t mtu) const { + LOG4CXX_AUTO_TRACE(logger_); if (!max_block_size_) { // FIXME(EZamakhov): add correct logics for TLS1/1.2/SSL3 // For SSL3.0 set temporary value 90, old TLS1.2 value is 29 assert(mtu > 90); return mtu - 90; } - return max_block_size_(mtu); + + const auto max_allowed_block_size = + mtu > SSL3_RT_MAX_PLAIN_LENGTH ? SSL3_RT_MAX_PLAIN_LENGTH : mtu; + + return max_block_size_(max_allowed_block_size); } bool CryptoManagerImpl::SSLContextImpl::IsHandshakePending() const { diff --git a/src/components/security_manager/test/crypto_manager_impl_test.cc b/src/components/security_manager/test/crypto_manager_impl_test.cc index 5e096194f3d..d30fa5ef23e 100644 --- a/src/components/security_manager/test/crypto_manager_impl_test.cc +++ b/src/components/security_manager/test/crypto_manager_impl_test.cc @@ -35,17 +35,17 @@ #else #include #endif //__QNXNTO__ -#include #include +#include #include #include "gtest/gtest.h" #include "security_manager/crypto_manager_impl.h" #include "security_manager/mock_security_manager_settings.h" +using ::testing::NiceMock; using ::testing::Return; using ::testing::ReturnRef; -using ::testing::NiceMock; namespace { const size_t kUpdatesBeforeHour = 24; @@ -62,7 +62,7 @@ const std::string kFordCipher = SSL3_TXT_RSA_DES_192_CBC3_SHA; // Used cipher from ford protocol requirement const std::string kFordCipher = TLS1_TXT_RSA_WITH_AES_256_GCM_SHA384; #endif -} +} // namespace namespace test { namespace components { diff --git a/src/components/security_manager/test/security_manager_test.cc b/src/components/security_manager/test/security_manager_test.cc index aff7cbca2d4..7906ae7006e 100644 --- a/src/components/security_manager/test/security_manager_test.cc +++ b/src/components/security_manager/test/security_manager_test.cc @@ -30,20 +30,20 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include #include +#include #include "gtest/gtest.h" -#include "utils/byte_order.h" #include "protocol/common.h" #include "security_manager/security_manager_impl.h" +#include "utils/byte_order.h" #include "protocol_handler/mock_protocol_handler.h" #include "protocol_handler/mock_session_observer.h" -#include "security_manager/mock_security_manager.h" -#include "security_manager/mock_ssl_context.h" #include "security_manager/mock_crypto_manager.h" +#include "security_manager/mock_security_manager.h" #include "security_manager/mock_security_manager_listener.h" +#include "security_manager/mock_ssl_context.h" #include "utils/mock_system_time_handler.h" #include "utils/test_async_waiter.h" @@ -52,28 +52,28 @@ namespace test { namespace components { namespace security_manager_test { -using protocol_handler::PROTOCOL_VERSION_2; -using protocol_handler::ServiceType; -using protocol_handler::kControl; -using protocol_handler::kRpc; using protocol_handler::kAudio; -using protocol_handler::kMobileNav; using protocol_handler::kBulk; +using protocol_handler::kControl; using protocol_handler::kInvalidServiceType; -using protocol_handler::RawMessagePtr; +using protocol_handler::kMobileNav; +using protocol_handler::kRpc; +using protocol_handler::PROTOCOL_VERSION_2; using protocol_handler::RawMessage; +using protocol_handler::RawMessagePtr; +using protocol_handler::ServiceType; -using security_manager::SecurityQuery; -using security_manager::SSLContext; using security_manager::SecurityManager; using security_manager::SecurityManagerImpl; +using security_manager::SecurityQuery; +using security_manager::SSLContext; using security_manager_test::InternalErrorWithErrId; +using ::testing::_; +using ::testing::DoAll; using ::testing::Return; using ::testing::ReturnNull; -using ::testing::DoAll; using ::testing::SetArgPointee; -using ::testing::_; namespace { // Sample data for handshake data emulation @@ -92,7 +92,7 @@ uint8_t* handshake_data_out_pointer = handshake_data_out; const size_t handshake_data_out_size = sizeof(handshake_data_out) / sizeof(handshake_data_out[0]); const uint32_t kAsyncExpectationsTimeout = 10000u; -} +} // namespace class SecurityManagerTest : public ::testing::Test { protected: @@ -104,8 +104,9 @@ class SecurityManagerTest : public ::testing::Test { void SetUp() OVERRIDE { security_manager_->set_session_observer(&mock_session_observer); security_manager_->set_protocol_handler(&mock_protocol_handler); - mock_sm_listener.reset(new testing::StrictMock< - security_manager_test::MockSecurityManagerListener>()); + mock_sm_listener.reset( + new testing::StrictMock< + security_manager_test::MockSecurityManagerListener>()); security_manager_->AddListener(mock_sm_listener.get()); } @@ -121,7 +122,7 @@ class SecurityManagerTest : public ::testing::Test { uint32_t dataSize, const ServiceType serviceType) { const RawMessagePtr rawMessagePtr(std::make_shared( - kKey, kProtocolVersion, data, dataSize, serviceType)); + kKey, kProtocolVersion, data, dataSize, false, serviceType)); security_manager_->OnMessageReceived(rawMessagePtr); } /* @@ -170,8 +171,9 @@ class SecurityManagerTest : public ::testing::Test { mock_ssl_context_new; testing::StrictMock mock_ssl_context_exists; - std::unique_ptr > mock_sm_listener; + std::unique_ptr< + testing::StrictMock > + mock_sm_listener; std::unique_ptr mock_system_time_handler; std::shared_ptr security_manager_; }; @@ -290,7 +292,9 @@ TEST_F(SecurityManagerTest, SecurityManager_NULLCryptoManager) { EXPECT_CALL(mock_protocol_handler, SendMessageToMobileApp( InternalErrorWithErrId(SecurityManager::ERROR_NOT_SUPPORTED), - kIsFinal)).WillOnce(NotifyTestAsyncWaiter(&waiter)); + false, + kIsFinal)) + .WillOnce(NotifyTestAsyncWaiter(&waiter)); const SecurityQuery::QueryHeader header(SecurityQuery::REQUEST, // It could be any query id SecurityQuery::INVALID_QUERY_ID); @@ -304,8 +308,8 @@ TEST_F(SecurityManagerTest, SecurityManager_NULLCryptoManager) { */ TEST_F(SecurityManagerTest, OnMobileMessageSent) { const uint8_t* data_param = NULL; - const RawMessagePtr rawMessagePtr( - std::make_shared(kKey, kProtocolVersion, data_param, 0)); + const RawMessagePtr rawMessagePtr(std::make_shared( + kKey, kProtocolVersion, data_param, 0, false)); security_manager_->OnMobileMessageSent(rawMessagePtr); } /* @@ -335,6 +339,7 @@ TEST_F(SecurityManagerTest, GetEmptyQuery) { mock_protocol_handler, SendMessageToMobileApp( InternalErrorWithErrId(SecurityManager::ERROR_INVALID_QUERY_SIZE), + false, kIsFinal)); // Call with NULL data call_OnMessageReceived(NULL, 0, kSecureServiceType); @@ -356,6 +361,7 @@ TEST_F(SecurityManagerTest, GetWrongJSONSize) { mock_protocol_handler, SendMessageToMobileApp( InternalErrorWithErrId(SecurityManager::ERROR_INVALID_QUERY_SIZE), + false, kIsFinal)); SecurityQuery::QueryHeader header(SecurityQuery::REQUEST, SecurityQuery::INVALID_QUERY_ID); @@ -385,7 +391,9 @@ TEST_F(SecurityManagerTest, GetInvalidQueryId) { mock_protocol_handler, SendMessageToMobileApp( InternalErrorWithErrId(SecurityManager::ERROR_INVALID_QUERY_ID), - kIsFinal)).WillOnce(NotifyTestAsyncWaiter(&waiter)); + false, + kIsFinal)) + .WillOnce(NotifyTestAsyncWaiter(&waiter)); times++; const SecurityQuery::QueryHeader header(SecurityQuery::REQUEST, SecurityQuery::INVALID_QUERY_ID); @@ -423,10 +431,11 @@ TEST_F(SecurityManagerTest, CreateSSLContext_ErrorCreateSSL) { EXPECT_CALL(mock_session_observer, ProtocolVersionUsed(connection_id, session_id, _)) .WillOnce(Return(true)); - EXPECT_CALL( - mock_protocol_handler, - SendMessageToMobileApp( - InternalErrorWithErrId(SecurityManager::ERROR_INTERNAL), kIsFinal)); + EXPECT_CALL(mock_protocol_handler, + SendMessageToMobileApp( + InternalErrorWithErrId(SecurityManager::ERROR_INTERNAL), + false, + kIsFinal)); // Emulate SessionObserver and CryptoManager result EXPECT_CALL(mock_session_observer, GetSSLContext(kKey, kControl)) @@ -457,6 +466,7 @@ TEST_F(SecurityManagerTest, CreateSSLContext_SetSSLContextError) { mock_protocol_handler, SendMessageToMobileApp( InternalErrorWithErrId(SecurityManager::ERROR_UNKNOWN_INTERNAL_ERROR), + false, kIsFinal)); // Emulate SessionObserver and CryptoManager result @@ -508,10 +518,11 @@ TEST_F(SecurityManagerTest, StartHandshake_ServiceStillUnprotected) { ProtocolVersionUsed(connection_id, session_id, _)) .WillOnce(Return(true)); // Expect InternalError with ERROR_INTERNAL - EXPECT_CALL( - mock_protocol_handler, - SendMessageToMobileApp( - InternalErrorWithErrId(SecurityManager::ERROR_INTERNAL), kIsFinal)); + EXPECT_CALL(mock_protocol_handler, + SendMessageToMobileApp( + InternalErrorWithErrId(SecurityManager::ERROR_INTERNAL), + false, + kIsFinal)); // Expect notifying listeners (unsuccess) EXPECT_CALL(*mock_sm_listener, OnHandshakeDone(kKey, SSLContext::Handshake_Result_Fail)) @@ -546,10 +557,11 @@ TEST_F(SecurityManagerTest, StartHandshake_SSLInternalError) { EXPECT_CALL(mock_session_observer, GetSSLContext(kKey, kControl)) .WillOnce(ReturnNull()); // Expect InternalError with ERROR_ID - EXPECT_CALL( - mock_protocol_handler, - SendMessageToMobileApp( - InternalErrorWithErrId(SecurityManager::ERROR_INTERNAL), kIsFinal)); + EXPECT_CALL(mock_protocol_handler, + SendMessageToMobileApp( + InternalErrorWithErrId(SecurityManager::ERROR_INTERNAL), + false, + kIsFinal)); security_manager_->StartHandshake(kKey); mock_sm_listener.release(); @@ -575,7 +587,9 @@ TEST_F(SecurityManagerTest, ProccessHandshakeData_WrongDataSize) { mock_protocol_handler, SendMessageToMobileApp( InternalErrorWithErrId(SecurityManager::ERROR_INVALID_QUERY_SIZE), - kIsFinal)).WillOnce(NotifyTestAsyncWaiter(&waiter)); + false, + kIsFinal)) + .WillOnce(NotifyTestAsyncWaiter(&waiter)); EmulateMobileMessageHandshake(NULL, 0); @@ -606,7 +620,9 @@ TEST_F(SecurityManagerTest, mock_protocol_handler, SendMessageToMobileApp( InternalErrorWithErrId(SecurityManager::ERROR_SERVICE_NOT_PROTECTED), - kIsFinal)).WillOnce(NotifyTestAsyncWaiter(&waiter)); + false, + kIsFinal)) + .WillOnce(NotifyTestAsyncWaiter(&waiter)); times++; // Expect notifying listeners (unsuccess) @@ -659,6 +675,7 @@ TEST_F(SecurityManagerTest, ProccessHandshakeData_InvalidData) { mock_protocol_handler, SendMessageToMobileApp( InternalErrorWithErrId(SecurityManager::ERROR_SSL_INVALID_DATA), + false, kIsFinal)) .Times(handshake_emulates) .WillRepeatedly(NotifyTestAsyncWaiter(&waiter)); @@ -737,9 +754,9 @@ TEST_F(SecurityManagerTest, ProccessHandshakeData_Answer) { // Get size of raw message after const size_t raw_message_size = 15; - EXPECT_CALL( - mock_protocol_handler, - SendMessageToMobileApp(RawMessageEqSize(raw_message_size), kIsFinal)) + EXPECT_CALL(mock_protocol_handler, + SendMessageToMobileApp( + RawMessageEqSize(raw_message_size), false, kIsFinal)) .Times(handshake_emulates) .WillRepeatedly(NotifyTestAsyncWaiter(&waiter)); times += handshake_emulates; @@ -866,7 +883,7 @@ TEST_F(SecurityManagerTest, ProccessHandshakeData_HandshakeFinished) { .WillRepeatedly(DoAll(NotifyTestAsyncWaiter(&waiter), Return(true))); times += 2; // matches to the number above - EXPECT_CALL(mock_protocol_handler, SendMessageToMobileApp(_, kIsFinal)) + EXPECT_CALL(mock_protocol_handler, SendMessageToMobileApp(_, false, kIsFinal)) .Times(2) .WillRepeatedly(NotifyTestAsyncWaiter(&waiter)); times += 2; // matches to the number above diff --git a/src/components/security_manager/test/security_query_matcher.cc b/src/components/security_manager/test/security_query_matcher.cc index 3b7f4dd2986..1bf22bf8cdd 100644 --- a/src/components/security_manager/test/security_query_matcher.cc +++ b/src/components/security_manager/test/security_query_matcher.cc @@ -33,8 +33,8 @@ #include #include "gmock/gmock.h" -#include "utils/byte_order.h" #include "security_manager/security_query.h" +#include "utils/byte_order.h" namespace test { namespace components { diff --git a/src/components/security_manager/test/security_query_test.cc b/src/components/security_manager/test/security_query_test.cc index 80da10ea722..6becddaaf91 100644 --- a/src/components/security_manager/test/security_query_test.cc +++ b/src/components/security_manager/test/security_query_test.cc @@ -30,14 +30,14 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include #include +#include #include "gtest/gtest.h" -#include "security_manager/security_query.h" #include "protocol_handler/protocol_payload.h" -#include "utils/byte_order.h" #include "security_manager/mock_security_manager.h" +#include "security_manager/security_query.h" +#include "utils/byte_order.h" // Test values for compare after serialization and byteorder conversion #define SEQ_NUMBER 0x12345678u diff --git a/src/components/security_manager/test/ssl_context_test.cc b/src/components/security_manager/test/ssl_context_test.cc index 05eeb802ad6..e4d6c308bbd 100644 --- a/src/components/security_manager/test/ssl_context_test.cc +++ b/src/components/security_manager/test/ssl_context_test.cc @@ -30,21 +30,21 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include "gtest/gtest.h" +#include #include #include #include -#include +#include "gtest/gtest.h" #include "security_manager/crypto_manager.h" #include "security_manager/crypto_manager_impl.h" +#include "security_manager/mock_security_manager_settings.h" #include "security_manager/ssl_context.h" #include "utils/custom_string.h" -#include "security_manager/mock_security_manager_settings.h" +using ::testing::NiceMock; using ::testing::Return; using ::testing::ReturnRef; -using ::testing::NiceMock; namespace { const std::string kCaPath = ""; @@ -98,14 +98,14 @@ class SSLTest : public testing::Test { static void SetCertificate(const std::string& file_name, std::string& out_certificate_data) { std::ifstream certificate_file(file_name.c_str()); - ASSERT_TRUE(certificate_file.is_open()) << "Could not open " << file_name - << "certificate data file"; + ASSERT_TRUE(certificate_file.is_open()) + << "Could not open " << file_name << "certificate data file"; std::stringstream certificate; certificate << certificate_file.rdbuf(); certificate_file.close(); out_certificate_data = certificate.str(); - ASSERT_FALSE(out_certificate_data.empty()) << file_name - << " data file is empty"; + ASSERT_FALSE(out_certificate_data.empty()) + << file_name << " data file is empty"; } virtual void SetUp() OVERRIDE { 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 7706b6e091c..0e19d2237e6 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 @@ -34,8 +34,8 @@ #include -#include "smart_objects/schema_item.h" #include "smart_objects/always_true_schema_item.h" +#include "smart_objects/schema_item.h" #include "smart_objects/schema_item_parameter.h" #include "utils/semantic_version.h" 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 beeeaac81f2..16dbad44264 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 @@ -113,10 +113,10 @@ errors::eType CDefaultSchemaItem::validate( const utils::SemanticVersion& MessageVersion, const bool allow_unknown_enums) { if (getSmartType() != Object.getType()) { - std::string validation_info = "Incorrect type, expected: " + - SmartObject::typeToString(getSmartType()) + - ", got: " + - SmartObject::typeToString(Object.getType()); + std::string validation_info = + "Incorrect type, expected: " + + SmartObject::typeToString(getSmartType()) + + ", got: " + SmartObject::typeToString(Object.getType()); report__->set_validation_info(validation_info); return errors::INVALID_VALUE; } else { 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 2a27f765d29..053ad983956 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 @@ -41,8 +41,8 @@ #include "smart_objects/default_shema_item.h" -#include "utils/semantic_version.h" #include +#include "utils/semantic_version.h" namespace ns_smart_device_link { namespace ns_smart_objects { @@ -325,10 +325,10 @@ errors::eType TEnumSchemaItem::validate( } validation_info = "Invalid enum value: " + Object.asString(); } else { - validation_info = "Incorrect type, expected: " + - SmartObject::typeToString(SmartType_Integer) + - " (enum), got: " + - SmartObject::typeToString(Object.getType()); + validation_info = + "Incorrect type, expected: " + + SmartObject::typeToString(SmartType_Integer) + + " (enum), got: " + SmartObject::typeToString(Object.getType()); } report__->set_validation_info(validation_info); return errors::INVALID_VALUE; 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 b3e227e0f15..c3767e8e48e 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 @@ -33,8 +33,8 @@ #ifndef SRC_COMPONENTS_SMART_OBJECTS_INCLUDE_SMART_OBJECTS_NUMBER_SCHEMA_ITEM_H_ #define SRC_COMPONENTS_SMART_OBJECTS_INCLUDE_SMART_OBJECTS_NUMBER_SCHEMA_ITEM_H_ -#include #include +#include #include "smart_objects/default_shema_item.h" #include "smart_objects/schema_item_parameter.h" @@ -113,10 +113,11 @@ class TNumberSchemaItem : public CDefaultSchemaItem { }; template -std::shared_ptr > TNumberSchemaItem< - NumberType>::create(const TSchemaItemParameter& MinValue, - const TSchemaItemParameter& MaxValue, - const TSchemaItemParameter& DefaultValue) { +std::shared_ptr > +TNumberSchemaItem::create( + const TSchemaItemParameter& MinValue, + const TSchemaItemParameter& MaxValue, + const TSchemaItemParameter& DefaultValue) { return std::shared_ptr >( new TNumberSchemaItem(MinValue, MaxValue, DefaultValue)); } 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 7b57792c1e5..ee42b366203 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 @@ -33,67 +33,69 @@ #define SRC_COMPONENTS_SMART_OBJECTS_INCLUDE_SMART_OBJECTS_OBJECT_SCHEMA_ITEM_H_ #include -#include #include +#include +#include #include "utils/macro.h" #include "utils/semantic_version.h" -#include #include "smart_objects/schema_item.h" #include "smart_objects/schema_item_parameter.h" namespace ns_smart_device_link { namespace ns_smart_objects { + /** - * @brief Object schema item. + * @brief Object member. **/ -class CObjectSchemaItem : public ISchemaItem { - public: +struct SMember { + /** + * @brief Default constructor. + **/ + SMember(); + /** + * @brief Constructor. + * @param SchemaItem Member schema item. + * @param IsMandatory true if member is mandatory, false + * otherwise. Defaults to true. + **/ + + SMember(const ISchemaItemPtr SchemaItem, + const bool IsMandatory = true, + const std::string& Since = "", + const std::string& Until = "", + const bool IsDeprecated = false, + const bool IsRemoved = false, + const std::vector& history_vector = {}); /** - * @brief Object member. + * @brief Checks the version a parameter was removed (until) + * If the mobile's msg version is greater than or **/ - struct SMember { - /** - * @brief Default constructor. - **/ - SMember(); - /** - * @brief Constructor. - * @param SchemaItem Member schema item. - * @param IsMandatory true if member is mandatory, false - * otherwise. Defaults to true. - **/ + bool CheckHistoryFieldVersion( + const utils::SemanticVersion& MessageVersion) const; - SMember(const ISchemaItemPtr SchemaItem, - const bool IsMandatory = true, - const std::string& Since = "", - const std::string& Until = "", - const bool IsDeprecated = false, - const bool IsRemoved = false, - const std::vector& history_vector = {}); - /** - * @brief Checks the version a parameter was removed (until) - * If the mobile's msg version is greater than or - **/ - bool CheckHistoryFieldVersion( - const utils::SemanticVersion& MessageVersion) const; + /** + * @brief Member schema item. + **/ + ISchemaItemPtr mSchemaItem; + /** + * @brief true if member is mandatory, false otherwise. + **/ + bool mIsMandatory; + boost::optional mSince; + boost::optional mUntil; + bool mIsDeprecated; + bool mIsRemoved; + std::vector mHistoryVector; +}; +typedef std::map Members; - /** - * @brief Member schema item. - **/ - ISchemaItemPtr mSchemaItem; - /** - * @brief true if member is mandatory, false otherwise. - **/ - bool mIsMandatory; - boost::optional mSince; - boost::optional mUntil; - bool mIsDeprecated; - bool mIsRemoved; - std::vector mHistoryVector; - }; - typedef std::map Members; +/** + * @brief Object schema item. + **/ +class CObjectSchemaItem : public ISchemaItem { + public: /** * @brief Create a new schema item. * @@ -153,6 +155,12 @@ class CObjectSchemaItem : public ISchemaItem { */ size_t GetMemberSize() OVERRIDE; + boost::optional GetMemberSchemaItem( + const std::string& member_key) OVERRIDE; + + void AddMemberSchemaItem(const std::string& member_key, + SMember& member) OVERRIDE; + protected: /** * @brief Constructor. @@ -173,14 +181,14 @@ class CObjectSchemaItem : public ISchemaItem { * @param member Schema member * @param MmessageVersion Semantic Version of mobile message. **/ - const CObjectSchemaItem::SMember& GetCorrectMember( - const SMember& member, const utils::SemanticVersion& messageVersion); + const SMember& GetCorrectMember(const SMember& member, + const utils::SemanticVersion& messageVersion); /** * @brief Map of member name to SMember structure describing the object *member. **/ - const Members mMembers; + Members mMembers; DISALLOW_COPY_AND_ASSIGN(CObjectSchemaItem); }; } // namespace ns_smart_objects 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 fa5f6d3adc2..9c29e66f36d 100644 --- a/src/components/smart_objects/include/smart_objects/schema_item.h +++ b/src/components/smart_objects/include/smart_objects/schema_item.h @@ -40,12 +40,14 @@ #include #include +#include "boost/optional/optional.hpp" #include "utils/macro.h" #include "utils/semantic_version.h" namespace ns_smart_device_link { namespace ns_smart_objects { class SmartObject; +class SMember; /** * @brief Base schema item. @@ -123,6 +125,17 @@ class ISchemaItem { virtual void BuildObjectBySchema(const SmartObject& pattern_object, SmartObject& result_object); + virtual boost::optional GetMemberSchemaItem( + const std::string& member_key) { + UNUSED(member_key); + return boost::optional(); + } + + virtual void AddMemberSchemaItem(const std::string& member_key, + SMember& member) { + UNUSED(member_key); + UNUSED(member); + } /** * @brief Get value param, depends of children * 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 b862d25a17c..f3aab0fc1eb 100644 --- a/src/components/smart_objects/include/smart_objects/smart_object.h +++ b/src/components/smart_objects/include/smart_objects/smart_object.h @@ -33,15 +33,15 @@ #ifndef SRC_COMPONENTS_SMART_OBJECTS_INCLUDE_SMART_OBJECTS_SMART_OBJECT_H_ #define SRC_COMPONENTS_SMART_OBJECTS_INCLUDE_SMART_OBJECTS_SMART_OBJECT_H_ +#include #include -#include #include +#include #include -#include +#include "rpc_base/validation_report.h" #include "smart_objects/smart_schema.h" #include "utils/custom_string.h" -#include "rpc_base/validation_report.h" namespace ns_smart_device_link { namespace ns_smart_objects { @@ -299,8 +299,8 @@ class SmartObject FINAL { bool operator==(const int64_t Value) const; /** - * @name Support of type: uint64_t - * @{ + * @name Support of type: uint64_t + * @{ **/ /** 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 ece26965393..8cbafa53b2f 100644 --- a/src/components/smart_objects/include/smart_objects/smart_schema.h +++ b/src/components/smart_objects/include/smart_objects/smart_schema.h @@ -32,8 +32,8 @@ #ifndef SRC_COMPONENTS_SMART_OBJECTS_INCLUDE_SMART_OBJECTS_SMART_SCHEMA_H_ #define SRC_COMPONENTS_SMART_OBJECTS_INCLUDE_SMART_OBJECTS_SMART_SCHEMA_H_ -#include "utils/macro.h" #include "smart_objects/schema_item.h" +#include "utils/macro.h" namespace ns_smart_device_link { namespace ns_smart_objects { @@ -85,6 +85,13 @@ class CSmartSchema FINAL { */ void setSchemaItem(const ISchemaItemPtr SchemaItem); + /** + * @brief Set new root schema item. + * + * @param SchemaItem Root schema item. + */ + ISchemaItemPtr getSchemaItem(); + /** * @brief Apply schema. * diff --git a/src/components/smart_objects/src/array_schema_item.cc b/src/components/smart_objects/src/array_schema_item.cc index 1671a976440..9420fe020f8 100644 --- a/src/components/smart_objects/src/array_schema_item.cc +++ b/src/components/smart_objects/src/array_schema_item.cc @@ -48,10 +48,10 @@ errors::eType CArraySchemaItem::validate( const utils::SemanticVersion& MessageVersion, const bool allow_unknown_enums) { if (SmartType_Array != Object.getType()) { - std::string validation_info = "Incorrect type, expected: " + - SmartObject::typeToString(SmartType_Array) + - ", got: " + - SmartObject::typeToString(Object.getType()); + std::string validation_info = + "Incorrect type, expected: " + + SmartObject::typeToString(SmartType_Array) + + ", got: " + SmartObject::typeToString(Object.getType()); report__->set_validation_info(validation_info); return errors::INVALID_VALUE; } diff --git a/src/components/smart_objects/src/object_schema_item.cc b/src/components/smart_objects/src/object_schema_item.cc index 21d2316e48a..01e4ec46e03 100644 --- a/src/components/smart_objects/src/object_schema_item.cc +++ b/src/components/smart_objects/src/object_schema_item.cc @@ -40,24 +40,23 @@ namespace { const char connection_key[] = "connection_key"; const char binary_data[] = "binary_data"; const char app_id[] = "appID"; -} +} // namespace namespace ns_smart_device_link { namespace ns_smart_objects { -CObjectSchemaItem::SMember::SMember() +SMember::SMember() : mSchemaItem(CAlwaysFalseSchemaItem::create()) , mIsMandatory(true) , mIsDeprecated(false) , mIsRemoved(false) {} -CObjectSchemaItem::SMember::SMember( - const ISchemaItemPtr SchemaItem, - const bool IsMandatory, - const std::string& Since, - const std::string& Until, - const bool IsDeprecated, - const bool IsRemoved, - const std::vector& history_vector) +SMember::SMember(const ISchemaItemPtr SchemaItem, + const bool IsMandatory, + const std::string& Since, + const std::string& Until, + const bool IsDeprecated, + const bool IsRemoved, + const std::vector& history_vector) : mSchemaItem(SchemaItem), mIsMandatory(IsMandatory) { if (Since.size() > 0) { utils::SemanticVersion since_struct(Since); @@ -76,7 +75,7 @@ CObjectSchemaItem::SMember::SMember( mHistoryVector = history_vector; } -bool CObjectSchemaItem::SMember::CheckHistoryFieldVersion( +bool SMember::CheckHistoryFieldVersion( const utils::SemanticVersion& MessageVersion) const { if (MessageVersion.isValid()) { if (mSince != boost::none) { @@ -113,10 +112,10 @@ errors::eType CObjectSchemaItem::validate( const utils::SemanticVersion& MessageVersion, const bool allow_unknown_enums) { if (SmartType_Map != object.getType()) { - std::string validation_info = "Incorrect type, expected: " + - SmartObject::typeToString(SmartType_Map) + - ", got: " + - SmartObject::typeToString(object.getType()); + std::string validation_info = + "Incorrect type, expected: " + + SmartObject::typeToString(SmartType_Map) + + ", got: " + SmartObject::typeToString(object.getType()); report__->set_validation_info(validation_info); return errors::INVALID_VALUE; } @@ -153,6 +152,7 @@ errors::eType CObjectSchemaItem::validate( } object_keys.erase(key_it); } + return errors::OK; } @@ -169,10 +169,10 @@ void CObjectSchemaItem::applySchema( } SmartObject default_value; - for (Members::const_iterator it = mMembers.begin(); it != mMembers.end(); - ++it) { - const std::string& key = it->first; - const SMember& member = it->second; + + for (const auto& item : mMembers) { + const std::string& key = item.first; + const SMember& member = item.second; if (!Object.keyExists(key)) { if (member.mSchemaItem->setDefaultValue(default_value)) { Object[key] = default_value; @@ -201,7 +201,6 @@ void CObjectSchemaItem::unapplySchema(SmartObject& Object, Object.erase(key); } } - for (Members::const_iterator it = mMembers.begin(); it != mMembers.end(); ++it) { const std::string& key = it->first; @@ -232,6 +231,21 @@ size_t CObjectSchemaItem::GetMemberSize() { return mMembers.size(); } +boost::optional CObjectSchemaItem::GetMemberSchemaItem( + const std::string& member_key) { + auto it = mMembers.find(member_key); + + if (it != mMembers.end()) { + return boost::optional(it->second); + } + return boost::optional(); +} + +void CObjectSchemaItem::AddMemberSchemaItem(const std::string& member_key, + SMember& member) { + mMembers[member_key] = member; +} + CObjectSchemaItem::CObjectSchemaItem(const Members& members) : mMembers(members) {} @@ -244,8 +258,7 @@ void CObjectSchemaItem::RemoveFakeParams( mMembers.find(key); if (mMembers.end() == members_it // FIXME(EZamakhov): Remove illegal usage of filed in AM - && - key.compare(connection_key) != 0 && key.compare(binary_data) != 0 && + && key.compare(connection_key) != 0 && key.compare(binary_data) != 0 && key.compare(app_id) != 0) { ++it; Object.erase(key); @@ -261,7 +274,7 @@ void CObjectSchemaItem::RemoveFakeParams( } } -const CObjectSchemaItem::SMember& CObjectSchemaItem::GetCorrectMember( +const SMember& CObjectSchemaItem::GetCorrectMember( const SMember& member, const utils::SemanticVersion& messageVersion) { // Check if member is the correct version if (member.CheckHistoryFieldVersion(messageVersion)) { diff --git a/src/components/smart_objects/src/smart_object.cc b/src/components/smart_objects/src/smart_object.cc index ef5dc787bee..eb1c737affe 100644 --- a/src/components/smart_objects/src/smart_object.cc +++ b/src/components/smart_objects/src/smart_object.cc @@ -34,13 +34,12 @@ #include #include -#include #include #include -#include #include #include #include +#include namespace ns_smart_device_link { namespace ns_smart_objects { diff --git a/src/components/smart_objects/src/smart_schema.cc b/src/components/smart_objects/src/smart_schema.cc index 4ab5e5ff236..6107d192667 100644 --- a/src/components/smart_objects/src/smart_schema.cc +++ b/src/components/smart_objects/src/smart_schema.cc @@ -53,6 +53,10 @@ void CSmartSchema::setSchemaItem(const ISchemaItemPtr schemaItem) { mSchemaItem = schemaItem; } +ISchemaItemPtr CSmartSchema::getSchemaItem() { + return mSchemaItem; +} + void CSmartSchema::applySchema(SmartObject& Object, const bool remove_unknown_parameters, const utils::SemanticVersion& MessageVersion) { diff --git a/src/components/smart_objects/src/string_schema_item.cc b/src/components/smart_objects/src/string_schema_item.cc index e2ebde1861b..c4382174d09 100644 --- a/src/components/smart_objects/src/string_schema_item.cc +++ b/src/components/smart_objects/src/string_schema_item.cc @@ -29,8 +29,8 @@ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ -#include "smart_objects/smart_object.h" #include "smart_objects/string_schema_item.h" +#include "smart_objects/smart_object.h" #include "utils/custom_string.h" namespace ns_smart_device_link { @@ -52,10 +52,10 @@ errors::eType CStringSchemaItem::validate( const utils::SemanticVersion& MessageVersion, const bool allow_unknown_enums) { if (SmartType_String != Object.getType()) { - std::string validation_info = "Incorrect type, expected: " + - SmartObject::typeToString(SmartType_String) + - ", got: " + - SmartObject::typeToString(Object.getType()); + std::string validation_info = + "Incorrect type, expected: " + + SmartObject::typeToString(SmartType_String) + + ", got: " + SmartObject::typeToString(Object.getType()); report__->set_validation_info(validation_info); return errors::INVALID_VALUE; } diff --git a/src/components/smart_objects/test/AlwaysFalseSchemaItem_test.cc b/src/components/smart_objects/test/AlwaysFalseSchemaItem_test.cc index 1f514672fdd..cded041bcc1 100644 --- a/src/components/smart_objects/test/AlwaysFalseSchemaItem_test.cc +++ b/src/components/smart_objects/test/AlwaysFalseSchemaItem_test.cc @@ -34,8 +34,8 @@ #include "gmock/gmock.h" -#include "smart_objects/smart_object.h" #include "smart_objects/always_false_schema_item.h" +#include "smart_objects/smart_object.h" namespace test { namespace components { diff --git a/src/components/smart_objects/test/AlwaysTrueSchemaItem_test.cc b/src/components/smart_objects/test/AlwaysTrueSchemaItem_test.cc index 7f26a4968a6..54a9c8684fa 100644 --- a/src/components/smart_objects/test/AlwaysTrueSchemaItem_test.cc +++ b/src/components/smart_objects/test/AlwaysTrueSchemaItem_test.cc @@ -34,8 +34,8 @@ #include "gmock/gmock.h" -#include "smart_objects/smart_object.h" #include "smart_objects/always_true_schema_item.h" +#include "smart_objects/smart_object.h" namespace test { namespace components { diff --git a/src/components/smart_objects/test/ArraySchemaItem_test.cc b/src/components/smart_objects/test/ArraySchemaItem_test.cc index 28f435ee43b..a22a27399d8 100644 --- a/src/components/smart_objects/test/ArraySchemaItem_test.cc +++ b/src/components/smart_objects/test/ArraySchemaItem_test.cc @@ -34,8 +34,8 @@ #include "gmock/gmock.h" -#include "smart_objects/smart_object.h" #include "smart_objects/array_schema_item.h" +#include "smart_objects/smart_object.h" #include "smart_objects/string_schema_item.h" namespace test { diff --git a/src/components/smart_objects/test/BoolSchemaItem_test.cc b/src/components/smart_objects/test/BoolSchemaItem_test.cc index ed0043925b5..7400729116e 100644 --- a/src/components/smart_objects/test/BoolSchemaItem_test.cc +++ b/src/components/smart_objects/test/BoolSchemaItem_test.cc @@ -34,8 +34,8 @@ #include "gmock/gmock.h" -#include "smart_objects/smart_object.h" #include "smart_objects/bool_schema_item.h" +#include "smart_objects/smart_object.h" namespace test { namespace components { diff --git a/src/components/smart_objects/test/CObjectSchemaItem_test.cc b/src/components/smart_objects/test/CObjectSchemaItem_test.cc index 646e60bf61d..8a7d09f31e6 100644 --- a/src/components/smart_objects/test/CObjectSchemaItem_test.cc +++ b/src/components/smart_objects/test/CObjectSchemaItem_test.cc @@ -32,18 +32,18 @@ #include +#include "formatters/CSmartFactory.h" +#include "formatters/generic_json_formatter.h" #include "gmock/gmock.h" -#include "smart_objects/smart_object.h" -#include "smart_objects/smart_schema.h" #include "smart_objects/array_schema_item.h" #include "smart_objects/bool_schema_item.h" -#include "smart_objects/string_schema_item.h" #include "smart_objects/enum_schema_item.h" #include "smart_objects/number_schema_item.h" -#include "smart_objects/schema_item_parameter.h" #include "smart_objects/object_schema_item.h" -#include "formatters/generic_json_formatter.h" -#include "formatters/CSmartFactory.h" +#include "smart_objects/schema_item_parameter.h" +#include "smart_objects/smart_object.h" +#include "smart_objects/smart_schema.h" +#include "smart_objects/string_schema_item.h" #include "utils/semantic_version.h" namespace formatters = ns_smart_device_link::ns_json_handler::formatters; @@ -89,7 +89,7 @@ namespace Keys { const char RESULT_CODE[] = "resultCode"; const char INFO[] = "info"; const char SUCCESS[] = "success"; -} +} // namespace Keys class ObjectSchemaItemTest : public ::testing::Test { protected: @@ -117,28 +117,27 @@ class ObjectSchemaItemTest : public ::testing::Test { resultCode_values.insert(ResultType::GENERIC_ERROR); resultCode_values.insert(ResultType::DISALLOWED); - CObjectSchemaItem::Members paramsMembersMap; - paramsMembersMap[S_FUNCTION_ID] = CObjectSchemaItem::SMember( + Members paramsMembersMap; + paramsMembersMap[S_FUNCTION_ID] = SMember( TEnumSchemaItem::create(function_values), true); paramsMembersMap[S_CORRELATION_ID] = - CObjectSchemaItem::SMember(TNumberSchemaItem::create(), true); - paramsMembersMap[S_PROTOCOL_VERSION] = CObjectSchemaItem::SMember( - TNumberSchemaItem::create(TSchemaItemParameter(1), - TSchemaItemParameter(2)), - true); - - CObjectSchemaItem::Members schemaMembersMap; - schemaMembersMap[Keys::RESULT_CODE] = CObjectSchemaItem::SMember( + SMember(TNumberSchemaItem::create(), true); + paramsMembersMap[S_PROTOCOL_VERSION] = + SMember(TNumberSchemaItem::create(TSchemaItemParameter(1), + TSchemaItemParameter(2)), + true); + + Members schemaMembersMap; + schemaMembersMap[Keys::RESULT_CODE] = SMember( TEnumSchemaItem::create(resultCode_values), false); - schemaMembersMap[Keys::INFO] = CObjectSchemaItem::SMember( - CStringSchemaItem::create(TSchemaItemParameter(0), - TSchemaItemParameter(10)), - false); - schemaMembersMap[Keys::SUCCESS] = - CObjectSchemaItem::SMember(CBoolSchemaItem::create(), false); + schemaMembersMap[Keys::INFO] = + SMember(CStringSchemaItem::create(TSchemaItemParameter(0), + TSchemaItemParameter(10)), + false); + schemaMembersMap[Keys::SUCCESS] = SMember(CBoolSchemaItem::create(), false); // Create fake param that has breaking history changes - std::vector fake_param_history_vector; + std::vector fake_param_history_vector; std::shared_ptr fake_param_SchemaItem = CArraySchemaItem::create( @@ -156,22 +155,21 @@ class ObjectSchemaItemTest : public ::testing::Test { TSchemaItemParameter(1), TSchemaItemParameter(100)); - fake_param_history_vector.push_back(CObjectSchemaItem::SMember( + fake_param_history_vector.push_back(SMember( fake_param_history_v1_SchemaItem, true, "", "4.5.0", false, false)); - schemaMembersMap["fakeParam"] = - CObjectSchemaItem::SMember(fake_param_SchemaItem, - false, - "4.5.0", - "", - false, - false, - fake_param_history_vector); - - CObjectSchemaItem::Members rootMembersMap; - rootMembersMap[S_PARAMS] = CObjectSchemaItem::SMember( - CObjectSchemaItem::create(paramsMembersMap), true); - rootMembersMap[S_MSG_PARAMS] = CObjectSchemaItem::SMember( - CObjectSchemaItem::create(schemaMembersMap), true); + schemaMembersMap["fakeParam"] = SMember(fake_param_SchemaItem, + false, + "4.5.0", + "", + false, + false, + fake_param_history_vector); + + Members rootMembersMap; + rootMembersMap[S_PARAMS] = + SMember(CObjectSchemaItem::create(paramsMembersMap), true); + rootMembersMap[S_MSG_PARAMS] = + SMember(CObjectSchemaItem::create(schemaMembersMap), true); schema_item = CObjectSchemaItem::create(rootMembersMap); } diff --git a/src/components/smart_objects/test/EnumSchemaItem_test.cc b/src/components/smart_objects/test/EnumSchemaItem_test.cc index edfa5633368..4f675ab181d 100644 --- a/src/components/smart_objects/test/EnumSchemaItem_test.cc +++ b/src/components/smart_objects/test/EnumSchemaItem_test.cc @@ -32,8 +32,8 @@ #include "gmock/gmock.h" -#include "smart_objects/smart_object.h" #include "smart_objects/enum_schema_item.h" +#include "smart_objects/smart_object.h" #include "smart_objects/string_schema_item.h" #include @@ -278,5 +278,5 @@ const test::components::SmartObjects::SchemaItem::TestType::eType test::components::SmartObjects::SchemaItem::TestType::MASTER_RESET, test::components::SmartObjects::SchemaItem::TestType::FACTORY_DEFAULTS, test::components::SmartObjects::SchemaItem::TestType::APP_UNAUTHORIZED}; -} -} +} // namespace ns_smart_objects +} // namespace ns_smart_device_link diff --git a/src/components/smart_objects/test/NumberSchemaItem_test.cc b/src/components/smart_objects/test/NumberSchemaItem_test.cc index eb227e4e9bb..04010be3f31 100644 --- a/src/components/smart_objects/test/NumberSchemaItem_test.cc +++ b/src/components/smart_objects/test/NumberSchemaItem_test.cc @@ -33,8 +33,8 @@ #include #include "gmock/gmock.h" -#include "smart_objects/smart_object.h" #include "smart_objects/number_schema_item.h" +#include "smart_objects/smart_object.h" namespace test { namespace components { diff --git a/src/components/smart_objects/test/SmartObjectConvertionTime_test.cc b/src/components/smart_objects/test/SmartObjectConvertionTime_test.cc index 7d95a40b26a..555239c489b 100644 --- a/src/components/smart_objects/test/SmartObjectConvertionTime_test.cc +++ b/src/components/smart_objects/test/SmartObjectConvertionTime_test.cc @@ -36,21 +36,21 @@ #include "gmock/gmock.h" -#include "smart_objects/smart_object.h" -#include "smart_objects/smart_schema.h" -#include "smart_objects/schema_item.h" -#include "formatters/CFormatterJsonSDLRPCv2.h" #include "formatters/CFormatterJsonSDLRPCv1.h" +#include "formatters/CFormatterJsonSDLRPCv2.h" #include "smart_objects/array_schema_item.h" #include "smart_objects/bool_schema_item.h" -#include "smart_objects/object_schema_item.h" -#include "smart_objects/string_schema_item.h" #include "smart_objects/enum_schema_item.h" #include "smart_objects/number_schema_item.h" +#include "smart_objects/object_schema_item.h" +#include "smart_objects/schema_item.h" #include "smart_objects/schema_item_parameter.h" +#include "smart_objects/smart_object.h" +#include "smart_objects/smart_schema.h" +#include "smart_objects/string_schema_item.h" -#include #include +#include namespace test { namespace components { @@ -252,21 +252,20 @@ class SmartObjectConvertionTimeTest : public ::testing::Test { TEnumSchemaItem::create( messageType_allowedEnumSubsetValues); - CObjectSchemaItem::Members paramsMembersMap; + Members paramsMembersMap; paramsMembersMap [ns_smart_device_link::ns_json_handler::strings::S_FUNCTION_ID] = - CObjectSchemaItem::SMember(functionId_SchemaItem, true); + SMember(functionId_SchemaItem, true); paramsMembersMap [ns_smart_device_link::ns_json_handler::strings::S_MESSAGE_TYPE] = - CObjectSchemaItem::SMember(messageType_SchemaItem, true); + SMember(messageType_SchemaItem, true); paramsMembersMap [ns_smart_device_link::ns_json_handler::strings::S_CORRELATION_ID] = - CObjectSchemaItem::SMember(TNumberSchemaItem::create(), true); + SMember(TNumberSchemaItem::create(), true); - std::map rootMembersMap; + std::map rootMembersMap; rootMembersMap[ns_smart_device_link::ns_json_handler::strings::S_PARAMS] = - CObjectSchemaItem::SMember(CObjectSchemaItem::create(paramsMembersMap), - true); + SMember(CObjectSchemaItem::create(paramsMembersMap), true); return CSmartSchema(CObjectSchemaItem::create(rootMembersMap)); } @@ -318,51 +317,43 @@ class SmartObjectConvertionTimeTest : public ::testing::Test { TSchemaItemParameter(2000000000), TSchemaItemParameter()); - std::map schemaMembersMap; + std::map schemaMembersMap; - schemaMembersMap["success"] = - CObjectSchemaItem::SMember(success_SchemaItem, true); - schemaMembersMap["resultCode"] = - CObjectSchemaItem::SMember(resultCode_SchemaItem, true); - schemaMembersMap["info"] = - CObjectSchemaItem::SMember(info_SchemaItem, false); - schemaMembersMap["tryAgainTime"] = - CObjectSchemaItem::SMember(tryAgainTime_SchemaItem, true); + schemaMembersMap["success"] = SMember(success_SchemaItem, true); + schemaMembersMap["resultCode"] = SMember(resultCode_SchemaItem, true); + schemaMembersMap["info"] = SMember(info_SchemaItem, false); + schemaMembersMap["tryAgainTime"] = SMember(tryAgainTime_SchemaItem, true); - std::map paramsMembersMap; + std::map paramsMembersMap; paramsMembersMap [ns_smart_device_link::ns_json_handler::strings::S_FUNCTION_ID] = - CObjectSchemaItem::SMember( - TEnumSchemaItem::create( - functionId_allowedEnumSubsetValues), - true); + SMember(TEnumSchemaItem::create( + functionId_allowedEnumSubsetValues), + true); paramsMembersMap [ns_smart_device_link::ns_json_handler::strings::S_MESSAGE_TYPE] = - CObjectSchemaItem::SMember( - TEnumSchemaItem::create( - messageType_allowedEnumSubsetValues), - true); + SMember(TEnumSchemaItem::create( + messageType_allowedEnumSubsetValues), + true); paramsMembersMap [ns_smart_device_link::ns_json_handler::strings::S_CORRELATION_ID] = - CObjectSchemaItem::SMember(TNumberSchemaItem::create(), true); + SMember(TNumberSchemaItem::create(), true); paramsMembersMap [ns_smart_device_link::ns_json_handler::strings::S_PROTOCOL_VERSION] = - CObjectSchemaItem::SMember( + SMember( TNumberSchemaItem::create(TSchemaItemParameter(1), TSchemaItemParameter(2)), true); paramsMembersMap [ns_smart_device_link::ns_json_handler::strings::S_PROTOCOL_TYPE] = - CObjectSchemaItem::SMember(TNumberSchemaItem::create(), true); + SMember(TNumberSchemaItem::create(), true); - std::map rootMembersMap; + std::map rootMembersMap; rootMembersMap [ns_smart_device_link::ns_json_handler::strings::S_MSG_PARAMS] = - CObjectSchemaItem::SMember( - CObjectSchemaItem::create(schemaMembersMap), true); + SMember(CObjectSchemaItem::create(schemaMembersMap), true); rootMembersMap[ns_smart_device_link::ns_json_handler::strings::S_PARAMS] = - CObjectSchemaItem::SMember(CObjectSchemaItem::create(paramsMembersMap), - true); + SMember(CObjectSchemaItem::create(paramsMembersMap), true); return CSmartSchema(CObjectSchemaItem::create(rootMembersMap)); } }; @@ -783,5 +774,5 @@ const test::components::SmartObjects::SmartObjectConvertionTimeTest:: MessageTypeTest::response, test::components::SmartObjects::SmartObjectConvertionTimeTest:: MessageTypeTest::notification}; -} -} +} // namespace ns_smart_objects +} // namespace ns_smart_device_link diff --git a/src/components/smart_objects/test/SmartObjectDraft_test.cc b/src/components/smart_objects/test/SmartObjectDraft_test.cc index cfb6785db7b..d2382be51d2 100644 --- a/src/components/smart_objects/test/SmartObjectDraft_test.cc +++ b/src/components/smart_objects/test/SmartObjectDraft_test.cc @@ -37,8 +37,8 @@ #include "smart_objects/smart_object.h" -using ::testing::ElementsAre; using ::testing::ContainerEq; +using ::testing::ElementsAre; namespace test { namespace components { diff --git a/src/components/smart_objects/test/map_performance_test.cc b/src/components/smart_objects/test/map_performance_test.cc index b0544a94d43..be29a93553a 100644 --- a/src/components/smart_objects/test/map_performance_test.cc +++ b/src/components/smart_objects/test/map_performance_test.cc @@ -30,9 +30,9 @@ * POSSIBILITY OF SUCH DAMAGE. */ +#include #include #include -#include #include "gmock/gmock.h" @@ -59,7 +59,7 @@ void MakeMapObject(Map& obj, const int size) { obj[i_key] = array; } } -} +} // namespace TEST(SmartObjectPerformanceTest, SmartObjectMapPerformance) { Map object; diff --git a/src/components/smart_objects/test/smart_object_performance_test.cc b/src/components/smart_objects/test/smart_object_performance_test.cc index 11273e332ff..ebf39e6b5ce 100644 --- a/src/components/smart_objects/test/smart_object_performance_test.cc +++ b/src/components/smart_objects/test/smart_object_performance_test.cc @@ -30,8 +30,8 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include #include +#include #include "gmock/gmock.h" @@ -58,7 +58,7 @@ void MakeMapObject(SmartObject& obj, const int size) { obj[i_key] = array; } } -} +} // namespace TEST(SmartObjectPerformanceTest, SmartObjectPerformance) { SmartObject object; diff --git a/src/components/telemetry_monitor/CMakeLists.txt b/src/components/telemetry_monitor/CMakeLists.txt index 093413ef3b1..a9c0e142246 100644 --- a/src/components/telemetry_monitor/CMakeLists.txt +++ b/src/components/telemetry_monitor/CMakeLists.txt @@ -63,7 +63,7 @@ set(LIBRARIES HMI_API MOBILE_API Utils - Policy + PolicyStatic ) add_library("TelemetryMonitor" ${SOURCES}) diff --git a/src/components/telemetry_monitor/include/telemetry_monitor/application_manager_metric_wrapper.h b/src/components/telemetry_monitor/include/telemetry_monitor/application_manager_metric_wrapper.h index eabaf0a5e43..7ee5729c9b9 100644 --- a/src/components/telemetry_monitor/include/telemetry_monitor/application_manager_metric_wrapper.h +++ b/src/components/telemetry_monitor/include/telemetry_monitor/application_manager_metric_wrapper.h @@ -35,8 +35,8 @@ #include -#include "telemetry_monitor/metric_wrapper.h" #include "telemetry_monitor/application_manager_observer.h" +#include "telemetry_monitor/metric_wrapper.h" namespace telemetry_monitor { @@ -48,5 +48,5 @@ class ApplicationManagerMetricWrapper : public MetricWrapper { message_metric; virtual Json::Value GetJsonMetric(); }; -} +} // namespace telemetry_monitor #endif // SRC_COMPONENTS_TELEMETRY_MONITOR_INCLUDE_TELEMETRY_MONITOR_APPLICATION_MANAGER_METRIC_WRAPPER_H_ diff --git a/src/components/telemetry_monitor/include/telemetry_monitor/application_manager_observer.h b/src/components/telemetry_monitor/include/telemetry_monitor/application_manager_observer.h index 31a3ceea123..826bc66c7f0 100644 --- a/src/components/telemetry_monitor/include/telemetry_monitor/application_manager_observer.h +++ b/src/components/telemetry_monitor/include/telemetry_monitor/application_manager_observer.h @@ -33,9 +33,9 @@ #ifndef SRC_COMPONENTS_TELEMETRY_MONITOR_INCLUDE_TELEMETRY_MONITOR_APPLICATION_MANAGER_OBSERVER_H_ #define SRC_COMPONENTS_TELEMETRY_MONITOR_INCLUDE_TELEMETRY_MONITOR_APPLICATION_MANAGER_OBSERVER_H_ -#include "utils/message_queue.h" #include "application_manager/telemetry_observer.h" #include "telemetry_monitor/application_manager_metric_wrapper.h" +#include "utils/message_queue.h" namespace telemetry_monitor { @@ -50,5 +50,5 @@ class ApplicationManagerObserver private: TelemetryMonitor* telemetry_monitor_; }; -} +} // namespace telemetry_monitor #endif // SRC_COMPONENTS_TELEMETRY_MONITOR_INCLUDE_TELEMETRY_MONITOR_APPLICATION_MANAGER_OBSERVER_H_ diff --git a/src/components/telemetry_monitor/include/telemetry_monitor/json_keys.h b/src/components/telemetry_monitor/include/telemetry_monitor/json_keys.h index 899c76b2e8e..94911bcaefe 100644 --- a/src/components/telemetry_monitor/include/telemetry_monitor/json_keys.h +++ b/src/components/telemetry_monitor/include/telemetry_monitor/json_keys.h @@ -47,6 +47,6 @@ const char connection_key[] = "connection_key"; const char stime[] = "stime"; const char utime[] = "utime"; const char memory[] = "RAM"; -} -} +} // namespace strings +} // namespace telemetry_monitor #endif // SRC_COMPONENTS_TELEMETRY_MONITOR_INCLUDE_TELEMETRY_MONITOR_JSON_KEYS_H_ diff --git a/src/components/telemetry_monitor/include/telemetry_monitor/metric_wrapper.h b/src/components/telemetry_monitor/include/telemetry_monitor/metric_wrapper.h index 431e255c7b7..f69efada82c 100644 --- a/src/components/telemetry_monitor/include/telemetry_monitor/metric_wrapper.h +++ b/src/components/telemetry_monitor/include/telemetry_monitor/metric_wrapper.h @@ -34,8 +34,8 @@ #define SRC_COMPONENTS_TELEMETRY_MONITOR_INCLUDE_TELEMETRY_MONITOR_METRIC_WRAPPER_H_ #include -#include "utils/resource_usage.h" #include "json/json.h" +#include "utils/resource_usage.h" namespace telemetry_monitor { diff --git a/src/components/telemetry_monitor/include/telemetry_monitor/protocol_handler_metric_wrapper.h b/src/components/telemetry_monitor/include/telemetry_monitor/protocol_handler_metric_wrapper.h index dfe7f4b9641..a3af8e7048b 100644 --- a/src/components/telemetry_monitor/include/telemetry_monitor/protocol_handler_metric_wrapper.h +++ b/src/components/telemetry_monitor/include/telemetry_monitor/protocol_handler_metric_wrapper.h @@ -35,8 +35,8 @@ #include -#include "telemetry_monitor/metric_wrapper.h" #include "protocol_handler_observer.h" +#include "telemetry_monitor/metric_wrapper.h" namespace telemetry_monitor { 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 0d31573d8eb..b7d8f6da2b3 100644 --- a/src/components/telemetry_monitor/include/telemetry_monitor/telemetry_monitor.h +++ b/src/components/telemetry_monitor/include/telemetry_monitor/telemetry_monitor.h @@ -35,16 +35,16 @@ #include -#include "utils/message_queue.h" -#include "utils/threads/thread.h" -#include "utils/threads/thread_delegate.h" -#include "telemetry_monitor/metric_wrapper.h" -#include "telemetry_monitor/application_manager_observer.h" #include "application_manager/application_manager.h" +#include "protocol_handler/protocol_handler_impl.h" +#include "protocol_handler_observer.h" +#include "telemetry_monitor/application_manager_observer.h" +#include "telemetry_monitor/metric_wrapper.h" #include "telemetry_monitor/transport_manager_observer.h" #include "transport_manager/transport_manager_impl.h" -#include "protocol_handler_observer.h" -#include "protocol_handler/protocol_handler_impl.h" +#include "utils/message_queue.h" +#include "utils/threads/thread.h" +#include "utils/threads/thread_delegate.h" namespace telemetry_monitor { @@ -78,12 +78,13 @@ class TelemetryMonitor { public: TelemetryMonitor(const std::string& server_address, uint16_t port); virtual ~TelemetryMonitor(); - virtual void Init(TelemetryObservable* - protocol_handler, - TelemetryObservable< - application_manager::AMTelemetryObserver>* app_manager, - TelemetryObservable* - transport_manager); + virtual void Init( + TelemetryObservable* + protocol_handler, + TelemetryObservable* + app_manager, + TelemetryObservable* + transport_manager); virtual void Stop(); virtual void Start(); virtual void SendMetric(std::shared_ptr metric); 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 d0bf4ba5bbc..f79e27d2a04 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 @@ -34,8 +34,8 @@ #define SRC_COMPONENTS_TELEMETRY_MONITOR_INCLUDE_TELEMETRY_MONITOR_TRANSPORT_MANAGER_OBSERVER_H_ #include "transport_manager/telemetry_observer.h" -#include "utils/message_queue.h" #include "utils/date_time.h" +#include "utils/message_queue.h" namespace telemetry_monitor { 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 006aac196f6..90c5ffb87e2 100644 --- a/src/components/telemetry_monitor/src/application_manager_metric_wrapper.cc +++ b/src/components/telemetry_monitor/src/application_manager_metric_wrapper.cc @@ -31,8 +31,8 @@ */ #include "telemetry_monitor/application_manager_metric_wrapper.h" -#include "telemetry_monitor/json_keys.h" #include "application_manager/smart_object_keys.h" +#include "telemetry_monitor/json_keys.h" #include "utils/convert_utils.h" namespace telemetry_monitor { diff --git a/src/components/telemetry_monitor/src/application_manager_observer.cc b/src/components/telemetry_monitor/src/application_manager_observer.cc index 1e621c8a6e4..1a18d87ad8a 100644 --- a/src/components/telemetry_monitor/src/application_manager_observer.cc +++ b/src/components/telemetry_monitor/src/application_manager_observer.cc @@ -31,8 +31,8 @@ */ #include "telemetry_monitor/application_manager_observer.h" -#include "telemetry_monitor/telemetry_monitor.h" #include "telemetry_monitor/application_manager_metric_wrapper.h" +#include "telemetry_monitor/telemetry_monitor.h" namespace telemetry_monitor { diff --git a/src/components/telemetry_monitor/src/metric_wrapper.cc b/src/components/telemetry_monitor/src/metric_wrapper.cc index 10b694c5e60..8b2ba6f220b 100644 --- a/src/components/telemetry_monitor/src/metric_wrapper.cc +++ b/src/components/telemetry_monitor/src/metric_wrapper.cc @@ -71,4 +71,4 @@ void MetricWrapper::Clear() { MetricWrapper::~MetricWrapper() { Clear(); } -} +} // namespace telemetry_monitor diff --git a/src/components/telemetry_monitor/src/protocol_handler_observer.cc b/src/components/telemetry_monitor/src/protocol_handler_observer.cc index 19b04da3922..e696e58506b 100644 --- a/src/components/telemetry_monitor/src/protocol_handler_observer.cc +++ b/src/components/telemetry_monitor/src/protocol_handler_observer.cc @@ -30,10 +30,10 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include "utils/date_time.h" #include "telemetry_monitor/protocol_handler_observer.h" #include "telemetry_monitor/protocol_handler_metric_wrapper.h" #include "telemetry_monitor/telemetry_monitor.h" +#include "utils/date_time.h" namespace telemetry_monitor { diff --git a/src/components/telemetry_monitor/src/telemetry_monitor.cc b/src/components/telemetry_monitor/src/telemetry_monitor.cc index d62724a479e..e2f45b75761 100644 --- a/src/components/telemetry_monitor/src/telemetry_monitor.cc +++ b/src/components/telemetry_monitor/src/telemetry_monitor.cc @@ -32,12 +32,12 @@ #include "telemetry_monitor/telemetry_monitor.h" -#include -#include +#include +#include #include +#include #include -#include -#include +#include #include #include "transport_manager/transport_manager_default.h" 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 789da92eaf3..3a89c9245a3 100644 --- a/src/components/telemetry_monitor/src/transport_manager_metric_wrapper.cc +++ b/src/components/telemetry_monitor/src/transport_manager_metric_wrapper.cc @@ -31,9 +31,9 @@ */ #include "telemetry_monitor/transport_manager_metric_wrapper.h" +#include "application_manager/smart_object_keys.h" #include "json/json.h" #include "telemetry_monitor/json_keys.h" -#include "application_manager/smart_object_keys.h" namespace telemetry_monitor { diff --git a/src/components/telemetry_monitor/src/transport_manager_observer.cc b/src/components/telemetry_monitor/src/transport_manager_observer.cc index 25817d6c738..15338eddff0 100644 --- a/src/components/telemetry_monitor/src/transport_manager_observer.cc +++ b/src/components/telemetry_monitor/src/transport_manager_observer.cc @@ -33,8 +33,8 @@ #include -#include "telemetry_monitor/transport_manager_metric_wrapper.h" #include "telemetry_monitor/telemetry_monitor.h" +#include "telemetry_monitor/transport_manager_metric_wrapper.h" namespace telemetry_monitor { 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 2e6eaad9d86..4af5ba82b5b 100644 --- a/src/components/telemetry_monitor/test/application_manager_metric_test.cc +++ b/src/components/telemetry_monitor/test/application_manager_metric_test.cc @@ -30,11 +30,11 @@ * POSSIBILITY OF SUCH DAMAGE. */ +#include "application_manager/smart_object_keys.h" #include "gtest/gtest.h" +#include "telemetry_monitor/application_manager_metric_wrapper.h" #include "telemetry_monitor/json_keys.h" #include "utils/resource_usage.h" -#include "application_manager/smart_object_keys.h" -#include "telemetry_monitor/application_manager_metric_wrapper.h" namespace test { namespace components { diff --git a/src/components/telemetry_monitor/test/application_manager_observer_test.cc b/src/components/telemetry_monitor/test/application_manager_observer_test.cc index deecfa57b74..daf38904858 100644 --- a/src/components/telemetry_monitor/test/application_manager_observer_test.cc +++ b/src/components/telemetry_monitor/test/application_manager_observer_test.cc @@ -30,11 +30,11 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include "gtest/gtest.h" -#include "telemetry_monitor/mock_telemetry_monitor.h" +#include "telemetry_monitor/application_manager_observer.h" #include "application_manager/telemetry_observer.h" +#include "gtest/gtest.h" #include "telemetry_monitor/application_manager_metric_wrapper.h" -#include "telemetry_monitor/application_manager_observer.h" +#include "telemetry_monitor/mock_telemetry_monitor.h" #include "telemetry_monitor/telemetry_monitor.h" diff --git a/src/components/telemetry_monitor/test/include/telemetry_monitor/mock_telemetry_monitor.h b/src/components/telemetry_monitor/test/include/telemetry_monitor/mock_telemetry_monitor.h index c2aebe72b30..9b41d5a9acf 100644 --- a/src/components/telemetry_monitor/test/include/telemetry_monitor/mock_telemetry_monitor.h +++ b/src/components/telemetry_monitor/test/include/telemetry_monitor/mock_telemetry_monitor.h @@ -35,8 +35,8 @@ #include #include "gmock/gmock.h" -#include "telemetry_monitor/telemetry_monitor.h" #include "telemetry_monitor/metric_wrapper.h" +#include "telemetry_monitor/telemetry_monitor.h" namespace test { namespace components { @@ -51,7 +51,7 @@ class MockTelemetryMonitor : public telemetry_monitor::TelemetryMonitor { MOCK_METHOD1(SendMetric, void(std::shared_ptr metric)); }; -} // namespace transport_manager_test +} // namespace telemetry_monitor_test } // namespace components } // namespace test #endif // SRC_COMPONENTS_TELEMETRY_MONITOR_TEST_INCLUDE_TELEMETRY_MONITOR_MOCK_TELEMETRY_MONITOR_H_ diff --git a/src/components/telemetry_monitor/test/metric_wrapper_test.cc b/src/components/telemetry_monitor/test/metric_wrapper_test.cc index f1e3c77db4a..5501877ec8f 100644 --- a/src/components/telemetry_monitor/test/metric_wrapper_test.cc +++ b/src/components/telemetry_monitor/test/metric_wrapper_test.cc @@ -30,10 +30,10 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include "gtest/gtest.h" #include "telemetry_monitor/metric_wrapper.h" -#include "telemetry_monitor/json_keys.h" +#include "gtest/gtest.h" #include "json/json.h" +#include "telemetry_monitor/json_keys.h" #include "utils/resource_usage.h" namespace test { 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 c9130411e78..8662321be39 100644 --- a/src/components/telemetry_monitor/test/protocol_handler_metric_test.cc +++ b/src/components/telemetry_monitor/test/protocol_handler_metric_test.cc @@ -31,11 +31,11 @@ */ #include "gtest/gtest.h" -#include "telemetry_monitor/json_keys.h" #include "json/json.h" -#include "utils/resource_usage.h" -#include "telemetry_monitor/protocol_handler_metric_wrapper.h" #include "protocol_handler/telemetry_observer.h" +#include "telemetry_monitor/json_keys.h" +#include "telemetry_monitor/protocol_handler_metric_wrapper.h" +#include "utils/resource_usage.h" namespace test { namespace components { 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 587bf21ce66..b74434da3ca 100644 --- a/src/components/telemetry_monitor/test/protocol_handler_observer_test.cc +++ b/src/components/telemetry_monitor/test/protocol_handler_observer_test.cc @@ -31,9 +31,9 @@ */ #include "gtest/gtest.h" -#include "telemetry_monitor/telemetry_monitor.h" -#include "telemetry_monitor/mock_telemetry_monitor.h" #include "protocol_handler/telemetry_observer.h" +#include "telemetry_monitor/mock_telemetry_monitor.h" +#include "telemetry_monitor/telemetry_monitor.h" namespace test { namespace components { diff --git a/src/components/telemetry_monitor/test/telemetry_monitor_test.cc b/src/components/telemetry_monitor/test/telemetry_monitor_test.cc index b8d3f9063f2..f7b74ac2787 100644 --- a/src/components/telemetry_monitor/test/telemetry_monitor_test.cc +++ b/src/components/telemetry_monitor/test/telemetry_monitor_test.cc @@ -30,19 +30,19 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include "gtest/gtest.h" #include "telemetry_monitor/telemetry_monitor.h" -#include "protocol_handler/telemetry_observer.h" -#include "protocol_handler/protocol_handler.h" +#include "connection_handler/mock_connection_handler.h" +#include "gtest/gtest.h" #include "protocol_handler//mock_protocol_handler.h" -#include "protocol_handler/mock_session_observer.h" #include "protocol_handler/mock_protocol_handler_settings.h" -#include "connection_handler/mock_connection_handler.h" -#include "transport_manager/mock_transport_manager.h" +#include "protocol_handler/mock_session_observer.h" +#include "protocol_handler/protocol_handler.h" +#include "protocol_handler/telemetry_observer.h" #include "telemetry_monitor/mock_telemetry_observable.h" +#include "transport_manager/mock_transport_manager.h" -using testing::Return; using testing::_; +using testing::Return; namespace test { namespace components { 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 40caa6e0d61..3b3ac075771 100644 --- a/src/components/telemetry_monitor/test/transport_manager_metric_test.cc +++ b/src/components/telemetry_monitor/test/transport_manager_metric_test.cc @@ -31,11 +31,11 @@ */ #include "gtest/gtest.h" -#include "telemetry_monitor/json_keys.h" #include "json/json.h" -#include "utils/resource_usage.h" -#include "telemetry_monitor/transport_manager_metric_wrapper.h" #include "protocol_handler/telemetry_observer.h" +#include "telemetry_monitor/json_keys.h" +#include "telemetry_monitor/transport_manager_metric_wrapper.h" +#include "utils/resource_usage.h" namespace test { namespace components { diff --git a/src/components/telemetry_monitor/test/transport_manager_observer_test.cc b/src/components/telemetry_monitor/test/transport_manager_observer_test.cc index adc857d6cc0..c0501ac45ec 100644 --- a/src/components/telemetry_monitor/test/transport_manager_observer_test.cc +++ b/src/components/telemetry_monitor/test/transport_manager_observer_test.cc @@ -30,11 +30,11 @@ * POSSIBILITY OF SUCH DAMAGE. */ +#include "telemetry_monitor/transport_manager_observer.h" #include "gtest/gtest.h" -#include "telemetry_monitor/mock_telemetry_monitor.h" #include "protocol_handler/telemetry_observer.h" +#include "telemetry_monitor/mock_telemetry_monitor.h" #include "telemetry_monitor/transport_manager_metric_wrapper.h" -#include "telemetry_monitor/transport_manager_observer.h" namespace test { namespace components { @@ -47,7 +47,7 @@ TEST(TransportManagerObserverTest, MessageProcess) { MockTelemetryMonitor mock_telemetry_monitor; TransportManagerObserver tr_observer(&mock_telemetry_monitor); protocol_handler::RawMessage* ptr = - new ::protocol_handler::RawMessage(0, 0, NULL, 0); + new ::protocol_handler::RawMessage(0, 0, NULL, 0, false); tr_observer.StartRawMsg(ptr); EXPECT_CALL(mock_telemetry_monitor, SendMetric(_)); tr_observer.StopRawMsg(ptr); diff --git a/src/components/test_main.cc b/src/components/test_main.cc index 61606756fe5..8912ed9bd2c 100644 --- a/src/components/test_main.cc +++ b/src/components/test_main.cc @@ -1,7 +1,7 @@ +#include #include "gmock/gmock.h" -#include "utils/logger.h" #include "utils/custom_string.h" -#include +#include "utils/logger.h" CREATE_LOGGERPTR_GLOBAL(logger_, "SDLMain") int main(int argc, char** argv) { diff --git a/src/components/transport_manager/include/transport_manager/bluetooth/bluetooth_device_scanner.h b/src/components/transport_manager/include/transport_manager/bluetooth/bluetooth_device_scanner.h index dc38a971f57..768d9ebb544 100644 --- a/src/components/transport_manager/include/transport_manager/bluetooth/bluetooth_device_scanner.h +++ b/src/components/transport_manager/include/transport_manager/bluetooth/bluetooth_device_scanner.h @@ -39,9 +39,9 @@ #include #include #include +#include #include #include -#include #include "transport_manager/transport_adapter/device_scanner.h" #include "utils/conditional_variable.h" @@ -70,6 +70,11 @@ class BluetoothDeviceScanner : public DeviceScanner { BluetoothDeviceScanner(TransportAdapterController* controller, bool auto_repeat_search, int repeat_search_pause_sec); + + BluetoothDeviceScanner(TransportAdapterController* controller, + bool auto_repeat_search, + int repeat_search_pause_sec, + const uint8_t* smart_device_link_service_uuid_data); /** * @brief Destructor. */ diff --git a/src/components/transport_manager/include/transport_manager/cloud/cloud_device.h b/src/components/transport_manager/include/transport_manager/cloud/cloud_device.h index 9c25be2a3e0..15d23bba7fe 100644 --- a/src/components/transport_manager/include/transport_manager/cloud/cloud_device.h +++ b/src/components/transport_manager/include/transport_manager/cloud/cloud_device.h @@ -55,7 +55,7 @@ class CloudDevice : public Device { public: CloudDevice(std::string& host, std::string& port, std::string& name); - CloudDevice(CloudAppEndpoint endpoint, std::string& name); + CloudDevice(CloudAppEndpoint& endpoint, std::string& name); virtual const std::string& GetHost() const; diff --git a/src/components/transport_manager/include/transport_manager/cloud/websocket_client_connection.h b/src/components/transport_manager/include/transport_manager/cloud/websocket_client_connection.h index a726524af20..76c8ca73cd2 100644 --- a/src/components/transport_manager/include/transport_manager/cloud/websocket_client_connection.h +++ b/src/components/transport_manager/include/transport_manager/cloud/websocket_client_connection.h @@ -36,11 +36,11 @@ #ifndef SRC_COMPONENTS_TRANSPORT_MANAGER_INCLUDE_TRANSPORT_MANAGER_CLOUD_WEBSOCKET_CLIENT_CONNECTION_H_ #define SRC_COMPONENTS_TRANSPORT_MANAGER_INCLUDE_TRANSPORT_MANAGER_CLOUD_WEBSOCKET_CLIENT_CONNECTION_H_ -#include -#include #include #include #include +#include +#include #ifdef ENABLE_SECURITY #include #include @@ -51,11 +51,11 @@ #include #include #include -#include "transport_manager/transport_adapter/connection.h" #include "transport_manager/cloud/cloud_websocket_transport_adapter.h" -#include "utils/threads/thread.h" -#include "utils/threads/message_loop_thread.h" +#include "transport_manager/transport_adapter/connection.h" #include "utils/message_queue.h" +#include "utils/threads/message_loop_thread.h" +#include "utils/threads/thread.h" namespace websocket = boost::beast::websocket; // from diff --git a/src/components/transport_manager/include/transport_manager/iap2_emulation/iap2_transport_adapter.h b/src/components/transport_manager/include/transport_manager/iap2_emulation/iap2_transport_adapter.h index e53a472bcb9..a802a64afa2 100644 --- a/src/components/transport_manager/include/transport_manager/iap2_emulation/iap2_transport_adapter.h +++ b/src/components/transport_manager/include/transport_manager/iap2_emulation/iap2_transport_adapter.h @@ -33,9 +33,9 @@ #ifndef SRC_COMPONENTS_TRANSPORT_MANAGER_INCLUDE_TRANSPORT_MANAGER_IAP2_EMULATION_IAP2_TRANSPORT_ADAPTER_H_ #define SRC_COMPONENTS_TRANSPORT_MANAGER_INCLUDE_TRANSPORT_MANAGER_IAP2_EMULATION_IAP2_TRANSPORT_ADAPTER_H_ +#include "resumption/last_state.h" #include "transport_manager/tcp/tcp_transport_adapter.h" #include "transport_manager/transport_manager_settings.h" -#include "resumption/last_state.h" #include "utils/macro.h" #include "utils/threads/thread_delegate.h" @@ -108,8 +108,8 @@ class IAP2USBEmulationTransportAdapter : public TcpTransportAdapter { const TransportManagerSettings& settings); /** - * Destructor - */ + * Destructor + */ ~IAP2USBEmulationTransportAdapter(); /** 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 159b5ff21da..272b28b6b20 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,11 +1,11 @@ #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_ -#include #include +#include -#include "utils/macro.h" #include "transport_manager/tcp/network_interface_listener.h" +#include "utils/macro.h" namespace transport_manager { namespace transport_adapter { 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 0f9529d8d8f..f033d35bf7d 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 @@ -36,9 +36,9 @@ #ifndef SRC_COMPONENTS_TRANSPORT_MANAGER_INCLUDE_TRANSPORT_MANAGER_TCP_TCP_CLIENT_LISTENER_H_ #define SRC_COMPONENTS_TRANSPORT_MANAGER_INCLUDE_TRANSPORT_MANAGER_TCP_TCP_CLIENT_LISTENER_H_ +#include "transport_manager/transport_adapter/client_connection_listener.h" #include "utils/lock.h" #include "utils/threads/thread_delegate.h" -#include "transport_manager/transport_adapter/client_connection_listener.h" class Thread; struct in_addr; @@ -108,6 +108,10 @@ class TcpClientListener : public ClientConnectionListener { */ virtual TransportAdapter::Error StopListening(); + TransportAdapter::Error SuspendListening() OVERRIDE; + + TransportAdapter::Error ResumeListening() OVERRIDE; + /** * @brief Called from NetworkInterfaceListener when IP address of the network * interface is changed. diff --git a/src/components/transport_manager/include/transport_manager/tcp/tcp_device.h b/src/components/transport_manager/include/transport_manager/tcp/tcp_device.h index 7aa0b726878..6e7a306879a 100644 --- a/src/components/transport_manager/include/transport_manager/tcp/tcp_device.h +++ b/src/components/transport_manager/include/transport_manager/tcp/tcp_device.h @@ -36,19 +36,19 @@ #ifndef SRC_COMPONENTS_TRANSPORT_MANAGER_INCLUDE_TRANSPORT_MANAGER_TCP_TCP_DEVICE_H_ #define SRC_COMPONENTS_TRANSPORT_MANAGER_INCLUDE_TRANSPORT_MANAGER_TCP_TCP_DEVICE_H_ -#include -#include -#include #include +#include +#include #include -#include +#include #include +#include #include #include -#include "utils/lock.h" #include "transport_manager/transport_adapter/device.h" +#include "utils/lock.h" namespace transport_manager { namespace transport_adapter { 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 a38255966b8..b4f321d23f6 100644 --- a/src/components/transport_manager/include/transport_manager/telemetry_observer.h +++ b/src/components/transport_manager/include/transport_manager/telemetry_observer.h @@ -33,8 +33,8 @@ #ifndef SRC_COMPONENTS_TRANSPORT_MANAGER_INCLUDE_TRANSPORT_MANAGER_TELEMETRY_OBSERVER_H_ #define SRC_COMPONENTS_TRANSPORT_MANAGER_INCLUDE_TRANSPORT_MANAGER_TELEMETRY_OBSERVER_H_ -#include "transport_manager/common.h" #include "protocol/raw_message.h" +#include "transport_manager/common.h" #include "utils/date_time.h" namespace transport_manager { @@ -51,5 +51,5 @@ class TMTelemetryObserver { virtual ~TMTelemetryObserver() {} }; -} // transport_manager +} // namespace transport_manager #endif // SRC_COMPONENTS_TRANSPORT_MANAGER_INCLUDE_TRANSPORT_MANAGER_TELEMETRY_OBSERVER_H_ diff --git a/src/components/transport_manager/include/transport_manager/transport_adapter/client_connection_listener.h b/src/components/transport_manager/include/transport_manager/transport_adapter/client_connection_listener.h index f905e11c43e..e49a355e538 100644 --- a/src/components/transport_manager/include/transport_manager/transport_adapter/client_connection_listener.h +++ b/src/components/transport_manager/include/transport_manager/transport_adapter/client_connection_listener.h @@ -75,6 +75,18 @@ class ClientConnectionListener { */ virtual TransportAdapter::Error StopListening() = 0; + /** + * @brief Suspends current listening thread + * @return Error information about possible reason of failure. + */ + virtual TransportAdapter::Error SuspendListening() = 0; + + /** + * @brief Resumes current listening thread + * @return Error information about possible reason of failure. + */ + virtual TransportAdapter::Error ResumeListening() = 0; + /** * @brief Destructor. */ diff --git a/src/components/transport_manager/include/transport_manager/transport_adapter/threaded_socket_connection.h b/src/components/transport_manager/include/transport_manager/transport_adapter/threaded_socket_connection.h index f1c679c1238..11123ceb1ca 100644 --- a/src/components/transport_manager/include/transport_manager/transport_adapter/threaded_socket_connection.h +++ b/src/components/transport_manager/include/transport_manager/transport_adapter/threaded_socket_connection.h @@ -38,11 +38,11 @@ #include #include -#include "transport_manager/transport_adapter/connection.h" -#include "protocol/common.h" #include -#include "utils/threads/thread_delegate.h" +#include "protocol/common.h" +#include "transport_manager/transport_adapter/connection.h" #include "utils/lock.h" +#include "utils/threads/thread_delegate.h" using ::transport_manager::transport_adapter::Connection; 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 7a0a37758c4..72a67a3087c 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 @@ -33,9 +33,9 @@ #ifndef SRC_COMPONENTS_TRANSPORT_MANAGER_INCLUDE_TRANSPORT_MANAGER_TRANSPORT_ADAPTER_TRANSPORT_ADAPTER_CONTROLLER_H_ #define SRC_COMPONENTS_TRANSPORT_MANAGER_INCLUDE_TRANSPORT_MANAGER_TRANSPORT_ADAPTER_TRANSPORT_ADAPTER_CONTROLLER_H_ -#include "transport_manager/transport_adapter/device.h" -#include "transport_manager/transport_adapter/connection.h" #include "protocol/common.h" +#include "transport_manager/transport_adapter/connection.h" +#include "transport_manager/transport_adapter/device.h" namespace transport_manager { namespace transport_adapter { @@ -174,12 +174,12 @@ class TransportAdapterController { const ApplicationHandle& app_handle) = 0; /** - * @brief Launch OnDataReceiveDone event in the device adapter listener. - * - * @param device_handle Device unique identifier. - * @param app_handle Handle of application. - * @param message Smart pointer to the raw message. - */ + * @brief Launch OnDataReceiveDone event in the device adapter listener. + * + * @param device_handle Device unique identifier. + * @param app_handle Handle of application. + * @param message Smart pointer to the raw message. + */ virtual void DataReceiveDone(const DeviceUID& device_handle, const ApplicationHandle& app_handle, ::protocol_handler::RawMessagePtr message) = 0; 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 b30f1e35b25..0750b58aae5 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 @@ -33,21 +33,21 @@ #ifndef SRC_COMPONENTS_TRANSPORT_MANAGER_INCLUDE_TRANSPORT_MANAGER_TRANSPORT_ADAPTER_TRANSPORT_ADAPTER_IMPL_H_ #define SRC_COMPONENTS_TRANSPORT_MANAGER_INCLUDE_TRANSPORT_MANAGER_TRANSPORT_ADAPTER_TRANSPORT_ADAPTER_IMPL_H_ -#include -#include #include #include +#include +#include #include #include "utils/lock.h" #include "utils/rwlock.h" #include "utils/timer.h" +#include "resumption/last_state.h" +#include "transport_manager/transport_adapter/connection.h" #include "transport_manager/transport_adapter/transport_adapter.h" #include "transport_manager/transport_adapter/transport_adapter_controller.h" -#include "transport_manager/transport_adapter/connection.h" #include "transport_manager/transport_manager_settings.h" -#include "resumption/last_state.h" #ifdef TELEMETRY_MONITOR #include "transport_manager/telemetry_observer.h" @@ -202,19 +202,8 @@ class TransportAdapterImpl : public TransportAdapter, const ApplicationHandle& app_handle, const ::protocol_handler::RawMessagePtr data) OVERRIDE; - /** - * @brief Start client listener. - * - * @return Error information about possible reason of failure. - */ - TransportAdapter::Error StartClientListening() OVERRIDE; - - /** - * @brief Stop client listener. - * - * @return Error information about possible reason of failure. - */ - TransportAdapter::Error StopClientListening() OVERRIDE; + TransportAdapter::Error ChangeClientListening( + TransportAction required_change) OVERRIDE; /** * @brief Notify that device scanner is available. 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 a0e0a51c1e6..4db9a3b7104 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 @@ -33,9 +33,9 @@ #ifndef SRC_COMPONENTS_TRANSPORT_MANAGER_INCLUDE_TRANSPORT_MANAGER_TRANSPORT_ADAPTER_TRANSPORT_ADAPTER_LISTENER_H_ #define SRC_COMPONENTS_TRANSPORT_MANAGER_INCLUDE_TRANSPORT_MANAGER_TRANSPORT_ADAPTER_TRANSPORT_ADAPTER_LISTENER_H_ +#include "protocol/common.h" #include "transport_manager/common.h" #include "transport_manager/error.h" -#include "protocol/common.h" namespace transport_manager { namespace transport_adapter { @@ -307,6 +307,6 @@ class TransportAdapterListener { const TransportAdapter* transport_adapter) = 0; }; -} // transport_adapter namespace -} // transport_manager namespace +} // namespace transport_adapter +} // namespace transport_manager #endif // SRC_COMPONENTS_TRANSPORT_MANAGER_INCLUDE_TRANSPORT_MANAGER_TRANSPORT_ADAPTER_TRANSPORT_ADAPTER_LISTENER_H_ 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 0c9c6ef6a27..d00ae1c498a 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 @@ -34,8 +34,8 @@ #define SRC_COMPONENTS_TRANSPORT_MANAGER_INCLUDE_TRANSPORT_MANAGER_TRANSPORT_ADAPTER_TRANSPORT_ADAPTER_LISTENER_IMPL_H_ #include "transport_manager/common.h" -#include "transport_manager/transport_adapter/transport_adapter_listener.h" #include "transport_manager/transport_adapter/transport_adapter.h" +#include "transport_manager/transport_adapter/transport_adapter_listener.h" #include "transport_manager/transport_manager.h" namespace transport_manager { diff --git a/src/components/transport_manager/include/transport_manager/transport_manager_default.h b/src/components/transport_manager/include/transport_manager/transport_manager_default.h index 8039f9c9851..7fb0904fdf5 100644 --- a/src/components/transport_manager/include/transport_manager/transport_manager_default.h +++ b/src/components/transport_manager/include/transport_manager/transport_manager_default.h @@ -65,6 +65,6 @@ class TransportManagerDefault : public TransportManagerImpl { DISALLOW_COPY_AND_ASSIGN(TransportManagerDefault); }; -} +} // namespace transport_manager #endif // SRC_COMPONENTS_TRANSPORT_MANAGER_INCLUDE_TRANSPORT_MANAGER_TRANSPORT_MANAGER_DEFAULT_H_ 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 60303c1bca0..5e97a5567e7 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 @@ -33,29 +33,29 @@ #ifndef SRC_COMPONENTS_TRANSPORT_MANAGER_INCLUDE_TRANSPORT_MANAGER_TRANSPORT_MANAGER_IMPL_H_ #define SRC_COMPONENTS_TRANSPORT_MANAGER_INCLUDE_TRANSPORT_MANAGER_TRANSPORT_MANAGER_IMPL_H_ -#include -#include -#include -#include -#include #include -#include #include +#include +#include +#include +#include +#include +#include -#include "utils/timer.h" #include "utils/rwlock.h" +#include "utils/timer.h" +#include "protocol/common.h" +#include "transport_manager/transport_adapter/transport_adapter_listener_impl.h" #include "transport_manager/transport_manager.h" #include "transport_manager/transport_manager_listener.h" -#include "transport_manager/transport_adapter/transport_adapter_listener_impl.h" -#include "protocol/common.h" #ifdef TELEMETRY_MONITOR -#include "transport_manager/telemetry_observer.h" #include "telemetry_monitor/telemetry_observable.h" +#include "transport_manager/telemetry_observer.h" #endif // TELEMETRY_MONITOR -#include "utils/threads/message_loop_thread.h" #include "transport_manager/transport_adapter/transport_adapter_event.h" #include "transport_manager/transport_manager_settings.h" +#include "utils/threads/message_loop_thread.h" namespace transport_manager { @@ -74,10 +74,10 @@ class TransportManagerImpl public RawMessageLoopThread::Handler, public TransportAdapterEventLoopThread::Handler #ifdef TELEMETRY_MONITOR - , + , public telemetry_monitor::TelemetryObservable #endif // TELEMETRY_MONITOR - { +{ public: struct Connection { ConnectionUID id; @@ -132,6 +132,12 @@ class TransportManagerImpl */ virtual int Reinit() OVERRIDE; + virtual void Deinit() OVERRIDE; + + void StopEventsProcessing() OVERRIDE; + + void StartEventsProcessing() OVERRIDE; + /** * @brief Start scanning for new devices. * @@ -250,14 +256,8 @@ class TransportManagerImpl **/ int RemoveDevice(const DeviceHandle device) OVERRIDE; - /** - * @brief Turns on or off visibility of SDL to mobile devices - * when visibility is ON (on_off = true) mobile devices are able to connect - * otherwise ((on_off = false)) SDL is not visible from outside - * - * @return Code error. - */ - int Visibility(const bool& on_off) const OVERRIDE; + int PerformActionOnClients( + const TransportAction required_action) const OVERRIDE; /** * @brief OnDeviceListUpdated updates device list and sends appropriate @@ -327,9 +327,9 @@ class TransportManagerImpl private: /** - * @brief Structure that contains conversion functions (Device ID -> Device - * Handle; Device Handle -> Device ID) - */ + * @brief Structure that contains conversion functions (Device ID -> Device + * Handle; Device Handle -> Device ID) + */ struct Handle2GUIDConverter { /** * @brief ConversionTable Records uid/connection type/handle @@ -414,6 +414,10 @@ class TransportManagerImpl sync_primitives::Lock device_lock_; DeviceUID device_to_reconnect_; + std::atomic_bool events_processing_is_active_; + sync_primitives::Lock events_processing_lock_; + sync_primitives::ConditionalVariable events_processing_cond_var_; + /** * @brief Adds new incoming connection to connections list * @param c New connection @@ -421,18 +425,18 @@ class TransportManagerImpl void AddConnection(const ConnectionInternal& c); /** - * @brief Removes connection from connections list - * @param id Identifier of connection to be removed - * @param transport_adapter Pointer to transport adapter - * that holds connection - */ + * @brief Removes connection from connections list + * @param id Identifier of connection to be removed + * @param transport_adapter Pointer to transport adapter + * that holds connection + */ void RemoveConnection(const uint32_t id, transport_adapter::TransportAdapter* transport_adapter); /** - * @brief Deactivates all connections related to certain device - * @param device_uid Device unique identifier - */ + * @brief Deactivates all connections related to certain device + * @param device_uid Device unique identifier + */ void DeactivateDeviceConnections(const DeviceUID& device_uid); /** * @brief Returns connection from connections list by connection identifier @@ -452,14 +456,14 @@ class TransportManagerImpl const ApplicationHandle& application); /** - * @brief Returns active connection from connections list by device unique + * @brief Returns active connection from connections list by device unique * id - * and application handle - * (this method returns only active connections as opposed to previous one) - * @param device Device unique identifier - * @param application Application handle - * @return Pointer to connection or NULL if connection could not be found - */ + * and application handle + * (this method returns only active connections as opposed to previous one) + * @param device Device unique identifier + * @param application Application handle + * @return Pointer to connection or NULL if connection could not be found + */ ConnectionInternal* GetActiveConnection(const DeviceUID& device, const ApplicationHandle& application); diff --git a/src/components/transport_manager/include/transport_manager/usb/common.h b/src/components/transport_manager/include/transport_manager/usb/common.h index 1db1a83a3ab..d15e1fdd968 100644 --- a/src/components/transport_manager/include/transport_manager/usb/common.h +++ b/src/components/transport_manager/include/transport_manager/usb/common.h @@ -110,7 +110,7 @@ inline bool IsAppleDevice(const PlatformUsbDevice* device) { return IsAppleIAPDevice(device) || IsAppleIAP2Device(device); } -} // namespace -} // namespace +} // namespace transport_adapter +} // namespace transport_manager #endif // SRC_COMPONENTS_TRANSPORT_MANAGER_INCLUDE_TRANSPORT_MANAGER_USB_COMMON_H_ diff --git a/src/components/transport_manager/include/transport_manager/usb/libusb/platform_usb_device.h b/src/components/transport_manager/include/transport_manager/usb/libusb/platform_usb_device.h index baec1938b16..201f3787e00 100644 --- a/src/components/transport_manager/include/transport_manager/usb/libusb/platform_usb_device.h +++ b/src/components/transport_manager/include/transport_manager/usb/libusb/platform_usb_device.h @@ -36,8 +36,8 @@ #ifndef SRC_COMPONENTS_TRANSPORT_MANAGER_INCLUDE_TRANSPORT_MANAGER_USB_LIBUSB_PLATFORM_USB_DEVICE_H_ #define SRC_COMPONENTS_TRANSPORT_MANAGER_INCLUDE_TRANSPORT_MANAGER_USB_LIBUSB_PLATFORM_USB_DEVICE_H_ -#include #include +#include namespace transport_manager { diff --git a/src/components/transport_manager/include/transport_manager/usb/libusb/usb_connection.h b/src/components/transport_manager/include/transport_manager/usb/libusb/usb_connection.h index 5f6bd409576..2b7f6e41892 100644 --- a/src/components/transport_manager/include/transport_manager/usb/libusb/usb_connection.h +++ b/src/components/transport_manager/include/transport_manager/usb/libusb/usb_connection.h @@ -37,8 +37,8 @@ #include "utils/lock.h" -#include "transport_manager/transport_adapter/transport_adapter_controller.h" #include "transport_manager/transport_adapter/connection.h" +#include "transport_manager/transport_adapter/transport_adapter_controller.h" #include "transport_manager/usb/common.h" namespace transport_manager { diff --git a/src/components/transport_manager/include/transport_manager/usb/libusb/usb_handler.h b/src/components/transport_manager/include/transport_manager/usb/libusb/usb_handler.h index bed631ea2e7..6b15229522f 100644 --- a/src/components/transport_manager/include/transport_manager/usb/libusb/usb_handler.h +++ b/src/components/transport_manager/include/transport_manager/usb/libusb/usb_handler.h @@ -39,8 +39,8 @@ #include #include "transport_manager/transport_adapter/transport_adapter.h" -#include "transport_manager/usb/usb_control_transfer.h" #include "transport_manager/usb/libusb/platform_usb_device.h" +#include "transport_manager/usb/usb_control_transfer.h" #include "utils/threads/thread.h" diff --git a/src/components/transport_manager/include/transport_manager/usb/qnx/platform_usb_device.h b/src/components/transport_manager/include/transport_manager/usb/qnx/platform_usb_device.h index 9755a5eacdf..738675754d9 100644 --- a/src/components/transport_manager/include/transport_manager/usb/qnx/platform_usb_device.h +++ b/src/components/transport_manager/include/transport_manager/usb/qnx/platform_usb_device.h @@ -36,8 +36,8 @@ #ifndef SRC_COMPONENTS_TRANSPORT_MANAGER_INCLUDE_TRANSPORT_MANAGER_USB_QNX_PLATFORM_USB_DEVICE_H_ #define SRC_COMPONENTS_TRANSPORT_MANAGER_INCLUDE_TRANSPORT_MANAGER_USB_QNX_PLATFORM_USB_DEVICE_H_ -#include #include +#include namespace transport_manager { diff --git a/src/components/transport_manager/include/transport_manager/usb/qnx/usb_connection.h b/src/components/transport_manager/include/transport_manager/usb/qnx/usb_connection.h index e9f7344ee2c..ba7e263b4c6 100644 --- a/src/components/transport_manager/include/transport_manager/usb/qnx/usb_connection.h +++ b/src/components/transport_manager/include/transport_manager/usb/qnx/usb_connection.h @@ -38,8 +38,8 @@ #include "utils/lock.h" -#include "transport_manager/transport_adapter/transport_adapter_controller.h" #include "transport_manager/transport_adapter/connection.h" +#include "transport_manager/transport_adapter/transport_adapter_controller.h" #include "transport_manager/usb/common.h" namespace transport_manager { diff --git a/src/components/transport_manager/include/transport_manager/usb/qnx/usb_handler.h b/src/components/transport_manager/include/transport_manager/usb/qnx/usb_handler.h index c33e0f23618..53600309ec9 100644 --- a/src/components/transport_manager/include/transport_manager/usb/qnx/usb_handler.h +++ b/src/components/transport_manager/include/transport_manager/usb/qnx/usb_handler.h @@ -39,8 +39,8 @@ #include #include "transport_manager/transport_adapter/transport_adapter.h" -#include "transport_manager/usb/usb_control_transfer.h" #include "transport_manager/usb/qnx/platform_usb_device.h" +#include "transport_manager/usb/usb_control_transfer.h" namespace transport_manager { diff --git a/src/components/transport_manager/include/transport_manager/usb/usb_control_transfer.h b/src/components/transport_manager/include/transport_manager/usb/usb_control_transfer.h index 850902bea38..a47574353e9 100644 --- a/src/components/transport_manager/include/transport_manager/usb/usb_control_transfer.h +++ b/src/components/transport_manager/include/transport_manager/usb/usb_control_transfer.h @@ -100,7 +100,7 @@ class UsbControlTransferSequence { Transfers transfers_; }; -} // namespace -} // namespace +} // namespace transport_adapter +} // namespace transport_manager #endif // SRC_COMPONENTS_TRANSPORT_MANAGER_INCLUDE_TRANSPORT_MANAGER_USB_USB_CONTROL_TRANSFER_H_ diff --git a/src/components/transport_manager/include/transport_manager/usb/usb_device_scanner.h b/src/components/transport_manager/include/transport_manager/usb/usb_device_scanner.h index a6065de2b2e..9d99b1b548b 100644 --- a/src/components/transport_manager/include/transport_manager/usb/usb_device_scanner.h +++ b/src/components/transport_manager/include/transport_manager/usb/usb_device_scanner.h @@ -38,9 +38,9 @@ #include -#include "utils/lock.h" #include "transport_manager/transport_adapter/device_scanner.h" #include "transport_manager/usb/common.h" +#include "utils/lock.h" namespace transport_manager { @@ -48,7 +48,8 @@ namespace transport_adapter { class UsbDeviceScanner : public DeviceScanner, public UsbDeviceListener { public: - UsbDeviceScanner(class TransportAdapterController* controller); + UsbDeviceScanner(class TransportAdapterController* controller, + const TransportManagerSettings& settings); virtual ~UsbDeviceScanner(); protected: @@ -65,13 +66,14 @@ class UsbDeviceScanner : public DeviceScanner, public UsbDeviceListener { void SupportedDeviceFound(PlatformUsbDevice* device); TransportAdapterController* controller_; + const TransportManagerSettings& settings_; typedef std::list Devices; Devices devices_; sync_primitives::Lock devices_mutex_; }; -} // namespace -} // namespace +} // namespace transport_adapter +} // namespace transport_manager #endif // SRC_COMPONENTS_TRANSPORT_MANAGER_INCLUDE_TRANSPORT_MANAGER_USB_USB_DEVICE_SCANNER_H_ diff --git a/src/components/transport_manager/src/bluetooth/bluetooth_connection_factory.cc b/src/components/transport_manager/src/bluetooth/bluetooth_connection_factory.cc index 62615cb30fe..19f4078443b 100644 --- a/src/components/transport_manager/src/bluetooth/bluetooth_connection_factory.cc +++ b/src/components/transport_manager/src/bluetooth/bluetooth_connection_factory.cc @@ -33,9 +33,9 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include "transport_manager/transport_adapter/transport_adapter_controller.h" #include "transport_manager/bluetooth/bluetooth_connection_factory.h" #include "transport_manager/bluetooth/bluetooth_socket_connection.h" +#include "transport_manager/transport_adapter/transport_adapter_controller.h" #include "utils/logger.h" namespace transport_manager { diff --git a/src/components/transport_manager/src/bluetooth/bluetooth_device.cc b/src/components/transport_manager/src/bluetooth/bluetooth_device.cc index e7cc3d4f34f..734d8fe1e9b 100644 --- a/src/components/transport_manager/src/bluetooth/bluetooth_device.cc +++ b/src/components/transport_manager/src/bluetooth/bluetooth_device.cc @@ -36,13 +36,13 @@ #include #include #include +#include #include #include -#include #include -#include #include +#include #include #include diff --git a/src/components/transport_manager/src/bluetooth/bluetooth_device_scanner.cc b/src/components/transport_manager/src/bluetooth/bluetooth_device_scanner.cc index 75ea799ce8f..4759b2003af 100644 --- a/src/components/transport_manager/src/bluetooth/bluetooth_device_scanner.cc +++ b/src/components/transport_manager/src/bluetooth/bluetooth_device_scanner.cc @@ -38,18 +38,18 @@ #include #include #include +#include #include #include -#include #include -#include #include #include +#include #include -#include #include -#include "transport_manager/bluetooth/bluetooth_transport_adapter.h" +#include #include "transport_manager/bluetooth/bluetooth_device.h" +#include "transport_manager/bluetooth/bluetooth_transport_adapter.h" #include "utils/logger.h" #include "utils/threads/thread.h" @@ -133,7 +133,27 @@ BluetoothDeviceScanner::BluetoothDeviceScanner( 0xA8}; sdp_uuid128_create(&smart_device_link_service_uuid_, smart_device_link_service_uuid_data); - thread_ = threads::CreateThread("BT Device Scaner", + thread_ = threads::CreateThread("BT Device Scanner", + new BluetoothDeviceScannerDelegate(this)); +} + +BluetoothDeviceScanner::BluetoothDeviceScanner( + TransportAdapterController* controller, + bool auto_repeat_search, + int auto_repeat_pause_sec, + const uint8_t* smart_device_link_service_uuid_data) + : controller_(controller) + , thread_(NULL) + , shutdown_requested_(false) + , ready_(true) + , device_scan_requested_(false) + , device_scan_requested_lock_() + , device_scan_requested_cv_() + , auto_repeat_search_(auto_repeat_search) + , auto_repeat_pause_sec_(auto_repeat_pause_sec) { + sdp_uuid128_create(&smart_device_link_service_uuid_, + smart_device_link_service_uuid_data); + thread_ = threads::CreateThread("BT Device Scanner", new BluetoothDeviceScannerDelegate(this)); } diff --git a/src/components/transport_manager/src/bluetooth/bluetooth_socket_connection.cc b/src/components/transport_manager/src/bluetooth/bluetooth_socket_connection.cc index b4370e4b122..78597ac2ade 100644 --- a/src/components/transport_manager/src/bluetooth/bluetooth_socket_connection.cc +++ b/src/components/transport_manager/src/bluetooth/bluetooth_socket_connection.cc @@ -33,13 +33,13 @@ #include "transport_manager/bluetooth/bluetooth_socket_connection.h" -#include #include #include #include +#include #include #include -#include +#include #include "transport_manager/bluetooth/bluetooth_device.h" #include "transport_manager/transport_adapter/transport_adapter_controller.h" @@ -93,9 +93,9 @@ bool BluetoothSocketConnection::Establish(ConnectError** error) { do { rfcomm_socket = socket(AF_BLUETOOTH, SOCK_STREAM, BTPROTO_RFCOMM); if (-1 == rfcomm_socket) { - LOG4CXX_ERROR_WITH_ERRNO(logger_, - "Failed to create RFCOMM socket for device " - << device_handle()); + LOG4CXX_ERROR_WITH_ERRNO( + logger_, + "Failed to create RFCOMM socket for device " << device_handle()); *error = new ConnectError(); LOG4CXX_TRACE(logger_, "exit with FALSE"); return false; diff --git a/src/components/transport_manager/src/bluetooth/bluetooth_transport_adapter.cc b/src/components/transport_manager/src/bluetooth/bluetooth_transport_adapter.cc index b373744f795..911658bc561 100644 --- a/src/components/transport_manager/src/bluetooth/bluetooth_transport_adapter.cc +++ b/src/components/transport_manager/src/bluetooth/bluetooth_transport_adapter.cc @@ -34,18 +34,18 @@ */ #include -#include #include +#include #include +#include #include #include -#include -#include "transport_manager/bluetooth/bluetooth_transport_adapter.h" -#include "transport_manager/bluetooth/bluetooth_device_scanner.h" #include "transport_manager/bluetooth/bluetooth_connection_factory.h" #include "transport_manager/bluetooth/bluetooth_device.h" +#include "transport_manager/bluetooth/bluetooth_device_scanner.h" +#include "transport_manager/bluetooth/bluetooth_transport_adapter.h" #include "utils/logger.h" @@ -58,11 +58,12 @@ BluetoothTransportAdapter::~BluetoothTransportAdapter() {} BluetoothTransportAdapter::BluetoothTransportAdapter( resumption::LastState& last_state, const TransportManagerSettings& settings) - : TransportAdapterImpl(new BluetoothDeviceScanner(this, true, 0), - new BluetoothConnectionFactory(this), - NULL, - last_state, - settings) {} + : TransportAdapterImpl( + new BluetoothDeviceScanner(this, true, 0, settings.bluetooth_uuid()), + new BluetoothConnectionFactory(this), + NULL, + last_state, + settings) {} DeviceType BluetoothTransportAdapter::GetDeviceType() const { return BLUETOOTH; diff --git a/src/components/transport_manager/src/cloud/cloud_device.cc b/src/components/transport_manager/src/cloud/cloud_device.cc index c1ad186ded6..9225589d570 100644 --- a/src/components/transport_manager/src/cloud/cloud_device.cc +++ b/src/components/transport_manager/src/cloud/cloud_device.cc @@ -49,7 +49,7 @@ CloudDevice::CloudDevice(std::string& host, .query = "", .fragment = ""}) {} -CloudDevice::CloudDevice(CloudAppEndpoint endpoint, std::string& name) +CloudDevice::CloudDevice(CloudAppEndpoint& endpoint, std::string& name) : Device(name, std::string(name)), endpoint_(endpoint) {} bool CloudDevice::IsSameAs(const Device* other) const { diff --git a/src/components/transport_manager/src/cloud/cloud_websocket_connection_factory.cc b/src/components/transport_manager/src/cloud/cloud_websocket_connection_factory.cc index 0d9fda6fe52..d072685eefb 100644 --- a/src/components/transport_manager/src/cloud/cloud_websocket_connection_factory.cc +++ b/src/components/transport_manager/src/cloud/cloud_websocket_connection_factory.cc @@ -33,9 +33,9 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include "transport_manager/transport_adapter/transport_adapter_controller.h" #include "transport_manager/cloud/cloud_websocket_connection_factory.h" #include "transport_manager/cloud/websocket_client_connection.h" +#include "transport_manager/transport_adapter/transport_adapter_controller.h" #include "utils/logger.h" #include "transport_manager/cloud/cloud_device.h" diff --git a/src/components/transport_manager/src/cloud/websocket_client_connection.cc b/src/components/transport_manager/src/cloud/websocket_client_connection.cc index 1718e5ca1b3..794cf57208a 100644 --- a/src/components/transport_manager/src/cloud/websocket_client_connection.cc +++ b/src/components/transport_manager/src/cloud/websocket_client_connection.cc @@ -169,9 +169,9 @@ TransportAdapter::Error WebsocketClientConnection::Start() { #endif // ENABLE_SECURITY if (ec) { std::string str_err = "ErrorMessage: " + ec.message(); - LOG4CXX_ERROR(logger_, - "Could not complete handshake with host/port: " << host << ":" - << port); + LOG4CXX_ERROR( + logger_, + "Could not complete handshake with host/port: " << host << ":" << port); LOG4CXX_ERROR(logger_, str_err); return TransportAdapter::FAIL; } @@ -208,9 +208,9 @@ TransportAdapter::Error WebsocketClientConnection::Start() { boost::asio::post(io_pool_, [&]() { ioc_.run(); }); - LOG4CXX_DEBUG(logger_, - "Successfully started websocket connection @: " << host << ":" - << port); + LOG4CXX_DEBUG( + logger_, + "Successfully started websocket connection @: " << host << ":" << port); return TransportAdapter::OK; } @@ -261,7 +261,7 @@ void WebsocketClientConnection::OnRead(boost::system::error_code ec, boost::beast::buffers_front(buffer_.data())); ::protocol_handler::RawMessagePtr frame( - new protocol_handler::RawMessage(0, 0, data, size)); + new protocol_handler::RawMessage(0, 0, data, size, false)); controller_->DataReceiveDone(device_uid_, app_handle_, frame); 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 31e997f3ba7..2e37f76bc9b 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 @@ -32,14 +32,14 @@ #include "transport_manager/iap2_emulation/iap2_transport_adapter.h" -#include -#include #include -#include #include +#include +#include +#include -#include "utils/threads/thread.h" #include "utils/file_system.h" +#include "utils/threads/thread.h" namespace { static const mode_t mode = 0666; @@ -182,5 +182,5 @@ void IAP2USBEmulationTransportAdapter::IAPSignalHandlerDelegate:: run_flag_ = false; ThreadDelegate::exitThreadMain(); } -} -} // namespace transport_manager::transport_adapter +} // namespace transport_adapter +} // namespace transport_manager 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 047d43b7bfb..2e79e84f2ec 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 @@ -5,11 +5,11 @@ #include #include #include -#include #include -#include #include #include +#include +#include #include #include @@ -105,7 +105,7 @@ PlatformSpecificNetworkInterfaceListener:: bool PlatformSpecificNetworkInterfaceListener::Init() { LOG4CXX_AUTO_TRACE(logger_); - + LOG4CXX_DEBUG(logger_, "Init socket: " << socket_); if (socket_ >= 0) { LOG4CXX_WARN(logger_, "Network interface listener is already initialized"); return false; @@ -151,7 +151,7 @@ bool PlatformSpecificNetworkInterfaceListener::Init() { void PlatformSpecificNetworkInterfaceListener::Deinit() { LOG4CXX_AUTO_TRACE(logger_); - + LOG4CXX_DEBUG(logger_, "Deinit socket: " << socket_); if (socket_ >= 0) { close(socket_); socket_ = -1; @@ -356,7 +356,7 @@ bool PlatformSpecificNetworkInterfaceListener::InitializeStatus() { } #endif // BUILD_TESTS - struct ifaddrs* if_list, *interface; + struct ifaddrs *if_list, *interface; if (getifaddrs(&if_list) != 0) { LOG4CXX_WARN(logger_, "getifaddr failed, interface status won't be available until " @@ -421,9 +421,9 @@ bool PlatformSpecificNetworkInterfaceListener::UpdateStatus( switch (type) { case RTM_NEWLINK: { - LOG4CXX_DEBUG(logger_, - "netlink event: interface " << ifname - << " created or updated"); + LOG4CXX_DEBUG( + logger_, + "netlink event: interface " << ifname << " created or updated"); status.SetFlags(it->flags); break; } 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 9f2597f0a7c..d29ffeb144d 100644 --- a/src/components/transport_manager/src/tcp/tcp_client_listener.cc +++ b/src/components/transport_manager/src/tcp/tcp_client_listener.cc @@ -33,35 +33,35 @@ #include "transport_manager/tcp/tcp_client_listener.h" -#include -#include +#include #include #include -#include -#include -#include +#include +#include +#include #include -#include #include -#include +#include +#include +#include #ifdef __linux__ #include #else // __linux__ -#include #include #include #include +#include #endif // __linux__ #include #include "utils/logger.h" -#include "utils/threads/thread.h" -#include "transport_manager/transport_adapter/transport_adapter_controller.h" #include "transport_manager/tcp/network_interface_listener_impl.h" #include "transport_manager/tcp/tcp_device.h" #include "transport_manager/tcp/tcp_socket_connection.h" +#include "transport_manager/transport_adapter/transport_adapter_controller.h" +#include "utils/threads/thread.h" namespace transport_manager { namespace transport_adapter { @@ -374,17 +374,16 @@ TransportAdapter::Error TcpClientListener::StartListening() { return TransportAdapter::OK; } -void TcpClientListener::ListeningThreadDelegate::exitThreadMain() { - parent_->StopLoop(); -} +TransportAdapter::Error TcpClientListener::ResumeListening() { + LOG4CXX_AUTO_TRACE(logger_); -void TcpClientListener::ListeningThreadDelegate::threadMain() { - parent_->Loop(); -} + interface_listener_->Init(); + StartListeningThread(); + started_ = true; -TcpClientListener::ListeningThreadDelegate::ListeningThreadDelegate( - TcpClientListener* parent) - : parent_(parent) {} + LOG4CXX_INFO(logger_, "Tcp client listener was resumed successfully"); + return TransportAdapter::OK; +} TransportAdapter::Error TcpClientListener::StopListening() { LOG4CXX_AUTO_TRACE(logger_); @@ -398,10 +397,45 @@ TransportAdapter::Error TcpClientListener::StopListening() { StopListeningThread(); started_ = false; - LOG4CXX_INFO(logger_, "Tcp client listener has stopped successfully"); + LOG4CXX_INFO(logger_, "Tcp client listener was stopped successfully"); return TransportAdapter::OK; } +TransportAdapter::Error TcpClientListener::SuspendListening() { + LOG4CXX_AUTO_TRACE(logger_); + if (!started_) { + LOG4CXX_DEBUG(logger_, "TcpClientListener is not running now"); + return TransportAdapter::BAD_STATE; + } + + if (shutdown(socket_, SHUT_RDWR) != 0) { + LOG4CXX_WARN(logger_, "Socket was unable to be shutdowned"); + } + + if (close(socket_) != 0) { + LOG4CXX_ERROR_WITH_ERRNO(logger_, "Failed to close socket"); + } + + interface_listener_->Deinit(); + StopListeningThread(); + started_ = false; + + LOG4CXX_INFO(logger_, "Tcp client listener was suspended"); + return TransportAdapter::OK; +} + +void TcpClientListener::ListeningThreadDelegate::exitThreadMain() { + parent_->StopLoop(); +} + +void TcpClientListener::ListeningThreadDelegate::threadMain() { + parent_->Loop(); +} + +TcpClientListener::ListeningThreadDelegate::ListeningThreadDelegate( + TcpClientListener* parent) + : parent_(parent) {} + TransportAdapter::Error TcpClientListener::StartListeningThread() { LOG4CXX_AUTO_TRACE(logger_); @@ -455,9 +489,9 @@ void TcpClientListener::OnIPAddressUpdated(const std::string ipv4_addr, if (IsListeningOnSpecificInterface()) { if (!current_ip_address_.empty()) { // the server socket is running, terminate it - LOG4CXX_DEBUG(logger_, - "Stopping current TCP server socket on " - << designated_interface_); + LOG4CXX_DEBUG( + logger_, + "Stopping current TCP server socket on " << designated_interface_); StopOnNetworkInterface(); } if (!ipv4_addr.empty()) { @@ -525,9 +559,9 @@ bool TcpClientListener::StopOnNetworkInterface() { socket_ = -1; } - LOG4CXX_INFO(logger_, - "TCP server socket on " << designated_interface_ - << " stopped"); + LOG4CXX_INFO( + logger_, + "TCP server socket on " << designated_interface_ << " stopped"); } return true; } diff --git a/src/components/transport_manager/src/tcp/tcp_connection_factory.cc b/src/components/transport_manager/src/tcp/tcp_connection_factory.cc index e202554f8f2..50d1c74fa73 100644 --- a/src/components/transport_manager/src/tcp/tcp_connection_factory.cc +++ b/src/components/transport_manager/src/tcp/tcp_connection_factory.cc @@ -30,9 +30,9 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include "transport_manager/transport_adapter/transport_adapter_controller.h" #include "transport_manager/tcp/tcp_connection_factory.h" #include "transport_manager/tcp/tcp_server_originated_socket_connection.h" +#include "transport_manager/transport_adapter/transport_adapter_controller.h" #include "utils/logger.h" @@ -52,9 +52,9 @@ TransportAdapter::Error TcpConnectionFactory::Init() { TransportAdapter::Error TcpConnectionFactory::CreateConnection( const DeviceUID& device_uid, const ApplicationHandle& app_handle) { LOG4CXX_AUTO_TRACE(logger_); - LOG4CXX_DEBUG(logger_, - "DeviceUID: " << &device_uid - << ", ApplicationHandle: " << &app_handle); + LOG4CXX_DEBUG( + logger_, + "DeviceUID: " << &device_uid << ", ApplicationHandle: " << &app_handle); std::shared_ptr connection = std::make_shared( device_uid, app_handle, controller_); diff --git a/src/components/transport_manager/src/tcp/tcp_device.cc b/src/components/transport_manager/src/tcp/tcp_device.cc index dbcb5d38cbc..4542f76c1d4 100644 --- a/src/components/transport_manager/src/tcp/tcp_device.cc +++ b/src/components/transport_manager/src/tcp/tcp_device.cc @@ -30,8 +30,8 @@ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ -#include "utils/logger.h" #include "transport_manager/tcp/tcp_device.h" +#include "utils/logger.h" namespace transport_manager { namespace transport_adapter { @@ -57,9 +57,9 @@ TcpDevice::TcpDevice(const in_addr_t& in_addr, LOG4CXX_AUTO_TRACE(logger_); LOG4CXX_DEBUG(logger_, "Device created with transport switch emulation support."); - LOG4CXX_DEBUG(logger_, - "Device parameters: " << device_uid << " / " - << transport_switch_id); + LOG4CXX_DEBUG( + logger_, + "Device parameters: " << device_uid << " / " << transport_switch_id); } #endif // BUILD_TESTS diff --git a/src/components/transport_manager/src/tcp/tcp_server_originated_socket_connection.cc b/src/components/transport_manager/src/tcp/tcp_server_originated_socket_connection.cc index 2f10bd94540..690b2d25b38 100644 --- a/src/components/transport_manager/src/tcp/tcp_server_originated_socket_connection.cc +++ b/src/components/transport_manager/src/tcp/tcp_server_originated_socket_connection.cc @@ -65,9 +65,9 @@ bool TcpServerOriginatedSocketConnection::Establish(ConnectError** error) { const int port = tcp_device->GetApplicationPort(application_handle()); if (-1 == port) { - LOG4CXX_ERROR(logger_, - "Application port for " << application_handle() - << " not found"); + LOG4CXX_ERROR( + logger_, + "Application port for " << application_handle() << " not found"); *error = new ConnectError(); return false; } 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 b3dbf49628c..aeb50f3830c 100644 --- a/src/components/transport_manager/src/tcp/tcp_transport_adapter.cc +++ b/src/components/transport_manager/src/tcp/tcp_transport_adapter.cc @@ -32,19 +32,19 @@ #include "transport_manager/tcp/tcp_transport_adapter.h" +#include #include #include -#include #include #include #include -#include "utils/logger.h" -#include "utils/threads/thread_delegate.h" #include "transport_manager/tcp/tcp_client_listener.h" #include "transport_manager/tcp/tcp_connection_factory.h" #include "transport_manager/tcp/tcp_device.h" +#include "utils/logger.h" +#include "utils/threads/thread_delegate.h" namespace transport_manager { namespace transport_adapter { diff --git a/src/components/transport_manager/src/transport_adapter/threaded_socket_connection.cc b/src/components/transport_manager/src/transport_adapter/threaded_socket_connection.cc index 9d594affe42..96c4c2c3700 100644 --- a/src/components/transport_manager/src/transport_adapter/threaded_socket_connection.cc +++ b/src/components/transport_manager/src/transport_adapter/threaded_socket_connection.cc @@ -30,13 +30,13 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include #include #include #include -#include -#include #include +#include +#include +#include #include "utils/logger.h" #include "utils/threads/thread.h" @@ -300,11 +300,11 @@ bool ThreadedSocketConnection::Receive() { bytes_read = recv(socket_, buffer, sizeof(buffer), MSG_DONTWAIT); if (bytes_read > 0) { - LOG4CXX_DEBUG(logger_, - "Received " << bytes_read << " bytes for connection " - << this); + LOG4CXX_DEBUG( + logger_, + "Received " << bytes_read << " bytes for connection " << this); ::protocol_handler::RawMessagePtr frame( - new protocol_handler::RawMessage(0, 0, buffer, bytes_read)); + new protocol_handler::RawMessage(0, 0, buffer, bytes_read, false)); controller_->DataReceiveDone( device_handle(), application_handle(), frame); } else if (bytes_read < 0) { 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 865e8d6aa81..f0bfabf2e42 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 @@ -35,11 +35,11 @@ #include "utils/logger.h" #include "utils/timer_task_impl.h" -#include "transport_manager/transport_adapter/transport_adapter_impl.h" -#include "transport_manager/transport_adapter/transport_adapter_listener.h" +#include "transport_manager/transport_adapter/client_connection_listener.h" #include "transport_manager/transport_adapter/device_scanner.h" #include "transport_manager/transport_adapter/server_connection_factory.h" -#include "transport_manager/transport_adapter/client_connection_listener.h" +#include "transport_manager/transport_adapter/transport_adapter_impl.h" +#include "transport_manager/transport_adapter/transport_adapter_listener.h" namespace transport_manager { namespace transport_adapter { @@ -100,16 +100,16 @@ TransportAdapterImpl::~TransportAdapterImpl() { LOG4CXX_DEBUG(logger_, "device_scanner_ deleted."); } if (server_connection_factory_) { - LOG4CXX_DEBUG(logger_, - "Deleting server_connection_factory " - << server_connection_factory_); + LOG4CXX_DEBUG( + logger_, + "Deleting server_connection_factory " << server_connection_factory_); delete server_connection_factory_; LOG4CXX_DEBUG(logger_, "server_connection_factory deleted."); } if (client_connection_listener_) { - LOG4CXX_DEBUG(logger_, - "Deleting client_connection_listener_ " - << client_connection_listener_); + LOG4CXX_DEBUG( + logger_, + "Deleting client_connection_listener_ " << client_connection_listener_); delete client_connection_listener_; LOG4CXX_DEBUG(logger_, "client_connection_listener_ deleted."); } @@ -193,9 +193,9 @@ TransportAdapter::Error TransportAdapterImpl::SearchDevices() { TransportAdapter::Error TransportAdapterImpl::Connect( const DeviceUID& device_id, const ApplicationHandle& app_handle) { - LOG4CXX_TRACE(logger_, - "enter. DeviceUID " << device_id << " ApplicationHandle " - << app_handle); + LOG4CXX_TRACE( + logger_, + "enter. DeviceUID " << device_id << " ApplicationHandle " << app_handle); if (server_connection_factory_ == 0) { LOG4CXX_TRACE(logger_, "exit with NOT_SUPPORTED"); return NOT_SUPPORTED; @@ -339,9 +339,9 @@ void TransportAdapterImpl::ConnectionStatusUpdated(DeviceSptr device, TransportAdapter::Error TransportAdapterImpl::Disconnect( const DeviceUID& device_id, const ApplicationHandle& app_handle) { - LOG4CXX_TRACE(logger_, - "enter. device_id: " << &device_id - << ", device_id: " << &device_id); + LOG4CXX_TRACE( + logger_, + "enter. device_id: " << &device_id << ", device_id: " << &device_id); if (!initialised_) { LOG4CXX_TRACE(logger_, "exit with BAD_STATE"); return BAD_STATE; @@ -418,8 +418,9 @@ TransportAdapter::Error TransportAdapterImpl::SendData( } } -TransportAdapter::Error TransportAdapterImpl::StartClientListening() { - LOG4CXX_TRACE(logger_, "enter"); +TransportAdapter::Error TransportAdapterImpl::ChangeClientListening( + TransportAction required_change) { + LOG4CXX_AUTO_TRACE(logger_); if (client_connection_listener_ == 0) { LOG4CXX_TRACE(logger_, "exit with NOT_SUPPORTED"); return NOT_SUPPORTED; @@ -428,27 +429,43 @@ TransportAdapter::Error TransportAdapterImpl::StartClientListening() { LOG4CXX_TRACE(logger_, "exit with BAD_STATE"); return BAD_STATE; } - TransportAdapter::Error err = client_connection_listener_->StartListening(); - LOG4CXX_TRACE(logger_, "exit with error: " << err); - return err; -} -TransportAdapter::Error TransportAdapterImpl::StopClientListening() { - LOG4CXX_TRACE(logger_, "enter"); - if (client_connection_listener_ == 0) { - LOG4CXX_TRACE(logger_, "exit with NOT_SUPPORTED"); - return NOT_SUPPORTED; - } - if (!client_connection_listener_->IsInitialised()) { - LOG4CXX_TRACE(logger_, "exit with BAD_STATE"); - return BAD_STATE; - } - TransportAdapter::Error err = client_connection_listener_->StopListening(); - sync_primitives::AutoLock locker(devices_mutex_); - for (DeviceMap::iterator it = devices_.begin(); it != devices_.end(); ++it) { - it->second->Stop(); + TransportAdapter::Error err = TransportAdapter::Error::UNKNOWN; + + switch (required_change) { + case transport_manager::TransportAction::kVisibilityOn: + err = client_connection_listener_->StartListening(); + break; + + case transport_manager::TransportAction::kListeningOn: + err = client_connection_listener_->ResumeListening(); + break; + + case transport_manager::TransportAction::kListeningOff: + err = client_connection_listener_->SuspendListening(); + { + sync_primitives::AutoLock locker(devices_mutex_); + for (DeviceMap::iterator it = devices_.begin(); it != devices_.end(); + ++it) { + it->second->Stop(); + } + } + break; + + case transport_manager::TransportAction::kVisibilityOff: + err = client_connection_listener_->StopListening(); + { + sync_primitives::AutoLock locker(devices_mutex_); + for (DeviceMap::iterator it = devices_.begin(); it != devices_.end(); + ++it) { + it->second->Stop(); + } + } + break; + default: + NOTREACHED(); } - LOG4CXX_TRACE(logger_, "exit with error: " << err); + LOG4CXX_TRACE(logger_, "Exit with error: " << err); return err; } @@ -638,9 +655,9 @@ void TransportAdapterImpl::ConnectionCreated( void TransportAdapterImpl::DeviceDisconnected( const DeviceUID& device_handle, const DisconnectDeviceError& error) { const DeviceUID device_uid = device_handle; - LOG4CXX_TRACE(logger_, - "enter. device_handle: " << &device_uid - << ", error: " << &error); + LOG4CXX_TRACE( + logger_, + "enter. device_handle: " << &device_uid << ", error: " << &error); ApplicationList app_list = GetApplicationList(device_uid); for (ApplicationList::const_iterator i = app_list.begin(); i != app_list.end(); @@ -698,9 +715,9 @@ void TransportAdapterImpl::DisconnectDone(const DeviceUID& device_handle, const ApplicationHandle& app_handle) { const DeviceUID device_uid = device_handle; const ApplicationHandle app_uid = app_handle; - LOG4CXX_TRACE(logger_, - "enter. device_id: " << &device_uid - << ", app_handle: " << &app_uid); + LOG4CXX_TRACE( + logger_, + "enter. device_id: " << &device_uid << ", app_handle: " << &app_uid); DeviceSptr device = FindDevice(device_handle); if (!device) { LOG4CXX_WARN(logger_, "Device: uid " << &device_uid << " not found"); @@ -823,9 +840,9 @@ void TransportAdapterImpl::DeviceSwitched(const DeviceUID& device_handle) { ConnectionSPtr TransportAdapterImpl::FindPendingConnection( const DeviceUID& device_id, const ApplicationHandle& app_handle) const { - LOG4CXX_TRACE(logger_, - "enter. device_id: " << &device_id - << ", app_handle: " << &app_handle); + LOG4CXX_TRACE( + logger_, + "enter. device_id: " << &device_id << ", app_handle: " << &app_handle); ConnectionSPtr connection; connections_lock_.AcquireForReading(); ConnectionMap::const_iterator it = @@ -886,9 +903,9 @@ void TransportAdapterImpl::ConnectPending(const DeviceUID& device_id, void TransportAdapterImpl::ConnectDone(const DeviceUID& device_id, const ApplicationHandle& app_handle) { - LOG4CXX_TRACE(logger_, - "enter. device_id: " << &device_id - << ", app_handle: " << &app_handle); + LOG4CXX_TRACE( + logger_, + "enter. device_id: " << &device_id << ", app_handle: " << &app_handle); connections_lock_.AcquireForReading(); ConnectionMap::iterator it_conn = connections_.find(std::make_pair(device_id, app_handle)); @@ -975,9 +992,9 @@ ApplicationList TransportAdapterImpl::GetApplicationList( void TransportAdapterImpl::ConnectionFinished( const DeviceUID& device_id, const ApplicationHandle& app_handle) { - LOG4CXX_TRACE(logger_, - "enter. device_id: " << &device_id - << ", app_handle: " << &app_handle); + LOG4CXX_TRACE( + logger_, + "enter. device_id: " << &device_id << ", app_handle: " << &app_handle); connections_lock_.AcquireForReading(); ConnectionMap::iterator it = connections_.find(std::make_pair(device_id, app_handle)); @@ -1101,9 +1118,9 @@ bool TransportAdapterImpl::ToBeAutoDisconnected(DeviceSptr device) const { ConnectionSPtr TransportAdapterImpl::FindEstablishedConnection( const DeviceUID& device_id, const ApplicationHandle& app_handle) const { - LOG4CXX_TRACE(logger_, - "enter. device_id: " << &device_id - << ", app_handle: " << &app_handle); + LOG4CXX_TRACE( + logger_, + "enter. device_id: " << &device_id << ", app_handle: " << &app_handle); ConnectionSPtr connection; connections_lock_.AcquireForReading(); ConnectionMap::const_iterator it = 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 4ef685adbc0..bf2d3dbdf4e 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 @@ -34,9 +34,9 @@ #include "utils/logger.h" +#include "transport_manager/transport_adapter/transport_adapter_event.h" #include "transport_manager/transport_adapter/transport_adapter_listener_impl.h" #include "transport_manager/transport_manager_impl.h" -#include "transport_manager/transport_adapter/transport_adapter_event.h" namespace transport_manager { CREATE_LOGGERPTR_GLOBAL(logger_, "TransportManager") diff --git a/src/components/transport_manager/src/transport_manager_impl.cc b/src/components/transport_manager/src/transport_manager_impl.cc index 0c49401c80b..07dd35bc2fd 100644 --- a/src/components/transport_manager/src/transport_manager_impl.cc +++ b/src/components/transport_manager/src/transport_manager_impl.cc @@ -33,28 +33,28 @@ #include "transport_manager/transport_manager_impl.h" #include +#include #include +#include +#include +#include #include #include -#include -#include -#include #include -#include -#include "utils/macro.h" #include "utils/logger.h" +#include "utils/macro.h" -#include "utils/timer_task_impl.h" -#include "transport_manager/common.h" -#include "transport_manager/transport_manager_listener.h" -#include "transport_manager/transport_manager_listener_empty.h" -#include "transport_manager/transport_adapter/transport_adapter.h" +#include "config_profile/profile.h" #if defined(CLOUD_APP_WEBSOCKET_TRANSPORT_SUPPORT) #include "transport_manager/cloud/cloud_websocket_transport_adapter.h" #endif +#include "transport_manager/common.h" +#include "transport_manager/transport_adapter/transport_adapter.h" #include "transport_manager/transport_adapter/transport_adapter_event.h" -#include "config_profile/profile.h" +#include "transport_manager/transport_manager_listener.h" +#include "transport_manager/transport_manager_listener_empty.h" +#include "utils/timer_task_impl.h" using ::transport_manager::transport_adapter::TransportAdapter; @@ -67,6 +67,7 @@ struct ConnectionFinder { return id_ == connection.id; } }; + } // namespace namespace transport_manager { @@ -100,7 +101,10 @@ TransportManagerImpl::TransportManagerImpl( , device_switch_timer_( "Device reconection timer", new timer::TimerTaskImpl( - this, &TransportManagerImpl::ReconnectionTimeout)) { + this, &TransportManagerImpl::ReconnectionTimeout)) + , events_processing_is_active_(true) + , events_processing_lock_() + , events_processing_cond_var_() { LOG4CXX_TRACE(logger_, "TransportManager has created"); } @@ -379,9 +383,9 @@ int TransportManagerImpl::Stop() { int TransportManagerImpl::SendMessageToDevice( const ::protocol_handler::RawMessagePtr message) { LOG4CXX_TRACE(logger_, "enter. RawMessageSptr: " << message); - LOG4CXX_INFO(logger_, - "Send message to device called with arguments " - << message.get()); + LOG4CXX_INFO( + logger_, + "Send message to device called with arguments " << message.get()); if (false == this->is_initialized_) { LOG4CXX_ERROR(logger_, "TM is not initialized."); LOG4CXX_TRACE(logger_, @@ -586,21 +590,36 @@ int TransportManagerImpl::Init(resumption::LastState& last_state) { return E_SUCCESS; } -int TransportManagerImpl::Reinit() { +void TransportManagerImpl::Deinit() { LOG4CXX_AUTO_TRACE(logger_); DisconnectAllDevices(); TerminateAllAdapters(); device_to_adapter_map_.clear(); connection_id_counter_ = 0; +} + +int TransportManagerImpl::Reinit() { int ret = InitAllAdapters(); return ret; } -int TransportManagerImpl::Visibility(const bool& on_off) const { - LOG4CXX_TRACE(logger_, "enter. On_off: " << &on_off); - TransportAdapter::Error ret; +void TransportManagerImpl::StopEventsProcessing() { + LOG4CXX_AUTO_TRACE(logger_); + events_processing_is_active_ = false; +} - LOG4CXX_DEBUG(logger_, "Visibility change requested to " << on_off); +void TransportManagerImpl::StartEventsProcessing() { + LOG4CXX_AUTO_TRACE(logger_); + events_processing_is_active_ = true; + events_processing_cond_var_.Broadcast(); +} + +int TransportManagerImpl::PerformActionOnClients( + const TransportAction required_action) const { + LOG4CXX_TRACE(logger_, + "The following action requested: " + << static_cast(required_action) + << " to be performed on connected clients"); if (!is_initialized_) { LOG4CXX_ERROR(logger_, "TM is not initialized"); LOG4CXX_TRACE(logger_, @@ -609,21 +628,19 @@ int TransportManagerImpl::Visibility(const bool& on_off) const { return E_TM_IS_NOT_INITIALIZED; } - for (std::vector::const_iterator it = - transport_adapters_.begin(); - it != transport_adapters_.end(); - ++it) { - if (on_off) { - ret = (*it)->StartClientListening(); - } else { - ret = (*it)->StopClientListening(); - } + TransportAdapter::Error ret = TransportAdapter::Error::UNKNOWN; + + for (auto adapter_ptr : transport_adapters_) { + ret = adapter_ptr->ChangeClientListening(required_action); + if (TransportAdapter::Error::NOT_SUPPORTED == ret) { LOG4CXX_DEBUG(logger_, - "Visibility change is not supported for adapter " - << *it << "[" << (*it)->GetDeviceType() << "]"); + "Requested action on client is not supported for adapter " + << adapter_ptr << "[" << adapter_ptr->GetDeviceType() + << "]"); } } + LOG4CXX_TRACE(logger_, "exit with E_SUCCESS"); return E_SUCCESS; } @@ -781,9 +798,9 @@ TransportManagerImpl::ConnectionInternal* TransportManagerImpl::GetActiveConnection( const DeviceUID& device, const ApplicationHandle& application) { LOG4CXX_AUTO_TRACE(logger_); - LOG4CXX_DEBUG(logger_, - "DeviceUID: " << device - << " ApplicationHandle: " << application); + LOG4CXX_DEBUG( + logger_, + "DeviceUID: " << device << " ApplicationHandle: " << application); for (std::vector::iterator it = connections_.begin(); it != connections_.end(); ++it) { @@ -932,9 +949,9 @@ bool TransportManagerImpl::UpdateDeviceMapping( item = device_to_adapter_map_.begin(); } - LOG4CXX_DEBUG(logger_, - "After cleanup. Device map size is " - << device_to_adapter_map_.size()); + LOG4CXX_DEBUG( + logger_, + "After cleanup. Device map size is " << device_to_adapter_map_.size()); for (DeviceList::const_iterator it = adapter_device_list.begin(); it != adapter_device_list.end(); @@ -944,10 +961,10 @@ bool TransportManagerImpl::UpdateDeviceMapping( device_to_adapter_map_.insert(std::make_pair(device_uid, ta)); if (!result.second) { LOG4CXX_WARN(logger_, - "Device UID " - << device_uid - << " is known already. Processing skipped." - "Connection type is: " << ta->GetConnectionType()); + "Device UID " << device_uid + << " is known already. Processing skipped." + "Connection type is: " + << ta->GetConnectionType()); continue; } DeviceHandle device_handle = @@ -959,9 +976,9 @@ bool TransportManagerImpl::UpdateDeviceMapping( RaiseEvent(&TransportManagerListener::OnDeviceFound, info); } - LOG4CXX_DEBUG(logger_, - "After update. Device map size is " - << device_to_adapter_map_.size()); + LOG4CXX_DEBUG( + logger_, + "After update. Device map size is " << device_to_adapter_map_.size()); return true; } @@ -987,6 +1004,13 @@ void TransportManagerImpl::OnDeviceListUpdated(TransportAdapter* ta) { void TransportManagerImpl::Handle(TransportAdapterEvent event) { LOG4CXX_TRACE(logger_, "enter"); + + if (!events_processing_is_active_) { + LOG4CXX_DEBUG(logger_, "Waiting for events handling unlock"); + sync_primitives::AutoLock auto_lock(events_processing_lock_); + events_processing_cond_var_.Wait(auto_lock); + } + switch (event.event_type) { case EventTypeEnum::ON_SEARCH_DONE: { RaiseEvent(&TransportManagerListener::OnScanDevicesFinished); @@ -1297,6 +1321,13 @@ void TransportManagerImpl::SetTelemetryObserver(TMTelemetryObserver* observer) { void TransportManagerImpl::Handle(::protocol_handler::RawMessagePtr msg) { LOG4CXX_TRACE(logger_, "enter"); + + if (!events_processing_is_active_) { + LOG4CXX_DEBUG(logger_, "Waiting for events handling unlock"); + sync_primitives::AutoLock auto_lock(events_processing_lock_); + events_processing_cond_var_.Wait(auto_lock); + } + sync_primitives::AutoReadLock lock(connections_lock_); ConnectionInternal* connection = GetConnection(msg->connection_key()); if (connection == NULL) { diff --git a/src/components/transport_manager/src/usb/libusb/platform_usb_device.cc b/src/components/transport_manager/src/usb/libusb/platform_usb_device.cc index 33709cf0f6b..7d7fb49e6ed 100644 --- a/src/components/transport_manager/src/usb/libusb/platform_usb_device.cc +++ b/src/components/transport_manager/src/usb/libusb/platform_usb_device.cc @@ -83,5 +83,5 @@ std::string PlatformUsbDevice::GetSerialNumber() const { return GetDescString(device_descriptor_.iSerialNumber); } -} // namespace -} // namespace +} // namespace transport_adapter +} // namespace transport_manager diff --git a/src/components/transport_manager/src/usb/libusb/usb_connection.cc b/src/components/transport_manager/src/usb/libusb/usb_connection.cc index 212e6e0ec39..9f57df499e8 100644 --- a/src/components/transport_manager/src/usb/libusb/usb_connection.cc +++ b/src/components/transport_manager/src/usb/libusb/usb_connection.cc @@ -38,8 +38,8 @@ #include -#include "transport_manager/usb/libusb/usb_connection.h" #include "transport_manager/transport_adapter/transport_adapter_impl.h" +#include "transport_manager/usb/libusb/usb_connection.h" #include "utils/logger.h" @@ -137,7 +137,7 @@ void UsbConnection::OnInTransfer(libusb_transfer* transfer) { << transfer->actual_length << ", data:" << hex_data(transfer->buffer, transfer->actual_length)); ::protocol_handler::RawMessagePtr data(new protocol_handler::RawMessage( - 0, 0, in_buffer_, transfer->actual_length)); + 0, 0, in_buffer_, transfer->actual_length, false)); controller_->DataReceiveDone(device_uid_, app_handle_, data); } else { LOG4CXX_ERROR(logger_, diff --git a/src/components/transport_manager/src/usb/libusb/usb_handler.cc b/src/components/transport_manager/src/usb/libusb/usb_handler.cc index c62e80d1bec..975f71e84cc 100644 --- a/src/components/transport_manager/src/usb/libusb/usb_handler.cc +++ b/src/components/transport_manager/src/usb/libusb/usb_handler.cc @@ -33,14 +33,14 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include #include +#include -#include "transport_manager/usb/common.h" #include "transport_manager/transport_adapter/transport_adapter_impl.h" +#include "transport_manager/usb/common.h" -#include "utils/macro.h" #include "utils/logger.h" +#include "utils/macro.h" #include "utils/threads/thread.h" namespace transport_manager { @@ -90,20 +90,20 @@ UsbHandler::UsbHandler() UsbHandler::~UsbHandler() { shutdown_requested_ = true; - if (libusb_context_ != 0) { + thread_->stop(); + LOG4CXX_INFO(logger_, "UsbHandler thread finished"); + if (libusb_context_ != 0) { // This wakes up libusb_handle_events() libusb_hotplug_deregister_callback(libusb_context_, arrived_callback_handle_); libusb_hotplug_deregister_callback(libusb_context_, left_callback_handle_); } - thread_->stop(); - LOG4CXX_INFO(logger_, "UsbHandler thread finished"); + thread_->join(); + delete thread_->delegate(); + threads::DeleteThread(thread_); if (libusb_context_) { libusb_exit(libusb_context_); libusb_context_ = 0; } - thread_->join(); - delete thread_->delegate(); - threads::DeleteThread(thread_); } void UsbHandler::DeviceArrived(libusb_device* device_libusb) { diff --git a/src/components/transport_manager/src/usb/qnx/platform_usb_device.cc b/src/components/transport_manager/src/usb/qnx/platform_usb_device.cc index e85ab12b10e..bb6e3416591 100644 --- a/src/components/transport_manager/src/usb/qnx/platform_usb_device.cc +++ b/src/components/transport_manager/src/usb/qnx/platform_usb_device.cc @@ -76,5 +76,5 @@ std::string PlatformUsbDevice::GetSerialNumber() const { return GetDescString(device_descriptor_.iSerialNumber); } -} // namespace -} // namespace +} // namespace transport_adapter +} // namespace transport_manager diff --git a/src/components/transport_manager/src/usb/qnx/usb_connection.cc b/src/components/transport_manager/src/usb/qnx/usb_connection.cc index b9386c5d9fb..2945639ce95 100644 --- a/src/components/transport_manager/src/usb/qnx/usb_connection.cc +++ b/src/components/transport_manager/src/usb/qnx/usb_connection.cc @@ -37,8 +37,8 @@ #include #include -#include "transport_manager/usb/qnx/usb_connection.h" #include "transport_manager/transport_adapter/transport_adapter_impl.h" +#include "transport_manager/usb/qnx/usb_connection.h" #include "utils/logger.h" @@ -144,7 +144,7 @@ void UsbConnection::OnInTransfer(usbd_urb* urb) { device_uid_, app_handle_, DataReceiveError()); } else { ::protocol_handler::RawMessagePtr msg( - new protocol_handler::RawMessage(0, 0, in_buffer_, len)); + new protocol_handler::RawMessage(0, 0, in_buffer_, len, false)); controller_->DataReceiveDone(device_uid_, app_handle_, msg); } diff --git a/src/components/transport_manager/src/usb/qnx/usb_handler.cc b/src/components/transport_manager/src/usb/qnx/usb_handler.cc index 2336a05f165..9ac4a40d926 100644 --- a/src/components/transport_manager/src/usb/qnx/usb_handler.cc +++ b/src/components/transport_manager/src/usb/qnx/usb_handler.cc @@ -35,11 +35,11 @@ #include -#include #include +#include -#include "transport_manager/usb/common.h" #include "transport_manager/transport_adapter/transport_adapter_impl.h" +#include "transport_manager/usb/common.h" #include "utils/logger.h" @@ -321,5 +321,5 @@ TransportAdapter::Error UsbHandler::Init() { return TransportAdapter::OK; } -} // namespace -} // namespace +} // namespace transport_adapter +} // namespace transport_manager diff --git a/src/components/transport_manager/src/usb/usb_aoa_adapter.cc b/src/components/transport_manager/src/usb/usb_aoa_adapter.cc index b7faf1ef6b6..d1e9c64c3be 100644 --- a/src/components/transport_manager/src/usb/usb_aoa_adapter.cc +++ b/src/components/transport_manager/src/usb/usb_aoa_adapter.cc @@ -34,9 +34,9 @@ */ #include "transport_manager/usb/usb_aoa_adapter.h" -#include "transport_manager/usb/usb_device_scanner.h" -#include "transport_manager/usb/usb_connection_factory.h" #include "transport_manager/usb/common.h" +#include "transport_manager/usb/usb_connection_factory.h" +#include "transport_manager/usb/usb_device_scanner.h" #include "utils/logger.h" namespace transport_manager { @@ -45,7 +45,7 @@ namespace transport_adapter { CREATE_LOGGERPTR_GLOBAL(logger_, "TransportManager") UsbAoaAdapter::UsbAoaAdapter(resumption::LastState& last_state, const TransportManagerSettings& settings) - : TransportAdapterImpl(new UsbDeviceScanner(this), + : TransportAdapterImpl(new UsbDeviceScanner(this, settings), new UsbConnectionFactory(this), NULL, last_state, diff --git a/src/components/transport_manager/src/usb/usb_connection_factory.cc b/src/components/transport_manager/src/usb/usb_connection_factory.cc index 528855cd50d..401dde2534d 100644 --- a/src/components/transport_manager/src/usb/usb_connection_factory.cc +++ b/src/components/transport_manager/src/usb/usb_connection_factory.cc @@ -31,8 +31,8 @@ */ #include "transport_manager/usb/usb_connection_factory.h" -#include "transport_manager/usb/usb_device.h" #include "transport_manager/transport_adapter/transport_adapter_impl.h" +#include "transport_manager/usb/usb_device.h" #include "utils/logger.h" #if defined(__QNXNTO__) diff --git a/src/components/transport_manager/src/usb/usb_device_scanner.cc b/src/components/transport_manager/src/usb/usb_device_scanner.cc index 092fd29f1a5..51d521c1bf4 100644 --- a/src/components/transport_manager/src/usb/usb_device_scanner.cc +++ b/src/components/transport_manager/src/usb/usb_device_scanner.cc @@ -33,9 +33,9 @@ #include #include "transport_manager/transport_adapter/transport_adapter_impl.h" -#include "transport_manager/usb/usb_device_scanner.h" -#include "transport_manager/usb/usb_device.h" #include "transport_manager/usb/common.h" +#include "transport_manager/usb/usb_device.h" +#include "transport_manager/usb/usb_device_scanner.h" #include "utils/logger.h" @@ -47,6 +47,7 @@ CREATE_LOGGERPTR_GLOBAL(logger_, "TransportManager") class AoaInitSequence : public UsbControlTransferSequence { public: AoaInitSequence(); + AoaInitSequence(const TransportManagerSettings& settings); virtual ~AoaInitSequence() {} private: @@ -86,8 +87,9 @@ void UsbDeviceScanner::OnDeviceLeft(PlatformUsbDevice* device) { } } -UsbDeviceScanner::UsbDeviceScanner(TransportAdapterController* controller) - : controller_(controller) {} +UsbDeviceScanner::UsbDeviceScanner(TransportAdapterController* controller, + const TransportManagerSettings& settings) + : controller_(controller), settings_(settings) {} UsbDeviceScanner::~UsbDeviceScanner() {} @@ -171,28 +173,29 @@ class AoaInitSequence::AoaTurnIntoAccessoryMode : public UsbControlOutTransfer { } }; -static char manufacturer[] = "SDL"; -static char model_name[] = "Core"; -static char description[] = "SmartDeviceLink Core Component USB"; -static char version[] = "1.0"; -static char uri[] = "http://www.smartdevicelink.org"; -static char serial_num[] = "N000000"; - -AoaInitSequence::AoaInitSequence() : UsbControlTransferSequence() { +AoaInitSequence::AoaInitSequence(const TransportManagerSettings& settings) + : UsbControlTransferSequence() { + auto manufacturer = settings.aoa_filter_manufacturer().c_str(); + auto model_name = settings.aoa_filter_model_name().c_str(); + auto description = settings.aoa_filter_description().c_str(); + auto version = settings.aoa_filter_version().c_str(); + auto uri = settings.aoa_filter_uri().c_str(); + auto serial_num = settings.aoa_filter_serial_number().c_str(); AddTransfer(new AoaGetProtocolRequest); - AddTransfer(new AoaSendIdString(0, manufacturer, sizeof(manufacturer))); - AddTransfer(new AoaSendIdString(1, model_name, sizeof(model_name))); - AddTransfer(new AoaSendIdString(2, description, sizeof(description))); - AddTransfer(new AoaSendIdString(3, version, sizeof(version))); - AddTransfer(new AoaSendIdString(4, uri, sizeof(uri))); - AddTransfer(new AoaSendIdString(5, serial_num, sizeof(serial_num))); + AddTransfer(new AoaSendIdString(0, manufacturer, strlen(manufacturer))); + AddTransfer(new AoaSendIdString(1, model_name, strlen(model_name))); + AddTransfer(new AoaSendIdString(2, description, strlen(description))); + AddTransfer(new AoaSendIdString(3, version, strlen(version))); + AddTransfer(new AoaSendIdString(4, uri, strlen(uri))); + AddTransfer(new AoaSendIdString(5, serial_num, strlen(serial_num))); AddTransfer(new AoaTurnIntoAccessoryMode); } void UsbDeviceScanner::TurnIntoAccessoryMode(PlatformUsbDevice* device) { LOG4CXX_AUTO_TRACE(logger_); LOG4CXX_DEBUG(logger_, "PlatformUsbDevice: " << device); - GetUsbHandler()->StartControlTransferSequence(new AoaInitSequence, device); + GetUsbHandler()->StartControlTransferSequence(new AoaInitSequence(settings_), + device); } void UsbDeviceScanner::SupportedDeviceFound(PlatformUsbDevice* device) { @@ -247,5 +250,5 @@ bool UsbDeviceScanner::IsInitialised() const { return true; } -} // namespace -} // namespace +} // namespace transport_adapter +} // namespace transport_manager diff --git a/src/components/transport_manager/test/include/transport_manager/cloud/sample_websocket_server.h b/src/components/transport_manager/test/include/transport_manager/cloud/sample_websocket_server.h index f785263c985..a8b801c1fe1 100644 --- a/src/components/transport_manager/test/include/transport_manager/cloud/sample_websocket_server.h +++ b/src/components/transport_manager/test/include/transport_manager/cloud/sample_websocket_server.h @@ -159,4 +159,4 @@ class WSSSession { } // namespace websocket } // namespace sample -#endif // SRC_COMPONENTS_TRANSPORT_MANAGER_TEST_INCLUDE_TRANSPORT_MANAGER_CLOUD_SAMPLE_WEBSOCKET_SERVER_H_ \ No newline at end of file +#endif // SRC_COMPONENTS_TRANSPORT_MANAGER_TEST_INCLUDE_TRANSPORT_MANAGER_CLOUD_SAMPLE_WEBSOCKET_SERVER_H_ diff --git a/src/components/transport_manager/test/include/transport_manager/mock_transport_manager_impl.h b/src/components/transport_manager/test/include/transport_manager/mock_transport_manager_impl.h index e94586a8565..758d22dae26 100644 --- a/src/components/transport_manager/test/include/transport_manager/mock_transport_manager_impl.h +++ b/src/components/transport_manager/test/include/transport_manager/mock_transport_manager_impl.h @@ -33,10 +33,10 @@ #ifndef SRC_COMPONENTS_TRANSPORT_MANAGER_TEST_INCLUDE_TRANSPORT_MANAGER_MOCK_TRANSPORT_MANAGER_IMPL_H_ #define SRC_COMPONENTS_TRANSPORT_MANAGER_TEST_INCLUDE_TRANSPORT_MANAGER_MOCK_TRANSPORT_MANAGER_IMPL_H_ -#include "gmock/gmock.h" #include "config_profile/profile.h" -#include "transport_manager/transport_manager_impl.h" +#include "gmock/gmock.h" #include "transport_manager/mock_transport_manager_settings.h" +#include "transport_manager/transport_manager_impl.h" #include "transport_manager/transport_manager_settings.h" namespace test { diff --git a/src/components/transport_manager/test/include/transport_manager/mock_transport_manager_listener.h b/src/components/transport_manager/test/include/transport_manager/mock_transport_manager_listener.h index 4eaf34d041f..0c9ca959e9f 100644 --- a/src/components/transport_manager/test/include/transport_manager/mock_transport_manager_listener.h +++ b/src/components/transport_manager/test/include/transport_manager/mock_transport_manager_listener.h @@ -33,10 +33,10 @@ #ifndef SRC_COMPONENTS_TRANSPORT_MANAGER_TEST_INCLUDE_TRANSPORT_MANAGER_MOCK_TRANSPORT_MANAGER_LISTENER_H_ #define SRC_COMPONENTS_TRANSPORT_MANAGER_TEST_INCLUDE_TRANSPORT_MANAGER_MOCK_TRANSPORT_MANAGER_LISTENER_H_ -#include #include -#include "transport_manager/transport_manager_listener.h" +#include #include "protocol/raw_message.h" +#include "transport_manager/transport_manager_listener.h" namespace test { namespace components { diff --git a/src/components/transport_manager/test/include/transport_manager/raw_message_matcher.h b/src/components/transport_manager/test/include/transport_manager/raw_message_matcher.h index 9c7327e6fb1..2ee699096f8 100644 --- a/src/components/transport_manager/test/include/transport_manager/raw_message_matcher.h +++ b/src/components/transport_manager/test/include/transport_manager/raw_message_matcher.h @@ -38,8 +38,8 @@ #include -#include "transport_manager/common.h" #include "protocol/common.h" +#include "transport_manager/common.h" using ::testing::Matcher; using ::testing::MatcherInterface; diff --git a/src/components/transport_manager/test/include/transport_manager/tcp/mock_tcp_transport_adapter.h b/src/components/transport_manager/test/include/transport_manager/tcp/mock_tcp_transport_adapter.h index 432e4f3fa0f..daa9397b7d2 100644 --- a/src/components/transport_manager/test/include/transport_manager/tcp/mock_tcp_transport_adapter.h +++ b/src/components/transport_manager/test/include/transport_manager/tcp/mock_tcp_transport_adapter.h @@ -34,6 +34,7 @@ #define SRC_COMPONENTS_TRANSPORT_MANAGER_TEST_INCLUDE_TRANSPORT_MANAGER_TCP_MOCK_TCP_TRANSPORT_ADAPTER_H_ #include "gmock/gmock.h" +#include "transport_manager/common.h" #include "transport_manager/tcp/tcp_transport_adapter.h" #include "transport_manager/transport_manager_settings.h" @@ -50,14 +51,18 @@ class MockTCPTransportAdapter : public TcpTransportAdapter { resumption::LastState& last_state, const transport_manager::TransportManagerSettings& settings) : TcpTransportAdapter(port, last_state, settings) {} - MOCK_CONST_METHOD2(FindEstablishedConnection, - ConnectionSPtr(const DeviceUID& device_handle, - const ApplicationHandle& app_handle)); + MOCK_CONST_METHOD2( + FindEstablishedConnection, + ConnectionSPtr(const transport_manager::DeviceUID& device_handle, + const transport_manager::ApplicationHandle& app_handle)); - MOCK_CONST_METHOD1(FindDevice, DeviceSptr(const DeviceUID& device_handle)); + MOCK_CONST_METHOD1( + FindDevice, + DeviceSptr(const transport_manager::DeviceUID& device_handle)); MOCK_METHOD2(Connect, - TransportAdapter::Error(const DeviceUID& device_handle, - const ApplicationHandle& app_handle)); + TransportAdapter::Error( + const transport_manager::DeviceUID& device_handle, + const transport_manager::ApplicationHandle& app_handle)); void CallStore() { Store(); } diff --git a/src/components/transport_manager/test/include/transport_manager/transport_adapter/mock_client_connection_listener.h b/src/components/transport_manager/test/include/transport_manager/transport_adapter/mock_client_connection_listener.h index 0f6f1e9f14b..6d451294de5 100644 --- a/src/components/transport_manager/test/include/transport_manager/transport_adapter/mock_client_connection_listener.h +++ b/src/components/transport_manager/test/include/transport_manager/transport_adapter/mock_client_connection_listener.h @@ -50,6 +50,12 @@ class MockClientConnectionListener MOCK_METHOD0( StartListening, ::transport_manager::transport_adapter::TransportAdapter::Error()); + MOCK_METHOD0( + SuspendListening, + ::transport_manager::transport_adapter::TransportAdapter::Error()); + MOCK_METHOD0( + ResumeListening, + ::transport_manager::transport_adapter::TransportAdapter::Error()); MOCK_METHOD0( StopListening, ::transport_manager::transport_adapter::TransportAdapter::Error()); diff --git a/src/components/transport_manager/test/include/transport_manager/transport_adapter/mock_transport_adapter_impl.h b/src/components/transport_manager/test/include/transport_manager/transport_adapter/mock_transport_adapter_impl.h index 3a1422cee12..592ed855ccc 100644 --- a/src/components/transport_manager/test/include/transport_manager/transport_adapter/mock_transport_adapter_impl.h +++ b/src/components/transport_manager/test/include/transport_manager/transport_adapter/mock_transport_adapter_impl.h @@ -34,19 +34,19 @@ #define SRC_COMPONENTS_TRANSPORT_MANAGER_TEST_INCLUDE_TRANSPORT_MANAGER_TRANSPORT_ADAPTER_MOCK_TRANSPORT_ADAPTER_IMPL_H_ #include "gmock/gmock.h" -#include "transport_manager/transport_manager_settings.h" -#include "transport_manager/transport_adapter/transport_adapter_impl.h" -#include "transport_manager/transport_adapter/device.h" #include "transport_manager/common.h" +#include "transport_manager/transport_adapter/device.h" +#include "transport_manager/transport_adapter/transport_adapter_impl.h" +#include "transport_manager/transport_manager_settings.h" -using ::transport_manager::transport_adapter::TransportAdapterImpl; -using ::transport_manager::transport_adapter::DeviceScanner; -using ::transport_manager::transport_adapter::ServerConnectionFactory; +using ::transport_manager::ApplicationHandle; +using ::transport_manager::DeviceUID; using ::transport_manager::transport_adapter::ClientConnectionListener; -using ::transport_manager::transport_adapter::DeviceType; using ::transport_manager::transport_adapter::ConnectionSPtr; -using ::transport_manager::DeviceUID; -using ::transport_manager::ApplicationHandle; +using ::transport_manager::transport_adapter::DeviceScanner; +using ::transport_manager::transport_adapter::DeviceType; +using ::transport_manager::transport_adapter::ServerConnectionFactory; +using ::transport_manager::transport_adapter::TransportAdapterImpl; namespace test { namespace components { 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 55a35fb4ea8..c6e007b62a5 100644 --- a/src/components/transport_manager/test/network_interface_listener_test.cc +++ b/src/components/transport_manager/test/network_interface_listener_test.cc @@ -3,8 +3,8 @@ #include #include "gtest/gtest.h" -#include "transport_manager/tcp/network_interface_listener_impl.h" #include "transport_manager/tcp/mock_tcp_client_listener.h" +#include "transport_manager/tcp/network_interface_listener_impl.h" #include "utils/test_async_waiter.h" #include "utils/threads/thread.h" @@ -15,7 +15,7 @@ namespace transport_manager_test { namespace { const long kThreadStartWaitMsec = 10; const uint32_t kStartNotificationTimeoutMsec = 500; -} +} // namespace using ::testing::_; using ::testing::AtLeast; 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 da58466c299..97c8fac9c94 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 @@ -15,7 +15,7 @@ namespace transport_manager_test { namespace { const long kThreadStartWaitMsec = 10; const uint32_t kStartNotificationTimeoutMsec = 500; -} +} // namespace using ::testing::_; using ::testing::AtLeast; @@ -207,7 +207,8 @@ TEST_F(NetworkInterfaceListenerTest, DesignatedInterface_IPAddressChanged) { SetDummyInterfaceTable(entries1); EXPECT_CALL(mock_tcp_client_listener_, - OnIPAddressUpdated(entries1[0].ipv4_address, "")).Times(1); + OnIPAddressUpdated(entries1[0].ipv4_address, "")) + .Times(1); // this test case doesn't call Start() - we only check the behavior of // NotifyIPAddresses() @@ -216,7 +217,8 @@ TEST_F(NetworkInterfaceListenerTest, DesignatedInterface_IPAddressChanged) { SetDummyInterfaceTable(entries2); EXPECT_CALL(mock_tcp_client_listener_, - OnIPAddressUpdated(entries2[0].ipv4_address, "")).Times(1); + OnIPAddressUpdated(entries2[0].ipv4_address, "")) + .Times(1); interface_listener_impl_->testCallNotifyIPAddresses(); @@ -239,7 +241,8 @@ TEST_F(NetworkInterfaceListenerTest, DesignatedInterface_IPAddressNotChanged) { SetDummyInterfaceTable(entries1); EXPECT_CALL(mock_tcp_client_listener_, - OnIPAddressUpdated(entries1[0].ipv4_address, "")).Times(1); + OnIPAddressUpdated(entries1[0].ipv4_address, "")) + .Times(1); interface_listener_impl_->testCallNotifyIPAddresses(); @@ -268,9 +271,10 @@ TEST_F(NetworkInterfaceListenerTest, DesignatedInterface_GoesUnavailable) { SetDummyInterfaceTable(entries1); - EXPECT_CALL(mock_tcp_client_listener_, - OnIPAddressUpdated(entries1[0].ipv4_address, - entries1[0].ipv6_address)).Times(1); + EXPECT_CALL( + mock_tcp_client_listener_, + OnIPAddressUpdated(entries1[0].ipv4_address, entries1[0].ipv6_address)) + .Times(1); interface_listener_impl_->testCallNotifyIPAddresses(); @@ -297,9 +301,10 @@ TEST_F(NetworkInterfaceListenerTest, DesignatedInterface_Removed) { SetDummyInterfaceTable(entries1); - EXPECT_CALL(mock_tcp_client_listener_, - OnIPAddressUpdated(entries1[0].ipv4_address, - entries1[0].ipv6_address)).Times(1); + EXPECT_CALL( + mock_tcp_client_listener_, + OnIPAddressUpdated(entries1[0].ipv4_address, entries1[0].ipv6_address)) + .Times(1); interface_listener_impl_->testCallNotifyIPAddresses(); @@ -331,7 +336,8 @@ TEST_F(NetworkInterfaceListenerTest, DesignatedInterface_Added) { SetDummyInterfaceTable(entries2); EXPECT_CALL(mock_tcp_client_listener_, - OnIPAddressUpdated(entries2[1].ipv4_address, "")).Times(1); + OnIPAddressUpdated(entries2[1].ipv4_address, "")) + .Times(1); interface_listener_impl_->testCallNotifyIPAddresses(); @@ -386,9 +392,10 @@ TEST_F(NetworkInterfaceListenerTest, // dummy_int1 should not be selected struct InterfaceEntry* expected = &entries[1]; - EXPECT_CALL(mock_tcp_client_listener_, - OnIPAddressUpdated(expected->ipv4_address, - expected->ipv6_address)).Times(1); + EXPECT_CALL( + mock_tcp_client_listener_, + OnIPAddressUpdated(expected->ipv4_address, expected->ipv6_address)) + .Times(1); interface_listener_impl_->testCallNotifyIPAddresses(); @@ -412,7 +419,8 @@ TEST_F(NetworkInterfaceListenerTest, AutoSelectInterface_SkipEmptyInterface) { // net_dummy2 should not be selected struct InterfaceEntry* expected = &entries[0]; EXPECT_CALL(mock_tcp_client_listener_, - OnIPAddressUpdated(expected->ipv4_address, "")).Times(1); + OnIPAddressUpdated(expected->ipv4_address, "")) + .Times(1); interface_listener_impl_->testCallNotifyIPAddresses(); @@ -434,9 +442,10 @@ TEST_F(NetworkInterfaceListenerTest, // dummy_int1 should not be selected struct InterfaceEntry* expected = &entries[1]; - EXPECT_CALL(mock_tcp_client_listener_, - OnIPAddressUpdated(expected->ipv4_address, - expected->ipv6_address)).Times(1); + EXPECT_CALL( + mock_tcp_client_listener_, + OnIPAddressUpdated(expected->ipv4_address, expected->ipv6_address)) + .Times(1); SetDummyInterfaceTable(entries); @@ -499,9 +508,10 @@ TEST_F(NetworkInterfaceListenerTest, AutoSelectInterface_EnableInterface) { entries[0].flags |= IFF_RUNNING; SetDummyInterfaceTable(entries); - EXPECT_CALL(mock_tcp_client_listener_, - OnIPAddressUpdated(entries[0].ipv4_address, - entries[0].ipv6_address)).Times(1); + EXPECT_CALL( + mock_tcp_client_listener_, + OnIPAddressUpdated(entries[0].ipv4_address, entries[0].ipv6_address)) + .Times(1); interface_listener_impl_->testCallNotifyIPAddresses(); @@ -550,9 +560,10 @@ TEST_F(NetworkInterfaceListenerTest, AutoSelectInterface_SwitchInterface) { switched = &entries[0]; } - EXPECT_CALL(mock_tcp_client_listener_, - OnIPAddressUpdated(switched->ipv4_address, - switched->ipv6_address)).Times(1); + EXPECT_CALL( + mock_tcp_client_listener_, + OnIPAddressUpdated(switched->ipv4_address, switched->ipv6_address)) + .Times(1); interface_listener_impl_->testCallNotifyIPAddresses(); diff --git a/src/components/transport_manager/test/sample_websocket_server.cc b/src/components/transport_manager/test/sample_websocket_server.cc index 2cb45242aa7..917184a3612 100644 --- a/src/components/transport_manager/test/sample_websocket_server.cc +++ b/src/components/transport_manager/test/sample_websocket_server.cc @@ -375,4 +375,4 @@ void WSSSession::on_accept(boost::system::error_code ec) { } } // namespace websocket -} // namespace sample \ No newline at end of file +} // namespace sample 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 1f4a17cf6cf..d524b3eb6a9 100644 --- a/src/components/transport_manager/test/tcp_client_listener_test.cc +++ b/src/components/transport_manager/test/tcp_client_listener_test.cc @@ -33,16 +33,16 @@ #include #include #include -#include #include +#include #include "gtest/gtest.h" -#include "transport_manager/transport_adapter/mock_transport_adapter.h" -#include "transport_manager/tcp/tcp_client_listener.h" -#include "transport_manager/tcp/network_interface_listener.h" #include "transport_manager/mock_transport_manager.h" -#include "transport_manager/transport_adapter/transport_adapter_controller.h" +#include "transport_manager/tcp/network_interface_listener.h" +#include "transport_manager/tcp/tcp_client_listener.h" #include "transport_manager/transport_adapter/mock_device.h" +#include "transport_manager/transport_adapter/mock_transport_adapter.h" +#include "transport_manager/transport_adapter/transport_adapter_controller.h" #include "utils/test_async_waiter.h" #include "utils/threads/thread.h" @@ -60,7 +60,7 @@ using namespace ::transport_manager::transport_adapter; namespace { const long kThreadStartWaitMsec = 10; const uint32_t kConnectionCreatedTimeoutMsec = 200; -} +} // namespace class MockTransportAdapterController : public TransportAdapterController { public: @@ -395,7 +395,8 @@ TEST_P(TcpClientListenerTest, OnIPAddressUpdated_IPv4Address_changed) { expected_config_1.insert(std::make_pair(tc_tcp_port, test_port)); EXPECT_CALL(adapter_controller_mock_, - TransportConfigUpdated(expected_config_1)).Times(1); + TransportConfigUpdated(expected_config_1)) + .Times(1); tcp_client_listener_->OnIPAddressUpdated(test_ipv4_addr_1, test_ipv6_addr); @@ -406,7 +407,8 @@ TEST_P(TcpClientListenerTest, OnIPAddressUpdated_IPv4Address_changed) { expected_config_2.insert(std::make_pair(tc_tcp_port, test_port)); EXPECT_CALL(adapter_controller_mock_, - TransportConfigUpdated(expected_config_2)).Times(1); + TransportConfigUpdated(expected_config_2)) + .Times(1); tcp_client_listener_->OnIPAddressUpdated(test_ipv4_addr_2, test_ipv6_addr); @@ -440,7 +442,8 @@ TEST_P(TcpClientListenerTest, OnIPAddressUpdated_IPv4Address_same) { expected_config_1.insert(std::make_pair(tc_tcp_port, test_port)); EXPECT_CALL(adapter_controller_mock_, - TransportConfigUpdated(expected_config_1)).Times(1); + TransportConfigUpdated(expected_config_1)) + .Times(1); tcp_client_listener_->OnIPAddressUpdated(test_ipv4_addr_1, test_ipv6_addr); @@ -485,7 +488,8 @@ TEST_P(TcpClientListenerTest, OnIPAddressUpdated_IPv4Address_disabled) { expected_config_1.insert(std::make_pair(tc_tcp_port, test_port)); EXPECT_CALL(adapter_controller_mock_, - TransportConfigUpdated(expected_config_1)).Times(1); + TransportConfigUpdated(expected_config_1)) + .Times(1); tcp_client_listener_->OnIPAddressUpdated(test_ipv4_addr_1, test_ipv6_addr); @@ -496,7 +500,8 @@ TEST_P(TcpClientListenerTest, OnIPAddressUpdated_IPv4Address_disabled) { expected_config_2.insert(std::make_pair(tc_tcp_port, test_port)); EXPECT_CALL(adapter_controller_mock_, - TransportConfigUpdated(expected_config_2)).Times(1); + TransportConfigUpdated(expected_config_2)) + .Times(1); tcp_client_listener_->OnIPAddressUpdated(test_ipv4_addr_2, test_ipv6_addr); @@ -530,7 +535,8 @@ TEST_P(TcpClientListenerTest, OnIPAddressUpdated_IPv4Address_reenabled) { expected_config_1.insert(std::make_pair(tc_tcp_port, test_port)); EXPECT_CALL(adapter_controller_mock_, - TransportConfigUpdated(expected_config_1)).Times(1); + TransportConfigUpdated(expected_config_1)) + .Times(1); tcp_client_listener_->OnIPAddressUpdated(test_ipv4_addr_1, test_ipv6_addr); @@ -541,7 +547,8 @@ TEST_P(TcpClientListenerTest, OnIPAddressUpdated_IPv4Address_reenabled) { expected_config_2.insert(std::make_pair(tc_tcp_port, test_port)); EXPECT_CALL(adapter_controller_mock_, - TransportConfigUpdated(expected_config_2)).Times(1); + TransportConfigUpdated(expected_config_2)) + .Times(1); tcp_client_listener_->OnIPAddressUpdated(test_ipv4_addr_2, test_ipv6_addr); @@ -552,7 +559,8 @@ TEST_P(TcpClientListenerTest, OnIPAddressUpdated_IPv4Address_reenabled) { expected_config_3.insert(std::make_pair(tc_tcp_port, test_port)); EXPECT_CALL(adapter_controller_mock_, - TransportConfigUpdated(expected_config_3)).Times(1); + TransportConfigUpdated(expected_config_3)) + .Times(1); tcp_client_listener_->OnIPAddressUpdated(test_ipv4_addr_3, test_ipv6_addr); diff --git a/src/components/transport_manager/test/tcp_device_test.cc b/src/components/transport_manager/test/tcp_device_test.cc index 55fa5ac5d34..f52270d1ee9 100644 --- a/src/components/transport_manager/test/tcp_device_test.cc +++ b/src/components/transport_manager/test/tcp_device_test.cc @@ -30,8 +30,8 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include "gtest/gtest.h" #include "transport_manager/tcp/tcp_device.h" +#include "gtest/gtest.h" #include "transport_manager/transport_adapter/device.h" namespace test { diff --git a/src/components/transport_manager/test/tcp_transport_adapter_test.cc b/src/components/transport_manager/test/tcp_transport_adapter_test.cc index 959180948a7..f5f6cc38c84 100644 --- a/src/components/transport_manager/test/tcp_transport_adapter_test.cc +++ b/src/components/transport_manager/test/tcp_transport_adapter_test.cc @@ -30,24 +30,24 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include "gtest/gtest.h" #include "transport_manager/tcp/tcp_transport_adapter.h" -#include "resumption/last_state_impl.h" +#include "gtest/gtest.h" #include "protocol/raw_message.h" +#include "resumption/last_state_impl.h" +#include "transport_manager/mock_transport_manager_settings.h" +#include "transport_manager/tcp/mock_tcp_transport_adapter.h" #include "transport_manager/transport_adapter/connection.h" -#include "transport_manager/transport_adapter/mock_transport_adapter_listener.h" -#include "transport_manager/transport_adapter/mock_device.h" #include "transport_manager/transport_adapter/mock_connection.h" -#include "transport_manager/tcp/mock_tcp_transport_adapter.h" -#include "transport_manager/mock_transport_manager_settings.h" +#include "transport_manager/transport_adapter/mock_device.h" +#include "transport_manager/transport_adapter/mock_transport_adapter_listener.h" namespace test { namespace components { namespace transport_manager_test { +using ::testing::_; using ::testing::Return; using ::testing::ReturnRef; -using ::testing::_; using namespace ::protocol_handler; using namespace ::transport_manager; diff --git a/src/components/transport_manager/test/transport_adapter_listener_test.cc b/src/components/transport_manager/test/transport_adapter_listener_test.cc index a5d08035aef..9f18d5bc13d 100644 --- a/src/components/transport_manager/test/transport_adapter_listener_test.cc +++ b/src/components/transport_manager/test/transport_adapter_listener_test.cc @@ -76,7 +76,8 @@ TEST_F(TransportAdapterListenerTest, OnCommunicationError) { ReceiveEventFromDevice(IsEvent(EventTypeEnum::ON_COMMUNICATION_ERROR, &adapter_mock, dev_id, - app_handle))).WillOnce(Return(E_SUCCESS)); + app_handle))) + .WillOnce(Return(E_SUCCESS)); transport_listener.OnCommunicationError(&adapter_mock, dev_id, app_handle); } @@ -129,7 +130,7 @@ TEST_F(TransportAdapterListenerTest, OnDataReceiveFailed) { TEST_F(TransportAdapterListenerTest, OnDataSendDone) { unsigned char data[3] = {0x20, 0x07, 0x01}; ::protocol_handler::RawMessagePtr data_container = - std::make_shared< ::protocol_handler::RawMessage>(1, 1, data, 3); + std::make_shared< ::protocol_handler::RawMessage>(1, 1, data, 3, false); EXPECT_CALL(tr_mock, ReceiveEventFromDevice(IsEvent(EventTypeEnum::ON_SEND_DONE, @@ -145,7 +146,7 @@ TEST_F(TransportAdapterListenerTest, OnDataSendDone) { TEST_F(TransportAdapterListenerTest, OnDataSendFailed) { unsigned char data[3] = {0x20, 0x07, 0x01}; ::protocol_handler::RawMessagePtr data_container = - std::make_shared< ::protocol_handler::RawMessage>(1, 1, data, 3); + std::make_shared< ::protocol_handler::RawMessage>(1, 1, data, 3, false); DataSendError err; EXPECT_CALL(tr_mock, @@ -195,7 +196,8 @@ TEST_F(TransportAdapterListenerTest, OnFindNewApplicationsRequest) { IsEvent(EventTypeEnum::ON_FIND_NEW_APPLICATIONS_REQUEST, &adapter_mock, "", - 0))).WillOnce(Return(E_SUCCESS)); + 0))) + .WillOnce(Return(E_SUCCESS)); transport_listener.OnFindNewApplicationsRequest(&adapter_mock); } @@ -225,7 +227,8 @@ TEST_F(TransportAdapterListenerTest, OnUnexpectedDisconnect) { ReceiveEventFromDevice(IsEvent(EventTypeEnum::ON_UNEXPECTED_DISCONNECT, &adapter_mock, dev_id, - app_handle))).WillOnce(Return(E_SUCCESS)); + app_handle))) + .WillOnce(Return(E_SUCCESS)); transport_listener.OnUnexpectedDisconnect( &adapter_mock, dev_id, app_handle, err); } diff --git a/src/components/transport_manager/test/transport_adapter_test.cc b/src/components/transport_manager/test/transport_adapter_test.cc index 35630e45dd1..712cc5f7500 100644 --- a/src/components/transport_manager/test/transport_adapter_test.cc +++ b/src/components/transport_manager/test/transport_adapter_test.cc @@ -118,12 +118,11 @@ class TransportAdapterTest : public ::testing::Test { "101.180.1.213", "23234", "/folder/img_index(1)/file.html/"}, - TestEndpoint{ - "[2600:3c00::f03c:91ff:fe73:2b08]:31333/folder/img_index(1)/" - "file.html", - "[2600:3c00::f03c:91ff:fe73:2b08]", - "31333", - "/folder/img_index(1)/file.html/"}, + TestEndpoint{"[2600:3c00::f03c:91ff:fe73:2b08]:31333/folder/img_index(1)/" + "file.html", + "[2600:3c00::f03c:91ff:fe73:2b08]", + "31333", + "/folder/img_index(1)/file.html/"}, // With query and/or fragment TestEndpoint{ "username@localhost:22/folder/img_index(1)/" @@ -133,15 +132,14 @@ class TransportAdapterTest : public ::testing::Test { "/folder/img_index(1)/file.html/" "?eventId=2345&eventName='some%20event'&eventSuccess=" "true"}, - TestEndpoint{ - "username@localhost.com:80/folder/img_index(1)/" - "file.html?eventId=2345&eventName='some%20event'&" - "eventSuccess=true#section1", - "username@localhost.com", - "80", - "/folder/img_index(1)/file.html/" - "?eventId=2345&eventName='some%20event'&eventSuccess=true#" - "section1"}, + TestEndpoint{"username@localhost.com:80/folder/img_index(1)/" + "file.html?eventId=2345&eventName='some%20event'&" + "eventSuccess=true#section1", + "username@localhost.com", + "80", + "/folder/img_index(1)/file.html/" + "?eventId=2345&eventName='some%20event'&eventSuccess=true#" + "section1"}, TestEndpoint{ "localhost:443/" "?eventId=2345&eventName='some%20event'&eventSuccess=true#section1", @@ -200,18 +198,16 @@ class TransportAdapterTest : public ::testing::Test { "232", "/folder/img\tindex(1)//file.html/"}, // Incorrect query - TestEndpoint{ - "username@localhost:443/?eventId=2345&eventName='some " - "event'&eventSuccess=true", - "username@localhost", - "443", - "?eventId=2345&eventName='some event'&eventSuccess=true"}, - TestEndpoint{ - "username@localhost:443/" - "?eventId=2345&eventName='some\tevent'&eventSuccess=true", - "username@localhost", - "443", - "?eventId=2345&eventName='some\tevent'&eventSuccess=true"}, + TestEndpoint{"username@localhost:443/?eventId=2345&eventName='some " + "event'&eventSuccess=true", + "username@localhost", + "443", + "?eventId=2345&eventName='some event'&eventSuccess=true"}, + TestEndpoint{"username@localhost:443/" + "?eventId=2345&eventName='some\tevent'&eventSuccess=true", + "username@localhost", + "443", + "?eventId=2345&eventName='some\tevent'&eventSuccess=true"}, // Incorrect fragment TestEndpoint{"a1(b2).com:80/folder/img_index(1)/file.html#section 1", "a1(b2).com", @@ -973,7 +969,7 @@ TEST_F(TransportAdapterTest, SendData) { const unsigned int kSize = 3; unsigned char data[kSize] = {0x20, 0x07, 0x01}; const RawMessagePtr kMessage = - std::make_shared(1, 1, data, kSize); + std::make_shared(1, 1, data, kSize, false); EXPECT_CALL(*mock_connection, SendData(kMessage)) .WillOnce(Return(TransportAdapter::OK)); @@ -1013,7 +1009,7 @@ TEST_F(TransportAdapterTest, SendData_ConnectionNotEstablished) { const unsigned int kSize = 3; unsigned char data[kSize] = {0x20, 0x07, 0x01}; const RawMessagePtr kMessage = - std::make_shared(1, 1, data, kSize); + std::make_shared(1, 1, data, kSize, false); EXPECT_CALL(*mock_connection, SendData(kMessage)).Times(0); res = transport_adapter.SendData(dev_id, app_handle, kMessage); @@ -1039,7 +1035,8 @@ TEST_F(TransportAdapterTest, StartClientListening_ClientNotInitialized) { EXPECT_CALL(*clientMock, IsInitialised()).WillOnce(Return(false)); EXPECT_CALL(*clientMock, StartListening()).Times(0); - TransportAdapter::Error res = transport_adapter.StartClientListening(); + TransportAdapter::Error res = transport_adapter.ChangeClientListening( + transport_manager::TransportAction::kVisibilityOn); EXPECT_EQ(TransportAdapter::BAD_STATE, res); EXPECT_CALL(*dev_mock, Terminate()); @@ -1062,7 +1059,8 @@ TEST_F(TransportAdapterTest, StartClientListening) { EXPECT_CALL(*clientMock, StartListening()) .WillOnce(Return(TransportAdapter::OK)); - TransportAdapter::Error res = transport_adapter.StartClientListening(); + TransportAdapter::Error res = transport_adapter.ChangeClientListening( + transport_manager::TransportAction::kVisibilityOn); EXPECT_EQ(TransportAdapter::OK, res); EXPECT_CALL(*dev_mock, Terminate()); @@ -1096,7 +1094,8 @@ TEST_F(TransportAdapterTest, StopClientListening_Success) { EXPECT_CALL(*clientMock, StopListening()) .WillOnce(Return(TransportAdapter::OK)); - res = transport_adapter.StopClientListening(); + res = transport_adapter.ChangeClientListening( + transport_manager::TransportAction::kVisibilityOff); EXPECT_EQ(TransportAdapter::OK, res); EXPECT_CALL(*dev_mock, Terminate()); diff --git a/src/components/transport_manager/test/transport_manager_default_test.cc b/src/components/transport_manager/test/transport_manager_default_test.cc index 8e8a964228a..40938d0370b 100644 --- a/src/components/transport_manager/test/transport_manager_default_test.cc +++ b/src/components/transport_manager/test/transport_manager_default_test.cc @@ -30,20 +30,20 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include "gtest/gtest.h" -#include "transport_manager/transport_manager.h" #include "transport_manager/transport_manager_default.h" -#include "transport_manager/mock_transport_manager_settings.h" +#include "gtest/gtest.h" #include "resumption/mock_last_state.h" +#include "transport_manager/mock_transport_manager_settings.h" +#include "transport_manager/transport_manager.h" namespace test { namespace components { namespace transport_manager_test { using resumption_test::MockLastState; +using ::testing::NiceMock; using ::testing::Return; using ::testing::ReturnRef; -using ::testing::NiceMock; namespace { const std::string kDeviceName = "name"; @@ -57,6 +57,22 @@ const std::string kTransportManager = "TransportManager"; const std::string kTcpAdapter = "TcpAdapter"; const std::string kBluetoothAdapter = "BluetoothAdapter"; const std::string kDevices = "devices"; +std::vector kBTUUID = {0x93, + 0x6D, + 0xA0, + 0x1F, + 0x9A, + 0xBD, + 0x4D, + 0x9D, + 0x80, + 0xC7, + 0x02, + 0xAF, + 0x85, + 0xC8, + 0x22, + 0xA8}; } // namespace TEST(TestTransportManagerDefault, Init_LastStateNotUsed) { @@ -78,7 +94,22 @@ TEST(TestTransportManagerDefault, Init_LastStateNotUsed) { EXPECT_CALL(transport_manager_settings, transport_manager_tcp_adapter_network_interface()) .WillRepeatedly(ReturnRef(network_interface)); - + EXPECT_CALL(transport_manager_settings, bluetooth_uuid()) + .WillRepeatedly(Return(kBTUUID.data())); + + std::string dummy_parameter; + EXPECT_CALL(transport_manager_settings, aoa_filter_manufacturer()) + .WillRepeatedly(ReturnRef(dummy_parameter)); + EXPECT_CALL(transport_manager_settings, aoa_filter_model_name()) + .WillRepeatedly(ReturnRef(dummy_parameter)); + EXPECT_CALL(transport_manager_settings, aoa_filter_description()) + .WillRepeatedly(ReturnRef(dummy_parameter)); + EXPECT_CALL(transport_manager_settings, aoa_filter_version()) + .WillRepeatedly(ReturnRef(dummy_parameter)); + EXPECT_CALL(transport_manager_settings, aoa_filter_uri()) + .WillRepeatedly(ReturnRef(dummy_parameter)); + EXPECT_CALL(transport_manager_settings, aoa_filter_serial_number()) + .WillRepeatedly(ReturnRef(dummy_parameter)); transport_manager.Init(mock_last_state); transport_manager.Stop(); } @@ -114,6 +145,8 @@ TEST(TestTransportManagerDefault, Init_LastStateUsed) { EXPECT_CALL(transport_manager_settings, transport_manager_tcp_adapter_network_interface()) .WillRepeatedly(ReturnRef(network_interface)); + EXPECT_CALL(transport_manager_settings, bluetooth_uuid()) + .WillRepeatedly(Return(kBTUUID.data())); transport_manager.Init(mock_last_state); transport_manager.Stop(); } @@ -149,6 +182,8 @@ TEST(TestTransportManagerDefault, Init_LastStateUsed_InvalidPort) { EXPECT_CALL(transport_manager_settings, transport_manager_tcp_adapter_network_interface()) .WillRepeatedly(ReturnRef(network_interface)); + EXPECT_CALL(transport_manager_settings, bluetooth_uuid()) + .WillRepeatedly(Return(kBTUUID.data())); transport_manager.Init(mock_last_state); transport_manager.Stop(); } diff --git a/src/components/transport_manager/test/transport_manager_impl_test.cc b/src/components/transport_manager/test/transport_manager_impl_test.cc index c7d70246580..ac9b801dbd9 100644 --- a/src/components/transport_manager/test/transport_manager_impl_test.cc +++ b/src/components/transport_manager/test/transport_manager_impl_test.cc @@ -30,26 +30,25 @@ * POSSIBILITY OF SUCH DAMAGE. */ +#include "transport_manager/transport_manager_impl.h" #include #include "gtest/gtest.h" #include "protocol/raw_message.h" +#include "resumption/last_state_impl.h" #include "transport_manager/common.h" -#include "transport_manager/transport_manager_impl.h" -#include "transport_manager/mock_telemetry_observer.h" -#include "transport_manager/mock_transport_manager_listener.h" #include "transport_manager/mock_telemetry_observer.h" -#include "transport_manager/transport_adapter/mock_transport_adapter.h" #include "transport_manager/mock_transport_manager_impl.h" +#include "transport_manager/mock_transport_manager_listener.h" #include "transport_manager/mock_transport_manager_settings.h" -#include "resumption/last_state_impl.h" +#include "transport_manager/transport_adapter/mock_transport_adapter.h" #include "utils/test_async_waiter.h" using ::testing::_; using ::testing::AtLeast; +using ::testing::DoAll; using ::testing::Return; using ::testing::ReturnRef; -using ::testing::DoAll; using ::protocol_handler::RawMessage; using ::protocol_handler::RawMessagePtr; @@ -64,7 +63,7 @@ namespace { const std::string kAppStorageFolder = "app_storage_folder"; const std::string kAppInfoFolder = "app_info_folder"; const uint32_t kAsyncExpectationsTimeout = 10000u; -} +} // namespace class TransportManagerImplTest : public ::testing::Test { protected: @@ -102,7 +101,7 @@ class TransportManagerImplTest : public ::testing::Test { unsigned char data[kSize] = { 0x20, 0x07, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; test_message_ = std::make_shared( - connection_key_, version_protocol_, data, kSize); + connection_key_, version_protocol_, data, kSize, false); } DeviceInfo ConstructDeviceInfo(const std::string& mac_address, @@ -665,15 +664,23 @@ TEST_F(TransportManagerImplTest, RemoveDevice_DeviceWasAdded) { } TEST_F(TransportManagerImplTest, SetVisibilityOn_StartClientListening) { - EXPECT_CALL(*mock_adapter_, StartClientListening()) + EXPECT_CALL( + *mock_adapter_, + ChangeClientListening(transport_manager::TransportAction::kVisibilityOn)) .WillOnce(Return(TransportAdapter::OK)); - EXPECT_EQ(::transport_manager::E_SUCCESS, tm_.Visibility(true)); + EXPECT_EQ(::transport_manager::E_SUCCESS, + tm_.PerformActionOnClients( + transport_manager::TransportAction::kVisibilityOn)); } TEST_F(TransportManagerImplTest, SetVisibilityOff_StopClientListening) { - EXPECT_CALL(*mock_adapter_, StopClientListening()) + EXPECT_CALL( + *mock_adapter_, + ChangeClientListening(transport_manager::TransportAction::kVisibilityOff)) .WillOnce(Return(TransportAdapter::OK)); - EXPECT_EQ(::transport_manager::E_SUCCESS, tm_.Visibility(false)); + EXPECT_EQ(::transport_manager::E_SUCCESS, + tm_.PerformActionOnClients( + transport_manager::TransportAction::kVisibilityOff)); } TEST_F(TransportManagerImplTest, StopTransportManager) { @@ -692,12 +699,14 @@ TEST_F(TransportManagerImplTest, StopTransportManager) { TEST_F(TransportManagerImplTest, Reinit) { EXPECT_CALL(*mock_adapter_, Terminate()); EXPECT_CALL(*mock_adapter_, Init()).WillOnce(Return(TransportAdapter::OK)); + tm_.Deinit(); EXPECT_EQ(E_SUCCESS, tm_.Reinit()); } TEST_F(TransportManagerImplTest, Reinit_InitAdapterFailed) { EXPECT_CALL(*mock_adapter_, Terminate()); EXPECT_CALL(*mock_adapter_, Init()).WillOnce(Return(TransportAdapter::FAIL)); + tm_.Deinit(); EXPECT_EQ(E_ADAPTERS_FAIL, tm_.Reinit()); } @@ -941,17 +950,22 @@ TEST_F(TransportManagerImplTest, RemoveDevice_TMIsNotInitialized) { TEST_F(TransportManagerImplTest, Visibility_TMIsNotInitialized) { // Arrange - const bool visible = true; + const transport_manager::TransportAction action = + transport_manager::TransportAction::kVisibilityOn; // Check before Act UninitializeTM(); // Act and Assert - EXPECT_CALL(*mock_adapter_, StartClientListening()).Times(0); - EXPECT_EQ(E_TM_IS_NOT_INITIALIZED, tm_.Visibility(visible)); + EXPECT_CALL( + *mock_adapter_, + ChangeClientListening(transport_manager::TransportAction::kVisibilityOn)) + .Times(0); + EXPECT_EQ(E_TM_IS_NOT_INITIALIZED, tm_.PerformActionOnClients(action)); } TEST_F(TransportManagerImplTest, HandleMessage_ConnectionNotExist) { EXPECT_CALL(*mock_adapter_, - SendData(mac_address_, application_id_, test_message_)).Times(0); + SendData(mac_address_, application_id_, test_message_)) + .Times(0); TestAsyncWaiter waiter; EXPECT_CALL(*tm_listener_, OnTMMessageSendFailed(_, test_message_)) @@ -971,16 +985,24 @@ TEST_F(TransportManagerImplTest, SearchDevices_TMIsNotInitialized) { } TEST_F(TransportManagerImplTest, SetVisibilityOn_TransportAdapterNotSupported) { - EXPECT_CALL(*mock_adapter_, StartClientListening()) + EXPECT_CALL( + *mock_adapter_, + ChangeClientListening(transport_manager::TransportAction::kVisibilityOn)) .WillOnce(Return(TransportAdapter::NOT_SUPPORTED)); - EXPECT_EQ(E_SUCCESS, tm_.Visibility(true)); + EXPECT_EQ(E_SUCCESS, + tm_.PerformActionOnClients( + transport_manager::TransportAction::kVisibilityOn)); } TEST_F(TransportManagerImplTest, SetVisibilityOff_TransportAdapterNotSupported) { - EXPECT_CALL(*mock_adapter_, StopClientListening()) + EXPECT_CALL( + *mock_adapter_, + ChangeClientListening(transport_manager::TransportAction::kVisibilityOff)) .WillOnce(Return(TransportAdapter::NOT_SUPPORTED)); - EXPECT_EQ(E_SUCCESS, tm_.Visibility(false)); + EXPECT_EQ(E_SUCCESS, + tm_.PerformActionOnClients( + transport_manager::TransportAction::kVisibilityOff)); } TEST_F(TransportManagerImplTest, @@ -1232,7 +1254,8 @@ TEST_F(TransportManagerImplTest, EXPECT_CALL(mock_transport_manager_settings_, app_transport_change_timer()) .WillOnce(Return(timeout)); EXPECT_CALL(mock_transport_manager_settings_, - app_transport_change_timer_addition()).WillOnce(Return(0)); + app_transport_change_timer_addition()) + .WillOnce(Return(0)); EXPECT_CALL(*tm_listener_, OnDeviceSwitchingStart(mac_address_, usb_serial)); diff --git a/src/components/transport_manager/test/websocket_connection_test.cc b/src/components/transport_manager/test/websocket_connection_test.cc index db3bc598b1d..d096d351f50 100644 --- a/src/components/transport_manager/test/websocket_connection_test.cc +++ b/src/components/transport_manager/test/websocket_connection_test.cc @@ -425,6 +425,7 @@ TEST_F(WebsocketConnectionTest, WSSConnection_SUCCESS_ValidTarget) { t1.join(); } +#ifdef ENABLE_SECURITY TEST_F(WebsocketConnectionTest, WSSConnection_FAILURE_InvalidTarget) { transport_manager::transport_adapter::CloudAppProperties properties{ .endpoint = "wss://" + kHost + ":" + std::to_string(kPort), @@ -486,6 +487,7 @@ TEST_F(WebsocketConnectionTest, WSSConnection_FAILURE_IncorrectCert) { wss_session->Stop(); t1.join(); } +#endif // ENABLE_SECURITY } // namespace transport_manager_test } // namespace components } // namespace test diff --git a/src/components/utils/CMakeLists.txt b/src/components/utils/CMakeLists.txt index 9562b50e784..451a8a629e0 100644 --- a/src/components/utils/CMakeLists.txt +++ b/src/components/utils/CMakeLists.txt @@ -58,7 +58,10 @@ set(EXCLUDE_PATHS ${DBMS_PATHS} ) -set(LIBRARIES) +set(LIBRARIES + encryption + jsoncpp +) if(NOT BUILD_BACKTRACE_SUPPORT) list(APPEND EXCLUDE_PATHS diff --git a/src/components/utils/include/utils/back_trace.h b/src/components/utils/include/utils/back_trace.h index 180714e5a6a..f23f87e60c5 100644 --- a/src/components/utils/include/utils/back_trace.h +++ b/src/components/utils/include/utils/back_trace.h @@ -33,8 +33,8 @@ #define SRC_COMPONENTS_UTILS_INCLUDE_UTILS_BACK_TRACE_H_ #include -#include #include +#include #include "utils/threads/thread.h" namespace utils { diff --git a/src/components/utils/include/utils/file_system.h b/src/components/utils/include/utils/file_system.h index e6e5fdc0d41..9e0dc233af0 100644 --- a/src/components/utils/include/utils/file_system.h +++ b/src/components/utils/include/utils/file_system.h @@ -35,11 +35,11 @@ #include #include +#include #include #include #include #include -#include namespace file_system { @@ -70,10 +70,10 @@ uint64_t FileSize(const std::string& path); /** * @brief Creates directory with owner_all permissions - * @param name path to directory - * @return path to created directory. + * @param path directory to create + * @return true if directory was created or already exist. */ -std::string CreateDirectory(const std::string& name); +bool CreateDirectory(const std::string& path); /** * @brief Creates directory recursively diff --git a/src/components/utils/include/utils/helpers.h b/src/components/utils/include/utils/helpers.h index f13d69aa834..1ef336daddd 100644 --- a/src/components/utils/include/utils/helpers.h +++ b/src/components/utils/include/utils/helpers.h @@ -132,6 +132,6 @@ bool in_range(const Container& container, return std::find(container.begin(), container.end(), value) != container.end(); } -} +} // namespace helpers #endif // SRC_COMPONENTS_UTILS_INCLUDE_UTILS_HELPERS_H_ 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 b20b43c2516..b0cac75c719 100644 --- a/src/components/utils/include/utils/log_message_loop_thread.h +++ b/src/components/utils/include/utils/log_message_loop_thread.h @@ -33,9 +33,9 @@ #ifndef SRC_COMPONENTS_UTILS_INCLUDE_UTILS_LOG_MESSAGE_LOOP_THREAD_H_ #define SRC_COMPONENTS_UTILS_INCLUDE_UTILS_LOG_MESSAGE_LOOP_THREAD_H_ -#include -#include #include +#include +#include #include "utils/macro.h" #include "utils/threads/message_loop_thread.h" diff --git a/src/components/utils/include/utils/optional.h b/src/components/utils/include/utils/optional.h index 0395945de02..626c166a021 100644 --- a/src/components/utils/include/utils/optional.h +++ b/src/components/utils/include/utils/optional.h @@ -79,5 +79,5 @@ class Optional { bool is_initialized_; }; -} // utils utils +} // namespace utils #endif // ERROR_OR_H diff --git a/src/components/utils/include/utils/qdb_wrapper/sql_query.h b/src/components/utils/include/utils/qdb_wrapper/sql_query.h index bc3e7a592be..b324fd5d404 100644 --- a/src/components/utils/include/utils/qdb_wrapper/sql_query.h +++ b/src/components/utils/include/utils/qdb_wrapper/sql_query.h @@ -33,11 +33,11 @@ #ifndef SRC_COMPONENTS_UTILS_INCLUDE_UTILS_QDB_WRAPPER_SQL_QUERY_H_ #define SRC_COMPONENTS_UTILS_INCLUDE_UTILS_QDB_WRAPPER_SQL_QUERY_H_ -#include #include +#include #include -#include #include +#include #include "qdb_wrapper/sql_error.h" #include "utils/lock.h" diff --git a/src/components/utils/include/utils/resource_usage.h b/src/components/utils/include/utils/resource_usage.h index d358c492255..d34897eded0 100644 --- a/src/components/utils/include/utils/resource_usage.h +++ b/src/components/utils/include/utils/resource_usage.h @@ -38,9 +38,9 @@ #include #endif -#include "utils/macro.h" -#include #include +#include +#include "utils/macro.h" #include "utils/logger.h" @@ -171,6 +171,6 @@ class Resources { */ static const char* proc; }; -} +} // namespace utils #endif // SRC_COMPONENTS_UTILS_INCLUDE_UTILS_RESOURCE_USAGE_H_ diff --git a/src/components/utils/include/utils/singleton.h b/src/components/utils/include/utils/singleton.h index b73780ee1d5..54fc113abac 100644 --- a/src/components/utils/include/utils/singleton.h +++ b/src/components/utils/include/utils/singleton.h @@ -33,9 +33,9 @@ #ifndef SRC_COMPONENTS_UTILS_INCLUDE_UTILS_SINGLETON_H_ #define SRC_COMPONENTS_UTILS_INCLUDE_UTILS_SINGLETON_H_ +#include "utils/atomic.h" #include "utils/lock.h" #include "utils/memory_barrier.h" -#include "utils/atomic.h" namespace utils { diff --git a/src/components/utils/include/utils/sqlite_wrapper/sql_database.h b/src/components/utils/include/utils/sqlite_wrapper/sql_database.h index f68c5e215ed..1bedbea01e7 100644 --- a/src/components/utils/include/utils/sqlite_wrapper/sql_database.h +++ b/src/components/utils/include/utils/sqlite_wrapper/sql_database.h @@ -34,8 +34,8 @@ #define SRC_COMPONENTS_UTILS_INCLUDE_UTILS_SQLITE_WRAPPER_SQL_DATABASE_H_ #include -#include "utils/sqlite_wrapper/sql_error.h" #include "utils/lock.h" +#include "utils/sqlite_wrapper/sql_error.h" struct sqlite3; diff --git a/src/components/utils/include/utils/sqlite_wrapper/sql_query.h b/src/components/utils/include/utils/sqlite_wrapper/sql_query.h index dc45be7ed1e..e7fe75f9c95 100644 --- a/src/components/utils/include/utils/sqlite_wrapper/sql_query.h +++ b/src/components/utils/include/utils/sqlite_wrapper/sql_query.h @@ -35,8 +35,8 @@ #include #include -#include "utils/sqlite_wrapper/sql_error.h" #include "utils/lock.h" +#include "utils/sqlite_wrapper/sql_error.h" struct sqlite3_stmt; diff --git a/src/components/utils/include/utils/stl_utils.h b/src/components/utils/include/utils/stl_utils.h index 4a4e3d2fe84..48511e6fb3b 100644 --- a/src/components/utils/include/utils/stl_utils.h +++ b/src/components/utils/include/utils/stl_utils.h @@ -32,6 +32,7 @@ #ifndef SRC_COMPONENTS_UTILS_INCLUDE_UTILS_STL_UTILS_H_ #define SRC_COMPONENTS_UTILS_INCLUDE_UTILS_STL_UTILS_H_ +#include #include "utils/macro.h" namespace utils { diff --git a/src/components/utils/include/utils/system.h b/src/components/utils/include/utils/system.h index 3b34d785263..f975f745100 100644 --- a/src/components/utils/include/utils/system.h +++ b/src/components/utils/include/utils/system.h @@ -91,6 +91,6 @@ class System { std::vector argv_; }; -} // utils +} // namespace utils #endif // SRC_COMPONENTS_UTILS_INCLUDE_UTILS_SYSTEM_H_ diff --git a/src/components/utils/include/utils/system_time_handler.h b/src/components/utils/include/utils/system_time_handler.h index 15b2dd0cca2..2013622f309 100644 --- a/src/components/utils/include/utils/system_time_handler.h +++ b/src/components/utils/include/utils/system_time_handler.h @@ -50,6 +50,11 @@ class SystemTimeListener { * @param utc_time current system time. */ virtual void OnSystemTimeArrived(const time_t utc_time) = 0; + + /** + * @brief OnSystemTimeFailed Notify about system request failure + */ + virtual void OnSystemTimeFailed() = 0; }; /** @@ -96,6 +101,12 @@ class SystemTimeHandler { */ time_t GetUTCTime(); + /** + * @brief ResetPendingSystemTimeRequests resets waiting for system time + * requests flag + */ + virtual void ResetPendingSystemTimeRequests() = 0; + /** * @brief Checks if system time is ready * and can be requested by GetSystemTime request diff --git a/src/components/utils/include/utils/threads/pulse_thread_delegate.h b/src/components/utils/include/utils/threads/pulse_thread_delegate.h index 623e12b2611..ad6df6fca7e 100644 --- a/src/components/utils/include/utils/threads/pulse_thread_delegate.h +++ b/src/components/utils/include/utils/threads/pulse_thread_delegate.h @@ -55,23 +55,23 @@ namespace threads { class PulseThreadDelegate : public ThreadDelegate { public: /** - * @brief default constructor - */ + * @brief default constructor + */ PulseThreadDelegate(); virtual void threadMain(); virtual void exitThreadMain(); protected: /** - * @brief This method is to be implemented to arm events of interest - * @param event pointer to structure sigevent - * @return If this method returns true, thread is blocked on + * @brief This method is to be implemented to arm events of interest + * @param event pointer to structure sigevent + * @return If this method returns true, thread is blocked on * MsgReceivePulse() waiting for Pulse - */ + */ virtual bool ArmEvent(struct sigevent* event) = 0; /** - * @brief This method is invoked from threadMain() when Pulse comes - */ + * @brief This method is invoked from threadMain() when Pulse comes + */ virtual void OnPulse() = 0; /** @@ -83,9 +83,9 @@ class PulseThreadDelegate : public ThreadDelegate { } /** - * Finalizes thread - * Can free resources - */ + * Finalizes thread + * Can free resources + */ virtual void Finalize() {} private: diff --git a/src/components/utils/include/utils/threads/thread_manager.h b/src/components/utils/include/utils/threads/thread_manager.h index 3f53c902c4a..4f28d0cb151 100644 --- a/src/components/utils/include/utils/threads/thread_manager.h +++ b/src/components/utils/include/utils/threads/thread_manager.h @@ -37,16 +37,16 @@ #include +#include #include -#include #include -#include +#include -#include "utils/macro.h" -#include "utils/singleton.h" -#include "utils/lock.h" #include "utils/conditional_variable.h" +#include "utils/lock.h" +#include "utils/macro.h" #include "utils/message_queue.h" +#include "utils/singleton.h" #include "utils/threads/thread.h" #include "utils/threads/thread_delegate.h" diff --git a/src/components/utils/include/utils/timer.h b/src/components/utils/include/utils/timer.h index b012b97e6a1..a47b52a0309 100644 --- a/src/components/utils/include/utils/timer.h +++ b/src/components/utils/include/utils/timer.h @@ -32,15 +32,15 @@ #ifndef SRC_COMPONENTS_UTILS_INCLUDE_UTILS_TIMER_H_ #define SRC_COMPONENTS_UTILS_INCLUDE_UTILS_TIMER_H_ -#include #include #include +#include -#include "utils/macro.h" #include "utils/lock.h" -#include "utils/timer_task.h" +#include "utils/macro.h" #include "utils/threads/thread.h" #include "utils/threads/thread_delegate.h" +#include "utils/timer_task.h" namespace timer { diff --git a/src/components/utils/include/utils/timer_task_impl.h b/src/components/utils/include/utils/timer_task_impl.h index 28618551ece..9ed6dd702dc 100644 --- a/src/components/utils/include/utils/timer_task_impl.h +++ b/src/components/utils/include/utils/timer_task_impl.h @@ -33,8 +33,8 @@ #ifndef SRC_COMPONENTS_UTILS_INCLUDE_UTILS_TIMER_TASK_IMPL_H_ #define SRC_COMPONENTS_UTILS_INCLUDE_UTILS_TIMER_TASK_IMPL_H_ -#include "utils/timer_task.h" #include "utils/macro.h" +#include "utils/timer_task.h" namespace timer { diff --git a/src/components/utils/src/back_trace.cc b/src/components/utils/src/back_trace.cc index c587643cc68..65f9e720701 100644 --- a/src/components/utils/src/back_trace.cc +++ b/src/components/utils/src/back_trace.cc @@ -33,8 +33,8 @@ #include "utils/back_trace.h" #include -#include #include +#include #include #include @@ -63,7 +63,7 @@ string demangle(const char* symbol) { } return symbol; } -} +} // namespace Backtrace::Backtrace(int32_t count, int32_t skip_top) : thread_id_(threads::Thread::CurrentId()) { diff --git a/src/components/utils/src/conditional_variable_boost.cc b/src/components/utils/src/conditional_variable_boost.cc index a74aa3eaa6a..c70b727d66e 100644 --- a/src/components/utils/src/conditional_variable_boost.cc +++ b/src/components/utils/src/conditional_variable_boost.cc @@ -34,9 +34,9 @@ #include #include +#include #include "utils/lock.h" #include "utils/logger.h" -#include namespace { const long kNanosecondsPerSecond = 1000000000; diff --git a/src/components/utils/src/convert_utils.cc b/src/components/utils/src/convert_utils.cc index 319b231a961..9d903187317 100644 --- a/src/components/utils/src/convert_utils.cc +++ b/src/components/utils/src/convert_utils.cc @@ -32,8 +32,8 @@ #include "utils/convert_utils.h" #include -#include #include +#include #include "utils/macro.h" long long int utils::ConvertInt64ToLongLongInt(const int64_t value) { diff --git a/src/components/utils/src/custom_string.cc b/src/components/utils/src/custom_string.cc index 8254a981806..7bbe5f2da82 100644 --- a/src/components/utils/src/custom_string.cc +++ b/src/components/utils/src/custom_string.cc @@ -31,14 +31,14 @@ */ #include "utils/custom_string.h" -#include -#include +#include +#include #include +#include +#include #include #include -#include #include -#include #include "utils/logger.h" #include "utils/macro.h" @@ -76,7 +76,7 @@ void ConvertWStringToLowerCase(std::wstring& str) { std::transform(str.begin(), str.end(), str.begin(), towlower); setlocale(LC_ALL, current_locale.c_str()); } -} +} // namespace namespace utils { namespace custom_string { diff --git a/src/components/utils/src/date_time.cc b/src/components/utils/src/date_time.cc index 3ca6050b3f0..cea35a977e0 100644 --- a/src/components/utils/src/date_time.cc +++ b/src/components/utils/src/date_time.cc @@ -102,4 +102,17 @@ TimeCompare compareTime(const TimeDuration& time1, const TimeDuration& time2) { return EQUAL; } +int64_t calculateAmountDaysFromDate(const std::time_t& start_date) { + const time_t current_date = std::time(NULL); + + // std::difftime returns difference between two timepoints in seconds + const uint32_t diff_consent_and_current_dates = (static_cast( + std::fabs(std::difftime(current_date, start_date)))); + + const uint32_t past_period_in_days = + diff_consent_and_current_dates / date_time::SECONDS_IN_DAY; + + return past_period_in_days; +} + } // namespace date_time diff --git a/src/components/utils/src/file_system.cc b/src/components/utils/src/file_system.cc index 430cf40da09..c2fb8a4eb45 100644 --- a/src/components/utils/src/file_system.cc +++ b/src/components/utils/src/file_system.cc @@ -100,16 +100,16 @@ size_t file_system::DirectorySize(const std::string& path) { } // NOTE that boost makes 0777 permissions by default -std::string file_system::CreateDirectory(const std::string& name) { +bool file_system::CreateDirectory(const std::string& path) { error_code ec; - bool success = fs::create_directory(name, ec); + const bool success = fs::create_directory(path, ec); if (!success || ec) { - LOG4CXX_WARN_WITH_ERRNO(logger_, "Unable to create directory: " << name); + LOG4CXX_WARN_WITH_ERRNO(logger_, "Unable to create directory: " << path); } else { // Set 0700 permissions to maintain previous API - fs::permissions(name, fs::perms::owner_all, ec); + fs::permissions(path, fs::perms::owner_all, ec); } - return name; + return success; } bool file_system::CreateDirectoryRecursively(const std::string& path) { diff --git a/src/components/utils/src/gen_hash.cc b/src/components/utils/src/gen_hash.cc index a43b8feb03d..0b85798b009 100644 --- a/src/components/utils/src/gen_hash.cc +++ b/src/components/utils/src/gen_hash.cc @@ -32,8 +32,8 @@ #include "utils/gen_hash.h" #include -#include #include +#include #include "utils/custom_string.h" namespace utils { diff --git a/src/components/utils/src/logger.cc b/src/components/utils/src/logger.cc index af21aeac77e..5a7922afc43 100644 --- a/src/components/utils/src/logger.cc +++ b/src/components/utils/src/logger.cc @@ -31,19 +31,16 @@ */ #include "utils/logger.h" +#include #include "utils/log_message_loop_thread.h" #include "utils/logger_status.h" -#include void deinit_logger() { CREATE_LOGGERPTR_LOCAL(logger_, "Utils") LOG4CXX_DEBUG(logger_, "Logger deinitialization"); logger::set_logs_enabled(false); - if (logger::logger_status == logger::LoggerThreadCreated) { - logger::flush_logger(); - } - logger::delete_log_message_loop_thread(); log4cxx::LoggerPtr rootLogger = log4cxx::Logger::getRootLogger(); + logger::delete_log_message_loop_thread(rootLogger); log4cxx::spi::LoggerRepositoryPtr repository = rootLogger->getLoggerRepository(); log4cxx::LoggerList loggers = repository->getCurrentLoggers(); diff --git a/src/components/utils/src/push_log.cc b/src/components/utils/src/push_log.cc index 6e16c99181d..f9d1cd738ad 100644 --- a/src/components/utils/src/push_log.cc +++ b/src/components/utils/src/push_log.cc @@ -36,8 +36,21 @@ namespace logger { -static bool logs_enabled_ = false; -static LogMessageLoopThread* log_message_loop_thread = NULL; +struct __attribute__((visibility("default"))) LogsEnabled { + static std::atomic_bool logs_enabled_; +}; + +std::atomic_bool LogsEnabled::logs_enabled_(false); + +template +using logger_ptr = std::unique_ptr >; + +static logger_ptr log_message_loop_thread; + +auto deinit_logger = [](LogMessageLoopThread* logMsgThread) { + delete logMsgThread; + logger::logger_status = logger::LoggerThreadNotCreated; +}; bool push_log(log4cxx::LoggerPtr logger, log4cxx::LevelPtr level, @@ -73,22 +86,46 @@ bool push_log(log4cxx::LoggerPtr logger, } bool logs_enabled() { - return logs_enabled_; + return LogsEnabled::logs_enabled_; } void set_logs_enabled(bool state) { - logs_enabled_ = state; + LogsEnabled::logs_enabled_ = state; } void create_log_message_loop_thread() { if (!log_message_loop_thread) { - log_message_loop_thread = new LogMessageLoopThread(); + log_message_loop_thread = logger_ptr( + new LogMessageLoopThread, deinit_logger); } } -void delete_log_message_loop_thread() { - delete log_message_loop_thread; - log_message_loop_thread = NULL; +void delete_log_message_loop_thread(log4cxx::LoggerPtr& logger) { + if (logger::logger_status == logger::LoggerThreadCreated) { + logger::flush_logger(); + } + + log_message_loop_thread.reset(); + + if (LOG4CXX_UNLIKELY(logger->isDebugEnabled())) { + ::log4cxx::helpers::MessageBuffer oss_; + logger->forcedLog(::log4cxx::Level::getDebug(), + oss_.str(oss_ << "Logger loop thread deinitialized"), + LOG4CXX_LOCATION); + } + + if (logger->getRootLogger() == logger) { + return; + } + + if (LOG4CXX_UNLIKELY(logger->isDebugEnabled())) { + ::log4cxx::helpers::MessageBuffer oss_; + logger->forcedLog(::log4cxx::Level::getDebug(), + oss_.str(oss_ << "Logger calling removeAllAppenders"), + LOG4CXX_LOCATION); + } + + logger->removeAllAppenders(); } void flush_logger() { diff --git a/src/components/utils/src/qdb_wrapper/sql_database.cc b/src/components/utils/src/qdb_wrapper/sql_database.cc index b95fe178458..e2a51753b28 100644 --- a/src/components/utils/src/qdb_wrapper/sql_database.cc +++ b/src/components/utils/src/qdb_wrapper/sql_database.cc @@ -30,8 +30,8 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include #include "qdb_wrapper/sql_database.h" +#include #include "utils/logger.h" namespace utils { diff --git a/src/components/utils/src/qdb_wrapper/sql_query.cc b/src/components/utils/src/qdb_wrapper/sql_query.cc index e5facb5853f..d101e807183 100644 --- a/src/components/utils/src/qdb_wrapper/sql_query.cc +++ b/src/components/utils/src/qdb_wrapper/sql_query.cc @@ -31,12 +31,12 @@ */ #include "qdb_wrapper/sql_query.h" +#include #include -#include #include +#include #include "qdb_wrapper/sql_database.h" #include "utils/logger.h" -#include namespace utils { namespace dbms { diff --git a/src/components/utils/src/resource_usage.cc b/src/components/utils/src/resource_usage.cc index 385c2bfa2e6..15a8c71e703 100644 --- a/src/components/utils/src/resource_usage.cc +++ b/src/components/utils/src/resource_usage.cc @@ -10,11 +10,11 @@ #include #include #endif -#include #include +#include +#include #include #include -#include #include #include "utils/file_system.h" diff --git a/src/components/utils/src/rwlock_posix.cc b/src/components/utils/src/rwlock_posix.cc index 08edb8cb0c4..81bf5feee18 100644 --- a/src/components/utils/src/rwlock_posix.cc +++ b/src/components/utils/src/rwlock_posix.cc @@ -30,8 +30,8 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include "utils/rwlock.h" #include "utils/logger.h" +#include "utils/rwlock.h" namespace sync_primitives { diff --git a/src/components/utils/src/signals_posix.cc b/src/components/utils/src/signals_posix.cc index e13dc04f40c..9b23aba804b 100644 --- a/src/components/utils/src/signals_posix.cc +++ b/src/components/utils/src/signals_posix.cc @@ -29,10 +29,10 @@ * 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 #include "utils/signals.h" @@ -83,7 +83,7 @@ pid_t Signals::Fork() { } void Signals::ExitProcess(const int status) { - exit(status); + _Exit(status); } void Signals::WaitPid(pid_t cpid, int* status, int options) { diff --git a/src/components/utils/src/system.cc b/src/components/utils/src/system.cc index 6c3cf561335..2acc7acf92f 100644 --- a/src/components/utils/src/system.cc +++ b/src/components/utils/src/system.cc @@ -32,16 +32,16 @@ #ifdef __QNX__ #include #else // __QNX__ +#include +#include #include #include -#include -#include #include #endif // __QNX__ #include -#include #include +#include #include #include "utils/logger.h" @@ -87,7 +87,7 @@ bool System::Execute() { bool System::Execute(bool wait) { size_t size = argv_.size(); - char** argv = new char* [size + 1]; + char** argv = new char*[size + 1]; std::transform(argv_.begin(), argv_.end(), argv, GetCString()); argv[size] = NULL; @@ -137,7 +137,7 @@ bool System::Execute(bool wait) { dup2(fd_dev0, STDERR_FILENO); size_t size = argv_.size(); - char** argv = new char* [size + 1]; + char** argv = new char*[size + 1]; std::transform(argv_.begin(), argv_.end(), argv, GetCString()); argv[size] = NULL; @@ -173,4 +173,4 @@ bool System::Execute(bool wait) { #endif // __QNX__ -} // utils +} // namespace utils diff --git a/src/components/utils/src/threads/async_runner.cc b/src/components/utils/src/threads/async_runner.cc index 131aaa3f786..740db016be0 100644 --- a/src/components/utils/src/threads/async_runner.cc +++ b/src/components/utils/src/threads/async_runner.cc @@ -110,4 +110,4 @@ void AsyncRunner::AsyncRunnerDelegate::runDelegate(ThreadDelegate* delegate) { delegate_notifier_.NotifyOne(); } -} // namespace policy. +} // namespace threads diff --git a/src/components/utils/src/threads/pulse_thread_delegate.cc b/src/components/utils/src/threads/pulse_thread_delegate.cc index 37e6c670d10..a76b17368ac 100644 --- a/src/components/utils/src/threads/pulse_thread_delegate.cc +++ b/src/components/utils/src/threads/pulse_thread_delegate.cc @@ -32,8 +32,8 @@ #include -#include "utils/threads/pulse_thread_delegate.h" #include "utils/logger.h" +#include "utils/threads/pulse_thread_delegate.h" namespace threads { diff --git a/src/components/utils/src/threads/thread_delegate.cc b/src/components/utils/src/threads/thread_delegate.cc index 917603f92c6..e071959522a 100644 --- a/src/components/utils/src/threads/thread_delegate.cc +++ b/src/components/utils/src/threads/thread_delegate.cc @@ -34,8 +34,8 @@ #include -#include "utils/threads/thread.h" #include "utils/lock.h" +#include "utils/threads/thread.h" namespace threads { diff --git a/src/components/utils/src/threads/thread_manager.cc b/src/components/utils/src/threads/thread_manager.cc index 2959a86cb79..8825510d744 100644 --- a/src/components/utils/src/threads/thread_manager.cc +++ b/src/components/utils/src/threads/thread_manager.cc @@ -31,16 +31,16 @@ */ #include "utils/threads/thread_manager.h" -#include "utils/threads/thread_delegate.h" -#include "utils/lock.h" #include "utils/conditional_variable.h" -#include "utils/threads/thread.h" +#include "utils/lock.h" #include "utils/logger.h" +#include "utils/threads/thread.h" +#include "utils/threads/thread_delegate.h" #include -#include #include +#include #if defined(OS_LINUX) #include diff --git a/src/components/utils/src/threads/thread_posix.cc b/src/components/utils/src/threads/thread_posix.cc index 51e59fa1085..35c1cd70847 100644 --- a/src/components/utils/src/threads/thread_posix.cc +++ b/src/components/utils/src/threads/thread_posix.cc @@ -32,16 +32,16 @@ #include #include -#include -#include #include +#include +#include #include #include -#include "utils/threads/thread.h" #include "utils/atomic.h" -#include "utils/threads/thread_delegate.h" #include "utils/logger.h" +#include "utils/threads/thread.h" +#include "utils/threads/thread_delegate.h" #ifndef __QNXNTO__ const int EOK = 0; @@ -172,9 +172,9 @@ bool Thread::start(const ThreadOptions& options) { } if (isThreadRunning_) { - LOG4CXX_TRACE(logger_, - "EXIT thread " << name_ << " #" << handle_ - << " is already running"); + LOG4CXX_TRACE( + logger_, + "EXIT thread " << name_ << " #" << handle_ << " is already running"); return true; } diff --git a/src/components/utils/src/threads/thread_validator.cc b/src/components/utils/src/threads/thread_validator.cc index 4024522ae48..3b753e79b58 100644 --- a/src/components/utils/src/threads/thread_validator.cc +++ b/src/components/utils/src/threads/thread_validator.cc @@ -31,8 +31,8 @@ */ #include "utils/threads/thread_validator.h" -#include "utils/logger.h" #include "utils/back_trace.h" +#include "utils/logger.h" namespace threads { @@ -46,14 +46,15 @@ SingleThreadSimpleValidator::~SingleThreadSimpleValidator() {} void SingleThreadSimpleValidator::AssertRunningOnCreationThread() const { PlatformThreadHandle current_id = Thread::CurrentId(); if (creation_thread_id_ != current_id) { - LOG4CXX_ERROR(logger_, - "Single-threaded object created at thread " - << creation_thread_id_ << " is accessed from thread " - << current_id + LOG4CXX_ERROR( + logger_, + "Single-threaded object created at thread " + << creation_thread_id_ << " is accessed from thread " << current_id #ifdef BACKTRACE_SUPPORT - << "\n" << utils::Backtrace() + << "\n" + << utils::Backtrace() #endif - ); + ); } } @@ -80,7 +81,7 @@ void SingleThreadValidator::AssertRunningOnValidThread() const { #ifdef BACKTRACE_SUPPORT << utils::Backtrace() #endif - ); + ); } } diff --git a/src/components/utils/src/timer.cc b/src/components/utils/src/timer.cc index 68693dfc557..8e854654def 100644 --- a/src/components/utils/src/timer.cc +++ b/src/components/utils/src/timer.cc @@ -33,13 +33,13 @@ #include -#include "utils/macro.h" -#include "utils/logger.h" -#include "utils/lock.h" -#include "utils/timer_task.h" #include "utils/conditional_variable.h" +#include "utils/lock.h" +#include "utils/logger.h" +#include "utils/macro.h" #include "utils/threads/thread.h" #include "utils/threads/thread_delegate.h" +#include "utils/timer_task.h" CREATE_LOGGERPTR_GLOBAL(logger_, "Utils") diff --git a/src/components/utils/test/CMakeLists.txt b/src/components/utils/test/CMakeLists.txt index f6bd24ff097..b5127ccabcb 100644 --- a/src/components/utils/test/CMakeLists.txt +++ b/src/components/utils/test/CMakeLists.txt @@ -87,7 +87,7 @@ collect_sources(SOURCES "${CMAKE_CURRENT_SOURCE_DIR}" "${EXCLUDE_PATHS}") set(LIBRARIES gmock Utils - Policy + PolicyStatic ConfigProfile ) diff --git a/src/components/utils/test/async_runner_test.cc b/src/components/utils/test/async_runner_test.cc index f01dad8d589..e26f80d954d 100644 --- a/src/components/utils/test/async_runner_test.cc +++ b/src/components/utils/test/async_runner_test.cc @@ -30,15 +30,15 @@ * POSSIBILITY OF SUCH DAMAGE. */ +#include "utils/threads/async_runner.h" #include #include #include -#include "utils/lock.h" -#include "utils/threads/async_runner.h" #include "utils/conditional_variable.h" +#include "utils/lock.h" -#include "gtest/gtest.h" #include "gmock/gmock.h" +#include "gtest/gtest.h" namespace test { namespace components { @@ -49,7 +49,7 @@ using namespace threads; namespace { size_t kCheckValue = 0u; const size_t kDelegatesAmount = 4u; -} +} // namespace // ThreadDelegate successor class TestThreadDelegate : public ThreadDelegate { @@ -93,7 +93,7 @@ class AsyncRunnerTest : public ::testing::Test { std::shared_ptr async_runner_; void CreateThreadsArray() { - delegates_ = new ThreadDelegate* [kDelegatesAmount]; + delegates_ = new ThreadDelegate*[kDelegatesAmount]; } void DeleteThreadsArray() { diff --git a/src/components/utils/test/auto_trace_test.cc b/src/components/utils/test/auto_trace_test.cc index 1290ce7e962..41dc90cae4e 100644 --- a/src/components/utils/test/auto_trace_test.cc +++ b/src/components/utils/test/auto_trace_test.cc @@ -30,19 +30,19 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include #include +#include #include "gtest/gtest.h" #include "utils/auto_trace.h" -#include "utils/logger.h" +#include "utils/date_time.h" +#include "utils/file_system.h" +#include "utils/helpers.h" #include "utils/log_message_loop_thread.h" +#include "utils/logger.h" +#include "utils/logger_status.h" #include "utils/threads/message_loop_thread.h" -#include "utils/file_system.h" #include "utils/threads/thread.h" -#include "utils/date_time.h" -#include "utils/logger_status.h" -#include "utils/helpers.h" namespace test { namespace components { @@ -115,7 +115,7 @@ bool CheckAutoTraceDebugInFile(const std::string& debug_message) { bool trace_exit = false; for (std::string line; Compare(false, debug_found, trace_enter, trace_exit) && - getline(file_log, line);) { + getline(file_log, line);) { debug_found = debug_found ? debug_found : IsLogLineContains(line, debug_log_level, debug_message); diff --git a/src/components/utils/test/back_trace_test.cc b/src/components/utils/test/back_trace_test.cc index dcb2a79baa1..2c8c61439b3 100644 --- a/src/components/utils/test/back_trace_test.cc +++ b/src/components/utils/test/back_trace_test.cc @@ -30,8 +30,8 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include "gtest/gtest.h" #include "utils/back_trace.h" +#include "gtest/gtest.h" namespace test { namespace components { diff --git a/src/components/utils/test/bitstream_test.cc b/src/components/utils/test/bitstream_test.cc index caec4b39703..3d20845dc4e 100644 --- a/src/components/utils/test/bitstream_test.cc +++ b/src/components/utils/test/bitstream_test.cc @@ -30,10 +30,10 @@ * POSSIBILITY OF SUCH DAMAGE. */ +#include "utils/bitstream.h" #include #include "gtest/gtest.h" #include "utils/macro.h" -#include "utils/bitstream.h" namespace test { namespace components { diff --git a/src/components/utils/test/custom_string_test.cc b/src/components/utils/test/custom_string_test.cc index bca332be5ae..cf03f6099ff 100644 --- a/src/components/utils/test/custom_string_test.cc +++ b/src/components/utils/test/custom_string_test.cc @@ -30,10 +30,10 @@ * POSSIBILITY OF SUCH DAMAGE. */ +#include "utils/custom_string.h" #include #include #include "gtest/gtest.h" -#include "utils/custom_string.h" namespace custom_str = utils::custom_string; diff --git a/src/components/utils/test/data_accessor_test.cc b/src/components/utils/test/data_accessor_test.cc index 24b7bab282d..b9d8f3b4f92 100644 --- a/src/components/utils/test/data_accessor_test.cc +++ b/src/components/utils/test/data_accessor_test.cc @@ -30,8 +30,8 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include "gtest/gtest.h" #include "utils/data_accessor.h" +#include "gtest/gtest.h" #include "utils/lock.h" namespace test { diff --git a/src/components/utils/test/date_time_test.cc b/src/components/utils/test/date_time_test.cc index 00085813aad..4cde9a4fc4b 100644 --- a/src/components/utils/test/date_time_test.cc +++ b/src/components/utils/test/date_time_test.cc @@ -30,9 +30,9 @@ * POSSIBILITY OF SUCH DAMAGE. */ +#include "utils/date_time.h" #include #include "gtest/gtest.h" -#include "utils/date_time.h" namespace test { namespace components { diff --git a/src/components/utils/test/file_system_test.cc b/src/components/utils/test/file_system_test.cc index eb35773fc96..3d518e599fd 100644 --- a/src/components/utils/test/file_system_test.cc +++ b/src/components/utils/test/file_system_test.cc @@ -32,8 +32,8 @@ #include #include -#include #include +#include #include "gtest/gtest.h" #include "utils/file_system.h" @@ -57,7 +57,7 @@ StringArray MergeStringsToArray(const std::string& first, return array_of_strings; } -} +} // namespace TEST(FileSystemTest, CreateDeleteDirectory) { ASSERT_FALSE(DirectoryExists("./Test directory")); diff --git a/src/components/utils/test/generated_code_with_sqlite_test.cc b/src/components/utils/test/generated_code_with_sqlite_test.cc index 1c829c838c4..b75ec5c58f5 100644 --- a/src/components/utils/test/generated_code_with_sqlite_test.cc +++ b/src/components/utils/test/generated_code_with_sqlite_test.cc @@ -29,9 +29,9 @@ * POSSIBILITY OF SUCH DAMAGE. */ +#include "utils/generated_code_with_sqlite_test.h" #include #include "gtest/gtest.h" -#include "utils/generated_code_with_sqlite_test.h" namespace test { namespace components { diff --git a/src/components/utils/test/include/utils/generated_code_with_sqlite_test.h b/src/components/utils/test/include/utils/generated_code_with_sqlite_test.h index e21fd75f87a..0e75b8ba879 100644 --- a/src/components/utils/test/include/utils/generated_code_with_sqlite_test.h +++ b/src/components/utils/test/include/utils/generated_code_with_sqlite_test.h @@ -35,8 +35,8 @@ #include #include "policy/policy_table/types.h" #include "rpc_base/rpc_base.h" -#include "utils/sqlite_wrapper/sql_query.h" #include "utils/sqlite_wrapper/sql_database.h" +#include "utils/sqlite_wrapper/sql_query.h" namespace test { namespace components { diff --git a/src/components/utils/test/include/utils/mock_signals_posix.h b/src/components/utils/test/include/utils/mock_signals_posix.h index 1aad2d58734..363708a6682 100644 --- a/src/components/utils/test/include/utils/mock_signals_posix.h +++ b/src/components/utils/test/include/utils/mock_signals_posix.h @@ -33,10 +33,10 @@ #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" +#include "gmock/gmock.h" +#include "utils/signals.h" namespace utils { 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 92287fb45bd..74b1f5094f2 100644 --- a/src/components/utils/test/log_message_loop_thread_test.cc +++ b/src/components/utils/test/log_message_loop_thread_test.cc @@ -30,9 +30,9 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include "gtest/gtest.h" -#include "gmock/gmock.h" #include "utils/log_message_loop_thread.h" +#include "gmock/gmock.h" +#include "gtest/gtest.h" #include "utils/logger_status.h" namespace test { diff --git a/src/components/utils/test/message_queue_test.cc b/src/components/utils/test/message_queue_test.cc index 9aa70933d64..b3c654420a9 100644 --- a/src/components/utils/test/message_queue_test.cc +++ b/src/components/utils/test/message_queue_test.cc @@ -30,9 +30,9 @@ * POSSIBILITY OF SUCH DAMAGE. */ +#include "utils/message_queue.h" #include #include "gtest/gtest.h" -#include "utils/message_queue.h" namespace test { namespace components { diff --git a/src/components/utils/test/messagemeter_test.cc b/src/components/utils/test/messagemeter_test.cc index d45e6000347..fdfca113a84 100644 --- a/src/components/utils/test/messagemeter_test.cc +++ b/src/components/utils/test/messagemeter_test.cc @@ -1,44 +1,44 @@ /* -* Copyright (c) 2015, 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) 2015, 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 "gtest/gtest.h" #include "gmock/gmock.h" +#include "gtest/gtest.h" #include "utils/macro.h" -#include "utils/messagemeter.h" #include "utils/date_time.h" +#include "utils/messagemeter.h" namespace test { namespace components { diff --git a/src/components/utils/test/mock_signals_posix.cc b/src/components/utils/test/mock_signals_posix.cc index 47531b4a9fa..93c08a690d3 100644 --- a/src/components/utils/test/mock_signals_posix.cc +++ b/src/components/utils/test/mock_signals_posix.cc @@ -30,9 +30,9 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include "gtest/gtest.h" -#include "gmock/gmock.h" #include "utils/mock_signals_posix.h" +#include "gmock/gmock.h" +#include "gtest/gtest.h" #include "utils/signals.h" namespace utils { diff --git a/src/components/utils/test/posix_thread_test.cc b/src/components/utils/test/posix_thread_test.cc index a44e1b9b898..4bf0c8c0926 100644 --- a/src/components/utils/test/posix_thread_test.cc +++ b/src/components/utils/test/posix_thread_test.cc @@ -52,7 +52,7 @@ const char* threadName("test thread"); const std::string test_thread_name("THREAD"); sync_primitives::ConditionalVariable cond_var_; sync_primitives::Lock test_mutex_; -}; +}; // namespace // ThreadDelegate successor class TestThreadDelegate : public threads::ThreadDelegate { diff --git a/src/components/utils/test/prioritized_queue_test.cc b/src/components/utils/test/prioritized_queue_test.cc index 082ff567130..ed22c2db48c 100644 --- a/src/components/utils/test/prioritized_queue_test.cc +++ b/src/components/utils/test/prioritized_queue_test.cc @@ -30,8 +30,8 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include "gtest/gtest.h" #include "utils/prioritized_queue.h" +#include "gtest/gtest.h" namespace test { namespace components { diff --git a/src/components/utils/test/qdb_wrapper/sql_database_test.cc b/src/components/utils/test/qdb_wrapper/sql_database_test.cc index 4e1a822b579..33dfe691196 100644 --- a/src/components/utils/test/qdb_wrapper/sql_database_test.cc +++ b/src/components/utils/test/qdb_wrapper/sql_database_test.cc @@ -33,11 +33,11 @@ #include "gtest/gtest.h" -#include "qdb_wrapper/sql_error.h" #include "qdb_wrapper/sql_database.h" +#include "qdb_wrapper/sql_error.h" -using ::utils::dbms::SQLError; using ::utils::dbms::SQLDatabase; +using ::utils::dbms::SQLError; namespace test { namespace components { diff --git a/src/components/utils/test/qdb_wrapper/sql_query_test.cc b/src/components/utils/test/qdb_wrapper/sql_query_test.cc index e575e4f5759..6279f4d8a17 100644 --- a/src/components/utils/test/qdb_wrapper/sql_query_test.cc +++ b/src/components/utils/test/qdb_wrapper/sql_query_test.cc @@ -34,12 +34,12 @@ #include "gtest/gtest.h" -#include "qdb_wrapper/sql_error.h" #include "qdb_wrapper/sql_database.h" +#include "qdb_wrapper/sql_error.h" #include "qdb_wrapper/sql_query.h" -using ::utils::dbms::SQLError; using ::utils::dbms::SQLDatabase; +using ::utils::dbms::SQLError; using ::utils::dbms::SQLQuery; namespace test { diff --git a/src/components/utils/test/resource_usage_test.cc b/src/components/utils/test/resource_usage_test.cc index 96b4fe4b49e..ac8825c8416 100644 --- a/src/components/utils/test/resource_usage_test.cc +++ b/src/components/utils/test/resource_usage_test.cc @@ -34,8 +34,8 @@ #include "gtest/gtest.h" #include "utils/macro.h" -#include "utils/resource_usage.h" #include "utils/file_system.h" +#include "utils/resource_usage.h" namespace utils { @@ -80,7 +80,7 @@ TEST_F(ResourceUsagePrivateTest, GetProcPathTest) { // assert EXPECT_EQ(filename, fd + "/stat"); } -} +} // namespace utils namespace test { namespace components { diff --git a/src/components/utils/test/scope_guard_test.cc b/src/components/utils/test/scope_guard_test.cc index 5e685d6aba9..1f9224effa1 100644 --- a/src/components/utils/test/scope_guard_test.cc +++ b/src/components/utils/test/scope_guard_test.cc @@ -30,18 +30,18 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include "gmock/gmock.h" #include "utils/scope_guard.h" +#include "gmock/gmock.h" #include "utils/macro.h" namespace test { namespace components { namespace utils_test { -using ::utils::ScopeGuard; +using ::testing::Mock; using ::utils::MakeGuard; using ::utils::MakeObjGuard; -using ::testing::Mock; +using ::utils::ScopeGuard; class TestCalleeObject { public: @@ -55,7 +55,7 @@ void dealloc(char* ptr) { delete ptr; ++call_with_param_count; } -} +} // namespace TEST(ScopeGuardTest, CallFreeFunctionWithParam) { { @@ -118,4 +118,4 @@ TEST(ScopeGuardTest, DismissCallObjectFunctionWithParam) { } // namespace utils_test } // namespace components -} // namesapce test +} // namespace test diff --git a/src/components/utils/test/singleton_test.cc b/src/components/utils/test/singleton_test.cc index ae05b6cbabd..a38f51726cd 100644 --- a/src/components/utils/test/singleton_test.cc +++ b/src/components/utils/test/singleton_test.cc @@ -30,9 +30,9 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include "gtest/gtest.h" #include "utils/singleton.h" #include +#include "gtest/gtest.h" namespace test { namespace components { diff --git a/src/components/utils/test/sqlite_wrapper/sql_database_test.cc b/src/components/utils/test/sqlite_wrapper/sql_database_test.cc index 9732fbe078d..0195e02121a 100644 --- a/src/components/utils/test/sqlite_wrapper/sql_database_test.cc +++ b/src/components/utils/test/sqlite_wrapper/sql_database_test.cc @@ -1,40 +1,40 @@ /* 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. -*/ + * 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/sqlite_wrapper/sql_database.h" #include "gtest/gtest.h" #include "utils/sqlite_wrapper/sql_error.h" -#include "utils/sqlite_wrapper/sql_database.h" -using ::utils::dbms::SQLError; using ::utils::dbms::SQLDatabase; +using ::utils::dbms::SQLError; namespace test { namespace components { diff --git a/src/components/utils/test/sqlite_wrapper/sql_query_test.cc b/src/components/utils/test/sqlite_wrapper/sql_query_test.cc index c10c26a2c7d..b2d3c747cd9 100644 --- a/src/components/utils/test/sqlite_wrapper/sql_query_test.cc +++ b/src/components/utils/test/sqlite_wrapper/sql_query_test.cc @@ -29,17 +29,17 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include #include +#include #include "gtest/gtest.h" -#include "utils/sqlite_wrapper/sql_error.h" #include "utils/sqlite_wrapper/sql_database.h" +#include "utils/sqlite_wrapper/sql_error.h" #include "utils/sqlite_wrapper/sql_query.h" -using ::utils::dbms::SQLError; using ::utils::dbms::SQLDatabase; +using ::utils::dbms::SQLError; using ::utils::dbms::SQLQuery; namespace test { diff --git a/src/components/utils/test/stl_utils_test.cc b/src/components/utils/test/stl_utils_test.cc index 5250a7a5141..c2701c1558e 100644 --- a/src/components/utils/test/stl_utils_test.cc +++ b/src/components/utils/test/stl_utils_test.cc @@ -30,10 +30,10 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include +#include "utils/stl_utils.h" #include +#include #include "gtest/gtest.h" -#include "utils/stl_utils.h" namespace test { namespace components { diff --git a/src/components/utils/test/system_test.cc b/src/components/utils/test/system_test.cc index b479823aa59..b9daa575ba5 100644 --- a/src/components/utils/test/system_test.cc +++ b/src/components/utils/test/system_test.cc @@ -30,8 +30,8 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include "gmock/gmock.h" #include "utils/system.h" +#include "gmock/gmock.h" namespace test { namespace components { diff --git a/src/components/utils/test/test_generator/generated_msg_version_test.cc b/src/components/utils/test/test_generator/generated_msg_version_test.cc index c9647dcad05..4d1d70a5d67 100644 --- a/src/components/utils/test/test_generator/generated_msg_version_test.cc +++ b/src/components/utils/test/test_generator/generated_msg_version_test.cc @@ -30,11 +30,11 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include +#include "generated_msg_version.h" #include +#include #include #include "gtest/gtest.h" -#include "generated_msg_version.h" #include "utils/file_system.h" using namespace std; diff --git a/src/components/utils/test/timer_test.cc b/src/components/utils/test/timer_test.cc index ea5c9f0b84a..d7b196876d9 100644 --- a/src/components/utils/test/timer_test.cc +++ b/src/components/utils/test/timer_test.cc @@ -30,12 +30,12 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include "gtest/gtest.h" #include "utils/timer.h" -#include "utils/mock_timer_task.h" +#include "gtest/gtest.h" #include "utils/conditional_variable.h" #include "utils/lock.h" #include "utils/macro.h" +#include "utils/mock_timer_task.h" #include "utils/timer_task_impl.h" namespace test { diff --git a/tools/InterfaceGenerator/Generator.py b/tools/InterfaceGenerator/Generator.py index 932620c153d..905b0754b33 100755 --- a/tools/InterfaceGenerator/Generator.py +++ b/tools/InterfaceGenerator/Generator.py @@ -26,6 +26,7 @@ import generator.parsers.JSONRPC import generator.generators.SmartFactorySDLRPC import generator.generators.SmartFactoryJSONRPC +import generator.generators.PolicyTypes import MsgVersionGenerate from generator.parsers.RPCBase import ParseError @@ -37,7 +38,11 @@ "sdlrpcv2": (generator.parsers.SDLRPCV2.Parser, generator.generators.SmartFactorySDLRPC.CodeGenerator), "jsonrpc": (generator.parsers.JSONRPC.Parser, - generator.generators.SmartFactoryJSONRPC.CodeGenerator) + generator.generators.SmartFactoryJSONRPC.CodeGenerator), + "mobile-policy-types": (generator.parsers.SDLRPCV2.Parser, + generator.generators.PolicyTypes.CodeGenerator), + "hmi-policy-types": (generator.parsers.JSONRPC.Parser, + generator.generators.PolicyTypes.CodeGenerator) } diff --git a/tools/InterfaceGenerator/MsgVersionGenerate.py b/tools/InterfaceGenerator/MsgVersionGenerate.py index 4a24a3239fb..d1e5d7d9689 100644 --- a/tools/InterfaceGenerator/MsgVersionGenerate.py +++ b/tools/InterfaceGenerator/MsgVersionGenerate.py @@ -69,7 +69,7 @@ def prepare_data_for_storage(major_version, minor_version, patch_version, minimu """Prepares data to store to file. """ temp = Template( - u'''/*Copyright (c) 2016, Ford Motor Company\n''' + u'''/*Copyright (c) 2019, SmartDeviceLink Consortium, Inc.\n''' u'''All rights reserved.\n''' u'''Redistribution and use in source and binary forms, with or without\n''' u'''modification, are permitted provided that the following conditions are met:\n''' @@ -79,9 +79,9 @@ def prepare_data_for_storage(major_version, minor_version, patch_version, minimu u'''this list of conditions and the following\n''' u'''disclaimer in the documentation and/or other materials provided with the\n''' u'''distribution.\n''' - u'''Neither the name of the Ford Motor Company nor the names of its contributors\n''' - u'''may be used to endorse or promote products derived from this software\n''' - u'''without specific prior written permission.\n''' + u'''Neither the name of the SmartDeviceLink Consortium, Inc. nor the names of its\n''' + u'''contributors may be used to endorse or promote products derived from this\n''' + u'''software without specific prior written permission.\n''' u'''THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\"\n''' u'''AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n''' u'''IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n''' @@ -96,6 +96,7 @@ def prepare_data_for_storage(major_version, minor_version, patch_version, minimu u'''*/\n''' u'''#ifndef GENERATED_MSG_VERSION_H\n''' u'''#define GENERATED_MSG_VERSION_H\n\n''' + u'''#include \n\n''' u'''namespace application_manager {\n\n''' u'''const uint16_t major_version = $m_version;\n''' u'''const uint16_t minor_version = $min_version;\n''' diff --git a/tools/InterfaceGenerator/generator/generators/PolicyTypes.py b/tools/InterfaceGenerator/generator/generators/PolicyTypes.py new file mode 100644 index 00000000000..2621950e7a4 --- /dev/null +++ b/tools/InterfaceGenerator/generator/generators/PolicyTypes.py @@ -0,0 +1,691 @@ +"""SmartFactory code generator base. + +Base of code generator for SmartFactory that provides SmartSchema object in +accordance with given internal model. + +""" +# pylint: disable=W0402 +# pylint: disable=C0302 +import codecs +import collections +import os +import string +import uuid +import re + +from generator import Model + + +class GenerateError(Exception): + + """Generate error. + + This exception is raised when generator is unable to create + output from given model. + + """ + + pass + +def to_camel_case(snake_str): + components = snake_str.split('_') + return components[0].lower() + "".join(x.title() for x in components[1:]) + +def to_snake_case(camel_str): + s1 = re.sub('(.)([A-Z][a-z]+)', r'\1_\2', camel_str) + return re.sub('([a-z0-9])([A-Z])', r'\1_\2', s1) + +class CodeGenerator(object): + + """Base PolicyTypes generator. + + This class provides service which allows to generate *.h files with types required for Policy + + """ + + def __init__(self): + """Construct new object.""" + + self._generated_structs = [] + self._structs_add_code = u"" + + def generate_vehicledatatype_names(self, enum): + template = string.Template('''static std::set ${enum_name}_enum_names = { \n${values}\n};\n''') + enum_element_name = lambda enum_element: enum_element.internal_name if enum_element.internal_name else enum_element.name + values = ", \n".join([" \"{}\"".format(enum_element_name(enum_element)) for enum_element in enum.elements.values()]) + return template.substitute(enum_name=enum.name, values = values) + + def generate_all_enum_values(self, enum): + template = string.Template('''static std::set ${enum_name}_all_enum_values = { \n${values}\n};\n''') + enum_element_name = lambda enum_element: enum_element.internal_name if enum_element.internal_name else enum_element.name + values = ", \n".join([" mobile_apis::{}::{}".format(enum.name, enum_element_name(enum_element)) for enum_element in enum.elements.values()]) + return template.substitute(enum_name=enum.name, values = values) + + def generate_enums_schema_factory_content(self, enums): + return "\n".join([self._enum_factory_element_template.substitute(enum_name = enum.name) for enum in enums]) + + def generate_enums_schema_factory_impl(self, enums): + enums_values = "" + for enum in enums: + enums_values += "\n".join([self.generate_all_enum_values(enum)]) + if enum.name == "VehicleDataType": + enums_values += "\n".join([self.generate_vehicledatatype_names(enum)]) + return self._enum_factory_template.substitute(enums_values = enums_values, + enum_factory_content = self.generate_enums_schema_factory_content(enums)) + + def generate_POD_types_schema_factory_impl(self, enums): + pod_types = { + "Integer" : "int32_t", + "Float" : "double", + } + '''if (enum_name == "DriverDistractionState") { + return Get(DriverDistractionState_all_enum_values); + }''' + enums_values = "\n".join([self.generate_all_enum_values(enum) for enum in enums]) + return self._enum_factory_template.substitute(enums_values = enums_values, + enum_factory_content = self.generate_enums_schema_factory_content(enums)) + + def generate(self, interface, filename, namespace, destination_dir): + """ Generate SmartFactory source files. + + Generates source code files at destination directory in + accordance with given model in specified namespace. + + Keyword arguments: + interface -- model of the interface to generate source code for. + filename -- name of initial XML file. + namespace -- name of destination namespace. + destination_dir -- directory to create source files. + + """ + + if interface is None: + raise GenerateError("Given interface is None.") + + params_set = set() + for func in interface.functions.values(): + for param in func.params: + params_set.add(param) + parameter_enum = Model.Enum('Parameter') + + for item in params_set: + parameter_enum.elements[item.upper()] = Model.EnumElement(item) + + + required_enums_for_policy = [ + "HMILevel", + "FunctionID", + "HybridAppPreference", + "AppHMIType", + "RequestType", + "ModuleType", + "Common_AppPriority", + "Parameter" + ] + + self.required_empty_value = [ + "RequestType", + "ModuleType", + "Parameter" + ] + + self.enum_items_naming_conversion_ = { + "HMILevel" : lambda item_name : "HL_" + item_name.replace("HMI_", ""), + "AppHMIType" : lambda item_name : "AHT_" + item_name, + "FunctionID" : lambda item_name : item_name, + "HybridAppPreference" : lambda item_name : item_name, + "RequestType" : lambda item_name : "RT_" + item_name, + "ModuleType" : lambda item_name : "MT_" + item_name, + "Common_AppPriority" : lambda item_name : "P_" + item_name if not item_name == "VOICE_COMMUNICATION" else "P_VOICECOM", + "Parameter" : lambda item_name : "P_" + to_snake_case(item_name).upper() + } + + self.enum_items_string_naming_conversion_ = { + "HMILevel" : lambda item_name : item_name, + "AppHMIType" : lambda item_name : item_name, + "FunctionID" : lambda item_name : item_name[:item_name.rfind("ID")], + "HybridAppPreference" : lambda item_name : item_name, + "RequestType" : lambda item_name : item_name, + "ModuleType" : lambda item_name : item_name, + "Common_AppPriority" : lambda item_name : item_name if not item_name == "VOICE_COMMUNICATION" else "VOICECOM", + "Parameter" : lambda item_name : item_name + } + + self.enum_naming_conversion_ = { + "HMILevel" : "HmiLevel", + "AppHMIType" : "AppHMIType", + "FunctionID" : "FunctionID", + "HybridAppPreference" : "HybridAppPreference", + "RequestType" : "RequestType", + "ModuleType" : "ModuleType", + "Common_AppPriority" : "Priority", + "Parameter" : "Parameter" + } + + get_first_enum_value_name = lambda enum : enum.elements.values()[0].name + enum_required_for_policy = lambda enum : enum.name in required_enums_for_policy and "." not in get_first_enum_value_name(enum) + + # In case if "." is in FunctionID name this is HMI_API function ID and should not be included in Policy enums + + required_enum_values = [val for val in interface.enums.values() + if enum_required_for_policy(val)] + + if filename == "MOBILE_API": + self._write_cc_with_enum_schema_factory(filename, namespace, destination_dir, interface.enums.values()) + + # Params should be generated as enum for MOBILE_API to validate RPCSpec parameters + required_enum_values.append(parameter_enum) + + self._write_header_with_enums(filename, namespace, destination_dir, required_enum_values) + self._write_cc_with_enums(filename, namespace, destination_dir, required_enum_values) + + def _write_cc_with_enum_schema_factory(self,filename, namespace, destination_dir, required_enum_values): + class_name = u"generated_{0}_enum_schema_factory".format(filename) + header_file_name = '''policy/policy_table/policy_enum_schema_factory.h''' + cc_file_name = u"".join("{0}.cc".format(class_name)) + if not os.path.exists(destination_dir): + os.makedirs(destination_dir) + print(os.path.join(destination_dir, cc_file_name)) + with codecs.open(os.path.join(destination_dir, cc_file_name), + encoding="utf-8", + mode="w") as f_cc: + guard = u"_{0}_{1}_CC__".format( class_name.upper(), + unicode(uuid.uuid1().hex.capitalize())) + namespace_open, namespace_close = self._namespaces_strings(namespace) + includes = '''#include \n'''\ + '''#include "interfaces/MOBILE_API.h"\n'''\ + '''#include "smart_objects/enum_schema_item.h"\n''' + f_cc.write(self._cc_file_template.substitute( + class_name=class_name, + header_file=header_file_name, + includes = includes, + namespace_open=namespace_open, + enums_content=self.generate_enums_schema_factory_impl(required_enum_values), + namespace_close=namespace_close)) + + def _write_header_with_enums(self,filename, namespace, destination_dir, required_enum_values): + class_name = u"generated_{0}_policy_types".format(filename) + header_file_name = u"".join("{0}.h".format(class_name)) + if not os.path.exists(destination_dir): + os.makedirs(destination_dir) + with codecs.open(os.path.join(destination_dir, header_file_name), + encoding="utf-8", + mode="w") as f_h: + guard = u"_{0}_{1}_H__".format( class_name.upper(), + unicode(uuid.uuid1().hex.capitalize())) + namespace_open, namespace_close = self._namespaces_strings(namespace) + f_h.write(self._h_file_template.substitute( + class_name=class_name, + guard=guard, + includes="", + namespace_open=namespace_open, + enums_content=self._gen_enums(required_enum_values + ), + namespace_close=namespace_close)) + + def _write_cc_with_enums(self,filename, namespace, destination_dir, required_enum_values): + class_name = u"generated_{0}_policy_types".format(filename) + header_file_name = u"".join("{0}.h".format(class_name)) + cc_file_name = u"".join("{0}.cc".format(class_name)) + if not os.path.exists(destination_dir): + os.makedirs(destination_dir) + with codecs.open(os.path.join(destination_dir, cc_file_name), + encoding="utf-8", + mode="w") as f_cc: + guard = u"_{0}_{1}_CC__".format( class_name.upper(), + unicode(uuid.uuid1().hex.capitalize())) + namespace_open, namespace_close = self._namespaces_strings(namespace) + f_cc.write(self._cc_file_template.substitute( + class_name=class_name, + header_file=header_file_name, + includes="", + namespace_open=namespace_open, + enums_content=self.gen_enums_processing(required_enum_values + ), + namespace_close=namespace_close)) + + def _namespaces_strings(self, namespace): + + """ Generate open and close namespaces strings + + Generates source code for opening and close namespaces + + Keyword arguments: + namespace -- name of destination namespace. + + Returns: + Tuple with namespace open string and namespace close string + """ + + namespace = unicode(namespace) + namespace_open = u"" + namespace_close = u"" + if namespace: + parts = namespace.split(u"::") + for part in parts: + namespace_open = u"".join( + [namespace_open, + self._namespace_open_template.substitute(name=part)]) + namespace_close = u"".join( + [namespace_close, + "}} // {0}\n".format(part)]) + + return namespace_open, namespace_close + + + def _gen_enums(self, enums): + """Generate enums for header file. + + Generates declaration of enumerations for the header file. + + Keyword arguments: + enums -- list of enums to generate. + + Returns: + String with enums declaration source code. + + """ + + if enums is None: + raise GenerateError("Enums is None") + + return u"\n".join([self._gen_enum(x) for x in enums]) + + def _gen_enum(self, enum): + """Generate enum for header file. + + Generates declaration of enumeration for the header file. + + Keyword arguments: + enum -- enum to generate. + + Returns: + String with enum declaration source code. + + """ + + enum_elements = enum.elements.values() + return self._enum_template.substitute( + comment=self._gen_comment(enum), + name=self.enum_naming_conversion_[enum.name], + enum_items=self._indent_code(self._gen_enum_elements( + enum_elements, enum.name), 1)) + + def _gen_enum_elements(self, enum_elements, enum_name): + """Generate enum elements for header file. + + Generates declaration of enumeration elements for the header file. + + Keyword arguments: + enum_elements -- list of enum elements to generate. + + Returns: + String with enum elements declaration source code. + + """ + enum_elements = [self._gen_enum_element(x, enum_name) + for x in enum_elements] + if (enum_name in self.required_empty_value): + enum_elements.append(self._gen_empty_enum_element(enum_name)) + return u",\n\n".join(enum_elements) + + def _gen_empty_enum_element(self, enum_name) : + return self._enum_element_with_value_template.substitute( + comment="", + name=self.enum_items_naming_conversion_[enum_name]("EMPTY"), + value=-1) + + def _gen_enum_element(self, enum_element, enum_name): + """Generate enum element for header file. + + Generates declaration of enumeration element for the header file. + + Keyword arguments: + enum_element -- enum element to generate. + + Returns: + String with enum element declaration source code. + + """ + + if enum_element.value is not None: + return self._enum_element_with_value_template.substitute( + comment=self._gen_comment(enum_element), + name=self.enum_items_naming_conversion_[enum_name](enum_element.primary_name), + value=enum_element.value) + else: + return self._enum_element_with_no_value_template.substitute( + comment=self._gen_comment(enum_element), + name=self.enum_items_naming_conversion_[enum_name](enum_element.primary_name)) + + def gen_enums_processing(self, enums): + validation = "\n".join([self._gen_enum_validation(enum) for enum in enums]) + to_json = "\n".join([self._gen_enum_to_json(enum) for enum in enums]) + from_json = "\n".join([self._gen_enum_from_json(enum) for enum in enums]) + return "\n".join([validation, to_json, from_json]) + + def _gen_enum_validation(self, enum): + return self._valiation_enum_template.substitute( + name = self.enum_naming_conversion_[enum.name], + enum_items = "\n".join([self._gen_enum_item_validation(enum_item.name, enum.name) for enum_item in enum.elements.values()]) + ) + + def _gen_enum_item_validation(self, item_name, enum_name): + return self._valiation_enum_item_template.substitute( + name = self.enum_items_naming_conversion_[enum_name](item_name)) + + def _gen_enum_to_json(self, enum): + name = self.enum_naming_conversion_[enum.name] + enum_items = "\n".join([self._gen_enum_item_to_json(enum_item.name, enum.name) for enum_item in enum.elements.values()]) + if (enum.name in self.required_empty_value): + enum_items+= "\n" + self._gen_enum_item_to_json("EMPTY", enum.name) + return self._enum_to_json_template.substitute( + name = name, + enum_items = enum_items + ) + + def _gen_enum_item_to_json(self, item_name, enum_name): + return self._enum_to_json_item_template.substitute( + name = self.enum_items_naming_conversion_[enum_name](item_name), + string_name = self.enum_items_string_naming_conversion_[enum_name](item_name) + ) + + + def _gen_enum_from_json(self, enum): + name = self.enum_naming_conversion_[enum.name] + enum_items = "\n".join([self._gen_enum_item_from_json(enum_item.name, enum.name) for enum_item in enum.elements.values()]) + if (enum.name in self.required_empty_value): + enum_items += "\n" + self._gen_enum_item_from_json("EMPTY", enum.name) + return self._enum_from_json_template.substitute( + name = name, + enum_items = enum_items + ) + + def _gen_enum_item_from_json(self, item_name, enum_name): + return self._enum_from_json_item_template.substitute( + name = self.enum_items_naming_conversion_[enum_name](item_name), + string_name = self.enum_items_string_naming_conversion_[enum_name](item_name) + ) + + def _gen_comment(self, interface_item_base, use_doxygen=True): + """Generate doxygen comment for iterface_item_base for header file. + + Generates doxygen comment for any iterface_item_base for the header + file. + + Keyword arguments: + interface_item_base -- object to generate doxygen comment for. + use_doxygen -- Flag that indicates does function uses doxygen or not. + + Returns: + String with generated doxygen comment. + + """ + + brief_type_title = None + interface_item_base_classname = interface_item_base.__class__.__name__ + if interface_item_base_classname in self._model_types_briefs: + brief_type_title = \ + self._model_types_briefs[interface_item_base_classname] + else: + raise GenerateError("Unable to create comment for unknown type " + + interface_item_base_classname) + + name = interface_item_base.primary_name if \ + type(interface_item_base) is Model.EnumElement else \ + interface_item_base.name + brief_description = (u" * @brief {0}{1}.\n" if use_doxygen is + True else u"// {0}{1}.\n").format( + brief_type_title, + name) + + description = u"".join([(u" * {0}\n" if use_doxygen + is True else u"// {0}\n").format(x) + for x in self._normalize_multiline_comments( + interface_item_base.description)]) + if description is not u"": + description = u"".join([u" *\n" if use_doxygen + is True else u"//\n", description]) + + design_description = u"".join([(u" * {0}\n" if use_doxygen is + True else u"// {0}\n").format(x) + for x in + self._normalize_multiline_comments( + interface_item_base. + design_description)]) + if design_description is not u"": + design_description = u"".join([u" *\n" if use_doxygen is + True else "//\n", + design_description]) + + issues = u"".join([(u" * @note {0}\n" if use_doxygen is + True else u"// Note: {0}\n").format(x) + for x in self._normalize_multiline_comments( + [x.value for x in interface_item_base.issues])]) + if issues is not u"": + issues = u"".join([u" *\n" if use_doxygen is + True else u"//\n", issues]) + + todos = u"".join([(u" * @todo {0}\n" if use_doxygen is + True else u"// ToDo: {0}\n").format(x) + for x in self._normalize_multiline_comments( + interface_item_base.todos)]) + if todos is not u"": + todos = u"".join([u" *\n" if use_doxygen is + True else u"//\n", todos]) + + returns = u"" + if type(interface_item_base) is Model.Function: + returns = u"".join([u" *\n", self._function_return_comment]) + + template = self._comment_doxygen_template if use_doxygen is \ + True else self._comment_cc_template + + return template.substitute( + brief_description=brief_description, + description=description, + design_description=design_description, + issues=issues, + todos=todos, + returns=returns) + + def _indent_code(self, code, indent_level): + """Indent given source code. + + Indents given source code right by given indentation level. + + Keyword arguments: + code -- given source code. + indent_level -- desired indentation level. + + Returns: + String with processed code. + + """ + + code_lines = code.split("\n") + return u"".join( + [u"{0}{1}\n".format( + self._indent_template * indent_level, + x) if x is not u"" else u"\n" for x in code_lines]) + + @staticmethod + def _normalize_multiline_comments(initial_strings): + """Normalize multiline comments. + + Makes multiline comment clean of any line breaks creating additional + strings for the comment. + + Keyword arguments: + initial_strings -- initial list of strings to process. + + Returns: + New list of the strings (with contains no strings with line breaks). + + """ + + result = [] + for initial_string in initial_strings: + result = result + initial_string.splitlines() + return result + + _model_types_briefs = dict( + {u"EnumElement": u"", + u"Enum": u"Enumeration ", + u"Function": u"Method that generates schema for function ", + u"Struct": u"Method that generates schema item for structure ", + u"Param": u"Struct member ", + u"FunctionParam": u"Function parameter "}) + + _cc_file_template = string.Template( + u'''/**\n''' + u''' * @file ${class_name}.h\n''' + u''' * @brief Generated class ${class_name} source file.\n''' + u''' *\n''' + u'''*/\n''' + u'''#include "${header_file}"\n''' + u'''${includes}''' + u'''\n\n''' + u'''$namespace_open''' + u'''\n''' + u'''$enums_content''' + u'''\n''' + u'''$namespace_close''' + u'''\n\n''') + + + _h_file_template = string.Template( + u'''/**\n''' + u''' * @file ${class_name}.h\n''' + u''' * @brief Generated class ${class_name} header file.\n''' + u''' *\n''' + u'''* Copyright (c) 2017, Ford Motor Company\n''' + u'''* All rights reserved.\n''' + u'''*\n''' + u'''* Redistribution and use in source and binary forms, with or without\n''' + u'''* modification, are permitted provided that the following conditions are met:\n''' + u'''*\n''' + u'''* Redistributions of source code must retain the above copyright notice, this\n''' + u'''* list of conditions and the following disclaimer.\n''' + u'''*\n''' + u'''* Redistributions in binary form must reproduce the above copyright notice,\n''' + u'''* this list of conditions and the following\n''' + u'''* disclaimer in the documentation and/or other materials provided with the\n''' + u'''* distribution.\n''' + u'''*\n''' + u'''* Neither the name of the Ford Motor Company nor the names of its contributors\n''' + u'''* may be used to endorse or promote products derived from this software\n''' + u'''* without specific prior written permission.\n''' + u'''*\n''' + u'''* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"\n''' + u'''* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n''' + u'''* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n''' + u'''* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE\n''' + u'''* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n''' + u'''* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n''' + u'''* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS\n''' + u'''* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN\n''' + u'''* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n''' + u'''* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\n''' + u'''* POSSIBILITY OF SUCH DAMAGE.\n''' + u'''*/\n''' + u'''\n''' + u'''#ifndef $guard\n''' + u'''#define $guard\n''' + u'''#include \n''' + u'''${includes}''' + u'''\n''' + u'''$namespace_open''' + u'''$enums_content''' + u'''$namespace_close''' + u'''#endif //$guard\n''' + u'''\n\n''') + + + _namespace_open_template = string.Template( + u'''namespace $name {\n''') + + _comment_doxygen_template = string.Template( + u'''/**\n''' + u'''$brief_description''' + u'''$description''' + u'''$design_description''' + u'''$issues''' + u'''$todos''' + u'''$returns */''') + + _enum_template = string.Template( + u'''$comment\n''' + u'''enum $name {\n''' + u'''$enum_items};\n''' + u'''bool IsValidEnum($name val);\n''' + u'''const char* EnumToJsonString($name val);\n''' + u'''bool EnumFromJsonString(const std::string& literal, $name* result);\n''' + ) + _valiation_enum_template = string.Template( + u'''bool IsValidEnum($name val) {\n''' + u''' return !(std::string(EnumToJsonString(val)).empty());\n''' + u'''};\n''') + + _valiation_enum_item_template = string.Template( + u''' case $name: return true;''') + + _enum_to_json_template = string.Template( + u'''const char* EnumToJsonString($name val) {\n''' + u''' switch (val) {\n''' + u'''$enum_items\n''' + u''' default: return "";\n''' + u''' }\n''' + u'''};\n''') + + _enum_to_json_item_template = string.Template( + u''' case $name: return "$string_name";''') + + _enum_from_json_template = string.Template( + u'''bool EnumFromJsonString(const std::string& literal, $name* result) {\n''' + u'''$enum_items''' + u''' return false;\n''' + u'''};\n''') + + _enum_from_json_item_template = string.Template( + u''' if ("$string_name" == literal) {\n''' + u''' *result = $name;\n''' + u''' return true;\n''' + u''' }\n''') + + _enum_element_with_value_template = string.Template( + u'''$comment\n''' + u'''$name = $value''') + + _enum_element_with_no_value_template = string.Template( + u'''$comment\n''' + u'''$name''') + _enum_factory_template = string.Template( + '''${enums_values}\n''' + '''template\n''' + '''std::shared_ptr Create(const std::set& all_enum_values) {\n''' + '''using namespace smart_objects;\n''' + ''' static auto schemaItem = TEnumSchemaItem::create(all_enum_values, TSchemaItemParameter());\n''' + ''' return schemaItem;\n''' + '''}\n\n''' + '''std::shared_ptr EnumSchemaItemFactory::Get(const std::string & enum_name) {\n''' + '''${enum_factory_content}\n''' + ''' return std::shared_ptr();\n''' + '''}\n\n''' + '''bool EnumSchemaItemFactory::IsRPCSpecVehicleDataType(const std::string& vd_name) {\n''' + ''' for(auto& item_name : VehicleDataType_enum_names) {\n''' + ''' if (vd_name == item_name) {\n''' + ''' return true;\n''' + ''' }\n''' + ''' }\n''' + ''' return false;\n''' + '''}\n''') + _enum_factory_element_template = string.Template( + ''' if (enum_name == "${enum_name}") {\n''' + ''' return Create(${enum_name}_all_enum_values);\n''' + ''' }''') + _POD_type_factory_element_template = string.Template( + ''' if (typename == "${type_name}") {\n''' + ''' return TNumberSchemaItem<${cpp_type}>::create(TSchemaItemParameter(${min_val}), TSchemaItemParameter(${${max_val}}), TSchemaItemParameter<${cpp_type}>());''' + ''' }''') + _indent_template = u" " diff --git a/tools/InterfaceGenerator/generator/generators/SmartFactoryBase.py b/tools/InterfaceGenerator/generator/generators/SmartFactoryBase.py index c6a0145ac60..6cd60a7dfc4 100755 --- a/tools/InterfaceGenerator/generator/generators/SmartFactoryBase.py +++ b/tools/InterfaceGenerator/generator/generators/SmartFactoryBase.py @@ -93,7 +93,7 @@ def generate(self, interface, filename, namespace, destination_dir): with codecs.open(os.path.join(destination_dir, header_file_name), encoding="utf-8", mode="w") as f_h: - f_h.write(self._h_file_tempalte.substitute( + f_h.write(self._h_file_template.substitute( class_name=class_name, guard=guard, namespace_open=namespace_open, @@ -131,7 +131,7 @@ def generate(self, interface, filename, namespace, destination_dir): with codecs.open(os.path.join(destination_dir, header_file_name), encoding="utf-8", mode="w") as f_h: - f_h.write(self._hpp_schema_file_tempalte.substitute( + f_h.write(self._hpp_schema_file_template.substitute( class_name=class_name, guard=guard, header_file_name=unicode("".join("{0}.h".format(class_name))), @@ -157,6 +157,8 @@ def generate(self, interface, filename, namespace, destination_dir): interface.functions.values()), function_schemas=self._gen_function_schemas( interface.functions.values()), + function_schemas_switch=self._gen_function_schema_switch( + interface.functions.values()), init_function_impls=self._gen_function_impls( interface.functions.values(), namespace, @@ -450,6 +452,48 @@ def _gen_function_schemas(self, functions): self._gen_function_schema(x), 1) for x in functions]) + def _gen_function_schema_switch(self, functions): + """Generate initialization code of each function for source file. + + Generates function schema initialization code that should be used + in the source file. + + Keyword arguments: + function -- function to generate method for. + + Returns: + String with switch for functions initialization source code. + + """ + + if functions is None: + raise GenerateError("Functions is None") + + def function_id_switch(self, message_type, functions): + case_list = [self._function_id_case_template.substitute( + function_id=x.function_id.primary_name, + message_type=x.message_type.primary_name) + for x in functions if x.message_type.primary_name == message_type ] + case_list.append("default:\n break;\n") + switch_function_id_cases = self._indent_code(u"".join(case_list), 1)[:-1] + + return self._indent_code(self._function_switch_template.substitute( + switchable="function_id", + cases=switch_function_id_cases + ), 1)[:-1] + + message_type_case_list = [self._message_type_case_template.substitute( + message_type = message_type, + case_body = function_id_switch(self, message_type, functions) + ) for message_type in set([x.message_type.primary_name for x in functions])] + message_type_case_list.append("default:\n break;\n") + message_type_cases = self._indent_code(u"".join(message_type_case_list), 1)[:-1] + + return self._indent_code(self._function_switch_template.substitute( + switchable="message_type", + cases=message_type_cases + ), 1)[:-1] + def _gen_function_schema(self, function): """Generate function initialization code for source file. @@ -1361,7 +1405,7 @@ def _normalize_multiline_comments(initial_strings): u"Param": u"Struct member ", u"FunctionParam": u"Function parameter "}) - _h_file_tempalte = string.Template( + _h_file_template = string.Template( u'''/**\n''' u''' * @file ${class_name}.h\n''' u''' * @brief Generated class ${class_name} header file.\n''' @@ -1426,7 +1470,7 @@ def _normalize_multiline_comments(initial_strings): u'''#endif //$guard\n''' u'''\n\n''') - _hpp_schema_file_tempalte = string.Template( + _hpp_schema_file_template = string.Template( u'''/**\n''' u''' * @file ${class_name}.h\n''' u''' * @brief Generated class ${class_name} header file.\n''' @@ -1488,6 +1532,7 @@ def _normalize_multiline_comments(initial_strings): u'''#include "formatters/CSmartFactory.h"\n''' u'''#include "smart_objects/smart_schema.h"\n''' u'''#include "smart_objects/schema_item.h"\n''' + u'''#include "smart_objects/object_schema_item.h"\n''' u'''#include "$header_file_name"\n''' u'''\n''' u'''$namespace_open''' @@ -1512,7 +1557,7 @@ def _normalize_multiline_comments(initial_strings): u'''SmartSchemas\n''' u''' * in accordance with definitions from ${class_name}.xml file\n''' u''' */\n''' - u'''// Copyright (c) 2013, Ford Motor Company\n''' + u'''// Copyright (c) 2019, SmartDeviceLink Consortium, Inc.\n''' u'''// All rights reserved.\n''' u'''//\n''' u'''// Redistribution and use in source and binary forms, ''' @@ -1531,11 +1576,11 @@ def _normalize_multiline_comments(initial_strings): u'''provided with the\n''' u'''// distribution.\n''' u'''//\n''' - u'''// Neither the name of the Ford Motor Company nor the names ''' - u'''of its contributors\n''' - u'''// may be used to endorse or promote products derived ''' - u'''from this software\n''' - u'''// without specific prior written permission.\n''' + u'''// Neither the name of the SmartDeviceLink Consortium, Inc. nor the names ''' + u'''of its\n''' + u'''// contributors may be used to endorse or promote products derived ''' + u'''from this\n''' + u'''// software without specific prior written permission.\n''' u'''//\n''' u'''// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND ''' u'''CONTRIBUTORS "AS IS"\n''' @@ -1604,6 +1649,32 @@ def _normalize_multiline_comments(initial_strings): u'''CAlwaysFalseSchemaItem::create();\n''' u'''}\n''' u'''\n''' + u'''bool $namespace::$class_name::AddCustomMember(FunctionID::eType function_id,\n''' + u''' messageType::eType message_type,\n''' + u''' std::string member_key, ns_smart_device_link::ns_smart_objects::SMember member) {\n''' + u''' using namespace ns_smart_device_link::ns_json_handler;\n''' + u''' using namespace ns_smart_device_link::ns_smart_objects;\n''' + u''' SmartSchemaKey shema_key(function_id, message_type);\n''' + u''' auto function_schema = functions_schemes_.find(shema_key);\n''' + u''' if (functions_schemes_.end() == function_schema){\n''' + u''' return false;\n''' + u''' }\n''' + u'''\n''' + u''' auto schema = function_schema->second.getSchemaItem();\n''' + u''' auto msg_params_schema_item = schema->GetMemberSchemaItem(ns_smart_device_link::ns_json_handler::strings::S_MSG_PARAMS);\n''' + u''' if (!msg_params_schema_item.is_initialized()){\n''' + u''' return false;\n''' + u''' }\n''' + u'''\n''' + u''' msg_params_schema_item->mSchemaItem->AddMemberSchemaItem(member_key, member);\n''' + u''' return true;\n''' + u'''}\n''' + u'''\n''' + u'''void $namespace::$class_name::ResetFunctionSchema(FunctionID::eType function_id,\n''' + u''' messageType::eType message_type) {\n''' + u''' InitFunctionSchema(function_id, message_type);\n''' + u'''}\n''' + u'''\n''' u'''void $namespace::$class_name::InitStructSchemes(\n''' u''' TStructsSchemaItems &struct_schema_items) {''' u'''$struct_schema_items''' @@ -1617,6 +1688,19 @@ def _normalize_multiline_comments(initial_strings): u'''$function_schemas''' u'''}\n''' u'''\n''' + u'''void $namespace::$class_name::InitFunctionSchema(\n''' + u''' const FunctionID::eType &function_id,\n''' + u''' const messageType::eType &message_type) {\n''' + u'''\n''' + u''' TStructsSchemaItems struct_schema_items;\n''' + u''' InitStructSchemes(struct_schema_items);\n''' + u'''\n''' + u''' std::set function_id_items { function_id };\n''' + u''' std::set message_type_items { message_type };\n''' + u'''\n''' + u'''$function_schemas_switch''' + u'''}\n''' + u'''\n''' u'''//------------- Functions schemes initialization -------------\n''' u'''\n''' u'''$init_function_impls''' @@ -1668,6 +1752,26 @@ def _normalize_multiline_comments(initial_strings): u'''};\n''' u'''\n''') + _function_switch_template = string.Template( + u'''switch(${switchable}) {\n''' + u'''${cases}''' + u'''}\n''') + + _message_type_case_template = string.Template( + u'''case messageType::${message_type}: {\n''' + u'''${case_body}''' + u''' break;\n''' + u'''}\n''') + + _function_id_case_template = string.Template( + u'''case FunctionID::${function_id}: {\n''' + u''' ns_smart_device_link::ns_json_handler::SmartSchemaKey shema_key(function_id, message_type);\n''' + u''' functions_schemes_[shema_key] = ''' + u'''InitFunction_${function_id}_${message_type}(''' + u'''struct_schema_items, function_id_items, message_type_items);\n''' + u''' break;\n''' + u'''}\n''') + _struct_schema_item_template = string.Template( u'''std::shared_ptr struct_schema_item_${name} = ''' u'''InitStructSchemaItem_${name}(struct_schema_items);\n''' @@ -1695,7 +1799,7 @@ def _normalize_multiline_comments(initial_strings): _struct_impl_code_tempate = string.Template( u'''${schema_loc_decl}''' u'''${schema_items_decl}''' - u'''CObjectSchemaItem::Members ''' + u'''Members ''' u'''schema_members;\n\n''' u'''${schema_item_fill}''' u'''return CObjectSchemaItem::create(schema_members);''') @@ -1724,10 +1828,10 @@ def _normalize_multiline_comments(initial_strings): u'''std::shared_ptr ${var_name} = ${item_decl};''') _impl_code_shared_ptr_vector_template = string.Template( - u'''std::vector ${var_name}_history_vector;''') + u'''std::vector ${var_name}_history_vector;''') _impl_code_append_history_vector_template = string.Template( - u'''${vector_name}_history_vector.push_back(CObjectSchemaItem::SMember(${name}_SchemaItem, ${mandatory}, "${since}", "${until}", ${deprecated}, ${removed}));''') + u'''${vector_name}_history_vector.push_back(SMember(${name}_SchemaItem, ${mandatory}, "${since}", "${until}", ${deprecated}, ${removed}));''') _impl_code_integer_item_template = string.Template( u'''TNumberSchemaItem<${type}>::create(${params})''') @@ -1755,16 +1859,13 @@ def _normalize_multiline_comments(initial_strings): u'''TSchemaItemParameter<$type>($value)''') _impl_code_item_fill_template = string.Template( - u'''schema_members["${name}"] = CObjectSchemaItem::''' - u'''SMember(${var_name}, ${is_mandatory});''') + u'''schema_members["${name}"] = SMember(${var_name}, ${is_mandatory});''') _impl_code_item_fill_template_with_version = string.Template( - u'''schema_members["${name}"] = CObjectSchemaItem::''' - u'''SMember(${var_name}, ${is_mandatory}, "${since}", "${until}", ${deprecated}, ${removed});''') + u'''schema_members["${name}"] = SMember(${var_name}, ${is_mandatory}, "${since}", "${until}", ${deprecated}, ${removed});''') _impl_code_item_fill_template_with_version_and_history_vector = string.Template( - u'''schema_members["${name}"] = CObjectSchemaItem::''' - u'''SMember(${var_name}, ${is_mandatory}, "${since}", "${until}", ${deprecated}, ${removed}, ${vector_name}_history_vector);''') + u'''schema_members["${name}"] = SMember(${var_name}, ${is_mandatory}, "${since}", "${until}", ${deprecated}, ${removed}, ${vector_name}_history_vector);''') _function_impl_template = string.Template( u'''CSmartSchema $namespace::$class_name::''' @@ -1778,22 +1879,22 @@ def _normalize_multiline_comments(initial_strings): _function_impl_code_tempate = string.Template( u'''${schema_loc_decl}''' u'''${schema_items_decl}''' - u'''CObjectSchemaItem::Members ''' + u'''Members ''' u'''schema_members;\n\n''' u'''${schema_item_fill}''' - u'''CObjectSchemaItem::Members ''' + u'''Members ''' u'''params_members;\n''' u'''${schema_params_fill}''' u'''\n''' - u'''CObjectSchemaItem::Members ''' + u'''Members ''' u'''root_members_map;\n''' u'''root_members_map[ns_smart_device_link::ns_json_handler::''' u'''strings::S_MSG_PARAMS] = ''' - u'''CObjectSchemaItem::SMember(CObjectSchemaItem::''' + u'''SMember(CObjectSchemaItem::''' u'''create(schema_members), true);\n''' u'''root_members_map[ns_smart_device_link::ns_json_handler::''' u'''strings::S_PARAMS] = ''' - u'''CObjectSchemaItem::SMember(CObjectSchemaItem::''' + u'''SMember(CObjectSchemaItem::''' u'''create(params_members), true);\n\n''' u'''return CSmartSchema(CObjectSchemaItem::''' u'''create(root_members_map));''') @@ -1809,7 +1910,19 @@ def _normalize_multiline_comments(initial_strings): u''' */\n''' u''' $class_name();\n''' u'''\n''' - u''' protected:\n''' + u''' /**\n''' + u''' * @brief Adds custom members to existing list of params.\n''' + u''' */\n''' + u''' bool AddCustomMember(FunctionID::eType function_id,\n''' + u''' messageType::eType message_type,\n''' + u''' std::string member_key, ns_smart_device_link::ns_smart_objects::SMember member);\n''' + u'''\n''' + u''' /**\n''' + u''' * @brief Reset function schema to state defined in API.\n''' + u''' */\n''' + u''' void ResetFunctionSchema(FunctionID::eType function_id,\n''' + u''' messageType::eType message_type);\n''' + u'''\n''' u''' /**\n''' u''' * @brief Type that maps of struct IDs to schema items.\n''' u''' */\n''' @@ -1817,6 +1930,7 @@ def _normalize_multiline_comments(initial_strings): u'''std::shared_ptr > TStructsSchemaItems;\n''' u'''\n''' + u''' protected:\n''' u''' /**\n''' u''' * @brief Helper that allows to make reference to struct\n''' u''' *\n''' @@ -1852,8 +1966,19 @@ def _normalize_multiline_comments(initial_strings): u''' const std::set ''' u'''&message_type_items);\n''' u'''\n''' + u''' /**\n''' + u''' * @brief Initializes single function schema.\n''' + u''' *\n''' + u''' * @param function_id Function ID of schema to be initialized.\n''' + u''' * @param message_type Message type of schema to be initialized.\n''' + u''' */\n''' + u''' void InitFunctionSchema(\n''' + u''' const FunctionID::eType &function_id,\n''' + u''' const messageType::eType &message_type);\n''' + u'''\n''' u'''$init_function_decls''' u'''\n''' + u''' public:\n''' u'''$init_struct_decls''' u'''};''') diff --git a/tools/InterfaceGenerator/generator/generators/SmartFactoryJSONRPC.py b/tools/InterfaceGenerator/generator/generators/SmartFactoryJSONRPC.py index 6924ec67aaa..07b55382a67 100755 --- a/tools/InterfaceGenerator/generator/generators/SmartFactoryJSONRPC.py +++ b/tools/InterfaceGenerator/generator/generators/SmartFactoryJSONRPC.py @@ -100,35 +100,35 @@ def _gen_schema_params_fill(self, message_type_name): u'''error_response_schema));\n''') _error_response_schema_template = ( - u'''CObjectSchemaItem::Members ''' + u'''Members ''' u'''params_members;\n''' u'''params_members[ns_smart_device_link::ns_json_handler::''' - u'''strings::S_FUNCTION_ID] = CObjectSchemaItem::SMember(''' + u'''strings::S_FUNCTION_ID] = SMember(''' u'''TEnumSchemaItem::create(''' u'''function_id_items), true);\n''' u'''params_members[ns_smart_device_link::ns_json_handler::''' - u'''strings::S_MESSAGE_TYPE] = CObjectSchemaItem::SMember(''' + u'''strings::S_MESSAGE_TYPE] = SMember(''' u'''TEnumSchemaItem::create(''' u'''message_type_items), true);\n''' u'''params_members[ns_smart_device_link::ns_json_handler::''' - u'''strings::S_PROTOCOL_VERSION] = CObjectSchemaItem::SMember(''' + u'''strings::S_PROTOCOL_VERSION] = SMember(''' u'''TNumberSchemaItem::create(), true);\n''' u'''params_members[ns_smart_device_link::ns_json_handler::''' - u'''strings::S_PROTOCOL_TYPE] = CObjectSchemaItem::SMember(''' + u'''strings::S_PROTOCOL_TYPE] = SMember(''' u'''TNumberSchemaItem::create(), true);\n''' u'''params_members[ns_smart_device_link::ns_json_handler::''' - u'''strings::S_CORRELATION_ID] = CObjectSchemaItem::SMember(''' + u'''strings::S_CORRELATION_ID] = SMember(''' u'''TNumberSchemaItem::create(), true);\n''' u'''params_members[ns_smart_device_link::ns_json_handler::''' - u'''strings::kCode] = CObjectSchemaItem::SMember(''' + u'''strings::kCode] = SMember(''' u'''TNumberSchemaItem::create(), true);\n''' u'''params_members[ns_smart_device_link::ns_json_handler::''' - u'''strings::kMessage] = CObjectSchemaItem::SMember(''' + u'''strings::kMessage] = SMember(''' u'''CStringSchemaItem::create(), true);\n''' u'''\n''' - u'''CObjectSchemaItem::Members root_members_map;\n''' + u'''Members root_members_map;\n''' u'''root_members_map[ns_smart_device_link::ns_json_handler::''' - u'''strings::S_PARAMS] = CObjectSchemaItem::SMember(''' + u'''strings::S_PARAMS] = SMember(''' u'''CObjectSchemaItem::create(params_members), true);\n''' u'''\n''' u'''CSmartSchema error_response_schema(''' @@ -137,29 +137,23 @@ def _gen_schema_params_fill(self, message_type_name): _base_params = ( u'''params_members[ns_smart_device_link::ns_json_handler::''' - u'''strings::S_FUNCTION_ID] = CObjectSchemaItem::''' - u'''SMember(TEnumSchemaItem::''' + u'''strings::S_FUNCTION_ID] = SMember(TEnumSchemaItem::''' u'''create(function_id_items), true);\n''' u'''params_members[ns_smart_device_link::ns_json_handler::''' - u'''strings::S_MESSAGE_TYPE] = CObjectSchemaItem::''' - u'''SMember(TEnumSchemaItem::''' + u'''strings::S_MESSAGE_TYPE] = SMember(TEnumSchemaItem::''' u'''create(message_type_items), true);\n''' u'''params_members[ns_smart_device_link::ns_json_handler::''' - u'''strings::S_PROTOCOL_VERSION] = CObjectSchemaItem::''' - u'''SMember(TNumberSchemaItem::create(), true);\n''' + u'''strings::S_PROTOCOL_VERSION] = SMember(TNumberSchemaItem::create(), true);\n''' u'''params_members[ns_smart_device_link::ns_json_handler::''' - u'''strings::S_PROTOCOL_TYPE] = CObjectSchemaItem::''' - u'''SMember(TNumberSchemaItem::create(), true);\n''' + u'''strings::S_PROTOCOL_TYPE] = SMember(TNumberSchemaItem::create(), true);\n''' ) _correlation_id_param = ( u'''params_members[ns_smart_device_link::ns_json_handler::''' - u'''strings::S_CORRELATION_ID] = CObjectSchemaItem::''' - u'''SMember(TNumberSchemaItem::create(), true);\n''' + u'''strings::S_CORRELATION_ID] = SMember(TNumberSchemaItem::create(), true);\n''' ) _additional_response_params = ( u'''params_members[ns_smart_device_link::ns_json_handler::''' - u'''strings::kCode] = CObjectSchemaItem::''' - u'''SMember(TNumberSchemaItem::create(), true);\n''' + u'''strings::kCode] = SMember(TNumberSchemaItem::create(), true);\n''' ) diff --git a/tools/InterfaceGenerator/generator/generators/SmartFactorySDLRPC.py b/tools/InterfaceGenerator/generator/generators/SmartFactorySDLRPC.py index c3244f7e95c..f82c7bb8087 100755 --- a/tools/InterfaceGenerator/generator/generators/SmartFactorySDLRPC.py +++ b/tools/InterfaceGenerator/generator/generators/SmartFactorySDLRPC.py @@ -68,24 +68,19 @@ def _gen_schema_params_fill(self, message_type_name): base_params = \ u'''params_members[ns_smart_device_link::ns_json_handler::''' \ - u'''strings::S_FUNCTION_ID] = CObjectSchemaItem::''' \ - u'''SMember(TEnumSchemaItem::''' \ + u'''strings::S_FUNCTION_ID] = SMember(TEnumSchemaItem::''' \ u'''create(function_id_items), true);\n''' \ u'''params_members[ns_smart_device_link::ns_json_handler::''' \ - u'''strings::S_MESSAGE_TYPE] = CObjectSchemaItem::''' \ - u'''SMember(TEnumSchemaItem::''' \ + u'''strings::S_MESSAGE_TYPE] = SMember(TEnumSchemaItem::''' \ u'''create(message_type_items), true);\n''' \ u'''params_members[ns_smart_device_link::ns_json_handler::''' \ - u'''strings::S_PROTOCOL_VERSION] = CObjectSchemaItem::''' \ - u'''SMember(TNumberSchemaItem::create(), true);\n''' \ + u'''strings::S_PROTOCOL_VERSION] = SMember(TNumberSchemaItem::create(), true);\n''' \ u'''params_members[ns_smart_device_link::ns_json_handler::''' \ - u'''strings::S_PROTOCOL_TYPE] = CObjectSchemaItem::''' \ - u'''SMember(TNumberSchemaItem::create(), true);\n''' + u'''strings::S_PROTOCOL_TYPE] = SMember(TNumberSchemaItem::create(), true);\n''' correlation_id_param = \ u'''params_members[ns_smart_device_link::ns_json_handler::''' \ - u'''strings::S_CORRELATION_ID] = CObjectSchemaItem::''' \ - u'''SMember(TNumberSchemaItem::create(), true);\n''' + u'''strings::S_CORRELATION_ID] = SMember(TNumberSchemaItem::create(), true);\n''' return u"".join([base_params, correlation_id_param if unicode(message_type_name) != diff --git a/tools/InterfaceGenerator/generator/parsers/JSONRPC.py b/tools/InterfaceGenerator/generator/parsers/JSONRPC.py index 092f41ec17a..52aa5a10488 100755 --- a/tools/InterfaceGenerator/generator/parsers/JSONRPC.py +++ b/tools/InterfaceGenerator/generator/parsers/JSONRPC.py @@ -4,8 +4,9 @@ """ +from generator import Model from generator.parsers import RPCBase - +import xml.etree.ElementTree as ET class Parser(RPCBase.Parser): @@ -42,6 +43,17 @@ def _parse_root(self, root): self._interface_name = element.attrib["name"] self._parse_interface(element, self._interface_name + "_") + def _check_enum_name(self, enum): + """Check enum name. + + This method is called to check whether the newly parsed enum's name + conflicts with some predefined enum. + As SDLRPCV2 has no predefined enums this implementation does nothing. + + """ + + pass + def _provide_enum_element_for_function(self, enum_name, element_name): """Provide enum element for functions. diff --git a/tools/InterfaceGenerator/generator/parsers/RPCBase.py b/tools/InterfaceGenerator/generator/parsers/RPCBase.py index 21f07e6ac57..ac5bb4c858b 100755 --- a/tools/InterfaceGenerator/generator/parsers/RPCBase.py +++ b/tools/InterfaceGenerator/generator/parsers/RPCBase.py @@ -270,7 +270,7 @@ def _parse_struct(self, element, prefix): result = self._parse_version(attrib[attribute]) until = result elif attribute == "deprecated": - deprecated = attributes[attribute] + deprecated = attrib[attribute] elif attribute == "removed": removed = attrib[attribute] else: @@ -865,8 +865,6 @@ def _ignore_attribute(self, attrib, name): """ if name in attrib: del attrib[name] - print ("Ignoring attribute '" + - name + "'") return True def _parse_version(self, version): @@ -906,7 +904,7 @@ def _parse_history(self, history, prefix, parent): elif subelement.tag == "param" and parent.tag == "param": items.append(self._parse_function_param(subelement, prefix)) elif subelement.tag == "function" and parent.tag == "function": - items.append(self.__parse_function(subelement, prefix)) + items.append(self._parse_function(subelement, prefix)) else: raise ParseError("A history tag must be nested within the element it notes the history for. Fix item: '" + parent.attrib["name"] + "'") diff --git a/tools/InterfaceGenerator/generator/parsers/SDLRPCV2.py b/tools/InterfaceGenerator/generator/parsers/SDLRPCV2.py index 3d67c6e4c60..24974a55272 100755 --- a/tools/InterfaceGenerator/generator/parsers/SDLRPCV2.py +++ b/tools/InterfaceGenerator/generator/parsers/SDLRPCV2.py @@ -8,6 +8,7 @@ from generator import Model from generator.parsers import RPCBase +import xml.etree.ElementTree as ET class Parser(RPCBase.Parser): @@ -31,6 +32,7 @@ def _check_enum_name(self, enum): As SDLRPCV2 has no predefined enums this implementation does nothing. """ + pass def _parse_function_id_type(self, function_name, attrib): diff --git a/tools/InterfaceGenerator/test/generator/generators/test_SmartFactoryJSONRPC.py b/tools/InterfaceGenerator/test/generator/generators/test_SmartFactoryJSONRPC.py index c4813d00a8c..533fe92eb58 100755 --- a/tools/InterfaceGenerator/test/generator/generators/test_SmartFactoryJSONRPC.py +++ b/tools/InterfaceGenerator/test/generator/generators/test_SmartFactoryJSONRPC.py @@ -18,95 +18,95 @@ EXPECTED_RESULT_REQUEST = ( u"""params_members[ns_smart_device_link::ns_json_handler::""" - u"""strings::S_FUNCTION_ID] = CObjectSchemaItem::SMember(""" + u"""strings::S_FUNCTION_ID] = SMember(""" u"""TEnumSchemaItem::create(""" u"""function_id_items), true);\n""" u"""params_members[ns_smart_device_link::ns_json_handler::""" - u"""strings::S_MESSAGE_TYPE] = CObjectSchemaItem::SMember(""" + u"""strings::S_MESSAGE_TYPE] = SMember(""" u"""TEnumSchemaItem::create(""" u"""message_type_items), true);\n""" u"""params_members[ns_smart_device_link::ns_json_handler::""" - u"""strings::S_PROTOCOL_VERSION] = CObjectSchemaItem::SMember(""" + u"""strings::S_PROTOCOL_VERSION] = SMember(""" u"""TNumberSchemaItem::create(), true);\n""" u"""params_members[ns_smart_device_link::ns_json_handler::""" - u"""strings::S_PROTOCOL_TYPE] = CObjectSchemaItem::SMember(""" + u"""strings::S_PROTOCOL_TYPE] = SMember(""" u"""TNumberSchemaItem::create(), true);\n""" u"""params_members[ns_smart_device_link::ns_json_handler::""" - u"""strings::S_CORRELATION_ID] = CObjectSchemaItem::SMember(""" + u"""strings::S_CORRELATION_ID] = SMember(""" u"""TNumberSchemaItem::create(), true);\n""" ) EXPECTED_RESULT_RESPONSE = ( u"""params_members[ns_smart_device_link::ns_json_handler::""" - u"""strings::S_FUNCTION_ID] = CObjectSchemaItem::SMember(""" + u"""strings::S_FUNCTION_ID] = SMember(""" u"""TEnumSchemaItem::create(""" u"""function_id_items), true);\n""" u"""params_members[ns_smart_device_link::ns_json_handler::""" - u"""strings::S_MESSAGE_TYPE] = CObjectSchemaItem::SMember(""" + u"""strings::S_MESSAGE_TYPE] = SMember(""" u"""TEnumSchemaItem::create(""" u"""message_type_items), true);\n""" u"""params_members[ns_smart_device_link::ns_json_handler::""" - u"""strings::S_PROTOCOL_VERSION] = CObjectSchemaItem::SMember(""" + u"""strings::S_PROTOCOL_VERSION] = SMember(""" u"""TNumberSchemaItem::create(), true);\n""" u"""params_members[ns_smart_device_link::ns_json_handler::""" - u"""strings::S_PROTOCOL_TYPE] = CObjectSchemaItem::SMember(""" + u"""strings::S_PROTOCOL_TYPE] = SMember(""" u"""TNumberSchemaItem::create(), true);\n""" u"""params_members[ns_smart_device_link::ns_json_handler::""" - u"""strings::S_CORRELATION_ID] = CObjectSchemaItem::SMember(""" + u"""strings::S_CORRELATION_ID] = SMember(""" u"""TNumberSchemaItem::create(), true);\n""" u"""params_members[ns_smart_device_link::ns_json_handler::""" - u"""strings::kCode] = CObjectSchemaItem::SMember(""" + u"""strings::kCode] = SMember(""" u"""TNumberSchemaItem::create(), true);\n""" ) EXPECTED_RESULT_NOTIFICATION = ( u"""params_members[ns_smart_device_link::ns_json_handler::""" - u"""strings::S_FUNCTION_ID] = CObjectSchemaItem::SMember(""" + u"""strings::S_FUNCTION_ID] = SMember(""" u"""TEnumSchemaItem::create(""" u"""function_id_items), true);\n""" u"""params_members[ns_smart_device_link::ns_json_handler::""" - u"""strings::S_MESSAGE_TYPE] = CObjectSchemaItem::SMember(""" + u"""strings::S_MESSAGE_TYPE] = SMember(""" u"""TEnumSchemaItem::create(""" u"""message_type_items), true);\n""" u"""params_members[ns_smart_device_link::ns_json_handler::""" - u"""strings::S_PROTOCOL_VERSION] = CObjectSchemaItem::SMember(""" + u"""strings::S_PROTOCOL_VERSION] = SMember(""" u"""TNumberSchemaItem::create(), true);\n""" u"""params_members[ns_smart_device_link::ns_json_handler::""" - u"""strings::S_PROTOCOL_TYPE] = CObjectSchemaItem::SMember(""" + u"""strings::S_PROTOCOL_TYPE] = SMember(""" u"""TNumberSchemaItem::create(), true);\n""" ) EXPECTED_PRE_FUNCTION_CODE = ( - u""" std::map """ + u""" std::map """ u"""params_members;\n""" u""" params_members[ns_smart_device_link::ns_json_handler::""" - u"""strings::S_FUNCTION_ID] = CObjectSchemaItem::SMember(""" + u"""strings::S_FUNCTION_ID] = SMember(""" u"""TEnumSchemaItem::create(""" u"""function_id_items), true);\n""" u""" params_members[ns_smart_device_link::ns_json_handler::""" - u"""strings::S_MESSAGE_TYPE] = CObjectSchemaItem::SMember(""" + u"""strings::S_MESSAGE_TYPE] = SMember(""" u"""TEnumSchemaItem::create(""" u"""message_type_items), true);\n""" u""" params_members[ns_smart_device_link::ns_json_handler::""" - u"""strings::S_PROTOCOL_VERSION] = CObjectSchemaItem::SMember(""" + u"""strings::S_PROTOCOL_VERSION] = SMember(""" u"""TNumberSchemaItem::create(), true);\n""" u""" params_members[ns_smart_device_link::ns_json_handler::""" - u"""strings::S_PROTOCOL_TYPE] = CObjectSchemaItem::SMember(""" + u"""strings::S_PROTOCOL_TYPE] = SMember(""" u"""TNumberSchemaItem::create(), true);\n""" u""" params_members[ns_smart_device_link::ns_json_handler::""" - u"""strings::S_CORRELATION_ID] = CObjectSchemaItem::SMember(""" + u"""strings::S_CORRELATION_ID] = SMember(""" u"""TNumberSchemaItem::create(), true);\n""" u""" params_members[ns_smart_device_link::ns_json_handler""" - u"""::strings::kCode] = CObjectSchemaItem::SMember(""" + u"""::strings::kCode] = SMember(""" u"""TNumberSchemaItem::create(), true);\n""" u""" params_members[ns_smart_device_link::ns_json_handler::""" - u"""strings::kMessage] = CObjectSchemaItem::SMember(""" + u"""strings::kMessage] = SMember(""" u"""CStringSchemaItem::create(), true);\n""" u"""\n""" - u""" std::map """ + u""" std::map """ u"""root_members_map;\n""" u""" root_members_map[ns_smart_device_link::ns_json_handler::""" - u"""strings::S_PARAMS] = CObjectSchemaItem::SMember(""" + u"""strings::S_PARAMS] = SMember(""" u"""CObjectSchemaItem::create(params_members), true);\n""" u"""\n""" u""" CSmartSchema error_response_schema(CObjectSchemaItem::create(""" diff --git a/tools/InterfaceGenerator/test/generator/generators/test_SmartFactorySDLRPC.py b/tools/InterfaceGenerator/test/generator/generators/test_SmartFactorySDLRPC.py index 35e4aeb6ce0..3c354cd34b6 100755 --- a/tools/InterfaceGenerator/test/generator/generators/test_SmartFactorySDLRPC.py +++ b/tools/InterfaceGenerator/test/generator/generators/test_SmartFactorySDLRPC.py @@ -18,23 +18,23 @@ EXPECTED_NOTIFICATION_RESULT = ( u"""params_members[ns_smart_device_link::ns_json_handler::""" - u"""strings::S_FUNCTION_ID] = CObjectSchemaItem::SMember(""" + u"""strings::S_FUNCTION_ID] = SMember(""" u"""TEnumSchemaItem::create(""" u"""function_id_items), true);\n""" u"""params_members[ns_smart_device_link::ns_json_handler::""" - u"""strings::S_MESSAGE_TYPE] = CObjectSchemaItem::SMember(""" + u"""strings::S_MESSAGE_TYPE] = SMember(""" u"""TEnumSchemaItem::create(""" u"""message_type_items), true);\n""" u"""params_members[ns_smart_device_link::ns_json_handler::""" - u"""strings::S_PROTOCOL_VERSION] = CObjectSchemaItem::SMember(""" + u"""strings::S_PROTOCOL_VERSION] = SMember(""" u"""TNumberSchemaItem::create(), true);\n""" u"""params_members[ns_smart_device_link::ns_json_handler::""" - u"""strings::S_PROTOCOL_TYPE] = CObjectSchemaItem::SMember(""" + u"""strings::S_PROTOCOL_TYPE] = SMember(""" u"""TNumberSchemaItem::create(), true);\n""") EXPECTED_REQ_RESP_RESULT = "".join([EXPECTED_NOTIFICATION_RESULT, ( u"""params_members[ns_smart_device_link::ns_json_handler::""" - u"""strings::S_CORRELATION_ID] = CObjectSchemaItem::SMember(""" + u"""strings::S_CORRELATION_ID] = SMember(""" u"""TNumberSchemaItem::create(), true);\n""")]) DESCRIPTION = [u"Description Line1", u"Description Line2"] diff --git a/tools/InterfaceGenerator/test/generator/generators/test_expected_jsonrpc.cc b/tools/InterfaceGenerator/test/generator/generators/test_expected_jsonrpc.cc index 49369d25591..05795ecf3bf 100644 --- a/tools/InterfaceGenerator/test/generator/generators/test_expected_jsonrpc.cc +++ b/tools/InterfaceGenerator/test/generator/generators/test_expected_jsonrpc.cc @@ -95,17 +95,17 @@ void XXX::YYY::ZZZ::Test::InitFunctionSchemes( const TStructsSchemaItems &struct_schema_items, const std::set &function_id_items, const std::set &message_type_items) { - std::map params_members; - params_members[ns_smart_device_link::ns_json_handler::strings::S_FUNCTION_ID] = CObjectSchemaItem::SMember(TEnumSchemaItem::create(function_id_items), true); - params_members[ns_smart_device_link::ns_json_handler::strings::S_MESSAGE_TYPE] = CObjectSchemaItem::SMember(TEnumSchemaItem::create(message_type_items), true); - params_members[ns_smart_device_link::ns_json_handler::strings::S_PROTOCOL_VERSION] = CObjectSchemaItem::SMember(TNumberSchemaItem::create(), true); - params_members[ns_smart_device_link::ns_json_handler::strings::S_PROTOCOL_TYPE] = CObjectSchemaItem::SMember(TNumberSchemaItem::create(), true); - params_members[ns_smart_device_link::ns_json_handler::strings::S_CORRELATION_ID] = CObjectSchemaItem::SMember(TNumberSchemaItem::create(), true); - params_members[ns_smart_device_link::ns_json_handler::strings::kCode] = CObjectSchemaItem::SMember(TNumberSchemaItem::create(), true); - params_members[ns_smart_device_link::ns_json_handler::strings::kMessage] = CObjectSchemaItem::SMember(CStringSchemaItem::create(), true); - - std::map root_members_map; - root_members_map[ns_smart_device_link::ns_json_handler::strings::S_PARAMS] = CObjectSchemaItem::SMember(CObjectSchemaItem::create(params_members), true); + std::map params_members; + params_members[ns_smart_device_link::ns_json_handler::strings::S_FUNCTION_ID] = SMember(TEnumSchemaItem::create(function_id_items), true); + params_members[ns_smart_device_link::ns_json_handler::strings::S_MESSAGE_TYPE] = SMember(TEnumSchemaItem::create(message_type_items), true); + params_members[ns_smart_device_link::ns_json_handler::strings::S_PROTOCOL_VERSION] = SMember(TNumberSchemaItem::create(), true); + params_members[ns_smart_device_link::ns_json_handler::strings::S_PROTOCOL_TYPE] = SMember(TNumberSchemaItem::create(), true); + params_members[ns_smart_device_link::ns_json_handler::strings::S_CORRELATION_ID] = SMember(TNumberSchemaItem::create(), true); + params_members[ns_smart_device_link::ns_json_handler::strings::kCode] = SMember(TNumberSchemaItem::create(), true); + params_members[ns_smart_device_link::ns_json_handler::strings::kMessage] = SMember(CStringSchemaItem::create(), true); + + std::map root_members_map; + root_members_map[ns_smart_device_link::ns_json_handler::strings::S_PARAMS] = SMember(CObjectSchemaItem::create(params_members), true); CSmartSchema error_response_schema(CObjectSchemaItem::create(root_members_map)); @@ -147,21 +147,21 @@ CSmartSchema XXX::YYY::ZZZ::Test::InitFunction_name1_request( // Function parameter param2. TSharedPtr param2_SchemaItem = TEnumSchemaItem::create(param2_allowed_enum_subset_values, TSchemaItemParameter(name1)); - std::map schema_members; + std::map schema_members; - schema_members["param1"] = CObjectSchemaItem::SMember(param1_SchemaItem, true); - schema_members["param2"] = CObjectSchemaItem::SMember(param2_SchemaItem, true); + schema_members["param1"] = SMember(param1_SchemaItem, true); + schema_members["param2"] = SMember(param2_SchemaItem, true); - std::map params_members; - params_members[ns_smart_device_link::ns_json_handler::strings::S_FUNCTION_ID] = CObjectSchemaItem::SMember(TEnumSchemaItem::create(function_id_items), true); - params_members[ns_smart_device_link::ns_json_handler::strings::S_MESSAGE_TYPE] = CObjectSchemaItem::SMember(TEnumSchemaItem::create(message_type_items), true); - params_members[ns_smart_device_link::ns_json_handler::strings::S_PROTOCOL_VERSION] = CObjectSchemaItem::SMember(TNumberSchemaItem::create(), true); - params_members[ns_smart_device_link::ns_json_handler::strings::S_PROTOCOL_TYPE] = CObjectSchemaItem::SMember(TNumberSchemaItem::create(), true); - params_members[ns_smart_device_link::ns_json_handler::strings::S_CORRELATION_ID] = CObjectSchemaItem::SMember(TNumberSchemaItem::create(), true); + std::map params_members; + params_members[ns_smart_device_link::ns_json_handler::strings::S_FUNCTION_ID] = SMember(TEnumSchemaItem::create(function_id_items), true); + params_members[ns_smart_device_link::ns_json_handler::strings::S_MESSAGE_TYPE] = SMember(TEnumSchemaItem::create(message_type_items), true); + params_members[ns_smart_device_link::ns_json_handler::strings::S_PROTOCOL_VERSION] = SMember(TNumberSchemaItem::create(), true); + params_members[ns_smart_device_link::ns_json_handler::strings::S_PROTOCOL_TYPE] = SMember(TNumberSchemaItem::create(), true); + params_members[ns_smart_device_link::ns_json_handler::strings::S_CORRELATION_ID] = SMember(TNumberSchemaItem::create(), true); - std::map root_members_map; - root_members_map[ns_smart_device_link::ns_json_handler::strings::S_MSG_PARAMS] = CObjectSchemaItem::SMember(CObjectSchemaItem::create(schema_members), true); - root_members_map[ns_smart_device_link::ns_json_handler::strings::S_PARAMS] = CObjectSchemaItem::SMember(CObjectSchemaItem::create(params_members), true); + std::map root_members_map; + root_members_map[ns_smart_device_link::ns_json_handler::strings::S_MSG_PARAMS] = SMember(CObjectSchemaItem::create(schema_members), true); + root_members_map[ns_smart_device_link::ns_json_handler::strings::S_PARAMS] = SMember(CObjectSchemaItem::create(params_members), true); return CSmartSchema(CObjectSchemaItem::create(root_members_map)); } @@ -170,19 +170,19 @@ CSmartSchema XXX::YYY::ZZZ::Test::InitFunction_val_1_response( const TStructsSchemaItems &struct_schema_items, const std::set &function_id_items, const std::set &message_type_items) { - std::map schema_members; + std::map schema_members; - std::map params_members; - params_members[ns_smart_device_link::ns_json_handler::strings::S_FUNCTION_ID] = CObjectSchemaItem::SMember(TEnumSchemaItem::create(function_id_items), true); - params_members[ns_smart_device_link::ns_json_handler::strings::S_MESSAGE_TYPE] = CObjectSchemaItem::SMember(TEnumSchemaItem::create(message_type_items), true); - params_members[ns_smart_device_link::ns_json_handler::strings::S_PROTOCOL_VERSION] = CObjectSchemaItem::SMember(TNumberSchemaItem::create(), true); - params_members[ns_smart_device_link::ns_json_handler::strings::S_PROTOCOL_TYPE] = CObjectSchemaItem::SMember(TNumberSchemaItem::create(), true); - params_members[ns_smart_device_link::ns_json_handler::strings::S_CORRELATION_ID] = CObjectSchemaItem::SMember(TNumberSchemaItem::create(), true); - params_members[ns_smart_device_link::ns_json_handler::strings::kCode] = CObjectSchemaItem::SMember(TNumberSchemaItem::create(), true); + std::map params_members; + params_members[ns_smart_device_link::ns_json_handler::strings::S_FUNCTION_ID] = SMember(TEnumSchemaItem::create(function_id_items), true); + params_members[ns_smart_device_link::ns_json_handler::strings::S_MESSAGE_TYPE] = SMember(TEnumSchemaItem::create(message_type_items), true); + params_members[ns_smart_device_link::ns_json_handler::strings::S_PROTOCOL_VERSION] = SMember(TNumberSchemaItem::create(), true); + params_members[ns_smart_device_link::ns_json_handler::strings::S_PROTOCOL_TYPE] = SMember(TNumberSchemaItem::create(), true); + params_members[ns_smart_device_link::ns_json_handler::strings::S_CORRELATION_ID] = SMember(TNumberSchemaItem::create(), true); + params_members[ns_smart_device_link::ns_json_handler::strings::kCode] = SMember(TNumberSchemaItem::create(), true); - std::map root_members_map; - root_members_map[ns_smart_device_link::ns_json_handler::strings::S_MSG_PARAMS] = CObjectSchemaItem::SMember(CObjectSchemaItem::create(schema_members), true); - root_members_map[ns_smart_device_link::ns_json_handler::strings::S_PARAMS] = CObjectSchemaItem::SMember(CObjectSchemaItem::create(params_members), true); + std::map root_members_map; + root_members_map[ns_smart_device_link::ns_json_handler::strings::S_MSG_PARAMS] = SMember(CObjectSchemaItem::create(schema_members), true); + root_members_map[ns_smart_device_link::ns_json_handler::strings::S_PARAMS] = SMember(CObjectSchemaItem::create(params_members), true); return CSmartSchema(CObjectSchemaItem::create(root_members_map)); } @@ -191,17 +191,17 @@ CSmartSchema XXX::YYY::ZZZ::Test::InitFunction_val_2_notification( const TStructsSchemaItems &struct_schema_items, const std::set &function_id_items, const std::set &message_type_items) { - std::map schema_members; + std::map schema_members; - std::map params_members; - params_members[ns_smart_device_link::ns_json_handler::strings::S_FUNCTION_ID] = CObjectSchemaItem::SMember(TEnumSchemaItem::create(function_id_items), true); - params_members[ns_smart_device_link::ns_json_handler::strings::S_MESSAGE_TYPE] = CObjectSchemaItem::SMember(TEnumSchemaItem::create(message_type_items), true); - params_members[ns_smart_device_link::ns_json_handler::strings::S_PROTOCOL_VERSION] = CObjectSchemaItem::SMember(TNumberSchemaItem::create(), true); - params_members[ns_smart_device_link::ns_json_handler::strings::S_PROTOCOL_TYPE] = CObjectSchemaItem::SMember(TNumberSchemaItem::create(), true); + std::map params_members; + params_members[ns_smart_device_link::ns_json_handler::strings::S_FUNCTION_ID] = SMember(TEnumSchemaItem::create(function_id_items), true); + params_members[ns_smart_device_link::ns_json_handler::strings::S_MESSAGE_TYPE] = SMember(TEnumSchemaItem::create(message_type_items), true); + params_members[ns_smart_device_link::ns_json_handler::strings::S_PROTOCOL_VERSION] = SMember(TNumberSchemaItem::create(), true); + params_members[ns_smart_device_link::ns_json_handler::strings::S_PROTOCOL_TYPE] = SMember(TNumberSchemaItem::create(), true); - std::map root_members_map; - root_members_map[ns_smart_device_link::ns_json_handler::strings::S_MSG_PARAMS] = CObjectSchemaItem::SMember(CObjectSchemaItem::create(schema_members), true); - root_members_map[ns_smart_device_link::ns_json_handler::strings::S_PARAMS] = CObjectSchemaItem::SMember(CObjectSchemaItem::create(params_members), true); + std::map root_members_map; + root_members_map[ns_smart_device_link::ns_json_handler::strings::S_MSG_PARAMS] = SMember(CObjectSchemaItem::create(schema_members), true); + root_members_map[ns_smart_device_link::ns_json_handler::strings::S_PARAMS] = SMember(CObjectSchemaItem::create(params_members), true); return CSmartSchema(CObjectSchemaItem::create(root_members_map)); } @@ -270,28 +270,28 @@ TSharedPtr XXX::YYY::ZZZ::Test::InitStructSchemaItem_Struct1( // Struct member arrayOfEnum6. TSharedPtr arrayOfEnum6_SchemaItem = CArraySchemaItem::create(TEnumSchemaItem::create(sub3_allowed_enum_subset_values, TSchemaItemParameter()), TSchemaItemParameter(10), TSchemaItemParameter(43)); - std::map schema_members; - - schema_members["intParam"] = CObjectSchemaItem::SMember(intParam_SchemaItem, true); - schema_members["doubleParam"] = CObjectSchemaItem::SMember(doubleParam_SchemaItem, false); - schema_members["boolParam"] = CObjectSchemaItem::SMember(boolParam_SchemaItem, true); - schema_members["structParam"] = CObjectSchemaItem::SMember(structParam_SchemaItem, true); - schema_members["enumParam"] = CObjectSchemaItem::SMember(enumParam_SchemaItem, true); - schema_members["enumParam1"] = CObjectSchemaItem::SMember(enumParam1_SchemaItem, true); - schema_members["enumSubset1"] = CObjectSchemaItem::SMember(enumSubset1_SchemaItem, false); - schema_members["arrayOfInt"] = CObjectSchemaItem::SMember(arrayOfInt_SchemaItem, false); - schema_members["arrayOfEnum1"] = CObjectSchemaItem::SMember(arrayOfEnum1_SchemaItem, false); - schema_members["arrayOfEnum3"] = CObjectSchemaItem::SMember(arrayOfEnum3_SchemaItem, true); - schema_members["arrayOfEnum4"] = CObjectSchemaItem::SMember(arrayOfEnum4_SchemaItem, true); - schema_members["arrayOfEnum5"] = CObjectSchemaItem::SMember(arrayOfEnum5_SchemaItem, true); - schema_members["arrayOfEnum6"] = CObjectSchemaItem::SMember(arrayOfEnum6_SchemaItem, true); + std::map schema_members; + + schema_members["intParam"] = SMember(intParam_SchemaItem, true); + schema_members["doubleParam"] = SMember(doubleParam_SchemaItem, false); + schema_members["boolParam"] = SMember(boolParam_SchemaItem, true); + schema_members["structParam"] = SMember(structParam_SchemaItem, true); + schema_members["enumParam"] = SMember(enumParam_SchemaItem, true); + schema_members["enumParam1"] = SMember(enumParam1_SchemaItem, true); + schema_members["enumSubset1"] = SMember(enumSubset1_SchemaItem, false); + schema_members["arrayOfInt"] = SMember(arrayOfInt_SchemaItem, false); + schema_members["arrayOfEnum1"] = SMember(arrayOfEnum1_SchemaItem, false); + schema_members["arrayOfEnum3"] = SMember(arrayOfEnum3_SchemaItem, true); + schema_members["arrayOfEnum4"] = SMember(arrayOfEnum4_SchemaItem, true); + schema_members["arrayOfEnum5"] = SMember(arrayOfEnum5_SchemaItem, true); + schema_members["arrayOfEnum6"] = SMember(arrayOfEnum6_SchemaItem, true); return CObjectSchemaItem::create(schema_members); } TSharedPtr XXX::YYY::ZZZ::Test::InitStructSchemaItem_Struct2( const TStructsSchemaItems &struct_schema_items) { - std::map schema_members; + std::map schema_members; return CObjectSchemaItem::create(schema_members); } diff --git a/tools/InterfaceGenerator/test/generator/generators/test_expected_sdlrpc.cc b/tools/InterfaceGenerator/test/generator/generators/test_expected_sdlrpc.cc index a62f485eb97..30b9b645abf 100644 --- a/tools/InterfaceGenerator/test/generator/generators/test_expected_sdlrpc.cc +++ b/tools/InterfaceGenerator/test/generator/generators/test_expected_sdlrpc.cc @@ -130,21 +130,21 @@ CSmartSchema XXX::YYY::ZZZ::Test::InitFunction_name1_request( // Function parameter param2. TSharedPtr param2_SchemaItem = TEnumSchemaItem::create(param2_allowed_enum_subset_values, TSchemaItemParameter(name1)); - std::map schema_members; + std::map schema_members; - schema_members["param1"] = CObjectSchemaItem::SMember(param1_SchemaItem, true); - schema_members["param2"] = CObjectSchemaItem::SMember(param2_SchemaItem, true); + schema_members["param1"] = SMember(param1_SchemaItem, true); + schema_members["param2"] = SMember(param2_SchemaItem, true); - std::map params_members; - params_members[ns_smart_device_link::ns_json_handler::strings::S_FUNCTION_ID] = CObjectSchemaItem::SMember(TEnumSchemaItem::create(function_id_items), true); - params_members[ns_smart_device_link::ns_json_handler::strings::S_MESSAGE_TYPE] = CObjectSchemaItem::SMember(TEnumSchemaItem::create(message_type_items), true); - params_members[ns_smart_device_link::ns_json_handler::strings::S_PROTOCOL_VERSION] = CObjectSchemaItem::SMember(TNumberSchemaItem::create(), true); - params_members[ns_smart_device_link::ns_json_handler::strings::S_PROTOCOL_TYPE] = CObjectSchemaItem::SMember(TNumberSchemaItem::create(), true); - params_members[ns_smart_device_link::ns_json_handler::strings::S_CORRELATION_ID] = CObjectSchemaItem::SMember(TNumberSchemaItem::create(), true); + std::map params_members; + params_members[ns_smart_device_link::ns_json_handler::strings::S_FUNCTION_ID] = SMember(TEnumSchemaItem::create(function_id_items), true); + params_members[ns_smart_device_link::ns_json_handler::strings::S_MESSAGE_TYPE] = SMember(TEnumSchemaItem::create(message_type_items), true); + params_members[ns_smart_device_link::ns_json_handler::strings::S_PROTOCOL_VERSION] = SMember(TNumberSchemaItem::create(), true); + params_members[ns_smart_device_link::ns_json_handler::strings::S_PROTOCOL_TYPE] = SMember(TNumberSchemaItem::create(), true); + params_members[ns_smart_device_link::ns_json_handler::strings::S_CORRELATION_ID] = SMember(TNumberSchemaItem::create(), true); - std::map root_members_map; - root_members_map[ns_smart_device_link::ns_json_handler::strings::S_MSG_PARAMS] = CObjectSchemaItem::SMember(CObjectSchemaItem::create(schema_members), true); - root_members_map[ns_smart_device_link::ns_json_handler::strings::S_PARAMS] = CObjectSchemaItem::SMember(CObjectSchemaItem::create(params_members), true); + std::map root_members_map; + root_members_map[ns_smart_device_link::ns_json_handler::strings::S_MSG_PARAMS] = SMember(CObjectSchemaItem::create(schema_members), true); + root_members_map[ns_smart_device_link::ns_json_handler::strings::S_PARAMS] = SMember(CObjectSchemaItem::create(params_members), true); return CSmartSchema(CObjectSchemaItem::create(root_members_map)); } @@ -153,18 +153,18 @@ CSmartSchema XXX::YYY::ZZZ::Test::InitFunction_val_1_response( const TStructsSchemaItems &struct_schema_items, const std::set &function_id_items, const std::set &message_type_items) { - std::map schema_members; + std::map schema_members; - std::map params_members; - params_members[ns_smart_device_link::ns_json_handler::strings::S_FUNCTION_ID] = CObjectSchemaItem::SMember(TEnumSchemaItem::create(function_id_items), true); - params_members[ns_smart_device_link::ns_json_handler::strings::S_MESSAGE_TYPE] = CObjectSchemaItem::SMember(TEnumSchemaItem::create(message_type_items), true); - params_members[ns_smart_device_link::ns_json_handler::strings::S_PROTOCOL_VERSION] = CObjectSchemaItem::SMember(TNumberSchemaItem::create(), true); - params_members[ns_smart_device_link::ns_json_handler::strings::S_PROTOCOL_TYPE] = CObjectSchemaItem::SMember(TNumberSchemaItem::create(), true); - params_members[ns_smart_device_link::ns_json_handler::strings::S_CORRELATION_ID] = CObjectSchemaItem::SMember(TNumberSchemaItem::create(), true); + std::map params_members; + params_members[ns_smart_device_link::ns_json_handler::strings::S_FUNCTION_ID] = SMember(TEnumSchemaItem::create(function_id_items), true); + params_members[ns_smart_device_link::ns_json_handler::strings::S_MESSAGE_TYPE] = SMember(TEnumSchemaItem::create(message_type_items), true); + params_members[ns_smart_device_link::ns_json_handler::strings::S_PROTOCOL_VERSION] = SMember(TNumberSchemaItem::create(), true); + params_members[ns_smart_device_link::ns_json_handler::strings::S_PROTOCOL_TYPE] = SMember(TNumberSchemaItem::create(), true); + params_members[ns_smart_device_link::ns_json_handler::strings::S_CORRELATION_ID] = SMember(TNumberSchemaItem::create(), true); - std::map root_members_map; - root_members_map[ns_smart_device_link::ns_json_handler::strings::S_MSG_PARAMS] = CObjectSchemaItem::SMember(CObjectSchemaItem::create(schema_members), true); - root_members_map[ns_smart_device_link::ns_json_handler::strings::S_PARAMS] = CObjectSchemaItem::SMember(CObjectSchemaItem::create(params_members), true); + std::map root_members_map; + root_members_map[ns_smart_device_link::ns_json_handler::strings::S_MSG_PARAMS] = SMember(CObjectSchemaItem::create(schema_members), true); + root_members_map[ns_smart_device_link::ns_json_handler::strings::S_PARAMS] = SMember(CObjectSchemaItem::create(params_members), true); return CSmartSchema(CObjectSchemaItem::create(root_members_map)); } @@ -173,17 +173,17 @@ CSmartSchema XXX::YYY::ZZZ::Test::InitFunction_val_2_notification( const TStructsSchemaItems &struct_schema_items, const std::set &function_id_items, const std::set &message_type_items) { - std::map schema_members; + std::map schema_members; - std::map params_members; - params_members[ns_smart_device_link::ns_json_handler::strings::S_FUNCTION_ID] = CObjectSchemaItem::SMember(TEnumSchemaItem::create(function_id_items), true); - params_members[ns_smart_device_link::ns_json_handler::strings::S_MESSAGE_TYPE] = CObjectSchemaItem::SMember(TEnumSchemaItem::create(message_type_items), true); - params_members[ns_smart_device_link::ns_json_handler::strings::S_PROTOCOL_VERSION] = CObjectSchemaItem::SMember(TNumberSchemaItem::create(), true); - params_members[ns_smart_device_link::ns_json_handler::strings::S_PROTOCOL_TYPE] = CObjectSchemaItem::SMember(TNumberSchemaItem::create(), true); + std::map params_members; + params_members[ns_smart_device_link::ns_json_handler::strings::S_FUNCTION_ID] = SMember(TEnumSchemaItem::create(function_id_items), true); + params_members[ns_smart_device_link::ns_json_handler::strings::S_MESSAGE_TYPE] = SMember(TEnumSchemaItem::create(message_type_items), true); + params_members[ns_smart_device_link::ns_json_handler::strings::S_PROTOCOL_VERSION] = SMember(TNumberSchemaItem::create(), true); + params_members[ns_smart_device_link::ns_json_handler::strings::S_PROTOCOL_TYPE] = SMember(TNumberSchemaItem::create(), true); - std::map root_members_map; - root_members_map[ns_smart_device_link::ns_json_handler::strings::S_MSG_PARAMS] = CObjectSchemaItem::SMember(CObjectSchemaItem::create(schema_members), true); - root_members_map[ns_smart_device_link::ns_json_handler::strings::S_PARAMS] = CObjectSchemaItem::SMember(CObjectSchemaItem::create(params_members), true); + std::map root_members_map; + root_members_map[ns_smart_device_link::ns_json_handler::strings::S_MSG_PARAMS] = SMember(CObjectSchemaItem::create(schema_members), true); + root_members_map[ns_smart_device_link::ns_json_handler::strings::S_PARAMS] = SMember(CObjectSchemaItem::create(params_members), true); return CSmartSchema(CObjectSchemaItem::create(root_members_map)); } @@ -252,28 +252,28 @@ TSharedPtr XXX::YYY::ZZZ::Test::InitStructSchemaItem_Struct1( // Struct member arrayOfEnum6. TSharedPtr arrayOfEnum6_SchemaItem = CArraySchemaItem::create(TEnumSchemaItem::create(sub3_allowed_enum_subset_values, TSchemaItemParameter()), TSchemaItemParameter(10), TSchemaItemParameter(43)); - std::map schema_members; - - schema_members["intParam"] = CObjectSchemaItem::SMember(intParam_SchemaItem, true); - schema_members["doubleParam"] = CObjectSchemaItem::SMember(doubleParam_SchemaItem, false); - schema_members["boolParam"] = CObjectSchemaItem::SMember(boolParam_SchemaItem, true); - schema_members["structParam"] = CObjectSchemaItem::SMember(structParam_SchemaItem, true); - schema_members["enumParam"] = CObjectSchemaItem::SMember(enumParam_SchemaItem, true); - schema_members["enumParam1"] = CObjectSchemaItem::SMember(enumParam1_SchemaItem, true); - schema_members["enumSubset1"] = CObjectSchemaItem::SMember(enumSubset1_SchemaItem, false); - schema_members["arrayOfInt"] = CObjectSchemaItem::SMember(arrayOfInt_SchemaItem, false); - schema_members["arrayOfEnum1"] = CObjectSchemaItem::SMember(arrayOfEnum1_SchemaItem, false); - schema_members["arrayOfEnum3"] = CObjectSchemaItem::SMember(arrayOfEnum3_SchemaItem, true); - schema_members["arrayOfEnum4"] = CObjectSchemaItem::SMember(arrayOfEnum4_SchemaItem, true); - schema_members["arrayOfEnum5"] = CObjectSchemaItem::SMember(arrayOfEnum5_SchemaItem, true); - schema_members["arrayOfEnum6"] = CObjectSchemaItem::SMember(arrayOfEnum6_SchemaItem, true); + std::map schema_members; + + schema_members["intParam"] = SMember(intParam_SchemaItem, true); + schema_members["doubleParam"] = SMember(doubleParam_SchemaItem, false); + schema_members["boolParam"] = SMember(boolParam_SchemaItem, true); + schema_members["structParam"] = SMember(structParam_SchemaItem, true); + schema_members["enumParam"] = SMember(enumParam_SchemaItem, true); + schema_members["enumParam1"] = SMember(enumParam1_SchemaItem, true); + schema_members["enumSubset1"] = SMember(enumSubset1_SchemaItem, false); + schema_members["arrayOfInt"] = SMember(arrayOfInt_SchemaItem, false); + schema_members["arrayOfEnum1"] = SMember(arrayOfEnum1_SchemaItem, false); + schema_members["arrayOfEnum3"] = SMember(arrayOfEnum3_SchemaItem, true); + schema_members["arrayOfEnum4"] = SMember(arrayOfEnum4_SchemaItem, true); + schema_members["arrayOfEnum5"] = SMember(arrayOfEnum5_SchemaItem, true); + schema_members["arrayOfEnum6"] = SMember(arrayOfEnum6_SchemaItem, true); return CObjectSchemaItem::create(schema_members); } TSharedPtr XXX::YYY::ZZZ::Test::InitStructSchemaItem_Struct2( const TStructsSchemaItems &struct_schema_items) { - std::map schema_members; + std::map schema_members; return CObjectSchemaItem::create(schema_members); } diff --git a/tools/cmake/helpers/generators.cmake b/tools/cmake/helpers/generators.cmake index 64f7c1f670c..dbdb725e49b 100644 --- a/tools/cmake/helpers/generators.cmake +++ b/tools/cmake/helpers/generators.cmake @@ -41,6 +41,19 @@ set(INTEFRACE_GENERATOR "${CMAKE_SOURCE_DIR}/tools/InterfaceGenerator/Generator. set(INTEFRACE_GENERATOR_CMD ${PYTHON_EXECUTABLE} -B ${INTEFRACE_GENERATOR}) file(GLOB_RECURSE INTERFACE_GENERATOR_DEPENDENCIES "${CMAKE_SOURCE_DIR}/tools/InterfaceGenerator/*.*") +macro(generate_policy_types GENERATED_FILES + ARG_FULL_XML_NAME + ARG_NAMESPACE + PARSER_TYPE) + add_custom_command( + OUTPUT ${GENERATED_FILES} + COMMAND ${INTEFRACE_GENERATOR_CMD} ${ARG_FULL_XML_NAME} ${ARG_NAMESPACE} ${CMAKE_CURRENT_BINARY_DIR} "--parser-type" "${PARSER_TYPE}" + DEPENDS ${INTERFACE_GENERATOR_DEPENDENCIES} ${ARG_FULL_XML_NAME} + COMMENT "Generating files:\n\t${GENERATED_FILES}\nfrom:\n\t${ARG_FULL_XML_NAME}\n\ + ${INTEFRACE_GENERATOR_CMD} ${ARG_FULL_XML_NAME} ${ARG_NAMESPACE} ${CMAKE_CURRENT_BINARY_DIR} --parser-type ${PARSER_TYPE}" + VERBATIM) +endmacro() + macro(generate_interface 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 diff --git a/tools/infrastructure/check_style.sh b/tools/infrastructure/check_style.sh index 08ae1b9860a..006dd340d97 100755 --- a/tools/infrastructure/check_style.sh +++ b/tools/infrastructure/check_style.sh @@ -27,7 +27,7 @@ # 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. -FORMATER=clang-format-3.6 +FORMATER=clang-format-6.0 INSTALL_CMD="sudo apt-get install -f $FORMATER" if [ "$1" = "--help" ] diff --git a/tools/infrastructure/git-hooks/pre-commit b/tools/infrastructure/git-hooks/pre-commit index 9c46f195f36..710f0656c38 100755 --- a/tools/infrastructure/git-hooks/pre-commit +++ b/tools/infrastructure/git-hooks/pre-commit @@ -72,10 +72,10 @@ if [ "$?" -ne "0" ]; then exit 1 fi -# Auto update c++ files with clang-format-3.6 -CLANG_FORMAT=clang-format-3.6 +# Auto update c++ files with clang-format-6.0 +CLANG_FORMAT=clang-format-6.0 # Verify clang-format -CLANG_FORMAT_REQUIRED_VERSION=3.6 +CLANG_FORMAT_REQUIRED_VERSION=6.0 CLANG_FORMAT_CURRENT_VERSION=$($CLANG_FORMAT -version) if [[ $CLANG_FORMAT_CURRENT_VERSION != *$CLANG_FORMAT_REQUIRED_VERSION* ]] then diff --git a/tools/policy_table_validator/CMakeLists.txt b/tools/policy_table_validator/CMakeLists.txt index eabe4cfd5c4..6b9f26f01ad 100644 --- a/tools/policy_table_validator/CMakeLists.txt +++ b/tools/policy_table_validator/CMakeLists.txt @@ -3,14 +3,18 @@ include_directories( ${CMAKE_SOURCE_DIR}/src/components/rpc_base/include/ ${CMAKE_SOURCE_DIR}/src/components/utils/include/ - ${JSONCPP_INCLUDE_DIRECTORY} + ${COMPONENTS_DIR}/smart_objects/include/ + ${JSONCPP_INCLUDE_DIRECTORY} + ${BOOST_INCLUDE_DIR} ) message(STATUS "Using ${EXTENDED_POLICY} policy mode") if (${EXTENDED_POLICY} STREQUAL "EXTERNAL_PROPRIETARY") include_directories(${CMAKE_SOURCE_DIR}/src/components/policy/policy_external/include/) + include_directories(${CMAKE_BINARY_DIR}/src/components/policy/policy_external/) else() include_directories(${CMAKE_SOURCE_DIR}/src/components/policy/policy_regular/include/) + include_directories(${CMAKE_BINARY_DIR}/src/components/policy/policy_regular/) endif() link_directories (